From 599e379d16ad09c97bd9cc122d91f56ed80bb1fe Mon Sep 17 00:00:00 2001 From: jerome Date: Thu, 14 Aug 2008 12:01:34 +0000 Subject: [PATCH] MDL-16043: ensures cross-db: add lowercase conversion for every database fieldname, merged from 19 --- enrol/database/enrol.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/enrol/database/enrol.php b/enrol/database/enrol.php index 3cd6acf15fba9..78c0bfb29ae35 100644 --- a/enrol/database/enrol.php +++ b/enrol/database/enrol.php @@ -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++; } @@ -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 { @@ -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); @@ -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 @@ -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 @@ -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 }