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 ++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 app/Action/TaskAssignColorOnStartDate.php (limited to 'app/Action') 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; + } +} -- cgit v1.2.3