]> git.mjollnir.org Git - moodle.git/commitdiff
Fixes bug, "Warning: Invalid argument supplied for foreach() in /var/www/html/ndf42...
authornfreear <nfreear>
Tue, 10 Oct 2006 11:03:35 +0000 (11:03 +0000)
committernfreear <nfreear>
Tue, 10 Oct 2006 11:03:35 +0000 (11:03 +0000)
lib/blocklib.php

index e7a8930f7fd7994b71ac19c2c9b19069655c03f6..80e55cc55115ef26ebccf7127e7fd588648a789f 100644 (file)
@@ -171,13 +171,15 @@ function blocks_name_allowed_in_format($name, $pageformat) {
     $formats = block_method_result($name, 'applicable_formats');
     $accept  = NULL;
     $depth   = -1;
-    foreach($formats as $format => $allowed) {
-        $thisformat = '^'.str_replace('*', '[^-]*', $format).'.*$';
-        if(ereg($thisformat, $pageformat)) {
-            if(($scount = substr_count($format, '-')) > $depth) {
-                $depth  = $scount;
-                $accept = $allowed;
-            }
+    if (isset($formats)) {
+        foreach($formats as $format => $allowed) {
+            $thisformat = '^'.str_replace('*', '[^-]*', $format).'.*$';
+            if(ereg($thisformat, $pageformat)) {
+                if(($scount = substr_count($format, '-')) > $depth) {
+                    $depth  = $scount;
+                    $accept = $allowed;
+               }
+           }
         }
     }
     if($accept === NULL) {