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:
Simey Lameze
2016-08-15 12:56:51 +08:00
parent 6f302b17b9
commit 33b6da5327
3 changed files with 20 additions and 4 deletions
-3
View File
@@ -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. */
+19
View File
@@ -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;
}
+1 -1
View File
@@ -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;