Completed
Pull Request — 1.11.x (#1285)
by José
66:28 queued 22:09
created
main/lp/learnpath.class.php 1 patch
Braces   +104 added lines, -71 removed lines patch added patch discarded remove patch
@@ -3944,8 +3944,9 @@  discard block
 block discarded – undo
3944 3944
                 WHERE c_id = ".$course_id."
3945 3945
                 ORDER BY display_order";
3946 3946
         $res = Database::query($sql);
3947
-        if ($res === false)
3948
-            return false;
3947
+        if ($res === false) {
3948
+                    return false;
3949
+        }
3949 3950
         $lps = array ();
3950 3951
         $lp_order = array ();
3951 3952
         $num = Database :: num_rows($res);
@@ -4545,8 +4546,9 @@  discard block
 block discarded – undo
4545 4546
         if ($this->debug > 0) {
4546 4547
             error_log('New LP - In learnpath::set_maker()', 0);
4547 4548
         }
4548
-        if (empty ($name))
4549
-            return false;
4549
+        if (empty ($name)) {
4550
+                    return false;
4551
+        }
4550 4552
         $this->maker = $name;
4551 4553
         $lp_table = Database :: get_course_table(TABLE_LP_MAIN);
4552 4554
         $course_id = api_get_course_int_id();
@@ -4611,8 +4613,9 @@  discard block
 block discarded – undo
4611 4613
     public function set_terms_by_prefix($terms_string, $prefix)
4612 4614
     {
4613 4615
         $course_id = api_get_course_int_id();
4614
-        if (api_get_setting('search_enabled') !== 'true')
4615
-            return false;
4616
+        if (api_get_setting('search_enabled') !== 'true') {
4617
+                    return false;
4618
+        }
4616 4619
 
4617 4620
         if (!extension_loaded('xapian')) {
4618 4621
             return false;
@@ -4625,8 +4628,9 @@  discard block
 block discarded – undo
4625 4628
         $stored_terms = $this->get_common_index_terms_by_prefix($prefix);
4626 4629
 
4627 4630
         // Don't do anything if no change, verify only at DB, not the search engine.
4628
-        if ((count(array_diff($terms, $stored_terms)) == 0) && (count(array_diff($stored_terms, $terms)) == 0))
4629
-            return false;
4631
+        if ((count(array_diff($terms, $stored_terms)) == 0) && (count(array_diff($stored_terms, $terms)) == 0)) {
4632
+                    return false;
4633
+        }
4630 4634
 
4631 4635
         require_once 'xapian.php'; // TODO: Try catch every xapian use or make wrappers on API.
4632 4636
         require_once api_get_path(LIBRARY_PATH).'search/ChamiloIndexer.class.php';
@@ -4818,8 +4822,9 @@  discard block
 block discarded – undo
4818 4822
         if ($this->debug > 0) {
4819 4823
             error_log('New LP - In learnpath::set_proximity()', 0);
4820 4824
         }
4821
-        if (empty ($name))
4822
-            return false;
4825
+        if (empty ($name)) {
4826
+                    return false;
4827
+        }
4823 4828
 
4824 4829
         $this->proximity = $name;
4825 4830
         $lp_table = Database :: get_course_table(TABLE_LP_MAIN);
@@ -5163,8 +5168,9 @@  discard block
 block discarded – undo
5163 5168
 
5164 5169
         $sql = "SELECT * FROM $lp_table WHERE c_id = ".$course_id." ORDER BY display_order";
5165 5170
         $res = Database::query($sql);
5166
-        if ($res === false)
5167
-            return false;
5171
+        if ($res === false) {
5172
+                    return false;
5173
+        }
5168 5174
 
5169 5175
         $num = Database :: num_rows($res);
5170 5176
         // First check the order is correct, globally (might be wrong because
@@ -5475,8 +5481,9 @@  discard block
 block discarded – undo
5475 5481
             $position[$key] = $row['display_order'];
5476 5482
         }
5477 5483
 
5478
-        if (count($array) > 0)
5479
-            array_multisort($parent, SORT_ASC, $position, SORT_ASC, $array);
5484
+        if (count($array) > 0) {
5485
+                    array_multisort($parent, SORT_ASC, $position, SORT_ASC, $array);
5486
+        }
5480 5487
 
5481 5488
         return $array;
5482 5489
     }
@@ -6190,10 +6197,12 @@  discard block
 block discarded – undo
6190 6197
                     if ($new_comment || $new_title) {
6191 6198
                         $tbl_doc = Database :: get_course_table(TABLE_DOCUMENT);
6192 6199
                         $ct = '';
6193
-                        if ($new_comment)
6194
-                            $ct .= ", comment='" . Database::escape_string($new_comment). "'";
6195
-                        if ($new_title)
6196
-                            $ct .= ", title='" . Database::escape_string($new_title)."' ";
6200
+                        if ($new_comment) {
6201
+                                                    $ct .= ", comment='" . Database::escape_string($new_comment). "'";
6202
+                        }
6203
+                        if ($new_title) {
6204
+                                                    $ct .= ", title='" . Database::escape_string($new_title)."' ";
6205
+                        }
6197 6206
 
6198 6207
                         $sql = "UPDATE " . $tbl_doc ." SET " . substr($ct, 1)."
6199 6208
                                WHERE c_id = ".$course_id." AND id = " . $document_id;
@@ -6217,17 +6226,21 @@  discard block
 block discarded – undo
6217 6226
         // Please, do not modify this dirname formatting.
6218 6227
         $dir = isset($_GET['dir']) ? $_GET['dir'] : $_POST['dir'];
6219 6228
 
6220
-        if (strstr($dir, '..'))
6221
-            $dir = '/';
6229
+        if (strstr($dir, '..')) {
6230
+                    $dir = '/';
6231
+        }
6222 6232
 
6223
-        if ($dir[0] == '.')
6224
-            $dir = substr($dir, 1);
6233
+        if ($dir[0] == '.') {
6234
+                    $dir = substr($dir, 1);
6235
+        }
6225 6236
 
6226
-        if ($dir[0] != '/')
6227
-            $dir = '/' . $dir;
6237
+        if ($dir[0] != '/') {
6238
+                    $dir = '/' . $dir;
6239
+        }
6228 6240
 
6229
-        if ($dir[strlen($dir) - 1] != '/')
6230
-            $dir .= '/';
6241
+        if ($dir[strlen($dir) - 1] != '/') {
6242
+                    $dir .= '/';
6243
+        }
6231 6244
 
6232 6245
         $filepath = api_get_path(SYS_COURSE_PATH) . $_course['path'] . '/document' . $dir;
6233 6246
 
@@ -6292,8 +6305,9 @@  discard block
 block discarded – undo
6292 6305
                 }
6293 6306
                 $return .= '<div style="padding:10px;">';
6294 6307
 
6295
-                if ($msg != '')
6296
-                    $return .= $msg;
6308
+                if ($msg != '') {
6309
+                                    $return .= $msg;
6310
+                }
6297 6311
 
6298 6312
                 $return .= '<h3>'.$row['title'].'</h3>';
6299 6313
                 switch ($row['item_type']) {
@@ -6554,10 +6568,11 @@  discard block
 block discarded – undo
6554 6568
         $item_title			= Security::remove_XSS($item_title);
6555 6569
         $item_description 	= Security::remove_XSS($item_description);
6556 6570
 
6557
-        if ($id != 0 && is_array($extra_info))
6558
-            $parent = $extra_info['parent_item_id'];
6559
-        else
6560
-            $parent = 0;
6571
+        if ($id != 0 && is_array($extra_info)) {
6572
+                    $parent = $extra_info['parent_item_id'];
6573
+        } else {
6574
+                    $parent = 0;
6575
+        }
6561 6576
 
6562 6577
         $sql = "SELECT * FROM " . $tbl_lp_item . "
6563 6578
                 WHERE c_id = ".$course_id." AND lp_id = " . $this->lp_id;
@@ -6822,11 +6837,13 @@  discard block
 block discarded – undo
6822 6837
         }
6823 6838
 
6824 6839
         $legend = '<legend>';
6825
-        if ($action == 'add')
6826
-            $legend .= get_lang('CreateTheExercise');
6827
-        elseif ($action == 'move') $legend .= get_lang('MoveTheCurrentExercise');
6828
-        else
6829
-            $legend .= get_lang('EditCurrentExecice');
6840
+        if ($action == 'add') {
6841
+                    $legend .= get_lang('CreateTheExercise');
6842
+        } elseif ($action == 'move') {
6843
+            $legend .= get_lang('MoveTheCurrentExercise');
6844
+        } else {
6845
+                    $legend .= get_lang('EditCurrentExecice');
6846
+        }
6830 6847
         if (isset ($_GET['edit']) && $_GET['edit'] == 'true') {
6831 6848
             $legend .= Display :: return_warning_message(get_lang('Warning') . ' ! ' . get_lang('WarningEditingDocument'));
6832 6849
         }
@@ -6853,8 +6870,9 @@  discard block
 block discarded – undo
6853 6870
                         $arrHide[] = $arrLP[$i]['id'];
6854 6871
                     }
