break;
case 'visible':
- if (has_capability('moodle/category:manage', $context)
- or has_capability('moodle/category:viewhiddencategories',
- context_system::instance())) {
+ if (has_capability('moodle/category:viewhiddencategories', $context)) {
$value = clean_param($crit['value'], PARAM_INT);
$conditions[$key] = $value;
$wheres[] = $key . " = :" . $key;
if (!isset($excludedcats[$category->id])) {
// Final check to see if the category is visible to the user.
- if ($category->visible
- or has_capability('moodle/category:viewhiddencategories', context_system::instance())
- or has_capability('moodle/category:manage', $context)) {
+ if ($category->visible or has_capability('moodle/category:viewhiddencategories', $context)) {
$categoryinfo = array();
$categoryinfo['id'] = $category->id;
// Set the required capabilities by the external function.
$context = context_system::instance();
$roleid = $this->assignUserCapability('moodle/category:manage', $context->id);
+ $this->assignUserCapability('moodle/category:viewhiddencategories', $context->id, $roleid);
// Retrieve category1 + sub-categories except not visible ones
$categories = core_course_external::get_categories(array(
$this->assertEquals($DB->count_records('course_categories'), count($categories));
- $this->unassignUserCapability('moodle/category:manage', $context->id, $roleid);
+ $this->unassignUserCapability('moodle/category:viewhiddencategories', $context->id, $roleid);
- // Ensure maxdepthcategory is 2 and retrieve all categories without category:manage capability. It should retrieve all
- // visible categories as well.
+ // Ensure maxdepthcategory is 2 and retrieve all categories without category:viewhiddencategories capability.
+ // It should retrieve all visible categories as well.
set_config('maxcategorydepth', 2);
$categories = core_course_external::get_categories();