From c13abe596f03e30a9170b8c9ee09fe47c37be99d Mon Sep 17 00:00:00 2001 From: Angel Fernando Quiroz Campos Date: Tue, 18 Jul 2017 09:54:20 -0500 Subject: [PATCH] Fix parent names section in lp view - refs BT#12949 --- main/inc/ajax/lp.ajax.php | 8 +++++++- main/lp/learnpath.class.php | 6 ++++-- main/lp/lp_ajax_switch_item.php | 4 +++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/main/inc/ajax/lp.ajax.php b/main/inc/ajax/lp.ajax.php index 0e5a5cba19..370eadd6c2 100755 --- a/main/inc/ajax/lp.ajax.php +++ b/main/inc/ajax/lp.ajax.php @@ -286,9 +286,15 @@ switch ($action) { break; case 'get_parent_names': + $newItemId = isset($_GET['new_item']) ? intval($_GET['new_item']) : 0; + + if (!$newItemId) { + break; + } + /** @var \learnpath $lp */ $lp = Session::read('oLP'); - $parentNames = $lp->getCurrentItemParentNames(); + $parentNames = $lp->getCurrentItemParentNames($newItemId); $response = ''; diff --git a/main/lp/learnpath.class.php b/main/lp/learnpath.class.php index 6f69c8b06c..6176422d63 100755 --- a/main/lp/learnpath.class.php +++ b/main/lp/learnpath.class.php @@ -12573,12 +12573,14 @@ EOD; /** * Get the parent names for the current item + * @param int $newItemId Optional. The item ID * @return array */ - public function getCurrentItemParentNames() + public function getCurrentItemParentNames($newItemId = 0) { + $newItemId = $newItemId ?: $this->get_current_item_id(); $return = []; - $item = $this->getItem($this->get_current_item_id()); + $item = $this->getItem($newItemId); $parent = $this->getItem($item->get_parent()); while ($parent) { diff --git a/main/lp/lp_ajax_switch_item.php b/main/lp/lp_ajax_switch_item.php index 8fef30ff47..396af867f3 100755 --- a/main/lp/lp_ajax_switch_item.php +++ b/main/lp/lp_ajax_switch_item.php @@ -217,7 +217,9 @@ function switch_item_details($lp_id, $user_id, $view_id, $current_item, $next_it "update_toc('$mylesson_status','".$new_item_id."');". "update_progress_bar('$mycomplete','$mytotal','$myprogress_mode');"; $return .= 'updateGamificationValues(); '; - $return .= "$('#item-parent-names').load('".api_get_path(WEB_AJAX_PATH)."lp.ajax.php?a=get_parent_names');"; + $return .= "$('#item-parent-names').load('" + .api_get_path(WEB_AJAX_PATH) + ."lp.ajax.php?a=get_parent_names&new_item=$new_item_id');"; $mylp->set_error_msg(''); $mylp->prerequisites_match(); // Check the prerequisites are all complete.