forked from science-ation/science-ation
Add config/admin roles and conversion script
This commit is contained in:
parent
2e17685fc2
commit
801d2580be
@ -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";
|
||||
}
|
||||
|
||||
|
@ -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');
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user