@@ -171,28 +171,52 @@ discard block |
||
171 | 171 | } |
172 | 172 | |
173 | 173 | switch ($action) { |
174 | - case 'subscribe_user_with_password': |
|
175 | - $courses_controller->subscribe_user( |
|
176 | - isset($_POST['subscribe_user_with_password']) ? $_POST['subscribe_user_with_password'] : '', |
|
177 | - isset($_POST['search_term']) ? $_POST['search_term'] : '', |
|
178 | - isset($_POST['category_code']) ? $_POST['category_code'] : '' |
|
179 | - ); |
|
180 | - break; |
|
181 | - case 'createcoursecategory': |
|
182 | - $courses_controller->categories_list($action); |
|
183 | - break; |
|
184 | - case 'deletecoursecategory': |
|
185 | - $courses_controller->courses_list($action); |
|
186 | - break; |
|
187 | - case 'sortmycourses': |
|
188 | - $courses_controller->courses_list($action); |
|
189 | - break; |
|
190 | - case 'subscribe': |
|
191 | - if (!$user_can_view_page) { |
|
192 | - api_not_allowed(true); |
|
193 | - } |
|
194 | - |
|
195 | - if (!CoursesAndSessionsCatalog::is(CATALOG_SESSIONS)) { |
|
174 | + case 'subscribe_user_with_password': |
|
175 | + $courses_controller->subscribe_user( |
|
176 | + isset($_POST['subscribe_user_with_password']) ? $_POST['subscribe_user_with_password'] : '', |
|
177 | + isset($_POST['search_term']) ? $_POST['search_term'] : '', |
|
178 | + isset($_POST['category_code']) ? $_POST['category_code'] : '' |
|
179 | + ); |
|
180 | + break; |
|
181 | + case 'createcoursecategory': |
|
182 | + $courses_controller->categories_list($action); |
|
183 | + break; |
|
184 | + case 'deletecoursecategory': |
|
185 | + $courses_controller->courses_list($action); |
|
186 | + break; |
|
187 | + case 'sortmycourses': |
|
188 | + $courses_controller->courses_list($action); |
|
189 | + break; |
|
190 | + case 'subscribe': |
|
191 | + if (!$user_can_view_page) { |
|
192 | + api_not_allowed(true); |
|
193 | + } |
|
194 | + |
|
195 | + if (!CoursesAndSessionsCatalog::is(CATALOG_SESSIONS)) { |
|
196 | + $courses_controller->courses_categories( |
|
197 | + $action, |
|
198 | + $categoryCode, |
|
199 | + null, |
|
200 | + null, |
|
201 | + null, |
|
202 | + $limit |
|
203 | + ); |
|
204 | + } else { |
|
205 | + header('Location: ' . api_get_self()); |
|
206 | + } |
|
207 | + break; |
|
208 | + case 'display_random_courses': |
|
209 | + if (!$user_can_view_page) { |
|
210 | + api_not_allowed(true); |
|
211 | + } |
|
212 | + |
|
213 | + $courses_controller->courses_categories($action); |
|
214 | + break; |
|
215 | + case 'display_courses': |
|
216 | + if (!$user_can_view_page) { |
|
217 | + api_not_allowed(true); |
|
218 | + } |
|
219 | + |
|
196 | 220 | $courses_controller->courses_categories( |
197 | 221 | $action, |
198 | 222 | $categoryCode, |
@@ -201,126 +225,102 @@ discard block |
||
201 | 225 | null, |
202 | 226 | $limit |
203 | 227 | ); |
204 | - } else { |
|
205 | - header('Location: ' . api_get_self()); |
|
206 | - } |
|
207 | - break; |
|
208 | - case 'display_random_courses': |
|
209 | - if (!$user_can_view_page) { |
|
210 | - api_not_allowed(true); |
|
211 | - } |
|
212 | - |
|
213 | - $courses_controller->courses_categories($action); |
|
214 | - break; |
|
215 | - case 'display_courses': |
|
216 | - if (!$user_can_view_page) { |
|
217 | - api_not_allowed(true); |
|
218 | - } |
|
219 | - |
|
220 | - $courses_controller->courses_categories( |
|
221 | - $action, |
|
222 | - $categoryCode, |
|
223 | - null, |
|
224 | - null, |
|
225 | - null, |
|
226 | - $limit |
|
227 | - ); |
|
228 | - break; |
|
229 | - case 'display_sessions': |
|
230 | - if (!$user_can_view_page) { |
|
231 | - api_not_allowed(true); |
|
232 | - } |
|
233 | - |
|
234 | - $courses_controller->sessionsList($action, $nameTools, $limit); |
|
235 | - break; |
|
236 | - case 'subscribe_to_session': |
|
237 | - if (!$user_can_view_page) { |
|
238 | - api_not_allowed(true); |
|
239 | - } |
|
240 | - |
|
241 | - $userId = api_get_user_id(); |
|
242 | - $confirmed = isset($_GET['confirm']); |
|
243 | - $sessionId = intval($_GET['session_id']); |
|
244 | - |
|
245 | - if (empty($userId)) { |
|
246 | - api_not_allowed(); |
|
247 | - exit; |
|
248 | - } |
|
249 | - |
|
250 | - if (!$confirmed) { |
|
251 | - $template = new Template(null, false, false, false, false, false); |
|
252 | - $template->assign('session_id', $sessionId); |
|
253 | - |
|
254 | - $layout = $template->get_template('auth/confirm_session_subscription.tpl'); |
|
255 | - |
|
256 | - echo $template->fetch($layout); |
|
257 | - exit; |
|
258 | - } |
|
259 | - |
|
260 | - $registrationAllowed = api_get_setting('catalog_allow_session_auto_subscription'); |
|
261 | - if ($registrationAllowed === 'true') { |
|
262 | - $entityManager = Database::getManager(); |
|
263 | - $repository = $entityManager->getRepository('ChamiloCoreBundle:SequenceResource'); |
|
264 | - |
|
265 | - $sequences = $repository->getRequirements( |
|
266 | - $sessionId, |
|
267 | - SequenceResource::SESSION_TYPE |
|
268 | - ); |
|
228 | + break; |
|
229 | + case 'display_sessions': |
|
230 | + if (!$user_can_view_page) { |
|
231 | + api_not_allowed(true); |
|
232 | + } |
|
233 | + |
|
234 | + $courses_controller->sessionsList($action, $nameTools, $limit); |
|
235 | + break; |
|
236 | + case 'subscribe_to_session': |
|
237 | + if (!$user_can_view_page) { |
|
238 | + api_not_allowed(true); |
|
239 | + } |
|
240 | + |
|
241 | + $userId = api_get_user_id(); |
|
242 | + $confirmed = isset($_GET['confirm']); |
|
243 | + $sessionId = intval($_GET['session_id']); |
|
269 | 244 | |
270 | - if (count($sequences) > 0) { |
|
271 | - $requirementsData = SequenceResourceManager::checkRequirementsForUser( |
|
272 | - $sequences, |
|
273 | - SequenceResource::SESSION_TYPE, |
|
274 | - $userId |
|
245 | + if (empty($userId)) { |
|
246 | + api_not_allowed(); |
|
247 | + exit; |
|
248 | + } |
|
249 | + |
|
250 | + if (!$confirmed) { |
|
251 | + $template = new Template(null, false, false, false, false, false); |
|
252 | + $template->assign('session_id', $sessionId); |
|
253 | + |
|
254 | + $layout = $template->get_template('auth/confirm_session_subscription.tpl'); |
|
255 | + |
|
256 | + echo $template->fetch($layout); |
|
257 | + exit; |
|
258 | + } |
|
259 | + |
|
260 | + $registrationAllowed = api_get_setting('catalog_allow_session_auto_subscription'); |
|
261 | + if ($registrationAllowed === 'true') { |
|
262 | + $entityManager = Database::getManager(); |
|
263 | + $repository = $entityManager->getRepository('ChamiloCoreBundle:SequenceResource'); |
|
264 | + |
|
265 | + $sequences = $repository->getRequirements( |
|
266 | + $sessionId, |
|
267 | + SequenceResource::SESSION_TYPE |
|
275 | 268 | ); |
276 | 269 | |
277 | - $continueWithSubscription = SequenceResourceManager::checkSequenceAreCompleted($requirementsData); |
|
270 | + if (count($sequences) > 0) { |
|
271 | + $requirementsData = SequenceResourceManager::checkRequirementsForUser( |
|
272 | + $sequences, |
|
273 | + SequenceResource::SESSION_TYPE, |
|
274 | + $userId |
|
275 | + ); |
|
276 | + |
|
277 | + $continueWithSubscription = SequenceResourceManager::checkSequenceAreCompleted($requirementsData); |
|
278 | 278 | |
279 | - if (!$continueWithSubscription) { |
|
280 | - header('Location: ' . api_get_path(WEB_CODE_PATH) . 'auth/courses.php'); |
|
281 | - exit; |
|
279 | + if (!$continueWithSubscription) { |
|
280 | + header('Location: ' . api_get_path(WEB_CODE_PATH) . 'auth/courses.php'); |
|
281 | + exit; |
|
282 | + } |
|
282 | 283 | } |
283 | - } |
|
284 | 284 | |
285 | - SessionManager::suscribe_users_to_session( |
|
286 | - $_GET['session_id'], |
|
287 | - array($userId), |
|
288 | - SESSION_VISIBLE_READ_ONLY, |
|
289 | - false |
|
290 | - ); |
|
285 | + SessionManager::suscribe_users_to_session( |
|
286 | + $_GET['session_id'], |
|
287 | + array($userId), |
|
288 | + SESSION_VISIBLE_READ_ONLY, |
|
289 | + false |
|
290 | + ); |
|
291 | 291 | |
292 | - $coursesList = SessionManager::get_course_list_by_session_id($_GET['session_id']); |
|
293 | - $count = count($coursesList); |
|
294 | - $url = ''; |
|
295 | - |
|
296 | - if ($count <= 0) { |
|
297 | - // no course in session -> return to catalog |
|
298 | - $url = api_get_path(WEB_CODE_PATH) . 'auth/courses.php'; |
|
299 | - } elseif ($count == 1) { |
|
300 | - // only one course, so redirect directly to this course |
|
301 | - foreach ($coursesList as $course) { |
|
302 | - $url = api_get_path(WEB_COURSE_PATH) . $course['directory'] . '/index.php?id_session=' . intval($_GET['session_id']); |
|
292 | + $coursesList = SessionManager::get_course_list_by_session_id($_GET['session_id']); |
|
293 | + $count = count($coursesList); |
|
294 | + $url = ''; |
|
295 | + |
|
296 | + if ($count <= 0) { |
|
297 | + // no course in session -> return to catalog |
|
298 | + $url = api_get_path(WEB_CODE_PATH) . 'auth/courses.php'; |
|
299 | + } elseif ($count == 1) { |
|
300 | + // only one course, so redirect directly to this course |
|
301 | + foreach ($coursesList as $course) { |
|
302 | + $url = api_get_path(WEB_COURSE_PATH) . $course['directory'] . '/index.php?id_session=' . intval($_GET['session_id']); |
|
303 | + } |
|
304 | + } else { |
|
305 | + $url = api_get_path(WEB_CODE_PATH) . 'session/index.php?session_id=' . intval($_GET['session_id']); |
|
303 | 306 | } |
304 | - } else { |
|
305 | - $url = api_get_path(WEB_CODE_PATH) . 'session/index.php?session_id=' . intval($_GET['session_id']); |
|
307 | + header('Location: ' . $url); |
|
308 | + exit; |
|
306 | 309 | } |
307 | - header('Location: ' . $url); |
|
308 | - exit; |
|
309 | - } |
|
310 | - //else show error message? |
|
311 | - break; |
|
312 | - case 'search_tag': |
|
313 | - if (!$user_can_view_page) { |
|
314 | - api_not_allowed(true); |
|
315 | - } |
|
316 | - |
|
317 | - $courses_controller->sessionsListByCoursesTag($limit); |
|
318 | - break; |
|
319 | - case 'search_session': |
|
320 | - if (!$user_can_view_page) { |
|
321 | - api_not_allowed(true); |
|
322 | - } |
|
323 | - |
|
324 | - $courses_controller->sessionListBySearch($limit); |
|
325 | - break; |
|
310 | + //else show error message? |
|
311 | + break; |
|
312 | + case 'search_tag': |
|
313 | + if (!$user_can_view_page) { |
|
314 | + api_not_allowed(true); |
|
315 | + } |
|
316 | + |
|
317 | + $courses_controller->sessionsListByCoursesTag($limit); |
|
318 | + break; |
|
319 | + case 'search_session': |
|
320 | + if (!$user_can_view_page) { |
|
321 | + api_not_allowed(true); |
|
322 | + } |
|
323 | + |
|
324 | + $courses_controller->sessionListBySearch($limit); |
|
325 | + break; |
|
326 | 326 | } |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | |
69 | 69 | $parentIdCondition = " AND (t1.parent_id IS NULL OR t1.parent_id = '' )"; |
70 | 70 | if (!empty($category)) { |
71 | - $parentIdCondition = " AND t1.parent_id = '$category' "; |
|
71 | + $parentIdCondition = " AND t1.parent_id = '$category' "; |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | $sql = "SELECT |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | |
100 | 100 | $categories = Database::store_result($result); |
101 | 101 | foreach ($categories as $category) { |
102 | - $category['nbr_courses'] = 1; |
|
102 | + $category['nbr_courses'] = 1; |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | return $categories; |
@@ -196,13 +196,13 @@ discard block |
||
196 | 196 | if ($row = Database::fetch_array($result)) { |
197 | 197 | if (!empty($row['parent_id'])) { |
198 | 198 | Database::query("UPDATE $tbl_course SET category_code = '".$row['parent_id']."' WHERE category_code='$node'"); |
199 | - Database::query("UPDATE $tbl_category SET parent_id='" . $row['parent_id'] . "' WHERE parent_id='$node'"); |
|
199 | + Database::query("UPDATE $tbl_category SET parent_id='".$row['parent_id']."' WHERE parent_id='$node'"); |
|
200 | 200 | } else { |
201 | 201 | Database::query("UPDATE $tbl_course SET category_code='' WHERE category_code='$node'"); |
202 | 202 | Database::query("UPDATE $tbl_category SET parent_id=NULL WHERE parent_id='$node'"); |
203 | 203 | } |
204 | 204 | |
205 | - Database::query("UPDATE $tbl_category SET tree_pos=tree_pos-1 WHERE tree_pos > '" . $row['tree_pos'] . "'"); |
|
205 | + Database::query("UPDATE $tbl_category SET tree_pos=tree_pos-1 WHERE tree_pos > '".$row['tree_pos']."'"); |
|
206 | 206 | Database::query("DELETE FROM $tbl_category WHERE code='$node'"); |
207 | 207 | |
208 | 208 | if (!empty($row['parent_id'])) { |
@@ -291,13 +291,13 @@ discard block |
||
291 | 291 | } |
292 | 292 | |
293 | 293 | $sql = "UPDATE $tbl_category |
294 | - SET tree_pos ='" . $row['tree_pos'] . "' |
|
294 | + SET tree_pos ='".$row['tree_pos']."' |
|
295 | 295 | WHERE code='$code'"; |
296 | 296 | Database::query($sql); |
297 | 297 | |
298 | 298 | $sql = "UPDATE $tbl_category |
299 | 299 | SET tree_pos = '$tree_pos' |
300 | - WHERE code= '" . $row['code'] . "'"; |
|
300 | + WHERE code= '".$row['code']."'"; |
|
301 | 301 | Database::query($sql); |
302 | 302 | |
303 | 303 | return true; |
@@ -423,12 +423,12 @@ discard block |
||
423 | 423 | |
424 | 424 | $editIcon = Display::return_icon('edit.png', get_lang('EditNode'), null, ICON_SIZE_SMALL); |
425 | 425 | $deleteIcon = Display::return_icon('delete.png', get_lang('DeleteNode'), null, ICON_SIZE_SMALL); |
426 | - $moveIcon = Display::return_icon('up.png', get_lang('UpInSameLevel'), null, ICON_SIZE_SMALL); |
|
426 | + $moveIcon = Display::return_icon('up.png', get_lang('UpInSameLevel'), null, ICON_SIZE_SMALL); |
|
427 | 427 | |
428 | 428 | foreach ($categories as $category) { |
429 | 429 | |
430 | 430 | $editUrl = $mainUrl.'&id='.$category['code'].'&action=edit'; |
431 | - $moveUrl = $mainUrl.'&id='.$category['code'].'&action=moveUp&tree_pos='.$category['tree_pos']; |
|
431 | + $moveUrl = $mainUrl.'&id='.$category['code'].'&action=moveUp&tree_pos='.$category['tree_pos']; |
|
432 | 432 | $deleteUrl = $mainUrl.'&id='.$category['code'].'&action=delete'; |
433 | 433 | |
434 | 434 | $actions = Display::url($editIcon, $editUrl).Display::url($moveIcon, $moveUrl).Display::url($deleteIcon, $deleteUrl); |
@@ -562,12 +562,12 @@ discard block |
||
562 | 562 | |
563 | 563 | $count_courses = countCoursesInCategory(); |
564 | 564 | |
565 | - $categories[0][count($categories[0])+1] = array( |
|
565 | + $categories[0][count($categories[0]) + 1] = array( |
|
566 | 566 | 'id' =>0, |
567 | 567 | 'name' => get_lang('None'), |
568 | 568 | 'code' => 'NONE', |
569 | 569 | 'parent_id' => null, |
570 | - 'tree_pos' => $row['tree_pos']+1, |
|
570 | + 'tree_pos' => $row['tree_pos'] + 1, |
|
571 | 571 | 'children_count' => 0, |
572 | 572 | 'auth_course_child' => true, |
573 | 573 | 'auth_cat_child' => true, |
@@ -594,7 +594,7 @@ discard block |
||
594 | 594 | |
595 | 595 | $without_special_courses = ''; |
596 | 596 | if (!empty($specialCourseList)) { |
597 | - $without_special_courses = ' AND course.code NOT IN ("' . implode('","', $specialCourseList) . '")'; |
|
597 | + $without_special_courses = ' AND course.code NOT IN ("'.implode('","', $specialCourseList).'")'; |
|
598 | 598 | } |
599 | 599 | |
600 | 600 | $visibilityCondition = null; |
@@ -608,15 +608,15 @@ discard block |
||
608 | 608 | if ($categoryCode == 'ALL') { |
609 | 609 | // Nothing to do |
610 | 610 | } elseif ($categoryCode == 'NONE') { |
611 | - $categoryFilter = ' AND category_code = "" '; |
|
611 | + $categoryFilter = ' AND category_code = "" '; |
|
612 | 612 | } else { |
613 | - $categoryFilter = ' AND category_code = "' . $categoryCode . '" '; |
|
613 | + $categoryFilter = ' AND category_code = "'.$categoryCode.'" '; |
|
614 | 614 | } |
615 | 615 | |
616 | 616 | if (!empty($searchTerm)) { |
617 | - $searchFilter = ' AND (code LIKE "%' . $searchTerm . '%" |
|
618 | - OR title LIKE "%' . $searchTerm . '%" |
|
619 | - OR tutor_name LIKE "%' . $searchTerm . '%") '; |
|
617 | + $searchFilter = ' AND (code LIKE "%'.$searchTerm.'%" |
|
618 | + OR title LIKE "%' . $searchTerm.'%" |
|
619 | + OR tutor_name LIKE "%' . $searchTerm.'%") '; |
|
620 | 620 | } |
621 | 621 | |
622 | 622 | $sql = "SELECT * FROM $tbl_course |
@@ -668,7 +668,7 @@ discard block |
||
668 | 668 | |
669 | 669 | $without_special_courses = ''; |
670 | 670 | if (!empty($specialCourseList)) { |
671 | - $without_special_courses = ' AND course.code NOT IN ("' . implode('","', $specialCourseList) . '")'; |
|
671 | + $without_special_courses = ' AND course.code NOT IN ("'.implode('","', $specialCourseList).'")'; |
|
672 | 672 | } |
673 | 673 | $visibilityCondition = null; |
674 | 674 | $hidePrivate = api_get_setting('course_catalog_hide_private'); |
@@ -719,7 +719,7 @@ discard block |
||
719 | 719 | $id_in = null; |
720 | 720 | while (list($id) = Database::fetch_row($result)) { |
721 | 721 | if ($id_in) { |
722 | - $id_in.=",$id"; |
|
722 | + $id_in .= ",$id"; |
|
723 | 723 | } else { |
724 | 724 | $id_in = "$id"; |
725 | 725 | } |
@@ -959,7 +959,7 @@ discard block |
||
959 | 959 | if (!empty($limit) && is_array($limit)) { |
960 | 960 | $limitStart = isset($limit['start']) ? $limit['start'] : 0; |
961 | 961 | $limitLength = isset($limit['length']) ? $limit['length'] : 10; |
962 | - $limitFilter = 'LIMIT ' . $limitStart . ', ' . $limitLength; |
|
962 | + $limitFilter = 'LIMIT '.$limitStart.', '.$limitLength; |
|
963 | 963 | } |
964 | 964 | |
965 | 965 | return $limitFilter; |
@@ -1045,21 +1045,21 @@ discard block |
||
1045 | 1045 | $hiddenLinks = isset($hiddenLinks) ? Security::remove_XSS($hiddenLinksRequest) : $categoryCodeRequest; |
1046 | 1046 | |
1047 | 1047 | // Start URL with params |
1048 | - $pageUrl = api_get_self() . |
|
1049 | - '?action=' . $action . |
|
1050 | - '&category_code=' .$categoryCode. |
|
1051 | - '&hidden_links=' .$hiddenLinks. |
|
1052 | - '&pageCurrent=' . $pageCurrent . |
|
1053 | - '&pageLength=' . $pageLength |
|
1048 | + $pageUrl = api_get_self(). |
|
1049 | + '?action='.$action. |
|
1050 | + '&category_code='.$categoryCode. |
|
1051 | + '&hidden_links='.$hiddenLinks. |
|
1052 | + '&pageCurrent='.$pageCurrent. |
|
1053 | + '&pageLength='.$pageLength |
|
1054 | 1054 | ; |
1055 | 1055 | |
1056 | 1056 | switch ($action) { |
1057 | 1057 | case 'subscribe': |
1058 | 1058 | // for search |
1059 | 1059 | $pageUrl .= |
1060 | - '&search_term=' . $searchTerm . |
|
1061 | - '&search_course=1' . |
|
1062 | - '&sec_token=' . $_SESSION['sec_token']; |
|
1060 | + '&search_term='.$searchTerm. |
|
1061 | + '&search_course=1'. |
|
1062 | + '&sec_token='.$_SESSION['sec_token']; |
|
1063 | 1063 | break; |
1064 | 1064 | case 'display_courses': |
1065 | 1065 | // No break |