diff options
author | Frederic Guillot <fred@kanboard.net> | 2016-05-28 19:48:22 -0400 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2016-05-28 19:48:22 -0400 |
commit | 14713b0ec7ed93ca45578da069ad4e19a7d8addf (patch) | |
tree | 79972d53f6091a1ddb17f64a6a05a5523f5d5168 /app/Model/TaskModification.php | |
parent | 936376ffe74c583d3cb819e98f53a85137fdf8bc (diff) |
Rename all models
Diffstat (limited to 'app/Model/TaskModification.php')
-rw-r--r-- | app/Model/TaskModification.php | 97 |
1 files changed, 0 insertions, 97 deletions
diff --git a/app/Model/TaskModification.php b/app/Model/TaskModification.php deleted file mode 100644 index 7e0ea8b2..00000000 --- a/app/Model/TaskModification.php +++ /dev/null @@ -1,97 +0,0 @@ -<?php - -namespace Kanboard\Model; - -use Kanboard\Core\Base; -use Kanboard\Event\TaskEvent; - -/** - * Task Modification - * - * @package model - * @author Frederic Guillot - */ -class TaskModification extends Base -{ - /** - * Update a task - * - * @access public - * @param array $values - * @param boolean $fire_events - * @return boolean - */ - public function update(array $values, $fire_events = true) - { - $original_task = $this->taskFinder->getById($values['id']); - - $this->prepare($values); - $result = $this->db->table(Task::TABLE)->eq('id', $original_task['id'])->update($values); - - if ($fire_events && $result) { - $this->fireEvents($original_task, $values); - } - - return $result; - } - - /** - * Fire events - * - * @access public - * @param array $task - * @param array $new_values - */ - public function fireEvents(array $task, array $new_values) - { - $events = array(); - $event_data = array_merge($task, $new_values, array('task_id' => $task['id'])); - - // Values changed - $event_data['changes'] = array_diff_assoc($new_values, $task); - unset($event_data['changes']['date_modification']); - - if ($this->isFieldModified('owner_id', $event_data['changes'])) { - $events[] = Task::EVENT_ASSIGNEE_CHANGE; - } elseif (! empty($event_data['changes'])) { - $events[] = Task::EVENT_CREATE_UPDATE; - $events[] = Task::EVENT_UPDATE; - } - - foreach ($events as $event) { - $this->logger->debug('Event fired: '.$event); - $this->dispatcher->dispatch($event, new TaskEvent($event_data)); - } - } - - /** - * Return true if the field is the only modified value - * - * @access public - * @param string $field - * @param array $changes - * @return boolean - */ - public function isFieldModified($field, array $changes) - { - return isset($changes[$field]) && count($changes) === 1; - } - - /** - * Prepare data before task modification - * - * @access public - * @param array $values Form values - */ - public function prepare(array &$values) - { - $values = $this->dateParser->convert($values, array('date_due')); - $values = $this->dateParser->convert($values, array('date_started'), true); - - $this->helper->model->removeFields($values, array('another_task', 'id')); - $this->helper->model->resetFields($values, array('date_due', 'date_started', 'score', 'category_id', 'time_estimated', 'time_spent')); - $this->helper->model->convertIntegerFields($values, array('priority', 'is_active', 'recurrence_status', 'recurrence_trigger', 'recurrence_factor', 'recurrence_timeframe', 'recurrence_basedate')); - - $values['date_modification'] = time(); - } -} |