From d4c4ecb808614bda71c56b351ff56f4e87092fe2 Mon Sep 17 00:00:00 2001 From: martinlanghoff Date: Wed, 19 Sep 2007 07:22:12 +0000 Subject: [PATCH] accesslib: get_user_access_sitewide() fix invalid SQL for users without RAs --- lib/accesslib.php | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/lib/accesslib.php b/lib/accesslib.php index 23446ea6b6..7ff3b01fd9 100755 --- a/lib/accesslib.php +++ b/lib/accesslib.php @@ -1264,23 +1264,26 @@ function get_user_access_sitewide($userid) { } } $clauses = join(" OR ", $clauses); - $sql = "SELECT ctx.path, rc.roleid, rc.capability, rc.permission - FROM {$CFG->prefix}role_capabilities rc - JOIN {$CFG->prefix}context ctx - ON rc.contextid=ctx.id - WHERE $clauses - ORDER BY ctx.depth ASC, ctx.path DESC, rc.roleid ASC "; + if ($clauses !== '') { + $sql = "SELECT ctx.path, rc.roleid, rc.capability, rc.permission + FROM {$CFG->prefix}role_capabilities rc + JOIN {$CFG->prefix}context ctx + ON rc.contextid=ctx.id + WHERE $clauses + ORDER BY ctx.depth ASC, ctx.path DESC, rc.roleid ASC "; - $rs = get_recordset_sql($sql); + $rs = get_recordset_sql($sql); + unset($clauses); - if ($rs->RecordCount()) { - while ($rd = rs_fetch_next_record($rs)) { - $k = "{$rd->path}:{$rd->roleid}"; - $acc['rdef'][$k][$rd->capability] = $rd->permission; + if ($rs->RecordCount()) { + while ($rd = rs_fetch_next_record($rs)) { + $k = "{$rd->path}:{$rd->roleid}"; + $acc['rdef'][$k][$rd->capability] = $rd->permission; + } + unset($rd); } - unset($rd); + rs_close($rs); } - rs_close($rs); // // Overrides for the role assignments IN SUBCONTEXTS -- 2.39.5