diff options
Diffstat (limited to 'actions')
-rw-r--r-- | actions/task_assign_color_category.php | 85 | ||||
-rw-r--r-- | actions/task_assign_color_user.php | 4 |
2 files changed, 86 insertions, 3 deletions
diff --git a/actions/task_assign_color_category.php b/actions/task_assign_color_category.php new file mode 100644 index 00000000..6fba5223 --- /dev/null +++ b/actions/task_assign_color_category.php @@ -0,0 +1,85 @@ +<?php + +namespace Action; + +require_once __DIR__.'/base.php'; + +/** + * Assign a color to a specific category + * + * @package action + * @author Frederic Guillot + */ +class TaskAssignColorCategory extends Base +{ + /** + * Task model + * + * @accesss private + * @var \Model\Task + */ + private $task; + + /** + * Constructor + * + * @access public + * @param integer $project_id Project id + * @param \Model\Task $task Task model instance + */ + public function __construct($project_id, \Model\Task $task) + { + parent::__construct($project_id); + $this->task = $task; + } + + /** + * Get the required parameter for the action (defined by the user) + * + * @access public + * @return array + */ + public function getActionRequiredParameters() + { + return array( + 'color_id' => t('Color'), + 'category_id' => t('Category'), + ); + } + + /** + * Get the required parameter for the event + * + * @access public + * @return string[] + */ + public function getEventRequiredParameters() + { + return array( + 'task_id', + 'category_id', + ); + } + + /** + * Execute the action + * + * @access public + * @param array $data Event data dictionary + * @return bool True if the action was executed or false when not executed + */ + public function doAction(array $data) + { + if ($data['category_id'] == $this->getParam('category_id')) { + + $this->task->update(array( + 'id' => $data['task_id'], + 'color_id' => $this->getParam('color_id'), + )); + + return true; + } + + return false; + } +} diff --git a/actions/task_assign_color_user.php b/actions/task_assign_color_user.php index d3ce1fbe..d5784270 100644 --- a/actions/task_assign_color_user.php +++ b/actions/task_assign_color_user.php @@ -42,7 +42,6 @@ class TaskAssignColorUser extends Base public function getActionRequiredParameters() { return array( - 'column_id' => t('Column'), 'color_id' => t('Color'), 'user_id' => t('Assignee'), ); @@ -59,7 +58,6 @@ class TaskAssignColorUser extends Base return array( 'task_id', 'owner_id', - 'column_id', ); } @@ -72,7 +70,7 @@ class TaskAssignColorUser extends Base */ public function doAction(array $data) { - if ($data['column_id'] == $this->getParam('column_id') && $data['owner_id'] == $this->getParam('user_id')) { + if ($data['owner_id'] == $this->getParam('user_id')) { $this->task->update(array( 'id' => $data['task_id'], |