Completed
Push — 1.11.x ( ca7787...41c0f2 )
by José
31:51
created
main/inc/ajax/chat.ajax.php 1 patch
Switch Indentation   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -55,56 +55,56 @@
 block discarded – undo
55 55
 }
56 56
 
57 57
 switch ($action) {
58
-    case 'chatheartbeat':
59
-        $chat->heartbeat();
60
-        break;
61
-    case 'closechat':
62
-        $chat->close();
63
-        break;
64
-    case 'sendchat':
65
-        $chat->send(api_get_user_id(), $to_user_id, $message);
66
-        break;
67
-    case 'startchatsession':
68
-        $chat->startSession();
69
-        break;
70
-    case 'set_status':
71
-        $status = isset($_REQUEST['status']) ? intval($_REQUEST['status']) : 0;
72
-        $chat->setUserStatus($status);
73
-        break;
74
-    case 'create_room':
75
-        $room = VideoChat::getChatRoomByUsers(api_get_user_id(), $to_user_id);
76
-
77
-        if ($room === false) {
78
-            $createdRoom = VideoChat::createRoom(api_get_user_id(), $to_user_id);
79
-
80
-            if ($createdRoom === false) {
81
-                echo Display::return_message(get_lang('ChatRoomNotCreated'), 'error');
82
-                break;
58
+        case 'chatheartbeat':
59
+            $chat->heartbeat();
60
+            break;
61
+        case 'closechat':
62
+            $chat->close();
63
+            break;
64
+        case 'sendchat':
65
+            $chat->send(api_get_user_id(), $to_user_id, $message);
66
+            break;
67
+        case 'startchatsession':
68
+            $chat->startSession();
69
+            break;
70
+        case 'set_status':
71
+            $status = isset($_REQUEST['status']) ? intval($_REQUEST['status']) : 0;
72
+            $chat->setUserStatus($status);
73
+            break;
74
+        case 'create_room':
75
+            $room = VideoChat::getChatRoomByUsers(api_get_user_id(), $to_user_id);
76
+
77
+            if ($room === false) {
78
+                $createdRoom = VideoChat::createRoom(api_get_user_id(), $to_user_id);
79
+
80
+                if ($createdRoom === false) {
81
+                    echo Display::return_message(get_lang('ChatRoomNotCreated'), 'error');
82
+                    break;
83
+                }
84
+
85
+                $room = VideoChat::getChatRoomByUsers(api_get_user_id(), $to_user_id);
83 86
             }
84 87
 
85
-            $room = VideoChat::getChatRoomByUsers(api_get_user_id(), $to_user_id);
86
-        }
87
-
88
-        $videoChatUrl = api_get_path(WEB_LIBRARY_JS_PATH) . "chat/video.php?room={$room['id']}";
89
-        $videoChatLink = Display::url(
90
-            Display::returnFontAwesomeIcon('video-camera') . get_lang('StartVideoChat'),
91
-            $videoChatUrl
92
-        );
93
-
94
-        $chat->send(
95
-            api_get_user_id(),
96
-            $to_user_id,
97
-            $videoChatLink,
98
-            false,
99
-            false
100
-        );
101
-
102
-        echo Display::tag('p', $videoChatLink, ['class' => 'lead']);
103
-        break;
104
-    case 'notify_not_support':
105
-        $chat->send(api_get_user_id(), $to_user_id, get_lang('TheXUserBrowserDoesNotSupportWebRTC'));
106
-        break;
107
-    default:
108
-        echo '';
88
+            $videoChatUrl = api_get_path(WEB_LIBRARY_JS_PATH) . "chat/video.php?room={$room['id']}";
89
+            $videoChatLink = Display::url(
90
+                Display::returnFontAwesomeIcon('video-camera') . get_lang('StartVideoChat'),
91
+                $videoChatUrl
92
+            );
93
+
94
+            $chat->send(
95
+                api_get_user_id(),
96
+                $to_user_id,
97
+                $videoChatLink,
98
+                false,
99
+                false
100
+            );
101
+
102
+            echo Display::tag('p', $videoChatLink, ['class' => 'lead']);
103
+            break;
104
+        case 'notify_not_support':
105
+            $chat->send(api_get_user_id(), $to_user_id, get_lang('TheXUserBrowserDoesNotSupportWebRTC'));
106
+            break;
107
+        default:
108
+            echo '';
109 109
 }
110 110
 exit;
Please login to merge, or discard this patch.
main/lp/storageapi.php 1 patch
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.
main/upload/upload.php 1 patch
Switch Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -31,14 +31,14 @@
 block discarded – undo
31 31
  * Redirect to the correct script to handle this type of upload
32 32
  */
33 33
 switch ($toolFromSession) {
34
-    case TOOL_LEARNPATH:
35
-        require 'upload.scorm.php';
36
-        break;
37
-    //the following cases need to be distinguished later on
38
-    case TOOL_DROPBOX:
39
-    case TOOL_STUDENTPUBLICATION:
40
-    case TOOL_DOCUMENT:
41
-    default:
42
-        require 'upload.document.php';
43
-        break;
34
+        case TOOL_LEARNPATH:
35
+            require 'upload.scorm.php';
36
+            break;
37
+        //the following cases need to be distinguished later on
38
+        case TOOL_DROPBOX:
39
+        case TOOL_STUDENTPUBLICATION:
40
+        case TOOL_DOCUMENT:
41
+        default:
42
+            require 'upload.document.php';
43
+            break;
44 44
 }
Please login to merge, or discard this patch.
main/auth/courses.php 1 patch
Switch Indentation   +136 added lines, -136 removed lines patch added patch discarded remove patch
@@ -175,28 +175,53 @@  discard block
 block discarded – undo
175 175
 }
176 176
 
