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.
This commit is contained in:
Adrian Greeve
2016-12-20 14:54:34 +08:00
parent 1ca30f2503
commit 0aa8b11f5c
3 changed files with 32 additions and 1 deletions
+1
View File
@@ -69,6 +69,7 @@ $capabilities = array(
'contextlevel' => CONTEXT_SYSTEM,
'archetypes' => array(
'manager' => CAP_ALLOW,
'coursecreator' => CAP_ALLOW,
)
),
+30
View File
@@ -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;
}
+1 -1
View File
@@ -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.