diff --git a/user.inc.php b/user.inc.php index f520ae6..064106f 100644 --- a/user.inc.php +++ b/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();