]> git.mjollnir.org Git - moodle.git/commitdiff
roles explanation: MDL-13538 further interface improvements.
authortjhunt <tjhunt>
Thu, 13 Nov 2008 01:44:29 +0000 (01:44 +0000)
committertjhunt <tjhunt>
Thu, 13 Nov 2008 01:44:29 +0000 (01:44 +0000)
admin/roles/explainhascapabiltiy.php
theme/standard/styles_color.css
theme/standard/styles_layout.css

index 44d941212b552808262ce7e727b505b6ad2d7a15..6c7320f070c00d89fbc6131ba47e5eb0c2862451 100644 (file)
@@ -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 '</tr>';
 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>';
 
@@ -187,7 +189,7 @@ foreach ($contexts as $con) {
     } 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 = '';
@@ -195,6 +197,7 @@ foreach ($contexts as $con) {
             $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 = '';
@@ -219,7 +222,13 @@ foreach ($contexts as $con) {
                     $classes .= ' hasnot';
                 }
             }
+            if ($overridden) {
+                $classes .= ' overridden';
+            }
             echo '<td class="cell ' . $classes . '">' . $permission . '</td>';
+            if ($con->firstoverride == $ocon->id) {
+                $overridden = true;
+            }
         }
         echo '</tr>';
         $firstcell = '';
index 87812b74634700d58090b274f8b53430228ce831..f0723e84e986875bf41e206f23e6db32e4d1e557 100644 (file)
@@ -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;
index 524863ef8771250c2e0bb1ecb3047ab16e32a0fc..394776d175d51df4d97dc59a34c86aa1b50cb1f5 100644 (file)
@@ -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 {