foreach ($proTasks as $row) { $projects[$row['task_project']]['tasks'][] = $row; } unset($proTasks); $parents = array(); foreach ($projects as $p) { global $parents, $task_id; $parents = array(); $tnums = count($p['tasks']); for ($i = 0; $i < $tnums; $i++) { $t = $p['tasks'][$i]; if (!isset($parents[$t['task_parent']])) { $parents[$t['task_parent']] = false; } if ($t['task_parent'] == $t['task_id']) { showfiltertask($t); findfiltertaskchild($p['tasks'], $t['task_id']); } } // Check for ophans. foreach ($parents as $id => $ok) { if (!$ok) { findfiltertaskchild($p['tasks'], $id); } } } /** * the results of the above bits are stored in $filter_task_list (array) * */ // months to scroll
function findfiltertaskchild(&$tarr, $parent, $level = 0) { global $projects, $filter_task_list; $level = $level + 1; $n = count($tarr); for ($x = 0; $x < $n; $x++) { if ($tarr[$x]['task_parent'] == $parent && $tarr[$x]['task_parent'] != $tarr[$x]['task_id']) { showfiltertask($tarr[$x], $level); findfiltertaskchild($tarr, $tarr[$x]['task_id'], $level); } } }
function findfiltertaskchild(&$tarr, $parent, $level = 0) { $level++; $n = count($tarr); for ($x = 0; $x < $n; $x++) { if ($tarr[$x]['task_parent'] == $parent && $tarr[$x]['task_parent'] != $tarr[$x]['task_id']) { showfiltertask($tarr[$x], $level); findfiltertaskchild($tarr, $tarr[$x]['task_id'], $level); } } }