本文整理汇总了PHP中CTask::getChildren方法的典型用法代码示例。如果您正苦于以下问题:PHP CTask::getChildren方法的具体用法?PHP CTask::getChildren怎么用?PHP CTask::getChildren使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CTask
的用法示例。
在下文中一共展示了CTask::getChildren方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: delete
/**
* @todo Parent store could be partially used
* @todo Can't delete a task with children
*/
function delete()
{
if (!$this->task_id) {
return 'invalid task id';
}
$q = new DBQuery();
if (dPgetConfig('check_task_empty_dynamic') && $this->task_parent != $this->task_id) {
//Check that we are not deleting the only child of a dynamic parent task
$task_test = new CTask();
$task_test->load($this->task_parent);
$siblings = $task_test->getChildren();
if ($task_test->task_dynamic == 1 && count($siblings) <= 1) {
return 'BadDyn_NoChild';
}
}
//load task first because we need info on it to update the parent tasks later
$task = new CTask();
$task->load($this->task_id);
//get child tasks so we can delete them too (no orphans)
$childrenlist = $task->getDeepChildren();
//delete task (if we're actually allowed to delete this task)
$err_msg = parent::delete($task->task_id, $task->task_name, $task->task_project);
if ($err_msg) {
return $err_msg;
}
$this->_action = 'deleted';
if ($task->task_parent != $task->task_id) {
//Has parent, run the update sequence, this child will no longer be in the database
$this->updateDynamics();
}
$q->clear();
//delete children
if (!empty($childrenlist)) {
foreach ($childrenlist as $child_id) {
$ctask = new CTask();
$ctask->load($child_id);
//ignore permissions on child tasks by deleteing task directly from the database
$q->setDelete('tasks');
$q->addWhere('task_id=' . $ctask->task_id);
if (!$q->exec()) {
return db_error();
}
$q->clear();
addHistory('tasks', $ctask->task_id, 'delete', $ctask->task_name, $ctask->task_project);
$this->updateDynamics();
//to update after children are deleted (see above)
}
$this->_action = 'deleted with children';
}
//delete affiliated task_logs (overrides any task_log permissions)
$q->setDelete('task_log');
if (!empty($childrenlist)) {
$q->addWhere('task_log_task IN (' . implode(', ', $childrenlist) . ', ' . $this->task_id . ')');
} else {
$q->addWhere('task_log_task=' . $this->task_id);
}
if (!$q->exec()) {
return db_error();
}
$q->clear();
//delete affiliated task_dependencies
$q->setDelete('task_dependencies');
if (!empty($childrenlist)) {
$q->addWhere('dependencies_task_id IN (' . implode(', ', $childrenlist) . ', ' . $task->task_id . ')');
} else {
$q->addWhere('dependencies_task_id=' . $task->task_id);
}
if (!$q->exec()) {
return db_error();
}
$q->clear();
// delete linked user tasks
$q->setDelete('user_tasks');
if (!empty($childrenlist)) {
$q->addWhere('task_id IN (' . implode(', ', $childrenlist) . ', ' . $task->task_id . ')');
} else {
$q->addWhere('task_id=' . $task->task_id);
}
if (!$q->exec()) {
return db_error();
}
$q->clear();
return NULL;
}
示例2: showtask_pd
//.........这里部分代码省略.........
$s .= '</td>';
// inactive
$s .= '<td nowrap="nowrap">';
$s .= $a['task_status'] == '-1' ? 'Yes' : '';
$s .= '</td>';
// add log
$s .= '<td align="center" nowrap="nowrap">';
if ($a['task_dynamic'] != 1 && 0 == $a['task_represents_project']) {
$s .= '<a href="?m=tasks&a=view&tab=1&project_id=' . $a['task_project'] . '&task_id=' . $a['task_id'] . '">' . w2PtoolTip('tasks', 'add work log to this task') . w2PshowImage('edit_add.png') . w2PendTip() . '</a>';
}
$s .= '</td>';
// dots
if ($today_view) {
$s .= '<td>';
} else {
$s .= '<td width="20%">';
}
for ($y = 0; $y < $level; $y++) {
if ($y + 1 == $level) {
$image = w2PfindImage('corner-dots.gif', $m);
} else {
$image = w2PfindImage('shim.gif', $m);
}
$s .= '<img src="' . $image . '" width="16" height="12" border="0" alt="" />';
}
// name link
if ($a['task_description']) {
$s .= w2PtoolTip('Task Description', $a['task_description'], true);
}
$jsTaskId = 'task_proj_' . $a['task_project'] . '_level-' . $level . '-task_' . $a['task_id'] . '_';
$open_link = '<a href="javascript: void(0);"><img onclick="expand_collapse(\'' . $jsTaskId . '\', \'tblProjects\',\'\',' . ($level + 1) . ');" id="' . $jsTaskId . '_collapse" src="' . w2PfindImage('icons/collapse.gif', $m) . '" border="0" align="center" ' . (!$expanded ? 'style="display:none"' : '') . ' alt="" /><img onclick="expand_collapse(\'' . $jsTaskId . '\', \'tblProjects\',\'\',' . ($level + 1) . ');" id="' . $jsTaskId . '_expand" src="' . w2PfindImage('icons/expand.gif', $m) . '" border="0" align="center" ' . ($expanded ? 'style="display:none"' : '') . ' alt="" /></a>';
$taskObj = new CTask();
$taskObj->load($a['task_id']);
if (count($taskObj->getChildren())) {
$is_parent = true;
} else {
$is_parent = false;
}
if ($a['task_milestone'] > 0) {
$s .= ' <a href="./index.php?m=tasks&a=view&task_id=' . $a['task_id'] . '" ><b>' . $a['task_name'] . '</b></a> <img src="' . w2PfindImage('icons/milestone.gif', $m) . '" border="0" alt="" /></td>';
} elseif ($a['task_dynamic'] == '1' || $is_parent) {
$s .= $open_link;
if ($a['task_dynamic'] == '1') {
$s .= ' <a href="./index.php?m=tasks&a=view&task_id=' . $a['task_id'] . '" ><b><i>' . $a['task_name'] . '</i></b></a></td>';
} else {
$s .= ' <a href="./index.php?m=tasks&a=view&task_id=' . $a['task_id'] . '" >' . $a['task_name'] . '</a></td>';
}
} else {
$s .= ' <a href="./index.php?m=tasks&a=view&task_id=' . $a['task_id'] . '" >' . $a['task_name'] . '</a></td>';
}
if ($a['task_description']) {
$s .= w2PendTip();
}
// task description
if ($PROJDESIGN_CONFIG['show_task_descriptions']) {
$s .= '<td align="justified">' . $a['task_description'] . '</td>';
}
// task owner
$s .= '<td align="left">' . '<a href="?m=admin&a=viewuser&user_id=' . $a['user_id'] . '">' . $a['contact_first_name'] . ' ' . $a['contact_last_name'] . '</a></td>';
$s .= '<td id="ignore_td_' . $a['task_id'] . '" nowrap="nowrap" align="center" style="' . $style . '">' . ($start_date ? $start_date->format($df . ' ' . $tf) : '-') . '</td>';
// duration or milestone
$s .= '<td id="ignore_td_' . $a['task_id'] . '" align="right" nowrap="nowrap" style="' . $style . '">';
$s .= $a['task_duration'] . ' ' . mb_substr($AppUI->_($durnTypes[$a['task_duration_type']]), 0, 1);
$s .= '</td>';
$s .= '<td id="ignore_td_' . $a['task_id'] . '" nowrap="nowrap" align="center" style="' . $style . '">' . ($end_date ? $end_date->format($df . ' ' . $tf) : '-') . '</td>';
if (isset($a['task_assigned_users']) && ($assigned_users = $a['task_assigned_users'])) {
示例3: check
function check()
{
global $AppUI;
if ($this->task_id === NULL) {
return 'task id is NULL';
}
// ensure changes to checkboxes are honoured
$this->task_milestone = intval($this->task_milestone);
$this->task_dynamic = intval($this->task_dynamic);
$this->task_percent_complete = intval($this->task_percent_complete);
if ($this->task_milestone) {
$this->task_duration = '0';
} else {
if (!$this->task_duration) {
$this->task_duration = '1';
}
}
if (!$this->task_creator) {
$this->task_creator = $AppUI->user_id;
}
if (!$this->task_duration_type) {
$this->task_duration_type = 1;
}
if (!$this->task_related_url) {
$this->task_related_url = '';
}
if (!$this->task_notify) {
$this->task_notify = 0;
}
/*
* Check for bad or circular task relationships (dep or child-parent).
* These checks are definately not exhaustive it is still quite possible
* to get things in a knot.
* Note: some of these checks may be problematic and might have to be removed
*/
static $addedit;
if (!isset($addedit)) {
$addedit = dPgetParam($_POST, 'dosql', '') == 'do_task_aed' ? true : false;
}
$this_dependencies = array();
/*
* If we are called from addedit then we want to use the incoming
* list of dependencies and attempt to stop bad deps from being created
*/
if ($addedit) {
$hdependencies = dPgetParam($_POST, 'hdependencies', '0');
if ($hdependencies) {
$this_dependencies = explode(',', $hdependencies);
}
} else {
$this_dependencies = explode(',', $this->getDependencies());
}
// Set to false for recursive updateDynamic calls etc.
$addedit = false;
// Has a parent
if ($this->task_id && $this->task_id != $this->task_parent) {
$this_children = $this->getChildren();
$this_child_deps = array();
foreach ($this_children as $child) {
$child_dep_str = $this->staticGetDependencies($child);
$this_child_deps = array_unique(array_merge($this_child_deps, explode(',', $child_dep_str)));
}
$current_task = $this;
$parents_children = array();
//itrative walk through parent tasks
while ($current_task->task_id != $current_task->task_parent) {
$current_parent = new CTask();
$current_parent->load($current_task->task_parent);
$parents_children = array_unique(array_merge($parents_children, $current_parent->getChildren()));
// Task parent (of any level) cannot be a child of task or its children
// extra precaution against any UI bugs allowing otherwise
if (in_array($current_parent->task_id, $parents_children)) {
return $this->task_id == $current_parent->task_parent ? 'BadParent_CircularParent' : array('BadParent_CircularGrandParent', '(' . $current_parent->task_id . ')');
}
//Task's children cannot have a parent (of any level) as a dependency
if (in_array($current_parent->task_id, $this_child_deps)) {
return 'BadParent_ChildDepOnParent';
}
//Task cannot have a parent (of any level) as a dependency
if (in_array($current_parent->task_id, $this_dependencies)) {
return $current_task == $this ? 'BadDep_CannotDependOnParent' : array('BadDep_CircularGrandParent', '(' . $current_parent->task_id . ')');
}
$parents_dependents = explode(',', $current_parent->dependentTasks());
$this_intersect = array_intersect($this_dependencies, $parents_dependents);
//Any tasks dependent on a dynamic parent task cannot be dependencies of task
if (array_sum($this_intersect)) {
$ids = '(' . implode(',', $intersect) . ')';
return array('BadDep_CircularDepOnParentDependent', $ids);
}
$current_task = $current_parent;
}
}
// parent
// Have deps
if (array_sum($this_dependencies)) {
if ($this->task_dynamic == 1) {
return 'BadDep_DynNoDep';
}
$this_dependents = $this->task_id ? explode(',', $this->dependentTasks()) : array();
// Treat parent task, like a dependent
//.........这里部分代码省略.........
示例4: elseif
$tabBox_show = 1;
if (canView('task_log')) {
$tabBox->add(W2P_BASE_DIR . '/modules/tasks/vw_logs', 'Task Logs');
}
if ($task_log_id == 0) {
if (canAdd('task_log')) {
$tabBox->add(W2P_BASE_DIR . '/modules/tasks/vw_log_update', 'Log');
}
} elseif (canEdit('task_log')) {
$tabBox->add(W2P_BASE_DIR . '/modules/tasks/vw_log_update', 'Edit Log');
} elseif (canAdd('task_log')) {
$tabBox_show = 1;
$tabBox->add(W2P_BASE_DIR . '/modules/tasks/vw_log_update', 'Log');
}
}
if (count($obj->getChildren()) > 0) {
// Has children
// settings for tasks
$f = 'children';
$min_view = true;
$tabBox_show = 1;
// in the tasks file there is an if that checks
// $_GET[task_status]; this patch is to be able to see
// child tasks withing an inactive task
$_GET['task_status'] = $obj->task_status;
$tabBox->add(W2P_BASE_DIR . '/modules/tasks/tasks', 'Child Tasks');
}
if (count($tabBox->tabs)) {
$tabBox_show = 1;
}
if ($tabBox_show == 1) {
示例5: showtask_pd_ed
function showtask_pd_ed(&$arr, $level = 0, $today_view = false)
{
global $AppUI, $w2Pconfig, $done, $userAlloc, $showEditCheckbox;
global $task_access, $PROJDESIGN_CONFIG, $m, $expanded;
$durnTypes = w2PgetSysVal('TaskDurationType');
//Check for Tasks Access
$tmpTask = new CTask();
$tmpTask->load($arr['task_id']);
$canAccess = $tmpTask->canAccess();
if (!$canAccess) {
return false;
}
$htmlHelper = new w2p_Output_HTMLHelper($AppUI);
$htmlHelper->df .= ' ' . $AppUI->getPref('TIMEFORMAT');
$htmlHelper->stageRowData($arr);
$types = w2Pgetsysval('TaskType');
$show_all_assignees = $w2Pconfig['show_all_task_assignees'] ? true : false;
$done[] = $arr['task_id'];
// prepare coloured highlight of task time information
$class = w2pFindTaskComplete($arr['task_start_date'], $arr['task_end_date'], $arr['task_percent_complete']);
$jsTaskId = 'task_proj_' . $arr['task_project'] . '_level-' . $level . '-task_' . $arr['task_id'] . '_';
if ($expanded) {
$s = '<tr id="' . $jsTaskId . '" class="' . $class . '" onclick="select_row(\'selected_task\', \'' . $arr['task_id'] . '\', \'frm_tasks\')">';
// edit icon
} else {
$s = '<tr id="' . $jsTaskId . '" class="' . $class . '" onclick="select_row(\'selected_task\', \'' . $arr['task_id'] . '\', \'frm_tasks\')" ' . ($level ? 'style="display:none"' : '') . '>';
// edit icon
}
$s .= '<td class="data _edit">';
$canEdit = $arr['task_represents_project'] ? false : true;
if ($canEdit) {
$s .= '<a href="?m=tasks&a=addedit&task_id=' . $arr['task_id'] . '">' . w2PshowImage('icons/pencil.gif', 12, 12) . '</a>';
}
$s .= '</td>';
$s .= $htmlHelper->createCell('task_percent_complete', $arr['task_percent_complete']);
$s .= $htmlHelper->createCell('task_priority', $arr['task_priority']);
$s .= $htmlHelper->createCell('user_task_priority', $arr['user_task_priority']);
$s .= $htmlHelper->createCell('other', mb_substr($task_access[$arr['task_access']], 0, 3));
$s .= $htmlHelper->createCell('other', mb_substr($types[$arr['task_type']], 0, 3));
// reminders set
$s .= $htmlHelper->createCell('other', $arr['queue_id'] ? 'Yes' : '');
$s .= $htmlHelper->createCell('other', $arr['task_status'] == -1 ? 'Yes' : '');
// add log
$s .= '<td align="center" nowrap="nowrap">';
if ($arr['task_dynamic'] != 1 && 0 == $arr['task_represents_project']) {
$s .= '<a href="?m=tasks&a=view&tab=1&project_id=' . $arr['task_project'] . '&task_id=' . $arr['task_id'] . '">' . w2PtoolTip('tasks', 'add work log to this task') . w2PshowImage('edit_add.png') . w2PendTip() . '</a>';
}
$s .= '</td>';
// dots
$s .= '<td style="width: ' . ($today_view ? '20%' : '50%') . '" class="data _name">';
for ($y = 0; $y < $level; $y++) {
if ($y + 1 == $level) {
$image = w2PfindImage('corner-dots.gif', $m);
} else {
$image = w2PfindImage('shim.gif', $m);
}
$s .= '<img src="' . $image . '" width="16" height="12" border="0" alt="" />';
}
// name link
if ($arr['task_description']) {
$s .= w2PtoolTip('Task Description', $arr['task_description'], true);
}
$jsTaskId = 'task_proj_' . $arr['task_project'] . '_level-' . $level . '-task_' . $arr['task_id'] . '_';
$open_link = '<a href="javascript: void(0);" onclick="selected_task_' . $arr['task_id'] . '.checked=true"><img onclick="expand_collapse(\'' . $jsTaskId . '\', \'tblProjects\',\'\',' . ($level + 1) . ');" id="' . $jsTaskId . '_collapse" src="' . w2PfindImage('icons/collapse.gif', $m) . '" border="0" align="center" ' . (!$expanded ? 'style="display:none"' : '') . ' alt="" /><img onclick="expand_collapse(\'' . $jsTaskId . '\', \'tblProjects\',\'\',' . ($level + 1) . ');" id="' . $jsTaskId . '_expand" src="' . w2PfindImage('icons/expand.gif', $m) . '" border="0" align="center" ' . ($expanded ? 'style="display:none"' : '') . ' alt="" /></a>';
$taskObj = new CTask();
$taskObj->load($arr['task_id']);
if (count($taskObj->getChildren())) {
$is_parent = true;
} else {
$is_parent = false;
}
if ($arr['task_milestone'] > 0) {
$s .= ' <a href="./index.php?m=tasks&a=view&task_id=' . $arr['task_id'] . '" ><b>' . $arr['task_name'] . '</b></a> <img src="' . w2PfindImage('icons/milestone.gif', $m) . '" border="0" alt="" /></td>';
} elseif ($arr['task_dynamic'] == '1' || $is_parent) {
$s .= $open_link;
if ($arr['task_dynamic'] == '1') {
$s .= ' <a href="./index.php?m=tasks&a=view&task_id=' . $arr['task_id'] . '" ><b><i>' . $arr['task_name'] . '</i></b></a></td>';
} else {
$s .= ' <a href="./index.php?m=tasks&a=view&task_id=' . $arr['task_id'] . '" >' . $arr['task_name'] . '</a></td>';
}
} else {
$s .= ' <a href="./index.php?m=tasks&a=view&task_id=' . $arr['task_id'] . '" >' . $arr['task_name'] . '</a></td>';
}
if ($arr['task_description']) {
$s .= w2PendTip();
}
// task description
if ($PROJDESIGN_CONFIG['show_task_descriptions']) {
$s .= '<td align="justified">' . $arr['task_description'] . '</td>';
}
// task owner
$s .= $htmlHelper->createCell('task_owner', $arr['contact_name']);
$s .= $htmlHelper->createCell('task_start_datetime', $arr['task_start_date']);
// duration or milestone
$s .= $htmlHelper->createCell('task_duration', $arr['task_duration'] . ' ' . mb_substr($AppUI->_($durnTypes[$arr['task_duration_type']]), 0, 1));
$s .= $htmlHelper->createCell('task_end_datetime', $arr['task_end_date']);
if (isset($arr['task_assigned_users']) && ($assigned_users = $arr['task_assigned_users'])) {
$a_u_tmp_array = array();
if ($show_all_assignees) {
$s .= '<td align="left">';
//.........这里部分代码省略.........
示例6: closeOpenedTaskRecursive
function closeOpenedTaskRecursive($task_id)
{
global $tasks_opened;
global $tasks_closed;
$tasks_closed = $tasks_closed ? $tasks_closed : array();
$tasks_opened = $tasks_opened ? $tasks_opened : array();
$close_task = new CTask();
if ($task_id > 0) {
closeOpenedTask($task_id);
$close_task->peek($task_id);
$children_to_close = $close_task->getChildren();
foreach ($children_to_close as $to_close) {
closeOpenedTaskRecursive($to_close);
}
}
}