Skip to content

Commit

Permalink
MDL-16043: ensures cross-db: add lowercase conversion for every datab…
Browse files Browse the repository at this point in the history
…ase fieldname, merged from 19
  • Loading branch information
jerome committed Aug 14, 2008
1 parent 8185aeb commit 599e379
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions enrol/database/enrol.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ function setup_enrolments(&$user) {
//$count = 0;
$courselist = array();
while ($fields_obj = (object)$rs->FetchRow()) { // Make a nice little array of courses to process
$fields_obj = (object)array_change_key_case((array)$fields_obj , CASE_LOWER);
$courselist[] = $fields_obj->enrolremotecoursefield;
//$count++;
}
Expand Down Expand Up @@ -156,7 +157,7 @@ function setup_enrolments(&$user) {
if ($role_assignment->enrol == 'database') {
//error_log('[ENROL_DB] Removing user from context '.$role_assignment->contextid);
role_unassign($role_assignment->roleid, $user->id, '', $role_assignment->contextid);
}
}
}
}
} else {
Expand Down Expand Up @@ -221,6 +222,7 @@ function sync_enrolments($role = null) {
$DB->begin_sql();
$extcourses = array();
while ($extcourse_obj = (object)$rs->FetchRow()) { // there are more course records
$extcourse_obj = (object)array_change_key_case((array)$extcourse_obj , CASE_LOWER);
$extcourse = $extcourse_obj->{$CFG->enrol_remotecoursefield};
array_push($extcourses, $extcourse);

Expand Down Expand Up @@ -274,8 +276,9 @@ function sync_enrolments($role = null) {
continue;
}

// slurp results into an array
// slurp results into an array
while ($crs_obj = (object)$crs->FetchRow()) {
$crs_obj = (object)array_change_key_case((array)$crs_obj , CASE_LOWER);
array_push($extenrolments, $crs_obj->{$CFG->enrol_remoteuserfield});
}
$crs->close(); // release the handle
Expand All @@ -302,7 +305,7 @@ function sync_enrolments($role = null) {
}
$params['roleid'] = $role->id;
$params['contextid'] = $context->id;

$to_prune = $DB->get_records_sql("
SELECT ra.*
FROM {role_assignments} ra
Expand Down Expand Up @@ -408,8 +411,8 @@ function sync_enrolments($role = null) {
error_log( "Unassigned role {$roleid} from user $user in context $contextid");
} else {
error_log( "Failed unassign role {$roleid} from user $user in context $contextid");
}
}
}
$ers->close(); // release the handle
}

Expand Down

0 comments on commit 599e379

Please sign in to comment.