diff options
author | Frederic Guillot <fred@kanboard.net> | 2017-06-03 11:32:24 -0400 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2017-06-03 11:32:24 -0400 |
commit | 43e4662b842248952aa53ebb69e8e833682a055c (patch) | |
tree | 5d20cf69c3d4998c00a396ac4096b8ade744c372 /app/Action | |
parent | 6251ac62d43817b996c2f0131433c1955e08a1de (diff) |
Add new automatic action to assign tasks to its creator
Diffstat (limited to 'app/Action')
-rw-r--r-- | app/Action/TaskAssignCreator.php | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/app/Action/TaskAssignCreator.php b/app/Action/TaskAssignCreator.php new file mode 100644 index 00000000..ce10b35f --- /dev/null +++ b/app/Action/TaskAssignCreator.php @@ -0,0 +1,98 @@ +<?php + +namespace Kanboard\Action; + +use Kanboard\Model\TaskModel; + +/** + * Assign a task to the creator + * + * @package Kanboard\Action + * @author Frederic Guillot + */ +class TaskAssignCreator extends Base +{ + /** + * Get automatic action description + * + * @access public + * @return string + */ + public function getDescription() + { + return t('Assign the task to its creator'); + } + + /** + * Get the list of compatible events + * + * @access public + * @return array + */ + public function getCompatibleEvents() + { + return array( + TaskModel::EVENT_MOVE_COLUMN, + ); + } + + /** + * Get the required parameter for the action (defined by the user) + * + * @access public + * @return array + */ + public function getActionRequiredParameters() + { + return array( + 'column_id' => t('Column'), + ); + } + + /** + * Get the required parameter for the event + * + * @access public + * @return string[] + */ + public function getEventRequiredParameters() + { + return array( + 'task_id', + 'task' => array( + 'project_id', + 'column_id', + 'creator_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) + { + $values = array( + 'id' => $data['task_id'], + 'owner_id' => $data['task']['creator_id'], + ); + + return $this->taskModificationModel->update($values); + } + + /** + * 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 $data['task']['column_id'] == $this->getParam('column_id'); + } +} |