From 5604e87f45f4f3cd4f780604de79620a9afbe35b Mon Sep 17 00:00:00 2001 From: Jakob Date: Tue, 12 Apr 2016 15:35:12 -0700 Subject: [PATCH] MDL-37765 Add capability to ignore conditional access.php Adding additional capability to bypass conditional restrictions on activities. --- availability/classes/info.php | 5 +++++ lang/en/role.php | 1 + lib/db/access.php | 11 +++++++++++ 3 files changed, 17 insertions(+) diff --git a/availability/classes/info.php b/availability/classes/info.php index afd1d40..592ba15 100644 --- a/availability/classes/info.php +++ b/availability/classes/info.php @@ -186,6 +186,11 @@ abstract class info { if (!$userid) { $userid = $USER->id; } + + if (has_capability('moodle/course:ignoreavailabilityrestrictions', $this->get_context(), $userid)) { + return true; + } + if (!$modinfo) { $modinfo = get_fast_modinfo($this->course, $userid); } diff --git a/lang/en/role.php b/lang/en/role.php index 6114201..e6f8987 100644 --- a/lang/en/role.php +++ b/lang/en/role.php @@ -140,6 +140,7 @@ $string['course:managegroups'] = 'Manage groups'; $string['course:managescales'] = 'Manage scales'; $string['course:markcomplete'] = 'Mark users as complete in course completion'; $string['course:movesections'] = 'Move sections'; +$string['course:ignoreavailabilityrestrictions'] = 'Ignore availability restrictions.'; $string['course:publish'] = 'Publish a course into hub'; $string['course:request'] = 'Request new courses'; $string['course:reset'] = 'Reset course'; diff --git a/lib/db/access.php b/lib/db/access.php index e8fac11..121c859 100644 --- a/lib/db/access.php +++ b/lib/db/access.php @@ -924,6 +924,17 @@ $capabilities = array( ) ), + 'moodle/course:ignoreavailabilityrestrictions' => array( + + 'captype' => 'read', + 'contextlevel' => CONTEXT_MODULE, + 'archetypes' => array( + 'teacher' => CAP_ALLOW, + 'editingteacher' => CAP_ALLOW, + 'manager' => CAP_ALLOW + ) + ), + 'moodle/course:viewparticipants' => array( 'captype' => 'read', -- 1.9.5.msysgit.0