diff --git a/main/auth/courses_categories.php b/main/auth/courses_categories.php index 840c676058..22def842d2 100755 --- a/main/auth/courses_categories.php +++ b/main/auth/courses_categories.php @@ -56,11 +56,13 @@ $code = isset($code) ? $code : null; return parseInt(parts[1], 10); }; - + $('#date').datepicker({ dateFormat: 'yy-mm-dd' }); - + });
@@ -68,9 +70,11 @@ $code = isset($code) ? $code : null;

- +
- +
@@ -88,43 +92,45 @@ $code = isset($code) ? $code : null;
- +
'; - $form .= ''; - $form .= ''; - $form .= ''; - $form .= '
'; - $form .= ''; - $form .= ''; + $form .= ''; + $form .= ''; + $form .= '
'; + $form .= ''; + $form .= ''; + $form .= '
'; + $form .= ''; + echo $form; + echo '
'; } - $form .= ''; - $form .= '
'; - $form .= ''; - echo $form; - echo '
'; -} -if ($showSessions) { ?> +if ($showSessions) { + ?>
- + ".get_lang('SearchResultsFor')." ".$searchTerm."
"; - } + if (!empty($searchTerm)) { + echo "

".get_lang('SearchResultsFor')." ".$searchTerm."
"; + } - $showTeacher = api_get_setting('display_teacher_in_courselist') === 'true'; - $ajax_url = api_get_path(WEB_AJAX_PATH).'course.ajax.php?a=add_course_vote'; - $user_id = api_get_user_id(); - $categoryListFromDatabase = CourseCategory::getCategories(); + $showTeacher = api_get_setting('display_teacher_in_courselist') === 'true'; + $ajax_url = api_get_path(WEB_AJAX_PATH).'course.ajax.php?a=add_course_vote'; + $user_id = api_get_user_id(); + $categoryListFromDatabase = CourseCategory::getCategories(); - $categoryList = []; - if (!empty($categoryListFromDatabase)) { - foreach ($categoryListFromDatabase as $categoryItem) { - $categoryList[$categoryItem['code']] = $categoryItem['name']; + $categoryList = []; + if (!empty($categoryListFromDatabase)) { + foreach ($categoryListFromDatabase as $categoryItem) { + $categoryList[$categoryItem['code']] = $categoryItem['name']; + } } - } - if (!empty($browse_courses_in_category)) { - echo '

