diff --git a/account.inc.php b/account.inc.php index 58d1969..f7a4c23 100644 --- a/account.inc.php +++ b/account.inc.php @@ -114,6 +114,15 @@ function account_load($id) return $a; } +function account_get_password($id) { + $id=intval($id); + $q=mysql_query("SELECT password FROM accounts WHERE id='$id'"); + $r=mysql_fetch_object($q); + return $r->password; +} + + + function account_load_by_username($username) { $un = mysql_real_escape_string($username); @@ -187,6 +196,7 @@ function account_set_email($accounts_id,$email) { // return true on success, false on failure function account_add_role($accounts_id, $roles_id, $conferences_id, $password = null){ global $config; + global $conference; // avoid injections $accounts_id=intval($accounts_id); @@ -291,16 +301,26 @@ function account_add_role($accounts_id, $roles_id, $conferences_id, $password = return "mysqlerror:" . mysql_error(); } + $a=account_load($accounts_id); + $password=account_get_password($accounts_id); -//FIXME: this is where we should send the email -/* - email_send("{$type}_new_invite",$_POST['email'], - array("FAIRNAME"=>$config['fairname']), - array("FAIRNAME"=>$config['fairname'], - "EMAIL"=>$_POST['email'], - "ROLE"=>type)); + //in this case, we want to send to pendingemail if thats all we have, because + //its possible that this is a new user that was just added and we just sent + //the email confirmation email as well, so on new user invitation, they will get + //the invite email as well as the email confirmation email. + if($a['email']) $e=$a['email']; + else if($a['pendingemail']) $e=$a['pendingemail']; + + email_send("{$role}_new_invite", + $e, + array("FAIRNAME"=>$conference['name']), + array("FAIRNAME"=>$conference['name'], + "EMAIL"=>$e, + "USERNAME"=>$a['username'], + "PASSWORD"=>$password, + "ROLE"=>$role) + ); -*/ // if we made it this far, the role was successfully added return 'ok'; }