summaryrefslogtreecommitdiff
path: root/plugins/TimeMachine/Action/SubtaskTimerMoveTaskColumn.php
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2020-05-05 14:25:42 +0200
committeremkael <emkael@tlen.pl>2020-05-05 14:25:42 +0200
commit62827e6cf470449c117624058fb36ad94804bcc0 (patch)
tree10cd1e4d36c34b694acfadaa69fc7f6ae2b1eabd /plugins/TimeMachine/Action/SubtaskTimerMoveTaskColumn.php
parent7b66ddf2e4fbdb837e78d8b7dbaa9fc38391bc32 (diff)
Time tracking related pluginsHEADmaster
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;
+ }
+}