Updated e-mail to accomodate custom e-mail address confirmation messages.

This commit is contained in:
jacob 2011-03-24 21:04:28 +00:00
parent 98f6a9f76d
commit 4a9e2ca163
4 changed files with 48 additions and 10 deletions

View File

@ -180,18 +180,31 @@ function account_set_email($accounts_id,$email) {
global $config;
//we dont actually set the email until its confirmed, we only set the pending email :p
if(isEmailAddress($email)) {
$code=generatePassword(24);
mysql_query("UPDATE accounts SET pendingemail='".mysql_real_escape_string($email)."', pendingemailcode='$code' WHERE id='$accounts_id'");
$urlproto = $_SERVER['SERVER_PORT'] == 443 ? "https://" : "http://";
$urlmain = "$urlproto{$_SERVER['HTTP_HOST']}{$config['SFIABDIRECTORY']}";
$urlemailconfirm = "emailconfirmation.php?i=$accounts_id&e=".rawurlencode($email)."&c=".$code;
$link=$urlmain."/".$urlemailconfirm;
email_send('account_email_confirmation',$email,array(),array("EMAIL"=>$email,"EMAILCONFIRMATIONLINK"=>$link));
$code=generatePassword(24);
mysql_query("UPDATE accounts SET email=NULL, pendingemail='".mysql_real_escape_string($email)."', pendingemailcode='$code' WHERE id='$accounts_id'");
$link = account_build_email_confirmation_link($accounts_id);
email_send('account_email_confirmation',$email,array(),array("EMAIL"=>$email,"EMAILCONFIRMATIONLINK"=>$link));
}
}
// generate the email confirmation URL. Separated from account_set_email for use elsewhere.
// returns null if no confirmation code is set for this account
function account_build_email_confirmation_link($accounts_id){
global $config;
$q = mysql_query("SELECT pendingemail, pendingemailcode FROM accounts WHERE id = $accounts_id");
$row = mysql_fetch_assoc($q);
$code = $row['pendingemailcode'];
$email = $row['pendingemail'];
if(trim($code) == ''){
return null;
}
$urlproto = $_SERVER['SERVER_PORT'] == 443 ? "https://" : "http://";
$urlmain = "$urlproto{$_SERVER['HTTP_HOST']}{$config['SFIABDIRECTORY']}";
$urlemailconfirm = "emailconfirmation.php?i=$accounts_id&e=".rawurlencode($email)."&c=".$code;
return $urlmain."/".$urlemailconfirm;
}
// add the specified role to the account's user record for the specified conference
// return true on success, false on failure
function account_add_role($accounts_id, $roles_id, $conferences_id, $password = null){

View File

@ -223,5 +223,24 @@
AND users.deleted='no'
ORDER BY email"),
"accounts_email_unconfirmed" => array("name" => "Users active in any active conference with unconfirmed e-mail addresses", "query" =>
"SELECT users.id
FROM users
JOIN accounts ON users.accounts_id = accounts.id
JOIN conferences ON users.conferences_id = conferences.id
WHERE conferences.status = 'running'
AND accounts.email != accounts.pendingemail
AND accounts.pendingemail IS NOT NULL
AND accounts.pendingemail != ''
"),
"accounts_email_unconfirmed_thisconference" => array("name" => "Users active for this conference with unconfirmed e-mail addresses", "query" =>
"SELECT users.id
FROM users JOIN accounts ON users.accounts_id = accounts.id
WHERE users.conferences_id = {$conference['id']}
AND accounts.email != accounts.pendingemail
AND accounts.pendingemail IS NOT NULL
AND accounts.pendingemail != ''
"),
);
?>

View File

@ -294,6 +294,7 @@ case 'dialog_edit':
<option value="REGNUM">[REGNUM]</option>
<option value="URLMAIN">[URLMAIN]</option>
<option value="URLLOGIN">[URLLOGIN]</option>
<option value="EMAILCONFIRMATIONLINK">[EMAILCONFIRMATIONLINK]</option>
</select>
</td></tr></table>
</td>
@ -669,6 +670,8 @@ case "email_get_list":
$urllogin = "$urlmain/login.php";
while($r=mysql_fetch_object($recipq)) {
$u=user_load_by_uid($r->users_uid);
$confirmationLink = account_build_email_confirmation_link($u['accounts_id']);
$replacements=array(
"FAIRNAME"=>$config['fairname'],
"SALUTATION"=>$u['salutation'],
@ -679,6 +682,7 @@ case "email_get_list":
"ORGANIZATION"=>$u['sponsor']['organization'],
"URLMAIN"=>$urlmain,
"URLLOGIN"=>$urllogin,
"EMAILCONFIRMATIONLINK" => $confirmationLink,
);
if($u['email'] && $u['email'][0] != '*') {
@ -826,6 +830,7 @@ case "email_get_list":
if($u) {
$a=account_load($u['accounts_id']);
$apassword=account_get_password($u['accounts_id']);
$confirmationLink = account_build_email_confirmation_link($u['accounts_id']);
if($a['email']) {
$e=$a['email'];
}
@ -853,6 +858,7 @@ case "email_get_list":
"ORGANIZATION"=>$u['sponsor']['organization'],
"URLMAIN"=>$urlmain,
"URLLOGIN"=>$urllogin,
"EMAILCONFIRMATIONLINK" => $confirmationLink,
);
$toname=$u['name'];

View File

@ -109,7 +109,7 @@ if(!mysql_select_db($DBNAME)) {
@mysql_query("SET NAMES utf8");
//find out the fair year and any other 'year=0' configuration parameters (things that dont change as the years go on)
$q=@mysql_query("SELECT * FROM config WHERE conferences_id=0 OR year=0");
$q=@mysql_query("SELECT * FROM config WHERE conferences_id=0");
//we might get an error if installation step 2 is not done (ie, the config table doesnt even exist)
if(mysql_error()) {