mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 08:56:36 +02:00
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:
parent
8cd1bc7804
commit
fddbcf9c68
1 changed files with 6 additions and 0 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue