]> git.mjollnir.org Git - moodle.git/commitdiff
Reproduce MDL-17210 in this code, until it is fixed.
authortjhunt <tjhunt>
Wed, 12 Nov 2008 08:28:52 +0000 (08:28 +0000)
committertjhunt <tjhunt>
Wed, 12 Nov 2008 08:28:52 +0000 (08:28 +0000)
admin/roles/explainhascapabiltiy.php

index 12280173f20358c85f0486f34d82fd4c38e3c21f..5dfba3f55d0f4809ee3c65475e00430fff2218c1 100644 (file)
@@ -91,6 +91,7 @@ foreach ($contexts as $con) {
     }
     foreach ($contexts as $ocon) {
         $summedpermission = 0;
+        $gotsomething = false;
         foreach ($ras as $roleid) {
             if (isset($accessdata['rdef'][$ocon->path . ':' . $roleid][$capability])) {
                 $perm = $accessdata['rdef'][$ocon->path . ':' . $roleid][$capability];
@@ -103,12 +104,19 @@ foreach ($contexts as $con) {
                 $decisiveoverridecon = 0;
                 break 3;
             }
+            if ($perm) {
+                $gotsomething = true;
+            }
             $summedpermission += $perm;
         }
         if ($summedpermission) {
             $decisiveassigncon = $con->id;
             $decisiveoverridecon = $ocon->id;
             break 2;
+        } 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;
         }
     }
 }