- 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 ? getCataloguePagination($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; ?>
'; $form .= ''; $form .= ''; $form .= ''; $form .= '
'; $form .= '
'; $form .= ''; $form .= '
'; $form .= ''; echo $form; ?>
".get_lang('SearchResultsFor')." ".Security::remove_XSS($_POST['search_term'])."
"; } $ajax_url = api_get_path(WEB_AJAX_PATH).'course.ajax.php?a=add_course_vote'; $user_id = api_get_user_id(); if (!empty($browse_courses_in_category)) { foreach ($browse_courses_in_category as $course) { $course_hidden = ($course['visibility'] == COURSE_VISIBILITY_HIDDEN); if ($course_hidden) { continue; } $user_registerd_in_course = CourseManager::is_user_subscribed_in_course($user_id, $course['code']); $user_registerd_in_course_as_teacher = CourseManager::is_course_teacher($user_id, $course['code']); $user_registerd_in_course_as_student = ($user_registerd_in_course && !$user_registerd_in_course_as_teacher); $course_public = ($course['visibility'] == COURSE_VISIBILITY_OPEN_WORLD); $course_open = ($course['visibility'] == COURSE_VISIBILITY_OPEN_PLATFORM); $course_private = ($course['visibility'] == COURSE_VISIBILITY_REGISTERED); $course_closed = ($course['visibility'] == COURSE_VISIBILITY_CLOSED); $course_subscribe_allowed = ($course['subscribe'] == 1); $course_unsubscribe_allowed = ($course['unsubscribe'] == 1); $count_connections = $course['count_connections']; $creation_date = substr($course['creation_date'],0,10); $icon_title = null; $html = null; // display the course bloc $html .= '
'; // display thumbnail $html .= return_thumbnail($course, $icon_title); // display course title and button bloc $html .= '
'; $html .= return_title($course); // display button line $html .= '
'; // if user registered as student if ($user_registerd_in_course_as_student) { if (!$course_closed) { if ($course_unsubscribe_allowed) { $html .= return_unregister_button($course, $stok, $search_term, $code); } $html .= return_already_registered_label('student'); } $html .= return_description_button($course, $icon_title); } elseif ($user_registerd_in_course_as_teacher) { // if user registered as teacher //$html .= return_goto_button($course); if ($course_unsubscribe_allowed) { $html .= return_unregister_button($course, $stok, $search_term, $code); } $html .= return_already_registered_label('teacher'); $html .= return_description_button($course, $icon_title); } else { // if user not registered in the course if (!$course_closed) { if (!$course_private) { //$html .= return_goto_button($course); if ($course_subscribe_allowed) { $html .= return_register_button($course, $stok, $code, $search_term); } } } $html .= return_description_button($course, $icon_title); } $html .= '
'; $html .= '
'; $html .= '
'; $html .= '
'; echo $html; } } else { if (!isset($_REQUEST['subscribe_user_with_password']) && !isset($_REQUEST['subscribe_course']) ) { Display::display_warning_message(get_lang('ThereAreNoCoursesInThisCategory')); } } } echo $cataloguePagination; ?>
'; if (api_get_setting('show_courses_descriptions_in_catalog') == 'true') { $html .= ''; $html .= ''.api_htmlentities($title).''; $html .= ''; } else { $html .= ''.api_htmlentities($title).''; } $html .= ''; // thumbail return $html; } /** * Display the title of a course in course catalog * @param $course */ function return_title($course) { $html = ''; $linkCourse = api_get_course_url($course['code']); $title = cut($course['title'], 70); $ajax_url = api_get_path(WEB_AJAX_PATH).'course.ajax.php?a=add_course_vote'; $teachers = CourseManager::get_teacher_list_from_course_code_to_string($course['code']); $rating = Display::return_rating_system('star_'.$course['real_id'], $ajax_url.'&course_id='.$course['real_id'], $course['point_info']); $html .= '

' . cut($title, 60) . '

'; $html .= '
'.$teachers.'
'; $html .= '
'. $rating . '
'; return $html; } /** * Display the description button of a course in the course catalog * @param $course * @param $icon_title */ function return_description_button($course, $icon_title) { $title = $course['title']; $html = ''; if (api_get_setting('show_courses_descriptions_in_catalog') == 'true') { $html = ''.get_lang('Description').''; } return $html; } /** * Display the goto course button of a course in the course catalog * @param $course */ function return_goto_button($course) { $html = ' '.get_lang('GoToCourse').''; return $html; } /** * Display the already registerd text in a course in the course catalog * @param $in_status */ function return_already_registered_label($in_status) { $icon = Display::return_icon('teacher.png', get_lang('Teacher'), null, ICON_SIZE_TINY); if ($in_status == 'student') { $icon = Display::return_icon('user.png', get_lang('Student'), null, ICON_SIZE_TINY); } $html = Display::div($icon.' '.get_lang("AlreadyRegisteredToCourse"), array('id' => 'register', 'class' => 'user-register')); return $html; } /** * Display the register button of a course in the course catalog * @param $course * @param $stok * @param $code * @param $search_term */ function return_register_button($course, $stok, $code, $search_term) { $html = ' '.get_lang('Subscribe').''; return $html; } /** * Display the unregister button of a course in the course catalog * @param $course * @param $stok * @param $search_term * @param $code */ function return_unregister_button($course, $stok, $search_term, $code) { $html = ' '.get_lang('Unsubscribe').''; return $html; }