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
74
user_new.php
74
user_new.php
@ -115,42 +115,60 @@
|
||||
}
|
||||
|
||||
/* 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(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",
|
||||
array("<a href=\"user_login.php?type=$type\">", "</a>"))));
|
||||
break; /* Don't want to create an account */
|
||||
} else {
|
||||
/* If they're already logged in, we can go ahead and
|
||||
* add this role. We've passed all the required checks
|
||||
* for creating a new user of this role.
|
||||
* The user has already been warned about being logged
|
||||
* out. */
|
||||
if(isset($_SESSION['users_id'])) {
|
||||
/* user_create does last minute checks, like
|
||||
* ensuring a student doesn't try to also
|
||||
* register as a judge */
|
||||
$u = user_load($_SESSION['users_id']);
|
||||
$u = user_create($type, $u['username'], $u);
|
||||
$_SESSION['users_type'] = $type;
|
||||
message_push(notice(i18n("Login to finish adding the new role to your account")));
|
||||
|
||||
header("location: user_login.php?action=logout&redirect=roleattached");
|
||||
exit;
|
||||
}
|
||||
/* forward the user to the login page for whatever role
|
||||
* they already have (it doesn't matter), and
|
||||
* setup a login role_add redirect */
|
||||
message_push(notice(i18n("Your email address already exists. Please login to your existing account below and you will be redirected to the multi-role creation page to complete your registration request.")));
|
||||
header("location: user_login.php?type={$types[0]}&redirect=roleadd&redirectdata=$type");
|
||||
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",
|
||||
array("<a href=\"user_login.php?type=$type\">", "</a>"))));
|
||||
break; /* Don't want to create an account */
|
||||
} else {
|
||||
/* If they're already logged in, we can go ahead and
|
||||
* add this role. We've passed all the required checks
|
||||
* for creating a new user of this role.
|
||||
* The user has already been warned about being logged
|
||||
* out. */
|
||||
if(isset($_SESSION['users_id'])) {
|
||||
/* user_create does last minute checks, like
|
||||
* ensuring a student doesn't try to also
|
||||
* register as a judge */
|
||||
$u = user_load($_SESSION['users_id']);
|
||||
$u = user_create($type, $u['username'], $u);
|
||||
$_SESSION['users_type'] = $type;
|
||||
message_push(notice(i18n("Login to finish adding the new role to your account")));
|
||||
|
||||
header("location: user_login.php?action=logout&redirect=roleattached");
|
||||
exit;
|
||||
}
|
||||
/* forward the user to the login page for whatever role
|
||||
* they already have (it doesn't matter), and
|
||||
* setup a login role_add redirect */
|
||||
message_push(notice(i18n("Your email address already exists. Please login to your existing account below and you will be redirected to the multi-role creation page to complete your registration request.")));
|
||||
header("location: user_login.php?type={$types[0]}&redirect=roleadd&redirectdata=$type");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
else {
|
||||
//deletes = yes but year!=fairyear, so go ahead and let it create the new account
|
||||
}
|
||||
}
|
||||
|
||||
/* Strict validate the email */
|
||||
|
Loading…
x
Reference in New Issue
Block a user