From 2e059c7709c5b847154462252c62499b8e35a067 Mon Sep 17 00:00:00 2001 From: martinlanghoff Date: Wed, 19 Sep 2007 07:04:37 +0000 Subject: [PATCH] accesslib: get_user_courses_bycap() - make $doanything work in the optimised path OMG! Bugfix! --- lib/accesslib.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/accesslib.php b/lib/accesslib.php index 88e6d163ce..e1f884989e 100755 --- a/lib/accesslib.php +++ b/lib/accesslib.php @@ -746,6 +746,11 @@ function get_user_courses_bycap($userid, $cap, $sess, $doanything, $sort='c.sort $catclause = 'OR (' . join(' OR ', $catpaths) .')'; } unset($catpaths); + + $capany = ''; + if ($doanything) { + $capany = " OR rc.capability='moodle/site:doanything'"; + } // // Note here that we *have* to have the compound clauses // in the LEFT OUTER JOIN condition for them to return NULL @@ -759,7 +764,7 @@ function get_user_courses_bycap($userid, $cap, $sess, $doanything, $sort='c.sort LEFT OUTER JOIN {$CFG->prefix}role_assignments ra ON (ra.contextid=ctx.id AND ra.userid=$userid) LEFT OUTER JOIN {$CFG->prefix}role_capabilities rc - ON (rc.contextid=ctx.id AND rc.capability='$cap') + ON (rc.contextid=ctx.id AND (rc.capability='$cap' $capany)) WHERE ra.id IS NOT NULL OR rc.id IS NOT NULL $catclause -- 2.39.5