From 28ff8dad91c9e3c25f6a3b5398ae15f2a1ef95cd Mon Sep 17 00:00:00 2001 From: Frédéric Guillot Date: Wed, 10 Sep 2014 16:21:47 +0200 Subject: Add subtasks and comments history --- app/Event/CommentHistoryListener.php | 62 ++++++++++++++++++++++++++++++++++++ app/Event/SubtaskHistoryListener.php | 62 ++++++++++++++++++++++++++++++++++++ app/Event/TaskHistoryListener.php | 4 +-- 3 files changed, 126 insertions(+), 2 deletions(-) create mode 100644 app/Event/CommentHistoryListener.php create mode 100644 app/Event/SubtaskHistoryListener.php (limited to 'app/Event') diff --git a/app/Event/CommentHistoryListener.php b/app/Event/CommentHistoryListener.php new file mode 100644 index 00000000..a89ecbae --- /dev/null +++ b/app/Event/CommentHistoryListener.php @@ -0,0 +1,62 @@ +model = $model; + } + + /** + * 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 execute(array $data) + { + $creator_id = $this->model->acl->getUserId(); + + if ($creator_id && isset($data['task_id']) && isset($data['id'])) { + + $task = $this->model->task->getById($data['task_id']); + + $this->model->create( + $task['project_id'], + $data['task_id'], + $data['id'], + $creator_id, + $this->model->event->getLastTriggeredEvent(), + $data['comment'] + ); + } + + return false; + } +} diff --git a/app/Event/SubtaskHistoryListener.php b/app/Event/SubtaskHistoryListener.php new file mode 100644 index 00000000..e859828c --- /dev/null +++ b/app/Event/SubtaskHistoryListener.php @@ -0,0 +1,62 @@ +model = $model; + } + + /** + * 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 execute(array $data) + { + $creator_id = $this->model->acl->getUserId(); + + if ($creator_id && isset($data['task_id']) && isset($data['id'])) { + + $task = $this->model->task->getById($data['task_id']); + + $this->model->create( + $task['project_id'], + $data['task_id'], + $data['id'], + $creator_id, + $this->model->event->getLastTriggeredEvent(), + '' + ); + } + + return false; + } +} diff --git a/app/Event/TaskHistoryListener.php b/app/Event/TaskHistoryListener.php index d6709f6e..c8a880e8 100644 --- a/app/Event/TaskHistoryListener.php +++ b/app/Event/TaskHistoryListener.php @@ -14,7 +14,7 @@ use Model\TaskHistory; class TaskHistoryListener implements Listener { /** - * TaskHistory model + * Task History model * * @accesss private * @var \Model\TaskHistory @@ -25,7 +25,7 @@ class TaskHistoryListener implements Listener * Constructor * * @access public - * @param \Model\TaskHistory $model TaskHistory model instance + * @param \Model\TaskHistory $model Task History model instance */ public function __construct(TaskHistory $model) { -- cgit v1.2.3