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