From 0aa8b11f5cfcd671fb1969253b5e929f77eedf6b Mon Sep 17 00:00:00 2001 From: Adrian Greeve Date: Thu, 8 Dec 2016 13:51:55 +0800 Subject: [PATCH] MDL-57251 administration: Updated coursecreator role. The coursecreator role now has the moodle/site:configview capability so that they have access to the required admin pages. --- lib/db/access.php | 1 + lib/db/upgrade.php | 30 ++++++++++++++++++++++++++++++ version.php | 2 +- 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/lib/db/access.php b/lib/db/access.php index 10242db5b5c..8154cf28353 100644 --- a/lib/db/access.php +++ b/lib/db/access.php @@ -69,6 +69,7 @@ $capabilities = array( 'contextlevel' => CONTEXT_SYSTEM, 'archetypes' => array( 'manager' => CAP_ALLOW, + 'coursecreator' => CAP_ALLOW, ) ), diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index da208239457..d7bf3e8b009 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -2436,5 +2436,35 @@ function xmldb_main_upgrade($oldversion) { // Automatically generated Moodle v3.2.0 release upgrade line. // Put any upgrade step following this. + if ($oldversion < 2016120500.03) { + // Find all roles with the coursecreator archetype. + $coursecreatorroleids = $DB->get_records('role', array('archetype' => 'coursecreator'), '', 'id'); + + $context = context_system::instance(); + $capability = 'moodle/site:configview'; + + foreach ($coursecreatorroleids as $roleid => $notused) { + + // Check that the capability has not already been assigned. If it has then it's either already set + // to allow or specifically set to prohibit or prevent. + if (!$DB->record_exists('role_capabilities', array('roleid' => $roleid, 'capability' => $capability))) { + // Assign the capability. + $cap = new stdClass(); + $cap->contextid = $context->id; + $cap->roleid = $roleid; + $cap->capability = $capability; + $cap->permission = CAP_ALLOW; + $cap->timemodified = time(); + $cap->modifierid = 0; + + $DB->insert_record('role_capabilities', $cap); + } + } + $context->mark_dirty(); + + // Main savepoint reached. + upgrade_main_savepoint(true, 2016120500.03); + } + return true; } diff --git a/version.php b/version.php index 67e133cbae2..8de1673f228 100644 --- a/version.php +++ b/version.php @@ -29,7 +29,7 @@ defined('MOODLE_INTERNAL') || die(); -$version = 2016120500.02; // 20161205 = branching date YYYYMMDD - do not modify! +$version = 2016120500.03; // 20161205 = branching date YYYYMMDD - do not modify! // RR = release increments - 00 in DEV branches. // .XX = incremental changes.