diff --git a/main/inc/ajax/lp.ajax.php b/main/inc/ajax/lp.ajax.php
index 9aea0c8fbe..ec9c16ab47 100644
--- a/main/inc/ajax/lp.ajax.php
+++ b/main/inc/ajax/lp.ajax.php
@@ -8,45 +8,49 @@ require_once '../global.inc.php';
api_protect_course_script(true);
$action = $_REQUEST['a'];
-$course_id = api_get_course_int_id();
-$tbl_lp_item = Database :: get_course_table(TABLE_LP_ITEM);
+$course_id = api_get_course_int_id();
+$tbl_lp_item = Database :: get_course_table(TABLE_LP_ITEM);
-switch ($action) {
+switch ($action) {
case 'add_lp_item':
- if (api_is_allowed_to_edit(null, true)) {
+ if (api_is_allowed_to_edit(null, true)) {
if ($_SESSION['oLP']) {
- //Updating the lp.modified_on
- $_SESSION['oLP']->set_modified_on();
- echo $_SESSION['oLP']->add_item($_REQUEST['parent_id'], $_REQUEST['previous_id'], $_REQUEST['type'], $_REQUEST['id'], $_REQUEST['title'], null);
+ //Updating the lp.modified_on
+ $_SESSION['oLP']->set_modified_on();
+ echo $_SESSION['oLP']->add_item($_REQUEST['parent_id'], $_REQUEST['previous_id'], $_REQUEST['type'], $_REQUEST['id'], $_REQUEST['title'], null);
}
}
- break;
+ break;
case 'update_lp_item_order':
if (api_is_allowed_to_edit(null, true)) {
$new_order = $_POST['new_order'];
- $sections = explode('^', $new_order);
+ $sections = explode('^', $new_order);
$new_array = array();
$i = 0;
+
foreach ($sections as $items) {
- list($id, $parent_id) = explode('|', $items);
- $new_array[$i]['id'] = intval($id);
- $new_array[$i]['parent_id'] = intval($parent_id);
- $i++;
- }
+ if (!empty($items)) {
+ list($id, $parent_id) = explode('|', $items);
+ $new_array[$i]['id'] = intval($id);
+ $new_array[$i]['parent_id'] = intval($parent_id);
+ $i++;
+ }
+ }
+
$counter = 1;
for ($i=0; $i < count($new_array); $i++) {
- $params = array();
+ $params = array();
$id = $new_array[$i]['id'];
if (empty($id)) {
continue;
}
$parent_id = isset($new_array[$i]['parent_id']) ? $new_array[$i]['parent_id'] : 0;
- $params['display_order'] = $counter;
+ $params['display_order'] = $counter;
$params['previous_item_id'] = isset($new_array[$i-1]) && isset($new_array[$i-1]['id']) ? $new_array[$i-1]['id'] : 0;
- $params['next_item_id'] = isset($new_array[$i+1]) && isset($new_array[$i+1]['id']) ? $new_array[$i+1]['id'] : 0;
- $params['parent_item_id'] = $parent_id;
+ $params['next_item_id'] = isset($new_array[$i+1]) && isset($new_array[$i+1]['id']) ? $new_array[$i+1]['id'] : 0;
+ $params['parent_item_id'] = $parent_id;
Database::update($tbl_lp_item, $params, array('id = ? AND c_id = ? '=> array(intval($id), $course_id)));
- $counter ++;
+ $counter ++;
}
Display::display_confirmation_message(get_lang('Saved'));
}
diff --git a/main/newscorm/learnpath.class.php b/main/newscorm/learnpath.class.php
index 71d9df0ceb..fb1ce36c45 100644
--- a/main/newscorm/learnpath.class.php
+++ b/main/newscorm/learnpath.class.php
@@ -1608,7 +1608,7 @@ class learnpath {
}
$this->last = $this->current;
// current is
- $this->current = $this->ordered_items[$index];
+ $this->current = isset($this->ordered_items[$index]) ? $this->ordered_items[$index] : null;
$this->index = $index;
if ($this->debug > 2) {
error_log('$index ' . $index);
@@ -5030,6 +5030,8 @@ class learnpath {
$this->tree_array($arrLP);
$arrLP = $this->arrMenu;
unset ($this->arrMenu);
+ $default_data = null;
+ $default_content = null;
$elements = array();
for ($i = 0; $i < count($arrLP); $i++) {
@@ -6618,7 +6620,9 @@ class learnpath {
}
$this->tree_array($arrLP);
- $arrLP = $this->arrMenu;
+
+ $arrLP = isset($this->arrMenu) ? $this->arrMenu : null;
+
unset ($this->arrMenu);
$gradebook = isset($_GET['gradebook']) ? Security :: remove_XSS($_GET['gradebook']) : null;
@@ -7914,7 +7918,7 @@ class learnpath {
$return .= ' ';
$return .= '';
- $return .= ''.
+ $return .= ''.
((!empty ($row_hot['comment'])) ? $row_hot['comment'] : Security :: remove_XSS($row_hot['title'])) . '';
$return .= '';
}
@@ -7927,7 +7931,7 @@ class learnpath {
$return .= ' ';
$return .= '
';
- $return .= '' .
+ $return .= '' .
Security :: remove_XSS(cut($row_quiz['title'], 80)).
'';
$return .= '';
@@ -7987,7 +7991,7 @@ class learnpath {
$return = '