diff options
Diffstat (limited to 'app/Model')
-rwxr-xr-x | app/Model/TaskDuplication.php | 31 | ||||
-rw-r--r-- | app/Model/TaskPosition.php | 15 | ||||
-rw-r--r-- | app/Model/TaskStatus.php | 11 |
3 files changed, 19 insertions, 38 deletions
diff --git a/app/Model/TaskDuplication.php b/app/Model/TaskDuplication.php index ada3b6d6..7f9308d2 100755 --- a/app/Model/TaskDuplication.php +++ b/app/Model/TaskDuplication.php @@ -52,39 +52,40 @@ class TaskDuplication extends Base } /** - * Create task recurrence to the same project + * Duplicate recurring task * * @access public * @param integer $task_id Task id * @return boolean|integer Recurrence task id */ - public function createRecurrence($task_id) + public function duplicateRecurringTask($task_id) { $values = $this->copyFields($task_id); - if ($values['recurrence_status'] == Task::RECURE_STATUS_PENDING) - { + if ($values['recurrence_status'] == Task::RECURE_STATUS_PENDING) { + $values['recurrence_parent'] = $task_id; $values['column_id'] = $this->board->getFirstColumn($values['project_id']); - $this->recurrenceDateDue($values); - $recuretask = $this->save($task_id, $values); + $this->calculateRecurringTaskDueDate($values); + + $recurring_task_id = $this->save($task_id, $values); - if ($recuretask) - { - $recurrenceStatusUpdate = $this->db + if ($recurring_task_id > 0) { + + $parent_update = $this->db ->table(Task::TABLE) - ->eq('id',$task_id) + ->eq('id', $task_id) ->update(array( 'recurrence_status' => Task::RECURE_STATUS_PROCESSED, - 'recurrence_child' => $recuretask, + 'recurrence_child' => $recurring_task_id, )); - if($recurrenceStatusUpdate) - { - return $recuretask; + if ($parent_update) { + return $recurring_task_id; } } } + return false; } @@ -176,7 +177,7 @@ class TaskDuplication extends Base * @access private * @param array $values */ - private function recurrenceDateDue(array &$values) + private function calculateRecurringTaskDueDate(array &$values) { if (! empty($values['date_due']) && $values['recurrence_factor'] != 0) { diff --git a/app/Model/TaskPosition.php b/app/Model/TaskPosition.php index 37c1ace0..0c4beb2d 100644 --- a/app/Model/TaskPosition.php +++ b/app/Model/TaskPosition.php @@ -39,19 +39,6 @@ class TaskPosition extends Base if ($fire_events) { $this->fireEvents($original_task, $column_id, $position, $swimlane_id); } - - if ($original_task['recurrence_status'] == Task::RECURE_STATUS_PENDING - && $original_task['column_id'] != $column_id - && ( - ($original_task['column_id'] == $this->board->getFirstColumn($project_id) - && $original_task['recurrence_trigger'] == Task::RECURE_TRIGGER_FIRST) - || ($column_id == $this->board->getLastColumn($project_id) - && $original_task['recurrence_trigger'] == Task::RECURE_TRIGGER_LAST) - ) - ) - { - $this->taskDuplication->createRecurrence($task_id); - } } return $result; @@ -159,6 +146,8 @@ class TaskPosition extends Base 'src_column_id' => $task['column_id'], 'dst_column_id' => $new_column_id, 'date_moved' => $task['date_moved'], + 'recurrence_status' => $task['recurrence_status'], + 'recurrence_trigger' => $task['recurrence_trigger'], ); if ($task['swimlane_id'] != $new_swimlane_id) { diff --git a/app/Model/TaskStatus.php b/app/Model/TaskStatus.php index 1ae8bfeb..30a65e1e 100644 --- a/app/Model/TaskStatus.php +++ b/app/Model/TaskStatus.php @@ -89,9 +89,7 @@ class TaskStatus extends Base */ private function changeStatus($task_id, $status, $date_completed, $event) { - $task = $this->taskFinder->getById($task_id); - - if (!$task['id']) { + if (! $this->taskFinder->exists($task_id)) { return false; } @@ -109,13 +107,6 @@ class TaskStatus extends Base $event, new TaskEvent(array('task_id' => $task_id) + $this->taskFinder->getById($task_id)) ); - - if ($status == Task::STATUS_CLOSED - && $task['recurrence_status'] == Task::RECURE_STATUS_PENDING - && $task['recurrence_trigger'] == Task::RECURE_TRIGGER_CLOSE) - { - $this->taskDuplication->createRecurrence($task_id); - } } return $result; |