From dc191af610b7cc7f5688e43d2b2a31c0ba01ef82 Mon Sep 17 00:00:00 2001 From: tjhunt Date: Thu, 13 Nov 2008 01:44:29 +0000 Subject: [PATCH] roles explanation: MDL-13538 further interface improvements. --- admin/roles/explainhascapabiltiy.php | 29 ++++++++++++++++++---------- theme/standard/styles_color.css | 11 ++++++----- theme/standard/styles_layout.css | 1 + 3 files changed, 26 insertions(+), 15 deletions(-) diff --git a/admin/roles/explainhascapabiltiy.php b/admin/roles/explainhascapabiltiy.php index 44d941212b..6c7320f070 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 '' . get_string('context', 'role') . '' . get_string('role') . ''; foreach (array_slice($contexts, 0, count($contexts) - 1) as $con) { - echo '' . $con->id . ''; + echo '' . $con->number . ''; } 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 . '' . $rolenames[$roleid] . ''; + $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 87812b7463..f0723e84e9 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 524863ef87..394776d175 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 { -- 2.39.5