if ($hostid == $CFG->mnet_localhost_id && $course->id != SITEID) {
$courseusers = get_users_by_capability($context, 'moodle/course:view', '', 'lastname ASC, firstname ASC', '','u.id, u.firstname, u.lastname, u.idnumber',$selectedgroup,null, false);
} else {
- $courseusers = get_site_users("u.lastaccess DESC", "u.id, u.firstname, u.lastname, u.idnumber");
+ // this may be a lot of users :-(
+ $courseusers = $DB->get_records('user', array('deleted'=>0), 'u.lastaccess DESC', 'u.id, u.firstname, u.lastname, u.idnumber');
}
if (count($courseusers) < COURSE_MAX_USERS_PER_DROPDOWN && !$showusers) {
function print_log_selector_form($course, $selecteduser=0, $selecteddate='today',
$modname="", $modid=0, $modaction='', $selectedgroup=-1, $showcourses=0, $showusers=0, $logformat='showashtml') {
- global $USER, $CFG;
+ global $USER, $CFG, $DB;
// first check to see if we can override showcourses and showusers
$numcourses = count_records_select("course", "", "COUNT(id)");
if ($course->id != SITEID) {
$courseusers = get_users_by_capability($context, 'moodle/course:view', '', 'lastname ASC, firstname ASC', '','u.id, u.firstname, u.lastname, u.idnumber',$selectedgroup,null, false);
} else {
- $courseusers = get_site_users("u.lastaccess DESC", "u.id, u.firstname, u.lastname, u.idnumber");
+ // this may be a lot of users :-(
+ $courseusers = $DB->get_records('user', array('deleted'=>0), 'u.lastaccess DESC', 'u.id, u.firstname, u.lastname, u.idnumber');
}
if (count($courseusers) < COURSE_MAX_USERS_PER_DROPDOWN && !$showusers) {
* @return bool
*/
function isteacherinanycourse($userid=0, $includeadmin=true) {
- global $USER, $CFG;
+ global $USER, $CFG, $DB;
if (empty($CFG->rolesactive)) { // Teachers are locked out during an upgrade to 1.7
return false;
$userid = $USER->id;
}
- if (!record_exists('role_assignments', 'userid', $userid)) { // Has no roles anywhere
+ if (!$DB->record_exists('role_assignments', array('userid'=>$userid))) { // Has no roles anywhere
return false;
}
/// If this user is assigned as an editing teacher anywhere then return true
if ($roles = get_roles_with_capability('moodle/legacy:editingteacher', CAP_ALLOW)) {
foreach ($roles as $role) {
- if (record_exists('role_assignments', 'roleid', $role->id, 'userid', $userid)) {
+ if ($DB->record_exists('role_assignments', array('roleid'=>$role->id, 'userid'=>$userid))) {
return true;
}
}
/// If this user is assigned as a non-editing teacher anywhere then return true
if ($roles = get_roles_with_capability('moodle/legacy:teacher', CAP_ALLOW)) {
foreach ($roles as $role) {
- if (record_exists('role_assignments', 'roleid', $role->id, 'userid', $userid)) {
+ if ($DB->record_exists('role_assignments', array('roleid'=>$role->id, 'userid'=>$userid))) {
return true;
}
}
}
-/**
- * Returns a list of all site users
- * Obsolete, just calls get_course_users(SITEID)
- *
- * @uses SITEID
- * @deprecated Use {@link get_course_users()} instead.
- * @param string $fields A comma separated list of fields to be returned from the chosen table.
- * @return object|false {@link $USER} records or false if error.
- */
-function get_site_users($sort='u.lastaccess DESC', $fields='*', $exceptions='') {
-
- return get_course_users(SITEID, $sort, $exceptions, $fields);
-}
-
########### FROM weblib.php ##########################################################################