From 57bedaeeeafca352053227aba91f7677381e0902 Mon Sep 17 00:00:00 2001 From: Sam Hemelryk Date: Thu, 2 Dec 2010 06:11:27 +0000 Subject: [PATCH] output-custommenu MDL-25447 Fixed up the processing of the custom menu removing the hard-coded single step down --- lib/outputcomponents.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/outputcomponents.php b/lib/outputcomponents.php index fd0dfb37170..4cbd05cde53 100644 --- a/lib/outputcomponents.php +++ b/lib/outputcomponents.php @@ -2342,9 +2342,13 @@ class custom_menu extends custom_menu_item { if (preg_match('/^(\-*)/', $line, $match) && $lastchild != null && $lastdepth !== null) { $depth = strlen($match[1]); if ($depth < $lastdepth) { - if ($lastdepth > 1) { - $depth = $lastdepth - 1; - $lastchild = $lastchild->get_parent()->get_parent()->add($bits[0], $bits[1], $bits[2], $bits[3]); + $difference = $lastdepth - $depth; + if ($lastdepth > 1 && $lastdepth != $difference) { + $tempchild = $lastchild->get_parent(); + for ($i =0; $i < $difference; $i++) { + $tempchild = $tempchild->get_parent(); + } + $lastchild = $tempchild->add($bits[0], $bits[1], $bits[2], $bits[3]); } else { $depth = 0; $lastchild = new custom_menu_item($bits[0], $bits[1], $bits[2], $bits[3]); -- 2.43.0