$sql = " FROM {user} u
WHERE u.id IN ($enrolsql) $wherecondition
AND u.id NOT IN (
- SELECT u.id
- FROM {role_assignments} r, {user} u
+ SELECT r.userid
+ FROM {role_assignments} r
WHERE r.contextid = :contextid
- AND u.id = r.userid
AND r.roleid = :roleid)";
$order = ' ORDER BY lastname ASC, firstname ASC';
$sql = " FROM {user}
WHERE $wherecondition
AND id NOT IN (
- SELECT u.id
- FROM {role_assignments} r, {user} u
+ SELECT r.userid
+ FROM {role_assignments} r
WHERE r.contextid = :contextid
- AND u.id = r.userid
AND r.roleid = :roleid)";
$order = ' ORDER BY lastname ASC, firstname ASC';
// See if we got anything.
if ($this->multiselect) {
$userids = optional_param_array($this->name, array(), PARAM_INTEGER);
- } else {
- $userid = optional_param($this->name, 0, PARAM_INTEGER);
- if (empty($userid)) {
- return array();
- }
+ } else if ($userid = optional_param($this->name, 0, PARAM_INTEGER)) {
$userids = array($userid);
}
+ // If there are no users there is nobody to load
+ if (empty($userids)) {
+ return array();
+ }
// If we did, use the find_users method to validate the ids.
$this->validatinguserids = $userids;