function _views_gantt_prepare_tasks in Views Gantt 7
Modifies tasks array. Subtasks go to 'childtasks' item of parent task array.
1 call to _views_gantt_prepare_tasks()
- views_gantt_build_xml in ./
views_gantt.module - Builds XML file for dhtmlxGantt Chart.
File
- ./
views_gantt.module, line 269 - Module file for Views Gantt
Code
function _views_gantt_prepare_tasks(&$tasks) {
$relations = array();
foreach ($tasks as $key => $value) {
if ($value['parent_id']) {
$relations[$key] = $value['parent_id'];
}
}
$_tasks = $tasks;
foreach ($_tasks as $key => &$value) {
if (!empty($value['child_ids'])) {
foreach ($value['child_ids'] as $child_key) {
if (isset($tasks[$child_key])) {
$child_task = $tasks[$child_key];
$parent_id = $child_task['parent_id'];
unset($tasks[$child_key]);
$path = array_reverse(_views_gantt_task_path($parent_id, $tasks, $relations));
$t =& $tasks;
foreach ($path as $task_key) {
$t =& $t[$task_key];
}
$t[$child_key] = $child_task;
}
}
}
}
}