|
<?php |
|
|
|
namespace Kanboard\Action; |
|
|
|
use Kanboard\Model\TaskModel; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TaskAssignColorOnDueDate extends Base |
|
{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
public function getDescription() |
|
{ |
|
return t('Assign automatically a color when due date is expired'); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function getCompatibleEvents() |
|
{ |
|
return array( |
|
TaskModel::EVENT_DAILY_CRONJOB, |
|
); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function getActionRequiredParameters() |
|
{ |
|
return array( |
|
'color_id' => t('Color'), |
|
); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function getEventRequiredParameters() |
|
{ |
|
return array('tasks'); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function hasRequiredCondition(array $data) |
|
{ |
|
return count($data['tasks']) > 0; |
|
} |
|
} |
|
|