From fddbcf9c687bba24af9d6f127af5f61d52bd34c0 Mon Sep 17 00:00:00 2001 From: defacer Date: Mon, 31 Jan 2005 00:48:23 +0000 Subject: [PATCH] Fixing my buggy implementation of isteacherinanycourse(). This fixes bugs 2455, 2456 and maybe some others Eagle Eyes didn't have the time to find. ;-) --- lib/moodlelib.php | 6 ++++++ 1 file changed, 6 insertions(+) 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); } -- 2.39.5