本文整理汇总了PHP中CTask::deepCopy方法的典型用法代码示例。如果您正苦于以下问题:PHP CTask::deepCopy方法的具体用法?PHP CTask::deepCopy怎么用?PHP CTask::deepCopy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CTask
的用法示例。
在下文中一共展示了CTask::deepCopy方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: deepCopy
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: foreach
}
*/
} 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: deepCopy
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: importTasks
/** 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
}