|
<?php |
|
|
|
namespace Kanboard\Action; |
|
|
|
use Kanboard\Model\TaskModel; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TaskCloseNotMovedColumn extends Base |
|
{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
public function getDescription() |
|
{ |
|
return t('Close a task in a specific column when not moved during a given period'); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function getCompatibleEvents() |
|
{ |
|
return array(TaskModel::EVENT_DAILY_CRONJOB); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function getActionRequiredParameters() |
|
{ |
|
return array( |
|
'duration' => t('Duration in days'), |
|
'column_id' => t('Column') |
|
); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function getEventRequiredParameters() |
|
{ |
|
return array('tasks'); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function doAction(array $data) |
|
{ |
|
$results = array(); |
|
$max = $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); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function hasRequiredCondition(array $data) |
|
{ |
|
return count($data['tasks']) > 0; |
|
} |
|
} |
|
|