Skip to content

Commit

Permalink
Dev Implemented multiple survey deactivation.
Browse files Browse the repository at this point in the history
  • Loading branch information
SamMousa committed Aug 20, 2015
1 parent 3871747 commit 5c9782b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
21 changes: 21 additions & 0 deletions application/controllers/SurveysController.php
Expand Up @@ -339,6 +339,27 @@ public function actionDeleteMultiple(array $ids) {
$this->redirect(['surveys/index']);
}

public function actionDeactivateMultiple(array $ids) {
$count = 0;
foreach($ids as $id) {
$survey = $this->loadModel($id);
if ($survey->isActive
&& App()->user->checkAccess('survey', [
'entity' => 'survey',
'entity_id' => $survey->primaryKey,
'crud' => 'update'
])) {
if ($survey->deactivate()) {
$count++;
}

}

}
App()->user->setFlash('success', gT("Surveys deactivated") . " " . $count);
$this->redirect(['surveys/index']);
}

/**
* Renders the relevance and tailoring javascript for a survey.
* @todo Add caching headers.
Expand Down
2 changes: 1 addition & 1 deletion application/views/surveys/index.php
Expand Up @@ -29,7 +29,7 @@
'color' => 'danger',
'title' => gT("Stop selected surveys"),
'formaction' => App()->createUrl('surveys/deactivateMultiple'),
'data-confirm' => gT("This will activate all selected surveys, are you sure?")
'data-confirm' => gT("This will deactivate all selected surveys, are you sure?")
]),
TbHtml::endForm()
]));
Expand Down

0 comments on commit 5c9782b

Please sign in to comment.