From fba52083085733dd5c891839123d0c1845ef119a Mon Sep 17 00:00:00 2001 From: Christian Wolter Date: Mon, 22 Jan 2018 19:54:03 +0100 Subject: Add action to change color once start date is reached --- app/Action/TaskAssignColorOnStartDate.php | 100 ++++++++++++++++++++++++++++++ app/ServiceProvider/ActionProvider.php | 2 + 2 files changed, 102 insertions(+) create mode 100644 app/Action/TaskAssignColorOnStartDate.php (limited to 'app') diff --git a/app/Action/TaskAssignColorOnStartDate.php b/app/Action/TaskAssignColorOnStartDate.php new file mode 100644 index 00000000..39817845 --- /dev/null +++ b/app/Action/TaskAssignColorOnStartDate.php @@ -0,0 +1,100 @@ + t('Color'), + ); + } + + /** + * Get all tasks + * + * @access public + * @return array + */ + + public function getEventRequiredParameters() + { + return array('tasks'); + } + + /** + * Execute the action (change the task color) + * + * @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) + { + $results = array(); + + foreach ($data['tasks'] as $task) { + if ($task['date_started'] <= time() && $task['date_started'] > 0 && $task['color_id'] != $this->getParam('color_id')) { + $values = array( + 'id' => $task['id'], + 'color_id' => $this->getParam('color_id'), + ); + $results[] = $this->taskModificationModel->update($values, false); + } + } + + return in_array(true, $results, true); + } + + /** + * Check if the event data meet the action condition + * + * @access public + * @param array $data Event data dictionary + * @return bool + */ + public function hasRequiredCondition(array $data) + { + return count($data['tasks']) > 0; + } +} diff --git a/app/ServiceProvider/ActionProvider.php b/app/ServiceProvider/ActionProvider.php index 73d7f171..99a69247 100644 --- a/app/ServiceProvider/ActionProvider.php +++ b/app/ServiceProvider/ActionProvider.php @@ -5,6 +5,7 @@ namespace Kanboard\ServiceProvider; use Pimple\Container; use Pimple\ServiceProviderInterface; use Kanboard\Action\TaskAssignColorOnDueDate; +use Kanboard\Action\TaskAssignColorOnStartDate; use Kanboard\Action\TaskAssignColorPriority; use Kanboard\Action\TaskAssignDueDateOnCreation; use Kanboard\Action\TaskMoveColumnClosed; @@ -100,6 +101,7 @@ class ActionProvider implements ServiceProviderInterface $container['actionManager']->register(new TaskAssignColorOnDueDate($container)); $container['actionManager']->register(new SubtaskTimerMoveTaskColumn($container)); $container['actionManager']->register(new StopSubtaskTimerMoveTaskColumn($container)); + $container['actionManager']->register(new TaskAssignColorOnStartDate($container)); return $container; } -- cgit v1.2.3