<?php /* For licensing terms, see /license.txt */ /** * View (MVC patter) for courses categories * @author Christian Fasanando <*****@*****.**> - Beeznest * @package chamilo.auth */ if (isset($_REQUEST['action']) && Security::remove_XSS($_REQUEST['action']) !== 'subscribe') { $stok = Security::get_token(); } else { $stok = $_SESSION['sec_token']; } $showCourses = CoursesAndSessionsCatalog::showCourses(); $showSessions = CoursesAndSessionsCatalog::showSessions(); $pageCurrent = isset($pageCurrent) ? $pageCurrent : isset($_GET['pageCurrent']) ? intval($_GET['pageCurrent']) : 1; $pageLength = isset($pageLength) ? $pageLength : isset($_GET['pageLength']) ? intval($_GET['pageLength']) : 10; $pageTotal = intval(ceil(intval($countCoursesInCategory) / $pageLength)); $cataloguePagination = $pageTotal > 1 ? CourseCategoryManager::getCatalogPagination($pageCurrent, $pageLength, $pageTotal) : ''; $search_term = isset($search_term) ? $search_term : null; if ($showSessions && isset($_POST['date'])) { $date = $_POST['date']; } else { $date = date('Y-m-d'); } $userInfo = api_get_user_info(); $code = isset($code) ? $code : null; ?> <script> $(document).ready( function() { $('.star-rating li a').on('click', function(event) {
// Access rights: anonymous users can't do anything useful here. api_block_anonymous_users(); $user_can_view_page = false; //For students if (api_get_setting('allow_students_to_browse_courses') == 'false') { $user_can_view_page = false; } else { $user_can_view_page = true; } //For teachers/admins if (api_is_platform_admin() || api_is_course_admin() || api_is_allowed_to_create_course()) { $user_can_view_page = true; } // filter actions $actions = array('sortmycourses', 'createcoursecategory', 'subscribe', 'deletecoursecategory', 'display_courses', 'display_random_courses', 'subscribe_user_with_password', 'display_sessions'); $action = CoursesAndSessionsCatalog::is(CATALOG_SESSIONS) ? 'display_sessions' : 'display_random_courses'; if (isset($_GET['action']) && in_array($_GET['action'], $actions)) { $action = Security::remove_XSS($_GET['action']); } else { // Nothing to do } $nameTools = getCourseCatalogNameTools($action); if (empty($nameTools)) { $nameTools = get_lang('CourseManagement'); } else { if (!in_array($action, array('sortmycourses', 'createcoursecategory', 'display_random_courses', 'display_courses', 'subscribe'))) { $interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH) . 'auth/courses.php', 'name' => get_lang('CourseManagement')); } if ($action == 'createcoursecategory') { $interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH) . 'auth/courses.php?action=sortmycourses', 'name' => get_lang('SortMyCourses')); }
/** * Show the Session Catalogue with filtered session by a query term * @param array $limit */ public function sessionListBySearch(array $limit) { $q = isset($_REQUEST['q']) ? Security::remove_XSS($_REQUEST['q']) : null; $hiddenLinks = isset($_GET['hidden_links']) ? intval($_GET['hidden_links']) == 1 : false; $courseUrl = CourseCategoryManager::getCourseCategoryUrl(1, $limit['length'], null, 0, 'subscribe'); $searchDate = isset($_POST['date']) ? $_POST['date'] : date('Y-m-d'); $sessions = $this->model->browseSessionsBySearch($q, $limit); $sessionsBlocks = $this->getFormatedSessionsBlock($sessions); echo Container::getTemplating()->render('@temaplte_style/auth/session_catalog.html.twig', ['show_courses' => CoursesAndSessionsCatalog::showCourses(), 'show_sessions' => CoursesAndSessionsCatalog::showSessions(), 'show_tutor' => api_get_setting('session.show_session_coach') === 'true' ? true : false, 'course_url' => $courseUrl, 'already_subscribed_label' => $this->getAlreadyRegisteredInSessionLabel(), 'hidden_links' => $hiddenLinks, 'search_token' => Security::get_token(), 'search_date' => Security::remove_XSS($searchDate), 'search_tag' => Security::remove_XSS($q), 'sessions' => $sessionsBlocks]); }
$courses_controller->subscribe_user(isset($_POST['subscribe_user_with_password']) ? $_POST['subscribe_user_with_password'] : '', isset($_POST['search_term']) ? $_POST['search_term'] : '', isset($_POST['category_code']) ? $_POST['category_code'] : ''); break; case 'createcoursecategory': $courses_controller->categories_list($action); break; case 'deletecoursecategory': $courses_controller->courses_list($action); break; case 'sortmycourses': $courses_controller->courses_list($action); break; case 'subscribe': if (!$user_can_view_page) { api_not_allowed(true); } if (!CoursesAndSessionsCatalog::is(CATALOG_SESSIONS)) { $courses_controller->courses_categories($action, $categoryCode, null, null, null, $limit); } else { header('Location: ' . api_get_self()); } break; case 'display_random_courses': if (!$user_can_view_page) { api_not_allowed(true); } $courses_controller->courses_categories($action); break; case 'display_courses': if (!$user_can_view_page) { api_not_allowed(true); }
/** * Show the Session Catalogue with filtered session by a query term * @param array $limit */ public function sessionListBySearch(array $limit) { $q = isset($_REQUEST['q']) ? Security::remove_XSS($_REQUEST['q']) : null; $hiddenLinks = isset($_GET['hidden_links']) ? intval($_GET['hidden_links']) == 1 : false; $courseUrl = getCourseCategoryUrl(1, $limit['length'], null, 0, 'subscribe'); $searchDate = isset($_POST['date']) ? $_POST['date'] : date('Y-m-d'); $sessions = $this->model->browseSessionsBySearch($q, $limit); $sessionsBlocks = $this->getFormatedSessionsBlock($sessions); $tpl = new Template(); $tpl->assign('show_courses', CoursesAndSessionsCatalog::showCourses()); $tpl->assign('show_sessions', CoursesAndSessionsCatalog::showSessions()); $tpl->assign('show_tutor', api_get_setting('show_session_coach') === 'true' ? true : false); $tpl->assign('course_url', $courseUrl); $tpl->assign('already_subscribed_label', $this->getAlreadyRegisteredInSessionLabel()); $tpl->assign('hidden_links', $hiddenLinks); $tpl->assign('search_token', Security::get_token()); $tpl->assign('search_date', Security::remove_XSS($searchDate)); $tpl->assign('search_tag', Security::remove_XSS($q)); $tpl->assign('sessions', $sessionsBlocks); $contentTemplate = $tpl->get_template('auth/session_catalog.tpl'); $tpl->display($contentTemplate); }
/** * Return Session Catalogue rendered view * @param string $action * @param string $nameTools * @param array $limit */ public function sessionsList($action, $nameTools, $limit = array()) { $date = isset($_POST['date']) ? $_POST['date'] : date('Y-m-d'); $hiddenLinks = isset($_GET['hidden_links']) ? intval($_GET['hidden_links']) == 1 : false; $limit = isset($limit) ? $limit : getLimitArray(); $countSessions = $this->model->countSessions($date); $sessions = $this->model->browseSessions($date, $limit); $pageTotal = intval(ceil(intval($countSessions) / $limit['length'])); // Do NOT show pagination if only one page or less $cataloguePagination = $pageTotal > 1 ? getCataloguePagination($limit['current'], $limit['length'], $pageTotal) : ''; $sessionsBlocks = array(); // Get session list catalogue URL $sessionUrl = getCourseCategoryUrl(1, $limit['length'], null, 0, 'display_sessions'); // Get session search catalogue URL $courseUrl = getCourseCategoryUrl(1, $limit['length'], null, 0, 'subscribe'); foreach ($sessions as $session) { $sessionsBlocks[] = array('id' => $session['id'], 'name' => $session['name'], 'nbr_courses' => $session['nbr_courses'], 'nbr_users' => $session['nbr_users'], 'coach_name' => $session['coach_name'], 'is_subscribed' => $session['is_subscribed'], 'icon' => $this->getSessionIcon($session['name']), 'date' => SessionManager::getSessionFormattedDate($session), 'subscribe_button' => $this->getRegisterInSessionButton($session['name'])); } $tpl = new Template(); $tpl->assign('action', $action); $tpl->assign('showCourses', CoursesAndSessionsCatalog::showCourses()); $tpl->assign('showSessions', CoursesAndSessionsCatalog::showSessions()); $tpl->assign('api_get_self', api_get_self()); $tpl->assign('sessionUrl', $sessionUrl); $tpl->assign('courseUrl', $courseUrl); $tpl->assign('nameTools', $nameTools); $tpl->assign('coursesCategoriesList', $this->getCoursesCategoriesBlock(null, false, $limit)); $tpl->assign('cataloguePagination', $cataloguePagination); $tpl->assign('hiddenLinks', $hiddenLinks); $tpl->assign('searchToken', Security::get_token()); $tpl->assign('searchDate', $date); $tpl->assign('web_session_courses_ajax_url', api_get_path(WEB_AJAX_PATH) . 'course.ajax.php'); $tpl->assign('sessions_blocks', $sessionsBlocks); $tpl->assign('already_subscribed_label', $this->getAlreadyRegisterInSessionLabel()); $contentTemplate = $tpl->get_template('auth/sessions_catalog.tpl'); $tpl->display($contentTemplate); }