diff --git a/admin/roles/manage.html b/admin/roles/manage.html
index 9a357ac63a4..18f5f3e460b 100755
--- a/admin/roles/manage.html
+++ b/admin/roles/manage.html
@@ -34,26 +34,54 @@
: |
description); $usehtmleditor = false; ?> |
+
+ | : |
+ legacytype)) {
+ print_string('none');
+ } else {
+ print_string('legacy:'.$role->legacytype, 'role');
+ }
+ ?>
+ |
+
|
name).'" />';
if (isset($errors["name"])) formerr($errors["name"]);
- ?> |
+ ?>
+
|
shortname).'" />';
if (isset($errors["shortname"])) formerr($errors["shortname"]);
- ?> |
+ ?>
+
|
description);
- ?> |
+ ?>
+
+
+
+ |
+ $lcap) {
+ $options[$ltype] = get_string('legacy:'.$ltype, 'role');
+ }
+ choose_from_menu($options, 'legacytype', $role->legacytype, '');
+ ?>
+ |
@@ -88,27 +116,19 @@ $strrisks = s(get_string('risks', 'role'));
$strcapabilities = s(get_string('capabilities', 'role'));
// prepare legacy defaults
-$legacyroles = get_legacy_roles();
-
-$defaultcaps = false;
-foreach($legacyroles as $ltype=>$lcap) {
- if (empty($errors)) {
- // check the capability override for this cap, this role in this context
- $localoverride = get_local_override($roleid, $sitecontext->id, $lcap);
- } else {
- $localoverride->permission = $role->{$lcap};
- }
- if (!empty($localoverride->permission) and $localoverride->permission == CAP_ALLOW) {
- if ($defaultcaps !== false) {
- //oh, several legacy caps selected!
- $defaultcaps = false;
- break;
- }
- $defaultcaps = get_default_capabilities($ltype);
- }
+if (!empty($role->legacytype)) {
+ $defaultcaps = get_default_capabilities($role->legacytype);
+} else {
+ $defaultcaps = false;
}
foreach ($capabilities as $capability) {
+
+ //legacy caps have their own selector
+ if (strpos($capability->name, 'moodle/legacy:') === 0 ) {
+ continue;
+ }
+
// prints a breaker if component or name or context level
if ($capability->component != $component or $capability->contextlevel != $contextlevel) {
echo ('');
@@ -59,7 +65,7 @@
$isprohibit = 0;
}
- $isdisabled = $isprohibit || islegacy($capability->name);
+ $isdisabled = $isprohibit;
$riskinfo = '';
$rowclasses = '';
diff --git a/admin/roles/override.php b/admin/roles/override.php
index 8f1700b0f89..b031d785204 100755
--- a/admin/roles/override.php
+++ b/admin/roles/override.php
@@ -90,6 +90,10 @@
continue;
}
+ if (islegacy($data->{$cap->name})) {
+ continue;
+ }
+
$capname = $cap->name;
$value = clean_param($data->{$cap->name}, PARAM_INT);
if (!in_array($value, $allowed_values)) {
diff --git a/lang/en_utf8/role.php b/lang/en_utf8/role.php
index b220b6f660a..75172632ab0 100644
--- a/lang/en_utf8/role.php
+++ b/lang/en_utf8/role.php
@@ -65,6 +65,7 @@ $string['legacy:guest'] = 'LEGACY ROLE: Guest';
$string['legacy:student'] = 'LEGACY ROLE: Student';
$string['legacy:teacher'] = 'LEGACY ROLE: Teacher (non-editing)';
$string['legacy:user'] = 'LEGACY ROLE: Authenticated user';
+$string['legacytype'] = 'Legacy role type';
$string['listallroles'] = 'List all roles';
$string['manageroles'] = 'Manage roles';
$string['metaassignerror'] = 'Can not assign this role to user \"$a\" because Manage metacourse capability is needed.';
diff --git a/lib/accesslib.php b/lib/accesslib.php
index 5632324670a..fbcb5016d2d 100755
--- a/lib/accesslib.php
+++ b/lib/accesslib.php
@@ -1628,10 +1628,10 @@ function assign_legacy_capabilities($capability, $legacyperms) {
* @return boolean
*/
function islegacy($capabilityname) {
- if (strstr($capabilityname, 'legacy') === false) {
- return false;
- } else {
+ if (strpos($capabilityname, 'moodle/legacy') === 0) {
return true;
+ } else {
+ return false;
}
}
|