/** * Returns an unsaved copy of the task. Copies everything except open/closed state, * anything that needs the task to have an id (like tags, properties, subtask), * administrative info like who created the task and when, etc. * * @param TemplateTask $task * @return TemplateTask */ function createTaskCopy(TemplateTask $task) { $new = new TemplateTask(); $new->setMilestoneId($task->getMilestoneId()); $new->setParentId($task->getParentId()); $new->setObjectName($task->getObjectName()); $new->setAssignedToContactId($task->getAssignedToContactId()); $new->setPriority($task->getPriority()); $new->setTimeEstimate($task->getTimeEstimate()); $new->setText($task->getText()); $new->setOrder(TemplateTasks::maxOrder($new->getParentId(), $new->getMilestoneId())); $new->setStartDate($task->getStartDate()); $new->setDueDate($task->getDueDate()); return $new; }
/** * Attach subtask to thistask * * @param TemplateTask $task * @return null */ function attachTask(TemplateTask $task) { if ($task->getParentId() == $this->getId()) { return; } $task->setParentId($this->getId()); $task->save(); if ($this->isCompleted()) { $this->open(); } }