forked from science-ation/science-ation
if a user exists for the current fair year and is deleted when they try to register, simply undelete them
This commit is contained in:
parent
48361e5868
commit
d2a785acfb
20
user_new.php
20
user_new.php
@ -115,12 +115,26 @@
|
||||
}
|
||||
|
||||
/* See if this email already exists */
|
||||
$q = mysql_query("SELECT id,types FROM users WHERE email='$sql_email' OR username='$sql_email'");
|
||||
$q = mysql_query("SELECT id,types,MAX(year) AS year,deleted FROM users WHERE (email='$sql_email' OR username='$sql_email' )");
|
||||
//select *, max(year) from users where username=sql_email
|
||||
//if deleted and year = current yera - just undelete
|
||||
//if deleted and year != current yera - proceed normally and recreate the user
|
||||
|
||||
|
||||
if(mysql_num_rows($q) > 0) {
|
||||
/* It already exists, make sure they're not already in this role */
|
||||
$r = mysql_fetch_object($q);
|
||||
$types = split(',', $r->types);
|
||||
|
||||
if($r->year==$config['FAIRYEAR'] && $r->deleted=='yes') {
|
||||
mysql_query("UPDATE users SET deleted='no' WHERE id='$r->id'");
|
||||
message_push(happy(i18n("Your account has been undeleted")));
|
||||
message_push(notice(i18n("Use the 'recover password' option on the %1 {$user_what[$type]} login page %2 if you have forgotten your password",
|
||||
array("<a href=\"user_login.php?type=$type\">", "</a>"))));
|
||||
header("Location: user_login.php?type=$type");
|
||||
exit;
|
||||
}
|
||||
else if($r->deleted=='no') {
|
||||
if(in_array($type, $types)) {
|
||||
message_push(error(i18n("That email address has an existing {$user_what[$type]} registration")));
|
||||
message_push(notice(i18n("Use the 'recover password' option on the %1 {$user_what[$type]} login page %2 if you have forgotten your password",
|
||||
@ -152,6 +166,10 @@
|
||||
exit;
|
||||
}
|
||||
}
|
||||
else {
|
||||
//deletes = yes but year!=fairyear, so go ahead and let it create the new account
|
||||
}
|
||||
}
|
||||
|
||||
/* Strict validate the email */
|
||||
if(!user_valid_email($data_email)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user