diff --git a/lib/db/mysql.php b/lib/db/mysql.php index 7def4d56012..8db8532e1aa 100644 --- a/lib/db/mysql.php +++ b/lib/db/mysql.php @@ -807,6 +807,20 @@ function main_upgrade($oldversion=0) { set_field('blocks', 'version', 2004081200, 'name', 'course_list'); } + if ($oldversion < 2004081500) { // Adding new "auth" field to user table to allow more flexibility + table_column('user', '', 'auth', 'varchar', '20', '', 'manual', 'not null', 'id'); + + execute_sql("UPDATE {$CFG->prefix}user SET auth = 'manual'"); // Set everyone to 'manual' to be sure + + if ($admins = get_admins()) { // Set all the NON-admins to whatever the current auth module is + $adminlist = array(); + foreach ($admins as $user) { + $adminlist[] = $user->id; + } + $adminlist = implode(',', $adminlist); + execute_sql("UPDATE {$CFG->prefix}user SET auth = '$CFG->auth' WHERE id NOT IN ($adminlist)"); + } + } return $result; diff --git a/lib/db/mysql.sql b/lib/db/mysql.sql index c9a0c01777f..e04ace5a40b 100644 --- a/lib/db/mysql.sql +++ b/lib/db/mysql.sql @@ -307,6 +307,7 @@ CREATE TABLE `prefix_scale` ( CREATE TABLE `prefix_user` ( `id` int(10) unsigned NOT NULL auto_increment, + `auth` varchar(20) NOT NULL default 'manual', `confirmed` tinyint(1) NOT NULL default '0', `deleted` tinyint(1) NOT NULL default '0', `username` varchar(100) NOT NULL default '', diff --git a/lib/db/postgres7.php b/lib/db/postgres7.php index 96999eae1b2..1ad354a2a32 100644 --- a/lib/db/postgres7.php +++ b/lib/db/postgres7.php @@ -549,6 +549,20 @@ function main_upgrade($oldversion=0) { set_field('blocks', 'version', 2004081200, 'name', 'course_list'); } + if ($oldversion < 2004081500) { // Adding new "auth" field to user table to allow more flexibility + table_column('user', '', 'auth', 'varchar', '20', '', 'manual', 'not null', 'id'); + + execute_sql("UPDATE {$CFG->prefix}user SET auth = 'manual'"); // Set everyone to 'manual' to be sure + + if ($admins = get_admins()) { // Set all the NON-admins to whatever the current auth module is + $adminlist = array(); + foreach ($admins as $user) { + $adminlist[] = $user->id; + } + $adminlist = implode(',', $adminlist); + execute_sql("UPDATE {$CFG->prefix}user SET auth = '$CFG->auth' WHERE id NOT IN ($adminlist)"); + } + } return $result; diff --git a/lib/db/postgres7.sql b/lib/db/postgres7.sql index 204481bacba..8ab5470b2c4 100644 --- a/lib/db/postgres7.sql +++ b/lib/db/postgres7.sql @@ -197,6 +197,7 @@ CREATE INDEX prefix_cache_text_md5key_idx ON prefix_cache_text (md5key); CREATE TABLE prefix_user ( id SERIAL PRIMARY KEY, + auth varchar(20) NOT NULL default 'manual', confirmed integer NOT NULL default '0', deleted integer NOT NULL default '0', username varchar(100) NOT NULL default '', diff --git a/lib/moodlelib.php b/lib/moodlelib.php index f5acccee087..5691e40044d 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -716,6 +716,7 @@ function create_user_record($username, $password) { } } + $newuser->auth = $CFG->auth; $newuser->username = $username; $newuser->password = md5($password); $newuser->lang = $CFG->lang; diff --git a/login/index.php b/login/index.php index 2f3427a0416..6a4df7f3d7c 100644 --- a/login/index.php +++ b/login/index.php @@ -5,6 +5,7 @@ // Check if the guest user exists. If not, create one. if (! record_exists("user", "username", "guest")) { + $guest->auth = "manual"; $guest->username = "guest"; $guest->password = md5("guest"); $guest->firstname = addslashes(get_string("guestuser")); diff --git a/login/signup.php b/login/signup.php index cec9336f4b3..6385bd35af7 100644 --- a/login/signup.php +++ b/login/signup.php @@ -23,6 +23,7 @@ $user->lang = current_language(); $user->firstaccess = time(); $user->secret = random_string(15); + $user->auth = $CFG->auth; if (!empty($CFG->auth_user_create) and function_exists('auth_user_create') ){ if (! auth_user_exists($user->username)) { if (! auth_user_create($user,$plainpass)) { diff --git a/version.php b/version.php index 8659ab660ee..90cac225c87 100644 --- a/version.php +++ b/version.php @@ -5,8 +5,8 @@ // database to determine whether upgrades should // be performed (see lib/db/*.php) -$version = 2004081200; // The current version is a date (YYYYMMDDXX) +$version = 2004081500; // The current version is a date (YYYYMMDDXX) -$release = "1.4 development"; // User-friendly version number +$release = "1.4 alpha"; // User-friendly version number ?>