Course category: Add $checkHidePrivate parameter BT#18434

Allow admin to see the count of private courses
pull/3814/head
Julio Montoya 5 years ago
parent 08e5c0dbf3
commit deeb1db220
  1. 1
      main/auth/courses.php
  2. 22
      main/inc/lib/course_category.lib.php

@ -284,6 +284,7 @@ switch ($action) {
$categoryCode,
$searchTerm,
true,
true,
$conditions
);
}

@ -520,7 +520,7 @@ class CourseCategory
$url
);
$countCourses = self::countCoursesInCategory($category['code'], null, false);
$countCourses = self::countCoursesInCategory($category['code'], null, false, false);
$content = [
$title,
@ -596,8 +596,9 @@ class CourseCategory
/**
* @param string $category_code
* @param string $keyword
* @paran bool $avoidCourses
* @paran array $conditions
* @param bool $avoidCourses
* @param bool $checkHidePrivate
* @param array $conditions
*
* @return int
*/
@ -605,12 +606,20 @@ class CourseCategory
$category_code = '',
$keyword = '',
$avoidCourses = true,
$checkHidePrivate = true,
$conditions = []
) {
return self::getCoursesInCategory($category_code, $keyword, $avoidCourses, $conditions, true);
return self::getCoursesInCategory(
$category_code,
$keyword,
$avoidCourses,
$checkHidePrivate,
$conditions,
true
);
}
public static function getCoursesInCategory($category_code = '', $keyword = '', $avoidCourses = true, $conditions = [], $getCount = false)
public static function getCoursesInCategory($category_code = '', $keyword = '', $avoidCourses = true, $checkHidePrivate = true, $conditions = [], $getCount = false)
{
$tbl_course = Database::get_main_table(TABLE_MAIN_COURSE);
$categoryCode = Database::escape_string($category_code);
@ -620,8 +629,7 @@ class CourseCategory
if ($avoidCourses) {
$avoidCoursesCondition = CoursesAndSessionsCatalog::getAvoidCourseCondition();
}
$visibilityCondition = CourseManager::getCourseVisibilitySQLCondition('course', true);
$visibilityCondition = CourseManager::getCourseVisibilitySQLCondition('course', true, $checkHidePrivate);
$sqlInjectJoins = '';
$where = ' AND 1 = 1 ';

Loading…
Cancel
Save