diff options
author | Frederic Guillot <fred@kanboard.net> | 2015-02-07 21:44:51 -0500 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2015-02-07 21:44:51 -0500 |
commit | c9cc82eec898654846c3c7e409269166cc5dba7c (patch) | |
tree | 4ddc6479ff5447627f07a40f37024420e2bd0a71 /app/Subscriber/SubtaskTimesheetSubscriber.php | |
parent | 2d890cbc712371f17ba4bbceb02af3c5ba04e6da (diff) |
Update subtask spent based on the time tracking
Diffstat (limited to 'app/Subscriber/SubtaskTimesheetSubscriber.php')
-rw-r--r-- | app/Subscriber/SubtaskTimesheetSubscriber.php | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/app/Subscriber/SubtaskTimesheetSubscriber.php b/app/Subscriber/SubtaskTimesheetSubscriber.php index df10fc43..acae9a4b 100644 --- a/app/Subscriber/SubtaskTimesheetSubscriber.php +++ b/app/Subscriber/SubtaskTimesheetSubscriber.php @@ -11,21 +11,36 @@ class SubtaskTimesheetSubscriber extends Base implements EventSubscriberInterfac public static function getSubscribedEvents() { return array( - Subtask::EVENT_UPDATE => array('log', 0), + Subtask::EVENT_CREATE => array('updateTaskTime', 0), + Subtask::EVENT_UPDATE => array( + array('logStartEnd', 10), + array('updateTaskTime', 0), + ) ); } - public function log(SubtaskEvent $event) + public function updateTaskTime(SubtaskEvent $event) { - if (isset($event['status'])) { + if (isset($event['task_id'])) { + $this->subtaskTimeTracking->updateTaskTimeTracking($event['task_id']); + } + } + + public function logStartEnd(SubtaskEvent $event) + { + if ($this->config->get('subtask_time_tracking') == 1 && isset($event['status'])) { $subtask = $this->subtask->getById($event['id']); + if (empty($subtask['user_id'])) { + return false; + } + if ($subtask['status'] == Subtask::STATUS_INPROGRESS) { - $this->subtaskTimeTracking->logStartTime($subtask['id'], $subtask['user_id']); + return $this->subtaskTimeTracking->logStartTime($subtask['id'], $subtask['user_id']); } else { - $this->subtaskTimeTracking->logEndTime($subtask['id'], $subtask['user_id']); + return $this->subtaskTimeTracking->logEndTime($subtask['id'], $subtask['user_id']); } } } |