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