From ff892c5d25e0bab560f005c788189d38c2bcab7b Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Wed, 25 May 2016 22:28:09 -0400 Subject: Split project controller into multiple classes --- app/Controller/ProjectStatusController.php | 102 +++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 app/Controller/ProjectStatusController.php (limited to 'app/Controller/ProjectStatusController.php') diff --git a/app/Controller/ProjectStatusController.php b/app/Controller/ProjectStatusController.php new file mode 100644 index 00000000..16ac32b8 --- /dev/null +++ b/app/Controller/ProjectStatusController.php @@ -0,0 +1,102 @@ +getProject(); + + $this->response->html($this->template->render('project_status/enable', array( + 'project' => $project, + 'title' => t('Project activation') + ))); + } + + /** + * Enable the project + */ + public function enable() + { + $project = $this->getProject(); + $this->checkCSRFParam(); + + if ($this->project->enable($project['id'])) { + $this->flash->success(t('Project activated successfully.')); + } else { + $this->flash->failure(t('Unable to activate this project.')); + } + + $this->response->redirect($this->helper->url->to('ProjectViewController', 'show', array('project_id' => $project['id'])), true); + } + + /** + * Disable a project (confirmation dialog box) + */ + public function confirmDisable() + { + $project = $this->getProject(); + + $this->response->html($this->template->render('project_status/disable', array( + 'project' => $project, + 'title' => t('Project activation') + ))); + } + + /** + * Disable a project + */ + public function disable() + { + $project = $this->getProject(); + $this->checkCSRFParam(); + + if ($this->project->disable($project['id'])) { + $this->flash->success(t('Project disabled successfully.')); + } else { + $this->flash->failure(t('Unable to disable this project.')); + } + + $this->response->redirect($this->helper->url->to('ProjectViewController', 'show', array('project_id' => $project['id'])), true); + } + + /** + * Remove a project (confirmation dialog box) + */ + public function confirmRemove() + { + $project = $this->getProject(); + + $this->response->html($this->template->render('project_status/remove', array( + 'project' => $project, + 'title' => t('Remove project') + ))); + } + + /** + * Remove a project + */ + public function remove() + { + $project = $this->getProject(); + $this->checkCSRFParam(); + + if ($this->project->remove($project['id'])) { + $this->flash->success(t('Project removed successfully.')); + } else { + $this->flash->failure(t('Unable to remove this project.')); + } + + $this->response->redirect($this->helper->url->to('ProjectListController', 'show'), true); + } +} -- cgit v1.2.3