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/Action/TaskAssignCurrentUser.php | |
parent | 0c8de6a3f58cde2696ac276b3456f3577d312e2b (diff) |
Improve automatic actions (check for compatible events/actions/parameters)
Diffstat (limited to 'app/Action/TaskAssignCurrentUser.php')
-rw-r--r-- | app/Action/TaskAssignCurrentUser.php | 57 |
1 files changed, 23 insertions, 34 deletions
diff --git a/app/Action/TaskAssignCurrentUser.php b/app/Action/TaskAssignCurrentUser.php index 8ae87ff9..7a9cf70b 100644 --- a/app/Action/TaskAssignCurrentUser.php +++ b/app/Action/TaskAssignCurrentUser.php @@ -3,7 +3,6 @@ namespace Action; use Model\Task; -use Model\Acl; /** * Assign a task to the logged user @@ -14,34 +13,17 @@ use Model\Acl; class TaskAssignCurrentUser extends Base { /** - * Task model - * - * @accesss private - * @var \Model\Task - */ - private $task; - - /** - * Acl model - * - * @accesss private - * @var \Model\Acl - */ - private $acl; - - /** - * Constructor + * Get the list of compatible events * * @access public - * @param integer $project_id Project id - * @param \Model\Task $task Task model instance - * @param \Model\Acl $acl Acl model instance + * @return array */ - public function __construct($project_id, Task $task, Acl $acl) + public function getCompatibleEvents() { - parent::__construct($project_id); - $this->task = $task; - $this->acl = $acl; + return array( + Task::EVENT_CREATE, + Task::EVENT_MOVE_COLUMN, + ); } /** @@ -80,16 +62,23 @@ class TaskAssignCurrentUser extends Base */ public function doAction(array $data) { - if ($data['column_id'] == $this->getParam('column_id')) { - - $this->task->update(array( - 'id' => $data['task_id'], - 'owner_id' => $this->acl->getUserId(), - ), false); + $values = array( + 'id' => $data['task_id'], + 'owner_id' => $this->acl->getUserId(), + ); - return true; - } + return $this->task->update($values, false); + } - return false; + /** + * 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['column_id'] == $this->getParam('column_id'); } } |