Passed
Push — 1.10.x ( 615a12...380db0 )
by Angel Fernando Quiroz
53:36
created
main/newscorm/blank.php 2 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@
 block discarded – undo
1 1
 <?php
2 2
 /* For licensing terms, see /license.txt */
3 3
 /**
4
- * Script that displays a blank page (with later a message saying why)
5
- * @package chamilo.learnpath
6
- * @author Yannick Warnier <[email protected]>
7
- */
4
+     * Script that displays a blank page (with later a message saying why)
5
+     * @package chamilo.learnpath
6
+     * @author Yannick Warnier <[email protected]>
7
+     */
8 8
 // Flag to allow for anonymous user - needs to be set before global.inc.php.
9 9
 $use_anonymous = true;
10 10
 require_once '../inc/global.inc.php';
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@
 block discarded – undo
16 16
 Display::display_reduced_header();
17 17
 
18 18
 if (isset($_GET['error'])) {
19
-    switch ($_GET['error']){
19
+    switch ($_GET['error']) {
20 20
         case 'document_deleted':
21 21
             echo '<br /><br />';
22 22
             Display::display_error_message(get_lang('DocumentHasBeenDeleted'));
Please login to merge, or discard this patch.
main/newscorm/lp_move_item.php 2 patches
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -23,23 +23,23 @@
 block discarded – undo
23 23
 $htmlHeadXtra[] = '<script type="text/javascript">'.
24 24
 $_SESSION['oLP']->get_js_dropdown_array() .
25 25
 'function load_cbo(id){' ."\n" .
26
-  'if (!id) {return false;}'.
27
-  'var cbo = document.getElementById(\'previous\');' .
28
-  'for(var i = cbo.length - 1; i > 0; i--) {' .
26
+    'if (!id) {return false;}'.
27
+    'var cbo = document.getElementById(\'previous\');' .
28
+    'for(var i = cbo.length - 1; i > 0; i--) {' .
29 29
     'cbo.options[i] = null;' .
30
- '}' ."\n" .
31
-  'var k=0;' .
32
-  'for(var i = 1; i <= child_name[id].length; i++){' ."\n" .
33
-  '  cbo.options[i] = new Option(child_name[id][i-1], child_value[id][i-1]);' ."\n" .
34
-  '  k=i;' ."\n" .
35
-  '}' ."\n" .
36
-  'cbo.options[k].selected = true;'."\n" .
30
+    '}' ."\n" .
31
+    'var k=0;' .
32
+    'for(var i = 1; i <= child_name[id].length; i++){' ."\n" .
33
+    '  cbo.options[i] = new Option(child_name[id][i-1], child_value[id][i-1]);' ."\n" .
34
+    '  k=i;' ."\n" .
35
+    '}' ."\n" .
36
+    'cbo.options[k].selected = true;'."\n" .
37 37
 '}'."\n" .
38 38
 '$().ready(function() {'."\n" .
39
-  'if ($(\'#previous\')) {'."\n" .
39
+    'if ($(\'#previous\')) {'."\n" .
40 40
     'if(\'parent is\'+$(\'#idParent\').val()) {'.
41
-      'load_cbo($(\'#idParent\').val());'."\n" .
42
-  '}}'."\n" .
41
+        'load_cbo($(\'#idParent\').val());'."\n" .
42
+    '}}'."\n" .
43 43
 '});</script>'."\n" ;
44 44
 
45 45
 /* Constants and variables */
Please login to merge, or discard this patch.
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -21,26 +21,26 @@  discard block
 block discarded – undo
21 21
 
22 22
 /* Header and action code */
23 23
 $htmlHeadXtra[] = '<script type="text/javascript">'.
24
-$_SESSION['oLP']->get_js_dropdown_array() .
25
-'function load_cbo(id){' ."\n" .
24
+$_SESSION['oLP']->get_js_dropdown_array().
25
+'function load_cbo(id){'."\n".
26 26
   'if (!id) {return false;}'.
27
-  'var cbo = document.getElementById(\'previous\');' .
28
-  'for(var i = cbo.length - 1; i > 0; i--) {' .
29
-    'cbo.options[i] = null;' .
30
- '}' ."\n" .
31
-  'var k=0;' .
32
-  'for(var i = 1; i <= child_name[id].length; i++){' ."\n" .
33
-  '  cbo.options[i] = new Option(child_name[id][i-1], child_value[id][i-1]);' ."\n" .
34
-  '  k=i;' ."\n" .
35
-  '}' ."\n" .
36
-  'cbo.options[k].selected = true;'."\n" .
37
-'}'."\n" .
38
-'$().ready(function() {'."\n" .
39
-  'if ($(\'#previous\')) {'."\n" .
27
+  'var cbo = document.getElementById(\'previous\');'.
28
+  'for(var i = cbo.length - 1; i > 0; i--) {'.
29
+    'cbo.options[i] = null;'.
30
+ '}'."\n".
31
+  'var k=0;'.
32
+  'for(var i = 1; i <= child_name[id].length; i++){'."\n".
33
+  '  cbo.options[i] = new Option(child_name[id][i-1], child_value[id][i-1]);'."\n".
34
+  '  k=i;'."\n".
35
+  '}'."\n".
36
+  'cbo.options[k].selected = true;'."\n".
37
+'}'."\n".
38
+'$().ready(function() {'."\n".
39
+  'if ($(\'#previous\')) {'."\n".
40 40
     'if(\'parent is\'+$(\'#idParent\').val()) {'.
41
-      'load_cbo($(\'#idParent\').val());'."\n" .
42
-  '}}'."\n" .
43
-'});</script>'."\n" ;
41
+      'load_cbo($(\'#idParent\').val());'."\n".
42
+  '}}'."\n".
43
+'});</script>'."\n";
44 44
 
45 45
 /* Constants and variables */
46 46
 
@@ -79,11 +79,11 @@  discard block
 block discarded – undo
79 79
 /* SHOWING THE ADMIN TOOLS */
80 80
 
81 81
 if (isset($_SESSION['gradebook'])) {
82
-    $gradebook=	$_SESSION['gradebook'];
82
+    $gradebook = $_SESSION['gradebook'];
83 83
 }
84 84
 
85 85
 if (!empty($gradebook) && $gradebook == 'view') {
86
-    $interbreadcrumb[] = array (
86
+    $interbreadcrumb[] = array(
87 87
         'url' => '../gradebook/'.$_SESSION['gradebook_dest'],
88 88
         'name' => get_lang('ToolGradebook')
89 89
     );
Please login to merge, or discard this patch.
main/newscorm/lp_impress.php 3 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@
 block discarded – undo
36 36
     api_get_group_id()
37 37
 );
38 38
 if (!api_is_allowed_to_edit(null, true) && intval($visibility) == 0 ) {
39
-     api_not_allowed();
39
+        api_not_allowed();
40 40
 }
41 41
 
42 42
 if (empty($_SESSION['oLP'])) {
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
     null,
36 36
     api_get_group_id()
37 37
 );
38
-if (!api_is_allowed_to_edit(null, true) && intval($visibility) == 0 ) {
38
+if (!api_is_allowed_to_edit(null, true) && intval($visibility) == 0) {
39 39
      api_not_allowed();
40 40
 }
41 41
 
@@ -73,22 +73,22 @@  discard block
 block discarded – undo
73 73
 $html = '';
74 74
 $step = 1;
75 75
 foreach ($list as $toc) {
76
-    $x = 1000*$step;
76
+    $x = 1000 * $step;
77 77
     $html .= '<div id="step-'.$step.'" class="step slide" data-x="'.$x.'" data-y="-1500"  >';
78 78
     $html .= '<div class="impress-content">';
79 79
     $src = $_SESSION['oLP']->get_link('http', $toc['id']);
80 80
     if ($toc['type'] !== 'dokeos_chapter') {
81 81
         //just showing the src in a iframe ...
82 82
         $html .= '<h2>'.$toc['title'].'</h2>';
83
-        $html .= '<iframe border="0" frameborder="0" style="width:100%;height:600px" src="' . $src . '"></iframe>';
84
-    }else{
83
+        $html .= '<iframe border="0" frameborder="0" style="width:100%;height:600px" src="'.$src.'"></iframe>';
84
+    } else {
85 85
         $html .= "<div class='impress-title'>";
86 86
         $html .= '<h1>'.$toc['title'].'</h1>';
87 87
         $html .= "</div>";
88 88
     }
89 89
     $html .= "</div>";
90 90
     $html .= "</div>";
91
-    $step ++;
91
+    $step++;
92 92
 }
93 93
 
94 94
 //Setting the template
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -81,7 +81,7 @@
 block discarded – undo
81 81
         //just showing the src in a iframe ...
82 82
         $html .= '<h2>'.$toc['title'].'</h2>';
83 83
         $html .= '<iframe border="0" frameborder="0" style="width:100%;height:600px" src="' . $src . '"></iframe>';
84
-    }else{
84
+    } else{
85 85
         $html .= "<div class='impress-title'>";
86 86
         $html .= '<h1>'.$toc['title'].'</h1>';
87 87
         $html .= "</div>";
Please login to merge, or discard this patch.
main/newscorm/scormOrganization.class.php 2 patches
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -38,14 +38,14 @@  discard block
 block discarded – undo
38 38
                     //if ($first_item->type == XML_ELEMENT_NODE) this is already check prior to the call to this function.
39 39
                     $children = $element->childNodes;
40 40
                     foreach ($children as $child) {
41
-                         switch ($child->nodeType) {
41
+                            switch ($child->nodeType) {
42 42
                             case XML_ELEMENT_NODE:
43 43
                                 switch ($child->tagName) {
44 44
                                     case 'item':
45 45
                                          $oItem = new scormItem('manifest', $child);
46
-                                         if ($oItem->identifier != '') {
46
+                                            if ($oItem->identifier != '') {
47 47
                                             $this->items[$oItem->identifier] = $oItem;
48
-                                         }
48
+                                            }
49 49
                                         break;
50 50
                                     case 'metadata':
51 51
                                         $this->metadata = new scormMetadata('manifest', $child);
@@ -58,24 +58,24 @@  discard block
 block discarded – undo
58 58
                                         break;
59 59
                                 }
60 60
                                 break;
61
-                             case XML_TEXT_NODE:
61
+                                case XML_TEXT_NODE:
62 62
                                  break;
63
-                         }
63
+                            }
64 64
                     }
65 65
 
66 66
                     if ($element->hasAttributes()) {
67
-                         $attributes = $element->attributes;
68
-                         //$keep_href = '';
69
-                         foreach ($attributes as $attrib) {
70
-                             switch ($attrib->name) {
71
-                                 case 'identifier':
67
+                            $attributes = $element->attributes;
68
+                            //$keep_href = '';
69
+                            foreach ($attributes as $attrib) {
70
+                                switch ($attrib->name) {
71
+                                    case 'identifier':
72 72
                                      $this->identifier = $attrib->value;
73
-                                     break;
74
-                                 case 'structure':
73
+                                        break;
74
+                                    case 'structure':
75 75
                                      $this->structure = $attrib->value;
76
-                                     break;
77
-                             }
78
-                         }
76
+                                        break;
77
+                                }
78
+                            }
79 79
                     }
80 80
 
81 81
                     return true;
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -98,7 +98,7 @@
 block discarded – undo
98 98
         foreach ($this->items as $id => $dummy) {
99 99
             $abs_order = 0;
100 100
             // Passes the array as a pointer so it is modified in $list directly.
101
-            $this->items[$id]->get_flat_list($list,$abs_order, $i, 0);
101
+            $this->items[$id]->get_flat_list($list, $abs_order, $i, 0);
102 102
             $i++;
103 103
         }
104 104
 
Please login to merge, or discard this patch.
main/newscorm/storageapi.php 3 patches
Switch Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -15,52 +15,52 @@
 block discarded – undo
15 15
 }
16 16
 
17 17
 switch ($_REQUEST['action']) {
18
-    case "get":
19
-        print storage_get($_REQUEST['svuser'], $_REQUEST['svcourse'], $_REQUEST['svsco'], $_REQUEST['svkey']);
20
-        break;
21
-    case "set":
22
-        if (storage_can_set($_REQUEST['svuser'])) {
23
-            print storage_set($_REQUEST['svuser'], $_REQUEST['svcourse'], $_REQUEST['svsco'], $_REQUEST['svkey'], $_REQUEST['svvalue']);
24
-        }
25
-        break;
26
-    case "getall":
27
-        print storage_getall($_REQUEST['svuser'], $_REQUEST['svcourse'], $_REQUEST['svsco']);
28
-        break;
29
-    case "stackpush":
30
-        if (storage_can_set($_REQUEST['svuser'])) {
31
-            print storage_stack_push($_REQUEST['svuser'], $_REQUEST['svcourse'], $_REQUEST['svsco'], $_REQUEST['svkey'], $_REQUEST['svvalue']);
32
-        }
33
-        break;
34
-    case "stackpop":
35
-        if (storage_can_set($_REQUEST['svuser'])) {
36
-            print storage_stack_pop($_REQUEST['svuser'], $_REQUEST['svcourse'], $_REQUEST['svsco'], $_REQUEST['svkey']);
37
-        }
38
-        break;
39
-    case "stacklength":
40
-        print storage_stack_length($_REQUEST['svuser'], $_REQUEST['svcourse'], $_REQUEST['svsco'], $_REQUEST['svkey']);
41
-        break;
42
-    case "stackclear":
43
-        if (storage_can_set($_REQUEST['svuser'])) {
44
-            print storage_stack_clear($_REQUEST['svuser'], $_REQUEST['svcourse'], $_REQUEST['svsco'], $_REQUEST['svkey']);
45
-        }
46
-        break;
47
-    case "stackgetall":
48
-        if (storage_can_set($_REQUEST['svuser']))
49
-            print storage_stack_getall($_REQUEST['svuser'], $_REQUEST['svcourse'], $_REQUEST['svsco'], $_REQUEST['svkey']);
50
-        break;
51
-    case "getposition":
52
-        print storage_get_position($_REQUEST['svuser'], $_REQUEST['svcourse'], $_REQUEST['svsco'], $_REQUEST['svkey'], $_REQUEST['svasc']);
53
-        break;
54
-    case "getleaders":
55
-        print storage_get_leaders($_REQUEST['svuser'], $_REQUEST['svcourse'], $_REQUEST['svsco'], $_REQUEST['svkey'], $_REQUEST['svasc'], $_REQUEST['svlength']);
56
-        break;
57
-    case "usersgetall":
58
-// security issue
59
-        print "NOT allowed, security issue, see sources";
60
-//		print storage_get_all_users();
61
-        break;
62
-    default:
63
-        // Do nothing
18
+        case "get":
19
+            print storage_get($_REQUEST['svuser'], $_REQUEST['svcourse'], $_REQUEST['svsco'], $_REQUEST['svkey']);
20
+            break;
21
+        case "set":
22
+            if (storage_can_set($_REQUEST['svuser'])) {
23
+                print storage_set($_REQUEST['svuser'], $_REQUEST['svcourse'], $_REQUEST['svsco'], $_REQUEST['svkey'], $_REQUEST['svvalue']);
24
+            }
25
+            break;
26
+        case "getall":
27
+            print storage_getall($_REQUEST['svuser'], $_REQUEST['svcourse'], $_REQUEST['svsco']);
28
+            break;
29
+        case "stackpush":
30
+            if (storage_can_set($_REQUEST['svuser'])) {
31
+                print storage_stack_push($_REQUEST['svuser'], $_REQUEST['svcourse'], $_REQUEST['svsco'], $_REQUEST['svkey'], $_REQUEST['svvalue']);
32
+            }
33
+            break;
34
+        case "stackpop":
35
+            if (storage_can_set($_REQUEST['svuser'])) {
36
+                print storage_stack_pop($_REQUEST['svuser'], $_REQUEST['svcourse'], $_REQUEST['svsco'], $_REQUEST['svkey']);
37
+            }
38
+            break;
39
+        case "stacklength":
40
+            print storage_stack_length($_REQUEST['svuser'], $_REQUEST['svcourse'], $_REQUEST['svsco'], $_REQUEST['svkey']);
41
+            break;
42
+        case "stackclear":
43
+            if (storage_can_set($_REQUEST['svuser'])) {
44
+                print storage_stack_clear($_REQUEST['svuser'], $_REQUEST['svcourse'], $_REQUEST['svsco'], $_REQUEST['svkey']);
45
+            }
46
+            break;
47
+        case "stackgetall":
48
+            if (storage_can_set($_REQUEST['svuser']))
49
+                print storage_stack_getall($_REQUEST['svuser'], $_REQUEST['svcourse'], $_REQUEST['svsco'], $_REQUEST['svkey']);
50
+            break;
51
+        case "getposition":
52
+            print storage_get_position($_REQUEST['svuser'], $_REQUEST['svcourse'], $_REQUEST['svsco'], $_REQUEST['svkey'], $_REQUEST['svasc']);
53
+            break;
54
+        case "getleaders":
55
+            print storage_get_leaders($_REQUEST['svuser'], $_REQUEST['svcourse'], $_REQUEST['svsco'], $_REQUEST['svkey'], $_REQUEST['svasc'], $_REQUEST['svlength']);
56
+            break;
57
+        case "usersgetall":
58
+    // security issue
59
+            print "NOT allowed, security issue, see sources";
60
+    //		print storage_get_all_users();
61
+            break;
62
+        default:
63
+            // Do nothing
64 64
 }
65 65
 
66 66
 function storage_can_set($sv_user) {
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
         and sco_id = '$sv_sco'
104 104
         and course_id = '$sv_course'
105 105
         and sv_key = '$sv_key'
106
-        order by sv_value ".($sv_asc ? "ASC": "DESC")." limit $sv_length";
106
+        order by sv_value ".($sv_asc ? "ASC" : "DESC")." limit $sv_length";
107 107
 //	$sql_data = "select sv.user_id as user_id, sv_key as variable, sv_value as value
108 108
 //		from ".Database::get_main_table(TABLE_TRACK_STORED_VALUES)." sv
109 109
 //		where sv.user_id in (select u2.user_id from ($sql_leaders) u2)
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
         and search.sco_id = '$sv_sco'
136 136
         and search.course_id = '$sv_course'
137 137
         and search.sv_key = '$sv_key'
138
-        and list.sv_value ".($sv_asc ? "<=": ">=")." search.sv_value
138
+        and list.sv_value ".($sv_asc ? "<=" : ">=")." search.sv_value
139 139
         and list.sco_id = search.sco_id
140 140
         and list.course_id = search.course_id
141 141
         and list.sv_key = search.sv_key
Please login to merge, or discard this patch.
Braces   +6 added lines, -8 removed lines patch added patch discarded remove patch
@@ -45,8 +45,9 @@  discard block
 block discarded – undo
45 45
         }
46 46
         break;
47 47
     case "stackgetall":
48
-        if (storage_can_set($_REQUEST['svuser']))
49
-            print storage_stack_getall($_REQUEST['svuser'], $_REQUEST['svcourse'], $_REQUEST['svsco'], $_REQUEST['svkey']);
48
+        if (storage_can_set($_REQUEST['svuser'])) {
49
+                    print storage_stack_getall($_REQUEST['svuser'], $_REQUEST['svcourse'], $_REQUEST['svsco'], $_REQUEST['svkey']);
50
+        }
50 51
         break;
51 52
     case "getposition":
52 53
         print storage_get_position($_REQUEST['svuser'], $_REQUEST['svcourse'], $_REQUEST['svsco'], $_REQUEST['svkey'], $_REQUEST['svasc']);
@@ -87,8 +88,7 @@  discard block
 block discarded – undo
87 88
         } else {
88 89
             return $row['sv_value'];
89 90
         }
90
-    }
91
-    else {
91
+    } else {
92 92
         return null;
93 93
     }
94 94
 }
@@ -144,8 +144,7 @@  discard block
 block discarded – undo
144 144
     if (Database::num_rows($res) > 0) {
145 145
         $row = Database::fetch_assoc($res);
146 146
         return $row['position'];
147
-    }
148
-    else {
147
+    } else {
149 148
         return null;
150 149
     }
151 150
 }
@@ -198,8 +197,7 @@  discard block
 block discarded – undo
198 197
     if ($resorder && $resinsert) {
199 198
         Database::query("commit");
200 199
         return 1;
201
-    }
202
-    else {
200
+    } else {
203 201
         Database::query("rollback");
204 202
         return 0;
205 203
     }
Please login to merge, or discard this patch.
main/newscorm/lp_view_item.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 
65 65
 // Using the resource linker as a tool for adding resources to the learning path.
66 66
 if ($action == 'add' && $type == 'learnpathitem') {
67
-     $htmlHeadXtra[] = "<script> window.location=\"../resourcelinker/resourcelinker.php?source_id=5&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&originalresource=no\"; </script>";
67
+        $htmlHeadXtra[] = "<script> window.location=\"../resourcelinker/resourcelinker.php?source_id=5&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&originalresource=no\"; </script>";
68 68
 }
