Commit 24407640 authored by Robert Lyon's avatar Robert Lyon
Browse files

Bug 1500215: Loop through artefact ancestors in correct order



Go from child to parent to grandparent etc.

behatnotneeded

Change-Id: If30d63483f33a50888a590875ddd979d6900c613
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
parent edf36355
...@@ -38,7 +38,7 @@ if (!$artefact->in_view_list()) { ...@@ -38,7 +38,7 @@ if (!$artefact->in_view_list()) {
// Build the path to the artefact through its parents. // Build the path to the artefact through its parents.
$artefactpath = array(); $artefactpath = array();
$ancestors = $artefact->get_item_ancestors(); $ancestors = array_reverse($artefact->get_item_ancestors());
$artefactok = false; $artefactok = false;
if (artefact_in_view($artefact, $viewid)) { if (artefact_in_view($artefact, $viewid)) {
...@@ -48,14 +48,16 @@ if (artefact_in_view($artefact, $viewid)) { ...@@ -48,14 +48,16 @@ if (artefact_in_view($artefact, $viewid)) {
if (!empty($ancestors)) { if (!empty($ancestors)) {
foreach ($ancestors as $ancestor) { foreach ($ancestors as $ancestor) {
$pathitem = artefact_instance_from_id($ancestor); if ($ancestor != $artefactid) {
if (artefact_in_view($pathitem, $viewid)) { $pathitem = artefact_instance_from_id($ancestor);
$artefactpath[] = array( if (artefact_in_view($pathitem, $viewid)) {
'url' => get_config('wwwroot') . 'artefact/artefact.php?artefact=' . $pathitem->get('id') . '&view=' . $viewid, $artefactpath[] = array(
'title' => $pathitem->display_title(), 'url' => get_config('wwwroot') . 'artefact/artefact.php?artefact=' . $pathitem->get('id') . '&view=' . $viewid,
); 'title' => $pathitem->display_title(),
$artefactok = true; );
$baseobject = $pathitem; $artefactok = true;
$baseobject = $pathitem;
}
} }
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment