$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.
} else {
$ras = array();
}
+ $con->firstoverride = 0;
foreach ($contexts as $ocon) {
$summedpermission = 0;
$gotsomething = false;
} 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;
}
}
echo '<tr class="row2"><th scope="col" class="header assignment">' . get_string('context', 'role') .
'</th><th scope="col" class="header assignment">' . get_string('role') . '</th>';
foreach (array_slice($contexts, 0, count($contexts) - 1) as $con) {
- echo '<th scope="col" class="header overridecontext">' . $con->id . '</th>';
+ echo '<th scope="col" class="header overridecontext">' . $con->number . '</th>';
}
echo '</tr></thead><tbody>';
} else {
$ras = array(0);
}
- $firstcell = '<th class="cell assignment" rowspan="' . count($ras) . '">' . $con->id . ' ' . $con->name . '</th>';
+ $firstcell = '<th class="cell assignment" rowspan="' . count($ras) . '">' . $con->number . '. ' . $con->name . '</th>';
$rowclass = ' class="newcontext"';
foreach ($ras as $roleid) {
$extraclass = '';
$extraclass = ' noroles';
}
echo '<tr' . $rowclass . '>' . $firstcell . '<th class="cell assignment' . $extraclass . '" scope="row">' . $rolenames[$roleid] . '</th>';
+ $overridden = false;
foreach ($contexts as $ocon) {
if ($roleid == 0) {
$perm = '';
$classes .= ' hasnot';
}
}
+ if ($overridden) {
+ $classes .= ' overridden';
+ }
echo '<td class="cell ' . $classes . '">' . $permission . '</td>';
+ if ($con->firstoverride == $ocon->id) {
+ $overridden = true;
+ }
}
echo '</tr>';
$firstcell = '';
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;