diff options
author | Frederic Guillot <fred@kanboard.net> | 2016-05-28 13:41:54 -0400 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2016-05-28 13:41:54 -0400 |
commit | 1353929a7dbd3f2e897fa7d3ab88e959ca573f9f (patch) | |
tree | 30bdbac4e466e74c3dfb4d451422f03c62bcbe41 /app/Controller/ActionController.php | |
parent | ab48a09f0d674b703467975b376c5ac7352670ae (diff) |
Rename controllers
Diffstat (limited to 'app/Controller/ActionController.php')
-rw-r--r-- | app/Controller/ActionController.php | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/app/Controller/ActionController.php b/app/Controller/ActionController.php new file mode 100644 index 00000000..51090d22 --- /dev/null +++ b/app/Controller/ActionController.php @@ -0,0 +1,77 @@ +<?php + +namespace Kanboard\Controller; + +/** + * Automatic Actions Controller + * + * @package Kanboard\Controller + * @author Frederic Guillot + */ +class ActionController extends BaseController +{ + /** + * List of automatic actions for a given project + * + * @access public + */ + public function index() + { + $project = $this->getProject(); + $actions = $this->action->getAllByProject($project['id']); + + $this->response->html($this->helper->layout->project('action/index', array( + 'values' => array('project_id' => $project['id']), + 'project' => $project, + 'actions' => $actions, + 'available_actions' => $this->actionManager->getAvailableActions(), + 'available_events' => $this->eventManager->getAll(), + 'available_params' => $this->actionManager->getAvailableParameters($actions), + 'columns_list' => $this->column->getList($project['id']), + 'users_list' => $this->projectUserRole->getAssignableUsersList($project['id']), + 'projects_list' => $this->projectUserRole->getProjectsByUser($this->userSession->getId()), + 'colors_list' => $this->color->getList(), + 'categories_list' => $this->category->getList($project['id']), + 'links_list' => $this->link->getList(0, false), + 'title' => t('Automatic actions') + ))); + } + + /** + * Confirmation dialog before removing an action + * + * @access public + */ + public function confirm() + { + $project = $this->getProject(); + + $this->response->html($this->helper->layout->project('action/remove', array( + 'action' => $this->action->getById($this->request->getIntegerParam('action_id')), + 'available_events' => $this->eventManager->getAll(), + 'available_actions' => $this->actionManager->getAvailableActions(), + 'project' => $project, + 'title' => t('Remove an action') + ))); + } + + /** + * Remove an action + * + * @access public + */ + public function remove() + { + $this->checkCSRFParam(); + $project = $this->getProject(); + $action = $this->action->getById($this->request->getIntegerParam('action_id')); + + if (! empty($action) && $this->action->remove($action['id'])) { + $this->flash->success(t('Action removed successfully.')); + } else { + $this->flash->failure(t('Unable to remove this action.')); + } + + $this->response->redirect($this->helper->url->to('ActionController', 'index', array('project_id' => $project['id']))); + } +} |