看板初始化提交

This commit is contained in:
zephyr
2026-06-01 21:23:12 -07:00
commit 54a842f4ab
2104 changed files with 241695 additions and 0 deletions
+305
View File
@@ -0,0 +1,305 @@
<?php
namespace Kanboard\Action;
use Kanboard\Event\GenericEvent;
/**
* Base class for automatic actions
*
* @package Kanboard\Action
* @author Frederic Guillot
*/
abstract class Base extends \Kanboard\Core\Base
{
/**
* Extended events
*
* @access private
* @var array
*/
private $compatibleEvents = array();
/**
* Keep history of executed events
*
* @access private
* @var array
*/
private $callStack = [];
/**
* Project id
*
* @access private
* @var integer
*/
private $projectId = 0;
/**
* User parameters
*
* @access private
* @var array
*/
private $params = array();
/**
* Get automatic action name
*
* @final
* @access public
* @return string
*/
final public function getName()
{
return '\\'.get_called_class();
}
/**
* Get automatic action description
*
* @abstract
* @access public
* @return string
*/
abstract public function getDescription();
/**
* Execute the action
*
* @abstract
* @access public
* @param array $data Event data dictionary
* @return bool True if the action was executed or false when not executed
*/
abstract public function doAction(array $data);
/**
* Get the required parameter for the action (defined by the user)
*
* @abstract
* @access public
* @return array
*/
abstract public function getActionRequiredParameters();
/**
* Get the required parameter for the event (check if for the event data)
*
* @abstract
* @access public
* @return array
*/
abstract public function getEventRequiredParameters();
/**
* Get the compatible events
*
* @abstract
* @access public
* @return array
*/
abstract public function getCompatibleEvents();
/**
* Check if the event data meet the action condition
*
* @access public
* @param array $data Event data dictionary
* @return bool
*/
abstract public function hasRequiredCondition(array $data);
/**
* Return class information
*
* @access public
* @return string
*/
public function __toString()
{
$params = array();
foreach ($this->params as $key => $value) {
$params[] = $key.'='.var_export($value, true);
}
return $this->getName().'('.implode('|', $params).')';
}
/**
* Set project id
*
* @access public
* @param integer $project_id
* @return Base
*/
public function setProjectId($project_id)
{
$this->projectId = $project_id;
return $this;
}
/**
* Get project id
*
* @access public
* @return integer
*/
public function getProjectId()
{
return $this->projectId;
}
/**
* Set an user defined parameter
*
* @access public
* @param string $name Parameter name
* @param mixed $value Value
* @return Base
*/
public function setParam($name, $value)
{
$this->params[$name] = $value;
return $this;
}
/**
* Get an user defined parameter
*
* @access public
* @param string $name Parameter name
* @param mixed $default Default value
* @return mixed
*/
public function getParam($name, $default = null)
{
return isset($this->params[$name]) ? $this->params[$name] : $default;
}
/**
* Check if an action is executable (right project and required parameters)
*
* @access public
* @param array $data
* @param string $eventName
* @return bool
*/
public function isExecutable(array $data, $eventName)
{
return $this->hasCompatibleEvent($eventName) &&
$this->hasRequiredProject($data) &&
$this->hasRequiredParameters($data) &&
$this->hasRequiredCondition($data);
}
/**
* Check if the event is compatible with the action
*
* @access public
* @param string $eventName
* @return bool
*/
public function hasCompatibleEvent($eventName)
{
return in_array($eventName, $this->getEvents());
}
/**
* Check if the event data has the required project
*
* @access public
* @param array $data Event data dictionary
* @return bool
*/
public function hasRequiredProject(array $data)
{
return (isset($data['project_id']) && $data['project_id'] == $this->getProjectId()) ||
(isset($data['task']['project_id']) && $data['task']['project_id'] == $this->getProjectId());
}
/**
* Check if the event data has required parameters to execute the action
*
* @access public
* @param array $data Event data dictionary
* @return bool True if all keys are there
*/
public function hasRequiredParameters(array $data, array $parameters = array())
{
$parameters = $parameters ?: $this->getEventRequiredParameters();
foreach ($parameters as $key => $value) {
if (is_array($value)) {
return isset($data[$key]) && $this->hasRequiredParameters($data[$key], $value);
} elseif (! isset($data[$value])) {
return false;
}
}
return true;
}
/**
* Execute the action
*
* @access public
* @param \Kanboard\Event\GenericEvent $event
* @param string $eventName
* @return bool
*/
public function execute(GenericEvent $event, $eventName)
{
$data = $event->getAll();
$hash = md5(serialize($data).$eventName);
// Do not call twice the same action with the same arguments.
if (isset($this->callStack[$hash])) {
return false;
} else {
$this->callStack[$hash] = true;
}
$executable = $this->isExecutable($data, $eventName);
$executed = false;
if ($executable) {
$executed = $this->doAction($data);
}
$this->logger->debug($this.' ['.$eventName.'] => executable='.var_export($executable, true).' exec_success='.var_export($executed, true));
return $executed;
}
/**
* Register a new event for the automatic action
*
* @access public
* @param string $event
* @param string $description
* @return Base
*/
public function addEvent($event, $description = '')
{
if ($description !== '') {
$this->eventManager->register($event, $description);
}
$this->compatibleEvents[] = $event;
return $this;
}
/**
* Get all compatible events of an automatic action
*
* @access public
* @return array
*/
public function getEvents()
{
return array_unique(array_merge($this->getCompatibleEvents(), $this->compatibleEvents));
}
}
+87
View File
@@ -0,0 +1,87 @@
<?php
namespace Kanboard\Action;
/**
* Create automatically a comment from a webhook
*
* @package Kanboard\Action
* @author Frederic Guillot
*/
class CommentCreation extends Base
{
/**
* Get automatic action description
*
* @access public
* @return string
*/
public function getDescription()
{
return t('Create a comment from an external provider');
}
/**
* Get the list of compatible events
*
* @access public
* @return string[]
*/
public function getCompatibleEvents()
{
return array();
}
/**
* Get the required parameter for the action (defined by the user)
*
* @access public
* @return string[]
*/
public function getActionRequiredParameters()
{
return array();
}
/**
* Get the required parameter for the event
*
* @access public
* @return array
*/
public function getEventRequiredParameters()
{
return array(
'task_id',
);
}
/**
* Execute the action (create a new comment)
*
* @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)
{
return (bool) $this->commentModel->create(array(
'reference' => isset($data['reference']) ? $data['reference'] : '',
'comment' => $data['comment'],
'task_id' => $data['task_id'],
'user_id' => isset($data['user_id']) && $this->projectPermissionModel->isAssignable($this->getProjectId(), $data['user_id']) ? $data['user_id'] : 0,
));
}
/**
* 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['comment']);
}
}
@@ -0,0 +1,100 @@
<?php
namespace Kanboard\Action;
use Kanboard\Model\TaskModel;
/**
* Add a comment of the triggering event to the task description.
*
* @package Kanboard\Action
* @author Oren Ben-Kiki
*/
class CommentCreationMoveTaskColumn extends Base
{
/**
* Get automatic action description
*
* @access public
* @return string
*/
public function getDescription()
{
return t('Add a comment log when moving the task between columns');
}
/**
* 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(
'column_id',
'project_id',
),
);
}
/**
* Execute the action (append to the task description).
*
* @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)
{
if (! $this->userSession->isLogged()) {
return false;
}
$column = $this->columnModel->getById($data['task']['column_id']);
return (bool) $this->commentModel->create(array(
'comment' => t('Moved to column %s', $column['title']),
'task_id' => $data['task_id'],
'user_id' => $this->userSession->getId(),
));
}
/**
* 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 $data['task']['column_id'] == $this->getParam('column_id');
}
}
@@ -0,0 +1,102 @@
<?php
namespace Kanboard\Action;
use Kanboard\Model\TaskModel;
use Kanboard\Model\SubtaskModel;
/**
* Stop the timer of all subtasks when moving a task to another column.
*
* @package Kanboard\Action
* @author Frederic Guillot
*/
class StopSubtaskTimerMoveTaskColumn extends Base
{
/**
* Get automatic action description
*
* @access public
* @return string
*/
public function getDescription()
{
return t('Stop the timer of all subtasks when moving a task to another 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(
'id',
'column_id',
'project_id',
),
);
}
/**
* Execute the action (append to the task description).
*
* @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)
{
$subtasks = $this->subtaskModel->getAll($data['task']['id']);
$results = array();
foreach ($subtasks as $subtask) {
$results[] = $this->subtaskModel->update(array('id' => $subtask['id'], 'status' => SubtaskModel::STATUS_DONE));
$results[] = $this->subtaskTimeTrackingModel->logEndTime($subtask['id'], $subtask['user_id']);
}
return !in_array(false, $results, true);
}
/**
* 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 $data['task']['column_id'] == $this->getParam('column_id');
}
}
+107
View File
@@ -0,0 +1,107 @@
<?php
namespace Kanboard\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 Frederic Guillot
*/
class SubtaskTimerMoveTaskColumn extends Base
{
/**
* Get automatic action description
*
* @access public
* @return string
*/
public function getDescription()
{
return t('Add a subtask and activate the timer when moving a task to another 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'),
'subtask' => t('Subtask Title'),
);
}
/**
* Get the required parameter for the event
*
* @access public
* @return string[]
*/
public function getEventRequiredParameters()
{
return array(
'task_id',
'task' => array(
'id',
'column_id',
'project_id',
'creator_id',
),
);
}
/**
* Execute the action (append to the task description).
*
* @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)
{
$subtaskID = $this->subtaskModel->create(array(
'title' => $this->getParam('subtask'),
'user_id' => $data['task']['creator_id'],
'task_id' => $data['task']['id'],
'status' => SubtaskModel::STATUS_INPROGRESS,
));
if ($subtaskID !== false) {
return $this->subtaskTimeTrackingModel->toggleTimer($subtaskID, $data['task']['creator_id'], SubtaskModel::STATUS_INPROGRESS);
}
return 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 $data['task']['column_id'] == $this->getParam('column_id');
}
}
+98
View File
@@ -0,0 +1,98 @@
<?php
namespace Kanboard\Action;
use Kanboard\Model\TaskModel;
/**
* Set a category automatically according to the color
*
* @package Kanboard\Action
* @author Frederic Guillot
*/
class TaskAssignCategoryColor extends Base
{
/**
* Get automatic action description
*
* @access public
* @return string
*/
public function getDescription()
{
return t('Assign automatically a category based on a color');
}
/**
* Get the list of compatible events
*
* @access public
* @return array
*/
public function getCompatibleEvents()
{
return array(
TaskModel::EVENT_CREATE_UPDATE,
);
}
/**
* Get the required parameter for the action (defined by the user)
*
* @access public
* @return array
*/
public function getActionRequiredParameters()
{
return array(
'color_id' => t('Color'),
'category_id' => t('Category'),
);
}
/**
* Get the required parameter for the event
*
* @access public
* @return string[]
*/
public function getEventRequiredParameters()
{
return array(
'task_id',
'task' => array(
'project_id',
'color_id',
),
);
}
/**
* Execute the action (change the category)
*
* @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'],
'category_id' => $this->getParam('category_id'),
);
return $this->taskModificationModel->update($values);
}
/**
* 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 $data['task']['color_id'] == $this->getParam('color_id');
}
}
+91
View File
@@ -0,0 +1,91 @@
<?php
namespace Kanboard\Action;
/**
* Set a category automatically according to a label
*
* @package Kanboard\Action
* @author Frederic Guillot
*/
class TaskAssignCategoryLabel extends Base
{
/**
* Get automatic action description
*
* @access public
* @return string
*/
public function getDescription()
{
return t('Change the category based on an external label');
}
/**
* Get the list of compatible events
*
* @access public
* @return array
*/
public function getCompatibleEvents()
{
return array();
}
/**
* Get the required parameter for the action (defined by the user)
*
* @access public
* @return array
*/
public function getActionRequiredParameters()
{
return array(
'label' => t('Label'),
'category_id' => t('Category'),
);
}
/**
* Get the required parameter for the event
*
* @access public
* @return string[]
*/
public function getEventRequiredParameters()
{
return array(
'task_id',
'label',
);
}
/**
* Execute the action (change the category)
*
* @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'],
'category_id' => $this->getParam('category_id'),
);
return $this->taskModificationModel->update($values);
}
/**
* 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 $data['label'] == $this->getParam('label') && empty($data['category_id']);
}
}
+102
View File
@@ -0,0 +1,102 @@
<?php
namespace Kanboard\Action;
use Kanboard\Model\TaskLinkModel;
/**
* Set a category automatically according to a task link
*
* @package Kanboard\Action
* @author Olivier Maridat
* @author Frederic Guillot
*/
class TaskAssignCategoryLink extends Base
{
/**
* Get automatic action description
*
* @access public
* @return string
*/
public function getDescription()
{
return t('Assign automatically a category based on a link');
}
/**
* Get the list of compatible events
*
* @access public
* @return array
*/
public function getCompatibleEvents()
{
return array(
TaskLinkModel::EVENT_CREATE_UPDATE,
);
}
/**
* Get the required parameter for the action (defined by the user)
*
* @access public
* @return array
*/
public function getActionRequiredParameters()
{
return array(
'category_id' => t('Category'),
'link_id' => t('Link type'),
);
}
/**
* Get the required parameter for the event
*
* @access public
* @return string[]
*/
public function getEventRequiredParameters()
{
return array(
'task_link' => array(
'task_id',
'link_id',
)
);
}
/**
* Execute the action (change the category)
*
* @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_link']['task_id'],
'category_id' => $this->getParam('category_id'),
);
return $this->taskModificationModel->update($values);
}
/**
* Check if the event data meet the action condition
*
* @access public
* @param array $data Event data dictionary
* @return bool
*/
public function hasRequiredCondition(array $data)
{
if ($data['task_link']['link_id'] == $this->getParam('link_id')) {
return empty($data['task']['category_id']);
}
return false;
}
}
@@ -0,0 +1,99 @@
<?php
namespace Kanboard\Action;
use Kanboard\Model\TaskModel;
/**
* Assign a category when the task is moved to a specific swimlane
*
* @package Kanboard\Action
* @author @Interleaved
*/
class TaskAssignCategorySwimlaneChange extends Base
{
/**
* Get automatic action description
*
* @access public
* @return string
*/
public function getDescription()
{
return t('Assign a category when the task is moved to a specific swimlane');
}
/**
* Get the list of compatible events
*
* @access public
* @return array
*/
public function getCompatibleEvents()
{
return array(
TaskModel::EVENT_CREATE,
TaskModel::EVENT_MOVE_SWIMLANE,
);
}
/**
* Get the required parameter for the action (defined by the user)
*
* @access public
* @return array
*/
public function getActionRequiredParameters()
{
return array(
'swimlane_id' => t('Swimlane'),
'category_id' => t('Category'),
);
}
/**
* Get the required parameter for the event
*
* @access public
* @return string[]
*/
public function getEventRequiredParameters()
{
return array(
'task_id',
'task' => array(
'project_id',
'swimlane_id',
)
);
}
/**
* Execute the action (set the task category)
*
* @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'],
'category_id' => $this->getParam('category_id'),
);
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 $data['task']['swimlane_id'] == $this->getParam('swimlane_id');
}
}
+98
View File
@@ -0,0 +1,98 @@
<?php
namespace Kanboard\Action;
use Kanboard\Model\TaskModel;
/**
* Assign a color to a specific category
*
* @package Kanboard\Action
* @author Frederic Guillot
*/
class TaskAssignColorCategory extends Base
{
/**
* Get automatic action description
*
* @access public
* @return string
*/
public function getDescription()
{
return t('Assign automatically a color based on a category');
}
/**
* Get the list of compatible events
*
* @access public
* @return array
*/
public function getCompatibleEvents()
{
return array(
TaskModel::EVENT_CREATE_UPDATE,
);
}
/**
* Get the required parameter for the action (defined by the user)
*
* @access public
* @return array
*/
public function getActionRequiredParameters()
{
return array(
'color_id' => t('Color'),
'category_id' => t('Category'),
);
}
/**
* Get the required parameter for the event
*
* @access public
* @return string[]
*/
public function getEventRequiredParameters()
{
return array(
'task_id',
'task' => array(
'project_id',
'category_id',
),
);
}
/**
* Execute the action (change the task color)
*
* @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'],
'color_id' => $this->getParam('color_id'),
);
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 $data['task']['category_id'] == $this->getParam('category_id');
}
}
+99
View File
@@ -0,0 +1,99 @@
<?php
namespace Kanboard\Action;
use Kanboard\Model\TaskModel;
/**
* Assign a color to a task
*
* @package Kanboard\Action
* @author Frederic Guillot
*/
class TaskAssignColorColumn extends Base
{
/**
* Get automatic action description
*
* @access public
* @return string
*/
public function getDescription()
{
return t('Assign a color when the task is moved to a specific column');
}
/**
* Get the list of compatible events
*
* @access public
* @return array
*/
public function getCompatibleEvents()
{
return array(
TaskModel::EVENT_CREATE,
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'),
'color_id' => t('Color'),
);
}
/**
* 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 color)
*
* @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'],
'color_id' => $this->getParam('color_id'),
);
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 $data['task']['column_id'] == $this->getParam('column_id');
}
}
+97
View File
@@ -0,0 +1,97 @@
<?php
namespace Kanboard\Action;
use Kanboard\Model\TaskLinkModel;
/**
* Assign a color to a specific task link
*
* @package Kanboard\Action
* @author Frederic Guillot
*/
class TaskAssignColorLink extends Base
{
/**
* Get automatic action description
*
* @access public
* @return string
*/
public function getDescription()
{
return t('Change task color when using a specific task link');
}
/**
* Get the list of compatible events
*
* @access public
* @return array
*/
public function getCompatibleEvents()
{
return array(
TaskLinkModel::EVENT_CREATE_UPDATE,
);
}
/**
* Get the required parameter for the action (defined by the user)
*
* @access public
* @return array
*/
public function getActionRequiredParameters()
{
return array(
'color_id' => t('Color'),
'link_id' => t('Link type'),
);
}
/**
* Get the required parameter for the event
*
* @access public
* @return string[]
*/
public function getEventRequiredParameters()
{
return array(
'task_link' => array(
'task_id',
'link_id',
)
);
}
/**
* Execute the action (change the task color)
*
* @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_link']['task_id'],
'color_id' => $this->getParam('color_id'),
);
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 $data['task_link']['link_id'] == $this->getParam('link_id');
}
}
+99
View File
@@ -0,0 +1,99 @@
<?php
namespace Kanboard\Action;
use Kanboard\Model\TaskModel;
/**
* Assign a color to a priority
*
* @package Kanboard\Action
* @author Julien Buratto
*/
class TaskAssignColorOnDueDate extends Base
{
/**
* Get action description
*
* @access public
* @return string
*/
public function getDescription()
{
return t('Assign automatically a color when due date is expired');
}
/**
* Get the list of compatible events
*
* @access public
* @return array
*/
public function getCompatibleEvents()
{
return array(
TaskModel::EVENT_DAILY_CRONJOB,
);
}
/**
* Get the required parameter for the action
*
* @access public
* @return array
*/
public function getActionRequiredParameters()
{
return array(
'color_id' => t('Color'),
);
}
/**
* Get all tasks
*
* @access public
* @return array
*/
public function getEventRequiredParameters()
{
return array('tasks');
}
/**
* Execute the action (change the task color)
*
* @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)
{
$results = array();
foreach ($data['tasks'] as $task) {
if ($task['date_due'] <= time() && $task['date_due'] > 0 && $task['color_id'] != $this->getParam('color_id')) {
$values = array(
'id' => $task['id'],
'color_id' => $this->getParam('color_id'),
);
$results[] = $this->taskModificationModel->update($values, false);
}
}
return in_array(true, $results, true);
}
/**
* 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 count($data['tasks']) > 0;
}
}
+99
View File
@@ -0,0 +1,99 @@
<?php
namespace Kanboard\Action;
use Kanboard\Model\TaskModel;
/**
* Assign a color when preset start date is reached
*
* @package Kanboard\Action
* @author Christian Wolter
*/
class TaskAssignColorOnStartDate extends Base
{
/**
* Get action description
*
* @access public
* @return string
*/
public function getDescription()
{
return t('Assign automatically a color when preset start date is reached');
}
/**
* Get the list of compatible events
*
* @access public
* @return array
*/
public function getCompatibleEvents()
{
return array(
TaskModel::EVENT_DAILY_CRONJOB,
);
}
/**
* Get the required parameter for the action
*
* @access public
* @return array
*/
public function getActionRequiredParameters()
{
return array(
'color_id' => t('Color'),
);
}
/**
* Get all tasks
*
* @access public
* @return array
*/
public function getEventRequiredParameters()
{
return array('tasks');
}
/**
* Execute the action (change the task color)
*
* @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)
{
$results = array();
foreach ($data['tasks'] as $task) {
if ($task['date_started'] <= time() && $task['date_started'] > 0 && $task['color_id'] != $this->getParam('color_id')) {
$values = array(
'id' => $task['id'],
'color_id' => $this->getParam('color_id'),
);
$results[] = $this->taskModificationModel->update($values, false);
}
}
return in_array(true, $results, true);
}
/**
* 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 count($data['tasks']) > 0;
}
}
+98
View File
@@ -0,0 +1,98 @@
<?php
namespace Kanboard\Action;
use Kanboard\Model\TaskModel;
/**
* Assign a color to a priority
*
* @package Kanboard\Action
* @author Frederic Guillot
*/
class TaskAssignColorPriority extends Base
{
/**
* Get automatic action description
*
* @access public
* @return string
*/
public function getDescription()
{
return t('Assign automatically a color based on a priority');
}
/**
* Get the list of compatible events
*
* @access public
* @return array
*/
public function getCompatibleEvents()
{
return array(
TaskModel::EVENT_CREATE_UPDATE,
);
}
/**
* Get the required parameter for the action (defined by the user)
*
* @access public
* @return array
*/
public function getActionRequiredParameters()
{
return array(
'color_id' => t('Color'),
'priority' => t('Priority'),
);
}
/**
* Get the required parameter for the event
*
* @access public
* @return string[]
*/
public function getEventRequiredParameters()
{
return array(
'task_id',
'task' => array(
'project_id',
'priority',
),
);
}
/**
* Execute the action (change the task color)
*
* @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'],
'color_id' => $this->getParam('color_id'),
);
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 $data['task']['priority'] == $this->getParam('priority');
}
}
+99
View File
@@ -0,0 +1,99 @@
<?php
namespace Kanboard\Action;
use Kanboard\Model\TaskModel;
/**
* Assign a color to a task based on Swimlane
*
* @package Kanboard\Action
* @author Dave Almond
*/
class TaskAssignColorSwimlane extends Base
{
/**
* Get automatic action description
*
* @access public
* @return string
*/
public function getDescription()
{
return t('Assign a color when the task is moved to a specific swimlane');
}
/**
* Get the list of compatible events
*
* @access public
* @return array
*/
public function getCompatibleEvents()
{
return array(
TaskModel::EVENT_CREATE,
TaskModel::EVENT_MOVE_SWIMLANE,
);
}
/**
* Get the required parameter for the action (defined by the user)
*
* @access public
* @return array
*/
public function getActionRequiredParameters()
{
return array(
'swimlane_id' => t('Swimlane'),
'color_id' => t('Color'),
);
}
/**
* Get the required parameter for the event
*
* @access public
* @return string[]
*/
public function getEventRequiredParameters()
{
return array(
'task_id',
'task' => array(
'project_id',
'swimlane_id',
),
);
}
/**
* Execute the action (set the task color)
*
* @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'],
'color_id' => $this->getParam('color_id'),
);
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 $data['task']['swimlane_id'] == $this->getParam('swimlane_id');
}
}
+99
View File
@@ -0,0 +1,99 @@
<?php
namespace Kanboard\Action;
use Kanboard\Model\TaskModel;
/**
* Assign a color to a specific user
*
* @package Kanboard\Action
* @author Frederic Guillot
*/
class TaskAssignColorUser extends Base
{
/**
* Get automatic action description
*
* @access public
* @return string
*/
public function getDescription()
{
return t('Assign a color to a specific user');
}
/**
* Get the list of compatible events
*
* @access public
* @return array
*/
public function getCompatibleEvents()
{
return array(
TaskModel::EVENT_CREATE,
TaskModel::EVENT_ASSIGNEE_CHANGE,
);
}
/**
* Get the required parameter for the action (defined by the user)
*
* @access public
* @return array
*/
public function getActionRequiredParameters()
{
return array(
'color_id' => t('Color'),
'user_id' => t('Assignee'),
);
}
/**
* Get the required parameter for the event
*
* @access public
* @return string[]
*/
public function getEventRequiredParameters()
{
return array(
'task_id',
'task' => array(
'project_id',
'owner_id',
),
);
}
/**
* Execute the action (change the task color)
*
* @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'],
'color_id' => $this->getParam('color_id'),
);
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 $data['task']['owner_id'] == $this->getParam('user_id');
}
}
+98
View File
@@ -0,0 +1,98 @@
<?php
namespace Kanboard\Action;
use Kanboard\Model\TaskModel;
/**
* Assign a task to the creator
*
* @package Kanboard\Action
* @author Frederic Guillot
*/
class TaskAssignCreator extends Base
{
/**
* Get automatic action description
*
* @access public
* @return string
*/
public function getDescription()
{
return t('Assign the task to its creator');
}
/**
* 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',
'creator_id',
),
);
}
/**
* 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 doAction(array $data)
{
$values = array(
'id' => $data['task_id'],
'owner_id' => $data['task']['creator_id'],
);
return $this->taskModificationModel->update($values);
}
/**
* 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 $data['task']['column_id'] == $this->getParam('column_id');
}
}
+95
View File
@@ -0,0 +1,95 @@
<?php
namespace Kanboard\Action;
use Kanboard\Model\TaskModel;
/**
* Assign a task to the logged user
*
* @package Kanboard\Action
* @author Frederic Guillot
*/
class TaskAssignCurrentUser extends Base
{
/**
* Get automatic action description
*
* @access public
* @return string
*/
public function getDescription()
{
return t('Assign the task to the person who does the action');
}
/**
* Get the list of compatible events
*
* @access public
* @return array
*/
public function getCompatibleEvents()
{
return array(
TaskModel::EVENT_CREATE,
);
}
/**
* Get the required parameter for the action (defined by the user)
*
* @access public
* @return array
*/
public function getActionRequiredParameters()
{
return array();
}
/**
* Get the required parameter for the event
*
* @access public
* @return string[]
*/
public function getEventRequiredParameters()
{
return array(
'task_id',
);
}
/**
* 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 doAction(array $data)
{
if (! $this->userSession->isLogged()) {
return false;
}
$values = array(
'id' => $data['task_id'],
'owner_id' => $this->userSession->getId(),
);
return $this->taskModificationModel->update($values);
}
/**
* 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 true;
}
}
+101
View File
@@ -0,0 +1,101 @@
<?php
namespace Kanboard\Action;
use Kanboard\Model\TaskModel;
/**
* Assign a task to the logged user on column change
*
* @package Kanboard\Action
* @author Frederic Guillot
*/
class TaskAssignCurrentUserColumn extends Base
{
/**
* Get automatic action description
*
* @access public
* @return string
*/
public function getDescription()
{
return t('Assign the task to the person who does the action when the column is changed');
}
/**
* 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
*
* @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)
{
if (! $this->userSession->isLogged()) {
return false;
}
$values = array(
'id' => $data['task_id'],
'owner_id' => $this->userSession->getId(),
);
return $this->taskModificationModel->update($values);
}
/**
* 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 $data['task']['column_id'] == $this->getParam('column_id');
}
}
@@ -0,0 +1,103 @@
<?php
namespace Kanboard\Action;
use Kanboard\Model\TaskModel;
/**
* Assign a task to the logged user on column change if no user is assigned already
*
* @package Kanboard\Action
* @author Glukose1
*/
class TaskAssignCurrentUserColumnIfNoUserAlreadySet extends Base
{
/**
* Get automatic action description
*
* @access public
* @return string
*/
public function getDescription()
{
return t('Assign a task to the logged user on column change to specified column if no user is assigned');
}
/**
* 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',
'owner_id',
),
);
}
/**
* 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 doAction(array $data)
{
if (!$this->userSession->isLogged()) {
return false;
}
if (!$data['task']['owner_id']) {
$values = array(
'id' => $data['task_id'],
'owner_id' => $this->userSession->getId(),
);
return $this->taskModificationModel->update($values);
}
return 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 $data['task']['column_id'] == $this->getParam('column_id');
}
}
@@ -0,0 +1,96 @@
<?php
namespace Kanboard\Action;
use Kanboard\Model\TaskModel;
/**
* Set the due date of task
*
* @package Kanboard\Action
* @author Frederic Guillot
*/
class TaskAssignDueDateOnCreation extends Base
{
/**
* Get automatic action description
*
* @access public
* @return string
*/
public function getDescription()
{
return t('Automatically set the due date on task creation');
}
/**
* Get the list of compatible events
*
* @access public
* @return array
*/
public function getCompatibleEvents()
{
return array(
TaskModel::EVENT_CREATE,
);
}
/**
* Get the required parameter for the action (defined by the user)
*
* @access public
* @return array
*/
public function getActionRequiredParameters()
{
return array(
'duration' => t('Duration in days')
);
}
/**
* Get the required parameter for the event
*
* @access public
* @return string[]
*/
public function getEventRequiredParameters()
{
return array(
'task_id',
'task' => array(
'project_id',
),
);
}
/**
* Execute the action (set the task color)
*
* @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_due' => strtotime('+'.$this->getParam('duration').'days'),
);
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 true;
}
}
@@ -0,0 +1,97 @@
<?php
namespace Kanboard\Action;
use Kanboard\Model\TaskModel;
/**
* Set the due date when task move away from certain column
*
* @package Kanboard\Action
* @author Stefan Krüger
*/
class TaskAssignDueDateOnMoveColumn extends Base
{
/**
* Get automatic action description
*
* @access public
* @return string
*/
public function getDescription()
{
return t('Automatically set the due date when the task is moved away from a specific 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(
'duration' => t('Duration in days'),
'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',
),
'src_column_id',
);
}
/**
* Execute the action (set the task color)
*
* @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_due' => strtotime('+'.$this->getParam('duration').'days'),
);
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['src_column_id']) && $data['src_column_id'] == $this->getParam('column_id');
}
}
+99
View File
@@ -0,0 +1,99 @@
<?php
namespace Kanboard\Action;
use Kanboard\Model\TaskModel;
/**
* Set a priority automatically according to the Swimlane
*
* @package Kanboard\Action
* @author Dave Almond
*/
class TaskAssignPrioritySwimlane extends Base
{
/**
* Get automatic action description
*
* @access public
* @return string
*/
public function getDescription()
{
return t('Assign a priority when the task is moved to a specific swimlane');
}
/**
* Get the list of compatible events
*
* @access public
* @return array
*/
public function getCompatibleEvents()
{
return array(
TaskModel::EVENT_CREATE,
TaskModel::EVENT_MOVE_SWIMLANE,
);
}
/**
* Get the required parameter for the action (defined by the user)
*
* @access public
* @return array
*/
public function getActionRequiredParameters()
{
return array(
'swimlane_id' => t('Swimlane'),
'priority' => t('Priority'),
);
}
/**
* Get the required parameter for the event
*
* @access public
* @return string[]
*/
public function getEventRequiredParameters()
{
return array(
'task_id',
'task' => array(
'project_id',
'swimlane_id',
),
);
}
/**
* Execute the action (set the priority)
*
* @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'],
'priority' => $this->getParam('priority'),
);
return $this->taskModificationModel->update($values);
}
/**
* 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 $data['task']['swimlane_id'] == $this->getParam('swimlane_id');
}
}
+99
View File
@@ -0,0 +1,99 @@
<?php
namespace Kanboard\Action;
use Kanboard\Model\TaskModel;
/**
* Assign a task to a specific user
*
* @package Kanboard\Action
* @author Frederic Guillot
*/
class TaskAssignSpecificUser extends Base
{
/**
* Get automatic action description
*
* @access public
* @return string
*/
public function getDescription()
{
return t('Assign the task to a specific user');
}
/**
* Get the list of compatible events
*
* @access public
* @return array
*/
public function getCompatibleEvents()
{
return array(
TaskModel::EVENT_CREATE_UPDATE,
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'),
'user_id' => t('Assignee'),
);
}
/**
* 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 (assign the given user)
*
* @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'],
'owner_id' => $this->getParam('user_id'),
);
return $this->taskModificationModel->update($values);
}
/**
* 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 $data['task']['column_id'] == $this->getParam('column_id');
}
}
@@ -0,0 +1,109 @@
<?php
namespace Kanboard\Action;
use Kanboard\Model\TaskModel;
/**
* Assign a Task to the creator in a specific column
*
* @package Kanboard\Action
* @author Glukose1
*/
class TaskAssignToUserOnCreationInColumn extends Base
{
/**
* Get automatic action description
*
* @access public
* @return string
*/
public function getDescription()
{
return t('Assign the task to its creator for specific columns if no assignee is set manually');
}
/**
* Get the list of compatible events
*
* @access public
* @return array
*/
public function getCompatibleEvents()
{
return array(
TaskModel::EVENT_CREATE,
);
}
/**
* 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',
'creator_id',
),
);
}
/**
* 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 doAction(array $data)
{
$assignee_id = $this->userModel->getIdByUsername($data['task']['assignee_username']);
if ($data['task']['assignee_username']) {
$values = array(
'id' => $data['task_id'],
'owner_id' => $assignee_id,
);
return $this->taskModificationModel->update($values);
}
$values = array(
'id' => $data['task_id'],
'owner_id' => $data['task']['creator_id'],
);
return $this->taskModificationModel->update($values);
}
/**
* 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 $data['task']['column_id'] == $this->getParam('column_id');
}
}
+88
View File
@@ -0,0 +1,88 @@
<?php
namespace Kanboard\Action;
/**
* Assign a task to someone
*
* @package Kanboard\Actionv
* @author Frederic Guillot
*/
class TaskAssignUser extends Base
{
/**
* Get automatic action description
*
* @access public
* @return string
*/
public function getDescription()
{
return t('Change the assignee based on an external username');
}
/**
* Get the list of compatible events
*
* @access public
* @return array
*/
public function getCompatibleEvents()
{
return array();
}
/**
* Get the required parameter for the action (defined by the user)
*
* @access public
* @return array
*/
public function getActionRequiredParameters()
{
return array();
}
/**
* Get the required parameter for the event
*
* @access public
* @return string[]
*/
public function getEventRequiredParameters()
{
return array(
'task_id',
'owner_id',
);
}
/**
* Execute the action (assign the given user)
*
* @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'],
'owner_id' => $data['owner_id'],
);
return $this->taskModificationModel->update($values);
}
/**
* 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 $this->projectPermissionModel->isAssignable($this->getProjectId(), $data['owner_id']);
}
}
@@ -0,0 +1,99 @@
<?php
namespace Kanboard\Action;
use Kanboard\Model\TaskModel;
/**
* Assign a user when the task is moved to a specific swimlane
*
* @package Kanboard\Action
* @author @Interleaved
*/
class TaskAssignUserSwimlaneChange extends Base
{
/**
* Get automatic action description
*
* @access public
* @return string
*/
public function getDescription()
{
return t('Assign the task to a specific user when the task is moved to a specific swimlane');
}
/**
* Get the list of compatible events
*
* @access public
* @return array
*/
public function getCompatibleEvents()
{
return array(
TaskModel::EVENT_CREATE,
TaskModel::EVENT_MOVE_SWIMLANE,
);
}
/**
* Get the required parameter for the action (defined by the user)
*
* @access public
* @return array
*/
public function getActionRequiredParameters()
{
return array(
'swimlane_id' => t('Swimlane'),
'user_id' => t('Assignee'),
);
}
/**
* Get the required parameter for the event
*
* @access public
* @return string[]
*/
public function getEventRequiredParameters()
{
return array(
'task_id',
'task' => array(
'project_id',
'swimlane_id',
)
);
}
/**
* Execute the action (set the task category)
*
* @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'],
'owner_id' => $this->getParam('user_id'),
);
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 $data['task']['swimlane_id'] == $this->getParam('swimlane_id');
}
}
+80
View File
@@ -0,0 +1,80 @@
<?php
namespace Kanboard\Action;
/**
* Close automatically a task
*
* @package Kanboard\Action
* @author Frederic Guillot
*/
class TaskClose extends Base
{
/**
* Get automatic action description
*
* @access public
* @return string
*/
public function getDescription()
{
return t('Close a task');
}
/**
* Get the list of compatible events
*
* @access public
* @return array
*/
public function getCompatibleEvents()
{
return array();
}
/**
* Get the required parameter for the action (defined by the user)
*
* @access public
* @return array
*/
public function getActionRequiredParameters()
{
return array();
}
/**
* Get the required parameter for the event
*
* @access public
* @return string[]
*/
public function getEventRequiredParameters()
{
return array('task_id');
}
/**
* Execute the action (close the task)
*
* @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)
{
return $this->taskStatusModel->close($data['task_id']);
}
/**
* 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 true;
}
}
+90
View File
@@ -0,0 +1,90 @@
<?php
namespace Kanboard\Action;
use Kanboard\Model\TaskModel;
/**
* Close automatically a task in a specific column
*
* @package Kanboard\Action
* @author Frederic Guillot
*/
class TaskCloseColumn extends Base
{
/**
* Get automatic action description
*
* @access public
* @return string
*/
public function getDescription()
{
return t('Close a task in a specific 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 (close the task)
*
* @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)
{
return $this->taskStatusModel->close($data['task_id']);
}
/**
* 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 $data['task']['column_id'] == $this->getParam('column_id');
}
}
+95
View File
@@ -0,0 +1,95 @@
<?php
namespace Kanboard\Action;
use Kanboard\Model\TaskModel;
/**
* Close automatically a task after when inactive
*
* @package Kanboard\Action
* @author Frederic Guillot
*/
class TaskCloseNoActivity extends Base
{
/**
* Get automatic action description
*
* @access public
* @return string
*/
public function getDescription()
{
return t('Close a task when there is no activity');
}
/**
* Get the list of compatible events
*
* @access public
* @return array
*/
public function getCompatibleEvents()
{
return array(TaskModel::EVENT_DAILY_CRONJOB);
}
/**
* Get the required parameter for the action (defined by the user)
*
* @access public
* @return array
*/
public function getActionRequiredParameters()
{
return array(
'duration' => t('Duration in days')
);
}
/**
* Get the required parameter for the event
*
* @access public
* @return string[]
*/
public function getEventRequiredParameters()
{
return array('tasks');
}
/**
* Execute the action (close the task)
*
* @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)
{
$results = array();
$max = (int)$this->getParam('duration') * 86400;
foreach ($data['tasks'] as $task) {
$duration = time() - $task['date_modification'];
if ($duration > $max) {
$results[] = $this->taskStatusModel->close($task['id']);
}
}
return in_array(true, $results, true);
}
/**
* 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 count($data['tasks']) > 0;
}
}
+96
View File
@@ -0,0 +1,96 @@
<?php
namespace Kanboard\Action;
use Kanboard\Model\TaskModel;
/**
* Close automatically a task after inactive and in a defined column
*
* @package Kanboard\Action
* @author Frederic Guillot
*/
class TaskCloseNoActivityColumn extends Base
{
/**
* Get automatic action description
*
* @access public
* @return string
*/
public function getDescription()
{
return t('Close a task when there is no activity in a specific column');
}
/**
* Get the list of compatible events
*
* @access public
* @return array
*/
public function getCompatibleEvents()
{
return array(TaskModel::EVENT_DAILY_CRONJOB);
}
/**
* Get the required parameter for the action (defined by the user)
*
* @access public
* @return array
*/
public function getActionRequiredParameters()
{
return array(
'duration' => t('Duration in days'),
'column_id' => t('Column')
);
}
/**
* Get the required parameter for the event
*
* @access public
* @return string[]
*/
public function getEventRequiredParameters()
{
return array('tasks');
}
/**
* Execute the action (close the task)
*
* @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)
{
$results = array();
$max = (int)$this->getParam('duration') * 86400;
foreach ($data['tasks'] as $task) {
$duration = time() - $task['date_modification'];
if ($duration > $max && $task['column_id'] == $this->getParam('column_id')) {
$results[] = $this->taskStatusModel->close($task['id']);
}
}
return in_array(true, $results, true);
}
/**
* 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 count($data['tasks']) > 0;
}
}
+96
View File
@@ -0,0 +1,96 @@
<?php
namespace Kanboard\Action;
use Kanboard\Model\TaskModel;
/**
* Close automatically in a defined column after a certain amount of time
*
* @package Kanboard\Action
* @author Frederic Guillot
*/
class TaskCloseNotMovedColumn extends Base
{
/**
* Get automatic action description
*
* @access public
* @return string
*/
public function getDescription()
{
return t('Close a task in a specific column when not moved during a given period');
}
/**
* Get the list of compatible events
*
* @access public
* @return array
*/
public function getCompatibleEvents()
{
return array(TaskModel::EVENT_DAILY_CRONJOB);
}
/**
* Get the required parameter for the action (defined by the user)
*
* @access public
* @return array
*/
public function getActionRequiredParameters()
{
return array(
'duration' => t('Duration in days'),
'column_id' => t('Column')
);
}
/**
* Get the required parameter for the event
*
* @access public
* @return string[]
*/
public function getEventRequiredParameters()
{
return array('tasks');
}
/**
* Execute the action (close the task)
*
* @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)
{
$results = array();
$max = (int)$this->getParam('duration') * 86400;
foreach ($data['tasks'] as $task) {
$duration = time() - $task['date_moved'];
if ($duration > $max && $task['column_id'] == $this->getParam('column_id')) {
$results[] = $this->taskStatusModel->close($task['id']);
}
}
return in_array(true, $results, true);
}
/**
* 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 count($data['tasks']) > 0;
}
}
+89
View File
@@ -0,0 +1,89 @@
<?php
namespace Kanboard\Action;
/**
* Create automatically a task from a webhook
*
* @package Kanboard\Action
* @author Frederic Guillot
*/
class TaskCreation extends Base
{
/**
* Get automatic action description
*
* @access public
* @return string
*/
public function getDescription()
{
return t('Create a task from an external provider');
}
/**
* Get the list of compatible events
*
* @access public
* @return array
*/
public function getCompatibleEvents()
{
return array();
}
/**
* Get the required parameter for the action (defined by the user)
*
* @access public
* @return array
*/
public function getActionRequiredParameters()
{
return array();
}
/**
* Get the required parameter for the event
*
* @access public
* @return string[]
*/
public function getEventRequiredParameters()
{
return array(
'project_id',
'reference',
'title',
);
}
/**
* Execute the action (create a new task)
*
* @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)
{
return (bool) $this->taskCreationModel->create(array(
'project_id' => $data['project_id'],
'title' => $data['title'],
'reference' => $data['reference'],
'description' => isset($data['description']) ? $data['description'] : '',
));
}
/**
* 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 true;
}
}
+101
View File
@@ -0,0 +1,101 @@
<?php
namespace Kanboard\Action;
use Kanboard\Model\TaskModel;
/**
* Duplicate a task to another project
*
* @package Kanboard\Action
* @author Frederic Guillot
*/
class TaskDuplicateAnotherProject extends Base
{
/**
* Get automatic action description
*
* @access public
* @return string
*/
public function getDescription()
{
return t('Duplicate the task to another project');
}
/**
* Get the list of compatible events
*
* @access public
* @return array
*/
public function getCompatibleEvents()
{
return array(
TaskModel::EVENT_MOVE_COLUMN,
TaskModel::EVENT_CLOSE,
TaskModel::EVENT_CREATE,
);
}
/**
* Get the required parameter for the action (defined by the user)
*
* @access public
* @return array
*/
public function getActionRequiredParameters()
{
return array(
'column_id' => t('Column'),
'project_id' => t('Project'),
);
}
/**
* 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 (duplicate the task to another project)
*
* @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)
{
$destination_column_id = $this->columnModel->getFirstColumnId($this->getParam('project_id'));
return (bool) $this->taskProjectDuplicationModel->duplicateToProject(
$data['task_id'],
$this->getParam('project_id'),
null,
$destination_column_id
);
}
/**
* 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 $data['task']['column_id'] == $this->getParam('column_id') && $data['task']['project_id'] != $this->getParam('project_id');
}
}
+119
View File
@@ -0,0 +1,119 @@
<?php
namespace Kanboard\Action;
use Kanboard\Model\TaskModel;
/**
* Email a task to someone
*
* @package Kanboard\Action
* @author Frederic Guillot
*/
class TaskEmail extends Base
{
/**
* Get automatic action description
*
* @access public
* @return string
*/
public function getDescription()
{
return t('Send a task by email to someone');
}
/**
* Get the list of compatible events
*
* @access public
* @return array
*/
public function getCompatibleEvents()
{
return array(
TaskModel::EVENT_MOVE_COLUMN,
TaskModel::EVENT_CLOSE,
TaskModel::EVENT_CREATE,
);
}
/**
* Get the required parameter for the action (defined by the user)
*
* @access public
* @return array
*/
public function getActionRequiredParameters()
{
return array(
'column_id' => t('Column'),
'user_id' => t('User that will receive the email'),
'subject' => t('Email subject'),
);
}
/**
* 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 (move the task to another column)
*
* @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)
{
$user = $this->userModel->getById($this->getParam('user_id'));
$subject = $this->getParam('subject');
foreach ($data["task"] as $key => $value) {
if ($value !== null) {
$placeholder = sprintf('{{%s}}', $key);
$subject = str_replace($placeholder, $value, $subject);
}
}
if (! empty($user['email'])) {
$this->emailClient->send(
$user['email'],
$user['name'] ?: $user['username'],
$subject,
$this->template->render('notification/task_create', array(
'task' => $data['task'],
))
);
return true;
}
return 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 $data['task']['column_id'] == $this->getParam('column_id');
}
}
+124
View File
@@ -0,0 +1,124 @@
<?php
namespace Kanboard\Action;
use Kanboard\Model\TaskModel;
/**
* Email a task with no activity
*
* @package Kanboard\Action
* @author Frederic Guillot
*/
class TaskEmailNoActivity extends Base
{
/**
* Get automatic action description
*
* @access public
* @return string
*/
public function getDescription()
{
return t('Send email when there is no activity on a task');
}
/**
* Get the list of compatible events
*
* @access public
* @return array
*/
public function getCompatibleEvents()
{
return array(
TaskModel::EVENT_DAILY_CRONJOB,
);
}
/**
* Get the required parameter for the action (defined by the user)
*
* @access public
* @return array
*/
public function getActionRequiredParameters()
{
return array(
'user_id' => t('User that will receive the email'),
'subject' => t('Email subject'),
'duration' => t('Duration in days'),
);
}
/**
* Get the required parameter for the event
*
* @access public
* @return string[]
*/
public function getEventRequiredParameters()
{
return array('tasks');
}
/**
* 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 count($data['tasks']) > 0;
}
/**
* Execute the action (move the task to another column)
*
* @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)
{
$results = array();
$max = (int)$this->getParam('duration') * 86400;
$user = $this->userModel->getById($this->getParam('user_id'));
if (! empty($user['email'])) {
foreach ($data['tasks'] as $task) {
$duration = time() - $task['date_modification'];
if ($duration > $max) {
$results[] = $this->sendEmail($task['id'], $user);
}
}
}
return in_array(true, $results, true);
}
/**
* Send email
*
* @access private
* @param integer $task_id
* @param array $user
* @return boolean
*/
private function sendEmail($task_id, array $user)
{
$task = $this->taskFinderModel->getDetails($task_id);
$this->emailClient->send(
$user['email'],
$user['name'] ?: $user['username'],
$this->getParam('subject'),
$this->template->render('notification/task_create', array('task' => $task))
);
return true;
}
}
+94
View File
@@ -0,0 +1,94 @@
<?php
namespace Kanboard\Action;
use Kanboard\Model\TaskModel;
/**
* Move a task to another project
*
* @package Kanboard\Action
* @author Frederic Guillot
*/
class TaskMoveAnotherProject extends Base
{
/**
* Get automatic action description
*
* @access public
* @return string
*/
public function getDescription()
{
return t('Move the task to another project');
}
/**
* Get the list of compatible events
*
* @access public
* @return array
*/
public function getCompatibleEvents()
{
return array(
TaskModel::EVENT_MOVE_COLUMN,
TaskModel::EVENT_CLOSE,
);
}
/**
* Get the required parameter for the action (defined by the user)
*
* @access public
* @return array
*/
public function getActionRequiredParameters()
{
return array(
'column_id' => t('Column'),
'project_id' => t('Project'),
);
}
/**
* 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 (move the task to another project)
*
* @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)
{
return $this->taskProjectMoveModel->moveToProject($data['task_id'], $this->getParam('project_id'));
}
/**
* 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 $data['task']['column_id'] == $this->getParam('column_id') && $data['task']['project_id'] != $this->getParam('project_id');
}
}
+104
View File
@@ -0,0 +1,104 @@
<?php
namespace Kanboard\Action;
use Kanboard\Model\TaskModel;
/**
* Move a task to another column when an assignee is set
*
* @package Kanboard\Action
* @author Francois Ferrand
*/
class TaskMoveColumnAssigned extends Base
{
/**
* Get automatic action description
*
* @access public
* @return string
*/
public function getDescription()
{
return t('Move the task to another column when assigned to a user');
}
/**
* Get the list of compatible events
*
* @access public
* @return array
*/
public function getCompatibleEvents()
{
return array(
TaskModel::EVENT_ASSIGNEE_CHANGE,
TaskModel::EVENT_UPDATE,
);
}
/**
* Get the required parameter for the action (defined by the user)
*
* @access public
* @return array
*/
public function getActionRequiredParameters()
{
return array(
'src_column_id' => t('Source column'),
'dest_column_id' => t('Destination 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',
'owner_id',
'position',
'swimlane_id',
)
);
}
/**
* Execute the action (move the task to another column)
*
* @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)
{
return $this->taskPositionModel->movePosition(
$data['task']['project_id'],
$data['task_id'],
$this->getParam('dest_column_id'),
$data['task']['position'],
$data['task']['swimlane_id'],
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 $data['task']['column_id'] == $this->getParam('src_column_id') && $data['task']['owner_id'] > 0;
}
}
+105
View File
@@ -0,0 +1,105 @@
<?php
namespace Kanboard\Action;
use Kanboard\Model\TaskModel;
/**
* Move a task to another column when the category is changed
*
* @package Kanboard\Action
* @author Francois Ferrand
*/
class TaskMoveColumnCategoryChange extends Base
{
/**
* Get automatic action description
*
* @access public
* @return string
*/
public function getDescription()
{
return t('Move the task to another column when the category is changed');
}
/**
* Get the list of compatible events
*
* @access public
* @return array
*/
public function getCompatibleEvents()
{
return array(
TaskModel::EVENT_UPDATE,
TaskModel::EVENT_CREATE,
TaskModel::EVENT_CREATE_UPDATE,
);
}
/**
* Get the required parameter for the action (defined by the user)
*
* @access public
* @return array
*/
public function getActionRequiredParameters()
{
return array(
'dest_column_id' => t('Destination column'),
'category_id' => t('Category'),
);
}
/**
* Get the required parameter for the event
*
* @access public
* @return string[]
*/
public function getEventRequiredParameters()
{
return array(
'task_id',
'task' => array(
'project_id',
'column_id',
'category_id',
'position',
'swimlane_id',
)
);
}
/**
* Execute the action (move the task to another column)
*
* @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)
{
return $this->taskPositionModel->movePosition(
$data['task']['project_id'],
$data['task_id'],
$this->getParam('dest_column_id'),
$data['task']['position'],
$data['task']['swimlane_id'],
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 $data['task']['column_id'] != $this->getParam('dest_column_id') && $data['task']['category_id'] == $this->getParam('category_id');
}
}
+102
View File
@@ -0,0 +1,102 @@
<?php
namespace Kanboard\Action;
use Kanboard\Model\TaskModel;
/**
* Move a task to another column when the task is closed
*
* @package Kanboard\Action
* @author Frederic Guillot
*/
class TaskMoveColumnClosed extends Base
{
/**
* Get automatic action description
*
* @access public
* @return string
*/
public function getDescription()
{
return t('Move the task to another column when closed');
}
/**
* Get the list of compatible events
*
* @access public
* @return array
*/
public function getCompatibleEvents()
{
return array(
TaskModel::EVENT_CLOSE,
);
}
/**
* Get the required parameter for the action (defined by the user)
*
* @access public
* @return array
*/
public function getActionRequiredParameters()
{
return array(
'dest_column_id' => t('Destination 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',
'swimlane_id',
'is_active',
)
);
}
/**
* Execute the action (move the task to another column)
*
* @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)
{
return $this->taskPositionModel->movePosition(
$data['task']['project_id'],
$data['task']['id'],
$this->getParam('dest_column_id'),
1,
$data['task']['swimlane_id'],
true,
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 $data['task']['column_id'] != $this->getParam('dest_column_id') && $data['task']['is_active'] == 0;
}
}
+104
View File
@@ -0,0 +1,104 @@
<?php
namespace Kanboard\Action;
use Kanboard\Model\TaskModel;
/**
* Move a task to another column when not moved during a given period
*
* @package Kanboard\Action
* @author Frederic Guillot
*/
class TaskMoveColumnNotMovedPeriod extends Base
{
/**
* Get automatic action description
*
* @access public
* @return string
*/
public function getDescription()
{
return t('Move the task to another column when not moved during a given period');
}
/**
* Get the list of compatible events
*
* @access public
* @return array
*/
public function getCompatibleEvents()
{
return array(TaskModel::EVENT_DAILY_CRONJOB);
}
/**
* Get the required parameter for the action (defined by the user)
*
* @access public
* @return array
*/
public function getActionRequiredParameters()
{
return array(
'duration' => t('Duration in days'),
'src_column_id' => t('Source column'),
'dest_column_id' => t('Destination column'),
);
}
/**
* Get the required parameter for the event
*
* @access public
* @return string[]
*/
public function getEventRequiredParameters()
{
return array('tasks');
}
/**
* Execute the action (close the task)
*
* @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)
{
$results = array();
$max = (int)$this->getParam('duration') * 86400;
foreach ($data['tasks'] as $task) {
$duration = time() - $task['date_moved'];
if ($duration > $max && $task['column_id'] == $this->getParam('src_column_id')) {
$results[] = $this->taskPositionModel->movePosition(
$task['project_id'],
$task['id'],
$this->getParam('dest_column_id'),
1,
$task['swimlane_id'],
false
);
}
}
return in_array(true, $results, true);
}
/**
* 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 count($data['tasks']) > 0;
}
}
+103
View File
@@ -0,0 +1,103 @@
<?php
namespace Kanboard\Action;
use Kanboard\Model\TaskModel;
/**
* Move the task from one to another column when due date is LESS than a certain number of days
*
* @package Kanboard\Action
*/
class TaskMoveColumnOnDueDate extends Base
{
/**
* Get automatic action description
*
* @access public
* @return string
*/
public function getDescription()
{
return t('Move the task to another column when the due date is less than a certain number of days');
}
/**
* Get the list of compatible events
*
* @access public
* @return array
*/
public function getCompatibleEvents()
{
return array(TaskModel::EVENT_DAILY_CRONJOB);
}
/**
* Get the required parameter for the action (defined by the user)
*
* @access public
* @return array
*/
public function getActionRequiredParameters()
{
return array(
'duration' => t('Duration in days'),
'src_column_id' => t('Source column'),
'dest_column_id' => t('Destination column'),
);
}
/**
* Get the required parameter for the event
*
* @access public
* @return string[]
*/
public function getEventRequiredParameters()
{
return array('tasks');
}
/**
* Execute the action (close the task)
*
* @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)
{
$results = array();
$min = (int)$this->getParam('duration') * 86400;
foreach ($data['tasks'] as $task) {
$duration = $task['date_due'] - time();
if ($task['date_due'] > 0 && $duration < $min && $task['column_id'] == $this->getParam('src_column_id')) {
$results[] = $this->taskPositionModel->movePosition(
$task['project_id'],
$task['id'],
$this->getParam('dest_column_id'),
1,
$task['swimlane_id'],
true
);
}
}
return in_array(true, $results, true);
}
/**
* 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 count($data['tasks']) > 0;
}
}
+101
View File
@@ -0,0 +1,101 @@
<?php
namespace Kanboard\Action;
use Kanboard\Model\TaskModel;
/**
* Move a task to another column once a predefined start date is reached
*
* @package Kanboard\Action
* @author Christian Wolter
*/
class TaskMoveColumnOnStartDate extends Base
{
/**
* Get automatic action description
*
* @access public
* @return string
*/
public function getDescription()
{
return t('Move the task to another column once a predefined start date is reached');
}
/**
* Get the list of compatible events
*
* @access public
* @return array
*/
public function getCompatibleEvents()
{
return array(TaskModel::EVENT_DAILY_CRONJOB);
}
/**
* Get the required parameter for the action (defined by the user)
*
* @access public
* @return array
*/
public function getActionRequiredParameters()
{
return array(
'src_column_id' => t('Source column'),
'dest_column_id' => t('Destination column'),
);
}
/**
* Get the required parameter for the event
*
* @access public
* @return string[]
*/
public function getEventRequiredParameters()
{
return array('tasks');
}
/**
* Execute the action (close the task)
*
* @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)
{
$results = array();
foreach ($data['tasks'] as $task) {
if ($task['date_started'] <= time() && $task['date_started'] > 0 && $task['column_id'] == $this->getParam('src_column_id')) {
$results[] = $this->taskPositionModel->movePosition(
$task['project_id'],
$task['id'],
$this->getParam('dest_column_id'),
1,
$task['swimlane_id'],
false
);
}
}
return in_array(true, $results, true);
}
/**
* 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 count($data['tasks']) > 0;
}
}
+104
View File
@@ -0,0 +1,104 @@
<?php
namespace Kanboard\Action;
use Kanboard\Model\TaskModel;
/**
* Move a task to another column when an assignee is cleared
*
* @package Kanboard\Action
* @author Francois Ferrand
*/
class TaskMoveColumnUnAssigned extends Base
{
/**
* Get automatic action description
*
* @access public
* @return string
*/
public function getDescription()
{
return t('Move the task to another column when assignee is cleared');
}
/**
* Get the list of compatible events
*
* @access public
* @return array
*/
public function getCompatibleEvents()
{
return array(
TaskModel::EVENT_ASSIGNEE_CHANGE,
TaskModel::EVENT_UPDATE,
);
}
/**
* Get the required parameter for the action (defined by the user)
*
* @access public
* @return array
*/
public function getActionRequiredParameters()
{
return array(
'src_column_id' => t('Source column'),
'dest_column_id' => t('Destination 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',
'owner_id',
'position',
'swimlane_id',
)
);
}
/**
* Execute the action (move the task to another column)
*
* @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)
{
return $this->taskPositionModel->movePosition(
$data['task']['project_id'],
$data['task_id'],
$this->getParam('dest_column_id'),
$data['task']['position'],
$data['task']['swimlane_id'],
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 $data['task']['column_id'] == $this->getParam('src_column_id') && $data['task']['owner_id'] == 0;
}
}
+107
View File
@@ -0,0 +1,107 @@
<?php
namespace Kanboard\Action;
use Kanboard\Model\TaskModel;
/**
* Move a task to another column when an assignee is set
*
* @package Kanboard\Action
* @author Francois Ferrand
*/
class TaskMoveSwimlaneAssigned extends Base
{
/**
* Get automatic action description
*
* @access public
* @return string
*/
public function getDescription()
{
return t('Move the task to another swimlane when assigned to a user');
}
/**
* Get the list of compatible events
*
* @access public
* @return array
*/
public function getCompatibleEvents()
{
return array(
TaskModel::EVENT_CREATE_UPDATE,
TaskModel::EVENT_ASSIGNEE_CHANGE,
TaskModel::EVENT_UPDATE,
);
}
/**
* Get the required parameter for the action (defined by the user)
*
* @access public
* @return array
*/
public function getActionRequiredParameters()
{
return array(
'user_id' => t('Assignee'),
'dest_swimlane_id' => t('Destination swimlane'),
);
}
/**
* Get the required parameter for the event
*
* @access public
* @return string[]
*/
public function getEventRequiredParameters()
{
return array(
'task_id',
'task' => array(
'project_id',
'column_id',
'owner_id',
'position',
'swimlane_id',
)
);
}
/**
* Execute the action (move the task to another column)
*
* @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)
{
return $this->taskPositionModel->movePosition(
$data['task']['project_id'],
$data['task_id'],
$data['task']['column_id'],
$data['task']['position'],
$this->getParam('dest_swimlane_id'),
true
);
}
/**
* 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 $data['task']['swimlane_id'] != $this->getParam('dest_swimlane_id') && $data['task']['owner_id'] == $this->getParam("user_id");
}
}
@@ -0,0 +1,103 @@
<?php
namespace Kanboard\Action;
use Kanboard\Model\TaskModel;
/**
* Move a task to another swimlane when the category is changed
*
* @package Kanboard\Action
* @author @Interleaved
*/
class TaskMoveSwimlaneCategoryChange extends Base
{
/**
* Get automatic action description
*
* @access public
* @return string
*/
public function getDescription()
{
return t('Move the task to another swimlane when the category is changed');
}
/**
* Get the list of compatible events
*
* @access public
* @return array
*/
public function getCompatibleEvents()
{
return array(
TaskModel::EVENT_UPDATE,
);
}
/**
* Get the required parameter for the action (defined by the user)
*
* @access public
* @return array
*/
public function getActionRequiredParameters()
{
return array(
'dest_swimlane_id' => t('Destination swimlane'),
'category_id' => t('Category'),
);
}
/**
* Get the required parameter for the event
*
* @access public
* @return string[]
*/
public function getEventRequiredParameters()
{
return array(
'task_id',
'task' => array(
'project_id',
'column_id',
'category_id',
'position',
'swimlane_id',
)
);
}
/**
* Execute the action (move the task to another swimlane)
*
* @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)
{
return $this->taskPositionModel->movePosition(
$data['task']['project_id'],
$data['task_id'],
$data['task']['column_id'],
$data['task']['position'],
$this->getParam('dest_swimlane_id'),
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 $data['task']['swimlane_id'] != $this->getParam('dest_swimlane_id') && $data['task']['category_id'] == $this->getParam('category_id');
}
}
+80
View File
@@ -0,0 +1,80 @@
<?php
namespace Kanboard\Action;
/**
* Open automatically a task
*
* @package Kanboard\Action
* @author Frederic Guillot
*/
class TaskOpen extends Base
{
/**
* Get automatic action description
*
* @access public
* @return string
*/
public function getDescription()
{
return t('Open a task');
}
/**
* Get the list of compatible events
*
* @access public
* @return array
*/
public function getCompatibleEvents()
{
return array();
}
/**
* Get the required parameter for the action (defined by the user)
*
* @access public
* @return array
*/
public function getActionRequiredParameters()
{
return array();
}
/**
* Get the required parameter for the event
*
* @access public
* @return string[]
*/
public function getEventRequiredParameters()
{
return array('task_id');
}
/**
* Execute the action (close the task)
*
* @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)
{
return $this->taskStatusModel->open($data['task_id']);
}
/**
* 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 true;
}
}
+97
View File
@@ -0,0 +1,97 @@
<?php
namespace Kanboard\Action;
use Kanboard\Model\TaskModel;
/**
* Set the start date of task
*
* @package Kanboard\Action
* @author Frederic Guillot
*/
class TaskUpdateStartDate extends Base
{
/**
* Get automatic action description
*
* @access public
* @return string
*/
public function getDescription()
{
return t('Automatically update the start date');
}
/**
* 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 color)
*
* @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 $data['task']['column_id'] == $this->getParam('column_id');
}
}
@@ -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 the task is moved away from a specific 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',
),
'src_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['src_column_id'] == $this->getParam('column_id');
}
}