|
<?php |
|
|
|
namespace Kanboard\Action; |
|
|
|
use Kanboard\Model\TaskModel; |
|
use Kanboard\Model\SubtaskModel; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class StopSubtaskTimerMoveTaskColumn extends Base |
|
{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
public function getDescription() |
|
{ |
|
return t('Stop the timer of all subtasks when moving a task to another column'); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function getCompatibleEvents() |
|
{ |
|
return array( |
|
TaskModel::EVENT_MOVE_COLUMN, |
|
); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function getActionRequiredParameters() |
|
{ |
|
return array( |
|
'column_id' => t('Column'), |
|
); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function getEventRequiredParameters() |
|
{ |
|
return array( |
|
'task_id', |
|
'task' => array( |
|
'id', |
|
'column_id', |
|
'project_id', |
|
), |
|
); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function hasRequiredCondition(array $data) |
|
{ |
|
return $data['task']['column_id'] == $this->getParam('column_id'); |
|
} |
|
} |
|
|