Commit b1eb88a4 authored by Adrian Greeve's avatar Adrian Greeve
Browse files

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.
parent 5100c486
......@@ -69,6 +69,7 @@ $capabilities = array(
'contextlevel' => CONTEXT_SYSTEM,
'archetypes' => array(
'manager' => CAP_ALLOW,
'coursecreator' => CAP_ALLOW,
)
),
......
......@@ -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;
}
......@@ -29,7 +29,7 @@
defined('MOODLE_INTERNAL') || die();
$version = 2016120500.02; // YYYYMMDD = weekly release date of this DEV branch.
$version = 2016120500.03; // YYYYMMDD = weekly release date of this DEV branch.
// RR = release increments - 00 in DEV branches.
// .XX = incremental changes.
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment