diff --git a/account.inc.php b/account.inc.php
index c4cc72a..552e5a6 100644
--- a/account.inc.php
+++ b/account.inc.php
@@ -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){
diff --git a/admin/communication.inc.php b/admin/communication.inc.php
index 86003b1..4987f30 100644
--- a/admin/communication.inc.php
+++ b/admin/communication.inc.php
@@ -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 != ''
+ "),
);
?>
diff --git a/admin/communication.php b/admin/communication.php
index 48fa547..644dd84 100644
--- a/admin/communication.php
+++ b/admin/communication.php
@@ -294,6 +294,7 @@ case 'dialog_edit':
+
@@ -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'];
diff --git a/common.inc.bootstrap.php b/common.inc.bootstrap.php
index 5a00169..4b02d2f 100644
--- a/common.inc.bootstrap.php
+++ b/common.inc.bootstrap.php
@@ -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()) {