summaryrefslogtreecommitdiff
path: root/update.php
diff options
context:
space:
mode:
Diffstat (limited to 'update.php')
-rw-r--r--update.php23
1 files changed, 22 insertions, 1 deletions
diff --git a/update.php b/update.php
index 9bfeaa060..8a2b7da3d 100644
--- a/update.php
+++ b/update.php
@@ -53,7 +53,8 @@ $mysql_updates = array(
"2002-04-14 : modules/themes web config" => "update_25",
"2002-04-14 : new taxonomy system" => "update_26",
"2002-04-16" => "update_27",
- "2002-04-20" => "update_28"
+ "2002-04-20" => "update_28",
+ "2002-04-23 : roles cleanup" => "update_29"
);
// Update functions
@@ -413,6 +414,26 @@ function update_28() {
update_sql("ALTER TABLE poll DROP lid;");
}
+function update_29() {
+ update_sql("CREATE TABLE permission (
+ rid INT UNSIGNED NOT NULL,
+ perm TEXT,
+ tid INT UNSIGNED NOT NULL,
+ KEY (rid)
+ )");
+
+ update_sql("INSERT INTO permission (rid, perm) SELECT rid, perm FROM role");
+ update_sql("ALTER TABLE users ADD rid INT UNSIGNED NOT NULL");
+
+ $result = db_query("SELECT rid, name FROM role");
+ while ($role = db_fetch_object($result)) {
+ db_query("UPDATE users SET rid = ".$role->rid." WHERE role = '".$role->name."'");
+ }
+
+ update_sql("ALTER TABLE users DROP role");
+ update_sql("ALTER TABLE role DROP perm");
+}
+
/*
** System functions
*/