Commit d0090e69 authored by Dries's avatar Dries

- Patch #7614 by jhriggs: fixed some role related problems.

parent cd2f2bc0
......@@ -594,7 +594,6 @@ CREATE TABLE users (
picture varchar(255) NOT NULL DEFAULT '',
init varchar(64) default '',
data longtext,
rid int(10) unsigned NOT NULL default '0',
PRIMARY KEY (uid),
UNIQUE KEY name (name),
KEY changed (changed)
......@@ -667,7 +666,8 @@ INSERT INTO system VALUES ('modules/page.module','page','module','',1,0,0);
INSERT INTO system VALUES ('modules/story.module','story','module','',1,0,0);
INSERT INTO system VALUES ('modules/taxonomy.module','taxonomy','module','',1,0,0);
INSERT INTO system VALUES ('themes/xtemplate/xtemplate.theme','xtemplate','theme','Internet explorer, Netscape, Opera',1,0,0);
INSERT INTO users (uid, name, mail, rid) VALUES ('0', '', '', '1');
INSERT INTO users (uid, name, mail) VALUES ('0', '', '');
INSERT INTO users_roles (uid, rid) VALUES (0, 1);
INSERT INTO role (rid, name) VALUES (1, 'anonymous user');
INSERT INTO permission VALUES (1,'access content',0);
......
......@@ -587,7 +587,6 @@ CREATE TABLE users (
picture varchar(255) NOT NULL DEFAULT '',
init varchar(64) default '',
data text default '',
rid integer NOT NULL default '0',
PRIMARY KEY (uid),
UNIQUE (name)
);
......@@ -665,7 +664,8 @@ INSERT INTO system VALUES ('themes/xtemplate/xtemplate.theme','xtemplate','theme
INSERT INTO variable(name,value) VALUES('update_start', 's:10:"2004-02-21";');
INSERT INTO variable(name,value) VALUES('theme_default','s:9:"xtemplate";');
INSERT INTO users(uid,name,mail,rid) VALUES(0,'','', '1');
INSERT INTO users(uid,name,mail) VALUES(0,'','');
INSERT INTO users_roles(uid,rid) VALUES(0, 1);
INSERT INTO role (rid, name) VALUES (1, 'anonymous user');
INSERT INTO permission VALUES (1,'access content',0);
......
......@@ -86,11 +86,13 @@ function user_save($account, $array = array()) {
db_query("UPDATE {users} SET $query changed = %d WHERE uid = %d", array_merge($v, array(time(), $account->uid)));
// reload user roles
db_query("DELETE FROM {users_roles} WHERE uid = %d", $account->uid);
// reload user roles if provided
if (is_array($array['rid'])) {
db_query("DELETE FROM {users_roles} WHERE uid = %d", $account->uid);
foreach ($array['rid'] as $rid) {
db_query("INSERT INTO {users_roles} (uid, rid) VALUES (%d, %d)", $account->uid, $rid);
foreach ($array['rid'] as $rid) {
db_query("INSERT INTO {users_roles} (uid, rid) VALUES (%d, %d)", $account->uid, $rid);
}
}
$user = user_load(array('uid' => $account->uid));
......
......@@ -86,11 +86,13 @@ function user_save($account, $array = array()) {
db_query("UPDATE {users} SET $query changed = %d WHERE uid = %d", array_merge($v, array(time(), $account->uid)));
// reload user roles
db_query("DELETE FROM {users_roles} WHERE uid = %d", $account->uid);
// reload user roles if provided
if (is_array($array['rid'])) {
db_query("DELETE FROM {users_roles} WHERE uid = %d", $account->uid);
foreach ($array['rid'] as $rid) {
db_query("INSERT INTO {users_roles} (uid, rid) VALUES (%d, %d)", $account->uid, $rid);
foreach ($array['rid'] as $rid) {
db_query("INSERT INTO {users_roles} (uid, rid) VALUES (%d, %d)", $account->uid, $rid);
}
}
$user = user_load(array('uid' => $account->uid));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment