mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 08:56:36 +02:00
FIxed some typos and other logic related to assign_capabilities
This commit is contained in:
parent
93b7e8d3a7
commit
2e85fffeb1
1 changed files with 8 additions and 11 deletions
|
@ -934,10 +934,7 @@ function assign_legacy_capabilities($capability, $legacyperms) {
|
||||||
// 'moodle/legacy:coursecreator'
|
// 'moodle/legacy:coursecreator'
|
||||||
// 'moodle/legacy:admin'
|
// 'moodle/legacy:admin'
|
||||||
|
|
||||||
if (!$roles = get_roles_with_capability('moodle/legacy:'.$type, CAP_ALLOW)) {
|
if ($roles = get_roles_with_capability('moodle/legacy:'.$type, CAP_ALLOW)) {
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($roles as $role) {
|
foreach ($roles as $role) {
|
||||||
// Assign a site level capability.
|
// Assign a site level capability.
|
||||||
if (!assign_capability($capability, $perm, $role->id, $systemcontext->id)) {
|
if (!assign_capability($capability, $perm, $role->id, $systemcontext->id)) {
|
||||||
|
@ -945,6 +942,7 @@ function assign_legacy_capabilities($capability, $legacyperms) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1125,7 +1123,7 @@ function assign_capability($capability, $permission, $roleid, $contextid, $overw
|
||||||
unassign_capability($capability, $roleid, $contextid);
|
unassign_capability($capability, $roleid, $contextid);
|
||||||
}
|
}
|
||||||
|
|
||||||
$existing = get_record('role_capabilities', 'contextid', $contextid, 'roleid', $capability, $capability);
|
$existing = get_record('role_capabilities', 'contextid', $contextid, 'roleid', $roleid, 'capability', $capability);
|
||||||
|
|
||||||
if ($existing and !$overwrite) { // We want to keep whatever is there already
|
if ($existing and !$overwrite) { // We want to keep whatever is there already
|
||||||
return true;
|
return true;
|
||||||
|
@ -1441,8 +1439,7 @@ function update_capabilities($component='moodle') {
|
||||||
// legacy capabilities moodle/legacy:* as well?
|
// legacy capabilities moodle/legacy:* as well?
|
||||||
if (isset($capdef['legacy']) && is_array($capdef['legacy']) &&
|
if (isset($capdef['legacy']) && is_array($capdef['legacy']) &&
|
||||||
!assign_legacy_capabilities($capname, $capdef['legacy'])) {
|
!assign_legacy_capabilities($capname, $capdef['legacy'])) {
|
||||||
error('Could not assign legacy capabilities');
|
notify('Could not assign legacy capabilities for '.$capname);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Are there any capabilities that have been removed from the file
|
// Are there any capabilities that have been removed from the file
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue