From cc4a7edf6f87ce742c449966aacc1c1b4feea24a Mon Sep 17 00:00:00 2001 From: gustav_delius Date: Mon, 30 Aug 2004 08:49:01 +0000 Subject: [PATCH] course teachers are also site students. This implements the rule described in http://moodle.org/mod/forum/discuss.php?d=8452#56678. This commit is probably pointless because the rules are likely to change again soon. I won't merge it onto HEAD. --- lib/datalib.php | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/lib/datalib.php b/lib/datalib.php index a01781c9529..d01ab5d1412 100644 --- a/lib/datalib.php +++ b/lib/datalib.php @@ -1220,11 +1220,30 @@ function get_course_students($courseid, $sort="s.timeaccess", $dir="", $page=0, $sort = " ORDER BY $sort "; } - return get_records_sql("SELECT $fields + $students = get_records_sql("SELECT $fields FROM {$CFG->prefix}user u, {$CFG->prefix}user_students s $groupmembers WHERE $select $search $sort $dir $limit"); + + if ($courseid != SITEID) { + return $students; + } + + // We are here because we need the students for the site. + // These also include teachers on real courses + $select .= "AND s.course <> '".SITEID."'"; + if (!$teachers = get_records_sql("SELECT $fields + FROM {$CFG->prefix}user u, + {$CFG->prefix}user_teachers s + $groupmembers + WHERE $select $search $sort $dir $limit")) { + return $students; + } + if (!$students) { + return $teachers; + } + return $teachers + $students; } /**