/** * 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]); }
} else { // Ensure the database prefix + database name do not get over 40 characters. $maxlength = 40; // Build the form. $form = new FormValidator('add_course', 'post', 'course_request_edit.php?id=' . $id . '&caller=' . $caller); // Form title. $form->addElement('header', $tool_name); // Title. $form->addElement('text', 'title', get_lang('CourseName'), array('size' => '60', 'id' => 'title')); $form->applyFilter('title', 'html_filter'); $form->addRule('title', get_lang('ThisFieldIsRequired'), 'required'); // Course category. $url = api_get_path(WEB_AJAX_PATH) . 'course.ajax.php?a=search_category'; $courseSelect = $form->addElement('select_ajax', 'category_code', get_lang('CourseFaculty'), null, array('url' => $url)); if (!empty($course_request_info['category_code'])) { $data = CourseCategoryManager::getCategory($course_request_info['category_code']); $courseSelect->addOption($data['name'], $data['code'], ['selected' => 'selected']); } // Course code. $form->addText('wanted_code', get_lang('Code'), false, array('size' => '$maxlength', 'maxlength' => $maxlength)); $form->applyFilter('wanted_code', 'html_filter'); $form->addRule('wanted_code', get_lang('Max'), 'maxlength', $maxlength); $form->addRule('wanted_code', get_lang('ThisFieldIsRequired'), 'required'); // The teacher. $titular = $form->addText('tutor_name', get_lang('Professor'), null, array('size' => '60', 'disabled' => 'disabled')); // Description of the requested course. $form->addElement('textarea', 'description', get_lang('Description'), array('style' => 'border:#A5ACB2 solid 1px; font-family:arial,verdana,helvetica,sans-serif; font-size:12px', 'rows' => '3', 'cols' => '116')); $form->addRule('description', get_lang('ThisFieldIsRequired'), 'required'); // Objectives of the requested course. $form->addElement('textarea', 'objetives', get_lang('Objectives'), array('style' => 'border:#A5ACB2 solid 1px; font-family:arial,verdana,helvetica,sans-serif; font-size:12px', 'rows' => '3', 'cols' => '116')); $form->addRule('objetives', get_lang('ThisFieldIsRequired'), 'required');
/** * Display list of courses in a category. * (for anonymous users) * * @version 1.1 * @author Patrick Cool <*****@*****.**>, Ghent University - refactoring and code cleaning * @author Julio Montoya <*****@*****.**>, Beeznest template modifs */ function return_courses_in_categories() { $result = ''; $stok = Security::get_token(); // Initialization. $user_identified = api_get_user_id() > 0 && !api_is_anonymous(); $web_course_path = api_get_path(WEB_COURSE_PATH); $category = Database::escape_string($_GET['category']); $setting_show_also_closed_courses = api_get_setting('show_closed_courses') == 'true'; // Database table definitions. $main_course_table = Database::get_main_table(TABLE_MAIN_COURSE); $main_category_table = Database::get_main_table(TABLE_MAIN_CATEGORY); // Get list of courses in category $category. $sql_get_course_list = "SELECT * FROM {$main_course_table} cours\n WHERE category_code = '" . Database::escape_string($_GET['category']) . "'\n ORDER BY title, UPPER(visual_code)"; // Showing only the courses of the current access_url_id. if (api_is_multiple_url_enabled()) { $url_access_id = api_get_current_access_url_id(); if ($url_access_id != -1) { $tbl_url_rel_course = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); $sql_get_course_list = "SELECT * FROM {$main_course_table} as course\n INNER JOIN {$tbl_url_rel_course} as url_rel_course\n ON (url_rel_course.c_id = course.id)\n WHERE\n access_url_id = {$url_access_id} AND\n category_code = '" . Database::escape_string($_GET['category']) . "'\n ORDER BY title, UPPER(visual_code)"; } } // Removed: AND cours.visibility='".COURSE_VISIBILITY_OPEN_WORLD."' $sql_result_courses = Database::query($sql_get_course_list); while ($course_result = Database::fetch_array($sql_result_courses)) { $course_list[] = $course_result; } // $setting_show_also_closed_courses if ($user_identified) { if ($setting_show_also_closed_courses) { $platform_visible_courses = ''; } else { $platform_visible_courses = " AND (t3.visibility='" . COURSE_VISIBILITY_OPEN_WORLD . "' OR t3.visibility='" . COURSE_VISIBILITY_OPEN_PLATFORM . "' )"; } } else { if ($setting_show_also_closed_courses) { $platform_visible_courses = ''; } else { $platform_visible_courses = " AND (t3.visibility='" . COURSE_VISIBILITY_OPEN_WORLD . "' )"; } } $sqlGetSubCatList = "\n SELECT t1.name,\n t1.code,\n t1.parent_id,\n t1.children_count,COUNT(DISTINCT t3.code) AS nbCourse\n FROM {$main_category_table} t1\n LEFT JOIN {$main_category_table} t2 ON t1.code=t2.parent_id\n LEFT JOIN {$main_course_table} t3 ON (t3.category_code = t1.code {$platform_visible_courses})\n WHERE t1.parent_id " . (empty($category) ? "IS NULL" : "='{$category}'") . "\n GROUP BY t1.name,t1.code,t1.parent_id,t1.children_count ORDER BY t1.tree_pos, t1.name"; // Showing only the category of courses of the current access_url_id if (api_is_multiple_url_enabled()) { $courseCategoryCondition = null; if (CourseCategoryManager::isMultipleUrlSupport()) { $table = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE_CATEGORY); $courseCategoryCondition = " INNER JOIN {$table} a ON (t1.id = a.course_category_id)"; } $url_access_id = api_get_current_access_url_id(); if ($url_access_id != -1) { $tbl_url_rel_course = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); $sqlGetSubCatList = "\n SELECT t1.name,\n t1.code,\n t1.parent_id,\n t1.children_count,\n COUNT(DISTINCT t3.code) AS nbCourse\n FROM {$main_category_table} t1\n {$courseCategoryCondition}\n LEFT JOIN {$main_category_table} t2 ON t1.code = t2.parent_id\n LEFT JOIN {$main_course_table} t3 ON (t3.category_code = t1.code {$platform_visible_courses})\n INNER JOIN {$tbl_url_rel_course} as url_rel_course\n ON (url_rel_course.c_id = t3.id)\n WHERE\n url_rel_course.access_url_id = {$url_access_id} AND\n t1.parent_id " . (empty($category) ? "IS NULL" : "='{$category}'") . "\n GROUP BY t1.name,t1.code,t1.parent_id,t1.children_count\n ORDER BY t1.tree_pos, t1.name"; } } $resCats = Database::query($sqlGetSubCatList); $thereIsSubCat = false; if (Database::num_rows($resCats) > 0) { $htmlListCat = Display::page_header(get_lang('CatList')); $htmlListCat .= '<ul>'; $htmlTitre = ''; while ($catLine = Database::fetch_array($resCats)) { $category_has_open_courses = self::category_has_open_courses($catLine['code']); if ($category_has_open_courses) { // The category contains courses accessible to anonymous visitors. $htmlListCat .= '<li>'; $htmlListCat .= '<a href="' . api_get_self() . '?category=' . $catLine['code'] . '">' . $catLine['name'] . '</a>'; if (api_get_setting('show_number_of_courses') == 'true') { $htmlListCat .= ' (' . $catLine['nbCourse'] . ' ' . get_lang('Courses') . ')'; } $htmlListCat .= "</li>"; $thereIsSubCat = true; } elseif ($catLine['children_count'] > 0) { // The category has children, subcategories. $htmlListCat .= '<li>'; $htmlListCat .= '<a href="' . api_get_self() . '?category=' . $catLine['code'] . '">' . $catLine['name'] . '</a>'; $htmlListCat .= "</li>"; $thereIsSubCat = true; } elseif (api_get_setting('show_empty_course_categories') == 'true') { /* End changed code to eliminate the (0 courses) after empty categories. */ $htmlListCat .= '<li>'; $htmlListCat .= $catLine['name']; $htmlListCat .= "</li>"; $thereIsSubCat = true; } // Else don't set thereIsSubCat to true to avoid printing things if not requested. // TODO: deprecate this useless feature - this includes removing system variable if (empty($htmlTitre)) { $htmlTitre = '<p>'; if (api_get_setting('show_back_link_on_top_of_tree') == 'true') { $htmlTitre .= '<a href="' . api_get_self() . '"><< ' . get_lang('BackToHomePage') . '</a>'; } $htmlTitre .= "</p>"; } } $htmlListCat .= "</ul>"; } $result .= $htmlTitre; if ($thereIsSubCat) { $result .= $htmlListCat; } while ($categoryName = Database::fetch_array($resCats)) { $result .= '<h3>' . $categoryName['name'] . "</h3>\n"; } $numrows = Database::num_rows($sql_result_courses); $courses_list_string = ''; $courses_shown = 0; if ($numrows > 0) { $courses_list_string .= Display::page_header(get_lang('CourseList')); $courses_list_string .= "<ul>"; if (api_get_user_id()) { $courses_of_user = self::get_courses_of_user(api_get_user_id()); } foreach ($course_list as $course) { // $setting_show_also_closed_courses if ($course['visibility'] == COURSE_VISIBILITY_HIDDEN) { continue; } if (!$setting_show_also_closed_courses) { // If we do not show the closed courses // we only show the courses that are open to the world (to everybody) // and the courses that are open to the platform (if the current user is a registered user. if ($user_identified && $course['visibility'] == COURSE_VISIBILITY_OPEN_PLATFORM || $course['visibility'] == COURSE_VISIBILITY_OPEN_WORLD) { $courses_shown++; $courses_list_string .= "<li>"; $courses_list_string .= '<a href="' . $web_course_path . $course['directory'] . '/">' . $course['title'] . '</a><br />'; $course_details = array(); if (api_get_setting('course.display_coursecode_in_courselist') == 'true') { $course_details[] = $course['visual_code']; } if (api_get_setting('course.display_teacher_in_courselist') == 'true') { $course_details[] = CourseManager::getTeacherListFromCourseToString($course['real_id']); } if (api_get_setting('show_different_course_language') == 'true' && $course['course_language'] != api_get_setting('language.platform_language')) { $course_details[] = $course['course_language']; } $courses_list_string .= implode(' - ', $course_details); $courses_list_string .= "</li>"; } } else { // We DO show the closed courses. // The course is accessible if (link to the course homepage): // 1. the course is open to the world (doesn't matter if the user is logged in or not): $course['visibility'] == COURSE_VISIBILITY_OPEN_WORLD); // 2. the user is logged in and the course is open to the world or open to the platform: ($user_identified && $course['visibility'] == COURSE_VISIBILITY_OPEN_PLATFORM); // 3. the user is logged in and the user is subscribed to the course and the course visibility is not COURSE_VISIBILITY_CLOSED; // 4. the user is logged in and the user is course admin of te course (regardless of the course visibility setting); // 5. the user is the platform admin api_is_platform_admin(). $courses_shown++; $courses_list_string .= "<li>"; if ($course['visibility'] == COURSE_VISIBILITY_OPEN_WORLD || $user_identified && $course['visibility'] == COURSE_VISIBILITY_OPEN_PLATFORM || $user_identified && array_key_exists($course['code'], $courses_of_user) && $course['visibility'] != COURSE_VISIBILITY_CLOSED || $courses_of_user[$course['code']]['status'] == '1' || api_is_platform_admin()) { $courses_list_string .= '<a href="' . $web_course_path . $course['directory'] . '/">'; } $courses_list_string .= $course['title']; if ($course['visibility'] == COURSE_VISIBILITY_OPEN_WORLD || $user_identified && $course['visibility'] == COURSE_VISIBILITY_OPEN_PLATFORM || $user_identified && array_key_exists($course['code'], $courses_of_user) && $course['visibility'] != COURSE_VISIBILITY_CLOSED || $courses_of_user[$course['code']]['status'] == '1' || api_is_platform_admin()) { $courses_list_string .= '</a><br />'; } $course_details = array(); if (api_get_setting('course.display_coursecode_in_courselist') == 'true') { $course_details[] = $course['visual_code']; } // if (api_get_setting('course.display_coursecode_in_courselist') == 'true' && api_get_setting('course.display_teacher_in_courselist') == 'true') { // $courses_list_string .= ' - '; // } if (api_get_setting('course.display_teacher_in_courselist') == 'true') { if (!empty($course['tutor_name'])) { $course_details[] = $course['tutor_name']; } } if (api_get_setting('show_different_course_language') == 'true' && $course['course_language'] != api_get_setting('language.platform_language')) { $course_details[] = $course['course_language']; } $courses_list_string .= implode(' - ', $course_details); // We display a subscription link if: // 1. it is allowed to register for the course and if the course is not already in the courselist of the user and if the user is identiefied // 2. if ($user_identified && !array_key_exists($course['code'], $courses_of_user)) { if ($course['subscribe'] == '1') { $courses_list_string .= ' <a class="btn btn-primary" href="main/auth/courses.php?action=subscribe_course&sec_token=' . $stok . '&subscribe_course=' . $course['code'] . '&category_code=' . Security::remove_XSS($_GET['category']) . '">' . get_lang('Subscribe') . '</a><br />'; } else { $courses_list_string .= '<br />' . get_lang('SubscribingNotAllowed'); } } $courses_list_string .= "</li>"; } //end else } // end foreach $courses_list_string .= "</ul>"; } if ($courses_shown > 0) { // Only display the list of courses and categories if there was more than // 0 courses visible to the world (we're in the anonymous list here). $result .= $courses_list_string; } if ($category != '') { $result .= '<p><a href="' . api_get_self() . '"> ' . Display::return_icon('back.png', get_lang('BackToHomePage')) . get_lang('BackToHomePage') . '</a></p>'; } return $result; }
use Chamilo\CoreBundle\Framework\Container; use Chamilo\CoreBundle\Entity\SequenceResource; /** * Template (front controller in MVC pattern) used for distpaching * to the controllers depend on the current action * @author Christian Fasanando <*****@*****.**> - Beeznest * @package chamilo.auth */ // Delete the globals['_cid'], we don't need it here. $cidReset = true; // Flag forcing the 'current course' reset // including files //require_once '../inc/global.inc.php'; $ctok = Security::get_existing_token(); // Get Limit data $limit = CourseCategoryManager::getLimitArray(); // Section for the tabs. $this_section = SECTION_COURSES; if (api_get_setting('course.course_catalog_published') !== 'true') { // 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('display.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()) {
$class = "add"; $text = get_lang('AddCategory'); $form->setDefaults(array('auth_course_child' => 'TRUE')); $form->addButtonCreate($text); } $form->display(); } elseif (api_get_multiple_access_url() && api_get_current_access_url_id() != 1) { // If multiple URLs and not main URL, prevent edition and inform user Display::display_warning_message(get_lang('CourseCategoriesAreGlobal')); } } else { // If multiple URLs and not main URL, prevent deletion and inform user if ($action == 'delete' && api_get_multiple_access_url() && api_get_current_access_url_id() != 1) { Display::display_warning_message(get_lang('CourseCategoriesAreGlobal')); } echo '<div class="actions">'; $link = null; if (!empty($parentInfo)) { $parentCode = $parentInfo['parent_id']; echo Display::url(Display::return_icon('back.png', get_lang("Back"), '', ICON_SIZE_MEDIUM), api_get_path(WEB_CODE_PATH) . 'admin/course_category.php?category=' . $parentCode); } if (empty($parentInfo) || $parentInfo['auth_cat_child'] == 'TRUE') { echo Display::url(Display::return_icon('new_folder.png', get_lang("AddACategory"), '', ICON_SIZE_MEDIUM), api_get_path(WEB_CODE_PATH) . 'admin/course_category.php?action=add&category=' . Security::remove_XSS($category)); } echo '</div>'; if (!empty($parentInfo)) { echo Display::page_subheader($parentInfo['name'] . ' (' . $parentInfo['code'] . ')'); } echo CourseCategoryManager::listCategories($category); } Display::display_footer();
/** * Updates the access_url_rel_course_category table with a given list * @author Julio Montoya * @param array course category list * @param int access_url_id **/ public static function updateUrlRelCourseCategory($list, $urlId) { $table = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE_CATEGORY); $sql = "SELECT course_category_id FROM {$table} WHERE access_url_id = " . intval($urlId); $result = Database::query($sql); $existingItems = array(); while ($row = Database::fetch_array($result)) { $existingItems[] = $row['course_category_id']; } // Adding foreach ($list as $id) { UrlManager::addCourseCategoryToUrl($id, $urlId); $categoryInfo = CourseCategoryManager::getCategoryById($id); $children = CourseCategoryManager::getChildren($categoryInfo['code']); if (!empty($children)) { foreach ($children as $category) { UrlManager::addCourseCategoryToUrl($category['id'], $urlId); } } } // Deleting old items foreach ($existingItems as $id) { if (!in_array($id, $list)) { UrlManager::deleteUrlRelCourseCategory($id, $urlId); $categoryInfo = CourseCategoryManager::getCategoryById($id); $children = CourseCategoryManager::getChildren($categoryInfo['code']); if (!empty($children)) { foreach ($children as $category) { UrlManager::deleteUrlRelCourseCategory($category['id'], $urlId); } } } } }
$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', 'subscribe_to_session', 'search_tag', 'search_session'); $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']); } $categoryCode = isset($_GET['category_code']) ? $_GET['category_code'] : ''; $nameTools = CourseCategoryManager::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')); } $interbreadcrumb[] = array('url' => '#', 'name' => $nameTools); } // course description controller object $courses_controller = new CoursesController(); // We are moving a course or category of the user up/down the list (=Sort My Courses). if (isset($_GET['move'])) {
/** * 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 : CourseCategory::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 ? CourseCategory::getCatalogPagination($limit['current'], $limit['length'], $pageTotal) : ''; $sessionsBlocks = $this->getFormatedSessionsBlock($sessions); // Get session list catalogue URL //$sessionUrl = CourseCategoryManager::getCourseCategoryUrl(1, $limit['length'], null, 0, 'display_sessions'); // Get session search catalogue URL $courseUrl = CourseCategoryManager::getCourseCategoryUrl(1, $limit['length'], null, 0, 'subscribe'); $tpl = \Chamilo\CoreBundle\Framework\Container::getTwig(); $tpl->addGlobal('show_courses', CoursesAndSessionsCatalog::showCourses()); $tpl->addGlobal('show_sessions', CoursesAndSessionsCatalog::showSessions()); $tpl->addGlobal('show_tutor', api_get_setting('session.show_session_coach') === 'true' ? true : false); $tpl->addGlobal('course_url', $courseUrl); $tpl->addGlobal('catalog_pagination', $cataloguePagination); $tpl->addGlobal('hidden_links', $hiddenLinks); $tpl->addGlobal('search_token', Security::get_token()); $tpl->addGlobal('search_date', $date); $tpl->addGlobal('web_session_courses_ajax_url', api_get_path(WEB_AJAX_PATH) . 'course.ajax.php'); $tpl->addGlobal('sessions', $sessionsBlocks); $tpl->addGlobal('already_subscribed_label', $this->getAlreadyRegisteredInSessionLabel()); echo $tpl->render('@template_style/auth/session_catalog.html.twig'); }
if ($result) { Display::addFlash(Display::return_message(get_lang('ItemCopied'))); } else { Display::addFlash(Display::return_message(get_lang('ThereWasAnError'), 'error')); } header('Location: session_list.php'); exit; } $tool_name = get_lang('SessionList'); Display::display_header($tool_name); $courseId = isset($_GET['course_id']) ? $_GET['course_id'] : null; $sessionFilter = new FormValidator('course_filter', 'get', '', '', array(), FormValidator::LAYOUT_INLINE); $courseSelect = $sessionFilter->addElement('select_ajax', 'course_name', get_lang('SearchCourse'), null, array('url' => api_get_path(WEB_AJAX_PATH) . 'course.ajax.php?a=search_course')); if (!empty($courseId)) { $courseInfo = api_get_course_info_by_id($courseId); $parents = CourseCategoryManager::getParentsToString($courseInfo['categoryCode']); $courseSelect->addOption($parents . $courseInfo['title'], $courseInfo['code'], ['selected' => 'selected']); } $url = api_get_self(); $actions = ' <script> $(function() { $("#course_name").on("change", function() { var courseId = $(this).val(); if (!courseId) { return; } window.location = "' . $url . '?course_id="+courseId; });
} $a_profs[0] = '-- ' . get_lang('NoManager') . ' --'; while ($a_titulars = Database::fetch_array($q_result_titulars)) { $s_username = $a_titulars['username']; $s_lastname = $a_titulars['lastname']; $s_firstname = $a_titulars['firstname']; if (api_get_person_name($s_firstname, $s_lastname) == $s_tutor) { $s_selected_tutor = api_get_person_name($s_firstname, $s_lastname); } $s_disabled_select_titular = ''; if (!api_is_course_admin()) { $s_disabled_select_titular = 'disabled=disabled'; } $a_profs[api_get_person_name($s_firstname, $s_lastname)] = api_get_person_name($s_lastname, $s_firstname) . ' (' . $s_username . ')'; } $categories = CourseCategoryManager::getCategoriesCanBeAddedInCourse($_course['categoryCode']); $linebreak = '<div class="row"><div class="label"></div><div class="formw" style="border-bottom:1px dashed grey"></div></div>'; // Build the form $form = new FormValidator('update_course', 'post', api_get_self() . '?' . api_get_cidreq()); // COURSE SETTINGS $form->addElement('html', '<div><h3>' . Display::return_icon('settings.png', Security::remove_XSS(get_lang('CourseSettings')), '', ICON_SIZE_SMALL) . ' ' . Security::remove_XSS(get_lang('CourseSettings')) . '</h3><div>'); $image_html = ''; // Display course picture $course_path = api_get_path(SYS_COURSE_PATH) . $currentCourseRepository; // course path if (file_exists($course_path . '/course-pic85x85.png')) { $course_web_path = api_get_path(WEB_COURSE_PATH) . $currentCourseRepository; // course web path $course_medium_image = $course_web_path . '/course-pic85x85.png?' . rand(1, 1000); // redimensioned image 85x85 $image_html = '<div class="row"><label class="col-md-2 control-label">' . get_lang('Image') . '</label> <div class="col-md-8"><img src="' . $course_medium_image . '" /></div></div>';
$link_url = ''; } else { $filename = ''; } } break; } } break; } //end of second switch($action) (when POST['formSent'] was not set, yet) } // end of "else" in if($_POST['formSent']) condition } else { //if $action is empty, then prepare a list of the course categories to display (?) $Categories = CourseCategoryManager::getCategoriesToDisplayInHomePage(); } // Display section Display::display_header($tool_name); switch ($action) { case 'open_link': if (!empty($link)) { // $link is only set in case of action=open_link and is filtered $open = @(string) file_get_contents($homep . $link); $open = api_to_system_encoding($open, api_detect_encoding(strip_tags($open))); echo $open; } break; case 'edit_notice': // Display for edit_notice case ?>
} $noUserGroupList = $userGroupList = array(); $ajax_search = $add_type == 'unique' ? true : false; if ($ajax_search) { $userGroups = UrlManager::getUrlRelCourseCategory($access_url_id); foreach ($userGroups as $item) { $userGroupList[$item['id']] = $item; } } else { $userGroups = UrlManager::getUrlRelCourseCategory(); foreach ($userGroups as $item) { if ($item['access_url_id'] == $access_url_id) { $userGroupList[$item['id']] = $item; } } $noUserGroupList = CourseCategoryManager::getCourseCategoryNotInList(array_keys($userGroupList)); } if ($add_type == 'multiple') { $link_add_type_unique = '<a href="' . api_get_self() . '?add_type=unique&access_url_id=' . $access_url_id . '">' . get_lang('SessionAddTypeUnique') . '</a>'; $link_add_type_multiple = get_lang('SessionAddTypeMultiple'); } else { $link_add_type_unique = get_lang('SessionAddTypeUnique'); $link_add_type_multiple = '<a href="' . api_get_self() . '?add_type=multiple&access_url_id=' . $access_url_id . '">' . get_lang('SessionAddTypeMultiple') . '</a>'; } $url_list = UrlManager::get_url_data(); ?> <div style="text-align: left;"> <?php echo $link_add_type_unique; ?> | <?php
} $groupName = 'session_coaches[' . $sessionId . ']'; $platformTeacherId = 'platform_teachers_by_session_' . $sessionId; $coachId = 'coaches_by_session_' . $sessionId; $platformTeacherName = 'platform_teachers_by_session'; $coachName = 'coaches_by_session'; $sessionUrl = api_get_path(WEB_CODE_PATH) . 'admin/resume_session.php?id_session=' . $sessionId; $form->addElement('advmultiselect', $groupName, Display::url($session['name'], $sessionUrl, array('target' => '_blank')) . ' - ' . get_lang('Coaches'), $allTeachers); $courseInfo[$groupName] = $sessionTeachers; } } // Category code $url = api_get_path(WEB_AJAX_PATH) . 'course.ajax.php?a=search_category'; $categorySelect = $form->addElement('select_ajax', 'category_code', get_lang('CourseFaculty'), null, array('url' => $url)); if (!empty($courseInfo['categoryCode'])) { $data = CourseCategoryManager::getCategory($courseInfo['categoryCode']); $categorySelect->addOption($data['name'], $data['code']); } $form->addText('department_name', get_lang('CourseDepartment'), false, array('size' => '60')); $form->applyFilter('department_name', 'html_filter'); $form->applyFilter('department_name', 'trim'); $form->addText('department_url', get_lang('CourseDepartmentURL'), false, array('size' => '60')); $form->applyFilter('department_url', 'html_filter'); $form->applyFilter('department_url', 'trim'); $form->addElement('select_language', 'course_language', get_lang('CourseLanguage')); $form->applyFilter('select_language', 'html_filter'); $group = array(); $group[] = $form->createElement('radio', 'visibility', get_lang("CourseAccess"), get_lang('OpenToTheWorld'), COURSE_VISIBILITY_OPEN_WORLD); $group[] = $form->createElement('radio', 'visibility', null, get_lang('OpenToThePlatform'), COURSE_VISIBILITY_OPEN_PLATFORM); $group[] = $form->createElement('radio', 'visibility', null, get_lang('Private'), COURSE_VISIBILITY_REGISTERED); $group[] = $form->createElement('radio', 'visibility', null, get_lang('CourseVisibilityClosed'), COURSE_VISIBILITY_CLOSED);
$quant = UrlManager::relation_url_user_exist(api_get_user_id(), $current_access_url_id); if ($quant == 0) { Display::display_warning_message('<a href="' . api_get_self() . '?action=register&sec_token=' . $parameters['sec_token'] . '">' . get_lang('ClickToRegisterAdmin') . '</a>', false); } } // action menu echo '<div class="actions">'; echo Display::url(Display::return_icon('new_link.png', get_lang('AddUrl'), array(), ICON_SIZE_MEDIUM), api_get_path(WEB_CODE_PATH) . 'admin/access_url_edit.php'); echo Display::url(Display::return_icon('user.png', get_lang('ManageUsers'), array(), ICON_SIZE_MEDIUM), api_get_path(WEB_CODE_PATH) . 'admin/access_url_edit_users_to_url.php'); echo Display::url(Display::return_icon('course.png', get_lang('ManageCourses'), array(), ICON_SIZE_MEDIUM), api_get_path(WEB_CODE_PATH) . 'admin/access_url_edit_courses_to_url.php'); //echo Display::url(Display::return_icon('session.png', get_lang('ManageSessions'), array(), ICON_SIZE_MEDIUM), api_get_path(WEB_CODE_PATH).'admin/access_url_edit_sessions_to_url.php'); $userGroup = new UserGroup(); if ($userGroup->getUseMultipleUrl()) { echo Display::url(Display::return_icon('class.png', get_lang('ManageUserGroup'), array(), ICON_SIZE_MEDIUM), api_get_path(WEB_CODE_PATH) . 'admin/access_url_edit_usergroup_to_url.php'); } if (CourseCategoryManager::isMultipleUrlSupport()) { echo Display::url(Display::return_icon('folder.png', get_lang('ManageCourseCategories'), array(), ICON_SIZE_MEDIUM), api_get_path(WEB_CODE_PATH) . 'admin/access_url_edit_course_category_to_url.php'); } echo '</div>'; $sortable_data = UrlManager::get_url_data(); $urls = array(); foreach ($sortable_data as $row) { //title $url = Display::url($row['url'], $row['url'], array('target' => '_blank')); $description = $row['description']; //Status $active = $row['active']; if ($active == '1') { $action = 'lock'; $image = 'right'; }
//if session is defined, lets find only courses of this session $courseList = SessionManager::get_course_list_by_session_id($_GET['session_id'], $_GET['q']); } else { //if session is not defined lets search all courses STARTING with $_GET['q'] //TODO change this function to search not only courses STARTING with $_GET['q'] $courseList = CourseManager::get_courses_list(0, 0, 1, 'ASC', -1, $_GET['q'], null, true); } $results = array(); if (empty($courseList)) { echo json_encode([]); break; } foreach ($courseList as $course) { $title = $course['title']; if (!empty($course['category_code'])) { $parents = CourseCategoryManager::getParentsToString($course['category_code']); $title = $parents . $course['title']; } $results['items'][] = array('id' => $course['id'], 'text' => $title); } echo json_encode($results); } break; case 'search_course_by_session': if (api_is_platform_admin()) { $results = SessionManager::get_course_list_by_session_id($_GET['session_id'], $_GET['q']); $results2 = array(); if (!empty($results)) { foreach ($results as $item) { $item2 = array(); foreach ($item as $id => $internal) {
$form .= '</div>'; $form .= '</form>'; echo $form; ?> </div> </div> <?php if ($showSessions) { ?> <div class="col-md-4"> <h5><?php echo get_lang('Sessions'); ?> </h5> <a class="btn btn-default btn-block" href="<?php echo CourseCategoryManager::getCourseCategoryUrl(1, $pageLength, null, 0, 'display_sessions'); ?> "> <?php echo get_lang('SessionList'); ?> </a> </div> <?php } ?> </div> <?php } ?> <div class="row">
/** * Display all the courses in the given course category. I could have used a parameter here * @param string $categoryCode Category code * @param int $randomValue * @param array $limit will be used if $random_value is not set. * This array should contains 'start' and 'length' keys * @return array Courses data */ public function browse_courses_in_category($categoryCode, $randomValue = null, $limit = array()) { return CourseCategoryManager::browseCoursesInCategory($categoryCode, $randomValue, $limit); }