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

This commit is contained in:
Eloy Lafuente (stronk7) 2012-08-22 01:55:34 +02:00
commit 41624a5682
4 changed files with 14 additions and 23 deletions

View File

@ -1039,12 +1039,10 @@ class potential_assignees_below_course extends role_assign_user_selector_base {
$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;

View File

@ -278,7 +278,7 @@ class course_enrolment_manager {
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 @@ class course_enrolment_manager {
$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 @@ class course_enrolment_manager {
$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;

View File

@ -55,11 +55,9 @@ class enrol_manual_potential_participant extends user_selector_base {
$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()) {

View File

@ -832,10 +832,9 @@ class group_non_members_selector extends groups_user_selector_base {
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";