MDL-52105 enrol_self: Fix wrong holdkey cap restriction for manager
This commit add an upgrade step to remove wrong CAP_PROHIBIT on enrol/self:holdkey for manager role. Also remove the restriction from the self enrolment access file.
This commit is contained in:
@@ -52,9 +52,6 @@ $capabilities = array(
|
||||
|
||||
'captype' => 'write',
|
||||
'contextlevel' => CONTEXT_COURSE,
|
||||
'archetypes' => array(
|
||||
'manager' => CAP_PROHIBIT,
|
||||
)
|
||||
),
|
||||
|
||||
/* Voluntarily unenrol self from course - watch out for data loss. */
|
||||
|
||||
@@ -39,5 +39,24 @@ function xmldb_enrol_self_upgrade($oldversion) {
|
||||
// Moodle v3.1.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Moodle v3.2.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
if ($oldversion < 2016052301) {
|
||||
global $DB;
|
||||
// Get roles with manager archetype.
|
||||
$managerroles = get_archetype_roles('manager');
|
||||
if (!empty($managerroles)) {
|
||||
// Remove wrong CAP_PROHIBIT from self:holdkey.
|
||||
foreach ($managerroles as $role) {
|
||||
$DB->execute("DELETE
|
||||
FROM {role_capabilities}
|
||||
WHERE roleid = ? AND capability = ? AND permission = ?",
|
||||
array($role->id, 'enrol/self:holdkey', CAP_PROHIBIT));
|
||||
}
|
||||
}
|
||||
upgrade_mod_savepoint(true, 2016052301, 'enrol_self');
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$plugin->version = 2016052300; // The current plugin version (Date: YYYYMMDDXX)
|
||||
$plugin->version = 2016052301; // The current plugin version (Date: YYYYMMDDXX)
|
||||
$plugin->requires = 2016051900; // Requires this Moodle version
|
||||
$plugin->component = 'enrol_self'; // Full name of the plugin (used for diagnostics)
|
||||
$plugin->cron = 600;
|
||||
|
||||
Reference in New Issue
Block a user