/** * Duplicate a task to another project (always copy to the first column) * * @access public * @param integer $task_id Task id * @param integer $project_id Destination project id * @return boolean */ public function duplicateToAnotherProject($task_id, $project_id) { $this->db->startTransaction(); $boardModel = new Board($this->db, $this->event); // Get the original task $task = $this->getById($task_id); // Cleanup data unset($task['id']); unset($task['date_completed']); // Assign new values $task['date_creation'] = time(); $task['owner_id'] = 0; $task['is_active'] = 1; $task['column_id'] = $boardModel->getFirstColumn($project_id); $task['project_id'] = $project_id; $task['position'] = $this->countByColumnId($task['project_id'], $task['column_id']); // Save task if (!$this->db->table(self::TABLE)->save($task)) { $this->db->cancelTransaction(); return false; } $task_id = $this->db->getConnection()->getLastId(); $this->db->closeTransaction(); // Trigger events $this->event->trigger(self::EVENT_CREATE, array('task_id' => $task_id) + $task); return $task_id; }