Пример #1
0
	private function task_item(ProjectTask $task) {
		return array(
			"id" => $task->getId(),
			"title" => clean($task->getObjectName()),
			"parent" => $task->getParentId(),
			"milestone" => $task->getMilestoneId(),
			"assignedTo" => $task->getAssignedTo()? $task->getAssignedToName():'',
			"completed" => $task->isCompleted(),
			"completedBy" => $task->getCompletedByName(),
			"isLate" => $task->isLate(),
			"daysLate" => $task->getLateInDays(),
			"priority" => $task->getPriority(),
			"percentCompleted" => $task->getPercentCompleted(),
			"duedate" => ($task->getDueDate() ? $task->getDueDate()->getTimestamp() : '0'),
			"order" => $task->getOrder()
		);
	}
Пример #2
0
	/**
	 * 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 ProjectTask $task
	 * @return ProjectTask
	 */
	function createTaskCopy(ProjectTask $task) {
		$new = new ProjectTask ();
		$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 ( ProjectTasks::maxOrder ( $new->getParentId (), $new->getMilestoneId () ) );
		$new->setStartDate ( $task->getStartDate () );
		$new->setDueDate ( $task->getDueDate () );
		return $new;
	}
 private function task_item(ProjectTask $task)
 {
     $isCurrentProject = active_project() instanceof Project && $task->getProjectId() == active_project()->getId();
     return array("id" => $task->getId(), "title" => clean($task->getObjectName()), "parent" => $task->getParentId(), "milestone" => $task->getMilestoneId(), "assignedTo" => $task->getAssignedTo() ? $task->getAssignedToName() : '', "workspaces" => $isCurrentProject ? '' : $task->getWorkspacesNamesCSV(logged_user()->getWorkspacesQuery()), "workspaceids" => $isCurrentProject ? '' : $task->getWorkspacesIdsCSV(logged_user()->getWorkspacesQuery()), "workspacecolors" => $isCurrentProject ? '' : $task->getWorkspaceColorsCSV(logged_user()->getWorkspacesQuery()), "completed" => $task->isCompleted(), "completedBy" => $task->getCompletedByName(), "isLate" => $task->isLate(), "daysLate" => $task->getLateInDays(), "priority" => $task->getPriority(), "duedate" => $task->getDueDate() ? $task->getDueDate()->getTimestamp() : '0', "order" => $task->getOrder());
 }
Пример #4
0
 /**
  * Save subtasks added in task form, at 'subtasks' tab
  * @param $parent_task: ProjectTask - The parent task to set in the subtasks to save
  * @param $subtasks_data: array - An array with all the subtasks data
  * @param $member_ids: array with the member ids to classify the subtasks
  * @return array with the application logs to generate
  */
 private function saveSubtasks($parent_task, $subtasks_data, $member_ids)
 {
     $to_log = array('add' => array(), 'edit' => array(), 'trash' => array(), 'assigned' => array());
     $subs = $parent_task->getSubscriberIds();
     $subs_array = array();
     foreach ($subs as $sid) {
         $subs_array['user_' . $sid] = 1;
     }
     if ($parent_task instanceof ProjectTask && is_array($subtasks_data)) {
         foreach ($subtasks_data as $stdata) {
             $st = null;
             if ($stdata['id'] > 0) {
                 $st = ProjectTasks::instance()->findById($stdata['id']);
                 // subtask has been deleted, delete object and continue with next subtask
                 if ($stdata['deleted'] == 1 && $st instanceof ProjectTask) {
                     /*$st->trash(false);
                     		$st->save();*/
                     DB::execute("UPDATE " . TABLE_PREFIX . "objects SET trashed_by_id=" . logged_user()->getId() . ", trashed_on=NOW() WHERE id=" . $st->getId());
                     $to_log['trash'][] = $st;
                     continue;
                 }
             }
             $new_subtask = false;
             // new subtask
             if (!$st instanceof ProjectTask) {
                 $st = new ProjectTask();
                 $new_subtask = true;
             }
             if (trim($stdata['name'] == '')) {
                 continue;
             }
             $changed = false;
             if ($st->getObjectName() != $stdata['name'] || $st->getAssignedToContactId() != $stdata['assigned_to']) {
                 $changed = true;
             }
             if ($new_subtask || $changed) {
                 if ($stdata['assigned_to'] > 0 && $stdata['assigned_to'] != $st->getAssignedToContactId()) {
                     $to_log['assigned'][] = $st;
                 }
                 $st->setParentId($parent_task->getId());
                 $st->setObjectName($stdata['name']);
                 $st->setAssignedToContactId($stdata['assigned_to']);
                 $st->setPriority(array_var($stdata, 'priority', ProjectTasks::PRIORITY_NORMAL));
                 $st->setTypeContent(config_option("wysiwyg_tasks") ? 'html' : 'text');
                 $st->save();
                 $object_controller = new ObjectController();
                 $object_controller->add_to_members($st, $member_ids);
                 $st_subs_array = $subs_array;
                 if ($stdata['assigned_to'] > 0 && !in_array($stdata['assigned_to'], $subs)) {
                     $st_subs_array['user_' . $stdata['assigned_to']] = 1;
                 }
                 $object_controller->add_subscribers($st, $st_subs_array);
                 if ($new_subtask) {
                     $to_log['add'][] = $st;
                 } else {
                     $to_log['edit'][] = $st;
                 }
             }
         }
     }
     return $to_log;
 }