diff options
author | Dries Buytaert <dries@buytaert.net> | 2001-11-17 12:17:46 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2001-11-17 12:17:46 +0000 |
commit | cd2df442b0f00564d2c895d3b817d24c8382044e (patch) | |
tree | b5a9219793bef2e2161dabd41c8e4090c22b9212 | |
parent | 0a4f99ef22c6f74b4cfbe0dc0b9f9110641be0ab (diff) | |
download | brdo-cd2df442b0f00564d2c895d3b817d24c8382044e.tar.gz brdo-cd2df442b0f00564d2c895d3b817d24c8382044e.tar.bz2 |
- update.php:
* added a new update method to create the authmap table, to move
the old 'jabber' and 'drupal' field in the users table to this
new authmap table, and to remove users and node left-overs.
-rw-r--r-- | update.php | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/update.php b/update.php index 0f2e151f1..f1dc3ada8 100644 --- a/update.php +++ b/update.php @@ -16,6 +16,7 @@ $mysql_updates = array( "2001-11-01" => "update_7", "2001-11-02" => "update_8", "2001-11-04" => "update_9", + "2001-11-17: distributed authentication" => "update_10", ); // Update functions @@ -195,6 +196,42 @@ function update_9() { } } +function update_10() { + // create a new table: + update_sql("CREATE TABLE authmap ( + aid int(10) unsigned DEFAULT '0' NOT NULL auto_increment, + uid int(10) DEFAULT '' NOT NULL, + authname varchar(128) DEFAULT '' NOT NULL, + module varchar(128) DEFAULT '' NOT NULL, + UNIQUE authname (authname), + PRIMARY KEY (aid) + );"); + + // populate the new table: + $result = db_query("SELECT uid, name, jabber, drupal FROM users WHERE jabber != '' || drupal != ''"); + while ($user = db_fetch_object($result)) { + if ($user->jabber) { + update_sql("INSERT INTO authmap (uid, authname, module) VALUES ('$user->uid', '$user->jabber', 'jabber')"); + } + if ($user->drupal) { + update_sql("INSERT INTO authmap (uid, authname, module) VALUES ('$user->uid', '$user->drupal', 'drupal')"); + } + } + + // remove the old user-table leftovers: + update_sql("DELETE FROM variable WHERE name = 'user_jabber'"); + update_sql("DELETE FROM variable WHERE name = 'user_drupal'"); + update_sql("ALTER TABLE users DROP drupal"); + update_sql("ALTER TABLE users DROP jabber"); + + // remove the old node-table leftovers: + update_sql("ALTER TABLE forum DROP body_old;"); + update_sql("ALTER TABLE story DROP body_old;"); + update_sql("ALTER TABLE book DROP body_old;"); + update_sql("ALTER TABLE page DROP body_old;"); + update_sql("ALTER TABLE blog DROP body_old;"); +} + // System functions function update_sql($sql) { global $edit; @@ -256,7 +293,7 @@ function update_page() { print form($form); break; } - + } print "<html><h1>Drupal update</h1>"; |