Skip to content
Permalink
Browse files

Merge branch 'w34_MDL-34776_m24_notinsql' of git://github.com/skodak/…

…moodle
  • Loading branch information...
stronk7 committed Aug 21, 2012
2 parents 479fa62 + cb94adc commit 41624a5682a88c1fdcb23dc8ceb0c4c5dce4560e
Showing with 14 additions and 23 deletions.
  1. +4 −6 admin/roles/lib.php
  2. +5 −9 enrol/locallib.php
  3. +3 −5 enrol/manual/locallib.php
  4. +2 −3 user/selector/lib.php
@@ -1039,12 +1039,10 @@ public function find_users($search) {
$countfields = 'SELECT COUNT(u.id)';
$sql = " FROM {user} u
WHERE u.id IN ($enrolsql) $wherecondition
AND u.id NOT IN (
SELECT r.userid
FROM {role_assignments} r
WHERE r.contextid = :contextid
AND r.roleid = :roleid)";
LEFT JOIN {role_assignments} ra ON (ra.userid = u.id AND ra.roleid = :roleid AND ra.contextid = :contextid)
WHERE u.id IN ($enrolsql)
$wherecondition
AND ra.id IS NULL";
$order = ' ORDER BY lastname ASC, firstname ASC';
$params['contextid'] = $this->context->id;
@@ -278,7 +278,7 @@ public function get_potential_users($enrolid, $search='', $searchanywhere=false,
global $DB, $CFG;
// Add some additional sensible conditions
$tests = array("id <> :guestid", 'u.deleted = 0', 'u.confirmed = 1');
$tests = array("u.id <> :guestid", 'u.deleted = 0', 'u.confirmed = 1');
$params = array('guestid' => $CFG->siteguest);
if (!empty($search)) {
$conditions = get_extra_user_fields($this->get_context());
@@ -306,10 +306,9 @@ public function get_potential_users($enrolid, $search='', $searchanywhere=false,
$fields = 'SELECT '.$ufields;
$countfields = 'SELECT COUNT(1)';
$sql = " FROM {user} u
LEFT JOIN {user_enrolments} ue ON (ue.userid = u.id AND ue.enrolid = :enrolid)
WHERE $wherecondition
AND u.id NOT IN (SELECT ue.userid
FROM {user_enrolments} ue
JOIN {enrol} e ON (e.id = ue.enrolid AND e.id = :enrolid))";
AND ue.id IS NULL";
$order = ' ORDER BY u.lastname ASC, u.firstname ASC';
$params['enrolid'] = $enrolid;
$totalusers = $DB->count_records_sql($countfields . $sql, $params);
@@ -353,12 +352,9 @@ public function search_other_users($search='', $searchanywhere=false, $page=0, $
$fields = 'SELECT '.user_picture::fields('u', array('username','lastaccess'));
$countfields = 'SELECT COUNT(u.id)';
$sql = " FROM {user} u
LEFT JOIN {role_assignments} ra ON (ra.userid = u.id AND ra.contextid = :contextid)
WHERE $wherecondition
AND u.id NOT IN (
SELECT u.id
FROM {role_assignments} r, {user} u
WHERE r.contextid = :contextid AND
u.id = r.userid)";
AND ra.id IS NULL";
$order = ' ORDER BY lastname ASC, firstname ASC';
$params['contextid'] = $this->context->id;
@@ -55,11 +55,9 @@ public function find_users($search) {
$countfields = 'SELECT COUNT(1)';
$sql = " FROM {user} u
WHERE $wherecondition AND
u.id NOT IN (
SELECT ue.userid
FROM {user_enrolments} ue
JOIN {enrol} e ON (e.id = ue.enrolid AND e.id = :enrolid))";
LEFT JOIN {user_enrolments} ue ON (ue.userid = u.id AND ue.enrolid = :enrolid)
WHERE $wherecondition
AND ue.id IS NULL";
$order = ' ORDER BY u.lastname ASC, u.firstname ASC';
if (!$this->is_validating()) {
@@ -832,10 +832,9 @@ public function find_users($search) {
JOIN ($enrolsql) e ON e.id = u.id
LEFT JOIN {role_assignments} ra ON (ra.userid = u.id AND ra.contextid " . get_related_contexts_string($context) . " AND ra.roleid $roleids)
LEFT JOIN {role} r ON r.id = ra.roleid
LEFT JOIN {groups_members} gm ON (gm.userid = u.id AND gm.groupid = :groupid)
WHERE u.deleted = 0
AND u.id NOT IN (SELECT userid
FROM {groups_members}
WHERE groupid = :groupid)
AND gm.id IS NULL
AND $searchcondition";
$orderby = "ORDER BY u.lastname, u.firstname";

0 comments on commit 41624a5

Please sign in to comment.
You can’t perform that action at this time.