69 69
 if ((!$is_allowed_to_edit) || ($isStudentView)) {
70 70
     error_log('New LP - User not authorized in lp_view_item.php');
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 // Theme calls
99 99
 $show_learn_path = true;
100 100
 if (isset($_SESSION['oLP']) && is_object($_SESSION['oLP'])) {
101
-	$lp_theme_css = $_SESSION['oLP']->get_theme();
101
+    $lp_theme_css = $_SESSION['oLP']->get_theme();
102 102
 }
103 103
 
104 104
 if ($mode == 'fullpage') {
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 if (isset($_GET['lp_item_id'])) {
20 20
 
21 21
     // Get parameter only came from lp_view.php.
22
-    $lp_item_id  = intval($_GET['lp_item_id']);
22
+    $lp_item_id = intval($_GET['lp_item_id']);
23 23
     if (isset($_SESSION['lpobject'])) {
24 24
         $oLP = unserialize($_SESSION['lpobject']);
25 25
     }
@@ -56,8 +56,8 @@  discard block
 block discarded – undo
56 56
 $tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
57 57
 $tbl_lp_view = Database::get_course_table(TABLE_LP_VIEW);
58 58
 
59
-$isStudentView = (empty($_REQUEST['isStudentView']) ? 0 : (int)$_REQUEST['isStudentView']);
60
-$learnpath_id = (int)$_REQUEST['lp_id'];
59
+$isStudentView = (empty($_REQUEST['isStudentView']) ? 0 : (int) $_REQUEST['isStudentView']);
60
+$learnpath_id = (int) $_REQUEST['lp_id'];
61 61
 
62 62
 // Using the resource linker as a tool for adding resources to the learning path.
63 63
 if ($action == 'add' && $type == 'learnpathitem') {
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 /* SHOWING THE ADMIN TOOLS	*/
79 79
 
80 80
 if (api_is_in_gradebook()) {
81
-    $interbreadcrumb[] = array (
81
+    $interbreadcrumb[] = array(
82 82
         'url' => api_get_path(WEB_CODE_PATH).'gradebook/index.php?'.api_get_cidreq(),
83 83
         'name' => get_lang('ToolGradebook')
84 84
     );
Please login to merge, or discard this patch.
main/newscorm/scormMetadata.class.php 2 patches
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -39,60 +39,60 @@
 block discarded – undo
39 39
                 case 'manifest': // Do the same as the default.
40 40
                      $children = $element->childNodes;
41 41
                     foreach ($children as $child) {
42
-                         switch ($child->nodeType) {
43
-                             case XML_ELEMENT_NODE:
42
+                            switch ($child->nodeType) {
43
+                                case XML_ELEMENT_NODE:
44 44
                                 // Could be 'lom', 'schema', 'schemaversion' or 'location'.
45 45
                                  switch ($child->tagName) {
46
-                                     case 'lom':
46
+                                        case 'lom':
47 47
                                          $childchildren = $child->childNodes;
48
-                                         foreach ($childchildren as $childchild) {
49
-                                             $this->lom = $childchild->nodeValue;
50
-                                         }
51
-                                         break;
52
-                                     case 'schema':
48
+                                            foreach ($childchildren as $childchild) {
49
+                                                $this->lom = $childchild->nodeValue;
50
+                                            }
51
+                                            break;
52
+                                        case 'schema':
53 53
                                          $childchildren = $child->childNodes;
54
-                                         foreach ($childchildren as $childchild) {
55
-                                             // There is generally only one child here.
56
-                                             $this->schema = $childchild->nodeValue;
57
-                                         }
58
-                                         break;
59
-                                     case 'schemaversion':
54
+                                            foreach ($childchildren as $childchild) {
55
+                                                // There is generally only one child here.
56
+                                                $this->schema = $childchild->nodeValue;
57
+                                            }
58
+                                            break;
59
+                                        case 'schemaversion':
60 60
                                          $childchildren = $child->childNodes;
61
-                                         foreach ($childchildren as $childchild) {
62
-                                             // There is generally only one child here.
63
-                                             $this->schemaversion = $childchild->nodeValue;
64
-                                         }
65
-                                         break;
66
-                                     case 'location':
61
+                                            foreach ($childchildren as $childchild) {
62
+                                                // There is generally only one child here.
63
+                                                $this->schemaversion = $childchild->nodeValue;
64
+                                            }
65
+                                            break;
66
+                                        case 'location':
67 67
                                          $childchildren = $child->childNodes;
68
-                                         foreach ($childchildren as $childchild) {
69
-                                             // There is generally only one child here.
70
-                                             $this->location = $childchild->nodeValue;
71
-                                         }
72
-                                         break;
73
-                                 }
74
-                                 break;
75
-                             case XML_TEXT_NODE:
68
+                                            foreach ($childchildren as $childchild) {
69
+                                                // There is generally only one child here.
70
+                                                $this->location = $childchild->nodeValue;
71
+                                            }
72
+                                            break;
73
+                                    }
74
+                                    break;
75
+                                case XML_TEXT_NODE:
76 76
                                  if (trim($child->textContent) != '') {
77
-                                     if (count($children == 1)) {
78
-                                         // If this is the only child at this level and it is a content... save differently.
79
-                                         $this->text = $child->textContent;
80
-                                     } else {
81
-                                         $this->text[$element->tagName] = $child->textContent;
82
-                                     }
83
-                                 }
84
-                                 break;
85
-                         }
86
-                     }
87
-                     $attributes = $element->attributes;
88
-                     //$keep_href = '';
89
-                     if (is_array($attributes)) {
90
-                         foreach ($attributes as $attrib) {
91
-                             if (trim($attrib->value) != ''){
92
-                                 $this->attribs[$attrib->name] = $attrib->value;
93
-                             }
94
-                         }
95
-                     }
77
+                                        if (count($children == 1)) {
78
+                                            // If this is the only child at this level and it is a content... save differently.
79
+                                            $this->text = $child->textContent;
80
+                                        } else {
81
+                                            $this->text[$element->tagName] = $child->textContent;
82
+                                        }
83
+                                    }
84
+                                    break;
85
+                            }
86
+                        }
87
+                        $attributes = $element->attributes;
88
+                        //$keep_href = '';
89
+                        if (is_array($attributes)) {
90
+                            foreach ($attributes as $attrib) {
91
+                                if (trim($attrib->value) != ''){
92
+                                    $this->attribs[$attrib->name] = $attrib->value;
93
+                                }
94
+                            }
95
+                        }
96 96
                     return true;
97 97
                     //break;
98 98
             }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -88,7 +88,7 @@
 block discarded – undo
88 88
                      //$keep_href = '';
89 89
                      if (is_array($attributes)) {
90 90
                          foreach ($attributes as $attrib) {
91
-                             if (trim($attrib->value) != ''){
91
+                             if (trim($attrib->value) != '') {
92 92
                                  $this->attribs[$attrib->name] = $attrib->value;
93 93
                              }
94 94
                          }
Please login to merge, or discard this patch.
main/newscorm/scormItem.class.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
                                         }
101 101
                                         break;
102 102
                                     case 'item':
103
-                                        $oItem = new scormItem('manifest',$child);
103
+                                        $oItem = new scormItem('manifest', $child);
104 104
                                         if ($oItem->identifier != '') {
105 105
                                             $this->sub_items[$oItem->identifier] = $oItem;
106 106
                                         }
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
                         $attributes = $element->attributes;
120 120
                         //$keep_href = '';
121 121
                         foreach ($attributes as $attrib) {
122
-                            switch($attrib->name){
122
+                            switch ($attrib->name) {
123 123
                                 case 'identifier':
124 124
                                     $this->identifier = $attrib->value;
125 125
                                     break;
@@ -172,8 +172,8 @@  discard block
 block discarded – undo
172 172
         );
173 173
         $abs_order++;
174 174
         $i = 1;
175
-        foreach($this->sub_items as $id => $dummy) {
176
-            $oSubitem =& $this->sub_items[$id];
175
+        foreach ($this->sub_items as $id => $dummy) {
176
+            $oSubitem = & $this->sub_items[$id];
177 177
             $oSubitem->get_flat_list($list, $abs_order, $i, $level + 1);
178 178
             $i++;
179 179
         }
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
         parent::save($from_outside, $prereqs_complete);
189 189
         // Under certain conditions, the scorm_contact should not be set, because no scorm signal was sent.
190 190
         $this->scorm_contact = true;
191
-        if (!$this->scorm_contact){
191
+        if (!$this->scorm_contact) {
192 192
             //error_log('New LP - was expecting SCORM message but none received', 0);
193 193
         }
194 194
     }
Please login to merge, or discard this patch.
main/newscorm/lp_controller.php 4 patches
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -538,17 +538,17 @@  discard block
 block discarded – undo
538 538
                 if (isset($_REQUEST['activate_start_date_check']) &&
539 539
                     $_REQUEST['activate_start_date_check'] == 1
540 540
                 ) {
541
-                	$publicated_on = $_REQUEST['publicated_on'];
541
+                    $publicated_on = $_REQUEST['publicated_on'];
542 542
                 } else {
543
-                	$publicated_on = null;
543
+                    $publicated_on = null;
544 544
                 }
545 545
 
546 546
                 if (isset($_REQUEST['activate_end_date_check']) &&
547 547
                     $_REQUEST['activate_end_date_check'] == 1
548 548
                 ) {
549
-                	$expired_on = $_REQUEST['expired_on'];
549
+                    $expired_on = $_REQUEST['expired_on'];
550 550
                 } else {
551
-                	$expired_on = null;
551
+                    $expired_on = null;
552 552
                 }
553 553
 
554 554
                 $new_lp_id = learnpath::add_lp(
@@ -937,9 +937,9 @@  discard block
 block discarded – undo
937 937
             $_SESSION['oLP']->setSubscribeUsers($_REQUEST['subscribe_users']);
938 938
 
939 939
             if (isset($_REQUEST['activate_start_date_check']) && $_REQUEST['activate_start_date_check'] == 1) {
940
-            	$publicated_on  = $_REQUEST['publicated_on'];
940
+                $publicated_on  = $_REQUEST['publicated_on'];
941 941
             } else {
942
-            	$publicated_on = null;
942
+                $publicated_on = null;
943 943
             }
944 944
 
945 945
             if (isset($_REQUEST['activate_end_date_check']) && $_REQUEST['activate_end_date_check'] == 1) {
@@ -1151,7 +1151,7 @@  discard block
 block discarded – undo
1151 1151
         } elseif ($mode == 'embedded') {
1152 1152
             $_SESSION['oLP']->mode = 'embedded';
1153 1153
         } elseif ($mode == 'embedframe') {
1154
-        	$_SESSION['oLP']->mode = 'embedframe';
1154
+            $_SESSION['oLP']->mode = 'embedframe';
1155 1155
         } elseif ($mode == 'impress') {
1156 1156
             $_SESSION['oLP']->mode = 'impress';
1157 1157
         }
@@ -1189,11 +1189,11 @@  discard block
 block discarded – undo
1189 1189
 		require 'lp_list.php';
1190 1190
 		break;
1191 1191
      */
1192
-	case 'switch_attempt_mode':
1193
-		if($debug>0) error_log('New LP - switch_reinit action triggered',0);
1194
-		if(!$lp_found){ error_log('New LP - No learnpath given for switch',0); require 'lp_list.php'; }
1195
-		$_SESSION['refresh'] = 1;
1196
-		$_SESSION['oLP']->switch_attempt_mode();
1192
+    case 'switch_attempt_mode':
1193
+        if($debug>0) error_log('New LP - switch_reinit action triggered',0);
1194
+        if(!$lp_found){ error_log('New LP - No learnpath given for switch',0); require 'lp_list.php'; }
1195
+        $_SESSION['refresh'] = 1;
1196
+        $_SESSION['oLP']->switch_attempt_mode();
1197 1197
         require 'lp_list.php';
1198 1198
         break;
1199 1199
     case 'switch_scorm_debug':
Please login to merge, or discard this patch.
Switch Indentation   +886 added lines, -886 removed lines patch added patch discarded remove patch
@@ -365,815 +365,815 @@  discard block
 block discarded – undo
365 365
 }
366 366
 
367 367
 switch ($action) {
368
-    case 'add_item':
369
-        if (!$is_allowed_to_edit) {
370
-            api_not_allowed(true);
371
-        }
372
-        if ($debug > 0) error_log('New LP - add item action triggered', 0);
373
-
374
-        if (!$lp_found) {
375
-            //check if the learnpath ID was defined, otherwise send back to list
376
-            if ($debug > 0) error_log('New LP - No learnpath given for add item', 0);
377
-            require 'lp_list.php';
378
-        } else {
379
-            $_SESSION['refresh'] = 1;
368
+        case 'add_item':
369
+            if (!$is_allowed_to_edit) {
370
+                api_not_allowed(true);
371
+            }
372
+            if ($debug > 0) error_log('New LP - add item action triggered', 0);
380 373
 
381
-            if (isset($_POST['submit_button']) && !empty($post_title)) {
382
-                // If a title was sumbitted:
374
+            if (!$lp_found) {
375
+                //check if the learnpath ID was defined, otherwise send back to list
376
+                if ($debug > 0) error_log('New LP - No learnpath given for add item', 0);
377
+                require 'lp_list.php';
378
+            } else {
379
+                $_SESSION['refresh'] = 1;
383 380
 
384
-                //Updating the lp.modified_on
385
-                $_SESSION['oLP']->set_modified_on();
381
+                if (isset($_POST['submit_button']) && !empty($post_title)) {
382
+                    // If a title was sumbitted:
386 383
 
387
-                if (isset($_SESSION['post_time']) && $_SESSION['post_time'] == $_POST['post_time']) {
388
-                    // Check post_time to ensure ??? (counter-hacking measure?)
389
-                    require 'lp_add_item.php';
390
-                } else {
384
+                    //Updating the lp.modified_on
385
+                    $_SESSION['oLP']->set_modified_on();
391 386
 
392
-                    $_SESSION['post_time'] = $_POST['post_time'];
387
+                    if (isset($_SESSION['post_time']) && $_SESSION['post_time'] == $_POST['post_time']) {
388
+                        // Check post_time to ensure ??? (counter-hacking measure?)
389
+                        require 'lp_add_item.php';
390
+                    } else {
393 391
 
394
-                    $parent = isset($_POST['parent']) ? $_POST['parent'] : '';
395
-                    $previous = isset($_POST['previous']) ? $_POST['previous'] : '';
396
-                    $type = isset($_POST['type']) ? $_POST['type'] : '';
397
-                    $path = isset($_POST['path']) ? $_POST['path'] : '';
398
-                    $description = isset($_POST['description']) ? $_POST['description'] : '';
399
-                    $prerequisites = isset($_POST['prerequisites']) ? $_POST['prerequisites'] : '';
400
-                    $maxTimeAllowed = isset($_POST['maxTimeAllowed']) ? $_POST['maxTimeAllowed'] : '';
392
+                        $_SESSION['post_time'] = $_POST['post_time'];
393
+
394
+                        $parent = isset($_POST['parent']) ? $_POST['parent'] : '';
395
+                        $previous = isset($_POST['previous']) ? $_POST['previous'] : '';
396
+                        $type = isset($_POST['type']) ? $_POST['type'] : '';
397
+                        $path = isset($_POST['path']) ? $_POST['path'] : '';
398
+                        $description = isset($_POST['description']) ? $_POST['description'] : '';
399
+                        $prerequisites = isset($_POST['prerequisites']) ? $_POST['prerequisites'] : '';
400
+                        $maxTimeAllowed = isset($_POST['maxTimeAllowed']) ? $_POST['maxTimeAllowed'] : '';
401
+
402
+                        if ($_POST['type'] == TOOL_DOCUMENT) {
403
+                            if (isset($_POST['path']) && $_GET['edit'] != 'true') {
404
+                                $document_id = $_POST['path'];
405
+                            } else {
406
+                                if ($_POST['content_lp']) {
407
+                                    $document_id = $_SESSION['oLP']->create_document(
408
+                                        $_course,
409
+                                        $_POST['content_lp'],
410
+                                        $_POST['title']
411
+                                    );
412
+                                }
413
+                            }
401 414
 
402
-                    if ($_POST['type'] == TOOL_DOCUMENT) {
403
-                        if (isset($_POST['path']) && $_GET['edit'] != 'true') {
404
-                            $document_id = $_POST['path'];
415
+                            $new_item_id = $_SESSION['oLP']->add_item(
416
+                                $parent,
417
+                                $previous,
418
+                                $type,
419
+                                $document_id,
420
+                                $post_title,
421
+                                $description,
422
+                                $prerequisites
423
+                            );
405 424
                         } else {
406
-                            if ($_POST['content_lp']) {
407
-                                $document_id = $_SESSION['oLP']->create_document(
408
-                                    $_course,
409
-                                    $_POST['content_lp'],
410
-                                    $_POST['title']
411
-                                );
412
-                            }
425
+                            // For all other item types than documents, load the item using the item type and path rather than its ID.
426
+                            $new_item_id = $_SESSION['oLP']->add_item(
427
+                                $parent,
428
+                                $previous,
429
+                                $type,
430
+                                $path,
431
+                                $post_title,
432
+                                $description,
433
+                                $prerequisites,
434
+                                $maxTimeAllowed
435
+                            );
413 436
                         }
414
-
415
-                        $new_item_id = $_SESSION['oLP']->add_item(
416
-                            $parent,
417
-                            $previous,
418
-                            $type,
419
-                            $document_id,
420
-                            $post_title,
421
-                            $description,
422
-                            $prerequisites
423
-                        );
424
-                    } else {
425
-                        // For all other item types than documents, load the item using the item type and path rather than its ID.
426
-                        $new_item_id = $_SESSION['oLP']->add_item(
427
-                            $parent,
428
-                            $previous,
429
-                            $type,
430
-                            $path,
431
-                            $post_title,
432
-                            $description,
433
-                            $prerequisites,
434
-                            $maxTimeAllowed
435
-                        );
437
+                        $url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_SESSION['oLP']->lp_id);
438
+                        header('Location: '.$url);
439
+                        exit;
436 440
                     }
437
-                    $url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_SESSION['oLP']->lp_id);
438
-                    header('Location: '.$url);
439
-                    exit;
441
+                } else {
442
+                    require 'lp_add_item.php';
440 443
                 }
441
-            } else {
442
-                require 'lp_add_item.php';
443 444
             }
444
-        }
445
-        break;
446
-    case 'add_audio':
447
-        if (!$is_allowed_to_edit) {
448
-            api_not_allowed(true);
449
-        }
450
-        if ($debug > 0) error_log('New LP - add audio action triggered', 0);
451
-
452
-        if (!$lp_found) {
453
-            //check if the learnpath ID was defined, otherwise send back to list
454
-            if ($debug > 0) error_log('New LP - No learnpath given for add audio', 0);
455
-            require 'lp_list.php';
456
-        } else {
457
-            $_SESSION['refresh'] = 1;
458
-
459
-            if (isset($_REQUEST['id'])) {
460
-                $lp_item_obj = new learnpathItem($_REQUEST['id']);
445
+            break;
446
+        case 'add_audio':
447
+            if (!$is_allowed_to_edit) {
448
+                api_not_allowed(true);
449
+            }
450
+            if ($debug > 0) error_log('New LP - add audio action triggered', 0);
461 451
 
462
-                // Remove audio
463
-                if (isset($_GET['delete_file']) && $_GET['delete_file'] == 1) {
464
-                    $lp_item_obj->remove_audio();
452
+            if (!$lp_found) {
453
+                //check if the learnpath ID was defined, otherwise send back to list
454
+                if ($debug > 0) error_log('New LP - No learnpath given for add audio', 0);
455
+                require 'lp_list.php';
456
+            } else {
457
+                $_SESSION['refresh'] = 1;
465 458
 
466
-                    $url = api_get_self().'?action=add_audio&lp_id='.intval($_SESSION['oLP']->lp_id).'&id='.$lp_item_obj->get_id().'&'.api_get_cidreq();
467
-                    header('Location: '.$url);
468
-                    exit;
469
-                }
459
+                if (isset($_REQUEST['id'])) {
460
+                    $lp_item_obj = new learnpathItem($_REQUEST['id']);
470 461
 
471
-                // Upload audio
472
-                if (isset($_FILES['file']) && !empty($_FILES['file'])) {
473
-                    // Updating the lp.modified_on
474
-                    $_SESSION['oLP']->set_modified_on();
475
-                    $lp_item_obj->add_audio();
476
-                }
462
+                    // Remove audio
463
+                    if (isset($_GET['delete_file']) && $_GET['delete_file'] == 1) {
464
+                        $lp_item_obj->remove_audio();
477 465
 
478
-                //Add audio file from documents
479
-                if (isset($_REQUEST['document_id']) && !empty($_REQUEST['document_id'])) {
480
-                    $_SESSION['oLP']->set_modified_on();
481
-                    $lp_item_obj->add_audio_from_documents($_REQUEST['document_id']);
482
-                }
466
+                        $url = api_get_self().'?action=add_audio&lp_id='.intval($_SESSION['oLP']->lp_id).'&id='.$lp_item_obj->get_id().'&'.api_get_cidreq();
467
+                        header('Location: '.$url);
468
+                        exit;
469
+                    }
483 470
 
484
-                // Display.
485
-                require 'lp_add_audio.php';
486
-            } else {
487
-                require 'lp_add_audio.php';
488
-            }
489
-        }
490
-        break;
491
-    case 'add_lp_category':
492
-        if (!$is_allowed_to_edit) {
493
-            api_not_allowed(true);
494
-        }
495
-        require 'lp_add_category.php';
496
-        break;
497
-    case 'move_up_category':
498
-        if (!$is_allowed_to_edit) {
499
-            api_not_allowed(true);
500
-        }
501
-        if (isset($_REQUEST['id'])) {
502
-            learnpath::moveUpCategory($_REQUEST['id']);
503
-        }
504
-        require 'lp_list.php';
505
-        break;
506
-    case 'move_down_category':
507
-        if (!$is_allowed_to_edit) {
508
-            api_not_allowed(true);
509
-        }
510
-        if (isset($_REQUEST['id'])) {
511
-            learnpath::moveDownCategory($_REQUEST['id']);
512
-        }
513
-        require 'lp_list.php';
514
-        break;
515
-    case 'delete_lp_category':
516
-        if (!$is_allowed_to_edit) {
517
-            api_not_allowed(true);
518
-        }
519
-        if (isset($_REQUEST['id'])) {
520
-            learnpath::deleteCategory($_REQUEST['id']);
521
-        }
522
-        require 'lp_list.php';
523
-        break;
524
-    case 'add_lp':
525
-        if (!$is_allowed_to_edit) {
526
-            api_not_allowed(true);
527
-        }
528
-        if ($debug > 0) error_log('New LP - add_lp action triggered', 0);
529
-        if (isset($_REQUEST['lp_name']) && !empty($_REQUEST['lp_name'])) {
530
-            $_REQUEST['lp_name'] = trim($_REQUEST['lp_name']);
531
-            $_SESSION['refresh'] = 1;
471
+                    // Upload audio
472
+                    if (isset($_FILES['file']) && !empty($_FILES['file'])) {
473
+                        // Updating the lp.modified_on
474
+                        $_SESSION['oLP']->set_modified_on();
475
+                        $lp_item_obj->add_audio();
476
+                    }
532 477
 
533
-            if (isset($_SESSION['post_time']) && $_SESSION['post_time'] == $_REQUEST['post_time']) {
534
-                require 'lp_add.php';
535
-            } else {
536
-                $_SESSION['post_time'] = $_REQUEST['post_time'];
478
+                    //Add audio file from documents
479
+                    if (isset($_REQUEST['document_id']) && !empty($_REQUEST['document_id'])) {
480
+                        $_SESSION['oLP']->set_modified_on();
481
+                        $lp_item_obj->add_audio_from_documents($_REQUEST['document_id']);
482
+                    }
537 483
 
538
-                if (isset($_REQUEST['activate_start_date_check']) &&
539
-                    $_REQUEST['activate_start_date_check'] == 1
540
-                ) {
541
-                	$publicated_on = $_REQUEST['publicated_on'];
484
+                    // Display.
485
+                    require 'lp_add_audio.php';
542 486
                 } else {
543
-                	$publicated_on = null;
487
+                    require 'lp_add_audio.php';
544 488
                 }
489
+            }
490
+            break;
491
+        case 'add_lp_category':
492
+            if (!$is_allowed_to_edit) {
493
+                api_not_allowed(true);
494
+            }
495
+            require 'lp_add_category.php';
496
+            break;
497
+        case 'move_up_category':
498
+            if (!$is_allowed_to_edit) {
499
+                api_not_allowed(true);
500
+            }
501
+            if (isset($_REQUEST['id'])) {
502
+                learnpath::moveUpCategory($_REQUEST['id']);
503
+            }
504
+            require 'lp_list.php';
505
+            break;
506
+        case 'move_down_category':
507
+            if (!$is_allowed_to_edit) {
508
+                api_not_allowed(true);
509
+            }
510
+            if (isset($_REQUEST['id'])) {
511
+                learnpath::moveDownCategory($_REQUEST['id']);
512
+            }
513
+            require 'lp_list.php';
514
+            break;
515
+        case 'delete_lp_category':
516
+            if (!$is_allowed_to_edit) {
517
+                api_not_allowed(true);
518
+            }
519
+            if (isset($_REQUEST['id'])) {
520
+                learnpath::deleteCategory($_REQUEST['id']);
521
+            }
522
+            require 'lp_list.php';
523
+            break;
524
+        case 'add_lp':
525
+            if (!$is_allowed_to_edit) {
526
+                api_not_allowed(true);
527
+            }
528
+            if ($debug > 0) error_log('New LP - add_lp action triggered', 0);
529
+            if (isset($_REQUEST['lp_name']) && !empty($_REQUEST['lp_name'])) {
530
+                $_REQUEST['lp_name'] = trim($_REQUEST['lp_name']);
531
+                $_SESSION['refresh'] = 1;
545 532
 
546
-                if (isset($_REQUEST['activate_end_date_check']) &&
547
-                    $_REQUEST['activate_end_date_check'] == 1
548
-                ) {
549
-                	$expired_on = $_REQUEST['expired_on'];
533
+                if (isset($_SESSION['post_time']) && $_SESSION['post_time'] == $_REQUEST['post_time']) {
534
+                    require 'lp_add.php';
550 535
                 } else {
551
-                	$expired_on = null;
552
-                }
536
+                    $_SESSION['post_time'] = $_REQUEST['post_time'];
553 537
 
554
-                $new_lp_id = learnpath::add_lp(
555
-                    api_get_course_id(),
556
-                    Security::remove_XSS($_REQUEST['lp_name']),
557
-                    '',
558
-                    'chamilo',
559
-                    'manual',
560
-                    '',
561
-                    $publicated_on,
562
-                    $expired_on,
563
-                    $_REQUEST['category_id']
564
-                );
538
+                    if (isset($_REQUEST['activate_start_date_check']) &&
539
+                        $_REQUEST['activate_start_date_check'] == 1
540
+                    ) {
541
+                	    $publicated_on = $_REQUEST['publicated_on'];
542
+                    } else {
543
+                	    $publicated_on = null;
544
+                    }
565 545
 
566
-                if (is_numeric($new_lp_id)) {
567
-                    // TODO: Maybe create a first module directly to avoid bugging the user with useless queries
568
-                    $_SESSION['oLP'] = new learnpath(
546
+                    if (isset($_REQUEST['activate_end_date_check']) &&
547
+                        $_REQUEST['activate_end_date_check'] == 1
548
+                    ) {
549
+                	    $expired_on = $_REQUEST['expired_on'];
550
+                    } else {
551
+                	    $expired_on = null;
552
+                    }
553
+
554
+                    $new_lp_id = learnpath::add_lp(
569 555
                         api_get_course_id(),
570
-                        $new_lp_id,
571
-                        api_get_user_id()
556
+                        Security::remove_XSS($_REQUEST['lp_name']),
557
+                        '',
558
+                        'chamilo',
559
+                        'manual',
560
+                        '',
561
+                        $publicated_on,
562
+                        $expired_on,
563
+                        $_REQUEST['category_id']
572 564
                     );
573
-                    //require 'lp_build.php';
574
-                    $url = api_get_self().'?action=add_item&type=step&lp_id='.intval($new_lp_id).'&'.api_get_cidreq();
575
-                    header("Location: $url&isStudentView=false");
565
+
566
+                    if (is_numeric($new_lp_id)) {
567
+                        // TODO: Maybe create a first module directly to avoid bugging the user with useless queries
568
+                        $_SESSION['oLP'] = new learnpath(
569
+                            api_get_course_id(),
570
+                            $new_lp_id,
571
+                            api_get_user_id()
572
+                        );
573
+                        //require 'lp_build.php';
574
+                        $url = api_get_self().'?action=add_item&type=step&lp_id='.intval($new_lp_id).'&'.api_get_cidreq();
575
+                        header("Location: $url&isStudentView=false");
576
+                        exit;
577
+                    }
578
+                }
579
+            } else {
580
+                require 'lp_add.php';
581
+            }
582
+            break;
583
+        case 'admin_view':
584
+            if (!$is_allowed_to_edit) {
585
+                api_not_allowed(true);
586
+            }
587
+            if ($debug > 0) error_log('New LP - admin_view action triggered', 0);
588
+            if (!$lp_found) { error_log('New LP - No learnpath given for admin_view', 0); require 'lp_list.php'; }
589
+            else {
590
+                $_SESSION['refresh'] = 1;
591
+                require 'lp_admin_view.php';
592
+            }
593
+            break;
594
+        case 'auto_launch':
595
+            if (api_get_course_setting('enable_lp_auto_launch') == 1) { //Redirect to a specific LP
596
+                if (!$is_allowed_to_edit) {
597
+                    api_not_allowed(true);
598
+                }
599
+                if ($debug > 0) error_log('New LP - auto_launch action triggered', 0);
600
+                if (!$lp_found) { error_log('New LP - No learnpath given for set_autolaunch', 0); require 'lp_list.php'; }
601
+                else {
602
+                    $_SESSION['oLP']->set_autolaunch($_GET['lp_id'], $_GET['status']);
603
+                    require 'lp_list.php';
576 604
                     exit;
577 605
                 }
578 606
             }
579
-        } else {
580
-            require 'lp_add.php';
581
-        }
582
-        break;
583
-    case 'admin_view':
584
-        if (!$is_allowed_to_edit) {
585
-            api_not_allowed(true);
586
-        }
587
-        if ($debug > 0) error_log('New LP - admin_view action triggered', 0);
588
-        if (!$lp_found) { error_log('New LP - No learnpath given for admin_view', 0); require 'lp_list.php'; }
589
-        else {
590
-            $_SESSION['refresh'] = 1;
591
-            require 'lp_admin_view.php';
592
-        }
593
-        break;
594
-    case 'auto_launch':
595
-        if (api_get_course_setting('enable_lp_auto_launch') == 1) { //Redirect to a specific LP
607
+            break;
608
+        case 'build':
596 609
             if (!$is_allowed_to_edit) {
597 610
                 api_not_allowed(true);
598 611
             }
599
-            if ($debug > 0) error_log('New LP - auto_launch action triggered', 0);
600
-            if (!$lp_found) { error_log('New LP - No learnpath given for set_autolaunch', 0); require 'lp_list.php'; }
612
+            if ($debug > 0) error_log('New LP - build action triggered', 0);
613
+
614
+            if (!$lp_found) { error_log('New LP - No learnpath given for build', 0); require 'lp_list.php'; }
601 615
             else {
602
-                $_SESSION['oLP']->set_autolaunch($_GET['lp_id'], $_GET['status']);
603
-                require 'lp_list.php';
616
+                $_SESSION['refresh'] = 1;
617
+                //require 'lp_build.php';
618
+                $url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_SESSION['oLP']->lp_id);
619
+                header('Location: '.$url);
604 620
                 exit;
605 621
             }
606
-        }
607
-        break;
608
-    case 'build':
609
-        if (!$is_allowed_to_edit) {
610
-            api_not_allowed(true);
611
-        }
612
-        if ($debug > 0) error_log('New LP - build action triggered', 0);
622
+            break;
623
+        case 'edit_item':
624
+            if (!$is_allowed_to_edit) {
625
+                api_not_allowed(true);
626
+            }
627
+            if ($debug > 0) error_log('New LP - edit item action triggered', 0);
613 628
 
614
-        if (!$lp_found) { error_log('New LP - No learnpath given for build', 0); require 'lp_list.php'; }
615
-        else {
616
-            $_SESSION['refresh'] = 1;
617
-            //require 'lp_build.php';
618
-            $url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_SESSION['oLP']->lp_id);
619
-            header('Location: '.$url);
620
-            exit;
621
-        }
622
-        break;
623
-    case 'edit_item':
624
-        if (!$is_allowed_to_edit) {
625
-            api_not_allowed(true);
626
-        }
627
-        if ($debug > 0) error_log('New LP - edit item action triggered', 0);
629
+            if (!$lp_found) { error_log('New LP - No learnpath given for edit item', 0); require 'lp_list.php'; }
630
+            else {
631
+                $_SESSION['refresh'] = 1;
632
+                if (isset($_POST['submit_button']) && !empty($post_title)) {
628 633
 
629
-        if (!$lp_found) { error_log('New LP - No learnpath given for edit item', 0); require 'lp_list.php'; }
630
-        else {
631
-            $_SESSION['refresh'] = 1;
632
-            if (isset($_POST['submit_button']) && !empty($post_title)) {
634
+                    //Updating the lp.modified_on
635
+                    $_SESSION['oLP']->set_modified_on();
633 636
 
634
-                //Updating the lp.modified_on
635
-                $_SESSION['oLP']->set_modified_on();
637
+                    // TODO: mp3 edit
638
+                    $audio = array();
639
+                    if (isset($_FILES['mp3'])) {
640
+                        $audio = $_FILES['mp3'];
641
+                    }
636 642
 
637
-                // TODO: mp3 edit
638
-                $audio = array();
639
-                if (isset($_FILES['mp3'])) {
640
-                    $audio = $_FILES['mp3'];
641
-                }
643
+                    $description = isset($_POST['description']) ? $_POST['description'] : '';
644
+                    $prerequisites = isset($_POST['prerequisites']) ? $_POST['prerequisites'] : '';
645
+                    $maxTimeAllowed = isset($_POST['maxTimeAllowed']) ? $_POST['maxTimeAllowed'] : '';
646
+                    $url = isset($_POST['url']) ? $_POST['url'] : '';
647
+
648
+                    $_SESSION['oLP']->edit_item(
649
+                        $_REQUEST['id'],
650
+                        $_POST['parent'],
651
+                        $_POST['previous'],
652
+                        $post_title,
653
+                        $description,
654
+                        $prerequisites,
655
+                        $audio,
656
+                        $maxTimeAllowed,
657
+                        $url
658
+                    );
642 659
 
643
-                $description = isset($_POST['description']) ? $_POST['description'] : '';
644
-                $prerequisites = isset($_POST['prerequisites']) ? $_POST['prerequisites'] : '';
645
-                $maxTimeAllowed = isset($_POST['maxTimeAllowed']) ? $_POST['maxTimeAllowed'] : '';
646
-                $url = isset($_POST['url']) ? $_POST['url'] : '';
647
-
648
-                $_SESSION['oLP']->edit_item(
649
-                    $_REQUEST['id'],
650
-                    $_POST['parent'],
651
-                    $_POST['previous'],
652
-                    $post_title,
653
-                    $description,
654
-                    $prerequisites,
655
-                    $audio,
656
-                    $maxTimeAllowed,
657
-                    $url
658
-                );
660
+                    if (isset($_POST['content_lp'])) {
661
+                        $_SESSION['oLP']->edit_document($_course);
662
+                    }
663
+                    $is_success = true;
659 664
 
660
-                if (isset($_POST['content_lp'])) {
661
-                    $_SESSION['oLP']->edit_document($_course);
665
+                    $url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_SESSION['oLP']->lp_id);
666
+                    header('Location: '.$url);
667
+                    exit;
662 668
                 }
663
-                $is_success = true;
669
+                if (isset($_GET['view']) && $_GET['view'] == 'build') {
670
+                    require 'lp_edit_item.php';
671
+                } else {
672
+                    require 'lp_admin_view.php';
673
+                }
674
+            }
675
+            break;
676
+        case 'edit_item_prereq':
677
+            if (!$is_allowed_to_edit) {
678
+                api_not_allowed(true);
679
+            }
680
+            if ($debug > 0) error_log('New LP - edit item prereq action triggered', 0);
681
+            if (!$lp_found) { error_log('New LP - No learnpath given for edit item prereq', 0); require 'lp_list.php'; }
682
+            else {
683
+                if (isset($_POST['submit_button'])) {
684
+                    //Updating the lp.modified_on
685
+                    $_SESSION['oLP']->set_modified_on();
686
+                    $_SESSION['refresh'] = 1;
687
+                    $editPrerequisite = $_SESSION['oLP']->edit_item_prereq(
688
+                        $_GET['id'],
689
+                        $_POST['prerequisites'],
690
+                        $_POST['min_' . $_POST['prerequisites']],
691
+                        $_POST['max_' . $_POST['prerequisites']]
692
+                    );
664 693
 
665
-                $url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_SESSION['oLP']->lp_id);
666
-                header('Location: '.$url);
667
-                exit;
694
+                    if ($editPrerequisite) {
695
+                        $is_success = true;
696
+                    }
697
+
698
+                    $url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_SESSION['oLP']->lp_id).'&'.api_get_cidreq();
699
+                    header('Location: '.$url);
700
+                    exit;
701
+                } else {
702
+                    require 'lp_edit_item_prereq.php';
703
+                }
668 704
             }
669
-            if (isset($_GET['view']) && $_GET['view'] == 'build') {
670
-                require 'lp_edit_item.php';
671
-            } else {
672
-                require 'lp_admin_view.php';
705
+            break;
706
+        case 'move_item':
707
+            if (!$is_allowed_to_edit) {
708
+                api_not_allowed(true);
673 709
             }
674
-        }
675
-        break;
676
-    case 'edit_item_prereq':
677
-        if (!$is_allowed_to_edit) {
678
-            api_not_allowed(true);
679
-        }
680
-        if ($debug > 0) error_log('New LP - edit item prereq action triggered', 0);
681
-        if (!$lp_found) { error_log('New LP - No learnpath given for edit item prereq', 0); require 'lp_list.php'; }
682
-        else {
683
-            if (isset($_POST['submit_button'])) {
684
-                //Updating the lp.modified_on
685
-                $_SESSION['oLP']->set_modified_on();
710
+            if ($debug > 0) error_log('New LP - move item action triggered', 0);
711
+            if (!$lp_found) { error_log('New LP - No learnpath given for move item', 0); require 'lp_list.php'; }
712
+            else {
686 713
                 $_SESSION['refresh'] = 1;
687
-                $editPrerequisite = $_SESSION['oLP']->edit_item_prereq(
688
-                    $_GET['id'],
689
-                    $_POST['prerequisites'],
690
-                    $_POST['min_' . $_POST['prerequisites']],
691
-                    $_POST['max_' . $_POST['prerequisites']]
692
-                );
693
-
694
-                if ($editPrerequisite) {
714
+                if (isset($_POST['submit_button'])) {
715
+                    //Updating the lp.modified_on
716
+                    $_SESSION['oLP']->set_modified_on();
717
+                    $_SESSION['oLP']->edit_item(
718
+                        $_GET['id'],
719
+                        $_POST['parent'],
720
+                        $_POST['previous'],
721
+                        $post_title,
722
+                        $_POST['description']
723
+                    );
695 724
                     $is_success = true;
725
+                    $url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_SESSION['oLP']->lp_id).'&'.api_get_cidreq();
726
+                    header('Location: '.$url);
727
+                }
728
+                if (isset($_GET['view']) && $_GET['view'] == 'build') {
729
+                    require 'lp_move_item.php';
730
+                } else {
731
+                    // Avoids weird behaviours see CT#967.
732
+                    $check = Security::check_token('get');
733
+                    if ($check) {
734
+                        $_SESSION['oLP']->move_item($_GET['id'], $_GET['direction']);
735
+                    }
736
+                    Security::clear_token();
737
+                    require 'lp_admin_view.php';
696 738
                 }
697
-
698
-                $url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_SESSION['oLP']->lp_id).'&'.api_get_cidreq();
699
-                header('Location: '.$url);
700
-                exit;
701
-            } else {
702
-                require 'lp_edit_item_prereq.php';
703 739
             }
704
-        }
705
-        break;
706
-    case 'move_item':
707
-        if (!$is_allowed_to_edit) {
708
-            api_not_allowed(true);
709
-        }
710
-        if ($debug > 0) error_log('New LP - move item action triggered', 0);
711
-        if (!$lp_found) { error_log('New LP - No learnpath given for move item', 0); require 'lp_list.php'; }
712
-        else {
713
-            $_SESSION['refresh'] = 1;
714
-            if (isset($_POST['submit_button'])) {
715
-                //Updating the lp.modified_on
716
-                $_SESSION['oLP']->set_modified_on();
717
-                $_SESSION['oLP']->edit_item(
718
-                    $_GET['id'],
719
-                    $_POST['parent'],
720
-                    $_POST['previous'],
721
-                    $post_title,
722
-                    $_POST['description']
723
-                );
724
-                $is_success = true;
725
-                $url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_SESSION['oLP']->lp_id).'&'.api_get_cidreq();
726
-                header('Location: '.$url);
740
+            break;
741
+        case 'view_item':
742
+            if (!$is_allowed_to_edit) {
743
+                api_not_allowed(true);
727 744
             }
728
-            if (isset($_GET['view']) && $_GET['view'] == 'build') {
729
-                require 'lp_move_item.php';
745
+            if ($debug > 0) error_log('New LP - view_item action triggered', 0);
746
+            if (!$lp_found) {
747
+                error_log('New LP - No learnpath given for view item', 0); require 'lp_list.php';
730 748
             } else {
731
-                // Avoids weird behaviours see CT#967.
732
-                $check = Security::check_token('get');
733
-                if ($check) {
734
-                    $_SESSION['oLP']->move_item($_GET['id'], $_GET['direction']);
735
-                }
736
-                Security::clear_token();
737
-                require 'lp_admin_view.php';
749
+                $_SESSION['refresh'] = 1;
750
+                require 'lp_view_item.php';
751
+            }
752
+            break;
753
+        case 'upload':
754
+            if (!$is_allowed_to_edit) {
755
+                api_not_allowed(true);
756
+            }
757
+            if ($debug > 0) error_log('New LP - upload action triggered', 0);
758
+            $cwdir = getcwd();
759
+            require 'lp_upload.php';
760
+            // Reinit current working directory as many functions in upload change it.
761
+            chdir($cwdir);
762
+            require 'lp_list.php';
763
+            break;
764
+        case 'copy':
765
+            if (!$is_allowed_to_edit) {
766
+                api_not_allowed(true);
738 767
             }
739
-        }
740
-        break;
741
-    case 'view_item':
742
-        if (!$is_allowed_to_edit) {
743
-            api_not_allowed(true);
744
-        }
745
-        if ($debug > 0) error_log('New LP - view_item action triggered', 0);
746
-        if (!$lp_found) {
747
-            error_log('New LP - No learnpath given for view item', 0); require 'lp_list.php';
748
-        } else {
749
-            $_SESSION['refresh'] = 1;
750
-            require 'lp_view_item.php';
751
-        }
752
-        break;
753
-    case 'upload':
754
-        if (!$is_allowed_to_edit) {
755
-            api_not_allowed(true);
756
-        }
757
-        if ($debug > 0) error_log('New LP - upload action triggered', 0);
758
-        $cwdir = getcwd();
759
-        require 'lp_upload.php';
760
-        // Reinit current working directory as many functions in upload change it.
761
-        chdir($cwdir);
762
-        require 'lp_list.php';
763
-        break;
764
-    case 'copy':
765
-        if (!$is_allowed_to_edit) {
766
-            api_not_allowed(true);
767
-        }
768 768
 
769
-        $hideScormCopyLink = api_get_setting('hide_scorm_copy_link');
770
-        if ($hideScormCopyLink === 'true') {
771
-            api_not_allowed(true);
772
-        }
769
+            $hideScormCopyLink = api_get_setting('hide_scorm_copy_link');
770
+            if ($hideScormCopyLink === 'true') {
771
+                api_not_allowed(true);
772
+            }
773 773
 
774
-        if ($debug > 0) error_log('New LP - export action triggered', 0);
775
-        if (!$lp_found) { error_log('New LP - No learnpath given for copy', 0); require 'lp_list.php'; }
776
-        else {
777
-            $_SESSION['oLP']->copy();
778
-        }
779
-        require 'lp_list.php';
780
-        break;
781
-    case 'export':
782
-        if (!$is_allowed_to_edit) {
783
-            api_not_allowed(true);
784
-        }
785
-        $hideScormExportLink = api_get_setting('hide_scorm_export_link');
786
-        if ($hideScormExportLink === 'true') {
787
-            api_not_allowed(true);
788
-        }
789
-        if ($debug > 0) error_log('New LP - export action triggered', 0);
790
-        if (!$lp_found) { error_log('New LP - No learnpath given for export', 0); require 'lp_list.php'; }
791
-        else {
792
-            $_SESSION['oLP']->scorm_export();
793
-            exit();
794
-            //require 'lp_list.php';
795
-        }
796
-        break;
797
-    case 'export_to_pdf':
798
-        if (!learnpath::is_lp_visible_for_student($_SESSION['oLP']->lp_id, api_get_user_id())) {
799
-            api_not_allowed();
800
-        }
801
-        $hideScormPdfLink = api_get_setting('hide_scorm_pdf_link');
802
-        if ($hideScormPdfLink === 'true') {
803
-            api_not_allowed(true);
804
-        }
774
+            if ($debug > 0) error_log('New LP - export action triggered', 0);
775
+            if (!$lp_found) { error_log('New LP - No learnpath given for copy', 0); require 'lp_list.php'; }
776
+            else {
777
+                $_SESSION['oLP']->copy();
778
+            }
779
+            require 'lp_list.php';
780
+            break;
781
+        case 'export':
782
+            if (!$is_allowed_to_edit) {
783
+                api_not_allowed(true);
784
+            }
785
+            $hideScormExportLink = api_get_setting('hide_scorm_export_link');
786
+            if ($hideScormExportLink === 'true') {
787
+                api_not_allowed(true);
788
+            }
789
+            if ($debug > 0) error_log('New LP - export action triggered', 0);
790
+            if (!$lp_found) { error_log('New LP - No learnpath given for export', 0); require 'lp_list.php'; }
791
+            else {
792
+                $_SESSION['oLP']->scorm_export();
793
+                exit();
794
+                //require 'lp_list.php';
795
+            }
796
+            break;
797
+        case 'export_to_pdf':
798
+            if (!learnpath::is_lp_visible_for_student($_SESSION['oLP']->lp_id, api_get_user_id())) {
799
+                api_not_allowed();
800
+            }
801
+            $hideScormPdfLink = api_get_setting('hide_scorm_pdf_link');
802
+            if ($hideScormPdfLink === 'true') {
803
+                api_not_allowed(true);
804
+            }
805 805
 
806
-        if ($debug > 0) error_log('New LP - export action triggered', 0);
807
-        if (!$lp_found) { error_log('New LP - No learnpath given for export_to_pdf', 0); require 'lp_list.php';
808
-        } else {
809
-            $result = $_SESSION['oLP']->scorm_export_to_pdf($_GET['lp_id']);
810
-            if (!$result) {
806
+            if ($debug > 0) error_log('New LP - export action triggered', 0);
807
+            if (!$lp_found) { error_log('New LP - No learnpath given for export_to_pdf', 0); require 'lp_list.php';
808
+            } else {
809
+                $result = $_SESSION['oLP']->scorm_export_to_pdf($_GET['lp_id']);
810
+                if (!$result) {
811
+                    require 'lp_list.php';
812
+                }
813
+                exit;
814
+            }
815
+            break;
816
+        case 'delete':
817
+            if (!$is_allowed_to_edit) {
818
+                api_not_allowed(true);
819
+            }
820
+            if ($debug > 0) error_log('New LP - delete action triggered', 0);
821
+            if (!$lp_found) { error_log('New LP - No learnpath given for delete', 0); require 'lp_list.php'; }
822
+            else {
823
+                $_SESSION['refresh'] = 1;
824
+                $_SESSION['oLP']->delete(null, $_GET['lp_id'], 'remove');
825
+                Session::erase('oLP');
811 826
                 require 'lp_list.php';
812 827
             }
813
-            exit;
814
-        }
815
-        break;
816
-    case 'delete':
817
-        if (!$is_allowed_to_edit) {
818
-            api_not_allowed(true);
819
-        }
820
-        if ($debug > 0) error_log('New LP - delete action triggered', 0);
821
-        if (!$lp_found) { error_log('New LP - No learnpath given for delete', 0); require 'lp_list.php'; }
822
-        else {
823
-            $_SESSION['refresh'] = 1;
824
-            $_SESSION['oLP']->delete(null, $_GET['lp_id'], 'remove');
825
-            Session::erase('oLP');
826
-            require 'lp_list.php';
827
-        }
828
-        break;
829
-    case 'toggle_visible':
830
-        // Change lp visibility (inside lp tool).
831
-        if (!$is_allowed_to_edit) {
832
-            api_not_allowed(true);
833
-        }
834
-        if ($debug > 0) error_log('New LP - visibility action triggered', 0);
835
-        if (!$lp_found) { error_log('New LP - No learnpath given for visibility', 0); require 'lp_list.php'; }
836
-        else {
837
-            learnpath::toggle_visibility($_REQUEST['lp_id'], $_REQUEST['new_status']);
838
-            require 'lp_list.php';
839
-        }
840
-        break;
841
-    case 'toggle_publish':
842
-        // Change lp published status (visibility on homepage).
843
-        if (!$is_allowed_to_edit) {
844
-            api_not_allowed(true);
845
-        }
846
-        if ($debug > 0) error_log('New LP - publish action triggered', 0);
847
-        if (!$lp_found) { error_log('New LP - No learnpath given for publish', 0); require 'lp_list.php'; }
848
-        else {
849
-            learnpath::toggle_publish($_REQUEST['lp_id'], $_REQUEST['new_status']);
850
-            require 'lp_list.php';
851
-        }
852
-        break;
853
-    case 'move_lp_up':
854
-        // Change lp published status (visibility on homepage)
855
-        if (!$is_allowed_to_edit) {
856
-            api_not_allowed(true);
857
-        }
858
-        if ($debug > 0) error_log('New LP - publish action triggered', 0);
859
-        if (!$lp_found) {
860
-            error_log('New LP - No learnpath given for publish', 0);
861
-            require 'lp_list.php';
862
-        } else {
863
-            learnpath::move_up($_REQUEST['lp_id']);
864
-            require 'lp_list.php';
865
-        }
866
-        break;
867
-    case 'move_lp_down':
868
-        // Change lp published status (visibility on homepage)
869
-        if (!$is_allowed_to_edit) {
870
-            api_not_allowed(true);
871
-        }
872
-        if ($debug > 0) error_log('New LP - publish action triggered', 0);
873
-        if (!$lp_found) {
874
-            error_log('New LP - No learnpath given for publish', 0);
875
-            require 'lp_list.php';
876
-        } else {
877
-            learnpath::move_down($_REQUEST['lp_id']);
878
-            require 'lp_list.php';
879
-        }
880
-        break;
881
-    case 'edit':
882
-        if (!$is_allowed_to_edit) {
883
-            api_not_allowed(true);
884
-        }
885
-        if ($debug > 0) error_log('New LP - edit action triggered', 0);
886
-        if (!$lp_found) { error_log('New LP - No learnpath given for edit', 0); require 'lp_list.php'; }
887
-        else {
888
-            $_SESSION['refresh'] = 1;
889
-            require 'lp_edit.php';
890
-        }
891
-        break;
892
-    case 'update_lp':
893
-        if (!$is_allowed_to_edit) {
894
-            api_not_allowed(true);
895
-        }
896
-        if ($debug > 0) error_log('New LP - update_lp action triggered', 0);
897
-        if (!$lp_found) { error_log('New LP - No learnpath given for edit', 0); require 'lp_list.php'; }
898
-        else {
899
-            $_SESSION['refresh'] = 1;
900
-            $lp_name = Security::remove_XSS($_REQUEST['lp_name']);
901
-            $_SESSION['oLP']->set_name($lp_name);
902
-            $author = $_REQUEST['lp_author'];
903
-            // Fixing the author name (no body or html tags).
904
-            $auth_init = stripos($author, '<p>');
905
-            if ($auth_init === false) {
906
-                $auth_init = stripos($author, '<body>');
907
-                $auth_end = $auth_init + stripos(substr($author, $auth_init + 6), '</body>') + 7;
908
-                $len = $auth_end - $auth_init + 6;
828
+            break;
829
+        case 'toggle_visible':
830
+            // Change lp visibility (inside lp tool).
831
+            if (!$is_allowed_to_edit) {
832
+                api_not_allowed(true);
833
+            }
834
+            if ($debug > 0) error_log('New LP - visibility action triggered', 0);
835
+            if (!$lp_found) { error_log('New LP - No learnpath given for visibility', 0); require 'lp_list.php'; }
836
+            else {
837
+                learnpath::toggle_visibility($_REQUEST['lp_id'], $_REQUEST['new_status']);
838
+                require 'lp_list.php';
839
+            }
840
+            break;
841
+        case 'toggle_publish':
842
+            // Change lp published status (visibility on homepage).
843
+            if (!$is_allowed_to_edit) {
844
+                api_not_allowed(true);
845
+            }
846
+            if ($debug > 0) error_log('New LP - publish action triggered', 0);
847
+            if (!$lp_found) { error_log('New LP - No learnpath given for publish', 0); require 'lp_list.php'; }
848
+            else {
849
+                learnpath::toggle_publish($_REQUEST['lp_id'], $_REQUEST['new_status']);
850
+                require 'lp_list.php';
851
+            }
852
+            break;
853
+        case 'move_lp_up':
854
+            // Change lp published status (visibility on homepage)
855
+            if (!$is_allowed_to_edit) {
856
+                api_not_allowed(true);
857
+            }
858
+            if ($debug > 0) error_log('New LP - publish action triggered', 0);
859
+            if (!$lp_found) {
860
+                error_log('New LP - No learnpath given for publish', 0);
861
+                require 'lp_list.php';
862
+            } else {
863
+                learnpath::move_up($_REQUEST['lp_id']);
864
+                require 'lp_list.php';
865
+            }
866
+            break;
867
+        case 'move_lp_down':
868
+            // Change lp published status (visibility on homepage)
869
+            if (!$is_allowed_to_edit) {
870
+                api_not_allowed(true);
871
+            }
872
+            if ($debug > 0) error_log('New LP - publish action triggered', 0);
873
+            if (!$lp_found) {
874
+                error_log('New LP - No learnpath given for publish', 0);
875
+                require 'lp_list.php';
909 876
             } else {
910
-                $auth_end = strripos($author, '</p>');
911
-                $len = $auth_end - $auth_init + 4;
877
+                learnpath::move_down($_REQUEST['lp_id']);
878
+                require 'lp_list.php';
879
+            }
880
+            break;
881
+        case 'edit':
882
+            if (!$is_allowed_to_edit) {
883
+                api_not_allowed(true);
884
+            }
885
+            if ($debug > 0) error_log('New LP - edit action triggered', 0);
886
+            if (!$lp_found) { error_log('New LP - No learnpath given for edit', 0); require 'lp_list.php'; }
887
+            else {
888
+                $_SESSION['refresh'] = 1;
889
+                require 'lp_edit.php';
890
+            }
891
+            break;
892
+        case 'update_lp':
893
+            if (!$is_allowed_to_edit) {
894
+                api_not_allowed(true);
912 895
             }
896
+            if ($debug > 0) error_log('New LP - update_lp action triggered', 0);
897
+            if (!$lp_found) { error_log('New LP - No learnpath given for edit', 0); require 'lp_list.php'; }
898
+            else {
899
+                $_SESSION['refresh'] = 1;
900
+                $lp_name = Security::remove_XSS($_REQUEST['lp_name']);
901
+                $_SESSION['oLP']->set_name($lp_name);
902
+                $author = $_REQUEST['lp_author'];
903
+                // Fixing the author name (no body or html tags).
904
+                $auth_init = stripos($author, '<p>');
905
+                if ($auth_init === false) {
906
+                    $auth_init = stripos($author, '<body>');
907
+                    $auth_end = $auth_init + stripos(substr($author, $auth_init + 6), '</body>') + 7;
908
+                    $len = $auth_end - $auth_init + 6;
909
+                } else {
910
+                    $auth_end = strripos($author, '</p>');
911
+                    $len = $auth_end - $auth_init + 4;
912
+                }
913 913
 
914
-            $author_fixed = substr($author, $auth_init, $len);
915
-            //$author_fixed = $author;
914
+                $author_fixed = substr($author, $auth_init, $len);
915
+                //$author_fixed = $author;
916 916
 
917
-            $_SESSION['oLP']->set_author($author_fixed);
918
-            // TODO (as of Chamilo 1.8.8): Check in the future whether this field is needed.
919
-            $_SESSION['oLP']->set_encoding($_REQUEST['lp_encoding']);
917
+                $_SESSION['oLP']->set_author($author_fixed);
918
+                // TODO (as of Chamilo 1.8.8): Check in the future whether this field is needed.
919
+                $_SESSION['oLP']->set_encoding($_REQUEST['lp_encoding']);
920 920
 
921
-            if (isset($_REQUEST['lp_maker'])) {
922
-                $_SESSION['oLP']->set_maker($_REQUEST['lp_maker']);
923
-            }
924
-            if (isset($_REQUEST['lp_proximity'])) {
925
-                $_SESSION['oLP']->set_proximity($_REQUEST['lp_proximity']);
926
-            }
927
-            $_SESSION['oLP']->set_theme($_REQUEST['lp_theme']);
921
+                if (isset($_REQUEST['lp_maker'])) {
922
+                    $_SESSION['oLP']->set_maker($_REQUEST['lp_maker']);
923
+                }
924
+                if (isset($_REQUEST['lp_proximity'])) {
925
+                    $_SESSION['oLP']->set_proximity($_REQUEST['lp_proximity']);
926
+                }
927
+                $_SESSION['oLP']->set_theme($_REQUEST['lp_theme']);
928 928
 
929
-            if (isset($_REQUEST['hide_toc_frame']) && $_REQUEST['hide_toc_frame'] == 1) {
930
-                $hide_toc_frame = $_REQUEST['hide_toc_frame'];
931
-            } else {
932
-                $hide_toc_frame = null;
933
-            }
934
-            $_SESSION['oLP']->set_hide_toc_frame($hide_toc_frame);
935
-            $_SESSION['oLP']->set_prerequisite($_REQUEST['prerequisites']);
936
-            $_SESSION['oLP']->set_use_max_score($_REQUEST['use_max_score']);
937
-            $_SESSION['oLP']->setSubscribeUsers($_REQUEST['subscribe_users']);
929
+                if (isset($_REQUEST['hide_toc_frame']) && $_REQUEST['hide_toc_frame'] == 1) {
930
+                    $hide_toc_frame = $_REQUEST['hide_toc_frame'];
931
+                } else {
932
+                    $hide_toc_frame = null;
933
+                }
934
+                $_SESSION['oLP']->set_hide_toc_frame($hide_toc_frame);
935
+                $_SESSION['oLP']->set_prerequisite($_REQUEST['prerequisites']);
936
+                $_SESSION['oLP']->set_use_max_score($_REQUEST['use_max_score']);
937
+                $_SESSION['oLP']->setSubscribeUsers($_REQUEST['subscribe_users']);
938 938
 
939
-            if (isset($_REQUEST['activate_start_date_check']) && $_REQUEST['activate_start_date_check'] == 1) {
940
-            	$publicated_on  = $_REQUEST['publicated_on'];
941
-            } else {
942
-            	$publicated_on = null;
943
-            }
939
+                if (isset($_REQUEST['activate_start_date_check']) && $_REQUEST['activate_start_date_check'] == 1) {
940
+            	    $publicated_on  = $_REQUEST['publicated_on'];
941
+                } else {
942
+            	    $publicated_on = null;
943
+                }
944 944
 
945
-            if (isset($_REQUEST['activate_end_date_check']) && $_REQUEST['activate_end_date_check'] == 1) {
946
-                $expired_on = $_REQUEST['expired_on'];
947
-            } else {
948
-                $expired_on = null;
949
-            }
950
-            $_SESSION['oLP']->setCategoryId($_REQUEST['category_id']);
951
-            $_SESSION['oLP']->set_modified_on();
952
-            $_SESSION['oLP']->set_publicated_on($publicated_on);
953
-            $_SESSION['oLP']->set_expired_on($expired_on);
954
-
955
-            if (isset($_REQUEST['remove_picture']) && $_REQUEST['remove_picture']) {
956
-                $_SESSION['oLP']->delete_lp_image();
957
-            }
958
-
959
-            $extraFieldValue = new ExtraFieldValue('lp');
960
-            $params = array(
961
-                'lp_id' => $_SESSION['oLP']->id
962
-            );
963
-            $extraFieldValue->saveFieldValues($_REQUEST);
964
-
965
-            if ($_FILES['lp_preview_image']['size'] > 0)
966
-                $_SESSION['oLP']->upload_image($_FILES['lp_preview_image']);
967
-
968
-            if (api_get_setting('search_enabled') === 'true') {
969
-                require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php';
970
-                $specific_fields = get_specific_field_list();
971
-                foreach ($specific_fields as $specific_field) {
972
-                    $_SESSION['oLP']->set_terms_by_prefix($_REQUEST[$specific_field['code']], $specific_field['code']);
973
-                    $new_values = explode(',', trim($_REQUEST[$specific_field['code']]));
974
-                    if (!empty($new_values)) {
975
-                        array_walk($new_values, 'trim');
976
-                        delete_all_specific_field_value(
977
-                            api_get_course_id(),
978
-                            $specific_field['id'],
979
-                            TOOL_LEARNPATH,
980
-                            $_SESSION['oLP']->lp_id
981
-                        );
945
+                if (isset($_REQUEST['activate_end_date_check']) && $_REQUEST['activate_end_date_check'] == 1) {
946
+                    $expired_on = $_REQUEST['expired_on'];
947
+                } else {
948
+                    $expired_on = null;
949
+                }
950
+                $_SESSION['oLP']->setCategoryId($_REQUEST['category_id']);
951
+                $_SESSION['oLP']->set_modified_on();
952
+                $_SESSION['oLP']->set_publicated_on($publicated_on);
953
+                $_SESSION['oLP']->set_expired_on($expired_on);
954
+
955
+                if (isset($_REQUEST['remove_picture']) && $_REQUEST['remove_picture']) {
956
+                    $_SESSION['oLP']->delete_lp_image();
957
+                }
982 958
 
983
-                        foreach ($new_values as $value) {
984
-                            if (!empty($value)) {
985
-                                add_specific_field_value(
986
-                                    $specific_field['id'],
987
-                                    api_get_course_id(),
988
-                                    TOOL_LEARNPATH,
989
-                                    $_SESSION['oLP']->lp_id,
990
-                                    $value
991
-                                );
959
+                $extraFieldValue = new ExtraFieldValue('lp');
960
+                $params = array(
961
+                    'lp_id' => $_SESSION['oLP']->id
962
+                );
963
+                $extraFieldValue->saveFieldValues($_REQUEST);
964
+
965
+                if ($_FILES['lp_preview_image']['size'] > 0)
966
+                    $_SESSION['oLP']->upload_image($_FILES['lp_preview_image']);
967
+
968
+                if (api_get_setting('search_enabled') === 'true') {
969
+                    require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php';
970
+                    $specific_fields = get_specific_field_list();
971
+                    foreach ($specific_fields as $specific_field) {
972
+                        $_SESSION['oLP']->set_terms_by_prefix($_REQUEST[$specific_field['code']], $specific_field['code']);
973
+                        $new_values = explode(',', trim($_REQUEST[$specific_field['code']]));
974
+                        if (!empty($new_values)) {
975
+                            array_walk($new_values, 'trim');
976
+                            delete_all_specific_field_value(
977
+                                api_get_course_id(),
978
+                                $specific_field['id'],
979
+                                TOOL_LEARNPATH,
980
+                                $_SESSION['oLP']->lp_id
981
+                            );
982
+
983
+                            foreach ($new_values as $value) {
984
+                                if (!empty($value)) {
985
+                                    add_specific_field_value(
986
+                                        $specific_field['id'],
987
+                                        api_get_course_id(),
988
+                                        TOOL_LEARNPATH,
989
+                                        $_SESSION['oLP']->lp_id,
990
+                                        $value
991
+                                    );
992
+                                }
992 993
                             }
993 994
                         }
994 995
                     }
995 996
                 }
997
+                $url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_SESSION['oLP']->lp_id).'&'.api_get_cidreq();
998
+                header('Location: '.$url);
999
+                exit;
996 1000
             }
997
-            $url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_SESSION['oLP']->lp_id).'&'.api_get_cidreq();
998
-            header('Location: '.$url);
999
-            exit;
1000
-        }
1001
-        break;
1002
-    case 'add_sub_item': // Add an item inside a chapter.
1003
-        if (!$is_allowed_to_edit) {
1004
-            api_not_allowed(true);
1005
-        }
1006
-        if ($debug > 0) error_log('New LP - add sub item action triggered', 0);
1007
-        if (!$lp_found) { error_log('New LP - No learnpath given for add sub item', 0); require 'lp_list.php'; }
1008
-        else {
1009
-            $_SESSION['refresh'] = 1;
1010
-            if (!empty($_REQUEST['parent_item_id'])) {
1011
-                $_SESSION['from_learnpath']='yes';
1012
-                $_SESSION['origintoolurl'] = 'lp_controller.php?action=admin_view&lp_id='.Security::remove_XSS($_REQUEST['lp_id']);
1013
-                require 'resourcelinker.php';
1014
-            } else {
1001
+            break;
1002
+        case 'add_sub_item': // Add an item inside a chapter.
1003
+            if (!$is_allowed_to_edit) {
1004
+                api_not_allowed(true);
1005
+            }
1006
+            if ($debug > 0) error_log('New LP - add sub item action triggered', 0);
1007
+            if (!$lp_found) { error_log('New LP - No learnpath given for add sub item', 0); require 'lp_list.php'; }
1008
+            else {
1009
+                $_SESSION['refresh'] = 1;
1010
+                if (!empty($_REQUEST['parent_item_id'])) {
1011
+                    $_SESSION['from_learnpath']='yes';
1012
+                    $_SESSION['origintoolurl'] = 'lp_controller.php?action=admin_view&lp_id='.Security::remove_XSS($_REQUEST['lp_id']);
1013
+                    require 'resourcelinker.php';
1014
+                } else {
1015
+                    require 'lp_admin_view.php';
1016
+                }
1017
+            }
1018
+            break;
1019
+        case 'deleteitem':
1020
+        case 'delete_item':
1021
+            if (!$is_allowed_to_edit) {
1022
+                api_not_allowed(true);
1023
+            }
1024
+            if ($debug > 0) error_log('New LP - delete item action triggered', 0);
1025
+            if (!$lp_found) { error_log('New LP - No learnpath given for delete item', 0); require 'lp_list.php'; }
1026
+            else {
1027
+                //$_SESSION['refresh'] = 1;
1028
+                if (!empty($_REQUEST['id'])) {
1029
+                    $_SESSION['oLP']->delete_item($_REQUEST['id']);
1030
+                }
1031
+                $url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_REQUEST['lp_id']).api_get_cidreq();
1032
+                header('Location: '.$url);
1033
+                exit;
1034
+            }
1035
+            break;
1036
+        case 'edititemprereq':
1037
+        case 'edit_item_prereq':
1038
+            if (!$is_allowed_to_edit) {
1039
+                api_not_allowed(true);
1040
+            }
1041
+            if ($debug > 0) error_log('New LP - edit item prereq action triggered', 0);
1042
+            if (!$lp_found) { error_log('New LP - No learnpath given for edit item prereq', 0); require 'lp_list.php'; }
1043
+            else {
1044
+                if (!empty($_REQUEST['id']) && !empty($_REQUEST['submit_item'])) {
1045
+                    $_SESSION['refresh'] = 1;
1046
+                    $_SESSION['oLP']->edit_item_prereq($_REQUEST['id'], $_REQUEST['prereq']);
1047
+                }
1015 1048
                 require 'lp_admin_view.php';
1016 1049
             }
1017
-        }
1018
-        break;
1019
-    case 'deleteitem':
1020
-    case 'delete_item':
1021
-        if (!$is_allowed_to_edit) {
1022
-            api_not_allowed(true);
1023
-        }
1024
-        if ($debug > 0) error_log('New LP - delete item action triggered', 0);
1025
-        if (!$lp_found) { error_log('New LP - No learnpath given for delete item', 0); require 'lp_list.php'; }
1026
-        else {
1027
-            //$_SESSION['refresh'] = 1;
1028
-            if (!empty($_REQUEST['id'])) {
1029
-                $_SESSION['oLP']->delete_item($_REQUEST['id']);
1030
-            }
1031
-            $url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_REQUEST['lp_id']).api_get_cidreq();
1032
-            header('Location: '.$url);
1033
-            exit;
1034
-        }
1035
-        break;
1036
-    case 'edititemprereq':
1037
-    case 'edit_item_prereq':
1038
-        if (!$is_allowed_to_edit) {
1039
-            api_not_allowed(true);
1040
-        }
1041
-        if ($debug > 0) error_log('New LP - edit item prereq action triggered', 0);
1042
-        if (!$lp_found) { error_log('New LP - No learnpath given for edit item prereq', 0); require 'lp_list.php'; }
1043
-        else {
1044
-            if (!empty($_REQUEST['id']) && !empty($_REQUEST['submit_item'])) {
1050
+            break;
1051
+        case 'restart':
1052
+            if ($debug > 0) error_log('New LP - restart action triggered', 0);
1053
+            if (!$lp_found) { error_log('New LP - No learnpath given for restart', 0); require 'lp_list.php'; }
1054
+            else {
1055
+                $_SESSION['oLP']->restart();
1056
+                require 'lp_view.php';
1057
+            }
1058
+            break;
1059
+        case 'last':
1060
+            if ($debug > 0) error_log('New LP - last action triggered', 0);
1061
+            if (!$lp_found) { error_log('New LP - No learnpath given for last', 0); require 'lp_list.php'; }
1062
+            else {
1063
+                $_SESSION['oLP']->last();
1064
+                require 'lp_view.php';
1065
+            }
1066
+            break;
1067
+        case 'first':
1068
+            if ($debug > 0) error_log('New LP - first action triggered', 0);
1069
+            if (!$lp_found) { error_log('New LP - No learnpath given for first', 0); require 'lp_list.php'; }
1070
+            else {
1071
+                $_SESSION['oLP']->first();
1072
+                require 'lp_view.php';
1073
+            }
1074
+            break;
1075
+        case 'next':
1076
+            if ($debug > 0) error_log('New LP - next action triggered', 0);
1077
+            if (!$lp_found) { error_log('New LP - No learnpath given for next', 0); require 'lp_list.php'; }
1078
+            else {
1079
+                $_SESSION['oLP']->next();
1080
+                require 'lp_view.php';
1081
+            }
1082
+            break;
1083
+        case 'previous':
1084
+            if ($debug > 0) error_log('New LP - previous action triggered', 0);
1085
+            if (!$lp_found) { error_log('New LP - No learnpath given for previous', 0); require 'lp_list.php'; }
1086
+            else {
1087
+                $_SESSION['oLP']->previous();
1088
+                require 'lp_view.php';
1089
+            }
1090
+            break;
1091
+        case 'content':
1092
+            if ($debug > 0) error_log('New LP - content action triggered', 0);
1093
+            if ($debug > 0) error_log('New LP - Item id is '.intval($_GET['item_id']), 0);
1094
+            if (!$lp_found) {
1095
+                error_log('New LP - No learnpath given for content', 0);
1096
+                require 'lp_list.php';
1097
+            }
1098
+            else {
1099
+                $_SESSION['oLP']->save_last();
1100
+                $_SESSION['oLP']->set_current_item($_GET['item_id']);
1101
+                $_SESSION['oLP']->start_current_item();
1102
+                require 'lp_content.php';
1103
+            }
1104
+            break;
1105
+        case 'view':
1106
+            if ($debug > 0)
1107
+                error_log('New LP - view action triggered', 0);
1108
+            if (!$lp_found) {
1109
+                error_log('New LP - No learnpath given for view', 0);
1110
+                require 'lp_list.php';
1111
+            } else {
1112
+                if ($debug > 0) {error_log('New LP - Trying to set current item to ' . $_REQUEST['item_id'], 0); }
1113
+                if ( !empty($_REQUEST['item_id']) ) {
1114
+                    $_SESSION['oLP']->set_current_item($_REQUEST['item_id']);
1115
+                }
1116
+                require 'lp_view.php';
1117
+            }
1118
+            break;
1119
+        case 'save':
1120
+            if ($debug > 0) error_log('New LP - save action triggered', 0);
1121
+            if (!$lp_found) { error_log('New LP - No learnpath given for save', 0); require 'lp_list.php'; }
1122
+            else {
1123
+                $_SESSION['oLP']->save_item();
1124
+                require 'lp_save.php';
1125
+            }
1126
+            break;
1127
+        case 'stats':
1128
+            if ($debug > 0) error_log('New LP - stats action triggered', 0);
1129
+            if (!$lp_found) { error_log('New LP - No learnpath given for stats', 0); require 'lp_list.php'; }
1130
+            else {
1131
+                $_SESSION['oLP']->save_current();
1132
+                $_SESSION['oLP']->save_last();
1133
+                $output = require 'lp_stats.php';
1134
+                echo $output;
1135
+            }
1136
+            break;
1137
+        case 'list':
1138
+            if ($debug > 0) error_log('New LP - list action triggered', 0);
1139
+            if ($lp_found) {
1045 1140
                 $_SESSION['refresh'] = 1;
1046
-                $_SESSION['oLP']->edit_item_prereq($_REQUEST['id'], $_REQUEST['prereq']);
1141
+                $_SESSION['oLP']->save_last();
1047 1142
             }
1048
-            require 'lp_admin_view.php';
1049
-        }
1050
-        break;
1051
-    case 'restart':
1052
-        if ($debug > 0) error_log('New LP - restart action triggered', 0);
1053
-        if (!$lp_found) { error_log('New LP - No learnpath given for restart', 0); require 'lp_list.php'; }
1054
-        else {
1055
-            $_SESSION['oLP']->restart();
1056
-            require 'lp_view.php';
1057
-        }
1058
-        break;
1059
-    case 'last':
1060
-        if ($debug > 0) error_log('New LP - last action triggered', 0);
1061
-        if (!$lp_found) { error_log('New LP - No learnpath given for last', 0); require 'lp_list.php'; }
1062
-        else {
1063
-            $_SESSION['oLP']->last();
1064
-            require 'lp_view.php';
1065
-        }
1066
-        break;
1067
-    case 'first':
1068
-        if ($debug > 0) error_log('New LP - first action triggered', 0);
1069
-        if (!$lp_found) { error_log('New LP - No learnpath given for first', 0); require 'lp_list.php'; }
1070
-        else {
1071
-            $_SESSION['oLP']->first();
1072
-            require 'lp_view.php';
1073
-        }
1074
-        break;
1075
-    case 'next':
1076
-        if ($debug > 0) error_log('New LP - next action triggered', 0);
1077
-        if (!$lp_found) { error_log('New LP - No learnpath given for next', 0); require 'lp_list.php'; }
1078
-        else {
1079
-            $_SESSION['oLP']->next();
1080
-            require 'lp_view.php';
1081
-        }
1082
-        break;
1083
-    case 'previous':
1084
-        if ($debug > 0) error_log('New LP - previous action triggered', 0);
1085
-        if (!$lp_found) { error_log('New LP - No learnpath given for previous', 0); require 'lp_list.php'; }
1086
-        else {
1087
-            $_SESSION['oLP']->previous();
1088
-            require 'lp_view.php';
1089
-        }
1090
-        break;
1091
-    case 'content':
1092
-        if ($debug > 0) error_log('New LP - content action triggered', 0);
1093
-        if ($debug > 0) error_log('New LP - Item id is '.intval($_GET['item_id']), 0);
1094
-        if (!$lp_found) {
1095
-            error_log('New LP - No learnpath given for content', 0);
1096
-            require 'lp_list.php';
1097
-        }
1098
-        else {
1099
-            $_SESSION['oLP']->save_last();
1100
-            $_SESSION['oLP']->set_current_item($_GET['item_id']);
1101
-            $_SESSION['oLP']->start_current_item();
1102
-            require 'lp_content.php';
1103
-        }
1104
-        break;
1105
-    case 'view':
1106
-        if ($debug > 0)
1107
-            error_log('New LP - view action triggered', 0);
1108
-        if (!$lp_found) {
1109
-            error_log('New LP - No learnpath given for view', 0);
1110 1143
             require 'lp_list.php';
1111
-        } else {
1112
-            if ($debug > 0) {error_log('New LP - Trying to set current item to ' . $_REQUEST['item_id'], 0); }
1113
-            if ( !empty($_REQUEST['item_id']) ) {
1114
-                $_SESSION['oLP']->set_current_item($_REQUEST['item_id']);
1144
+            break;
1145
+        case 'mode':
1146
+            // Switch between fullscreen and embedded mode.
1147
+            if ($debug > 0) error_log('New LP - mode change triggered', 0);
1148
+            $mode = $_REQUEST['mode'];
1149
+            if ($mode == 'fullscreen') {
1150
+                $_SESSION['oLP']->mode = 'fullscreen';
1151
+            } elseif ($mode == 'embedded') {
1152
+                $_SESSION['oLP']->mode = 'embedded';
1153
+            } elseif ($mode == 'embedframe') {
1154
+        	    $_SESSION['oLP']->mode = 'embedframe';
1155
+            } elseif ($mode == 'impress') {
1156
+                $_SESSION['oLP']->mode = 'impress';
1115 1157
             }
1116 1158
             require 'lp_view.php';
1117
-        }
1118
-        break;
1119
-    case 'save':
1120
-        if ($debug > 0) error_log('New LP - save action triggered', 0);
1121
-        if (!$lp_found) { error_log('New LP - No learnpath given for save', 0); require 'lp_list.php'; }
1122
-        else {
1123
-            $_SESSION['oLP']->save_item();
1124
-            require 'lp_save.php';
1125
-        }
1126
-        break;
1127
-    case 'stats':
1128
-        if ($debug > 0) error_log('New LP - stats action triggered', 0);
1129
-        if (!$lp_found) { error_log('New LP - No learnpath given for stats', 0); require 'lp_list.php'; }
1130
-        else {
1131
-            $_SESSION['oLP']->save_current();
1132
-            $_SESSION['oLP']->save_last();
1133
-            $output = require 'lp_stats.php';
1134
-            echo $output;
1135
-        }
1136
-        break;
1137
-    case 'list':
1138
-        if ($debug > 0) error_log('New LP - list action triggered', 0);
1139
-        if ($lp_found) {
1140
-            $_SESSION['refresh'] = 1;
1141
-            $_SESSION['oLP']->save_last();
1142
-        }
1143
-        require 'lp_list.php';
1144
-        break;
1145
-    case 'mode':
1146
-        // Switch between fullscreen and embedded mode.
1147
-        if ($debug > 0) error_log('New LP - mode change triggered', 0);
1148
-        $mode = $_REQUEST['mode'];
1149
-        if ($mode == 'fullscreen') {
1150
-            $_SESSION['oLP']->mode = 'fullscreen';
1151
-        } elseif ($mode == 'embedded') {
1152
-            $_SESSION['oLP']->mode = 'embedded';
1153
-        } elseif ($mode == 'embedframe') {
1154
-        	$_SESSION['oLP']->mode = 'embedframe';
1155
-        } elseif ($mode == 'impress') {
1156
-            $_SESSION['oLP']->mode = 'impress';
1157
-        }
1158
-        require 'lp_view.php';
1159
-        break;
1160
-    case 'switch_view_mode':
1161
-        if ($debug > 0) error_log('New LP - switch_view_mode action triggered', 0);
1162
-        if (!$lp_found) { error_log('New LP - No learnpath given for switch', 0); require 'lp_list.php'; }
1163
-        if (Security::check_token('get')) {
1159
+            break;
1160
+        case 'switch_view_mode':
1161
+            if ($debug > 0) error_log('New LP - switch_view_mode action triggered', 0);
1162
+            if (!$lp_found) { error_log('New LP - No learnpath given for switch', 0); require 'lp_list.php'; }
1163
+            if (Security::check_token('get')) {
1164
+                $_SESSION['refresh'] = 1;
1165
+                $_SESSION['oLP']->update_default_view_mode();
1166
+            }
1167
+            require 'lp_list.php';
1168
+            break;
1169
+        case 'switch_force_commit':
1170
+            if ($debug > 0) error_log('New LP - switch_force_commit action triggered', 0);
1171
+            if (!$lp_found) { error_log('New LP - No learnpath given for switch', 0); require 'lp_list.php'; }
1164 1172
             $_SESSION['refresh'] = 1;
1165
-            $_SESSION['oLP']->update_default_view_mode();
1166
-        }
1167
-        require 'lp_list.php';
1168
-        break;
1169
-    case 'switch_force_commit':
1170
-        if ($debug > 0) error_log('New LP - switch_force_commit action triggered', 0);
1171
-        if (!$lp_found) { error_log('New LP - No learnpath given for switch', 0); require 'lp_list.php'; }
1172
-        $_SESSION['refresh'] = 1;
1173
-        $_SESSION['oLP']->update_default_scorm_commit();
1174
-        require 'lp_list.php';
1175
-        break;
1176
-    /* Those 2 switches have been replaced by switc_attempt_mode switch
1173
+            $_SESSION['oLP']->update_default_scorm_commit();
1174
+            require 'lp_list.php';
1175
+            break;
1176
+        /* Those 2 switches have been replaced by switc_attempt_mode switch
1177 1177
     case 'switch_reinit':
1178 1178
         if ($debug > 0) error_log('New LP - switch_reinit action triggered', 0);
1179 1179
         if (!$lp_found) { error_log('New LP - No learnpath given for switch', 0); require 'lp_list.php'; }
@@ -1196,199 +1196,199 @@  discard block
 block discarded – undo
1196 1196
 		$_SESSION['oLP']->switch_attempt_mode();
1197 1197
         require 'lp_list.php';
1198 1198
         break;
1199
-    case 'switch_scorm_debug':
1200
-        if ($debug > 0) error_log('New LP - switch_scorm_debug action triggered', 0);
1201
-        if (!$lp_found) { error_log('New LP - No learnpath given for switch', 0); require 'lp_list.php'; }
1202
-        $_SESSION['refresh'] = 1;
1203
-        $_SESSION['oLP']->update_scorm_debug();
1204
-        require 'lp_list.php';
1205
-        break;
1206
-    case 'intro_cmdAdd':
1207
-        if ($debug > 0) error_log('New LP - intro_cmdAdd action triggered', 0);
1208
-        // Add introduction section page.
1209
-        break;
1210
-    case 'js_api_refresh':
1211
-        if ($debug > 0) error_log('New LP - js_api_refresh action triggered', 0);
1212
-        if (!$lp_found) { error_log('New LP - No learnpath given for js_api_refresh', 0); require 'lp_message.php'; }
1213
-        if (isset($_REQUEST['item_id'])) {
1214
-            $htmlHeadXtra[] = $_SESSION['oLP']->get_js_info($_REQUEST['item_id']);
1215
-        }
1216
-        require 'lp_message.php';
1217
-        break;
1218
-    case 'return_to_course_homepage':
1219
-        if (!$lp_found) { error_log('New LP - No learnpath given for stats', 0); require 'lp_list.php'; }
1220
-        else {
1221
-            $_SESSION['oLP']->save_current();
1222
-            $_SESSION['oLP']->save_last();
1223
-            $url = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/index.php?id_session='.api_get_session_id();
1224
-            if (isset($_GET['redirectTo']) && $_GET['redirectTo'] == 'lp_list') {
1225
-                $url = 'lp_controller.php?'.api_get_cidreq();
1226
-            }
1227
-            header('location: '.$url);
1228
-            exit;
1229
-        }
1230
-        break;
1231
-    case 'search':
1232
-        /* Include the search script, it's smart enough to know when we are
1199
+        case 'switch_scorm_debug':
1200
+            if ($debug > 0) error_log('New LP - switch_scorm_debug action triggered', 0);
1201
+            if (!$lp_found) { error_log('New LP - No learnpath given for switch', 0); require 'lp_list.php'; }
1202
+            $_SESSION['refresh'] = 1;
1203
+            $_SESSION['oLP']->update_scorm_debug();
1204
+            require 'lp_list.php';
1205
+            break;
1206
+        case 'intro_cmdAdd':
1207
+            if ($debug > 0) error_log('New LP - intro_cmdAdd action triggered', 0);
1208
+            // Add introduction section page.
1209
+            break;
1210
+        case 'js_api_refresh':
1211
+            if ($debug > 0) error_log('New LP - js_api_refresh action triggered', 0);
1212
+            if (!$lp_found) { error_log('New LP - No learnpath given for js_api_refresh', 0); require 'lp_message.php'; }
1213
+            if (isset($_REQUEST['item_id'])) {
1214
+                $htmlHeadXtra[] = $_SESSION['oLP']->get_js_info($_REQUEST['item_id']);
1215
+            }
1216
+            require 'lp_message.php';
1217
+            break;
1218
+        case 'return_to_course_homepage':
1219
+            if (!$lp_found) { error_log('New LP - No learnpath given for stats', 0); require 'lp_list.php'; }
1220
+            else {
1221
+                $_SESSION['oLP']->save_current();
1222
+                $_SESSION['oLP']->save_last();
1223
+                $url = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/index.php?id_session='.api_get_session_id();
1224
+                if (isset($_GET['redirectTo']) && $_GET['redirectTo'] == 'lp_list') {
1225
+                    $url = 'lp_controller.php?'.api_get_cidreq();
1226
+                }
1227
+                header('location: '.$url);
1228
+                exit;
1229
+            }
1230
+            break;
1231
+        case 'search':
1232
+            /* Include the search script, it's smart enough to know when we are
1233 1233
          * searching or not.
1234 1234
          */
1235
-        require 'lp_list_search.php';
1236
-        break;
1237
-    case 'impress':
1238
-        if ($debug > 0)
1239
-            error_log('New LP - view action triggered', 0);
1240
-        if (!$lp_found) {
1241
-            error_log('New LP - No learnpath given for view', 0);
1242
-            require 'lp_list.php';
1243
-        } else {
1244
-            if ($debug > 0) {error_log('New LP - Trying to impress this LP item to ' . $_REQUEST['item_id'], 0); }
1245
-            if (!empty($_REQUEST['item_id']) ) {
1246
-                $_SESSION['oLP']->set_current_item($_REQUEST['item_id']);
1235
+            require 'lp_list_search.php';
1236
+            break;
1237
+        case 'impress':
1238
+            if ($debug > 0)
1239
+                error_log('New LP - view action triggered', 0);
1240
+            if (!$lp_found) {
1241
+                error_log('New LP - No learnpath given for view', 0);
1242
+                require 'lp_list.php';
1243
+            } else {
1244
+                if ($debug > 0) {error_log('New LP - Trying to impress this LP item to ' . $_REQUEST['item_id'], 0); }
1245
+                if (!empty($_REQUEST['item_id']) ) {
1246
+                    $_SESSION['oLP']->set_current_item($_REQUEST['item_id']);
1247
+                }
1248
+                require 'lp_impress.php';
1249
+            }
1250
+            break;
1251
+        case 'set_previous_step_as_prerequisite':
1252
+            $_SESSION['oLP']->set_previous_step_as_prerequisite_for_all_items();
1253
+            $url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_SESSION['oLP']->lp_id)."&message=ItemUpdated";
1254
+            header('Location: '.$url);
1255
+            break;
1256
+        case 'clear_prerequisites':
1257
+            $_SESSION['oLP']->clear_prerequisites();
1258
+            $url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_SESSION['oLP']->lp_id)."&message=ItemUpdated";
1259
+            header('Location: '.$url);
1260
+            break;
1261
+        case 'toggle_seriousgame': //activate/deactive seriousgame_mode
1262
+            if (!$is_allowed_to_edit) {
1263
+                api_not_allowed(true);
1247 1264
             }
1248
-            require 'lp_impress.php';
1249
-        }
1250
-        break;
1251
-    case 'set_previous_step_as_prerequisite':
1252
-        $_SESSION['oLP']->set_previous_step_as_prerequisite_for_all_items();
1253
-        $url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_SESSION['oLP']->lp_id)."&message=ItemUpdated";
1254
-        header('Location: '.$url);
1255
-        break;
1256
-    case 'clear_prerequisites':
1257
-        $_SESSION['oLP']->clear_prerequisites();
1258
-        $url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_SESSION['oLP']->lp_id)."&message=ItemUpdated";
1259
-        header('Location: '.$url);
1260
-        break;
1261
-    case 'toggle_seriousgame': //activate/deactive seriousgame_mode
1262
-        if (!$is_allowed_to_edit) {
1263
-            api_not_allowed(true);
1264
-        }
1265 1265
 
1266
-        if ($debug > 0) {
1267
-            error_log('New LP - seriousgame_mode action triggered');
1268
-        }
1266
+            if ($debug > 0) {
1267
+                error_log('New LP - seriousgame_mode action triggered');
1268
+            }
1269 1269
 
1270
-        if (!$lp_found) {
1271
-            error_log('New LP - No learnpath given for visibility');
1270
+            if (!$lp_found) {
1271
+                error_log('New LP - No learnpath given for visibility');
1272 1272
 
1273
-            require 'lp_list.php';
1274
-        }
1273
+                require 'lp_list.php';
1274
+            }
1275 1275
 
1276
-        $_SESSION['refresh'] = 1;
1277
-        $_SESSION['oLP']->set_seriousgame_mode();
1278
-        require 'lp_list.php';
1279
-        break;
1280
-    case 'create_forum':
1281
-        if (!isset($_GET['id'])) {
1276
+            $_SESSION['refresh'] = 1;
1277
+            $_SESSION['oLP']->set_seriousgame_mode();
1278
+            require 'lp_list.php';
1282 1279
             break;
1283
-        }
1284
-
1285
-        $selectedItem = null;
1286
-
1287
-        foreach ($_SESSION['oLP']->items as $item) {
1288
-            if ($item->db_id == $_GET['id']) {
1289
-                $selectedItem = $item;
1280
+        case 'create_forum':
1281
+            if (!isset($_GET['id'])) {
1282
+                break;
1290 1283
             }
1291
-        }
1292 1284
 
1293
-        if (!empty($selectedItem)) {
1294
-            $forumThread = $selectedItem->getForumThread(
1295
-                $_SESSION['oLP']->course_int_id,
1296
-                $_SESSION['oLP']->lp_session_id
1297
-            );
1285
+            $selectedItem = null;
1298 1286
 
1299
-            if (empty($forumThread)) {
1300
-                require '../forum/forumfunction.inc.php';
1287
+            foreach ($_SESSION['oLP']->items as $item) {
1288
+                if ($item->db_id == $_GET['id']) {
1289
+                    $selectedItem = $item;
1290
+                }
1291
+            }
1301 1292
 
1302
-                $forumCategory = getForumCategoryByTitle(
1303
-                    get_lang('LearningPaths'),
1293
+            if (!empty($selectedItem)) {
1294
+                $forumThread = $selectedItem->getForumThread(
1304 1295
                     $_SESSION['oLP']->course_int_id,
1305 1296
                     $_SESSION['oLP']->lp_session_id
1306 1297
                 );
1307 1298
 
1308
-                $forumCategoryId = !empty($forumCategory) ? $forumCategory['cat_id']: 0;
1309
-
1310
-                if (empty($forumCategoryId)) {
1311
-                    $forumCategoryId = store_forumcategory(
1312
-                        [
1313
-                            'lp_id' => 0,
1314
-                            'forum_category_title' => get_lang('LearningPaths'),
1315
-                            'forum_category_comment' => null
1316
-                        ],
1317
-                        [],
1318
-                        false
1319
-                    );
1320
-                }
1299
+                if (empty($forumThread)) {
1300
+                    require '../forum/forumfunction.inc.php';
1321 1301
 
1322
-                if (!empty($forumCategoryId)) {
1323
-                    $forum = $_SESSION['oLP']->getForum(
1302
+                    $forumCategory = getForumCategoryByTitle(
1303
+                        get_lang('LearningPaths'),
1304
+                        $_SESSION['oLP']->course_int_id,
1324 1305
                         $_SESSION['oLP']->lp_session_id
1325 1306
                     );
1326 1307
 
1327
-                    $forumId = !empty($forum) ? $forum['forum_id'] : 0;
1328
-
1329
-                    if (empty($forumId)) {
1330
-                        $forumId = $_SESSION['oLP']->createForum($forumCategoryId);
1308
+                    $forumCategoryId = !empty($forumCategory) ? $forumCategory['cat_id']: 0;
1309
+
1310
+                    if (empty($forumCategoryId)) {
1311
+                        $forumCategoryId = store_forumcategory(
1312
+                            [
1313
+                                'lp_id' => 0,
1314
+                                'forum_category_title' => get_lang('LearningPaths'),
1315
+                                'forum_category_comment' => null
1316
+                            ],
1317
+                            [],
1318
+                            false
1319
+                        );
1331 1320
                     }
1332 1321
 
1333
-                    if (!empty($forumId)) {
1334
-                        $selectedItem->createForumThread($forumId);
1322
+                    if (!empty($forumCategoryId)) {
1323
+                        $forum = $_SESSION['oLP']->getForum(
1324
+                            $_SESSION['oLP']->lp_session_id
1325
+                        );
1326
+
1327
+                        $forumId = !empty($forum) ? $forum['forum_id'] : 0;
1328
+
1329
+                        if (empty($forumId)) {
1330
+                            $forumId = $_SESSION['oLP']->createForum($forumCategoryId);
1331
+                        }
1332
+
1333
+                        if (!empty($forumId)) {
1334
+                            $selectedItem->createForumThread($forumId);
1335
+                        }
1335 1336
                     }
1336 1337
                 }
1337 1338
             }
1338
-        }
1339 1339
 
1340
-        header('Location:' . api_get_self() . '?' . http_build_query([
1341
-            'action' => 'add_item',
1342
-            'type' => 'step',
1343
-            'lp_id' => $_SESSION['oLP']->lp_id
1344
-        ]));
1340
+            header('Location:' . api_get_self() . '?' . http_build_query([
1341
+                'action' => 'add_item',
1342
+                'type' => 'step',
1343
+                'lp_id' => $_SESSION['oLP']->lp_id
1344
+            ]));
1345 1345
 
1346
-        break;
1347
-    case 'report':
1348
-        require 'lp_report.php';
1349
-        break;
1350
-    case 'dissociate_forum':
1351
-        if (!isset($_GET['id'])) {
1352 1346
             break;
1353
-        }
1347
+        case 'report':
1348
+            require 'lp_report.php';
1349
+            break;
1350
+        case 'dissociate_forum':
1351
+            if (!isset($_GET['id'])) {
1352
+                break;
1353
+            }
1354 1354
 
1355
-        $selectedItem = null;
1355
+            $selectedItem = null;
1356 1356
 
1357
-        foreach ($_SESSION['oLP']->items as $item) {
1358
-            if ($item->db_id != $_GET['id']) {
1359
-                continue;
1360
-            }
1357
+            foreach ($_SESSION['oLP']->items as $item) {
1358
+                if ($item->db_id != $_GET['id']) {
1359
+                    continue;
1360
+                }
1361 1361
 
1362
-            $selectedItem = $item;
1363
-        }
1362
+                $selectedItem = $item;
1363
+            }
1364 1364
 
1365
-        if (!empty($selectedItem)) {
1366
-            $forumThread = $selectedItem->getForumThread(
1367
-                $_SESSION['oLP']->course_int_id,
1368
-                $_SESSION['oLP']->lp_session_id
1369
-            );
1365
+            if (!empty($selectedItem)) {
1366
+                $forumThread = $selectedItem->getForumThread(
1367
+                    $_SESSION['oLP']->course_int_id,
1368
+                    $_SESSION['oLP']->lp_session_id
1369
+                );
1370 1370
 
1371
-            if (!empty($forumThread)) {
1372
-                $dissoaciated = $selectedItem->dissociateForumThread($forumThread['iid']);
1371
+                if (!empty($forumThread)) {
1372
+                    $dissoaciated = $selectedItem->dissociateForumThread($forumThread['iid']);
1373 1373
 
1374
-                if ($dissoaciated) {
1375
-                    Display::addFlash(
1376
-                        Display::return_message(get_lang('ForumDissociate'), 'success')
1377
-                    );
1374
+                    if ($dissoaciated) {
1375
+                        Display::addFlash(
1376
+                            Display::return_message(get_lang('ForumDissociate'), 'success')
1377
+                        );
1378
+                    }
1378 1379
                 }
1379 1380
             }
1380
-        }
1381 1381
 
1382
-        header('Location:' . api_get_self() . '?' . http_build_query([
1383
-            'action' => 'add_item',
1384
-            'type' => 'step',
1385
-            'lp_id' => $_SESSION['oLP']->lp_id
1386
-        ]));
1387
-        break;
1388
-    default:
1389
-        if ($debug > 0) error_log('New LP - default action triggered', 0);
1390
-        require 'lp_list.php';
1391
-        break;
1382
+            header('Location:' . api_get_self() . '?' . http_build_query([
1383
+                'action' => 'add_item',
1384
+                'type' => 'step',
1385
+                'lp_id' => $_SESSION['oLP']->lp_id
1386
+            ]));
1387
+            break;
1388
+        default:
1389
+            if ($debug > 0) error_log('New LP - default action triggered', 0);
1390
+            require 'lp_list.php';
1391
+            break;
1392 1392
 }
1393 1393
 
1394 1394
 if (!empty($_SESSION['oLP'])) {
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 
26 26
 // Including the global initialization file.
27 27
 require_once '../inc/global.inc.php';
28
-$current_course_tool  = TOOL_LEARNPATH;
28
+$current_course_tool = TOOL_LEARNPATH;
29 29
 $_course = api_get_course_info();
30 30
 
31 31
 $glossaryExtraTools = api_get_setting('show_glossary_in_extra_tools');
@@ -37,11 +37,11 @@  discard block
 block discarded – undo
37 37
     ) {
38 38
         $htmlHeadXtra[] = '<script>
39 39
     <!--
40
-        var jQueryFrameReadyConfigPath = \'' . api_get_jquery_web_path() . '\';
40
+        var jQueryFrameReadyConfigPath = \'' . api_get_jquery_web_path().'\';
41 41
     -->
42 42
     </script>';
43
-    $htmlHeadXtra[] = '<script src="' . api_get_path(WEB_LIBRARY_PATH) . 'javascript/jquery.frameready.js" type="text/javascript" language="javascript"></script>';
44
-    $htmlHeadXtra[] = '<script src="' . api_get_path(WEB_LIBRARY_PATH) . 'javascript/jquery.highlight.js" type="text/javascript" language="javascript"></script>';
43
+    $htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.frameready.js" type="text/javascript" language="javascript"></script>';
44
+    $htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.highlight.js" type="text/javascript" language="javascript"></script>';
45 45
     }
46 46
 }
47 47
 
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
 
269 269
 $course_id = api_get_course_int_id();
270 270
 
271
-if ($debug>0) error_log('New LP - Passed data remains check', 0);
271
+if ($debug > 0) error_log('New LP - Passed data remains check', 0);
272 272
 
273 273
 if (!$lp_found || (!empty($_REQUEST['lp_id']) && $_SESSION['oLP']->get_id() != $_REQUEST['lp_id'])) {
274 274
     if ($debug > 0) error_log('New LP - oLP is not object, has changed or refresh been asked, getting new', 0);
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
             if (Database::num_rows($res)) {
293 293
                 $row = Database::fetch_array($res);
294 294
                 $type = $row['lp_type'];
295
-                if ($debug > 0) error_log('New LP - found row - type '.$type. ' - Calling constructor with '.api_get_course_id().' - '.$lp_id.' - '.api_get_user_id(), 0);
295
+                if ($debug > 0) error_log('New LP - found row - type '.$type.' - Calling constructor with '.api_get_course_id().' - '.$lp_id.' - '.api_get_user_id(), 0);
296 296
                 switch ($type) {
297 297
                     case 1:
298 298
                         if ($debug > 0) error_log('New LP - found row - type dokeos - Calling constructor with '.api_get_course_id().' - '.$lp_id.' - '.api_get_user_id(), 0);
@@ -687,8 +687,8 @@  discard block
 block discarded – undo
687 687
                 $editPrerequisite = $_SESSION['oLP']->edit_item_prereq(
688 688
                     $_GET['id'],
689 689
                     $_POST['prerequisites'],
690
-                    $_POST['min_' . $_POST['prerequisites']],
691
-                    $_POST['max_' . $_POST['prerequisites']]
690
+                    $_POST['min_'.$_POST['prerequisites']],
691
+                    $_POST['max_'.$_POST['prerequisites']]
692 692
                 );
693 693
 
694 694
                 if ($editPrerequisite) {
@@ -937,7 +937,7 @@  discard block
 block discarded – undo
937 937
             $_SESSION['oLP']->setSubscribeUsers($_REQUEST['subscribe_users']);
938 938
 
939 939
             if (isset($_REQUEST['activate_start_date_check']) && $_REQUEST['activate_start_date_check'] == 1) {
940
-            	$publicated_on  = $_REQUEST['publicated_on'];
940
+            	$publicated_on = $_REQUEST['publicated_on'];
941 941
             } else {
942 942
             	$publicated_on = null;
943 943
             }
@@ -1008,7 +1008,7 @@  discard block
 block discarded – undo
1008 1008
         else {
1009 1009
             $_SESSION['refresh'] = 1;
1010 1010
             if (!empty($_REQUEST['parent_item_id'])) {
1011
-                $_SESSION['from_learnpath']='yes';
1011
+                $_SESSION['from_learnpath'] = 'yes';
1012 1012
                 $_SESSION['origintoolurl'] = 'lp_controller.php?action=admin_view&lp_id='.Security::remove_XSS($_REQUEST['lp_id']);
1013 1013
                 require 'resourcelinker.php';
1014 1014
             } else {
@@ -1109,8 +1109,8 @@  discard block
 block discarded – undo
1109 1109
             error_log('New LP - No learnpath given for view', 0);
1110 1110
             require 'lp_list.php';
1111 1111
         } else {
1112
-            if ($debug > 0) {error_log('New LP - Trying to set current item to ' . $_REQUEST['item_id'], 0); }
1113
-            if ( !empty($_REQUEST['item_id']) ) {
1112
+            if ($debug > 0) {error_log('New LP - Trying to set current item to '.$_REQUEST['item_id'], 0); }
1113
+            if (!empty($_REQUEST['item_id'])) {
1114 1114
                 $_SESSION['oLP']->set_current_item($_REQUEST['item_id']);
1115 1115
             }
1116 1116
             require 'lp_view.php';
@@ -1190,8 +1190,8 @@  discard block
 block discarded – undo
1190 1190
 		break;
1191 1191
      */
1192 1192
 	case 'switch_attempt_mode':
1193
-		if($debug>0) error_log('New LP - switch_reinit action triggered',0);
1194
-		if(!$lp_found){ error_log('New LP - No learnpath given for switch',0); require 'lp_list.php'; }
1193
+		if ($debug > 0) error_log('New LP - switch_reinit action triggered', 0);
1194
+		if (!$lp_found) { error_log('New LP - No learnpath given for switch', 0); require 'lp_list.php'; }
1195 1195
 		$_SESSION['refresh'] = 1;
1196 1196
 		$_SESSION['oLP']->switch_attempt_mode();
1197 1197
         require 'lp_list.php';
@@ -1241,8 +1241,8 @@  discard block
 block discarded – undo
1241 1241
             error_log('New LP - No learnpath given for view', 0);
1242 1242
             require 'lp_list.php';
1243 1243
         } else {
1244
-            if ($debug > 0) {error_log('New LP - Trying to impress this LP item to ' . $_REQUEST['item_id'], 0); }
1245
-            if (!empty($_REQUEST['item_id']) ) {
1244
+            if ($debug > 0) {error_log('New LP - Trying to impress this LP item to '.$_REQUEST['item_id'], 0); }
1245
+            if (!empty($_REQUEST['item_id'])) {
1246 1246
                 $_SESSION['oLP']->set_current_item($_REQUEST['item_id']);
1247 1247
             }
1248 1248
             require 'lp_impress.php';
@@ -1305,7 +1305,7 @@  discard block
 block discarded – undo
1305 1305
                     $_SESSION['oLP']->lp_session_id
1306 1306
                 );
1307 1307
 
1308
-                $forumCategoryId = !empty($forumCategory) ? $forumCategory['cat_id']: 0;
1308
+                $forumCategoryId = !empty($forumCategory) ? $forumCategory['cat_id'] : 0;
1309 1309
 
1310 1310
                 if (empty($forumCategoryId)) {
1311 1311
                     $forumCategoryId = store_forumcategory(
@@ -1337,7 +1337,7 @@  discard block
 block discarded – undo
1337 1337
             }
1338 1338
         }
1339 1339
 
1340
-        header('Location:' . api_get_self() . '?' . http_build_query([
1340
+        header('Location:'.api_get_self().'?'.http_build_query([
1341 1341
             'action' => 'add_item',
1342 1342
             'type' => 'step',
1343 1343
             'lp_id' => $_SESSION['oLP']->lp_id
@@ -1379,7 +1379,7 @@  discard block
 block discarded – undo
1379 1379
             }
1380 1380
         }
1381 1381
 
1382
-        header('Location:' . api_get_self() . '?' . http_build_query([
1382
+        header('Location:'.api_get_self().'?'.http_build_query([
1383 1383
             'action' => 'add_item',
1384 1384
             'type' => 'step',
1385 1385
             'lp_id' => $_SESSION['oLP']->lp_id
Please login to merge, or discard this patch.
Braces   +225 added lines, -121 removed lines patch added patch discarded remove patch
@@ -13,7 +13,9 @@  discard block
 block discarded – undo
13 13
 $use_anonymous = true;
14 14
 
15 15
 $debug = 0;
16
-if ($debug > 0) error_log('New LP -+- Entered lp_controller.php -+- (action: '.$_REQUEST['action'].')', 0);
16
+if ($debug > 0) {
17
+    error_log('New LP -+- Entered lp_controller.php -+- (action: '.$_REQUEST['action'].')', 0);
18
+}
17 19
 
18 20
 // Language files that needs to be included.
19 21
 if (isset($_GET['action'])) {
@@ -231,10 +233,14 @@  discard block
 block discarded – undo
231 233
     // If refresh is set, we regenerate the oLP object from the database (kind of flush).
232 234
     Session::erase('refresh');
233 235
     $myrefresh = 1;
234
-    if ($debug > 0) error_log('New LP - Refresh asked', 0);
235
-}
236
+    if ($debug > 0) {
237
+        error_log('New LP - Refresh asked', 0);
238
+    }
239
+    }
236 240
 
237
-if ($debug > 0) error_log('New LP - Passed refresh check', 0);
241
+if ($debug > 0) {
242
+    error_log('New LP - Passed refresh check', 0);
243
+}
238 244
 
239 245
 if (!empty($_REQUEST['dialog_box'])) {
240 246
     $dialog_box = stripslashes(urldecode($_REQUEST['dialog_box']));
@@ -244,17 +250,23 @@  discard block
 block discarded – undo
244 250
 $lp_found = false;
245 251
 
246 252
 if (isset($_SESSION['lpobject'])) {
247
-    if ($debug > 0) error_log('New LP - SESSION[lpobject] is defined', 0);
253
+    if ($debug > 0) {
254
+        error_log('New LP - SESSION[lpobject] is defined', 0);
255
+    }
248 256
     $oLP = unserialize($_SESSION['lpobject']);
249 257
     if (isset($oLP) && is_object($oLP)) {
250
-        if ($debug > 0) error_log('New LP - oLP is object', 0);
258
+        if ($debug > 0) {
259
+            error_log('New LP - oLP is object', 0);
260
+        }
251 261
         if ($myrefresh == 1 OR
252 262
             empty($oLP->cc) OR
253 263
             $oLP->cc != api_get_course_id() OR
254 264
             $oLP->lp_view_session_id != $session_id OR
255 265
             $oLP->scorm_debug == '1'
256 266
         ) {
257
-            if ($debug > 0) error_log('New LP - Course has changed, discard lp object', 0);
267
+            if ($debug > 0) {
268
+                error_log('New LP - Course has changed, discard lp object', 0);
269
+            }
258 270
             if ($myrefresh == 1) { $myrefresh_id = $oLP->get_id(); }
259 271
             $oLP = null;
260 272
             Session::erase('oLP');
@@ -268,13 +280,19 @@  discard block
 block discarded – undo
268 280
 
269 281
 $course_id = api_get_course_int_id();
270 282
 
271
-if ($debug>0) error_log('New LP - Passed data remains check', 0);
283
+if ($debug>0) {
284
+    error_log('New LP - Passed data remains check', 0);
285
+}
272 286
 
273 287
 if (!$lp_found || (!empty($_REQUEST['lp_id']) && $_SESSION['oLP']->get_id() != $_REQUEST['lp_id'])) {
274
-    if ($debug > 0) error_log('New LP - oLP is not object, has changed or refresh been asked, getting new', 0);
288
+    if ($debug > 0) {
289
+        error_log('New LP - oLP is not object, has changed or refresh been asked, getting new', 0);
290
+    }
275 291
     // Regenerate a new lp object? Not always as some pages don't need the object (like upload?)
276 292
     if (!empty($_REQUEST['lp_id']) || !empty($myrefresh_id)) {
277
-        if ($debug > 0) error_log('New LP - lp_id is defined', 0);
293
+        if ($debug > 0) {
294
+            error_log('New LP - lp_id is defined', 0);
295
+        }
278 296
         // Select the lp in the database and check which type it is (scorm/dokeos/aicc) to generate the
279 297
         // right object.
280 298
         if (!empty($_REQUEST['lp_id'])) {
@@ -286,49 +304,67 @@  discard block
 block discarded – undo
286 304
         $lp_table = Database::get_course_table(TABLE_LP_MAIN);
287 305
         if (is_numeric($lp_id)) {
288 306
             $sel = "SELECT lp_type FROM $lp_table WHERE c_id = $course_id AND id = $lp_id";
289
-            if ($debug > 0) error_log('New LP - querying '.$sel, 0);
307
+            if ($debug > 0) {
308
+                error_log('New LP - querying '.$sel, 0);
309
+            }
290 310
             $res = Database::query($sel);
291 311
 
292 312
             if (Database::num_rows($res)) {
293 313
                 $row = Database::fetch_array($res);
294 314
                 $type = $row['lp_type'];
295
-                if ($debug > 0) error_log('New LP - found row - type '.$type. ' - Calling constructor with '.api_get_course_id().' - '.$lp_id.' - '.api_get_user_id(), 0);
315
+                if ($debug > 0) {
316
+                    error_log('New LP - found row - type '.$type. ' - Calling constructor with '.api_get_course_id().' - '.$lp_id.' - '.api_get_user_id(), 0);
317
+                }
296 318
                 switch ($type) {
297 319
                     case 1:
298
-                        if ($debug > 0) error_log('New LP - found row - type dokeos - Calling constructor with '.api_get_course_id().' - '.$lp_id.' - '.api_get_user_id(), 0);
320
+                        if ($debug > 0) {
321
+                            error_log('New LP - found row - type dokeos - Calling constructor with '.api_get_course_id().' - '.$lp_id.' - '.api_get_user_id(), 0);
322
+                        }
299 323
 
300 324
                         $oLP = new learnpath(api_get_course_id(), $lp_id, api_get_user_id());
301 325
                         if ($oLP !== false) { $lp_found = true; } else { error_log($oLP->error, 0); }
302 326
                         break;
303 327
                     case 2:
304
-                        if ($debug > 0) error_log('New LP - found row - type scorm - Calling constructor with '.api_get_course_id().' - '.$lp_id.' - '.api_get_user_id(), 0);
328
+                        if ($debug > 0) {
329
+                            error_log('New LP - found row - type scorm - Calling constructor with '.api_get_course_id().' - '.$lp_id.' - '.api_get_user_id(), 0);
330
+                        }
305 331
                         $oLP = new scorm(api_get_course_id(), $lp_id, api_get_user_id());
306 332
                         if ($oLP !== false) { $lp_found = true; } else { error_log($oLP->error, 0); }
307 333
                         break;
308 334
                     case 3:
309
-                        if ($debug > 0) error_log('New LP - found row - type aicc - Calling constructor with '.api_get_course_id().' - '.$lp_id.' - '.api_get_user_id(), 0);
335
+                        if ($debug > 0) {
336
+                            error_log('New LP - found row - type aicc - Calling constructor with '.api_get_course_id().' - '.$lp_id.' - '.api_get_user_id(), 0);
337
+                        }
310 338
                         $oLP = new aicc(api_get_course_id(), $lp_id, api_get_user_id());
311 339
                         if ($oLP !== false) { $lp_found = true; } else { error_log($oLP->error, 0); }
312 340
                         break;
313 341
                     default:
314
-                        if ($debug > 0) error_log('New LP - found row - type other - Calling constructor with '.api_get_course_id().' - '.$lp_id.' - '.api_get_user_id(), 0);
342
+                        if ($debug > 0) {
343
+                            error_log('New LP - found row - type other - Calling constructor with '.api_get_course_id().' - '.$lp_id.' - '.api_get_user_id(), 0);
344
+                        }
315 345
                         $oLP = new learnpath(api_get_course_id(), $lp_id, api_get_user_id());
316 346
                         if ($oLP !== false) { $lp_found = true; } else { error_log($oLP->error, 0); }
317 347
                         break;
318 348
                 }
319 349
             }
320 350
         } else {
321
-            if ($debug > 0) error_log('New LP - Request[lp_id] is not numeric', 0);
351
+            if ($debug > 0) {
352
+                error_log('New LP - Request[lp_id] is not numeric', 0);
353
+            }
322 354
         }
323 355
     } else {
324
-        if ($debug > 0) error_log('New LP - Request[lp_id] and refresh_id were empty', 0);
356
+        if ($debug > 0) {
357
+            error_log('New LP - Request[lp_id] and refresh_id were empty', 0);
358
+        }
325 359
     }
326 360
     if ($lp_found) {
327 361
         $_SESSION['oLP'] = $oLP;
328 362
     }
329 363
 }
330 364
 
331
-if ($debug > 0) error_log('New LP - Passed oLP creation check', 0);
365
+if ($debug > 0) {
366
+    error_log('New LP - Passed oLP creation check', 0);
367
+}
332 368
 
333 369
 $is_allowed_to_edit = api_is_allowed_to_edit(false, true, false, false);
334 370
 
@@ -369,11 +405,15 @@  discard block
 block discarded – undo
369 405
         if (!$is_allowed_to_edit) {
370 406
             api_not_allowed(true);
371 407
         }
372
-        if ($debug > 0) error_log('New LP - add item action triggered', 0);
408
+        if ($debug > 0) {
409
+            error_log('New LP - add item action triggered', 0);
410
+        }
373 411
 
374 412
         if (!$lp_found) {
375 413
             //check if the learnpath ID was defined, otherwise send back to list
376
-            if ($debug > 0) error_log('New LP - No learnpath given for add item', 0);
414
+            if ($debug > 0) {
415
+                error_log('New LP - No learnpath given for add item', 0);
416
+            }
377 417
             require 'lp_list.php';
378 418
         } else {
379 419
             $_SESSION['refresh'] = 1;
@@ -447,11 +487,15 @@  discard block
 block discarded – undo
447 487
         if (!$is_allowed_to_edit) {
448 488
             api_not_allowed(true);
449 489
         }
450
-        if ($debug > 0) error_log('New LP - add audio action triggered', 0);
490
+        if ($debug > 0) {
491
+            error_log('New LP - add audio action triggered', 0);
492
+        }
451 493
 
452 494
         if (!$lp_found) {
453 495
             //check if the learnpath ID was defined, otherwise send back to list
454
-            if ($debug > 0) error_log('New LP - No learnpath given for add audio', 0);
496
+            if ($debug > 0) {
497
+                error_log('New LP - No learnpath given for add audio', 0);
498
+            }
455 499
             require 'lp_list.php';
456 500
         } else {
457 501
             $_SESSION['refresh'] = 1;
@@ -525,7 +569,9 @@  discard block
 block discarded – undo
525 569
         if (!$is_allowed_to_edit) {
526 570
             api_not_allowed(true);
527 571
         }
528
-        if ($debug > 0) error_log('New LP - add_lp action triggered', 0);
572
+        if ($debug > 0) {
573
+            error_log('New LP - add_lp action triggered', 0);
574
+        }
529 575
         if (isset($_REQUEST['lp_name']) && !empty($_REQUEST['lp_name'])) {
530 576
             $_REQUEST['lp_name'] = trim($_REQUEST['lp_name']);
531 577
             $_SESSION['refresh'] = 1;
@@ -584,9 +630,10 @@  discard block
 block discarded – undo
584 630
         if (!$is_allowed_to_edit) {
585 631
             api_not_allowed(true);
586 632
         }
587
-        if ($debug > 0) error_log('New LP - admin_view action triggered', 0);
588
-        if (!$lp_found) { error_log('New LP - No learnpath given for admin_view', 0); require 'lp_list.php'; }
589
-        else {
633
+        if ($debug > 0) {
634
+            error_log('New LP - admin_view action triggered', 0);
635
+        }
636
+        if (!$lp_found) { error_log('New LP - No learnpath given for admin_view', 0); require 'lp_list.php'; } else {
590 637
             $_SESSION['refresh'] = 1;
591 638
             require 'lp_admin_view.php';
592 639
         }
@@ -596,9 +643,10 @@  discard block
 block discarded – undo
596 643
             if (!$is_allowed_to_edit) {
597 644
                 api_not_allowed(true);
598 645
             }
599
-            if ($debug > 0) error_log('New LP - auto_launch action triggered', 0);
600
-            if (!$lp_found) { error_log('New LP - No learnpath given for set_autolaunch', 0); require 'lp_list.php'; }
601
-            else {
646
+            if ($debug > 0) {
647
+                error_log('New LP - auto_launch action triggered', 0);
648
+            }
649
+            if (!$lp_found) { error_log('New LP - No learnpath given for set_autolaunch', 0); require 'lp_list.php'; } else {
602 650
                 $_SESSION['oLP']->set_autolaunch($_GET['lp_id'], $_GET['status']);
603 651
                 require 'lp_list.php';
604 652
                 exit;
@@ -609,10 +657,11 @@  discard block
 block discarded – undo
609 657
         if (!$is_allowed_to_edit) {
610 658
             api_not_allowed(true);
611 659
         }
612
-        if ($debug > 0) error_log('New LP - build action triggered', 0);
660
+        if ($debug > 0) {
661
+            error_log('New LP - build action triggered', 0);
662
+        }
613 663
 
614
-        if (!$lp_found) { error_log('New LP - No learnpath given for build', 0); require 'lp_list.php'; }
615
-        else {
664
+        if (!$lp_found) { error_log('New LP - No learnpath given for build', 0); require 'lp_list.php'; } else {
616 665
             $_SESSION['refresh'] = 1;
617 666
             //require 'lp_build.php';
618 667
             $url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_SESSION['oLP']->lp_id);
@@ -624,10 +673,11 @@  discard block
 block discarded – undo
624 673
         if (!$is_allowed_to_edit) {
625 674
             api_not_allowed(true);
626 675
         }
627
-        if ($debug > 0) error_log('New LP - edit item action triggered', 0);
676
+        if ($debug > 0) {
677
+            error_log('New LP - edit item action triggered', 0);
678
+        }
628 679
 
629
-        if (!$lp_found) { error_log('New LP - No learnpath given for edit item', 0); require 'lp_list.php'; }
630
-        else {
680
+        if (!$lp_found) { error_log('New LP - No learnpath given for edit item', 0); require 'lp_list.php'; } else {
631 681
             $_SESSION['refresh'] = 1;
632 682
             if (isset($_POST['submit_button']) && !empty($post_title)) {
633 683
 
@@ -677,9 +727,10 @@  discard block
 block discarded – undo
677 727
         if (!$is_allowed_to_edit) {
678 728
             api_not_allowed(true);
679 729
         }
680
-        if ($debug > 0) error_log('New LP - edit item prereq action triggered', 0);
681
-        if (!$lp_found) { error_log('New LP - No learnpath given for edit item prereq', 0); require 'lp_list.php'; }
682
-        else {
730
+        if ($debug > 0) {
731
+            error_log('New LP - edit item prereq action triggered', 0);
732
+        }
733
+        if (!$lp_found) { error_log('New LP - No learnpath given for edit item prereq', 0); require 'lp_list.php'; } else {
683 734
             if (isset($_POST['submit_button'])) {
684 735
                 //Updating the lp.modified_on
685 736
                 $_SESSION['oLP']->set_modified_on();
@@ -707,9 +758,10 @@  discard block
 block discarded – undo
707 758
         if (!$is_allowed_to_edit) {
708 759
             api_not_allowed(true);
709 760
         }
710
-        if ($debug > 0) error_log('New LP - move item action triggered', 0);
711
-        if (!$lp_found) { error_log('New LP - No learnpath given for move item', 0); require 'lp_list.php'; }
712
-        else {
761
+        if ($debug > 0) {
762
+            error_log('New LP - move item action triggered', 0);
763
+        }
764
+        if (!$lp_found) { error_log('New LP - No learnpath given for move item', 0); require 'lp_list.php'; } else {
713 765
             $_SESSION['refresh'] = 1;
714 766
             if (isset($_POST['submit_button'])) {
715 767
                 //Updating the lp.modified_on
@@ -742,7 +794,9 @@  discard block
 block discarded – undo
742 794
         if (!$is_allowed_to_edit) {
743 795
             api_not_allowed(true);
744 796
         }
745
-        if ($debug > 0) error_log('New LP - view_item action triggered', 0);
797
+        if ($debug > 0) {
798
+            error_log('New LP - view_item action triggered', 0);
799
+        }
746 800
         if (!$lp_found) {
747 801
             error_log('New LP - No learnpath given for view item', 0); require 'lp_list.php';
748 802
         } else {
@@ -754,7 +808,9 @@  discard block
 block discarded – undo
754 808
         if (!$is_allowed_to_edit) {
755 809
             api_not_allowed(true);
756 810
         }
757
-        if ($debug > 0) error_log('New LP - upload action triggered', 0);
811
+        if ($debug > 0) {
812
+            error_log('New LP - upload action triggered', 0);
813
+        }
758 814
         $cwdir = getcwd();
759 815
         require 'lp_upload.php';
760 816
         // Reinit current working directory as many functions in upload change it.
@@ -771,9 +827,10 @@  discard block
 block discarded – undo
771 827
             api_not_allowed(true);
772 828
         }
773 829
 
774
-        if ($debug > 0) error_log('New LP - export action triggered', 0);
775
-        if (!$lp_found) { error_log('New LP - No learnpath given for copy', 0); require 'lp_list.php'; }
776
-        else {
830
+        if ($debug > 0) {
831
+            error_log('New LP - export action triggered', 0);
832
+        }
833
+        if (!$lp_found) { error_log('New LP - No learnpath given for copy', 0); require 'lp_list.php'; } else {
777 834
             $_SESSION['oLP']->copy();
778 835
         }
779 836
         require 'lp_list.php';
@@ -786,9 +843,10 @@  discard block
 block discarded – undo
786 843
         if ($hideScormExportLink === 'true') {
787 844
             api_not_allowed(true);
788 845
         }
789
-        if ($debug > 0) error_log('New LP - export action triggered', 0);
790
-        if (!$lp_found) { error_log('New LP - No learnpath given for export', 0); require 'lp_list.php'; }
791
-        else {
846
+        if ($debug > 0) {
847
+            error_log('New LP - export action triggered', 0);
848
+        }
849
+        if (!$lp_found) { error_log('New LP - No learnpath given for export', 0); require 'lp_list.php'; } else {
792 850
             $_SESSION['oLP']->scorm_export();
793 851
             exit();
794 852
             //require 'lp_list.php';
@@ -803,7 +861,9 @@  discard block
 block discarded – undo
803 861
             api_not_allowed(true);
804 862
         }
805 863
 
806
-        if ($debug > 0) error_log('New LP - export action triggered', 0);
864
+        if ($debug > 0) {
865
+            error_log('New LP - export action triggered', 0);
866
+        }
807 867
         if (!$lp_found) { error_log('New LP - No learnpath given for export_to_pdf', 0); require 'lp_list.php';
808 868
         } else {
809 869
             $result = $_SESSION['oLP']->scorm_export_to_pdf($_GET['lp_id']);
@@ -817,9 +877,10 @@  discard block
 block discarded – undo
817 877
         if (!$is_allowed_to_edit) {
818 878
             api_not_allowed(true);
819 879
         }
820
-        if ($debug > 0) error_log('New LP - delete action triggered', 0);
821
-        if (!$lp_found) { error_log('New LP - No learnpath given for delete', 0); require 'lp_list.php'; }
822
-        else {
880
+        if ($debug > 0) {
881
+            error_log('New LP - delete action triggered', 0);
882
+        }
883
+        if (!$lp_found) { error_log('New LP - No learnpath given for delete', 0); require 'lp_list.php'; } else {
823 884
             $_SESSION['refresh'] = 1;
824 885
             $_SESSION['oLP']->delete(null, $_GET['lp_id'], 'remove');
825 886
             Session::erase('oLP');
@@ -831,9 +892,10 @@  discard block
 block discarded – undo
831 892
         if (!$is_allowed_to_edit) {
832 893
             api_not_allowed(true);
833 894
         }
834
-        if ($debug > 0) error_log('New LP - visibility action triggered', 0);
835
-        if (!$lp_found) { error_log('New LP - No learnpath given for visibility', 0); require 'lp_list.php'; }
836
-        else {
895
+        if ($debug > 0) {
896
+            error_log('New LP - visibility action triggered', 0);
897
+        }
898
+        if (!$lp_found) { error_log('New LP - No learnpath given for visibility', 0); require 'lp_list.php'; } else {
837 899
             learnpath::toggle_visibility($_REQUEST['lp_id'], $_REQUEST['new_status']);
838 900
             require 'lp_list.php';
839 901
         }
@@ -843,9 +905,10 @@  discard block
 block discarded – undo
843 905
         if (!$is_allowed_to_edit) {
844 906
             api_not_allowed(true);
845 907
         }
846
-        if ($debug > 0) error_log('New LP - publish action triggered', 0);
847
-        if (!$lp_found) { error_log('New LP - No learnpath given for publish', 0); require 'lp_list.php'; }
848
-        else {
908
+        if ($debug > 0) {
909
+            error_log('New LP - publish action triggered', 0);
910
+        }
911
+        if (!$lp_found) { error_log('New LP - No learnpath given for publish', 0); require 'lp_list.php'; } else {
849 912
             learnpath::toggle_publish($_REQUEST['lp_id'], $_REQUEST['new_status']);
850 913
             require 'lp_list.php';
851 914
         }
@@ -855,7 +918,9 @@  discard block
 block discarded – undo
855 918
         if (!$is_allowed_to_edit) {
856 919
             api_not_allowed(true);
857 920
         }
858
-        if ($debug > 0) error_log('New LP - publish action triggered', 0);
921
+        if ($debug > 0) {
922
+            error_log('New LP - publish action triggered', 0);
923
+        }
859 924
         if (!$lp_found) {
860 925
             error_log('New LP - No learnpath given for publish', 0);
861 926
             require 'lp_list.php';
@@ -869,7 +934,9 @@  discard block
 block discarded – undo
869 934
         if (!$is_allowed_to_edit) {
870 935
             api_not_allowed(true);
871 936
         }
872
-        if ($debug > 0) error_log('New LP - publish action triggered', 0);
937
+        if ($debug > 0) {
938
+            error_log('New LP - publish action triggered', 0);
939
+        }
873 940
         if (!$lp_found) {
874 941
             error_log('New LP - No learnpath given for publish', 0);
875 942
             require 'lp_list.php';
@@ -882,9 +949,10 @@  discard block
 block discarded – undo
882 949
         if (!$is_allowed_to_edit) {
883 950
             api_not_allowed(true);
884 951
         }
885
-        if ($debug > 0) error_log('New LP - edit action triggered', 0);
886
-        if (!$lp_found) { error_log('New LP - No learnpath given for edit', 0); require 'lp_list.php'; }
887
-        else {
952
+        if ($debug > 0) {
953
+            error_log('New LP - edit action triggered', 0);
954
+        }
955
+        if (!$lp_found) { error_log('New LP - No learnpath given for edit', 0); require 'lp_list.php'; } else {
888 956
             $_SESSION['refresh'] = 1;
889 957
             require 'lp_edit.php';
890 958
         }
@@ -893,9 +961,10 @@  discard block
 block discarded – undo
893 961
         if (!$is_allowed_to_edit) {
894 962
             api_not_allowed(true);
895 963
         }
896
-        if ($debug > 0) error_log('New LP - update_lp action triggered', 0);
897
-        if (!$lp_found) { error_log('New LP - No learnpath given for edit', 0); require 'lp_list.php'; }
898
-        else {
964
+        if ($debug > 0) {
965
+            error_log('New LP - update_lp action triggered', 0);
966
+        }
967
+        if (!$lp_found) { error_log('New LP - No learnpath given for edit', 0); require 'lp_list.php'; } else {
899 968
             $_SESSION['refresh'] = 1;
900 969
             $lp_name = Security::remove_XSS($_REQUEST['lp_name']);
901 970
             $_SESSION['oLP']->set_name($lp_name);
@@ -962,8 +1031,9 @@  discard block
 block discarded – undo
962 1031
             );
963 1032
             $extraFieldValue->saveFieldValues($_REQUEST);
964 1033
 
965
-            if ($_FILES['lp_preview_image']['size'] > 0)
966
-                $_SESSION['oLP']->upload_image($_FILES['lp_preview_image']);
1034
+            if ($_FILES['lp_preview_image']['size'] > 0) {
1035
+                            $_SESSION['oLP']->upload_image($_FILES['lp_preview_image']);
1036
+            }
967 1037
 
968 1038
             if (api_get_setting('search_enabled') === 'true') {
969 1039
                 require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php';
@@ -1003,9 +1073,10 @@  discard block
 block discarded – undo
1003 1073
         if (!$is_allowed_to_edit) {
1004 1074
             api_not_allowed(true);
1005 1075
         }
1006
-        if ($debug > 0) error_log('New LP - add sub item action triggered', 0);
1007
-        if (!$lp_found) { error_log('New LP - No learnpath given for add sub item', 0); require 'lp_list.php'; }
1008
-        else {
1076
+        if ($debug > 0) {
1077
+            error_log('New LP - add sub item action triggered', 0);
1078
+        }
1079
+        if (!$lp_found) { error_log('New LP - No learnpath given for add sub item', 0); require 'lp_list.php'; } else {
1009 1080
             $_SESSION['refresh'] = 1;
1010 1081
             if (!empty($_REQUEST['parent_item_id'])) {
1011 1082
                 $_SESSION['from_learnpath']='yes';
@@ -1021,9 +1092,10 @@  discard block
 block discarded – undo
1021 1092
         if (!$is_allowed_to_edit) {
1022 1093
             api_not_allowed(true);
1023 1094
         }
1024
-        if ($debug > 0) error_log('New LP - delete item action triggered', 0);
1025
-        if (!$lp_found) { error_log('New LP - No learnpath given for delete item', 0); require 'lp_list.php'; }
1026
-        else {
1095
+        if ($debug > 0) {
1096
+            error_log('New LP - delete item action triggered', 0);
1097
+        }
1098
+        if (!$lp_found) { error_log('New LP - No learnpath given for delete item', 0); require 'lp_list.php'; } else {
1027 1099
             //$_SESSION['refresh'] = 1;
1028 1100
             if (!empty($_REQUEST['id'])) {
1029 1101
                 $_SESSION['oLP']->delete_item($_REQUEST['id']);
@@ -1038,9 +1110,10 @@  discard block
 block discarded – undo
1038 1110
         if (!$is_allowed_to_edit) {
1039 1111
             api_not_allowed(true);
1040 1112
         }
1041
-        if ($debug > 0) error_log('New LP - edit item prereq action triggered', 0);
1042
-        if (!$lp_found) { error_log('New LP - No learnpath given for edit item prereq', 0); require 'lp_list.php'; }
1043
-        else {
1113
+        if ($debug > 0) {
1114
+            error_log('New LP - edit item prereq action triggered', 0);
1115
+        }
1116
+        if (!$lp_found) { error_log('New LP - No learnpath given for edit item prereq', 0); require 'lp_list.php'; } else {
1044 1117
             if (!empty($_REQUEST['id']) && !empty($_REQUEST['submit_item'])) {
1045 1118
                 $_SESSION['refresh'] = 1;
1046 1119
                 $_SESSION['oLP']->edit_item_prereq($_REQUEST['id'], $_REQUEST['prereq']);
@@ -1049,53 +1122,61 @@  discard block
 block discarded – undo
1049 1122
         }
1050 1123
         break;
1051 1124
     case 'restart':
1052
-        if ($debug > 0) error_log('New LP - restart action triggered', 0);
1053
-        if (!$lp_found) { error_log('New LP - No learnpath given for restart', 0); require 'lp_list.php'; }
1054
-        else {
1125
+        if ($debug > 0) {
1126
+            error_log('New LP - restart action triggered', 0);
1127
+        }
1128
+        if (!$lp_found) { error_log('New LP - No learnpath given for restart', 0); require 'lp_list.php'; } else {
1055 1129
             $_SESSION['oLP']->restart();
1056 1130
             require 'lp_view.php';
1057 1131
         }
1058 1132
         break;
1059 1133
     case 'last':
1060
-        if ($debug > 0) error_log('New LP - last action triggered', 0);
1061
-        if (!$lp_found) { error_log('New LP - No learnpath given for last', 0); require 'lp_list.php'; }
1062
-        else {
1134
+        if ($debug > 0) {
1135
+            error_log('New LP - last action triggered', 0);
1136
+        }
1137
+        if (!$lp_found) { error_log('New LP - No learnpath given for last', 0); require 'lp_list.php'; } else {
1063 1138
             $_SESSION['oLP']->last();
1064 1139
             require 'lp_view.php';
1065 1140
         }
1066 1141
         break;
1067 1142
     case 'first':
1068
-        if ($debug > 0) error_log('New LP - first action triggered', 0);
1069
-        if (!$lp_found) { error_log('New LP - No learnpath given for first', 0); require 'lp_list.php'; }
1070
-        else {
1143
+        if ($debug > 0) {
1144
+            error_log('New LP - first action triggered', 0);
1145
+        }
1146
+        if (!$lp_found) { error_log('New LP - No learnpath given for first', 0); require 'lp_list.php'; } else {
1071 1147
             $_SESSION['oLP']->first();
1072 1148
             require 'lp_view.php';
1073 1149
         }
1074 1150
         break;
1075 1151
     case 'next':
1076
-        if ($debug > 0) error_log('New LP - next action triggered', 0);
1077
-        if (!$lp_found) { error_log('New LP - No learnpath given for next', 0); require 'lp_list.php'; }
1078
-        else {
1152
+        if ($debug > 0) {
1153
+            error_log('New LP - next action triggered', 0);
1154
+        }
1155
+        if (!$lp_found) { error_log('New LP - No learnpath given for next', 0); require 'lp_list.php'; } else {
1079 1156
             $_SESSION['oLP']->next();
1080 1157
             require 'lp_view.php';
1081 1158
         }
1082 1159
         break;
1083 1160
     case 'previous':
1084
-        if ($debug > 0) error_log('New LP - previous action triggered', 0);
1085
-        if (!$lp_found) { error_log('New LP - No learnpath given for previous', 0); require 'lp_list.php'; }
1086
-        else {
1161
+        if ($debug > 0) {
1162
+            error_log('New LP - previous action triggered', 0);
1163
+        }
1164
+        if (!$lp_found) { error_log('New LP - No learnpath given for previous', 0); require 'lp_list.php'; } else {
1087 1165
             $_SESSION['oLP']->previous();
1088 1166
             require 'lp_view.php';
1089 1167
         }
1090 1168
         break;
1091 1169
     case 'content':
1092
-        if ($debug > 0) error_log('New LP - content action triggered', 0);
1093
-        if ($debug > 0) error_log('New LP - Item id is '.intval($_GET['item_id']), 0);
1170
+        if ($debug > 0) {
1171
+            error_log('New LP - content action triggered', 0);
1172
+        }
1173
+        if ($debug > 0) {
1174
+            error_log('New LP - Item id is '.intval($_GET['item_id']), 0);
1175
+        }
1094 1176
         if (!$lp_found) {
1095 1177
             error_log('New LP - No learnpath given for content', 0);
1096 1178
             require 'lp_list.php';
1097
-        }
1098
-        else {
1179
+        } else {
1099 1180
             $_SESSION['oLP']->save_last();
1100 1181
             $_SESSION['oLP']->set_current_item($_GET['item_id']);
1101 1182
             $_SESSION['oLP']->start_current_item();
@@ -1103,8 +1184,9 @@  discard block
 block discarded – undo
1103 1184
         }
1104 1185
         break;
1105 1186
     case 'view':
1106
-        if ($debug > 0)
1107
-            error_log('New LP - view action triggered', 0);
1187
+        if ($debug > 0) {
1188
+                    error_log('New LP - view action triggered', 0);
1189
+        }
1108 1190
         if (!$lp_found) {
1109 1191
             error_log('New LP - No learnpath given for view', 0);
1110 1192
             require 'lp_list.php';
@@ -1117,17 +1199,19 @@  discard block
 block discarded – undo
1117 1199
         }
1118 1200
         break;
1119 1201
     case 'save':
1120
-        if ($debug > 0) error_log('New LP - save action triggered', 0);
1121
-        if (!$lp_found) { error_log('New LP - No learnpath given for save', 0); require 'lp_list.php'; }
1122
-        else {
1202
+        if ($debug > 0) {
1203
+            error_log('New LP - save action triggered', 0);
1204
+        }
1205
+        if (!$lp_found) { error_log('New LP - No learnpath given for save', 0); require 'lp_list.php'; } else {
1123 1206
             $_SESSION['oLP']->save_item();
1124 1207
             require 'lp_save.php';
1125 1208
         }
1126 1209
         break;
1127 1210
     case 'stats':
1128
-        if ($debug > 0) error_log('New LP - stats action triggered', 0);
1129
-        if (!$lp_found) { error_log('New LP - No learnpath given for stats', 0); require 'lp_list.php'; }
1130
-        else {
1211
+        if ($debug > 0) {
1212
+            error_log('New LP - stats action triggered', 0);
1213
+        }
1214
+        if (!$lp_found) { error_log('New LP - No learnpath given for stats', 0); require 'lp_list.php'; } else {
1131 1215
             $_SESSION['oLP']->save_current();
1132 1216
             $_SESSION['oLP']->save_last();
1133 1217
             $output = require 'lp_stats.php';
@@ -1135,7 +1219,9 @@  discard block
 block discarded – undo
1135 1219
         }
1136 1220
         break;
1137 1221
     case 'list':
1138
-        if ($debug > 0) error_log('New LP - list action triggered', 0);
1222
+        if ($debug > 0) {
1223
+            error_log('New LP - list action triggered', 0);
1224
+        }
1139 1225
         if ($lp_found) {
1140 1226
             $_SESSION['refresh'] = 1;
1141 1227
             $_SESSION['oLP']->save_last();
@@ -1144,7 +1230,9 @@  discard block
 block discarded – undo
1144 1230
         break;
1145 1231
     case 'mode':
1146 1232
         // Switch between fullscreen and embedded mode.
1147
-        if ($debug > 0) error_log('New LP - mode change triggered', 0);
1233
+        if ($debug > 0) {
1234
+            error_log('New LP - mode change triggered', 0);
1235
+        }
1148 1236
         $mode = $_REQUEST['mode'];
1149 1237
         if ($mode == 'fullscreen') {
1150 1238
             $_SESSION['oLP']->mode = 'fullscreen';
@@ -1158,7 +1246,9 @@  discard block
 block discarded – undo
1158 1246
         require 'lp_view.php';
1159 1247
         break;
1160 1248
     case 'switch_view_mode':
1161
-        if ($debug > 0) error_log('New LP - switch_view_mode action triggered', 0);
1249
+        if ($debug > 0) {
1250
+            error_log('New LP - switch_view_mode action triggered', 0);
1251
+        }
1162 1252
         if (!$lp_found) { error_log('New LP - No learnpath given for switch', 0); require 'lp_list.php'; }
1163 1253
         if (Security::check_token('get')) {
1164 1254
             $_SESSION['refresh'] = 1;
@@ -1167,7 +1257,9 @@  discard block
 block discarded – undo
1167 1257
         require 'lp_list.php';
1168 1258
         break;
1169 1259
     case 'switch_force_commit':
1170
-        if ($debug > 0) error_log('New LP - switch_force_commit action triggered', 0);
1260
+        if ($debug > 0) {
1261
+            error_log('New LP - switch_force_commit action triggered', 0);
1262
+        }
1171 1263
         if (!$lp_found) { error_log('New LP - No learnpath given for switch', 0); require 'lp_list.php'; }
1172 1264
         $_SESSION['refresh'] = 1;
1173 1265
         $_SESSION['oLP']->update_default_scorm_commit();
@@ -1190,25 +1282,33 @@  discard block
 block discarded – undo
1190 1282
 		break;
1191 1283
      */
1192 1284
 	case 'switch_attempt_mode':
1193
-		if($debug>0) error_log('New LP - switch_reinit action triggered',0);
1285
+		if($debug>0) {
1286
+		    error_log('New LP - switch_reinit action triggered',0);
1287
+		}
1194 1288
 		if(!$lp_found){ error_log('New LP - No learnpath given for switch',0); require 'lp_list.php'; }
1195 1289
 		$_SESSION['refresh'] = 1;
1196 1290
 		$_SESSION['oLP']->switch_attempt_mode();
1197 1291
         require 'lp_list.php';
1198 1292
         break;
1199 1293
     case 'switch_scorm_debug':
1200
-        if ($debug > 0) error_log('New LP - switch_scorm_debug action triggered', 0);
1294
+        if ($debug > 0) {
1295
+            error_log('New LP - switch_scorm_debug action triggered', 0);
1296
+        }
1201 1297
         if (!$lp_found) { error_log('New LP - No learnpath given for switch', 0); require 'lp_list.php'; }
1202 1298
         $_SESSION['refresh'] = 1;
1203 1299
         $_SESSION['oLP']->update_scorm_debug();
1204 1300
         require 'lp_list.php';
1205 1301
         break;
1206 1302
     case 'intro_cmdAdd':
1207
-        if ($debug > 0) error_log('New LP - intro_cmdAdd action triggered', 0);
1303
+        if ($debug > 0) {
1304
+            error_log('New LP - intro_cmdAdd action triggered', 0);
1305
+        }
1208 1306
         // Add introduction section page.
1209 1307
         break;
1210 1308
     case 'js_api_refresh':
1211
-        if ($debug > 0) error_log('New LP - js_api_refresh action triggered', 0);
1309
+        if ($debug > 0) {
1310
+            error_log('New LP - js_api_refresh action triggered', 0);
1311
+        }
1212 1312
         if (!$lp_found) { error_log('New LP - No learnpath given for js_api_refresh', 0); require 'lp_message.php'; }
1213 1313
         if (isset($_REQUEST['item_id'])) {
1214 1314
             $htmlHeadXtra[] = $_SESSION['oLP']->get_js_info($_REQUEST['item_id']);
@@ -1216,8 +1316,7 @@  discard block
 block discarded – undo
1216 1316
         require 'lp_message.php';
1217 1317
         break;
1218 1318
     case 'return_to_course_homepage':
1219
-        if (!$lp_found) { error_log('New LP - No learnpath given for stats', 0); require 'lp_list.php'; }
1220
-        else {
1319
+        if (!$lp_found) { error_log('New LP - No learnpath given for stats', 0); require 'lp_list.php'; } else {
1221 1320
             $_SESSION['oLP']->save_current();
1222 1321
             $_SESSION['oLP']->save_last();
1223 1322
             $url = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/index.php?id_session='.api_get_session_id();
@@ -1235,8 +1334,9 @@  discard block
 block discarded – undo
1235 1334
         require 'lp_list_search.php';
1236 1335
         break;
1237 1336
     case 'impress':
1238
-        if ($debug > 0)
1239
-            error_log('New LP - view action triggered', 0);
1337
+        if ($debug > 0) {
1338
+                    error_log('New LP - view action triggered', 0);
1339
+        }
1240 1340
         if (!$lp_found) {
1241 1341
             error_log('New LP - No learnpath given for view', 0);
1242 1342
             require 'lp_list.php';
@@ -1386,12 +1486,16 @@  discard block
 block discarded – undo
1386 1486
         ]));
1387 1487
         break;
1388 1488
     default:
1389
-        if ($debug > 0) error_log('New LP - default action triggered', 0);
1489
+        if ($debug > 0) {
1490
+            error_log('New LP - default action triggered', 0);
1491
+        }
1390 1492
         require 'lp_list.php';
1391 1493
         break;
1392 1494
 }
1393 1495
 
1394 1496
 if (!empty($_SESSION['oLP'])) {
1395 1497
     $_SESSION['lpobject'] = serialize($_SESSION['oLP']);
1396
-    if ($debug > 0) error_log('New LP - lpobject is serialized in session', 0);
1397
-}
1498
+    if ($debug > 0) {
1499
+        error_log('New LP - lpobject is serialized in session', 0);
1500
+    }
1501
+    }
Please login to merge, or discard this patch.