177 177
 switch ($action) {
178
-    case 'subscribe_user_with_password':
179
-        $courses_controller->subscribe_user(
180
-            isset($_POST['subscribe_user_with_password']) ? $_POST['subscribe_user_with_password'] : '',
181
-            isset($_POST['search_term']) ? $_POST['search_term'] : '',
182
-            isset($_POST['category_code']) ? $_POST['category_code'] : ''
183
-        );
184
-        break;
185
-    case 'createcoursecategory':
186
-        $courses_controller->categories_list($action);
187
-        break;
188
-    case 'deletecoursecategory':
189
-        $courses_controller->courses_list($action);
190
-        break;
191
-    case 'sortmycourses':
192
-        $courses_controller->courses_list($action);
193
-        break;
194
-    case 'subscribe':
195
-        if (!$user_can_view_page) {
196
-            api_not_allowed(true);
197
-        }
198
-
199
-        if (!CoursesAndSessionsCatalog::is(CATALOG_SESSIONS)) {
178
+        case 'subscribe_user_with_password':
179
+            $courses_controller->subscribe_user(
180
+                isset($_POST['subscribe_user_with_password']) ? $_POST['subscribe_user_with_password'] : '',
181
+                isset($_POST['search_term']) ? $_POST['search_term'] : '',
182
+                isset($_POST['category_code']) ? $_POST['category_code'] : ''
183
+            );
184
+            break;
185
+        case 'createcoursecategory':
186
+            $courses_controller->categories_list($action);
187
+            break;
188
+        case 'deletecoursecategory':
189
+            $courses_controller->courses_list($action);
190
+            break;
191
+        case 'sortmycourses':
192
+            $courses_controller->courses_list($action);
193
+            break;
194
+        case 'subscribe':
195
+            if (!$user_can_view_page) {
196
+                api_not_allowed(true);
197
+            }
198
+
199
+            if (!CoursesAndSessionsCatalog::is(CATALOG_SESSIONS)) {
200
+                $courses_controller->courses_categories(
201
+                    $action,
202
+                    $categoryCode,
203
+                    null,
204
+                    null,
205
+                    null,
206
+                    $limit
207
+                );
208
+            } else {
209
+                header('Location: ' . api_get_self());
210
+                exit;
211
+            }
212
+            break;
213
+        case 'display_random_courses':
214
+            if (!$user_can_view_page) {
215
+                api_not_allowed(true);
216
+            }
217
+
218
+            $courses_controller->courses_categories($action);
219
+            break;
220
+        case 'display_courses':
221
+            if (!$user_can_view_page) {
222
+                api_not_allowed(true);
223
+            }
224
+
200 225
             $courses_controller->courses_categories(
201 226
                 $action,
202 227
                 $categoryCode,
@@ -205,127 +230,102 @@  discard block
 block discarded – undo
205 230
                 null,
206 231
                 $limit
207 232
             );
208
-        } else {
209
-            header('Location: ' . api_get_self());
210
-            exit;
211
-        }
212
-        break;
213
-    case 'display_random_courses':
214
-        if (!$user_can_view_page) {
215
-            api_not_allowed(true);
216
-        }
217
-
218
-        $courses_controller->courses_categories($action);
219
-        break;
220
-    case 'display_courses':
221
-        if (!$user_can_view_page) {
222
-            api_not_allowed(true);
223
-        }
224
-
225
-        $courses_controller->courses_categories(
226
-            $action,
227
-            $categoryCode,
228
-            null,
229
-            null,
230
-            null,
231
-            $limit
232
-        );
233
-        break;
234
-    case 'display_sessions':
235
-        if (!$user_can_view_page) {
236
-            api_not_allowed(true);
237
-        }
238
-
239
-        $courses_controller->sessionsList($action, $nameTools, $limit);
240
-        break;
241
-    case 'subscribe_to_session':
242
-        if (!$user_can_view_page) {
243
-            api_not_allowed(true);
244
-        }
245
-
246
-        $userId = api_get_user_id();
247
-        $confirmed = isset($_GET['confirm']);
248
-        $sessionId = intval($_GET['session_id']);
249
-
250
-        if (empty($userId)) {
251
-            api_not_allowed();
252
-            exit;
253
-        }
254
-
255
-        if (!$confirmed) {
256
-            $template = new Template(null, false, false, false, false, false);
257
-            $template->assign('session_id', $sessionId);
258
-
259
-            $layout = $template->get_template('auth/confirm_session_subscription.tpl');
260
-
261
-            echo $template->fetch($layout);
262
-            exit;
263
-        }
264
-
265
-        $registrationAllowed = api_get_setting('catalog_allow_session_auto_subscription');
266
-        if ($registrationAllowed === 'true') {
267
-            $entityManager = Database::getManager();
268
-            $repository = $entityManager->getRepository('ChamiloCoreBundle:SequenceResource');
269
-
270
-            $sequences = $repository->getRequirements(
271
-                $sessionId,
272
-                SequenceResource::SESSION_TYPE
273
-            );
233
+            break;
234
+        case 'display_sessions':
235
+            if (!$user_can_view_page) {
236
+                api_not_allowed(true);
237
+            }
238
+
239
+            $courses_controller->sessionsList($action, $nameTools, $limit);
240
+            break;
241
+        case 'subscribe_to_session':
242
+            if (!$user_can_view_page) {
243
+                api_not_allowed(true);
244
+            }
274 245
 
275
-            if (count($sequences) > 0) {
276
-                $requirementsData = SequenceResourceManager::checkRequirementsForUser(
277
-                    $sequences,
278
-                    SequenceResource::SESSION_TYPE,
279
-                    $userId
246
+            $userId = api_get_user_id();
247
+            $confirmed = isset($_GET['confirm']);
248
+            $sessionId = intval($_GET['session_id']);
249
+
250
+            if (empty($userId)) {
251
+                api_not_allowed();
252
+                exit;
253
+            }
254
+
255
+            if (!$confirmed) {
256
+                $template = new Template(null, false, false, false, false, false);
257
+                $template->assign('session_id', $sessionId);
258
+
259
+                $layout = $template->get_template('auth/confirm_session_subscription.tpl');
260
+
261
+                echo $template->fetch($layout);
262
+                exit;
263
+            }
264
+
265
+            $registrationAllowed = api_get_setting('catalog_allow_session_auto_subscription');
266
+            if ($registrationAllowed === 'true') {
267
+                $entityManager = Database::getManager();
268
+                $repository = $entityManager->getRepository('ChamiloCoreBundle:SequenceResource');
269
+
270
+                $sequences = $repository->getRequirements(
271
+                    $sessionId,
272
+                    SequenceResource::SESSION_TYPE
280 273
                 );
281 274
 
282
-                $continueWithSubscription = SequenceResourceManager::checkSequenceAreCompleted($requirementsData);
275
+                if (count($sequences) > 0) {
276
+                    $requirementsData = SequenceResourceManager::checkRequirementsForUser(
277
+                        $sequences,
278
+                        SequenceResource::SESSION_TYPE,
279
+                        $userId
280
+                    );
281
+
282
+                    $continueWithSubscription = SequenceResourceManager::checkSequenceAreCompleted($requirementsData);
283 283
 
284
-                if (!$continueWithSubscription) {
285
-                    header('Location: ' .  api_get_path(WEB_CODE_PATH) . 'auth/courses.php');
286
-                    exit;
284
+                    if (!$continueWithSubscription) {
285
+                        header('Location: ' .  api_get_path(WEB_CODE_PATH) . 'auth/courses.php');
286
+                        exit;
287
+                    }
287 288
                 }
288
-            }
289 289
 
290
-            SessionManager::subscribe_users_to_session(
291
-                $_GET['session_id'],
292
-                array($userId),
293
-                SESSION_VISIBLE_READ_ONLY,
294
-                false
295
-            );
290
+                SessionManager::subscribe_users_to_session(
291
+                    $_GET['session_id'],
292
+                    array($userId),
293
+                    SESSION_VISIBLE_READ_ONLY,
294
+                    false
295
+                );
296 296
 
297
-            $coursesList = SessionManager::get_course_list_by_session_id($_GET['session_id']);
298
-            $count = count($coursesList);
299
-            $url = '';
300
-
301
-            if ($count <= 0) {
302
-                // no course in session -> return to catalog
303
-                $url = api_get_path(WEB_CODE_PATH) . 'auth/courses.php';
304
-            } elseif ($count == 1) {
305
-                // only one course, so redirect directly to this course
306
-                foreach ($coursesList as $course) {
307
-                    $url = api_get_path(WEB_COURSE_PATH) . $course['directory'] . '/index.php?id_session=' . intval($_GET['session_id']);
297
+                $coursesList = SessionManager::get_course_list_by_session_id($_GET['session_id']);
298
+                $count = count($coursesList);
299
+                $url = '';
300
+
301
+                if ($count <= 0) {
302
+                    // no course in session -> return to catalog
303
+                    $url = api_get_path(WEB_CODE_PATH) . 'auth/courses.php';
304
+                } elseif ($count == 1) {
305
+                    // only one course, so redirect directly to this course
306
+                    foreach ($coursesList as $course) {
307
+                        $url = api_get_path(WEB_COURSE_PATH) . $course['directory'] . '/index.php?id_session=' . intval($_GET['session_id']);
308
+                    }
309
+                } else {
310
+                    $url = api_get_path(WEB_CODE_PATH) . 'session/index.php?session_id=' . intval($_GET['session_id']);
308 311
                 }
309
-            } else {
310
-                $url = api_get_path(WEB_CODE_PATH) . 'session/index.php?session_id=' . intval($_GET['session_id']);
312
+                header('Location: ' . $url);
313
+                exit;
311 314
             }
312
-            header('Location: ' . $url);
313
-            exit;
314
-        }
315
-        //else show error message?
316
-        break;
317
-    case 'search_tag':
318
-        if (!$user_can_view_page) {
319
-            api_not_allowed(true);
320
-        }
321
-
322
-        $courses_controller->sessionsListByCoursesTag($limit);
323
-        break;
324
-    case 'search_session':
325
-        if (!$user_can_view_page) {
326
-            api_not_allowed(true);
327
-        }
328
-
329
-        $courses_controller->sessionListBySearch($limit);
330
-        break;
315
+            //else show error message?
316
+            break;
317
+        case 'search_tag':
318
+            if (!$user_can_view_page) {
319
+                api_not_allowed(true);
320
+            }
321
+
322
+            $courses_controller->sessionsListByCoursesTag($limit);
323
+            break;
324
+        case 'search_session':
325
+            if (!$user_can_view_page) {
326
+                api_not_allowed(true);
327
+            }
328
+
329
+            $courses_controller->sessionListBySearch($limit);
330
+            break;
331 331
 }
Please login to merge, or discard this patch.
main/user/user_export.php 1 patch
Switch Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -149,15 +149,15 @@
 block discarded – undo
149 149
 }
150 150
 
151 151
 switch ($file_type) {
152
-    case 'xml':
153
-        Export::arrayToXml($data, $filename, 'Contact', 'Contacts');
154
-        exit;
155
-        break;
156
-    case 'csv':
157
-        Export::arrayToCsv($data, $filename);
158
-        exit;
159
-    case 'xls':
160
-        Export::arrayToXls($data, $filename);
161
-        exit;
162
-        break;
152
+        case 'xml':
153
+            Export::arrayToXml($data, $filename, 'Contact', 'Contacts');
154
+            exit;
155
+            break;
156
+        case 'csv':
157
+            Export::arrayToCsv($data, $filename);
158
+            exit;
159
+        case 'xls':
160
+            Export::arrayToXls($data, $filename);
161
+            exit;
162
+            break;
163 163
 }
164 164
\ No newline at end of file
Please login to merge, or discard this patch.
main/lp/lp_controller.php 1 patch
Switch Indentation   +927 added lines, -927 removed lines patch added patch discarded remove patch
@@ -365,858 +365,858 @@  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 (!$lp_found) {
373
-            //check if the learnpath ID was defined, otherwise send back to list
374
-            if ($debug > 0) {
375
-                error_log('New LP - No learnpath given for add item', 0);
368
+        case 'add_item':
369
+            if (!$is_allowed_to_edit) {
370
+                api_not_allowed(true);
376 371
             }
377
-            require 'lp_list.php';
378
-        } else {
379
-            $_SESSION['refresh'] = 1;
372
+            if (!$lp_found) {
373
+                //check if the learnpath ID was defined, otherwise send back to list
374
+                if ($debug > 0) {
375
+                    error_log('New LP - No learnpath given for add item', 0);
376
+                }
377
+                require 'lp_list.php';
378
+            } else {
379
+                $_SESSION['refresh'] = 1;
380 380
 
381
-            if (isset($_POST['submit_button']) && !empty($post_title)) {
382
-                // If a title was submitted:
381
+                if (isset($_POST['submit_button']) && !empty($post_title)) {
382
+                    // If a title was submitted:
383 383
 
384
-                //Updating the lp.modified_on
385
-                $_SESSION['oLP']->set_modified_on();
384
+                    //Updating the lp.modified_on
385
+                    $_SESSION['oLP']->set_modified_on();
386 386
 
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 {
391
-                    $_SESSION['post_time'] = $_POST['post_time'];
392
-                    $directoryParentId = isset($_POST['directory_parent_id']) ? $_POST['directory_parent_id'] : 0;
393
-                    $courseInfo = api_get_course_info();
394
-                    if (empty($directoryParentId)) {
395
-                        $_SESSION['oLP']->generate_lp_folder($courseInfo);
396
-                    }
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 {
391
+                        $_SESSION['post_time'] = $_POST['post_time'];
392
+                        $directoryParentId = isset($_POST['directory_parent_id']) ? $_POST['directory_parent_id'] : 0;
393
+                        $courseInfo = api_get_course_info();
394
+                        if (empty($directoryParentId)) {
395
+                            $_SESSION['oLP']->generate_lp_folder($courseInfo);
396
+                        }
397 397
 
398
-                    $parent = isset($_POST['parent']) ? $_POST['parent'] : '';
399
-                    $previous = isset($_POST['previous']) ? $_POST['previous'] : '';
400
-                    $type = isset($_POST['type']) ? $_POST['type'] : '';
401
-                    $path = isset($_POST['path']) ? $_POST['path'] : '';
402
-                    $description = isset($_POST['description']) ? $_POST['description'] : '';
403
-                    $prerequisites = isset($_POST['prerequisites']) ? $_POST['prerequisites'] : '';
404
-                    $maxTimeAllowed = isset($_POST['maxTimeAllowed']) ? $_POST['maxTimeAllowed'] : '';
398
+                        $parent = isset($_POST['parent']) ? $_POST['parent'] : '';
399
+                        $previous = isset($_POST['previous']) ? $_POST['previous'] : '';
400
+                        $type = isset($_POST['type']) ? $_POST['type'] : '';
401
+                        $path = isset($_POST['path']) ? $_POST['path'] : '';
402
+                        $description = isset($_POST['description']) ? $_POST['description'] : '';
403
+                        $prerequisites = isset($_POST['prerequisites']) ? $_POST['prerequisites'] : '';
404
+                        $maxTimeAllowed = isset($_POST['maxTimeAllowed']) ? $_POST['maxTimeAllowed'] : '';
405
+
406
+                        if ($_POST['type'] == TOOL_DOCUMENT) {
407
+                            if (isset($_POST['path']) && $_GET['edit'] != 'true') {
408
+                                $document_id = $_POST['path'];
409
+                            } else {
410
+                                if ($_POST['content_lp']) {
411
+                                    $document_id = $_SESSION['oLP']->create_document(
412
+                                        $_course,
413
+                                        $_POST['content_lp'],
414
+                                        $_POST['title'],
415
+                                        'html',
416
+                                        $directoryParentId
417
+                                    );
418
+                                }
419
+                            }
405 420
 
406
-                    if ($_POST['type'] == TOOL_DOCUMENT) {
407
-                        if (isset($_POST['path']) && $_GET['edit'] != 'true') {
408
-                            $document_id = $_POST['path'];
421
+                            $new_item_id = $_SESSION['oLP']->add_item(
422
+                                $parent,
423
+                                $previous,
424
+                                $type,
425
+                                $document_id,
426
+                                $post_title,
427
+                                $description,
428
+                                $prerequisites
429
+                            );
409 430
                         } else {
410
-                            if ($_POST['content_lp']) {
411
-                                $document_id = $_SESSION['oLP']->create_document(
412
-                                    $_course,
413
-                                    $_POST['content_lp'],
414
-                                    $_POST['title'],
415
-                                    'html',
416
-                                    $directoryParentId
417
-                                );
418
-                            }
431
+                            // For all other item types than documents, load the item using the item type and path rather than its ID.
432
+                            $new_item_id = $_SESSION['oLP']->add_item(
433
+                                $parent,
434
+                                $previous,
435
+                                $type,
436
+                                $path,
437
+                                $post_title,
438
+                                $description,
439
+                                $prerequisites,
440
+                                $maxTimeAllowed
441
+                            );
419 442
                         }
420
-
421
-                        $new_item_id = $_SESSION['oLP']->add_item(
422
-                            $parent,
423
-                            $previous,
424
-                            $type,
425
-                            $document_id,
426
-                            $post_title,
427
-                            $description,
428
-                            $prerequisites
429
-                        );
430
-                    } else {
431
-                        // For all other item types than documents, load the item using the item type and path rather than its ID.
432
-                        $new_item_id = $_SESSION['oLP']->add_item(
433
-                            $parent,
434
-                            $previous,
435
-                            $type,
436
-                            $path,
437
-                            $post_title,
438
-                            $description,
439
-                            $prerequisites,
440
-                            $maxTimeAllowed
441
-                        );
443
+                        $url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_SESSION['oLP']->lp_id).'&'.api_get_cidreq();
444
+                        header('Location: '.$url);
445
+                        exit;
442 446
                     }
443
-                    $url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_SESSION['oLP']->lp_id).'&'.api_get_cidreq();
444
-                    header('Location: '.$url);
445
-                    exit;
447
+                } else {
448
+                    require 'lp_add_item.php';
446 449
                 }
447
-            } else {
448
-                require 'lp_add_item.php';
449 450
             }
450
-        }
451
-        break;
452
-    case 'add_users_to_category':
453
-        if (!$is_allowed_to_edit) {
454
-            api_not_allowed(true);
455
-        }
456
-        require 'lp_subscribe_users_to_category.php';
457
-        break;
458
-    case 'add_audio':
459
-        if (!$is_allowed_to_edit) {
460
-            api_not_allowed(true);
461
-        }
462
-        if (!$lp_found) {
463
-            //check if the learnpath ID was defined, otherwise send back to list
464
-            if ($debug > 0) {
465
-                error_log('New LP - No learnpath given for add audio', 0);
451
+            break;
452
+        case 'add_users_to_category':
453
+            if (!$is_allowed_to_edit) {
454
+                api_not_allowed(true);
466 455
             }
467
-            require 'lp_list.php';
468
-        } else {
469
-            $_SESSION['refresh'] = 1;
470
-
471
-            if (isset($_REQUEST['id'])) {
472
-                $lp_item_obj = new learnpathItem($_REQUEST['id']);
473
-
474
-                // Remove audio
475
-                if (isset($_GET['delete_file']) && $_GET['delete_file'] == 1) {
476
-                    $lp_item_obj->remove_audio();
477
-
478
-                    $url = api_get_self().'?action=add_audio&lp_id='.intval($_SESSION['oLP']->lp_id).'&id='.$lp_item_obj->get_id().'&'.api_get_cidreq();
479
-                    header('Location: '.$url);
480
-                    exit;
456
+            require 'lp_subscribe_users_to_category.php';
457
+            break;
458
+        case 'add_audio':
459
+            if (!$is_allowed_to_edit) {
460
+                api_not_allowed(true);
461
+            }
462
+            if (!$lp_found) {
463
+                //check if the learnpath ID was defined, otherwise send back to list
464
+                if ($debug > 0) {
465
+                    error_log('New LP - No learnpath given for add audio', 0);
481 466
                 }
467
+                require 'lp_list.php';
468
+            } else {
469
+                $_SESSION['refresh'] = 1;
482 470
 
483
-                // Upload audio
484
-                if (isset($_FILES['file']) && !empty($_FILES['file'])) {
485
-                    // Updating the lp.modified_on
486
-                    $_SESSION['oLP']->set_modified_on();
487
-                    $lp_item_obj->add_audio();
488
-                }
471
+                if (isset($_REQUEST['id'])) {
472
+                    $lp_item_obj = new learnpathItem($_REQUEST['id']);
489 473
 
490
-                //Add audio file from documents
491
-                if (isset($_REQUEST['document_id']) && !empty($_REQUEST['document_id'])) {
492
-                    $_SESSION['oLP']->set_modified_on();
493
-                    $lp_item_obj->add_audio_from_documents($_REQUEST['document_id']);
494
-                }
474
+                    // Remove audio
475
+                    if (isset($_GET['delete_file']) && $_GET['delete_file'] == 1) {
476
+                        $lp_item_obj->remove_audio();
495 477
 
496
-                // Display.
497
-                require 'lp_add_audio.php';
498
-            } else {
499
-                require 'lp_add_audio.php';
500
-            }
501
-        }
502
-        break;
503
-    case 'add_lp_category':
504
-        if (!$is_allowed_to_edit) {
505
-            api_not_allowed(true);
506
-        }
507
-        require 'lp_add_category.php';
508
-        break;
509
-    case 'move_up_category':
510
-        if (!$is_allowed_to_edit) {
511
-            api_not_allowed(true);
512
-        }
513
-        if (isset($_REQUEST['id'])) {
514
-            learnpath::moveUpCategory($_REQUEST['id']);
515
-        }
516
-        require 'lp_list.php';
517
-        break;
518
-    case 'move_down_category':
519
-        if (!$is_allowed_to_edit) {
520
-            api_not_allowed(true);
521
-        }
522
-        if (isset($_REQUEST['id'])) {
523
-            learnpath::moveDownCategory($_REQUEST['id']);
524
-        }
525
-        require 'lp_list.php';
526
-        break;
527
-    case 'delete_lp_category':
528
-        if (!$is_allowed_to_edit) {
529
-            api_not_allowed(true);
530
-        }
531
-        if (isset($_REQUEST['id'])) {
532
-            learnpath::deleteCategory($_REQUEST['id']);
533
-        }
534
-        require 'lp_list.php';
535
-        break;
536
-    case 'add_lp':
537
-        if (!$is_allowed_to_edit) {
538
-            api_not_allowed(true);
539
-        }
540
-        if (isset($_REQUEST['lp_name']) && !empty($_REQUEST['lp_name'])) {
541
-            $_REQUEST['lp_name'] = trim($_REQUEST['lp_name']);
542
-            $_SESSION['refresh'] = 1;
478
+                        $url = api_get_self().'?action=add_audio&lp_id='.intval($_SESSION['oLP']->lp_id).'&id='.$lp_item_obj->get_id().'&'.api_get_cidreq();
479
+                        header('Location: '.$url);
480
+                        exit;
481
+                    }
543 482
 
544
-            if (isset($_SESSION['post_time']) && $_SESSION['post_time'] == $_REQUEST['post_time']) {
545
-                require 'lp_add.php';
546
-            } else {
547
-                $_SESSION['post_time'] = $_REQUEST['post_time'];
483
+                    // Upload audio
484
+                    if (isset($_FILES['file']) && !empty($_FILES['file'])) {
485
+                        // Updating the lp.modified_on
486
+                        $_SESSION['oLP']->set_modified_on();
487
+                        $lp_item_obj->add_audio();
488
+                    }
548 489
 
549
-                if (isset($_REQUEST['activate_start_date_check']) &&
550
-                    $_REQUEST['activate_start_date_check'] == 1
551
-                ) {
552
-                    $publicated_on = $_REQUEST['publicated_on'];
490
+                    //Add audio file from documents
491
+                    if (isset($_REQUEST['document_id']) && !empty($_REQUEST['document_id'])) {
492
+                        $_SESSION['oLP']->set_modified_on();
493
+                        $lp_item_obj->add_audio_from_documents($_REQUEST['document_id']);
494
+                    }
495
+
496
+                    // Display.
497
+                    require 'lp_add_audio.php';
553 498
                 } else {
554
-                    $publicated_on = null;
499
+                    require 'lp_add_audio.php';
555 500
                 }
501
+            }
502
+            break;
503
+        case 'add_lp_category':
504
+            if (!$is_allowed_to_edit) {
505
+                api_not_allowed(true);
506
+            }
507
+            require 'lp_add_category.php';
508
+            break;
509
+        case 'move_up_category':
510
+            if (!$is_allowed_to_edit) {
511
+                api_not_allowed(true);
512
+            }
513
+            if (isset($_REQUEST['id'])) {
514
+                learnpath::moveUpCategory($_REQUEST['id']);
515
+            }
516
+            require 'lp_list.php';
517
+            break;
518
+        case 'move_down_category':
519
+            if (!$is_allowed_to_edit) {
520
+                api_not_allowed(true);
521
+            }
522
+            if (isset($_REQUEST['id'])) {
523
+                learnpath::moveDownCategory($_REQUEST['id']);
524
+            }
525
+            require 'lp_list.php';
526
+            break;
527
+        case 'delete_lp_category':
528
+            if (!$is_allowed_to_edit) {
529
+                api_not_allowed(true);
530
+            }
531
+            if (isset($_REQUEST['id'])) {
532
+                learnpath::deleteCategory($_REQUEST['id']);
533
+            }
534
+            require 'lp_list.php';
535
+            break;
536
+        case 'add_lp':
537
+            if (!$is_allowed_to_edit) {
538
+                api_not_allowed(true);
539
+            }
540
+            if (isset($_REQUEST['lp_name']) && !empty($_REQUEST['lp_name'])) {
541
+                $_REQUEST['lp_name'] = trim($_REQUEST['lp_name']);
542
+                $_SESSION['refresh'] = 1;
556 543
 
557
-                if (isset($_REQUEST['activate_end_date_check']) &&
558
-                    $_REQUEST['activate_end_date_check'] == 1
559
-                ) {
560
-                    $expired_on = $_REQUEST['expired_on'];
544
+                if (isset($_SESSION['post_time']) && $_SESSION['post_time'] == $_REQUEST['post_time']) {
545
+                    require 'lp_add.php';
561 546
                 } else {
562
-                    $expired_on = null;
563
-                }
547
+                    $_SESSION['post_time'] = $_REQUEST['post_time'];
564 548
 
565
-                $new_lp_id = learnpath::add_lp(
566
-                    api_get_course_id(),
567
-                    Security::remove_XSS($_REQUEST['lp_name']),
568
-                    '',
569
-                    'chamilo',
570
-                    'manual',
571
-                    '',
572
-                    $publicated_on,
573
-                    $expired_on,
574
-                    $_REQUEST['category_id']
575
-                );
549
+                    if (isset($_REQUEST['activate_start_date_check']) &&
550
+                        $_REQUEST['activate_start_date_check'] == 1
551
+                    ) {
552
+                        $publicated_on = $_REQUEST['publicated_on'];
553
+                    } else {
554
+                        $publicated_on = null;
555
+                    }
576 556
 
577
-                if (is_numeric($new_lp_id)) {
578
-                    // TODO: Maybe create a first directory directly to avoid bugging the user with useless queries
579
-                    $_SESSION['oLP'] = new learnpath(
557
+                    if (isset($_REQUEST['activate_end_date_check']) &&
558
+                        $_REQUEST['activate_end_date_check'] == 1
559
+                    ) {
560
+                        $expired_on = $_REQUEST['expired_on'];
561
+                    } else {
562
+                        $expired_on = null;
563
+                    }
564
+
565
+                    $new_lp_id = learnpath::add_lp(
580 566
                         api_get_course_id(),
581
-                        $new_lp_id,
582
-                        api_get_user_id()
567
+                        Security::remove_XSS($_REQUEST['lp_name']),
568
+                        '',
569
+                        'chamilo',
570
+                        'manual',
571
+                        '',
572
+                        $publicated_on,
573
+                        $expired_on,
574
+                        $_REQUEST['category_id']
583 575
                     );
584 576
 
585
-                    $accumulateScormTime = isset($_REQUEST['accumulate_scorm_time']) ? $_REQUEST['accumulate_scorm_time'] : 'true';
586
-                    $_SESSION['oLP']->setAccumulateScormTime($accumulateScormTime);
577
+                    if (is_numeric($new_lp_id)) {
578
+                        // TODO: Maybe create a first directory directly to avoid bugging the user with useless queries
579
+                        $_SESSION['oLP'] = new learnpath(
580
+                            api_get_course_id(),
581
+                            $new_lp_id,
582
+                            api_get_user_id()
583
+                        );
587 584
 
588
-                    $url = api_get_self().'?action=add_item&type=step&lp_id='.intval($new_lp_id).'&'.api_get_cidreq();
589
-                    header("Location: $url&isStudentView=false");
590
-                    exit;
585
+                        $accumulateScormTime = isset($_REQUEST['accumulate_scorm_time']) ? $_REQUEST['accumulate_scorm_time'] : 'true';
586
+                        $_SESSION['oLP']->setAccumulateScormTime($accumulateScormTime);
587
+
588
+                        $url = api_get_self().'?action=add_item&type=step&lp_id='.intval($new_lp_id).'&'.api_get_cidreq();
589
+                        header("Location: $url&isStudentView=false");
590
+                        exit;
591
+                    }
591 592
                 }
593
+            } else {
594
+                require 'lp_add.php';
592 595
             }
593
-        } else {
594
-            require 'lp_add.php';
595
-        }
596
-        break;
597
-    case 'admin_view':
598
-        if (!$is_allowed_to_edit) {
599
-            api_not_allowed(true);
600
-        }
601
-        if (!$lp_found) {
602
-            error_log('New LP - No learnpath given for admin_view', 0);
603
-            require 'lp_list.php';
604
-        } else {
605
-            $_SESSION['refresh'] = 1;
606
-            require 'lp_admin_view.php';
607
-        }
608
-        break;
609
-    case 'auto_launch':
610
-        if (api_get_course_setting('enable_lp_auto_launch') == 1) { //Redirect to a specific LP
596
+            break;
597
+        case 'admin_view':
611 598
             if (!$is_allowed_to_edit) {
612 599
                 api_not_allowed(true);
613 600
             }
614 601
             if (!$lp_found) {
615
-                error_log('New LP - No learnpath given for set_autolaunch', 0);
602
+                error_log('New LP - No learnpath given for admin_view', 0);
616 603
                 require 'lp_list.php';
604
+            } else {
605
+                $_SESSION['refresh'] = 1;
606
+                require 'lp_admin_view.php';
617 607
             }
618
-            else {
619
-                $_SESSION['oLP']->set_autolaunch($_GET['lp_id'], $_GET['status']);
608
+            break;
609
+        case 'auto_launch':
610
+            if (api_get_course_setting('enable_lp_auto_launch') == 1) { //Redirect to a specific LP
611
+                if (!$is_allowed_to_edit) {
612
+                    api_not_allowed(true);
613
+                }
614
+                if (!$lp_found) {
615
+                    error_log('New LP - No learnpath given for set_autolaunch', 0);
616
+                    require 'lp_list.php';
617
+                }
618
+                else {
619
+                    $_SESSION['oLP']->set_autolaunch($_GET['lp_id'], $_GET['status']);
620
+                    require 'lp_list.php';
621
+                    exit;
622
+                }
623
+            }
624
+            break;
625
+        case 'build':
626
+            if (!$is_allowed_to_edit) {
627
+                api_not_allowed(true);
628
+            }
629
+            if (!$lp_found) {
630
+                error_log('New LP - No learnpath given for build', 0);
620 631
                 require 'lp_list.php';
632
+            } else {
633
+                $_SESSION['refresh'] = 1;
634
+                //require 'lp_build.php';
635
+                $url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_SESSION['oLP']->lp_id).'&'.api_get_cidreq();
636
+                header('Location: '.$url);
621 637
                 exit;
622 638
             }
623
-        }
624
-        break;
625
-    case 'build':
626
-        if (!$is_allowed_to_edit) {
627
-            api_not_allowed(true);
628
-        }
629
-        if (!$lp_found) {
630
-            error_log('New LP - No learnpath given for build', 0);
631
-            require 'lp_list.php';
632
-        } else {
633
-            $_SESSION['refresh'] = 1;
634
-            //require 'lp_build.php';
635
-            $url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_SESSION['oLP']->lp_id).'&'.api_get_cidreq();
636
-            header('Location: '.$url);
637
-            exit;
638
-        }
639
-        break;
640
-    case 'edit_item':
641
-        if (!$is_allowed_to_edit) {
642
-            api_not_allowed(true);
643
-        }
644
-        if (!$lp_found) {
645
-            error_log('New LP - No learnpath given for edit item', 0);
646
-            require 'lp_list.php';
647
-        } else {
648
-            $_SESSION['refresh'] = 1;
649
-            if (isset($_POST['submit_button']) && !empty($post_title)) {
650
-                //Updating the lp.modified_on
651
-                $_SESSION['oLP']->set_modified_on();
639
+            break;
640
+        case 'edit_item':
641
+            if (!$is_allowed_to_edit) {
642
+                api_not_allowed(true);
643
+            }
644
+            if (!$lp_found) {
645
+                error_log('New LP - No learnpath given for edit item', 0);
646
+                require 'lp_list.php';
647
+            } else {
648
+                $_SESSION['refresh'] = 1;
649
+                if (isset($_POST['submit_button']) && !empty($post_title)) {
650
+                    //Updating the lp.modified_on
651
+                    $_SESSION['oLP']->set_modified_on();
652 652
 
653
-                // TODO: mp3 edit
654
-                $audio = array();
655
-                if (isset($_FILES['mp3'])) {
656
-                    $audio = $_FILES['mp3'];
657
-                }
653
+                    // TODO: mp3 edit
654
+                    $audio = array();
655
+                    if (isset($_FILES['mp3'])) {
656
+                        $audio = $_FILES['mp3'];
657
+                    }
658 658
 
659
-                $description = isset($_POST['description']) ? $_POST['description'] : '';
660
-                $prerequisites = isset($_POST['prerequisites']) ? $_POST['prerequisites'] : '';
661
-                $maxTimeAllowed = isset($_POST['maxTimeAllowed']) ? $_POST['maxTimeAllowed'] : '';
662
-                $url = isset($_POST['url']) ? $_POST['url'] : '';
663
-
664
-                $_SESSION['oLP']->edit_item(
665
-                    $_REQUEST['id'],
666
-                    $_POST['parent'],
667
-                    $_POST['previous'],
668
-                    $post_title,
669
-                    $description,
670
-                    $prerequisites,
671
-                    $audio,
672
-                    $maxTimeAllowed,
673
-                    $url
674
-                );
659
+                    $description = isset($_POST['description']) ? $_POST['description'] : '';
660
+                    $prerequisites = isset($_POST['prerequisites']) ? $_POST['prerequisites'] : '';
661
+                    $maxTimeAllowed = isset($_POST['maxTimeAllowed']) ? $_POST['maxTimeAllowed'] : '';
662
+                    $url = isset($_POST['url']) ? $_POST['url'] : '';
663
+
664
+                    $_SESSION['oLP']->edit_item(
665
+                        $_REQUEST['id'],
666
+                        $_POST['parent'],
667
+                        $_POST['previous'],
668
+                        $post_title,
669
+                        $description,
670
+                        $prerequisites,
671
+                        $audio,
672
+                        $maxTimeAllowed,
673
+                        $url
674
+                    );
675 675
 
676
-                if (isset($_POST['content_lp'])) {
677
-                    $_SESSION['oLP']->edit_document($_course);
678
-                }
679
-                $is_success = true;
676
+                    if (isset($_POST['content_lp'])) {
677
+                        $_SESSION['oLP']->edit_document($_course);
678
+                    }
679
+                    $is_success = true;
680 680
 
681
-                Display::addFlash(Display::return_message(get_lang('Updated')));
681
+                    Display::addFlash(Display::return_message(get_lang('Updated')));
682 682
 
683
-                $url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_SESSION['oLP']->lp_id).'&'.api_get_cidreq();
684
-                header('Location: '.$url);
685
-                exit;
683
+                    $url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_SESSION['oLP']->lp_id).'&'.api_get_cidreq();
684
+                    header('Location: '.$url);
685
+                    exit;
686
+                }
687
+                if (isset($_GET['view']) && $_GET['view'] == 'build') {
688
+                    require 'lp_edit_item.php';
689
+                } else {
690
+                    require 'lp_admin_view.php';
691
+                }
692
+            }
693
+            break;
694
+        case 'edit_item_prereq':
695
+            if (!$is_allowed_to_edit) {
696
+                api_not_allowed(true);
686 697
             }
687
-            if (isset($_GET['view']) && $_GET['view'] == 'build') {
688
-                require 'lp_edit_item.php';
698
+            if (!$lp_found) {
699
+                error_log('New LP - No learnpath given for edit item prereq', 0);
700
+                require 'lp_list.php';
689 701
             } else {
690
-                require 'lp_admin_view.php';
702
+                if (isset($_POST['submit_button'])) {
703
+                    //Updating the lp.modified_on
704
+                    $_SESSION['oLP']->set_modified_on();
705
+                    $_SESSION['refresh'] = 1;
706
+                    $editPrerequisite = $_SESSION['oLP']->edit_item_prereq(
707
+                        $_GET['id'],
708
+                        $_POST['prerequisites'],
709
+                        $_POST['min_' . $_POST['prerequisites']],
710
+                        $_POST['max_' . $_POST['prerequisites']]
711
+                    );
712
+
713
+                    if ($editPrerequisite) {
714
+                        $is_success = true;
715
+                    }
716
+
717
+                    $url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_SESSION['oLP']->lp_id).'&'.api_get_cidreq();
718
+                    header('Location: '.$url);
719
+                    exit;
720
+                } else {
721
+                    require 'lp_edit_item_prereq.php';
722
+                }
723
+            }
724
+            break;
725
+        case 'move_item':
726
+            if (!$is_allowed_to_edit) {
727
+                api_not_allowed(true);
691 728
             }
692
-        }
693
-        break;
694
-    case 'edit_item_prereq':
695
-        if (!$is_allowed_to_edit) {
696
-            api_not_allowed(true);
697
-        }
698
-        if (!$lp_found) {
699
-            error_log('New LP - No learnpath given for edit item prereq', 0);
700
-            require 'lp_list.php';
701
-        } else {
702
-            if (isset($_POST['submit_button'])) {
703
-                //Updating the lp.modified_on
704
-                $_SESSION['oLP']->set_modified_on();
705
-                $_SESSION['refresh'] = 1;
706
-                $editPrerequisite = $_SESSION['oLP']->edit_item_prereq(
707
-                    $_GET['id'],
708
-                    $_POST['prerequisites'],
709
-                    $_POST['min_' . $_POST['prerequisites']],
710
-                    $_POST['max_' . $_POST['prerequisites']]
711
-                );
712 729
 
713
-                if ($editPrerequisite) {
730
+            if (!$lp_found) {
731
+                error_log('New LP - No learnpath given for move item', 0);
732
+                require 'lp_list.php';
733
+            } else {
734
+                $_SESSION['refresh'] = 1;
735
+                if (isset($_POST['submit_button'])) {
736
+                    //Updating the lp.modified_on
737
+                    $_SESSION['oLP']->set_modified_on();
738
+                    $_SESSION['oLP']->edit_item(
739
+                        $_GET['id'],
740
+                        $_POST['parent'],
741
+                        $_POST['previous'],
742
+                        $post_title,
743
+                        $_POST['description']
744
+                    );
714 745
                     $is_success = true;
746
+                    $url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_SESSION['oLP']->lp_id).'&'.api_get_cidreq();
747
+                    header('Location: '.$url);
715 748
                 }
716
-
717
-                $url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_SESSION['oLP']->lp_id).'&'.api_get_cidreq();
718
-                header('Location: '.$url);
719
-                exit;
749
+                if (isset($_GET['view']) && $_GET['view'] == 'build') {
750
+                    require 'lp_move_item.php';
751
+                } else {
752
+                    // Avoids weird behaviours see CT#967.
753
+                    $check = Security::check_token('get');
754
+                    if ($check) {
755
+                        $_SESSION['oLP']->move_item($_GET['id'], $_GET['direction']);
756
+                    }
757
+                    Security::clear_token();
758
+                    require 'lp_admin_view.php';
759
+                }
760
+            }
761
+            break;
762
+        case 'view_item':
763
+            if (!$is_allowed_to_edit) {
764
+                api_not_allowed(true);
765
+            }
766
+            if (!$lp_found) {
767
+                error_log('New LP - No learnpath given for view item', 0); require 'lp_list.php';
720 768
             } else {
721
-                require 'lp_edit_item_prereq.php';
769
+                $_SESSION['refresh'] = 1;
770
+                require 'lp_view_item.php';
771
+            }
772
+            break;
773
+        case 'upload':
774
+            if (!$is_allowed_to_edit) {
775
+                api_not_allowed(true);
776
+            }
777
+            $cwdir = getcwd();
778
+            require 'lp_upload.php';
779
+            // Reinit current working directory as many functions in upload change it.
780
+            chdir($cwdir);
781
+            require 'lp_list.php';
782
+            break;
783
+        case 'copy':
784
+            if (!$is_allowed_to_edit) {
785
+                api_not_allowed(true);
786
+            }
787
+
788
+            $hideScormCopyLink = api_get_setting('hide_scorm_copy_link');
789
+            if ($hideScormCopyLink === 'true') {
790
+                api_not_allowed(true);
722 791
             }
723
-        }
724
-        break;
725
-    case 'move_item':
726
-        if (!$is_allowed_to_edit) {
727
-            api_not_allowed(true);
728
-        }
729 792
 
730
-        if (!$lp_found) {
731
-            error_log('New LP - No learnpath given for move item', 0);
793
+            if (!$lp_found) {
794
+                error_log('New LP - No learnpath given for copy', 0);
795
+                require 'lp_list.php';
796
+            } else {
797
+                $_SESSION['oLP']->copy();
798
+            }
732 799
             require 'lp_list.php';
733
-        } else {
734
-            $_SESSION['refresh'] = 1;
735
-            if (isset($_POST['submit_button'])) {
736
-                //Updating the lp.modified_on
737
-                $_SESSION['oLP']->set_modified_on();
738
-                $_SESSION['oLP']->edit_item(
739
-                    $_GET['id'],
740
-                    $_POST['parent'],
741
-                    $_POST['previous'],
742
-                    $post_title,
743
-                    $_POST['description']
744
-                );
745
-                $is_success = true;
746
-                $url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_SESSION['oLP']->lp_id).'&'.api_get_cidreq();
747
-                header('Location: '.$url);
800
+            break;
801
+        case 'export':
802
+            if (!$is_allowed_to_edit) {
803
+                api_not_allowed(true);
804
+            }
805
+            $hideScormExportLink = api_get_setting('hide_scorm_export_link');
806
+            if ($hideScormExportLink === 'true') {
807
+                api_not_allowed(true);
748 808
             }
749
-            if (isset($_GET['view']) && $_GET['view'] == 'build') {
750
-                require 'lp_move_item.php';
809
+            if (!$lp_found) {
810
+                error_log('New LP - No learnpath given for export', 0);
811
+                require 'lp_list.php';
751 812
             } else {
752
-                // Avoids weird behaviours see CT#967.
753
-                $check = Security::check_token('get');
754
-                if ($check) {
755
-                    $_SESSION['oLP']->move_item($_GET['id'], $_GET['direction']);
756
-                }
757
-                Security::clear_token();
758
-                require 'lp_admin_view.php';
813
+                $_SESSION['oLP']->scorm_export();
814
+                exit();
815
+            }
816
+            break;
817
+        case 'export_to_pdf':
818
+            if (!learnpath::is_lp_visible_for_student($_SESSION['oLP']->lp_id, api_get_user_id())) {
819
+                api_not_allowed();
820
+            }
821
+            $hideScormPdfLink = api_get_setting('hide_scorm_pdf_link');
822
+            if ($hideScormPdfLink === 'true') {
823
+                api_not_allowed(true);
759 824
             }
760
-        }
761
-        break;
762
-    case 'view_item':
763
-        if (!$is_allowed_to_edit) {
764
-            api_not_allowed(true);
765
-        }
766
-        if (!$lp_found) {
767
-            error_log('New LP - No learnpath given for view item', 0); require 'lp_list.php';
768
-        } else {
769
-            $_SESSION['refresh'] = 1;
770
-            require 'lp_view_item.php';
771
-        }
772
-        break;
773
-    case 'upload':
774
-        if (!$is_allowed_to_edit) {
775
-            api_not_allowed(true);
776
-        }
777
-        $cwdir = getcwd();
778
-        require 'lp_upload.php';
779
-        // Reinit current working directory as many functions in upload change it.
780
-        chdir($cwdir);
781
-        require 'lp_list.php';
782
-        break;
783
-    case 'copy':
784
-        if (!$is_allowed_to_edit) {
785
-            api_not_allowed(true);
786
-        }
787 825
 
788
-        $hideScormCopyLink = api_get_setting('hide_scorm_copy_link');
789
-        if ($hideScormCopyLink === 'true') {
790
-            api_not_allowed(true);
791
-        }
826
+            if (!$lp_found) {
827
+                error_log('New LP - No learnpath given for export_to_pdf', 0);
828
+                require 'lp_list.php';
829
+            } else {
830
+                $result = $_SESSION['oLP']->scorm_export_to_pdf($_GET['lp_id']);
831
+                if (!$result) {
832
+                    require 'lp_list.php';
833
+                }
834
+                exit;
835
+            }
836
+            break;
837
+        case 'delete':
838
+            if (!$is_allowed_to_edit) {
839
+                api_not_allowed(true);
840
+            }
841
+            if (!$lp_found) {
842
+                error_log('New LP - No learnpath given for delete', 0);
843
+                require 'lp_list.php';
844
+            } else {
845
+                $_SESSION['refresh'] = 1;
846
+                $_SESSION['oLP']->delete(null, $_GET['lp_id'], 'remove');
847
+                Display::addFlash(Display::return_message(get_lang('Deleted')));
848
+                Session::erase('oLP');
849
+                require 'lp_list.php';
850
+            }
851
+            break;
852
+        case 'toggle_visible':
853
+            // Change lp visibility (inside lp tool).
854
+            if (!$is_allowed_to_edit) {
855
+                api_not_allowed(true);
856
+            }
792 857
 
793
-        if (!$lp_found) {
794
-            error_log('New LP - No learnpath given for copy', 0);
795
-            require 'lp_list.php';
796
-        } else {
797
-            $_SESSION['oLP']->copy();
798
-        }
799
-        require 'lp_list.php';
800
-        break;
801
-    case 'export':
802
-        if (!$is_allowed_to_edit) {
803
-            api_not_allowed(true);
804
-        }
805
-        $hideScormExportLink = api_get_setting('hide_scorm_export_link');
806
-        if ($hideScormExportLink === 'true') {
807
-            api_not_allowed(true);
808
-        }
809
-        if (!$lp_found) {
810
-            error_log('New LP - No learnpath given for export', 0);
811
-            require 'lp_list.php';
812
-        } else {
813
-            $_SESSION['oLP']->scorm_export();
814
-            exit();
815
-        }
816
-        break;
817
-    case 'export_to_pdf':
818
-        if (!learnpath::is_lp_visible_for_student($_SESSION['oLP']->lp_id, api_get_user_id())) {
819
-            api_not_allowed();
820
-        }
821
-        $hideScormPdfLink = api_get_setting('hide_scorm_pdf_link');
822
-        if ($hideScormPdfLink === 'true') {
823
-            api_not_allowed(true);
824
-        }
858
+            if (!$lp_found) {
859
+                error_log('New LP - No learnpath given for visibility', 0);
860
+                require 'lp_list.php';
861
+            } else {
862
+                learnpath::toggle_visibility($_REQUEST['lp_id'], $_REQUEST['new_status']);
863
+                require 'lp_list.php';
864
+            }
865
+            break;
866
+        case 'toggle_publish':
867
+            // Change lp published status (visibility on homepage).
868
+            if (!$is_allowed_to_edit) {
869
+                api_not_allowed(true);
870
+            }
871
+            if (!$lp_found) {
872
+                error_log('New LP - No learnpath given for publish', 0);
873
+                require 'lp_list.php';
874
+            } else {
875
+                learnpath::toggle_publish($_REQUEST['lp_id'], $_REQUEST['new_status']);
876
+                require 'lp_list.php';
877
+            }
878
+            break;
879
+        case 'move_lp_up':
880
+            // Change lp published status (visibility on homepage)
881
+            if (!$is_allowed_to_edit) {
882
+                api_not_allowed(true);
883
+            }
884
+            if (!$lp_found) {
885
+                error_log('New LP - No learnpath given for publish', 0);
886
+                require 'lp_list.php';
887
+            } else {
888
+                learnpath::move_up($_REQUEST['lp_id']);
889
+                require 'lp_list.php';
890
+            }
891
+            break;
892
+        case 'move_lp_down':
893
+            // Change lp published status (visibility on homepage)
894
+            if (!$is_allowed_to_edit) {
895
+                api_not_allowed(true);
896
+            }
897
+            if (!$lp_found) {
898
+                error_log('New LP - No learnpath given for publish', 0);
899
+                require 'lp_list.php';
900
+            } else {
901
+                learnpath::move_down($_REQUEST['lp_id']);
902
+                require 'lp_list.php';
903
+            }
904
+            break;
905
+        case 'edit':
906
+            if (!$is_allowed_to_edit) {
907
+                api_not_allowed(true);
908
+            }
825 909
 
826
-        if (!$lp_found) {
827
-            error_log('New LP - No learnpath given for export_to_pdf', 0);
828
-            require 'lp_list.php';
829
-        } else {
830
-            $result = $_SESSION['oLP']->scorm_export_to_pdf($_GET['lp_id']);
831
-            if (!$result) {
910
+            if (!$lp_found) {
911
+                error_log('New LP - No learnpath given for edit', 0);
832 912
                 require 'lp_list.php';
913
+            } else {
914
+                $_SESSION['refresh'] = 1;
915
+                require 'lp_edit.php';
833 916
             }
834
-            exit;
835
-        }
836
-        break;
837
-    case 'delete':
838
-        if (!$is_allowed_to_edit) {
839
-            api_not_allowed(true);
840
-        }
841
-        if (!$lp_found) {
842
-            error_log('New LP - No learnpath given for delete', 0);
843
-            require 'lp_list.php';
844
-        } else {
845
-            $_SESSION['refresh'] = 1;
846
-            $_SESSION['oLP']->delete(null, $_GET['lp_id'], 'remove');
847
-            Display::addFlash(Display::return_message(get_lang('Deleted')));
848
-            Session::erase('oLP');
849
-            require 'lp_list.php';
850
-        }
851
-        break;
852
-    case 'toggle_visible':
853
-        // Change lp visibility (inside lp tool).
854
-        if (!$is_allowed_to_edit) {
855
-            api_not_allowed(true);
856
-        }
917
+            break;
918
+        case 'update_lp':
919
+            if (!$is_allowed_to_edit) {
920
+                api_not_allowed(true);
921
+            }
922
+            if (!$lp_found) {
923
+                error_log('New LP - No learnpath given for edit', 0);
924
+                require 'lp_list.php';
925
+            } else {
926
+                $_SESSION['refresh'] = 1;
927
+                $lp_name = Security::remove_XSS($_REQUEST['lp_name']);
928
+                $_SESSION['oLP']->set_name($lp_name);
929
+                $author = $_REQUEST['lp_author'];
930
+                // Fixing the author name (no body or html tags).
931
+                $auth_init = stripos($author, '<p>');
932
+                if ($auth_init === false) {
933
+                    $auth_init = stripos($author, '<body>');
934
+                    $auth_end = $auth_init + stripos(substr($author, $auth_init + 6), '</body>') + 7;
935
+                    $len = $auth_end - $auth_init + 6;
936
+                } else {
937
+                    $auth_end = strripos($author, '</p>');
938
+                    $len = $auth_end - $auth_init + 4;
939
+                }
857 940
 
858
-        if (!$lp_found) {
859
-            error_log('New LP - No learnpath given for visibility', 0);
860
-            require 'lp_list.php';
861
-        } else {
862
-            learnpath::toggle_visibility($_REQUEST['lp_id'], $_REQUEST['new_status']);
863
-            require 'lp_list.php';
864
-        }
865
-        break;
866
-    case 'toggle_publish':
867
-        // Change lp published status (visibility on homepage).
868
-        if (!$is_allowed_to_edit) {
869
-            api_not_allowed(true);
870
-        }
871
-        if (!$lp_found) {
872
-            error_log('New LP - No learnpath given for publish', 0);
873
-            require 'lp_list.php';
874
-        } else {
875
-            learnpath::toggle_publish($_REQUEST['lp_id'], $_REQUEST['new_status']);
876
-            require 'lp_list.php';
877
-        }
878
-        break;
879
-    case 'move_lp_up':
880
-        // Change lp published status (visibility on homepage)
881
-        if (!$is_allowed_to_edit) {
882
-            api_not_allowed(true);
883
-        }
884
-        if (!$lp_found) {
885
-            error_log('New LP - No learnpath given for publish', 0);
886
-            require 'lp_list.php';
887
-        } else {
888
-            learnpath::move_up($_REQUEST['lp_id']);
889
-            require 'lp_list.php';
890
-        }
891
-        break;
892
-    case 'move_lp_down':
893
-        // Change lp published status (visibility on homepage)
894
-        if (!$is_allowed_to_edit) {
895
-            api_not_allowed(true);
896
-        }
897
-        if (!$lp_found) {
898
-            error_log('New LP - No learnpath given for publish', 0);
899
-            require 'lp_list.php';
900
-        } else {
901
-            learnpath::move_down($_REQUEST['lp_id']);
902
-            require 'lp_list.php';
903
-        }
904
-        break;
905
-    case 'edit':
906
-        if (!$is_allowed_to_edit) {
907
-            api_not_allowed(true);
908
-        }
941
+                $author_fixed = substr($author, $auth_init, $len);
942
+                $_SESSION['oLP']->set_author($author_fixed);
943
+                // TODO (as of Chamilo 1.8.8): Check in the future whether this field is needed.
944
+                $_SESSION['oLP']->set_encoding($_REQUEST['lp_encoding']);
909 945
 
910
-        if (!$lp_found) {
911
-            error_log('New LP - No learnpath given for edit', 0);
912
-            require 'lp_list.php';
913
-        } else {
914
-            $_SESSION['refresh'] = 1;
915
-            require 'lp_edit.php';
916
-        }
917
-        break;
918
-    case 'update_lp':
919
-        if (!$is_allowed_to_edit) {
920
-            api_not_allowed(true);
921
-        }
922
-        if (!$lp_found) {
923
-            error_log('New LP - No learnpath given for edit', 0);
924
-            require 'lp_list.php';
925
-        } else {
926
-            $_SESSION['refresh'] = 1;
927
-            $lp_name = Security::remove_XSS($_REQUEST['lp_name']);
928
-            $_SESSION['oLP']->set_name($lp_name);
929
-            $author = $_REQUEST['lp_author'];
930
-            // Fixing the author name (no body or html tags).
931
-            $auth_init = stripos($author, '<p>');
932
-            if ($auth_init === false) {
933
-                $auth_init = stripos($author, '<body>');
934
-                $auth_end = $auth_init + stripos(substr($author, $auth_init + 6), '</body>') + 7;
935
-                $len = $auth_end - $auth_init + 6;
946
+                if (isset($_REQUEST['lp_maker'])) {
947
+                    $_SESSION['oLP']->set_maker($_REQUEST['lp_maker']);
948
+                }
949
+                if (isset($_REQUEST['lp_proximity'])) {
950
+                    $_SESSION['oLP']->set_proximity($_REQUEST['lp_proximity']);
951
+                }
952
+                $_SESSION['oLP']->set_theme($_REQUEST['lp_theme']);
953
+
954
+                if (isset($_REQUEST['hide_toc_frame']) && $_REQUEST['hide_toc_frame'] == 1) {
955
+                    $hide_toc_frame = $_REQUEST['hide_toc_frame'];
956
+                } else {
957
+                    $hide_toc_frame = null;
958
+                }
959
+                $_SESSION['oLP']->set_hide_toc_frame($hide_toc_frame);
960
+                $_SESSION['oLP']->set_prerequisite($_REQUEST['prerequisites']);
961
+                $_SESSION['oLP']->set_use_max_score($_REQUEST['use_max_score']);
962
+
963
+                $subscribeUsers = isset($_REQUEST['subscribe_users']) ? 1 : 0;
964
+                $_SESSION['oLP']->setSubscribeUsers($subscribeUsers);
965
+
966
+                $accumulateScormTime = isset($_REQUEST['accumulate_scorm_time']) ? $_REQUEST['accumulate_scorm_time'] : 'true';
967
+                $_SESSION['oLP']->setAccumulateScormTime($accumulateScormTime);
968
+
969
+                if (isset($_REQUEST['activate_start_date_check']) && $_REQUEST['activate_start_date_check'] == 1) {
970
+            	    $publicated_on  = $_REQUEST['publicated_on'];
971
+                } else {
972
+            	    $publicated_on = null;
973
+                }
974
+
975
+                if (isset($_REQUEST['activate_end_date_check']) && $_REQUEST['activate_end_date_check'] == 1) {
976
+                    $expired_on = $_REQUEST['expired_on'];
977
+                } else {
978
+                    $expired_on = null;
979
+                }
980
+                $_SESSION['oLP']->setCategoryId($_REQUEST['category_id']);
981
+                $_SESSION['oLP']->set_modified_on();
982
+                $_SESSION['oLP']->set_publicated_on($publicated_on);
983
+                $_SESSION['oLP']->set_expired_on($expired_on);
984
+
985
+                if (isset($_REQUEST['remove_picture']) && $_REQUEST['remove_picture']) {
986
+                    $_SESSION['oLP']->delete_lp_image();
987
+                }
988
+
989
+                $extraFieldValue = new ExtraFieldValue('lp');
990
+                $params = array(
991
+                    'lp_id' => $_SESSION['oLP']->id
992
+                );
993
+                $extraFieldValue->saveFieldValues($_REQUEST);
994
+
995
+                if ($_FILES['lp_preview_image']['size'] > 0) {
996
+                    $_SESSION['oLP']->upload_image($_FILES['lp_preview_image']);
997
+                }
998
+
999
+                if (api_get_setting('search_enabled') === 'true') {
1000
+                    require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php';
1001
+                    $specific_fields = get_specific_field_list();
1002
+                    foreach ($specific_fields as $specific_field) {
1003
+                        $_SESSION['oLP']->set_terms_by_prefix($_REQUEST[$specific_field['code']], $specific_field['code']);
1004
+                        $new_values = explode(',', trim($_REQUEST[$specific_field['code']]));
1005
+                        if (!empty($new_values)) {
1006
+                            array_walk($new_values, 'trim');
1007
+                            delete_all_specific_field_value(
1008
+                                api_get_course_id(),
1009
+                                $specific_field['id'],
1010
+                                TOOL_LEARNPATH,
1011
+                                $_SESSION['oLP']->lp_id
1012
+                            );
1013
+
1014
+                            foreach ($new_values as $value) {
1015
+                                if (!empty($value)) {
1016
+                                    add_specific_field_value(
1017
+                                        $specific_field['id'],
1018
+                                        api_get_course_id(),
1019
+                                        TOOL_LEARNPATH,
1020
+                                        $_SESSION['oLP']->lp_id,
1021
+                                        $value
1022
+                                    );
1023
+                                }
1024
+                            }
1025
+                        }
1026
+                    }
1027
+                }
1028
+                Display::addFlash(Display::return_message(get_lang('Updated')));
1029
+                $url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_SESSION['oLP']->lp_id).'&'.api_get_cidreq();
1030
+                header('Location: '.$url);
1031
+                exit;
1032
+            }
1033
+            break;
1034
+        case 'add_sub_item': // Add an item inside a dir/chapter.
1035
+            // @todo check if this is @deprecated
1036
+            if (!$is_allowed_to_edit) {
1037
+                api_not_allowed(true);
1038
+            }
1039
+            if (!$lp_found) {
1040
+                error_log('New LP - No learnpath given for add sub item', 0);
1041
+                require 'lp_list.php';
1042
+            } else {
1043
+                $_SESSION['refresh'] = 1;
1044
+                if (!empty($_REQUEST['parent_item_id'])) {
1045
+                    $_SESSION['from_learnpath'] = 'yes';
1046
+                    $_SESSION['origintoolurl'] = 'lp_controller.php?action=admin_view&lp_id='.intval($_REQUEST['lp_id']);
1047
+                } else {
1048
+                    require 'lp_admin_view.php';
1049
+                }
1050
+            }
1051
+            break;
1052
+        case 'deleteitem':
1053
+        case 'delete_item':
1054
+            if (!$is_allowed_to_edit) {
1055
+                api_not_allowed(true);
1056
+            }
1057
+            if (!$lp_found) {
1058
+                error_log('New LP - No learnpath given for delete item', 0);
1059
+                require 'lp_list.php';
936 1060
             } else {
937
-                $auth_end = strripos($author, '</p>');
938
-                $len = $auth_end - $auth_init + 4;
1061
+                if (!empty($_REQUEST['id'])) {
1062
+                    $_SESSION['oLP']->delete_item($_REQUEST['id']);
1063
+                }
1064
+                $url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_REQUEST['lp_id']).'&'.api_get_cidreq();
1065
+                header('Location: '.$url);
1066
+                exit;
939 1067
             }
940
-
941
-            $author_fixed = substr($author, $auth_init, $len);
942
-            $_SESSION['oLP']->set_author($author_fixed);
943
-            // TODO (as of Chamilo 1.8.8): Check in the future whether this field is needed.
944
-            $_SESSION['oLP']->set_encoding($_REQUEST['lp_encoding']);
945
-
946
-            if (isset($_REQUEST['lp_maker'])) {
947
-                $_SESSION['oLP']->set_maker($_REQUEST['lp_maker']);
1068
+            break;
1069
+        case 'edititemprereq':
1070
+        case 'edit_item_prereq':
1071
+            if (!$is_allowed_to_edit) {
1072
+                api_not_allowed(true);
948 1073
             }
949
-            if (isset($_REQUEST['lp_proximity'])) {
950
-                $_SESSION['oLP']->set_proximity($_REQUEST['lp_proximity']);
1074
+            if (!$lp_found) {
1075
+                error_log('New LP - No learnpath given for edit item prereq', 0);
1076
+                require 'lp_list.php';
1077
+            } else {
1078
+                if (!empty($_REQUEST['id']) && !empty($_REQUEST['submit_item'])) {
1079
+                    $_SESSION['refresh'] = 1;
1080
+                    $_SESSION['oLP']->edit_item_prereq($_REQUEST['id'], $_REQUEST['prereq']);
1081
+                }
1082
+                require 'lp_admin_view.php';
951 1083
             }
952
-            $_SESSION['oLP']->set_theme($_REQUEST['lp_theme']);
953
-
954
-            if (isset($_REQUEST['hide_toc_frame']) && $_REQUEST['hide_toc_frame'] == 1) {
955
-                $hide_toc_frame = $_REQUEST['hide_toc_frame'];
1084
+            break;
1085
+        case 'restart':
1086
+            if (!$lp_found) {
1087
+                error_log('New LP - No learnpath given for restart', 0);
1088
+                require 'lp_list.php';
956 1089
             } else {
957
-                $hide_toc_frame = null;
1090
+                $_SESSION['oLP']->restart();
1091
+                require 'lp_view.php';
958 1092
             }
959
-            $_SESSION['oLP']->set_hide_toc_frame($hide_toc_frame);
960
-            $_SESSION['oLP']->set_prerequisite($_REQUEST['prerequisites']);
961
-            $_SESSION['oLP']->set_use_max_score($_REQUEST['use_max_score']);
962
-
963
-            $subscribeUsers = isset($_REQUEST['subscribe_users']) ? 1 : 0;
964
-            $_SESSION['oLP']->setSubscribeUsers($subscribeUsers);
965
-
966
-            $accumulateScormTime = isset($_REQUEST['accumulate_scorm_time']) ? $_REQUEST['accumulate_scorm_time'] : 'true';
967
-            $_SESSION['oLP']->setAccumulateScormTime($accumulateScormTime);
968
-
969
-            if (isset($_REQUEST['activate_start_date_check']) && $_REQUEST['activate_start_date_check'] == 1) {
970
-            	$publicated_on  = $_REQUEST['publicated_on'];
1093
+            break;
1094
+        case 'last':
1095
+            if (!$lp_found) {
1096
+                error_log('New LP - No learnpath given for last', 0);
1097
+                require 'lp_list.php';
971 1098
             } else {
972
-            	$publicated_on = null;
1099
+                $_SESSION['oLP']->last();
1100
+                require 'lp_view.php';
973 1101
             }
974
-
975
-            if (isset($_REQUEST['activate_end_date_check']) && $_REQUEST['activate_end_date_check'] == 1) {
976
-                $expired_on = $_REQUEST['expired_on'];
1102
+            break;
1103
+        case 'first':
1104
+            if (!$lp_found) {
1105
+                error_log('New LP - No learnpath given for first', 0);
1106
+                require 'lp_list.php';
977 1107
             } else {
978
-                $expired_on = null;
1108
+                $_SESSION['oLP']->first();
1109
+                require 'lp_view.php';
979 1110
             }
980
-            $_SESSION['oLP']->setCategoryId($_REQUEST['category_id']);
981
-            $_SESSION['oLP']->set_modified_on();
982
-            $_SESSION['oLP']->set_publicated_on($publicated_on);
983
-            $_SESSION['oLP']->set_expired_on($expired_on);
984
-
985
-            if (isset($_REQUEST['remove_picture']) && $_REQUEST['remove_picture']) {
986
-                $_SESSION['oLP']->delete_lp_image();
1111
+            break;
1112
+        case 'next':
1113
+            if (!$lp_found) {
1114
+                error_log('New LP - No learnpath given for next', 0);
1115
+                require 'lp_list.php';
1116
+            } else {
1117
+                $_SESSION['oLP']->next();
1118
+                require 'lp_view.php';
987 1119
             }
988
-
989
-            $extraFieldValue = new ExtraFieldValue('lp');
990
-            $params = array(
991
-                'lp_id' => $_SESSION['oLP']->id
992
-            );
993
-            $extraFieldValue->saveFieldValues($_REQUEST);
994
-
995
-            if ($_FILES['lp_preview_image']['size'] > 0) {
996
-                $_SESSION['oLP']->upload_image($_FILES['lp_preview_image']);
1120
+            break;
1121
+        case 'previous':
1122
+            if (!$lp_found) {
1123
+                error_log('New LP - No learnpath given for previous', 0);
1124
+                require 'lp_list.php';
1125
+            } else {
1126
+                $_SESSION['oLP']->previous();
1127
+                require 'lp_view.php';
997 1128
             }
998
-
999
-            if (api_get_setting('search_enabled') === 'true') {
1000
-                require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php';
1001
-                $specific_fields = get_specific_field_list();
1002
-                foreach ($specific_fields as $specific_field) {
1003
-                    $_SESSION['oLP']->set_terms_by_prefix($_REQUEST[$specific_field['code']], $specific_field['code']);
1004
-                    $new_values = explode(',', trim($_REQUEST[$specific_field['code']]));
1005
-                    if (!empty($new_values)) {
1006
-                        array_walk($new_values, 'trim');
1007
-                        delete_all_specific_field_value(
1008
-                            api_get_course_id(),
1009
-                            $specific_field['id'],
1010
-                            TOOL_LEARNPATH,
1011
-                            $_SESSION['oLP']->lp_id
1012
-                        );
1013
-
1014
-                        foreach ($new_values as $value) {
1015
-                            if (!empty($value)) {
1016
-                                add_specific_field_value(
1017
-                                    $specific_field['id'],
1018
-                                    api_get_course_id(),
1019
-                                    TOOL_LEARNPATH,
1020
-                                    $_SESSION['oLP']->lp_id,
1021
-                                    $value
1022
-                                );
1023
-                            }
1024
-                        }
1025
-                    }
1129
+            break;
1130
+        case 'content':
1131
+            if ($debug > 0) error_log('New LP - Item id is '.intval($_GET['item_id']), 0);
1132
+            if (!$lp_found) {
1133
+                error_log('New LP - No learnpath given for content', 0);
1134
+                require 'lp_list.php';
1135
+            } else {
1136
+                if ($debug > 0) error_log('New LP - save_last()', 0);
1137
+                $_SESSION['oLP']->save_last();
1138
+                if ($debug > 0) error_log('New LP - set_current_item()', 0);
1139
+                $_SESSION['oLP']->set_current_item($_GET['item_id']);
1140
+                if ($debug > 0) error_log('New LP - start_current_item()', 0);
1141
+                $_SESSION['oLP']->start_current_item();
1142
+                require 'lp_content.php';
1143
+            }
1144
+            break;
1145
+        case 'view':
1146
+            if (!$lp_found) {
1147
+                error_log('New LP - No learnpath given for view', 0);
1148
+                require 'lp_list.php';
1149
+            } else {
1150
+                if ($debug > 0) {error_log('New LP - Trying to set current item to ' . $_REQUEST['item_id'], 0); }
1151
+                if ( !empty($_REQUEST['item_id']) ) {
1152
+                    $_SESSION['oLP']->set_current_item($_REQUEST['item_id']);
1026 1153
                 }
1154
+                require 'lp_view.php';
1027 1155
             }
1028
-            Display::addFlash(Display::return_message(get_lang('Updated')));
1029
-            $url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_SESSION['oLP']->lp_id).'&'.api_get_cidreq();
1030
-            header('Location: '.$url);
1031
-            exit;
1032
-        }
1033
-        break;
1034
-    case 'add_sub_item': // Add an item inside a dir/chapter.
1035
-        // @todo check if this is @deprecated
1036
-        if (!$is_allowed_to_edit) {
1037
-            api_not_allowed(true);
1038
-        }
1039
-        if (!$lp_found) {
1040
-            error_log('New LP - No learnpath given for add sub item', 0);
1041
-            require 'lp_list.php';
1042
-        } else {
1043
-            $_SESSION['refresh'] = 1;
1044
-            if (!empty($_REQUEST['parent_item_id'])) {
1045
-                $_SESSION['from_learnpath'] = 'yes';
1046
-                $_SESSION['origintoolurl'] = 'lp_controller.php?action=admin_view&lp_id='.intval($_REQUEST['lp_id']);
1156
+            break;
1157
+        case 'save':
1158
+            if (!$lp_found) {
1159
+                error_log('New LP - No learnpath given for save', 0);
1160
+                require 'lp_list.php';
1047 1161
             } else {
1048
-                require 'lp_admin_view.php';
1162
+                $_SESSION['oLP']->save_item();
1163
+                require 'lp_save.php';
1049 1164
             }
1050
-        }
1051
-        break;
1052
-    case 'deleteitem':
1053
-    case 'delete_item':
1054
-        if (!$is_allowed_to_edit) {
1055
-            api_not_allowed(true);
1056
-        }
1057
-        if (!$lp_found) {
1058
-            error_log('New LP - No learnpath given for delete item', 0);
1059
-            require 'lp_list.php';
1060
-        } else {
1061
-            if (!empty($_REQUEST['id'])) {
1062
-                $_SESSION['oLP']->delete_item($_REQUEST['id']);
1165
+            break;
1166
+        case 'stats':
1167
+            if (!$lp_found) {
1168
+                error_log('New LP - No learnpath given for stats', 0);
1169
+                require 'lp_list.php';
1170
+            } else {
1171
+                $_SESSION['oLP']->save_current();
1172
+                $_SESSION['oLP']->save_last();
1173
+                $output = require 'lp_stats.php';
1174
+                echo $output;
1063 1175
             }
1064
-            $url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_REQUEST['lp_id']).'&'.api_get_cidreq();
1065
-            header('Location: '.$url);
1066
-            exit;
1067
-        }
1068
-        break;
1069
-    case 'edititemprereq':
1070
-    case 'edit_item_prereq':
1071
-        if (!$is_allowed_to_edit) {
1072
-            api_not_allowed(true);
1073
-        }
1074
-        if (!$lp_found) {
1075
-            error_log('New LP - No learnpath given for edit item prereq', 0);
1076
-            require 'lp_list.php';
1077
-        } else {
1078
-            if (!empty($_REQUEST['id']) && !empty($_REQUEST['submit_item'])) {
1176
+            break;
1177
+        case 'list':
1178
+            if ($lp_found) {
1079 1179
                 $_SESSION['refresh'] = 1;
1080
-                $_SESSION['oLP']->edit_item_prereq($_REQUEST['id'], $_REQUEST['prereq']);
1180
+                $_SESSION['oLP']->save_last();
1081 1181
             }
1082
-            require 'lp_admin_view.php';
1083
-        }
1084
-        break;
1085
-    case 'restart':
1086
-        if (!$lp_found) {
1087
-            error_log('New LP - No learnpath given for restart', 0);
1088
-            require 'lp_list.php';
1089
-        } else {
1090
-            $_SESSION['oLP']->restart();
1091
-            require 'lp_view.php';
1092
-        }
1093
-        break;
1094
-    case 'last':
1095
-        if (!$lp_found) {
1096
-            error_log('New LP - No learnpath given for last', 0);
1097
-            require 'lp_list.php';
1098
-        } else {
1099
-            $_SESSION['oLP']->last();
1100
-            require 'lp_view.php';
1101
-        }
1102
-        break;
1103
-    case 'first':
1104
-        if (!$lp_found) {
1105
-            error_log('New LP - No learnpath given for first', 0);
1106
-            require 'lp_list.php';
1107
-        } else {
1108
-            $_SESSION['oLP']->first();
1109
-            require 'lp_view.php';
1110
-        }
1111
-        break;
1112
-    case 'next':
1113
-        if (!$lp_found) {
1114
-            error_log('New LP - No learnpath given for next', 0);
1115
-            require 'lp_list.php';
1116
-        } else {
1117
-            $_SESSION['oLP']->next();
1118
-            require 'lp_view.php';
1119
-        }
1120
-        break;
1121
-    case 'previous':
1122
-        if (!$lp_found) {
1123
-            error_log('New LP - No learnpath given for previous', 0);
1124
-            require 'lp_list.php';
1125
-        } else {
1126
-            $_SESSION['oLP']->previous();
1127
-            require 'lp_view.php';
1128
-        }
1129
-        break;
1130
-    case 'content':
1131
-        if ($debug > 0) error_log('New LP - Item id is '.intval($_GET['item_id']), 0);
1132
-        if (!$lp_found) {
1133
-            error_log('New LP - No learnpath given for content', 0);
1134
-            require 'lp_list.php';
1135
-        } else {
1136
-            if ($debug > 0) error_log('New LP - save_last()', 0);
1137
-            $_SESSION['oLP']->save_last();
1138
-            if ($debug > 0) error_log('New LP - set_current_item()', 0);
1139
-            $_SESSION['oLP']->set_current_item($_GET['item_id']);
1140
-            if ($debug > 0) error_log('New LP - start_current_item()', 0);
1141
-            $_SESSION['oLP']->start_current_item();
1142
-            require 'lp_content.php';
1143
-        }
1144
-        break;
1145
-    case 'view':
1146
-        if (!$lp_found) {
1147
-            error_log('New LP - No learnpath given for view', 0);
1148 1182
             require 'lp_list.php';
1149
-        } else {
1150
-            if ($debug > 0) {error_log('New LP - Trying to set current item to ' . $_REQUEST['item_id'], 0); }
1151
-            if ( !empty($_REQUEST['item_id']) ) {
1152
-                $_SESSION['oLP']->set_current_item($_REQUEST['item_id']);
1183
+            break;
1184
+        case 'mode':
1185
+            // Switch between fullscreen and embedded mode.
1186
+            $mode = $_REQUEST['mode'];
1187
+            if ($mode == 'fullscreen') {
1188
+                $_SESSION['oLP']->mode = 'fullscreen';
1189
+            } elseif ($mode == 'embedded') {
1190
+                $_SESSION['oLP']->mode = 'embedded';
1191
+            } elseif ($mode == 'embedframe') {
1192
+        	    $_SESSION['oLP']->mode = 'embedframe';
1193
+            } elseif ($mode == 'impress') {
1194
+                $_SESSION['oLP']->mode = 'impress';
1153 1195
             }
1154 1196
             require 'lp_view.php';
1155
-        }
1156
-        break;
1157
-    case 'save':
1158
-        if (!$lp_found) {
1159
-            error_log('New LP - No learnpath given for save', 0);
1160
-            require 'lp_list.php';
1161
-        } else {
1162
-            $_SESSION['oLP']->save_item();
1163
-            require 'lp_save.php';
1164
-        }
1165
-        break;
1166
-    case 'stats':
1167
-        if (!$lp_found) {
1168
-            error_log('New LP - No learnpath given for stats', 0);
1169
-            require 'lp_list.php';
1170
-        } else {
1171
-            $_SESSION['oLP']->save_current();
1172
-            $_SESSION['oLP']->save_last();
1173
-            $output = require 'lp_stats.php';
1174
-            echo $output;
1175
-        }
1176
-        break;
1177
-    case 'list':
1178
-        if ($lp_found) {
1179
-            $_SESSION['refresh'] = 1;
1180
-            $_SESSION['oLP']->save_last();
1181
-        }
1182
-        require 'lp_list.php';
1183
-        break;
1184
-    case 'mode':
1185
-        // Switch between fullscreen and embedded mode.
1186
-        $mode = $_REQUEST['mode'];
1187
-        if ($mode == 'fullscreen') {
1188
-            $_SESSION['oLP']->mode = 'fullscreen';
1189
-        } elseif ($mode == 'embedded') {
1190
-            $_SESSION['oLP']->mode = 'embedded';
1191
-        } elseif ($mode == 'embedframe') {
1192
-        	$_SESSION['oLP']->mode = 'embedframe';
1193
-        } elseif ($mode == 'impress') {
1194
-            $_SESSION['oLP']->mode = 'impress';
1195
-        }
1196
-        require 'lp_view.php';
1197
-        break;
1198
-    case 'switch_view_mode':
1197
+            break;
1198
+        case 'switch_view_mode':
1199 1199
 
1200
-        if (!$lp_found) {
1201
-            error_log('New LP - No learnpath given for switch', 0);
1200
+            if (!$lp_found) {
1201
+                error_log('New LP - No learnpath given for switch', 0);
1202
+                require 'lp_list.php';
1203
+            }
1204
+            if (Security::check_token('get')) {
1205
+                $_SESSION['refresh'] = 1;
1206
+                $_SESSION['oLP']->update_default_view_mode();
1207
+            }
1202 1208
             require 'lp_list.php';
1203
-        }
1204
-        if (Security::check_token('get')) {
1209
+            break;
1210
+        case 'switch_force_commit':
1211
+            if (!$lp_found) {
1212
+                error_log('New LP - No learnpath given for switch', 0);
1213
+                require 'lp_list.php';
1214
+            }
1205 1215
             $_SESSION['refresh'] = 1;
1206
-            $_SESSION['oLP']->update_default_view_mode();
1207
-        }
1208
-        require 'lp_list.php';
1209
-        break;
1210
-    case 'switch_force_commit':
1211
-        if (!$lp_found) {
1212
-            error_log('New LP - No learnpath given for switch', 0);
1216
+            $_SESSION['oLP']->update_default_scorm_commit();
1213 1217
             require 'lp_list.php';
1214
-        }
1215
-        $_SESSION['refresh'] = 1;
1216
-        $_SESSION['oLP']->update_default_scorm_commit();
1217
-        require 'lp_list.php';
1218
-        break;
1219
-    /* Those 2 switches have been replaced by switc_attempt_mode switch
1218
+            break;
1219
+        /* Those 2 switches have been replaced by switc_attempt_mode switch
1220 1220
     case 'switch_reinit':
1221 1221
         if (!$lp_found) { error_log('New LP - No learnpath given for switch', 0); require 'lp_list.php'; }
1222 1222
         $_SESSION['refresh'] = 1;
@@ -1236,208 +1236,208 @@  discard block
 block discarded – undo
1236 1236
 		$_SESSION['oLP']->switch_attempt_mode();
1237 1237
         require 'lp_list.php';
1238 1238
         break;
1239
-    case 'switch_scorm_debug':
1240
-        if (!$lp_found) { error_log('New LP - No learnpath given for switch', 0); require 'lp_list.php'; }
1241
-        $_SESSION['refresh'] = 1;
1242
-        $_SESSION['oLP']->update_scorm_debug();
1243
-        require 'lp_list.php';
1244
-        break;
1245
-    case 'intro_cmdAdd':
1246
-        // Add introduction section page.
1247
-        break;
1248
-    case 'js_api_refresh':
1249
-        if (!$lp_found) { error_log('New LP - No learnpath given for js_api_refresh', 0); require 'lp_message.php'; }
1250
-        if (isset($_REQUEST['item_id'])) {
1251
-            $htmlHeadXtra[] = $_SESSION['oLP']->get_js_info($_REQUEST['item_id']);
1252
-        }
1253
-        require 'lp_message.php';
1254
-        break;
1255
-    case 'return_to_course_homepage':
1256
-        if (!$lp_found) { error_log('New LP - No learnpath given for stats', 0); require 'lp_list.php'; }
1257
-        else {
1258
-            $_SESSION['oLP']->save_current();
1259
-            $_SESSION['oLP']->save_last();
1260
-            $url = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/index.php?id_session='.api_get_session_id();
1261
-            if (isset($_GET['redirectTo']) && $_GET['redirectTo'] == 'lp_list') {
1262
-                $url = 'lp_controller.php?'.api_get_cidreq();
1263
-            }
1264
-            header('location: '.$url);
1265
-            exit;
1266
-        }
1267
-        break;
1268
-    case 'search':
1269
-        /* Include the search script, it's smart enough to know when we are
1239
+        case 'switch_scorm_debug':
1240
+            if (!$lp_found) { error_log('New LP - No learnpath given for switch', 0); require 'lp_list.php'; }
1241
+            $_SESSION['refresh'] = 1;
1242
+            $_SESSION['oLP']->update_scorm_debug();
1243
+            require 'lp_list.php';
1244
+            break;
1245
+        case 'intro_cmdAdd':
1246
+            // Add introduction section page.
1247
+            break;
1248
+        case 'js_api_refresh':
1249
+            if (!$lp_found) { error_log('New LP - No learnpath given for js_api_refresh', 0); require 'lp_message.php'; }
1250
+            if (isset($_REQUEST['item_id'])) {
1251
+                $htmlHeadXtra[] = $_SESSION['oLP']->get_js_info($_REQUEST['item_id']);
1252
+            }
1253
+            require 'lp_message.php';
1254
+            break;
1255
+        case 'return_to_course_homepage':
1256
+            if (!$lp_found) { error_log('New LP - No learnpath given for stats', 0); require 'lp_list.php'; }
1257
+            else {
1258
+                $_SESSION['oLP']->save_current();
1259
+                $_SESSION['oLP']->save_last();
1260
+                $url = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/index.php?id_session='.api_get_session_id();
1261
+                if (isset($_GET['redirectTo']) && $_GET['redirectTo'] == 'lp_list') {
1262
+                    $url = 'lp_controller.php?'.api_get_cidreq();
1263
+                }
1264
+                header('location: '.$url);
1265
+                exit;
1266
+            }
1267
+            break;
1268
+        case 'search':
1269
+            /* Include the search script, it's smart enough to know when we are
1270 1270
          * searching or not.
1271 1271
          */
1272
-        require 'lp_list_search.php';
1273
-        break;
1274
-    case 'impress':
1275
-        if (!$lp_found) {
1276
-            error_log('New LP - No learnpath given for view', 0);
1277
-            require 'lp_list.php';
1278
-        } else {
1279
-            if ($debug > 0) {error_log('New LP - Trying to impress this LP item to ' . $_REQUEST['item_id'], 0); }
1280
-            if (!empty($_REQUEST['item_id']) ) {
1281
-                $_SESSION['oLP']->set_current_item($_REQUEST['item_id']);
1272
+            require 'lp_list_search.php';
1273
+            break;
1274
+        case 'impress':
1275
+            if (!$lp_found) {
1276
+                error_log('New LP - No learnpath given for view', 0);
1277
+                require 'lp_list.php';
1278
+            } else {
1279
+                if ($debug > 0) {error_log('New LP - Trying to impress this LP item to ' . $_REQUEST['item_id'], 0); }
1280
+                if (!empty($_REQUEST['item_id']) ) {
1281
+                    $_SESSION['oLP']->set_current_item($_REQUEST['item_id']);
1282
+                }
1283
+                require 'lp_impress.php';
1284
+            }
1285
+            break;
1286
+        case 'set_previous_step_as_prerequisite':
1287
+            $_SESSION['oLP']->set_previous_step_as_prerequisite_for_all_items();
1288
+            $url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_SESSION['oLP']->lp_id)."&".api_get_cidreq();
1289
+            Display::addFlash(Display::return_message(get_lang('ItemUpdated')));
1290
+            header('Location: '.$url);
1291
+            break;
1292
+        case 'clear_prerequisites':
1293
+            $_SESSION['oLP']->clear_prerequisites();
1294
+            $url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_SESSION['oLP']->lp_id)."&".api_get_cidreq();
1295
+            Display::addFlash(Display::return_message(get_lang('ItemUpdated')));
1296
+            header('Location: '.$url);
1297
+            break;
1298
+        case 'toggle_seriousgame': //activate/deactive seriousgame_mode
1299
+            if (!$is_allowed_to_edit) {
1300
+                api_not_allowed(true);
1282 1301
             }
1283
-            require 'lp_impress.php';
1284
-        }
1285
-        break;
1286
-    case 'set_previous_step_as_prerequisite':
1287
-        $_SESSION['oLP']->set_previous_step_as_prerequisite_for_all_items();
1288
-        $url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_SESSION['oLP']->lp_id)."&".api_get_cidreq();
1289
-        Display::addFlash(Display::return_message(get_lang('ItemUpdated')));
1290
-        header('Location: '.$url);
1291
-        break;
1292
-    case 'clear_prerequisites':
1293
-        $_SESSION['oLP']->clear_prerequisites();
1294
-        $url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_SESSION['oLP']->lp_id)."&".api_get_cidreq();
1295
-        Display::addFlash(Display::return_message(get_lang('ItemUpdated')));
1296
-        header('Location: '.$url);
1297
-        break;
1298
-    case 'toggle_seriousgame': //activate/deactive seriousgame_mode
1299
-        if (!$is_allowed_to_edit) {
1300
-            api_not_allowed(true);
1301
-        }
1302 1302
 
1303
-        if (!$lp_found) {
1304
-            error_log('New LP - No learnpath given for visibility');
1303
+            if (!$lp_found) {
1304
+                error_log('New LP - No learnpath given for visibility');
1305 1305
 
1306
-            require 'lp_list.php';
1307
-        }
1306
+                require 'lp_list.php';
1307
+            }
1308 1308
 
1309
-        $_SESSION['refresh'] = 1;
1310
-        $_SESSION['oLP']->set_seriousgame_mode();
1311
-        require 'lp_list.php';
1312
-        break;
1313
-    case 'create_forum':
1314
-        if (!isset($_GET['id'])) {
1309
+            $_SESSION['refresh'] = 1;
1310
+            $_SESSION['oLP']->set_seriousgame_mode();
1311
+            require 'lp_list.php';
1315 1312
             break;
1316
-        }
1317
-
1318
-        $selectedItem = null;
1319
-        foreach ($_SESSION['oLP']->items as $item) {
1320
-            if ($item->db_id == $_GET['id']) {
1321
-                $selectedItem = $item;
1313
+        case 'create_forum':
1314
+            if (!isset($_GET['id'])) {
1315
+                break;
1322 1316
             }
1323
-        }
1324
-
1325
-        if (!empty($selectedItem)) {
1326
-            $forumThread = $selectedItem->getForumThread(
1327
-                $_SESSION['oLP']->course_int_id,
1328
-                $_SESSION['oLP']->lp_session_id
1329
-            );
1330 1317
 
1331
-            if (empty($forumThread)) {
1332
-                require '../forum/forumfunction.inc.php';
1318
+            $selectedItem = null;
1319
+            foreach ($_SESSION['oLP']->items as $item) {
1320
+                if ($item->db_id == $_GET['id']) {
1321
+                    $selectedItem = $item;
1322
+                }
1323
+            }
1333 1324
 
1334
-                $forumCategory = getForumCategoryByTitle(
1335
-                    get_lang('LearningPaths'),
1325
+            if (!empty($selectedItem)) {
1326
+                $forumThread = $selectedItem->getForumThread(
1336 1327
                     $_SESSION['oLP']->course_int_id,
1337 1328
                     $_SESSION['oLP']->lp_session_id
1338 1329
                 );
1339 1330
 
1340
-                $forumCategoryId = !empty($forumCategory) ? $forumCategory['cat_id']: 0;
1341
-
1342
-                if (empty($forumCategoryId)) {
1343
-                    $forumCategoryId = store_forumcategory(
1344
-                        [
1345
-                            'lp_id' => 0,
1346
-                            'forum_category_title' => get_lang('LearningPaths'),
1347
-                            'forum_category_comment' => null
1348
-                        ],
1349
-                        [],
1350
-                        false
1351
-                    );
1352
-                }
1331
+                if (empty($forumThread)) {
1332
+                    require '../forum/forumfunction.inc.php';
1353 1333
 
1354
-                if (!empty($forumCategoryId)) {
1355
-                    $forum = $_SESSION['oLP']->getForum(
1334
+                    $forumCategory = getForumCategoryByTitle(
1335
+                        get_lang('LearningPaths'),
1336
+                        $_SESSION['oLP']->course_int_id,
1356 1337
                         $_SESSION['oLP']->lp_session_id
1357 1338
                     );
1358 1339
 
1359
-                    $forumId = !empty($forum) ? $forum['forum_id'] : 0;
1360
-
1361
-                    if (empty($forumId)) {
1362
-                        $forumId = $_SESSION['oLP']->createForum($forumCategoryId);
1340
+                    $forumCategoryId = !empty($forumCategory) ? $forumCategory['cat_id']: 0;
1341
+
1342
+                    if (empty($forumCategoryId)) {
1343
+                        $forumCategoryId = store_forumcategory(
1344
+                            [
1345
+                                'lp_id' => 0,
1346
+                                'forum_category_title' => get_lang('LearningPaths'),
1347
+                                'forum_category_comment' => null
1348
+                            ],
1349
+                            [],
1350
+                            false
1351
+                        );
1363 1352
                     }
1364 1353
 
1365
-                    if (!empty($forumId)) {
1366
-                        $selectedItem->createForumThread($forumId);
1354
+                    if (!empty($forumCategoryId)) {
1355
+                        $forum = $_SESSION['oLP']->getForum(
1356
+                            $_SESSION['oLP']->lp_session_id
1357
+                        );
1358
+
1359
+                        $forumId = !empty($forum) ? $forum['forum_id'] : 0;
1360
+
1361
+                        if (empty($forumId)) {
1362
+                            $forumId = $_SESSION['oLP']->createForum($forumCategoryId);
1363
+                        }
1364
+
1365
+                        if (!empty($forumId)) {
1366
+                            $selectedItem->createForumThread($forumId);
1367
+                        }
1367 1368
                     }
1368 1369
                 }
1369 1370
             }
1370
-        }
1371 1371
 
1372
-        header('Location:' . api_get_self() . '?' . http_build_query([
1373
-            'action' => 'add_item',
1374
-            'type' => 'step',
1375
-            'lp_id' => $_SESSION['oLP']->lp_id
1376
-        ]));
1372
+            header('Location:' . api_get_self() . '?' . http_build_query([
1373
+                'action' => 'add_item',
1374
+                'type' => 'step',
1375
+                'lp_id' => $_SESSION['oLP']->lp_id
1376
+            ]));
1377 1377
 
1378
-        break;
1379
-    case 'report':
1380
-        require 'lp_report.php';
1381
-        break;
1382
-    case 'dissociate_forum':
1383
-        if (!isset($_GET['id'])) {
1384 1378
             break;
1385
-        }
1379
+        case 'report':
1380
+            require 'lp_report.php';
1381
+            break;
1382
+        case 'dissociate_forum':
1383
+            if (!isset($_GET['id'])) {
1384
+                break;
1385
+            }
1386 1386
 
1387
-        $selectedItem = null;
1388
-        foreach ($_SESSION['oLP']->items as $item) {
1389
-            if ($item->db_id != $_GET['id']) {
1390
-                continue;
1387
+            $selectedItem = null;
1388
+            foreach ($_SESSION['oLP']->items as $item) {
1389
+                if ($item->db_id != $_GET['id']) {
1390
+                    continue;
1391
+                }
1392
+                $selectedItem = $item;
1391 1393
             }
1392
-            $selectedItem = $item;
1393
-        }
1394 1394
 
1395
-        if (!empty($selectedItem)) {
1396
-            $forumThread = $selectedItem->getForumThread(
1397
-                $_SESSION['oLP']->course_int_id,
1398
-                $_SESSION['oLP']->lp_session_id
1399
-            );
1395
+            if (!empty($selectedItem)) {
1396
+                $forumThread = $selectedItem->getForumThread(
1397
+                    $_SESSION['oLP']->course_int_id,
1398
+                    $_SESSION['oLP']->lp_session_id
1399
+                );
1400 1400
 
1401
-            if (!empty($forumThread)) {
1402
-                $dissociated = $selectedItem->dissociateForumThread($forumThread['iid']);
1401
+                if (!empty($forumThread)) {
1402
+                    $dissociated = $selectedItem->dissociateForumThread($forumThread['iid']);
1403 1403
 
1404
-                if ($dissociated) {
1405
-                    Display::addFlash(
1406
-                        Display::return_message(get_lang('ForumDissociate'), 'success')
1407
-                    );
1404
+                    if ($dissociated) {
1405
+                        Display::addFlash(
1406
+                            Display::return_message(get_lang('ForumDissociate'), 'success')
1407
+                        );
1408
+                    }
1408 1409
                 }
1409 1410
             }
1410
-        }
1411 1411
 
1412
-        header('Location:' . api_get_self() . '?' . http_build_query([
1413
-            'action' => 'add_item',
1414
-            'type' => 'step',
1415
-            'lp_id' => $_SESSION['oLP']->lp_id
1416
-        ]));
1417
-        break;
1418
-    case 'add_final_item':
1419
-        if (!$lp_found) {
1420
-            Display::addFlash(
1421
-                Display::return_message(get_lang('NoLPFound'), 'error')
1422
-            );
1412
+            header('Location:' . api_get_self() . '?' . http_build_query([
1413
+                'action' => 'add_item',
1414
+                'type' => 'step',
1415
+                'lp_id' => $_SESSION['oLP']->lp_id
1416
+            ]));
1423 1417
             break;
1424
-        }
1418
+        case 'add_final_item':
1419
+            if (!$lp_found) {
1420
+                Display::addFlash(
1421
+                    Display::return_message(get_lang('NoLPFound'), 'error')
1422
+                );
1423
+                break;
1424
+            }
1425 1425
 
1426
-        $_SESSION['refresh'] = 1;
1427
-        if (!isset($_POST['submit']) || empty($post_title)) {
1428
-            break;
1429
-        }
1426
+            $_SESSION['refresh'] = 1;
1427
+            if (!isset($_POST['submit']) || empty($post_title)) {
1428
+                break;
1429
+            }
1430 1430
 
1431
-        $_SESSION['oLP']->getFinalItemForm();
1432
-        $redirectTo = api_get_self() . '?' . api_get_cidreq().'&'.http_build_query([
1433
-            'action' => 'add_item',
1434
-            'type' => 'step',
1435
-            'lp_id' => intval($_SESSION['oLP']->lp_id)
1436
-        ]);
1437
-        break;
1438
-    default:
1439
-        require 'lp_list.php';
1440
-        break;
1431
+            $_SESSION['oLP']->getFinalItemForm();
1432
+            $redirectTo = api_get_self() . '?' . api_get_cidreq().'&'.http_build_query([
1433
+                'action' => 'add_item',
1434
+                'type' => 'step',
1435
+                'lp_id' => intval($_SESSION['oLP']->lp_id)
1436
+            ]);
1437
+            break;
1438
+        default:
1439
+            require 'lp_list.php';
1440
+            break;
1441 1441
 }
1442 1442
 
1443 1443
 if (!empty($_SESSION['oLP'])) {
Please login to merge, or discard this patch.