Skip to content

Commit

Permalink
Fixed issue #T136: Error Message Needs Rewording (#2135)
Browse files Browse the repository at this point in the history
* Fixed issue #14557: User with very limited rights is allowed to set expiry date at survey list screen

* Fixed issue #T136: Error Message Needs Rewording

Co-authored-by: encuestabizdevgit <devgit@encuesta.biz>
  • Loading branch information
gabrieljenik and encuestabizdevgit committed Nov 5, 2021
1 parent b1921e7 commit 537092d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
17 changes: 14 additions & 3 deletions application/controllers/admin/surveyadmin.php
Expand Up @@ -59,10 +59,13 @@ public function deleteMultiple()
$aSurveys = json_decode(Yii::app()->request->getPost('sItems'));
$aResults = array();
foreach ($aSurveys as $iSurveyID) {
$oSurvey = Survey::model()->findByPk($iSurveyID);
$aResults[$iSurveyID]['title'] = $oSurvey->correct_relation_defaultlanguage->surveyls_title;
if (Permission::model()->hasSurveyPermission($iSurveyID, 'survey', 'delete')) {
$oSurvey = Survey::model()->findByPk($iSurveyID);
$aResults[$iSurveyID]['title'] = $oSurvey->correct_relation_defaultlanguage->surveyls_title;
$aResults[$iSurveyID]['result'] = Survey::model()->deleteSurvey($iSurveyID);
} else {
$aResults[$iSurveyID]['result'] = false;
$aResults[$iSurveyID]['error'] = gT("User does not have valid permissions");
}
}

Expand Down Expand Up @@ -366,7 +369,12 @@ public function changeMultipleSurveyGroup()
$oSurvey = Survey::model()->findByPk($iSurveyID);
$oSurvey->gsid = $iSurveyGroupId;
$aResults[$iSurveyID]['title'] = $oSurvey->correct_relation_defaultlanguage->surveyls_title;
$aResults[$iSurveyID]['result']= $oSurvey->save();
if ($oSurvey->save()) {
$aResults[$iSurveyID]['result'] = true;
} else {
$aResults[$iSurveyID]['result'] = false;
$aResults[$iSurveyID]['error'] = gT("Survey update failed");
}
}

Yii::app()->getController()->renderPartial('ext.admin.survey.ListSurveysWidget.views.massive_actions._action_results', array('aResults'=>$aResults,'successLabel'=>gT("Success")));
Expand Down Expand Up @@ -396,6 +404,7 @@ public function changetemplate($iSurveyID, $template, $aResults = null, $bReturn
if (!empty($bReturn)){
$aResults[$iSurveyID]['title'] = $survey->correct_relation_defaultlanguage->surveyls_title;
$aResults[$iSurveyID]['result'] = false;
$aResults[$iSurveyID]['error'] = gT("User does not have valid permissions");
return $aResults;
}else{
die('No permission');
Expand Down Expand Up @@ -1999,13 +2008,15 @@ public function expireMultipleSurveys()
// We check the permission after retrieving the title because we need it anyway.
if (!Permission::model()->hasSurveyPermission($sid, 'surveysettings', 'update')) {
$aResults[$survey->primaryKey]['result'] = false;
$aResults[$survey->primaryKey]['error'] = gT("User does not have valid permissions");
continue;
}
$survey->expires = $expires;
if ($survey->save()) {
$aResults[$survey->primaryKey]['result'] = true;
} else {
$aResults[$survey->primaryKey]['result'] = false;
$aResults[$survey->primaryKey]['error'] = gT("Survey update failed");
}
}
Yii::app()->getController()->renderPartial('ext.admin.survey.ListSurveysWidget.views.massive_actions._action_results', array('aResults'=>$aResults, 'successLabel'=>gT('OK')));
Expand Down
Expand Up @@ -30,7 +30,7 @@
</td>
<?php else: ?>
<td class="text-warning">
<?php eT('Error'); ?>
<?= empty($result['error']) ? gT('Error') : sprintf(gT("Unable to perform function - %s"), $result['error']) ?>
</td>
<?php endif;?>
</tr>
Expand Down

0 comments on commit 537092d

Please sign in to comment.