summaryrefslogtreecommitdiff
path: root/app/Model/TaskModificationModel.php
diff options
context:
space:
mode:
Diffstat (limited to 'app/Model/TaskModificationModel.php')
-rw-r--r--app/Model/TaskModificationModel.php29
1 files changed, 21 insertions, 8 deletions
diff --git a/app/Model/TaskModificationModel.php b/app/Model/TaskModificationModel.php
index 0fc3617e..1b176a41 100644
--- a/app/Model/TaskModificationModel.php
+++ b/app/Model/TaskModificationModel.php
@@ -25,6 +25,7 @@ class TaskModificationModel extends Base
{
$original_task = $this->taskFinderModel->getById($values['id']);
+ $this->updateTags($values, $original_task);
$this->prepare($values);
$result = $this->db->table(TaskModel::TABLE)->eq('id', $original_task['id'])->update($values);
@@ -80,16 +81,11 @@ class TaskModificationModel extends Base
/**
* Prepare data before task modification
*
- * @access public
- * @param array $values Form values
+ * @access protected
+ * @param array $values
*/
- public function prepare(array &$values)
+ protected function prepare(array &$values)
{
- if (isset($values['tags'])) {
- $this->taskTagModel->save($values['project_id'], $values['id'], $values['tags']);
- unset($values['tags']);
- }
-
$values = $this->dateParser->convert($values, array('date_due'));
$values = $this->dateParser->convert($values, array('date_started'), true);
@@ -99,4 +95,21 @@ class TaskModificationModel extends Base
$values['date_modification'] = time();
}
+
+ /**
+ * Update tags
+ *
+ * @access protected
+ * @param array $values
+ * @param array $original_task
+ */
+ protected function updateTags(array &$values, array $original_task)
+ {
+ if (isset($values['tags'])) {
+ $this->taskTagModel->save($original_task['project_id'], $values['id'], $values['tags']);
+ unset($values['tags']);
+ } else {
+ $this->taskTagModel->save($original_task['project_id'], $values['id'], array());
+ }
+ }
}