예제 #1
0
 public function deepCopy($destProject_id = 0, $destTask_id = 0)
 {
     global $AppUI;
     $children = $this->getChildren();
     $newObj = $this->copy($destProject_id, $destTask_id);
     $new_id = $newObj->task_id;
     if (!empty($children)) {
         $tempTask = new CTask();
         foreach ($children as $child) {
             $tempTask->load($child);
             $tempTask->htmlDecode($child);
             $newChild = $tempTask->deepCopy($destProject_id, $new_id);
             $newChild->store($AppUI);
         }
     }
     return $newObj;
 }
예제 #2
0
     }
     */
 } else {
     if ($action == 'm') {
         //move task
         if (isset($children)) {
             $t->deepMove($new_project, $new_task);
         } else {
             $t->move($new_project, $new_task);
         }
         $t->store();
     } else {
         if ($action == 'c') {
             //copy task
             if (isset($children)) {
                 $t2 = $t->deepCopy($new_project, $new_task);
             } else {
                 $t2 = $t->copy($new_project, $new_task);
             }
             $t2->store();
         } else {
             if ($action > -2 && $action < 2) {
                 //set priority
                 $t->task_priority = $action;
                 $t->store();
                 if (isset($children)) {
                     foreach ($children as $child_id) {
                         $child_t = new CTask();
                         $child_t->load($child_id);
                         $child_t->task_priority = $action;
                         $child_t->store();
예제 #3
0
 function deepCopy($destProject_id = 0, $destTask_id = 0)
 {
     $children = $this->getChildren();
     $newObj = $this->copy($destProject_id, $destTask_id);
     if (!empty($children)) {
         $tempTask = new CTask();
         $new_child_ids = array();
         foreach ($children as $child) {
             $tempTask->peek($child);
             $tempTask->htmlDecode($child);
             $newChild = $tempTask->deepCopy($destProject_id, $newObj->task_id);
             $newChild->store();
             //old id to new id translation table
             $old_id = $tempTask->task_id;
             $new_child_ids[$old_id] = $newChild->task_id;
         }
         /*
          * We cannot update beyond the new child id without complicating matters
          * by mapping "old" id's to new in an array that would be accessible in 
          * *every* level of recursive call and get executed just before returning 
          * from a given call. Also we may not want to do this as there could be 
          * good reasons for keeping some of the old non-child dependancy ids anyway
          */
         //update dependancies on old child ids to new child id
         $dep_list = $newObj->getDependencies();
         if ($dep_list) {
             $dep_array = explode(',', $dep_list);
             foreach ($dep_array as $key => $dep_id) {
                 if ($new_child_ids[$dep_id]) {
                     $dep_array[$key] = $new_child_ids[$dep_id];
                 }
             }
             $dep_list = implode(',', $dep_array);
             $newObj->updateDependencies($dep_list);
         }
     }
     $newObj->store();
     return $newObj;
 }
예제 #4
0
 /**	Import tasks from another project
  *
  *	@param	int		Project ID of the tasks come from.
  *	@return	bool	
  **/
 function importTasks($from_project_id)
 {
     // Load the original
     $origProject = new CProject();
     $origProject->load($from_project_id);
     $q = new DBQuery();
     $q->addTable('tasks');
     $q->addQuery('task_id');
     $q->addWhere('task_project =' . $from_project_id);
     $q->addWhere('task_id = task_parent');
     $sql = $q->prepare();
     $q->clear();
     $tasks = array_flip(db_loadColumn($sql));
     $origDate = new CDate($origProject->project_start_date);
     $destDate = new CDate($this->project_start_date);
     $timeOffset = $destDate->getTime() - $origDate->getTime();
     // Dependencies array
     $deps = array();
     // Copy each task into this project and get their deps
     foreach ($tasks as $orig => $void) {
         $objTask = new CTask();
         $objTask->load($orig);
         $destTask = $objTask->deepCopy($this->project_id);
         $tasks[$orig] = $destTask;
         $deps[$orig] = $objTask->getDependencies();
     }
     $q->addTable('tasks');
     $q->addQuery('task_id');
     $q->addWhere('task_project =' . $this->project_id);
     $tasks = $q->loadColumn();
     // Update dates based on new project's start date.
     $newTask = new CTask();
     foreach ($tasks as $task_id) {
         $newTask->load($task_id);
         // Fix task start date from project start date offset
         $origDate->setDate($newTask->task_start_date);
         $destDate->setDate($origDate->getTime() + $timeOffset, DATE_FORMAT_UNIXTIME);
         $destDate = $destDate->next_working_day();
         $newTask->task_start_date = $destDate->format(FMT_DATETIME_MYSQL);
         // Fix task end date from start date + work duration
         //$newTask->calc_task_end_date();
         if (!empty($newTask->task_end_date) && $newTask->task_end_date != '0000-00-00 00:00:00') {
             $origDate->setDate($newTask->task_end_date);
             $destDate->setDate($origDate->getTime() + $timeOffset, DATE_FORMAT_UNIXTIME);
             $destDate = $destDate->next_working_day();
             $newTask->task_end_date = $destDate->format(FMT_DATETIME_MYSQL);
         }
         $newTask->store();
     }
     // end Fix record integrity
 }