Fixing my buggy implementation of isteacherinanycourse().

This fixes bugs 2455, 2456 and maybe some others Eagle Eyes didn't have
the time to find. ;-)
This commit is contained in:
defacer 2005-01-31 00:48:23 +00:00
parent 8cd1bc7804
commit fddbcf9c68

View file

@ -1317,6 +1317,8 @@ function isteacher($courseid, $userid=0, $includeadmin=true) {
* @todo Finish documenting this function * @todo Finish documenting this function
*/ */
function isteacherinanycourse($userid = 0, $includeadmin = true) { function isteacherinanycourse($userid = 0, $includeadmin = true) {
global $USER;
if(empty($userid)) { if(empty($userid)) {
if(empty($USER) || empty($USER->id)) { if(empty($USER) || empty($USER->id)) {
return false; return false;
@ -1324,6 +1326,10 @@ function isteacherinanycourse($userid = 0, $includeadmin = true) {
$userid = $USER->id; $userid = $USER->id;
} }
if (isadmin($userid) && $includeadmin) { // admins can do anything
return true;
}
return record_exists('user_teachers', 'userid', $userid); return record_exists('user_teachers', 'userid', $userid);
} }