enrol/db/enrol.php ignore delt'd usrs when enroling

Previously the import process would throw a non-fatal error when it found a
non-one number of users with the remote key.  This meant that
when there was a deleted user with the same remote key as an existing user, it
would throw an error, and report that there were no users for that remote key.
Fixed it so that it now ignores deleted users, and provides more accurate
and more precise error messages in the event that there are further
problems.

Author: Peter Bulmer
This commit is contained in:
martinlanghoff
2006-09-28 01:16:01 +00:00
parent dc77f7b55c
commit 80161aad61
+3 -2
View File
@@ -210,14 +210,15 @@ function sync_enrolments($type='student') {
$sql = "SELECT u.id AS userid, e.id AS enrolmentid" .
" FROM {$CFG->prefix}user u " .
" LEFT OUTER JOIN {$CFG->prefix}user_students e ON (u.id = e.userid AND e.course='{$course->id}')" .
" WHERE u.{$CFG->enrol_localuserfield} = '$member'";
" WHERE u.{$CFG->enrol_localuserfield} = '$member'" .
" AND (u.deleted IS NULL OR u.deleted=0)";
$ers = $db->Execute($sql);
if (!$ers) {
trigger_error($db->ErrorMsg() .' STATEMENT: '. $sql);
return false;
}
if ( $ers->RecordCount() != 1 ) { // if this returns empty, it means we don't have the student record.
if ( $ers->RecordCount() == 0 ) { // if this returns empty, it means we don't have the student record.
// should not happen -- but skip it anyway
trigger_error('weird! no user record entry?');
continue;