Skip to content

Commit

Permalink
enrol/db/enrol.php ignore delt'd usrs when enroling
Browse files Browse the repository at this point in the history
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
  • Loading branch information
martinlanghoff committed Sep 28, 2006
1 parent 13e8d6e commit f5896f0
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions enrol/database/enrol.php
Original file line number Diff line number Diff line change
Expand Up @@ -305,14 +305,15 @@ function sync_enrolments($role = null) {
LEFT OUTER JOIN {$CFG->prefix}role_assignments ra ON u.id = ra.userid
AND ra.roleid = {$role->id}
AND ra.contextid = {$context->id}
WHERE u.{$CFG->enrol_localuserfield} = ".$db->quote($member);
WHERE u.{$CFG->enrol_localuserfield} = ".$db->quote($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;
Expand Down

0 comments on commit f5896f0

Please sign in to comment.