From 801d2580be4e202a1d81890b4e6daeb66c479f2c Mon Sep 17 00:00:00 2001 From: dave Date: Tue, 13 Jul 2010 03:30:06 +0000 Subject: [PATCH] Add config/admin roles and conversion script --- db/db.update.198.php | 23 ++++++++++++++++++++++- db/db.update.198.sql | 6 ++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/db/db.update.198.php b/db/db.update.198.php index b13b9b7..99b224e 100644 --- a/db/db.update.198.php +++ b/db/db.update.198.php @@ -2,7 +2,6 @@ function db_update_198_post() { - echo "Migrating passwordset and oldpassword data...\n"; $q = mysql_query("SELECT * FROM accounts"); echo mysql_error(); @@ -38,6 +37,28 @@ function db_update_198_post() echo " No role data for user $id, skipping\n"; } } + + echo "Migating admin/config access to roles...\n"; + $q = mysql_query("SELECT * FROM users"); + echo mysql_error(); + while($u = mysql_fetch_assoc($q)) { + $id = $u['id']; + + $qq = mysql_query("SELECT * FROM user_roles WHERE users_id=$id AND roles_id='2'"); + echo mysql_error(); + if(mysql_num_rows($qq)) { + /* User has a committee role, add config/admin roles */ + if($u['access_admin'] == 'yes') { + mysql_query("INSERT INTO user_roles(`accounts_id`,`users_id`,`roles_id`,`active`,`complete`) + VALUES('{$u['accounts_id']}','$id',12,'yes','yes')"); + } + if($u['access_config'] == 'yes') { + mysql_query("INSERT INTO user_roles(`accounts_id`,`users_id`,`roles_id`,`active`,`complete`) + VALUES('{$u['accounts_id']}','$id',13,'yes','yes')"); + } + } + } + echo "Done.\n"; } diff --git a/db/db.update.198.sql b/db/db.update.198.sql index 07e491f..f899127 100644 --- a/db/db.update.198.sql +++ b/db/db.update.198.sql @@ -44,3 +44,9 @@ ALTER TABLE `users` ADD UNIQUE (`accounts_id` , `conferences_id`); ALTER TABLE `accounts` ADD `deleted` ENUM( 'no', 'yes' ) NOT NULL DEFAULT 'no' AFTER `superuser`; ALTER TABLE `accounts` ADD `deleted_datetime` DATETIME NOT NULL AFTER `deleted`; UPDATE `accounts` SET `deleted`='no'; + +-- Separate committee access levels into roles +INSERT INTO `roles` (`id` ,`type` ,`name`) VALUES + (12 , 'admin', 'Fair Administrator'), + (13 , 'config', 'Fair Configurator'); +