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, $categoryCode,
$searchTerm, $searchTerm,
true, true,
true,
$conditions $conditions
); );
} }

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

Loading…
Cancel
Save