diff --git a/block_overviewmyrolesincourses.php b/block_overviewmyrolesincourses.php index 3b4842a..208e463 100644 --- a/block_overviewmyrolesincourses.php +++ b/block_overviewmyrolesincourses.php @@ -64,7 +64,9 @@ public function get_content() { global $USER, $OUTPUT; $foldonstart = $this->config->foldonstart; // 1. Find all courses a user is enrolled. - $enroledcourses = enrol_get_my_courses(); + $enroledcourses = get_config('block_overviewmyrolesincourses', 'defaultskipcoursecapabilitycheck') + ? enrol_get_all_users_courses($USER->id) + : enrol_get_my_courses(); $text = ''; if ($enroledcourses) { // 2. Find all roles that the admin has configured as supported roles for this block. @@ -139,10 +141,6 @@ public function get_courses_enroled_with_roleid( $result = []; foreach ($enroledcourses as $enroledcourse) { $coursecontext = context_course::instance($enroledcourse->id); - if ($enroledcourse->visible == 0 && !has_capability('moodle/course:viewhiddencourses', $coursecontext)) { - // Only show invisible courses if capability moodle/course:viewhiddencourses on this coursecontext. - continue; - } $showpast = $this->config->showpast; $showinprogress = $this->config->showinprogress; $showfuture = $this->config->showfuture; diff --git a/lang/en/block_overviewmyrolesincourses.php b/lang/en/block_overviewmyrolesincourses.php index 8358e77..02079f6 100644 --- a/lang/en/block_overviewmyrolesincourses.php +++ b/lang/en/block_overviewmyrolesincourses.php @@ -46,6 +46,8 @@ $string['defaultusetimeranges_desc'] = 'By default show course duration'; $string['defaultusecategories'] = 'Show course category'; $string['defaultusecategories_desc'] = 'By default show course category'; +$string['defaultskipcoursecapabilitycheck'] = 'Skip checking capability to view hidden courses/categories'; +$string['defaultskipcoursecapabilitycheck_desc'] = 'By default skip checking capability to view hidden courses/categories'; $string['foldonstart'] = 'Fold courselists on start'; $string['future'] = 'future'; $string['inprogress'] = 'in progress'; diff --git a/settings.php b/settings.php index 314fd97..7aef0d3 100644 --- a/settings.php +++ b/settings.php @@ -110,4 +110,10 @@ get_string('defaultusecategories_desc', 'block_overviewmyrolesincourses'), 0 )); + $settings->add(new admin_setting_configcheckbox( + 'block_overviewmyrolesincourses/defaultskipcoursecapabilitycheck', + get_string('defaultskipcoursecapabilitycheck', 'block_overviewmyrolesincourses'), + get_string('defaultskipcoursecapabilitycheck_desc', 'block_overviewmyrolesincourses'), + 0 + )); }