From 6a1de0f2f34ad945af63077dc139abb1b5f69ec7 Mon Sep 17 00:00:00 2001 From: dave Date: Sun, 8 Feb 2009 07:40:36 +0000 Subject: [PATCH] - Fix the new user function, the user table is now UNIQUE in (username,year), so we need to insert both. --- user.inc.php | 9 ++++++--- user_new.php | 3 +-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/user.inc.php b/user.inc.php index 931d8cc..faa77dd 100644 --- a/user.inc.php +++ b/user.inc.php @@ -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 "
";
+//		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);
diff --git a/user_new.php b/user_new.php
index ac9c2db..61300c2 100644
--- a/user_new.php
+++ b/user_new.php
@@ -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);