From: defacer Date: Mon, 31 Jan 2005 00:48:23 +0000 (+0000) Subject: Fixing my buggy implementation of isteacherinanycourse(). X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=fddbcf9c687bba24af9d6f127af5f61d52bd34c0;p=moodle.git Fixing my buggy implementation of isteacherinanycourse(). This fixes bugs 2455, 2456 and maybe some others Eagle Eyes didn't have the time to find. ;-) --- diff --git a/lib/moodlelib.php b/lib/moodlelib.php index 360a8fe56d..221b5adb75 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -1317,6 +1317,8 @@ function isteacher($courseid, $userid=0, $includeadmin=true) { * @todo Finish documenting this function */ function isteacherinanycourse($userid = 0, $includeadmin = true) { + global $USER; + if(empty($userid)) { if(empty($USER) || empty($USER->id)) { return false; @@ -1324,6 +1326,10 @@ function isteacherinanycourse($userid = 0, $includeadmin = true) { $userid = $USER->id; } + if (isadmin($userid) && $includeadmin) { // admins can do anything + return true; + } + return record_exists('user_teachers', 'userid', $userid); }