summaryrefslogtreecommitdiff
path: root/app/Action
diff options
context:
space:
mode:
authorrenothing <261274+renothing@users.noreply.github.com>2019-07-09 10:48:24 +0800
committerFrédéric Guillot <fred@kanboard.net>2019-07-08 19:48:24 -0700
commitd3d55224329681722b52a84b31f141bf78aaa134 (patch)
treeda51edcae81ff95a6f73d028e256df33cb5853bf /app/Action
parent91d703eb8dd627659712e2c87fffab6140ec9aec (diff)
Automatically update the start date when a task move away from a column
Diffstat (limited to 'app/Action')
-rw-r--r--app/Action/TaskUpdateStartDateOnMoveColumn.php96
1 files changed, 96 insertions, 0 deletions
diff --git a/app/Action/TaskUpdateStartDateOnMoveColumn.php b/app/Action/TaskUpdateStartDateOnMoveColumn.php
new file mode 100644
index 00000000..8a00bbab
--- /dev/null
+++ b/app/Action/TaskUpdateStartDateOnMoveColumn.php
@@ -0,0 +1,96 @@
+<?php
+
+namespace Kanboard\Action;
+
+use Kanboard\Model\TaskModel;
+
+/**
+ * Set the start date when task move away from certain column
+ *
+ * @package Kanboard\Action
+ */
+class TaskUpdateStartDateOnMoveColumn extends Base
+{
+ /**
+ * Get automatic action description
+ *
+ * @access public
+ * @return string
+ */
+ public function getDescription()
+ {
+ return t('Automatically update the start date when task move away from certain column');
+ }
+
+ /**
+ * Get the list of compatible events
+ *
+ * @access public
+ * @return array
+ */
+ public function getCompatibleEvents()
+ {
+ return array(
+ TaskModel::EVENT_MOVE_COLUMN,
+ );
+ }
+
+ /**
+ * Get the required parameter for the action (defined by the user)
+ *
+ * @access public
+ * @return array
+ */
+ public function getActionRequiredParameters()
+ {
+ return array(
+ 'column_id' => t('Column'),
+ );
+ }
+
+ /**
+ * Get the required parameter for the event
+ *
+ * @access public
+ * @return string[]
+ */
+ public function getEventRequiredParameters()
+ {
+ return array(
+ 'task_id',
+ 'task' => array(
+ 'project_id',
+ 'column_id',
+ ),
+ );
+ }
+
+ /**
+ * Execute the action (set the task date_started)
+ *
+ * @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)
+ {
+ $values = array(
+ 'id' => $data['task_id'],
+ 'date_started' => time(),
+ );
+
+ return $this->taskModificationModel->update($values, 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 empty($data['task']['date_started']) && $data['task']['column_id'] != $this->getParam('column_id');
+ }
+}