forked from science-ation/science-ation
- Fix the user dupe code, now that username,year is unique
This commit is contained in:
parent
65e5bfc0fa
commit
d5676576a7
10
user.inc.php
10
user.inc.php
@ -457,8 +457,10 @@ function user_purge($u, $type=false)
|
||||
}
|
||||
|
||||
|
||||
/* Duplicate a row in the users table, or any one of the users_* tables. */
|
||||
function user_dupe_row($db, $key, $val, $newval)
|
||||
{
|
||||
$nullfields = array('deleteddatetime'); /* Fields that can be null */
|
||||
$q = mysql_query("SELECT * FROM $db WHERE $key='$val'");
|
||||
if(mysql_num_rows($q) != 1) {
|
||||
echo "ERROR duplicating row in $db: $key=$val NOT FOUND.\n";
|
||||
@ -468,8 +470,10 @@ function user_dupe_row($db, $key, $val, $newval)
|
||||
$i[$key] = $newval;
|
||||
|
||||
foreach($i as $k=>$v) {
|
||||
if($v == NULL)
|
||||
$i[$k] = 'NULL';
|
||||
if($v == NULL && in_array($k, $nullfields))
|
||||
$i[$k] = NULL;
|
||||
else if($k == 'year')
|
||||
$i[$k] = $config['FAIRYEAR'];
|
||||
else
|
||||
$i[$k] = '\''.mysql_escape_string($v).'\'';
|
||||
}
|
||||
@ -478,7 +482,7 @@ function user_dupe_row($db, $key, $val, $newval)
|
||||
$vals = join(',', array_values($i));
|
||||
|
||||
$q = "INSERT INTO $db ($keys) VALUES ($vals)";
|
||||
echo "Dupe Query: [$q]";
|
||||
// echo "Dupe Query: [$q]";
|
||||
$r = mysql_query($q);
|
||||
echo mysql_error();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user