6855 6872
                 } else {
6856
-                    if ($arrLP[$i]['item_type'] == 'dir')
6857
-                        $return .= '<option ' . (($parent == $arrLP[$i]['id']) ? 'selected="selected" ' : '') . 'style="padding-left:' . ($arrLP[$i]['depth'] * 10) . 'px;" value="' . $arrLP[$i]['id'] . '">' . $arrLP[$i]['title'] . '</option>';
6873
+                    if ($arrLP[$i]['item_type'] == 'dir') {
6874
+                                            $return .= '<option ' . (($parent == $arrLP[$i]['id']) ? 'selected="selected" ' : '') . 'style="padding-left:' . ($arrLP[$i]['depth'] * 10) . 'px;" value="' . $arrLP[$i]['id'] . '">' . $arrLP[$i]['title'] . '</option>';
6875
+                    }
6858 6876
                 }
6859 6877
             }
6860 6878
 
@@ -6872,11 +6890,13 @@  discard block
 block discarded – undo
6872 6890
 
6873 6891
         for ($i = 0; $i < count($arrLP); $i++) {
6874 6892
             if ($arrLP[$i]['parent_item_id'] == $parent && $arrLP[$i]['id'] != $id) {
6875
-                if ($extra_info['previous_item_id'] == $arrLP[$i]['id'])
6893
+                if ($extra_info['previous_item_id'] == $arrLP[$i]['id']) {
6894
+                                    $selected = 'selected="selected" ';
6895
+                } elseif ($action == 'add') {
6876 6896
                     $selected = 'selected="selected" ';
6877
-                elseif ($action == 'add') $selected = 'selected="selected" ';
6878
-                else
6879
-                    $selected = '';
6897
+                } else {
6898
+                                    $selected = '';
6899
+                }
6880 6900
 
6881 6901
                 $return .= '<option ' . $selected . 'value="' . $arrLP[$i]['id'] . '">' . get_lang('After') . ' "' . $arrLP[$i]['title'] . '"</option>';
6882 6902
             }
@@ -6903,9 +6923,11 @@  discard block
 block discarded – undo
6903 6923
                 $arrHide = array ();
6904 6924
                 for ($i = 0; $i < count($arrLP); $i++) {
6905 6925
                     if ($arrLP[$i]['id'] != $id && $arrLP[$i]['item_type'] != 'dir') {
6906
-                        if ($extra_info['previous_item_id'] == $arrLP[$i]['id'])
6907
-                            $s_selected_position = $arrLP[$i]['id'];
6908
-                        elseif ($action == 'add') $s_selected_position = 0;
6926
+                        if ($extra_info['previous_item_id'] == $arrLP[$i]['id']) {
6927
+                                                    $s_selected_position = $arrLP[$i]['id'];
6928
+                        } elseif ($action == 'add') {
6929
+                            $s_selected_position = 0;
6930
+                        }
6909 6931
                         $arrHide[$arrLP[$i]['id']]['value'] = $arrLP[$i]['title'];
6910 6932
 
6911 6933
                     }
@@ -7098,9 +7120,11 @@  discard block
 block discarded – undo
7098 7120
             $arrHide = array();
7099 7121
             for ($i = 0; $i < count($arrLP); $i++) {
7100 7122
                 if ($arrLP[$i]['id'] != $id && $arrLP[$i]['item_type'] != 'dir') {
7101
-                    if (isset($extra_info['previous_item_id']) && $extra_info['previous_item_id'] == $arrLP[$i]['id'])
7102
-                        $s_selected_position = $arrLP[$i]['id'];
7103
-                    elseif ($action == 'add') $s_selected_position = 0;
7123
+                    if (isset($extra_info['previous_item_id']) && $extra_info['previous_item_id'] == $arrLP[$i]['id']) {
7124
+                                            $s_selected_position = $arrLP[$i]['id'];
7125
+                    } elseif ($action == 'add') {
7126
+                        $s_selected_position = 0;
7127
+                    }
7104 7128
                     $arrHide[$arrLP[$i]['id']]['value'] = $arrLP[$i]['title'];
7105 7129
                 }
7106 7130
             }
@@ -7295,9 +7319,11 @@  discard block
 block discarded – undo
7295 7319
 
7296 7320
             for ($i = 0; $i < count($arrLP); $i++) {
7297 7321
                 if ($arrLP[$i]['id'] != $id && $arrLP[$i]['item_type'] != 'dir') {
7298
-                    if ($extra_info['previous_item_id'] == $arrLP[$i]['id'])
7299
-                        $s_selected_position = $arrLP[$i]['id'];
7300
-                    elseif ($action == 'add') $s_selected_position = 0;
7322
+                    if ($extra_info['previous_item_id'] == $arrLP[$i]['id']) {
7323
+                                            $s_selected_position = $arrLP[$i]['id'];
7324
+                    } elseif ($action == 'add') {
7325
+                        $s_selected_position = 0;
7326
+                    }
7301 7327
                     $arrHide[$arrLP[$i]['id']]['value'] = $arrLP[$i]['title'];
7302 7328
 
7303 7329
                 }
@@ -7331,8 +7357,7 @@  discard block
 block discarded – undo
7331 7357
 
7332 7358
         if (is_numeric($extra_info)) {
7333 7359
             $form->addHidden('path', $extra_info);
7334
-        }
7335
-        elseif (is_array($extra_info)) {
7360
+        } elseif (is_array($extra_info)) {
7336 7361
             $form->addHidden('path', $extra_info['path']);
7337 7362
         }
7338 7363
 
@@ -7385,8 +7410,9 @@  discard block
 block discarded – undo
7385 7410
                     lp_id = " . $this->lp_id . " AND
7386 7411
                     id != $id";
7387 7412
 
7388
-        if ($item_type == 'dir')
7389
-            $sql .= " AND parent_item_id = 0";
7413
+        if ($item_type == 'dir') {
7414
+                    $sql .= " AND parent_item_id = 0";
7415
+        }
7390 7416
 
7391 7417
         $result = Database::query($sql);
7392 7418
         $arrLP = array ();
@@ -7787,9 +7813,11 @@  discard block
 block discarded – undo
7787 7813
             $arrHide = array();
7788 7814
             for ($i = 0; $i < count($arrLP); $i++) {
7789 7815
                 if ($arrLP[$i]['id'] != $id && $arrLP[$i]['item_type'] != 'dir' && $arrLP[$i]['item_type'] !== TOOL_LP_FINAL_ITEM) {
7790
-                    if (isset($extra_info['previous_item_id']) && $extra_info['previous_item_id'] == $arrLP[$i]['id'])
7816
+                    if (isset($extra_info['previous_item_id']) && $extra_info['previous_item_id'] == $arrLP[$i]['id']) {
7817
+                                            $s_selected_position = $arrLP[$i]['id'];
7818
+                    } elseif ($action == 'add') {
7791 7819
                         $s_selected_position = $arrLP[$i]['id'];
7792
-                    elseif ($action == 'add') $s_selected_position = $arrLP[$i]['id'];
7820
+                    }
7793 7821
 
7794 7822
                     $arrHide[$arrLP[$i]['id']]['value'] = $arrLP[$i]['title'];
7795 7823
 
@@ -7800,17 +7828,18 @@  discard block
 block discarded – undo
7800 7828
                 $item_type = isset($extra_info['item_type']) ? $extra_info['item_type'] : null;
7801 7829
                 $edit = isset($_GET['edit']) ? $_GET['edit'] : null;
7802 7830
                 if (($extra_info == 'new' || $item_type == TOOL_DOCUMENT || $item_type == TOOL_LP_FINAL_ITEM || $edit == 'true')) {
7803
-                    if (isset ($_POST['content']))
7804
-                        $content = stripslashes($_POST['content']);
7805
-                    elseif (is_array($extra_info)) {
7831
+                    if (isset ($_POST['content'])) {
7832
+                                            $content = stripslashes($_POST['content']);
7833
+                    } elseif (is_array($extra_info)) {
7806 7834
                         //If it's an html document or a text file
7807 7835
                         if (!$no_display_edit_textarea) {
7808 7836
                             $content = $this->display_document($extra_info['path'], false, false);
7809 7837
                         }
7810
-                    } elseif (is_numeric($extra_info))
7811
-                        $content = $this->display_document($extra_info, false, false);
7812
-                    else
7813
-                        $content = '';
7838
+                    } elseif (is_numeric($extra_info)) {
7839
+                                            $content = $this->display_document($extra_info, false, false);
7840
+                    } else {
7841
+                                            $content = '';
7842
+                    }
7814 7843
 
7815 7844
                     if (!$no_display_edit_textarea) {
7816 7845
                         // We need to calculate here some specific settings for the online editor.
@@ -8074,9 +8103,11 @@  discard block
 block discarded – undo
8074 8103
             $arrHide = array();
8075 8104
             for ($i = 0; $i < count($arrLP); $i++) {
8076 8105
                 if ($arrLP[$i]['id'] != $id && $arrLP[$i]['item_type'] != 'dir') {
8077
-                    if ($extra_info['previous_item_id'] == $arrLP[$i]['id'])
8078
-                        $s_selected_position = $arrLP[$i]['id'];
8079
-                    elseif ($action == 'add') $s_selected_position = 0;
8106
+                    if ($extra_info['previous_item_id'] == $arrLP[$i]['id']) {
8107
+                                            $s_selected_position = $arrLP[$i]['id'];
8108
+                    } elseif ($action == 'add') {
8109
+                        $s_selected_position = 0;
8110
+                    }
8080 8111
                     $arrHide[$arrLP[$i]['id']]['value'] = $arrLP[$i]['title'];
8081 8112
 
8082 8113
                 }
@@ -8272,9 +8303,11 @@  discard block
 block discarded – undo
8272 8303
             $arrHide = array ();
8273 8304
             for ($i = 0; $i < count($arrLP); $i++) {
8274 8305
                 if ($arrLP[$i]['id'] != $id && $arrLP[$i]['item_type'] != 'dir') {
8275
-                    if ($extra_info['previous_item_id'] == $arrLP[$i]['id'])
8276
-                        $s_selected_position = $arrLP[$i]['id'];
8277
-                    elseif ($action == 'add') $s_selected_position = 0;
8306
+                    if ($extra_info['previous_item_id'] == $arrLP[$i]['id']) {
8307
+                                            $s_selected_position = $arrLP[$i]['id'];
8308
+                    } elseif ($action == 'add') {
8309
+                        $s_selected_position = 0;
8310
+                    }
8278 8311
                     $arrHide[$arrLP[$i]['id']]['value'] = $arrLP[$i]['title'];
8279 8312
 
8280 8313
                 }
Please login to merge, or discard this patch.
main/ticket/tickets.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -138,8 +138,8 @@  discard block
 block discarded – undo
138 138
 $isAdmin = api_is_platform_admin();
139 139
 
140 140
 Display::display_header(get_lang('MyTickets'));
141
-if (!empty($projectId))
142
-if ($isAdmin ) {
141
+if (!empty($projectId)) {
142
+    if ($isAdmin ) {
143 143
     $getParameters = [
144 144
         'keyword',
145 145
         'keyword_status',
@@ -151,6 +151,7 @@  discard block
 block discarded – undo
151 151
         'Tickets_per_page',
152 152
         'Tickets_column'
153 153
     ];
154
+}
154 155
     $get_parameter = '';
155 156
     foreach ($getParameters as $getParameter) {
156 157
         if (isset($_GET[$getParameter])) {
Please login to merge, or discard this patch.
main/lp/lp_controller.php 1 patch
Braces   +226 added lines, -113 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
 
@@ -372,11 +408,15 @@  discard block
 block discarded – undo
372 408
         if (!$is_allowed_to_edit) {
373 409
             api_not_allowed(true);
374 410
         }
375
-        if ($debug > 0) error_log('New LP - add item action triggered', 0);
411
+        if ($debug > 0) {
412
+            error_log('New LP - add item action triggered', 0);
413
+        }
376 414
 
377 415
         if (!$lp_found) {
378 416
             //check if the learnpath ID was defined, otherwise send back to list
379
-            if ($debug > 0) error_log('New LP - No learnpath given for add item', 0);
417
+            if ($debug > 0) {
418
+                error_log('New LP - No learnpath given for add item', 0);
419
+            }
380 420
             require 'lp_list.php';
381 421
         } else {
382 422
             $_SESSION['refresh'] = 1;
@@ -465,11 +505,15 @@  discard block
 block discarded – undo
465 505
             api_not_allowed(true);
466 506
         }
467 507
 
468
-        if ($debug > 0) error_log('New LP - add audio action triggered', 0);
508
+        if ($debug > 0) {
509
+            error_log('New LP - add audio action triggered', 0);
510
+        }
469 511
 
470 512
         if (!$lp_found) {
471 513
             //check if the learnpath ID was defined, otherwise send back to list
472
-            if ($debug > 0) error_log('New LP - No learnpath given for add audio', 0);
514
+            if ($debug > 0) {
515
+                error_log('New LP - No learnpath given for add audio', 0);
516
+            }
473 517
             require 'lp_list.php';
474 518
         } else {
475 519
             $_SESSION['refresh'] = 1;
@@ -543,7 +587,9 @@  discard block
 block discarded – undo
543 587
         if (!$is_allowed_to_edit) {
544 588
             api_not_allowed(true);
545 589
         }
546
-        if ($debug > 0) error_log('New LP - add_lp action triggered', 0);
590
+        if ($debug > 0) {
591
+            error_log('New LP - add_lp action triggered', 0);
592
+        }
547 593
         if (isset($_REQUEST['lp_name']) && !empty($_REQUEST['lp_name'])) {
548 594
             $_REQUEST['lp_name'] = trim($_REQUEST['lp_name']);
549 595
             $_SESSION['refresh'] = 1;
@@ -602,7 +648,9 @@  discard block
 block discarded – undo
602 648
         if (!$is_allowed_to_edit) {
603 649
             api_not_allowed(true);
604 650
         }
605
-        if ($debug > 0) error_log('New LP - admin_view action triggered', 0);
651
+        if ($debug > 0) {
652
+            error_log('New LP - admin_view action triggered', 0);
653
+        }
606 654
         if (!$lp_found) {
607 655
             error_log('New LP - No learnpath given for admin_view', 0);
608 656
             require 'lp_list.php';
@@ -616,9 +664,10 @@  discard block
 block discarded – undo
616 664
             if (!$is_allowed_to_edit) {
617 665
                 api_not_allowed(true);
618 666
             }
619
-            if ($debug > 0) error_log('New LP - auto_launch action triggered', 0);
620
-            if (!$lp_found) { error_log('New LP - No learnpath given for set_autolaunch', 0); require 'lp_list.php'; }
621
-            else {
667
+            if ($debug > 0) {
668
+                error_log('New LP - auto_launch action triggered', 0);
669
+            }
670
+            if (!$lp_found) { error_log('New LP - No learnpath given for set_autolaunch', 0); require 'lp_list.php'; } else {
622 671
                 $_SESSION['oLP']->set_autolaunch($_GET['lp_id'], $_GET['status']);
623 672
                 require 'lp_list.php';
624 673
                 exit;
@@ -629,10 +678,11 @@  discard block
 block discarded – undo
629 678
         if (!$is_allowed_to_edit) {
630 679
             api_not_allowed(true);
631 680
         }
632
-        if ($debug > 0) error_log('New LP - build action triggered', 0);
681
+        if ($debug > 0) {
682
+            error_log('New LP - build action triggered', 0);
683
+        }
633 684
 
634
-        if (!$lp_found) { error_log('New LP - No learnpath given for build', 0); require 'lp_list.php'; }
635
-        else {
685
+        if (!$lp_found) { error_log('New LP - No learnpath given for build', 0); require 'lp_list.php'; } else {
636 686
             $_SESSION['refresh'] = 1;
637 687
             //require 'lp_build.php';
638 688
             $url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_SESSION['oLP']->lp_id).'&'.api_get_cidreq();
@@ -644,7 +694,9 @@  discard block
 block discarded – undo
644 694
         if (!$is_allowed_to_edit) {
645 695
             api_not_allowed(true);
646 696
         }
647
-        if ($debug > 0) error_log('New LP - edit item action triggered', 0);
697
+        if ($debug > 0) {
698
+            error_log('New LP - edit item action triggered', 0);
699
+        }
648 700
 
649 701
         if (!$lp_found) {
650 702
             error_log('New LP - No learnpath given for edit item', 0);
@@ -699,9 +751,10 @@  discard block
 block discarded – undo
699 751
         if (!$is_allowed_to_edit) {
700 752
             api_not_allowed(true);
701 753
         }
702
-        if ($debug > 0) error_log('New LP - edit item prereq action triggered', 0);
703
-        if (!$lp_found) { error_log('New LP - No learnpath given for edit item prereq', 0); require 'lp_list.php'; }
704
-        else {
754
+        if ($debug > 0) {
755
+            error_log('New LP - edit item prereq action triggered', 0);
756
+        }
757
+        if (!$lp_found) { error_log('New LP - No learnpath given for edit item prereq', 0); require 'lp_list.php'; } else {
705 758
             if (isset($_POST['submit_button'])) {
706 759
                 //Updating the lp.modified_on
707 760
                 $_SESSION['oLP']->set_modified_on();
@@ -729,9 +782,10 @@  discard block
 block discarded – undo
729 782
         if (!$is_allowed_to_edit) {
730 783
             api_not_allowed(true);
731 784
         }
732
-        if ($debug > 0) error_log('New LP - move item action triggered', 0);
733
-        if (!$lp_found) { error_log('New LP - No learnpath given for move item', 0); require 'lp_list.php'; }
734
-        else {
785
+        if ($debug > 0) {
786
+            error_log('New LP - move item action triggered', 0);
787
+        }
788
+        if (!$lp_found) { error_log('New LP - No learnpath given for move item', 0); require 'lp_list.php'; } else {
735 789
             $_SESSION['refresh'] = 1;
736 790
             if (isset($_POST['submit_button'])) {
737 791
                 //Updating the lp.modified_on
@@ -764,7 +818,9 @@  discard block
 block discarded – undo
764 818
         if (!$is_allowed_to_edit) {
765 819
             api_not_allowed(true);
766 820
         }
767
-        if ($debug > 0) error_log('New LP - view_item action triggered', 0);
821
+        if ($debug > 0) {
822
+            error_log('New LP - view_item action triggered', 0);
823
+        }
768 824
         if (!$lp_found) {
769 825
             error_log('New LP - No learnpath given for view item', 0); require 'lp_list.php';
770 826
         } else {
@@ -776,7 +832,9 @@  discard block
 block discarded – undo
776 832
         if (!$is_allowed_to_edit) {
777 833
             api_not_allowed(true);
778 834
         }
779
-        if ($debug > 0) error_log('New LP - upload action triggered', 0);
835
+        if ($debug > 0) {
836
+            error_log('New LP - upload action triggered', 0);
837
+        }
780 838
         $cwdir = getcwd();
781 839
         require 'lp_upload.php';
782 840
         // Reinit current working directory as many functions in upload change it.
@@ -793,9 +851,10 @@  discard block
 block discarded – undo
793 851
             api_not_allowed(true);
794 852
         }
795 853
 
796
-        if ($debug > 0) error_log('New LP - export action triggered', 0);
797
-        if (!$lp_found) { error_log('New LP - No learnpath given for copy', 0); require 'lp_list.php'; }
798
-        else {
854
+        if ($debug > 0) {
855
+            error_log('New LP - export action triggered', 0);
856
+        }
857
+        if (!$lp_found) { error_log('New LP - No learnpath given for copy', 0); require 'lp_list.php'; } else {
799 858
             $_SESSION['oLP']->copy();
800 859
         }
801 860
         require 'lp_list.php';
@@ -828,7 +887,9 @@  discard block
 block discarded – undo
828 887
             api_not_allowed(true);
829 888
         }
830 889
 
831
-        if ($debug > 0) error_log('New LP - export action triggered', 0);
890
+        if ($debug > 0) {
891
+            error_log('New LP - export action triggered', 0);
892
+        }
832 893
         if (!$lp_found) { error_log('New LP - No learnpath given for export_to_pdf', 0); require 'lp_list.php';
833 894
         } else {
834 895
             $result = $_SESSION['oLP']->scorm_export_to_pdf($_GET['lp_id']);
@@ -842,9 +903,10 @@  discard block
 block discarded – undo
842 903
         if (!$is_allowed_to_edit) {
843 904
             api_not_allowed(true);
844 905
         }
845
-        if ($debug > 0) error_log('New LP - delete action triggered', 0);
846
-        if (!$lp_found) { error_log('New LP - No learnpath given for delete', 0); require 'lp_list.php'; }
847
-        else {
906
+        if ($debug > 0) {
907
+            error_log('New LP - delete action triggered', 0);
908
+        }
909
+        if (!$lp_found) { error_log('New LP - No learnpath given for delete', 0); require 'lp_list.php'; } else {
848 910
             $_SESSION['refresh'] = 1;
849 911
             $_SESSION['oLP']->delete(null, $_GET['lp_id'], 'remove');
850 912
             Session::erase('oLP');
@@ -856,9 +918,10 @@  discard block
 block discarded – undo
856 918
         if (!$is_allowed_to_edit) {
857 919
             api_not_allowed(true);
858 920
         }
859
-        if ($debug > 0) error_log('New LP - visibility action triggered', 0);
860
-        if (!$lp_found) { error_log('New LP - No learnpath given for visibility', 0); require 'lp_list.php'; }
861
-        else {
921
+        if ($debug > 0) {
922
+            error_log('New LP - visibility action triggered', 0);
923
+        }
924
+        if (!$lp_found) { error_log('New LP - No learnpath given for visibility', 0); require 'lp_list.php'; } else {
862 925
             learnpath::toggle_visibility($_REQUEST['lp_id'], $_REQUEST['new_status']);
863 926
             require 'lp_list.php';
864 927
         }
@@ -868,9 +931,10 @@  discard block
 block discarded – undo
868 931
         if (!$is_allowed_to_edit) {
869 932
             api_not_allowed(true);
870 933
         }
871
-        if ($debug > 0) error_log('New LP - publish action triggered', 0);
872
-        if (!$lp_found) { error_log('New LP - No learnpath given for publish', 0); require 'lp_list.php'; }
873
-        else {
934
+        if ($debug > 0) {
935
+            error_log('New LP - publish action triggered', 0);
936
+        }
937
+        if (!$lp_found) { error_log('New LP - No learnpath given for publish', 0); require 'lp_list.php'; } else {
874 938
             learnpath::toggle_publish($_REQUEST['lp_id'], $_REQUEST['new_status']);
875 939
             require 'lp_list.php';
876 940
         }
@@ -880,7 +944,9 @@  discard block
 block discarded – undo
880 944
         if (!$is_allowed_to_edit) {
881 945
             api_not_allowed(true);
882 946
         }
883
-        if ($debug > 0) error_log('New LP - publish action triggered', 0);
947
+        if ($debug > 0) {
948
+            error_log('New LP - publish action triggered', 0);
949
+        }
884 950
         if (!$lp_found) {
885 951
             error_log('New LP - No learnpath given for publish', 0);
886 952
             require 'lp_list.php';
@@ -894,7 +960,9 @@  discard block
 block discarded – undo
894 960
         if (!$is_allowed_to_edit) {
895 961
             api_not_allowed(true);
896 962
         }
897
-        if ($debug > 0) error_log('New LP - publish action triggered', 0);
963
+        if ($debug > 0) {
964
+            error_log('New LP - publish action triggered', 0);
965
+        }
898 966
         if (!$lp_found) {
899 967
             error_log('New LP - No learnpath given for publish', 0);
900 968
             require 'lp_list.php';
@@ -907,9 +975,10 @@  discard block
 block discarded – undo
907 975
         if (!$is_allowed_to_edit) {
908 976
             api_not_allowed(true);
909 977
         }
910
-        if ($debug > 0) error_log('New LP - edit action triggered', 0);
911
-        if (!$lp_found) { error_log('New LP - No learnpath given for edit', 0); require 'lp_list.php'; }
912
-        else {
978
+        if ($debug > 0) {
979
+            error_log('New LP - edit action triggered', 0);
980
+        }
981
+        if (!$lp_found) { error_log('New LP - No learnpath given for edit', 0); require 'lp_list.php'; } else {
913 982
             $_SESSION['refresh'] = 1;
914 983
             require 'lp_edit.php';
915 984
         }
@@ -918,9 +987,10 @@  discard block
 block discarded – undo
918 987
         if (!$is_allowed_to_edit) {
919 988
             api_not_allowed(true);
920 989
         }
921
-        if ($debug > 0) error_log('New LP - update_lp action triggered', 0);
922
-        if (!$lp_found) { error_log('New LP - No learnpath given for edit', 0); require 'lp_list.php'; }
923
-        else {
990
+        if ($debug > 0) {
991
+            error_log('New LP - update_lp action triggered', 0);
992
+        }
993
+        if (!$lp_found) { error_log('New LP - No learnpath given for edit', 0); require 'lp_list.php'; } else {
924 994
             $_SESSION['refresh'] = 1;
925 995
             $lp_name = Security::remove_XSS($_REQUEST['lp_name']);
926 996
             $_SESSION['oLP']->set_name($lp_name);
@@ -989,8 +1059,9 @@  discard block
 block discarded – undo
989 1059
             );
990 1060
             $extraFieldValue->saveFieldValues($_REQUEST);
991 1061
 
992
-            if ($_FILES['lp_preview_image']['size'] > 0)
993
-                $_SESSION['oLP']->upload_image($_FILES['lp_preview_image']);
1062
+            if ($_FILES['lp_preview_image']['size'] > 0) {
1063
+                            $_SESSION['oLP']->upload_image($_FILES['lp_preview_image']);
1064
+            }
994 1065
 
995 1066
             if (api_get_setting('search_enabled') === 'true') {
996 1067
                 require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php';
@@ -1030,9 +1101,10 @@  discard block
 block discarded – undo
1030 1101
         if (!$is_allowed_to_edit) {
1031 1102
             api_not_allowed(true);
1032 1103
         }
1033
-        if ($debug > 0) error_log('New LP - add sub item action triggered', 0);
1034
-        if (!$lp_found) { error_log('New LP - No learnpath given for add sub item', 0); require 'lp_list.php'; }
1035
-        else {
1104
+        if ($debug > 0) {
1105
+            error_log('New LP - add sub item action triggered', 0);
1106
+        }
1107
+        if (!$lp_found) { error_log('New LP - No learnpath given for add sub item', 0); require 'lp_list.php'; } else {
1036 1108
             $_SESSION['refresh'] = 1;
1037 1109
             if (!empty($_REQUEST['parent_item_id'])) {
1038 1110
                 $_SESSION['from_learnpath']='yes';
@@ -1048,7 +1120,9 @@  discard block
 block discarded – undo
1048 1120
         if (!$is_allowed_to_edit) {
1049 1121
             api_not_allowed(true);
1050 1122
         }
1051
-        if ($debug > 0) error_log('New LP - delete item action triggered', 0);
1123
+        if ($debug > 0) {
1124
+            error_log('New LP - delete item action triggered', 0);
1125
+        }
1052 1126
         if (!$lp_found) {
1053 1127
             error_log('New LP - No learnpath given for delete item', 0);
1054 1128
             require 'lp_list.php';
@@ -1067,9 +1141,10 @@  discard block
 block discarded – undo
1067 1141
         if (!$is_allowed_to_edit) {
1068 1142
             api_not_allowed(true);
1069 1143
         }
1070
-        if ($debug > 0) error_log('New LP - edit item prereq action triggered', 0);
1071
-        if (!$lp_found) { error_log('New LP - No learnpath given for edit item prereq', 0); require 'lp_list.php'; }
1072
-        else {
1144
+        if ($debug > 0) {
1145
+            error_log('New LP - edit item prereq action triggered', 0);
1146
+        }
1147
+        if (!$lp_found) { error_log('New LP - No learnpath given for edit item prereq', 0); require 'lp_list.php'; } else {
1073 1148
             if (!empty($_REQUEST['id']) && !empty($_REQUEST['submit_item'])) {
1074 1149
                 $_SESSION['refresh'] = 1;
1075 1150
                 $_SESSION['oLP']->edit_item_prereq($_REQUEST['id'], $_REQUEST['prereq']);
@@ -1078,64 +1153,80 @@  discard block
 block discarded – undo
1078 1153
         }
1079 1154
         break;
1080 1155
     case 'restart':
1081
-        if ($debug > 0) error_log('New LP - restart action triggered', 0);
1082
-        if (!$lp_found) { error_log('New LP - No learnpath given for restart', 0); require 'lp_list.php'; }
1083
-        else {
1156
+        if ($debug > 0) {
1157
+            error_log('New LP - restart action triggered', 0);
1158
+        }
1159
+        if (!$lp_found) { error_log('New LP - No learnpath given for restart', 0); require 'lp_list.php'; } else {
1084 1160
             $_SESSION['oLP']->restart();
1085 1161
             require 'lp_view.php';
1086 1162
         }
1087 1163
         break;
1088 1164
     case 'last':
1089
-        if ($debug > 0) error_log('New LP - last action triggered', 0);
1090
-        if (!$lp_found) { error_log('New LP - No learnpath given for last', 0); require 'lp_list.php'; }
1091
-        else {
1165
+        if ($debug > 0) {
1166
+            error_log('New LP - last action triggered', 0);
1167
+        }
1168
+        if (!$lp_found) { error_log('New LP - No learnpath given for last', 0); require 'lp_list.php'; } else {
1092 1169
             $_SESSION['oLP']->last();
1093 1170
             require 'lp_view.php';
1094 1171
         }
1095 1172
         break;
1096 1173
     case 'first':
1097
-        if ($debug > 0) error_log('New LP - first action triggered', 0);
1098
-        if (!$lp_found) { error_log('New LP - No learnpath given for first', 0); require 'lp_list.php'; }
1099
-        else {
1174
+        if ($debug > 0) {
1175
+            error_log('New LP - first action triggered', 0);
1176
+        }
1177
+        if (!$lp_found) { error_log('New LP - No learnpath given for first', 0); require 'lp_list.php'; } else {
1100 1178
             $_SESSION['oLP']->first();
1101 1179
             require 'lp_view.php';
1102 1180
         }
1103 1181
         break;
1104 1182
     case 'next':
1105
-        if ($debug > 0) error_log('New LP - next action triggered', 0);
1106
-        if (!$lp_found) { error_log('New LP - No learnpath given for next', 0); require 'lp_list.php'; }
1107
-        else {
1183
+        if ($debug > 0) {
1184
+            error_log('New LP - next action triggered', 0);
1185
+        }
1186
+        if (!$lp_found) { error_log('New LP - No learnpath given for next', 0); require 'lp_list.php'; } else {
1108 1187
             $_SESSION['oLP']->next();
1109 1188
             require 'lp_view.php';
1110 1189
         }
1111 1190
         break;
1112 1191
     case 'previous':
1113
-        if ($debug > 0) error_log('New LP - previous action triggered', 0);
1114
-        if (!$lp_found) { error_log('New LP - No learnpath given for previous', 0); require 'lp_list.php'; }
1115
-        else {
1192
+        if ($debug > 0) {
1193
+            error_log('New LP - previous action triggered', 0);
1194
+        }
1195
+        if (!$lp_found) { error_log('New LP - No learnpath given for previous', 0); require 'lp_list.php'; } else {
1116 1196
             $_SESSION['oLP']->previous();
1117 1197
             require 'lp_view.php';
1118 1198
         }
1119 1199
         break;
1120 1200
     case 'content':
1121
-        if ($debug > 0) error_log('New LP - content action triggered', 0);
1122
-        if ($debug > 0) error_log('New LP - Item id is '.intval($_GET['item_id']), 0);
1201
+        if ($debug > 0) {
1202
+            error_log('New LP - content action triggered', 0);
1203
+        }
1204
+        if ($debug > 0) {
1205
+            error_log('New LP - Item id is '.intval($_GET['item_id']), 0);
1206
+        }
1123 1207
         if (!$lp_found) {
1124 1208
             error_log('New LP - No learnpath given for content', 0);
1125 1209
             require 'lp_list.php';
1126 1210
         } else {
1127
-            if ($debug > 0) error_log('New LP - save_last()', 0);
1211
+            if ($debug > 0) {
1212
+                error_log('New LP - save_last()', 0);
1213
+            }
1128 1214
             $_SESSION['oLP']->save_last();
1129
-            if ($debug > 0) error_log('New LP - set_current_item()', 0);
1215
+            if ($debug > 0) {
1216
+                error_log('New LP - set_current_item()', 0);
1217
+            }
1130 1218
             $_SESSION['oLP']->set_current_item($_GET['item_id']);
1131
-            if ($debug > 0) error_log('New LP - start_current_item()', 0);
1219
+            if ($debug > 0) {
1220
+                error_log('New LP - start_current_item()', 0);
1221
+            }
1132 1222
             $_SESSION['oLP']->start_current_item();
1133 1223
             require 'lp_content.php';
1134 1224
         }
1135 1225
         break;
1136 1226
     case 'view':
1137
-        if ($debug > 0)
1138
-            error_log('New LP - view action triggered', 0);
1227
+        if ($debug > 0) {
1228
+                    error_log('New LP - view action triggered', 0);
1229
+        }
1139 1230
         if (!$lp_found) {
1140 1231
             error_log('New LP - No learnpath given for view', 0);
1141 1232
             require 'lp_list.php';
@@ -1148,17 +1239,19 @@  discard block
 block discarded – undo
1148 1239
         }
1149 1240
         break;
1150 1241
     case 'save':
1151
-        if ($debug > 0) error_log('New LP - save action triggered', 0);
1152
-        if (!$lp_found) { error_log('New LP - No learnpath given for save', 0); require 'lp_list.php'; }
1153
-        else {
1242
+        if ($debug > 0) {
1243
+            error_log('New LP - save action triggered', 0);
1244
+        }
1245
+        if (!$lp_found) { error_log('New LP - No learnpath given for save', 0); require 'lp_list.php'; } else {
1154 1246
             $_SESSION['oLP']->save_item();
1155 1247
             require 'lp_save.php';
1156 1248
         }
1157 1249
         break;
1158 1250
     case 'stats':
1159
-        if ($debug > 0) error_log('New LP - stats action triggered', 0);
1160
-        if (!$lp_found) { error_log('New LP - No learnpath given for stats', 0); require 'lp_list.php'; }
1161
-        else {
1251
+        if ($debug > 0) {
1252
+            error_log('New LP - stats action triggered', 0);
1253
+        }
1254
+        if (!$lp_found) { error_log('New LP - No learnpath given for stats', 0); require 'lp_list.php'; } else {
1162 1255
             $_SESSION['oLP']->save_current();
1163 1256
             $_SESSION['oLP']->save_last();
1164 1257
             $output = require 'lp_stats.php';
@@ -1166,7 +1259,9 @@  discard block
 block discarded – undo
1166 1259
         }
1167 1260
         break;
1168 1261
     case 'list':
1169
-        if ($debug > 0) error_log('New LP - list action triggered', 0);
1262
+        if ($debug > 0) {
1263
+            error_log('New LP - list action triggered', 0);
1264
+        }
1170 1265
         if ($lp_found) {
1171 1266
             $_SESSION['refresh'] = 1;
1172 1267
             $_SESSION['oLP']->save_last();
@@ -1175,7 +1270,9 @@  discard block
 block discarded – undo
1175 1270
         break;
1176 1271
     case 'mode':
1177 1272
         // Switch between fullscreen and embedded mode.
1178
-        if ($debug > 0) error_log('New LP - mode change triggered', 0);
1273
+        if ($debug > 0) {
1274
+            error_log('New LP - mode change triggered', 0);
1275
+        }
1179 1276
         $mode = $_REQUEST['mode'];
1180 1277
         if ($mode == 'fullscreen') {
1181 1278
             $_SESSION['oLP']->mode = 'fullscreen';
@@ -1189,7 +1286,9 @@  discard block
 block discarded – undo
1189 1286
         require 'lp_view.php';
1190 1287
         break;
1191 1288
     case 'switch_view_mode':
1192
-        if ($debug > 0) error_log('New LP - switch_view_mode action triggered', 0);
1289
+        if ($debug > 0) {
1290
+            error_log('New LP - switch_view_mode action triggered', 0);
1291
+        }
1193 1292
         if (!$lp_found) { error_log('New LP - No learnpath given for switch', 0); require 'lp_list.php'; }
1194 1293
         if (Security::check_token('get')) {
1195 1294
             $_SESSION['refresh'] = 1;
@@ -1198,7 +1297,9 @@  discard block
 block discarded – undo
1198 1297
         require 'lp_list.php';
1199 1298
         break;
1200 1299
     case 'switch_force_commit':
1201
-        if ($debug > 0) error_log('New LP - switch_force_commit action triggered', 0);
1300
+        if ($debug > 0) {
1301
+            error_log('New LP - switch_force_commit action triggered', 0);
1302
+        }
1202 1303
         if (!$lp_found) { error_log('New LP - No learnpath given for switch', 0); require 'lp_list.php'; }
1203 1304
         $_SESSION['refresh'] = 1;
1204 1305
         $_SESSION['oLP']->update_default_scorm_commit();
@@ -1221,25 +1322,33 @@  discard block
 block discarded – undo
1221 1322
 		break;
1222 1323
      */
1223 1324
 	case 'switch_attempt_mode':
1224
-		if($debug>0) error_log('New LP - switch_reinit action triggered',0);
1325
+		if($debug>0) {
1326
+		    error_log('New LP - switch_reinit action triggered',0);
1327
+		}
1225 1328
 		if(!$lp_found){ error_log('New LP - No learnpath given for switch',0); require 'lp_list.php'; }
1226 1329
 		$_SESSION['refresh'] = 1;
1227 1330
 		$_SESSION['oLP']->switch_attempt_mode();
1228 1331
         require 'lp_list.php';
1229 1332
         break;
1230 1333
     case 'switch_scorm_debug':
1231
-        if ($debug > 0) error_log('New LP - switch_scorm_debug action triggered', 0);
1334
+        if ($debug > 0) {
1335
+            error_log('New LP - switch_scorm_debug action triggered', 0);
1336
+        }
1232 1337
         if (!$lp_found) { error_log('New LP - No learnpath given for switch', 0); require 'lp_list.php'; }
1233 1338
         $_SESSION['refresh'] = 1;
1234 1339
         $_SESSION['oLP']->update_scorm_debug();
1235 1340
         require 'lp_list.php';
1236 1341
         break;
1237 1342
     case 'intro_cmdAdd':
1238
-        if ($debug > 0) error_log('New LP - intro_cmdAdd action triggered', 0);
1343
+        if ($debug > 0) {
1344
+            error_log('New LP - intro_cmdAdd action triggered', 0);
1345
+        }
1239 1346
         // Add introduction section page.
1240 1347
         break;
1241 1348
     case 'js_api_refresh':
1242
-        if ($debug > 0) error_log('New LP - js_api_refresh action triggered', 0);
1349
+        if ($debug > 0) {
1350
+            error_log('New LP - js_api_refresh action triggered', 0);
1351
+        }
1243 1352
         if (!$lp_found) { error_log('New LP - No learnpath given for js_api_refresh', 0); require 'lp_message.php'; }
1244 1353
         if (isset($_REQUEST['item_id'])) {
1245 1354
             $htmlHeadXtra[] = $_SESSION['oLP']->get_js_info($_REQUEST['item_id']);
@@ -1247,8 +1356,7 @@  discard block
 block discarded – undo
1247 1356
         require 'lp_message.php';
1248 1357
         break;
1249 1358
     case 'return_to_course_homepage':
1250
-        if (!$lp_found) { error_log('New LP - No learnpath given for stats', 0); require 'lp_list.php'; }
1251
-        else {
1359
+        if (!$lp_found) { error_log('New LP - No learnpath given for stats', 0); require 'lp_list.php'; } else {
1252 1360
             $_SESSION['oLP']->save_current();
1253 1361
             $_SESSION['oLP']->save_last();
1254 1362
             $url = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/index.php?id_session='.api_get_session_id();
@@ -1266,8 +1374,9 @@  discard block
 block discarded – undo
1266 1374
         require 'lp_list_search.php';
1267 1375
         break;
1268 1376
     case 'impress':
1269
-        if ($debug > 0)
1270
-            error_log('New LP - view action triggered', 0);
1377
+        if ($debug > 0) {
1378
+                    error_log('New LP - view action triggered', 0);
1379
+        }
1271 1380
         if (!$lp_found) {
1272 1381
             error_log('New LP - No learnpath given for view', 0);
1273 1382
             require 'lp_list.php';
@@ -1441,15 +1550,19 @@  discard block
 block discarded – undo
1441 1550
         ]);
1442 1551
         break;
1443 1552
     default:
1444
-        if ($debug > 0) error_log('New LP - default action triggered', 0);
1553
+        if ($debug > 0) {
1554
+            error_log('New LP - default action triggered', 0);
1555
+        }
1445 1556
         require 'lp_list.php';
1446 1557
         break;
1447 1558
 }
1448 1559
 
1449 1560
 if (!empty($_SESSION['oLP'])) {
1450 1561
     $_SESSION['lpobject'] = serialize($_SESSION['oLP']);
1451
-    if ($debug > 0) error_log('New LP - lpobject is serialized in session', 0);
1452
-}
1562
+    if ($debug > 0) {
1563
+        error_log('New LP - lpobject is serialized in session', 0);
1564
+    }
1565
+    }
1453 1566
 
1454 1567
 if (!empty($redirectTo)) {
1455 1568
     header("Location: $redirectTo");
Please login to merge, or discard this patch.