summaryrefslogtreecommitdiff
path: root/plugins/TimeMachine/Action/SubtaskTimerMoveTaskColumn.php
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/TimeMachine/Action/SubtaskTimerMoveTaskColumn.php')
-rw-r--r--plugins/TimeMachine/Action/SubtaskTimerMoveTaskColumn.php40
1 files changed, 40 insertions, 0 deletions
diff --git a/plugins/TimeMachine/Action/SubtaskTimerMoveTaskColumn.php b/plugins/TimeMachine/Action/SubtaskTimerMoveTaskColumn.php
new file mode 100644
index 00000000..e6d2217b
--- /dev/null
+++ b/plugins/TimeMachine/Action/SubtaskTimerMoveTaskColumn.php
@@ -0,0 +1,40 @@
+<?php
+
+namespace Kanboard\Plugin\TimeMachine\Action;
+
+use Kanboard\Model\TaskModel;
+use Kanboard\Model\SubtaskModel;
+
+/**
+ * Create a subtask and activate the timer when moving a task to another column.
+ *
+ * @package Kanboard\Action
+ * @author yvalentin
+ */
+class SubtaskTimerMoveTaskColumn extends \Kanboard\Action\SubtaskTimerMoveTaskColumn
+{
+ /**
+ * Execute the action (append to the task description).
+ * SubTask is create with user session (not with creator of the task, on original action on extends class)
+ *
+ * @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)
+ {
+ $userId = $this->userSession->getId();
+ $subtaskID = $this->subtaskModel->create(array(
+ 'title' => $this->getParam('subtask'),
+ 'user_id' => $userId,
+ 'task_id' => $data['task']['id'],
+ 'status' => SubtaskModel::STATUS_INPROGRESS,
+ ));
+
+ if ($subtaskID !== false) {
+ return $this->subtaskTimeTrackingModel->toggleTimer($subtaskID, $userId, SubtaskModel::STATUS_INPROGRESS);
+ }
+
+ return false;
+ }
+}