Skip to content

Commit

Permalink
Fixed issue: Cannot deactivate survey properly if user has global sur…
Browse files Browse the repository at this point in the history
…vey permissions, but is not allowed to access the assigned SurveyGroup
  • Loading branch information
c-schmitz committed Nov 2, 2023
1 parent 4ef1693 commit 2227098
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
1 change: 1 addition & 0 deletions application/controllers/SurveyAdministrationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -1616,6 +1616,7 @@ public function actionDeactivate()

// Load the active record again, as there have been sporadic errors with the dataset not being updated
$survey = Survey::model()->findByAttributes(array('sid' => $iSurveyID));
$survey->scenario = 'activationStateChange';
$survey->active = 'N';
$survey->save();

Expand Down
2 changes: 1 addition & 1 deletion application/models/Survey.php
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ public function rules()
//array('bounce_email', 'LSYii_EmailIDNAValidator', 'allowEmpty'=>true),
array('active', 'in', 'range' => array('Y', 'N'), 'allowEmpty' => true),
array('gsid', 'numerical', 'min' => '0', 'allowEmpty' => true),
array('gsid', 'in', 'range' => array_keys(SurveysGroups::getSurveyGroupsList()), 'allowEmpty' => true, 'message' => gT("You are not allowed to use this group")),
array('gsid', 'in', 'range' => array_keys(SurveysGroups::getSurveyGroupsList()), 'allowEmpty' => true, 'message' => gT("You are not allowed to use this group"), 'except' => 'activationStateChange'),
array('anonymized', 'in', 'range' => array('Y', 'N', 'I'), 'allowEmpty' => true),
array('savetimings', 'in', 'range' => array('Y', 'N', 'I'), 'allowEmpty' => true),
array('datestamp', 'in', 'range' => array('Y', 'N', 'I'), 'allowEmpty' => true),
Expand Down
10 changes: 4 additions & 6 deletions application/models/SurveyActivator.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,10 @@ public function activate()
return ['error' => $this->error];
}

Yii::app()->db->createCommand()->update(
Survey::model()->tableName(),
['active' => 'Y'],
'sid=:sid',
[':sid' => $this->survey->primaryKey]
);
$survey = Survey::model()->findByAttributes(array('sid' => $this->survey->primaryKey));
$survey->scenario = 'activationStateChange';
$survey->active = 'Y';
$survey->save();

$aResult = array(
'status' => 'OK',
Expand Down

0 comments on commit 2227098

Please sign in to comment.