'; - foreach ($browse_courses_in_category as $course) { - $course_hidden = $course['visibility'] == COURSE_VISIBILITY_HIDDEN; + if (!empty($browse_courses_in_category)) { + echo '
'; + foreach ($browse_courses_in_category as $course) { + $course_hidden = $course['visibility'] == COURSE_VISIBILITY_HIDDEN; - if ($course_hidden) { - continue; - } + if ($course_hidden) { + continue; + } - $userRegisteredInCourse = CourseManager::is_user_subscribed_in_course($user_id, $course['code']); - $userRegisteredInCourseAsTeacher = CourseManager::is_course_teacher($user_id, $course['code']); - $userRegistered = $userRegisteredInCourse && $userRegisteredInCourseAsTeacher; + $userRegisteredInCourse = CourseManager::is_user_subscribed_in_course($user_id, $course['code']); + $userRegisteredInCourseAsTeacher = CourseManager::is_course_teacher($user_id, $course['code']); + $userRegistered = $userRegisteredInCourse && $userRegisteredInCourseAsTeacher; - $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_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); + $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); - // display the course bloc - $html = '
'; + // display the course bloc + $html = '
'; - $course['category_title'] = ''; - if (isset($course['category'])) { - $course['category_title'] = isset($categoryList[$course['category']]) ? $categoryList[$course['category']] : ''; - } + $course['category_title'] = ''; + if (isset($course['category'])) { + $course['category_title'] = isset($categoryList[$course['category']]) ? $categoryList[$course['category']] : ''; + } - // Display thumbnail - $html .= returnThumbnail($course, $userRegistered); + // Display thumbnail + $html .= returnThumbnail($course, $userRegistered); - $separator = null; - $subscribeButton = return_register_button($course, $stok, $code, $searchTerm); - // Start buy course validation - // display the course price and buy button if the buycourses plugin is enabled and this course is configured - $plugin = BuyCoursesPlugin::create(); - $isThisCourseInSale = $plugin->buyCoursesForGridCatalogValidator( + $separator = null; + $subscribeButton = return_register_button($course, $stok, $code, $searchTerm); + // Start buy course validation + // display the course price and buy button if the buycourses plugin is enabled and this course is configured + $plugin = BuyCoursesPlugin::create(); + $isThisCourseInSale = $plugin->buyCoursesForGridCatalogValidator( $course['real_id'], BuyCoursesPlugin::PRODUCT_TYPE_COURSE ); - if ($isThisCourseInSale) { - // set the Price label - $separator = $isThisCourseInSale['html']; - // set the Buy button instead register. - if ($isThisCourseInSale['verificator']) { - $subscribeButton = $plugin->returnBuyCourseButton( + if ($isThisCourseInSale) { + // set the Price label + $separator = $isThisCourseInSale['html']; + // set the Buy button instead register. + if ($isThisCourseInSale['verificator']) { + $subscribeButton = $plugin->returnBuyCourseButton( $course['real_id'], BuyCoursesPlugin::PRODUCT_TYPE_COURSE ); + } } - } - // end buy course validation + // end buy course validation - // display course title and button bloc - $html .= '
'; - $html .= return_title($course, $userRegisteredInCourse); + // display course title and button bloc + $html .= '
'; + $html .= return_title($course, $userRegisteredInCourse); - if ($showTeacher) { - $html .= return_teacher($course); - } + if ($showTeacher) { + $html .= return_teacher($course); + } - // display button line - $html .= '
'; - $html .= $separator ? '
'.$separator.'
' : ''; - $html .= '
'; - // if user registered as student - if ($userRegisteredInCourse) { - $html .= return_already_registered_label('student'); - if (!$course_closed) { + // display button line + $html .= '
'; + $html .= $separator ? '
'.$separator.'
' : ''; + $html .= '
'; + // if user registered as student + if ($userRegisteredInCourse) { + $html .= return_already_registered_label('student'); + if (!$course_closed) { + if ($course_unsubscribe_allowed) { + $html .= return_unregister_button($course, $stok, $searchTerm, $code); + } + } + } elseif ($userRegisteredInCourseAsTeacher) { + // if user registered as teacher if ($course_unsubscribe_allowed) { $html .= return_unregister_button($course, $stok, $searchTerm, $code); } - } - } elseif ($userRegisteredInCourseAsTeacher) { - // if user registered as teacher - if ($course_unsubscribe_allowed) { - $html .= return_unregister_button($course, $stok, $searchTerm, $code); - } - } else { - // if user not registered in the course - if (!$course_closed) { - if (!$course_private) { - if ($course_subscribe_allowed) { - $html .= $subscribeButton; + } else { + // if user not registered in the course + if (!$course_closed) { + if (!$course_private) { + if ($course_subscribe_allowed) { + $html .= $subscribeButton; + } } } } + $html .= '
'; + $html .= '
'; + $html .= '
'; + $html .= '
'; + $html .= '
'; + echo $html; } - $html .= '
'; - $html .= '
'; - $html .= '
'; - $html .= '
'; - $html .= '
'; - echo $html; - } - echo '
'; - } else { - if (!isset($_REQUEST['subscribe_user_with_password']) && + echo '
'; + } else { + if (!isset($_REQUEST['subscribe_user_with_password']) && !isset($_REQUEST['subscribe_course']) ) { - echo Display::return_message( + echo Display::return_message( get_lang('ThereAreNoCoursesInThisCategory'), 'warning' ); + } } } -} echo '
'; echo $cataloguePagination;