/** * Save this list * * @param void * @return boolean */ function save() { if (!$this->isNew()) { $old_me = ProjectTasks::findById($this->getId(), true); if (!$old_me instanceof ProjectTask) { return; } // TODO: check this!!! // This was added cause deleting some tasks was giving an error, couldn't reproduce it again, but this solved it } if ($this->isNew() || $this->getAssignedToContactId() != $old_me->getAssignedToContactId()) { $this->setAssignedBy(logged_user()); $this->setAssignedOn(DateTimeValueLib::now()); } $due_date_changed = false; if (!$this->isNew()) { $old_due_date = $old_me->getDueDate(); $due_date = $this->getDueDate(); if ($due_date instanceof DateTimeValue) { if (!$old_due_date instanceof DateTimeValue || $old_due_date->getTimestamp() != $due_date->getTimestamp()) { $due_date_changed = true; } } else { if ($old_due_date instanceof DateTimeValue) { $due_date_changed = true; } } } //update Depth And Parents Path $parent_id_changed = false; $new_parent_id = $this->getParentId(); if (!$this->isNew()) { $old_parent_id = $old_me->getParentId(); if ($old_parent_id != $new_parent_id) { $this->updateDepthAndParentsPath($new_parent_id); } } else { $this->updateDepthAndParentsPath($new_parent_id); } parent::save(); if ($due_date_changed) { $id = $this->getId(); $sql = "UPDATE `" . TABLE_PREFIX . "object_reminders` SET\r\n\t\t\t\t`date` = date_sub((SELECT `due_date` FROM `" . TABLE_PREFIX . "project_tasks` WHERE `object_id` = {$id}),\r\n\t\t\t\t\tinterval `minutes_before` minute) WHERE `object_id` = {$id};"; DB::execute($sql); } $old_parent_id = isset($old_me) && $old_me instanceof ProjectTask ? $old_me->getParentId() : 0; if ($this->isNew() || $old_parent_id != $new_parent_id) { //update Depth And Parents Path for subtasks $subtasks = $this->getSubTasks(); if (is_array($subtasks)) { foreach ($subtasks as $subtask) { $subtask->updateDepthAndParentsPath($this->getId()); $subtask->save(); } // if } // if } return true; }
/** * Save this list * * @param void * @return boolean */ function save() { if (!$this->isNew()) { $old_me = ProjectTasks::findById($this->getId(), true); if (!$old_me instanceof ProjectTask) return; // TODO: check this!!! // This was added cause deleting some tasks was giving an error, couldn't reproduce it again, but this solved it } if ($this->isNew() || $this->getAssignedToContactId() != $old_me->getAssignedToContactId()) { $this->setAssignedBy(logged_user()); $this->setAssignedOn(DateTimeValueLib::now()); } $due_date_changed = false; if (!$this->isNew()) { $old_due_date = $old_me->getDueDate(); $due_date = $this->getDueDate(); if ($due_date instanceof DateTimeValue) { if (!$old_due_date instanceof DateTimeValue || $old_due_date->getTimestamp() != $due_date->getTimestamp()) { $due_date_changed = true; } } else { if ($old_due_date instanceof DateTimeValue) { $due_date_changed = true; } } } parent::save(); if ($due_date_changed) { $id = $this->getId(); $sql = "UPDATE `".TABLE_PREFIX."object_reminders` SET `date` = date_sub((SELECT `due_date` FROM `".TABLE_PREFIX."project_tasks` WHERE `id` = $id), interval `minutes_before` minute) WHERE `object_id` = $id;"; DB::execute($sql); } $tasks = $this->getSubTasks(); if(is_array($tasks)) { $task_ids = array(); foreach($tasks as $task) { $task_ids[] = $task->getId(); } // if } // if return true; } // save
/** * Save this list * * @param void * @return boolean */ function save() { if (!$this->isNew()) { $old_me = ProjectTasks::findById($this->getId(), true); if (!$old_me instanceof ProjectTask) { return; } // TODO: check this!!! /* This was added cause deleting some tasks was giving an error, couldn't reproduce it again, but this solved it */ } if ($this->isNew() || $this->getAssignedToCompanyId() != $old_me->getAssignedToCompanyId() || $this->getAssignedToUserId() != $old_me->getAssignedToUserId()) { $this->setAssignedBy(logged_user()); $this->setAssignedOn(DateTimeValueLib::now()); } $due_date_changed = false; if (!$this->isNew()) { $old_due_date = $old_me->getDueDate(); $due_date = $this->getDueDate(); if ($due_date instanceof DateTimeValue) { if (!$old_due_date instanceof DateTimeValue || $old_due_date->getTimestamp() != $due_date->getTimestamp()) { $due_date_changed = true; } } else { if ($old_due_date instanceof DateTimeValue) { $due_date_changed = true; } } } parent::save(); if ($due_date_changed) { $id = $this->getId(); $sql = "UPDATE `" . TABLE_PREFIX . "object_reminders` SET\n\t\t\t\t`date` = date_sub((SELECT `due_date` FROM `" . TABLE_PREFIX . "project_tasks` WHERE `id` = {$id}),\n\t\t\t\t\tinterval `minutes_before` minute) WHERE\n\t\t\t\t\t`object_manager` = 'ProjectTasks' AND `object_id` = {$id};"; DB::execute($sql); } $tasks = $this->getSubTasks(); if (is_array($tasks)) { $task_ids = array(); foreach ($tasks as $task) { $task_ids[] = $task->getId(); } // if if (count($task_ids) > 0) { ApplicationLogs::setIsPrivateForType($this->isPrivate(), 'ProjectTasks', $task_ids); } // if } // if return true; }