diff options
author | Frédéric Guillot <fred@kanboard.net> | 2014-09-28 14:26:40 -0400 |
---|---|---|
committer | Frédéric Guillot <fred@kanboard.net> | 2014-09-28 14:26:40 -0400 |
commit | 03fa01ac7b036820ee232d893ec63241918c6012 (patch) | |
tree | 295e82e6552ffb044554a11afa95318a4e180f87 /app/Controller | |
parent | 0c8de6a3f58cde2696ac276b3456f3577d312e2b (diff) |
Improve automatic actions (check for compatible events/actions/parameters)
Diffstat (limited to 'app/Controller')
-rw-r--r-- | app/Controller/Action.php | 57 |
1 files changed, 51 insertions, 6 deletions
diff --git a/app/Controller/Action.php b/app/Controller/Action.php index 64d77aab..44ab6430 100644 --- a/app/Controller/Action.php +++ b/app/Controller/Action.php @@ -37,7 +37,30 @@ class Action extends Base } /** - * Define action parameters (step 2) + * Choose the event according to the action (step 2) + * + * @access public + */ + public function event() + { + $project = $this->getProject(); + $values = $this->request->getValues(); + + if (empty($values['action_name']) || empty($values['project_id'])) { + $this->response->redirect('?controller=action&action=index&project_id='.$project['id']); + } + + $this->response->html($this->projectLayout('action_event', array( + 'values' => $values, + 'project' => $project, + 'events' => $this->action->getCompatibleEvents($values['action_name']), + 'menu' => 'projects', + 'title' => t('Automatic actions') + ))); + } + + /** + * Define action parameters (step 3) * * @access public */ @@ -45,14 +68,27 @@ class Action extends Base { $project = $this->getProject(); $values = $this->request->getValues(); - $action = $this->action->load($values['action_name'], $values['project_id']); + + if (empty($values['action_name']) || empty($values['project_id']) || empty($values['event_name'])) { + $this->response->redirect('?controller=action&action=index&project_id='.$project['id']); + } + + $action = $this->action->load($values['action_name'], $values['project_id'], $values['event_name']); + $action_params = $action->getActionRequiredParameters(); + + if (empty($action_params)) { + $this->doCreation($project, $values + array('params' => array())); + } + + $projects_list = $this->project->getList(false); + unset($projects_list[$project['id']]); $this->response->html($this->projectLayout('action_params', array( 'values' => $values, - 'action_params' => $action->getActionRequiredParameters(), + 'action_params' => $action_params, 'columns_list' => $this->board->getColumnsList($project['id']), 'users_list' => $this->projectPermission->getUsersList($project['id']), - 'projects_list' => $this->project->getList(false), + 'projects_list' => $projects_list, 'colors_list' => $this->color->getList(), 'categories_list' => $this->category->getList($project['id']), 'project' => $project, @@ -68,9 +104,18 @@ class Action extends Base */ public function create() { - $project = $this->getProject(); - $values = $this->request->getValues(); + $this->doCreation($this->getProject(), $this->request->getValues()); + } + /** + * Save the action + * + * @access private + * @param array $project Project properties + * @param array $values Form values + */ + private function doCreation(array $project, array $values) + { list($valid,) = $this->action->validateCreation($values); if ($valid) { |