]> git.mjollnir.org Git - moodle.git/commitdiff
Fixes MDL-12125, Call to a member function FetchRow on a non-object in get_user_acces...
authornfreear <nfreear>
Mon, 12 Nov 2007 16:53:53 +0000 (16:53 +0000)
committernfreear <nfreear>
Mon, 12 Nov 2007 16:53:53 +0000 (16:53 +0000)
lib/accesslib.php

index 233dcd9a7057d9dd7bf95b84e694b67148c97510..16c712c4694622d589374504688e3a06ec94b651 100755 (executable)
@@ -1258,12 +1258,14 @@ function get_user_access_sitewide($userid) {
         $rs = get_recordset_sql($sql);
         unset($clauses);
 
-        while ($rd = rs_fetch_next_record($rs)) {
-            $k = "{$rd->path}:{$rd->roleid}";
-            $accessdata['rdef'][$k][$rd->capability] = $rd->permission;
+        if ($rs) {
+            while ($rd = rs_fetch_next_record($rs)) {
+                $k = "{$rd->path}:{$rd->roleid}";
+                $accessdata['rdef'][$k][$rd->capability] = $rd->permission;
+            }
+            unset($rd);
+            rs_close($rs);
         }
-        unset($rd);
-        rs_close($rs);
     }
 
     //
@@ -1289,13 +1291,14 @@ function get_user_access_sitewide($userid) {
             ORDER BY sctx.depth, sctx.path, ra.roleid";
 
     $rs = get_recordset_sql($sql);
-    while ($rd = rs_fetch_next_record($rs)) {
-        $k = "{$rd->path}:{$rd->roleid}";
-        $accessdata['rdef'][$k][$rd->capability] = $rd->permission;
+    if ($rs) {
+        while ($rd = rs_fetch_next_record($rs)) {
+            $k = "{$rd->path}:{$rd->roleid}";
+            $accessdata['rdef'][$k][$rd->capability] = $rd->permission;
+        }
+        unset($rd);
+        rs_close($rs);
     }
-    unset($rd);
-    rs_close($rs);
-
     return $accessdata;
 }