Commit e1d506e5 authored by Nigel McNie's avatar Nigel McNie

Fixed a mistake in the 0.8 upgrade

It turns out that every user is using the 'mahara' institution's internal auth plugin, despite the fact that if they're in a different institution they shouldn't be able to use it. Fix this by creating internal auth plugins for all institutions that need them, and fixing the 'authinstance' field of the usr table.
parent 3b70be78
......@@ -484,6 +484,40 @@ function xmldb_core_upgrade($oldversion=0) {
ALTER TABLE ' . $prefix . 'auth_cron ALTER COLUMN callfunction DROP DEFAULT;
');
}
if ($oldversion < 2007080702) {
// Fix two mistakes in the 0.8 upgrade:
//
// 1) Only the internal institituion had an internal auth instance added for it. This should have meant that all users not in the internal institution were locked out, but...
// 2) All users were assigned to be in the internal auth instance, regardless of what institution they were in
$users = get_records_array('usr', '', '', '', 'id, username, institution, authinstance');
if ($users) {
$authinstances = get_records_assoc('auth_instance', '', '', '', 'institution, id');
foreach (array_keys($authinstances) as $key) {
$authinstances[$key] = $authinstances[$key]->id;
}
foreach ($users as $user) {
if (!isset($authinstances[$user->institution])) {
// There does not seem to be an authinstance set up for
// this user's institution. We should fix that now.
$authinstance = (object)array(
'instancename' => 'internal',
'priority' => 1,
'institution' => $user->institution,
'authname' => 'internal'
);
$authinstances[$user->institution] = insert_record('auth_instance', $authinstance, 'id', true);
}
if ($user->authinstance != $authinstances[$user->institution]) {
// Fix the user's authinstance
$user->authinstance = $authinstances[$user->institution];
update_record('usr', $user, 'id');
}
}
}
}
return $status;
......
......@@ -27,8 +27,8 @@
defined('INTERNAL') || die();
$config = new StdClass;
$config->version = 2007080701;
$config->release = '0.8.1';
$config->version = 2007080702;
$config->release = '0.8.2';
$config->minupgradefrom = 2007011600;
$config->minupgraderelease = '0.4.0 (build tag BUILD_20070122)';
$config->disablelogin = true;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment