diff --git a/admin/roles/explainhascapabiltiy.php b/admin/roles/explainhascapabiltiy.php
index 44d941212b5..6c7320f070c 100644
--- a/admin/roles/explainhascapabiltiy.php
+++ b/admin/roles/explainhascapabiltiy.php
@@ -14,9 +14,11 @@ if (!$context) {
$contextids = get_parent_contexts($context);
array_unshift($contextids, $context->id);
$contexts = array();
+$number = count($contextids);
foreach ($contextids as $contextid) {
$contexts[$contextid] = get_context_instance_by_id($contextid);
$contexts[$contextid]->name = print_context_name($contexts[$contextid], true, true);
+ $contexts[$contextid]->number = $number--;
}
// Validate the user id.
@@ -89,6 +91,7 @@ foreach ($contexts as $con) {
} else {
$ras = array();
}
+ $con->firstoverride = 0;
foreach ($contexts as $ocon) {
$summedpermission = 0;
$gotsomething = false;
@@ -98,24 +101,23 @@ foreach ($contexts as $con) {
} else {
$perm = CAP_INHERIT;
}
+ if ($perm && !$gotsomething) {
+ $gotsomething = true;
+ $con->firstoverride = $ocon->id;
+ }
if ($perm == CAP_PROHIBIT) {
$areprohibits = true;
$decisiveassigncon = 0;
$decisiveoverridecon = 0;
- break 3;
- }
- if ($perm) {
- $gotsomething = true;
+ break;
}
$summedpermission += $perm;
}
- if ($summedpermission) {
+ if (!$areprohibits && !$decisiveassigncon && $summedpermission) {
$decisiveassigncon = $con->id;
$decisiveoverridecon = $ocon->id;
- break 2;
+ break;
} else if ($gotsomething) {
- // This else clause makes sure this page matches the actual behaviour of
- // has_capability, which I believe is buggy. See MDL-17210.
break;
}
}
@@ -174,7 +176,7 @@ echo '';
echo '
';
foreach (array_slice($contexts, 0, count($contexts) - 1) as $con) {
- echo '';
+ echo '';
}
echo '
';
@@ -187,7 +189,7 @@ foreach ($contexts as $con) {
} else {
$ras = array(0);
}
- $firstcell = '' . $con->id . ' ' . $con->name . ' | ';
+ $firstcell = '' . $con->number . '. ' . $con->name . ' | ';
$rowclass = ' class="newcontext"';
foreach ($ras as $roleid) {
$extraclass = '';
@@ -195,6 +197,7 @@ foreach ($contexts as $con) {
$extraclass = ' noroles';
}
echo '' . $firstcell . '';
+ $overridden = false;
foreach ($contexts as $ocon) {
if ($roleid == 0) {
$perm = '';
@@ -219,7 +222,13 @@ foreach ($contexts as $con) {
$classes .= ' hasnot';
}
}
+ if ($overridden) {
+ $classes .= ' overridden';
+ }
echo '| ' . $permission . ' | ';
+ if ($con->firstoverride == $ocon->id) {
+ $overridden = true;
+ }
}
echo '
';
$firstcell = '';
diff --git a/theme/standard/styles_color.css b/theme/standard/styles_color.css
index 87812b74634..f0723e84e98 100644
--- a/theme/standard/styles_color.css
+++ b/theme/standard/styles_color.css
@@ -1174,15 +1174,16 @@ table.explainpermissions .decisive.has,
background-color: #ddffdd;
}
table.explainpermissions .decisive.hasnot,
+table.explainpermissions .prohibit,
#explaincaps .rolecap.no {
background-color: #ffdddd;
}
-table.explainpermissions .prohibit {
- background-color: #ffbbff;
- font-weight: bold;
-}
+table.explainpermissions .prohibit,
table.explainpermissions .decisive {
- font-weight: bold;
+ font-weight: bold;
+}
+table.explainpermissions .overridden {
+ text-decoration: line-through;
}
#admin-roles-manage .capdefault {
background-color:#dddddd;
diff --git a/theme/standard/styles_layout.css b/theme/standard/styles_layout.css
index 524863ef877..394776d175d 100644
--- a/theme/standard/styles_layout.css
+++ b/theme/standard/styles_layout.css
@@ -1178,6 +1178,7 @@ table.explainpermissions th.cell,
table.explainpermissions td.cell {
border-left: 1px solid black;
border-right: 1px solid black;
+ vertical-align: middle;
}
table.explainpermissions .newcontext .cell,
table.explainpermissions .row2 th.header {