forked from science-ation/science-ation
Misc login/invite fixes
This commit is contained in:
parent
518472136d
commit
22a46874ee
17
user.inc.php
17
user.inc.php
@ -1613,14 +1613,16 @@ function user_invite($username, $password, $email, $roles_id){
|
||||
|
||||
if($returnval == null){
|
||||
// good so far, let's see if the account already exists
|
||||
$q = mysql_query("SELECT id FROM accounts WHERE username = '" . mysql_real_escape_string($username) . "'");
|
||||
$q = mysql_query("SELECT id FROM accounts WHERE username='".mysql_real_escape_string($username)."' OR email='" . mysql_real_escape_string($username)."'");
|
||||
$row = mysql_fetch_assoc($q);
|
||||
if(is_array($row)){
|
||||
// This username is already in use. Let's see if this is a user that
|
||||
// the current one can modify
|
||||
$newUser = user_load(null, $row['id']);
|
||||
if(!is_array($newUser)){
|
||||
$returnval = 'Unable to load user';
|
||||
//this just means the user has no roles yet, that could be fine, if its a new user...
|
||||
$newUser = user_create($row['id'], $conference['id']);
|
||||
// $returnval = 'Unable to load user';
|
||||
}else{
|
||||
// check for role-specific limitations on who can edit who
|
||||
// we need to query the data manually, as the user_load function only
|
||||
@ -1634,11 +1636,13 @@ function user_invite($username, $password, $email, $roles_id){
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
}
|
||||
else {
|
||||
// ok, this is a new user name, so we'll need to create everything
|
||||
$newAccount = account_create($username, $password);
|
||||
if(is_array($newAccount)){
|
||||
// if we're inviting someone, then their email address __MUST__ be their username, otherwise, how the *(@&#*(@#& can we send them the invite?!
|
||||
// if we're inviting someone that doesnt already exist, then their email address __MUST__
|
||||
//be their username, otherwise, how the *(@&#*(@#& can we send them the invite?!
|
||||
account_set_email($newAccount['id'],$username);
|
||||
|
||||
// created the account successfully, now do the user
|
||||
@ -1660,7 +1664,10 @@ function user_invite($username, $password, $email, $roles_id){
|
||||
if($returnval == null){
|
||||
// if we've gotten this far, then either the user was created successfully, or they've
|
||||
// been loaded and our permission to modify them has been confirmed; we can add the role.
|
||||
$result = user_add_role($newUser, $roletype);
|
||||
// print_r($newUser);
|
||||
|
||||
$result = account_add_role($newUser['accounts_id'], $roles_id, $conference['id']);//, $password);
|
||||
|
||||
if($result == 'ok'){
|
||||
$returnval = user_load($newUser['id']);
|
||||
}else{
|
||||
|
@ -118,13 +118,13 @@
|
||||
update_status("<?=i18n('User not found. Choose the \"Invite New User\" button below to create an account for this user and send them an email invite.')?>");
|
||||
$("#button").attr('disabled',false);
|
||||
$("#button").val('<?=i18n("Invite new user")?>');
|
||||
$("#action").val("invite");
|
||||
$("#action").val("invitenew");
|
||||
break;
|
||||
case "norole":
|
||||
update_status("<?=i18n('User found without the selected role. Choose the \"Invite User to Role\" button below add the selected role on this user\'s account and send them email notice of the change.')?>");
|
||||
update_status("<?=i18n('Account found without the selected role.<br />Choose the \"Invite existing account role\" button below add the selected role on this user\'s account and send them email notice of the change.')?>");
|
||||
$("#button").attr('disabled',false);
|
||||
$("#button").val('<?=i18n("Invite existing user to role")?>');
|
||||
$("#action").val("invite");
|
||||
$("#button").val('<?=i18n("Invite existing account to role")?>');
|
||||
$("#action").val("inviteexisting");
|
||||
break;
|
||||
case "exist":
|
||||
update_status("<?=i18n('This user and role already exist. They cannot be invited.')?>");
|
||||
@ -161,7 +161,17 @@
|
||||
}
|
||||
*/
|
||||
|
||||
if($_POST['action']=="invite" && $_POST['email'] && $type != '') {
|
||||
if($_POST['action']=="invitenew" && $_POST['email'] && $type != '') {
|
||||
$newUser=user_invite($_POST['email'], null, $_POST['email'], $type);
|
||||
if(is_array($newUser)) {
|
||||
echo happy(i18n("%1 successfully invited to be a %2",array($_POST['email'],$type)));
|
||||
}
|
||||
else {
|
||||
echo error($newUser);
|
||||
}
|
||||
}
|
||||
else if($_POST['action']=="inviteexisting" && $_POST['email'] && $type != '') {
|
||||
|
||||
$newUser=user_invite($_POST['email'], null, $_POST['email'], $type);
|
||||
if(is_array($newUser)) {
|
||||
echo happy(i18n("%1 successfully invited to be a %2",array($_POST['email'],$type)));
|
||||
|
Loading…
x
Reference in New Issue
Block a user