FIxed some typos and other logic related to assign_capabilities

This commit is contained in:
moodler 2006-09-12 07:07:30 +00:00
parent 93b7e8d3a7
commit 2e85fffeb1

View file

@ -934,14 +934,12 @@ 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) {
} // Assign a site level capability.
if (!assign_capability($capability, $perm, $role->id, $systemcontext->id)) {
foreach ($roles as $role) { return false;
// Assign a site level capability. }
if (!assign_capability($capability, $perm, $role->id, $systemcontext->id)) {
return false;
} }
} }
} }
@ -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