- Fix the new user function, the user table is now UNIQUE in (username,year),

so we need to insert both.
This commit is contained in:
dave 2009-02-08 07:40:36 +00:00
parent eecb099e9b
commit 6a1de0f2f3
2 changed files with 7 additions and 5 deletions

View File

@ -150,6 +150,8 @@ function user_load($user, $uid = false)
if(mysql_num_rows($q)!=1) {
echo "Query [$query] returned ".mysql_num_rows($q)." rows\n";
// echo "<pre>";
// print_r(debug_backtrace());
return false;
}
@ -565,12 +567,13 @@ function user_add_role_allowed($type, $u)
return false;
}
function user_create($type, $u = NULL)
function user_create($type, $username, $u = NULL)
{
global $config;
if(!is_array($u)) {
mysql_query("INSERT INTO users (`types`,`passwordset`,`created`,`year`)
VALUES ('$type', '0000-00-00', NOW(), '{$config['FAIRYEAR']}')");
mysql_query("INSERT INTO users (`types`,`username`,`passwordset`,`created`,`year`)
VALUES ('$type', '$username','0000-00-00', NOW(), '{$config['FAIRYEAR']}')");
echo mysql_error();
$uid = mysql_insert_id();
mysql_query("UPDATE users SET uid='$uid' WHERE id='$uid'");
user_set_password($uid, NULL);

View File

@ -171,10 +171,9 @@
/* Add the user, user_create sets a random/expired password,
* so we'll just use that */
$u = user_create($type);
$u = user_create($type, $data_email);
$u['firstname'] = $data_fn;
$u['lastname'] = $data_ln;
$u['username'] = $data_email;
$u['email'] = $data_email;
user_save($u);