]> git.mjollnir.org Git - moodle.git/commitdiff
Added a new "auth" field to the user table. This field contains the
authormoodler <moodler>
Sun, 15 Aug 2004 07:27:52 +0000 (07:27 +0000)
committermoodler <moodler>
Sun, 15 Aug 2004 07:27:52 +0000 (07:27 +0000)
authentication mechanism used to create that user record.

Also added code to upgrade existing systems to have entries in that
field, and for new users to also have that field defined.

This will allow us to later improve the login procedure to be able to
handle various types of authentication.

lib/db/mysql.php
lib/db/mysql.sql
lib/db/postgres7.php
lib/db/postgres7.sql
lib/moodlelib.php
login/index.php
login/signup.php
version.php

index 7def4d560125dd6f4d5ccffb715e71e046f48aed..8db8532e1aa2134850e1d00128294e119aa91f65 100644 (file)
@@ -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;
 
index c9a0c01777f6e92323981c765cccbce17cd4e8e0..e04ace5a40b0840f646e3856a60ac7d5c4c9c34b 100644 (file)
@@ -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 '',
index 96999eae1b2b6be2dd8bd1965a1cc2032fe6218c..1ad354a2a3252df07a70470084ceb953e3ccc0b0 100644 (file)
@@ -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;
 
index 204481bacbadb877715d604eedb3ac4f2fce2f68..8ab5470b2c47d862ccc2737997213cbab3e93010 100644 (file)
@@ -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 '',
index f5acccee087d24a483e47108e6872f1baa41db1d..5691e40044dadbc3e12c9dff58be75d6f0db5b87 100644 (file)
@@ -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;
index 2f3427a04169a314410ace7536be4ddcfff8203e..6a4df7f3d7ce6995b3a17aa0281ed683cb9724fb 100644 (file)
@@ -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"));
index cec9336f4b3866435cca0bc4bec7a79ffdc6b12d..6385bd35af7e1b19193e58bb4cbc659383b94f0c 100644 (file)
@@ -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)) {
index 8659ab660ee11ab2f1c1408ba074ccf70351df4c..90cac225c8755aaab3a5f9aa6964587c0415fe4b 100644 (file)
@@ -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
 
 ?>