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:
@@ -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;
|
||||
}
|
||||
|
||||
+1
-1
@@ -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.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user