Add two new emails: registration complete, registration payment pending

Whipe out all 'from' of info@sfiab.ca (the old default, we dont want others using it!)
When sending emails, if 'from' is empty, use the $config['fairmanageremail']
Add a warning on the communication page if the fair manager email has not been set
Set the default 'from' for new emails to be the fair manager email

NOTE/FIXME: i added the hooks for the two new emails to be sent, but still 
need to fill in the substitution values as well as the "to" - no time now, 
will do that tomorrow
This commit is contained in:
james 2007-10-29 20:21:40 +00:00
parent d1c626e2b6
commit ab5180ef9e
5 changed files with 38 additions and 11 deletions

View File

@ -232,6 +232,8 @@
if($_POST['from']) $from=stripslashes($_POST['from']); if($_POST['from']) $from=stripslashes($_POST['from']);
if($_POST['body']) $body=stripslashes($_POST['body']); if($_POST['body']) $body=stripslashes($_POST['body']);
if(!$from && $config['fairmanageremail']) $from="Fair Manager <".$config['fairmanageremail'].">";
echo "<table>"; echo "<table>";
echo "<tr><td>".i18n("Email Name")."</td><td><input type=\"text\" name=\"name\" size=\"60\" value=\"$name\" /></td></tr>\n"; echo "<tr><td>".i18n("Email Name")."</td><td><input type=\"text\" name=\"name\" size=\"60\" value=\"$name\" /></td></tr>\n";
echo "<tr><td>".i18n("Email Key")."</td><td>"; echo "<tr><td>".i18n("Email Key")."</td><td>";
@ -252,8 +254,10 @@
} }
else else
{ {
if(!$config['fairmanageremail'])
echo notice(i18n("Warning: The 'Fair Manager Email' has not been set in SFIAB Configuration / Configuration Variables / Global. Please set it. The 'Fair Manager Email' is the default 'From' address for all emails and without a 'From' address, no emails can be sent!"));
$q=mysql_query("SELECT * FROM emails ORDER BY name"); $q=mysql_query("SELECT * FROM emails ORDER BY type,name");
echo "<A href=\"communication.php?action=add\">Add New Email</a>"; echo "<A href=\"communication.php?action=add\">Add New Email</a>";
echo "<table class=\"summarytable\">"; echo "<table class=\"summarytable\">";
echo "<tr>"; echo "<tr>";

View File

@ -216,18 +216,22 @@ echo mysql_Error();
} }
if($_POST['action']=="receivedyes") if($_POST['action']=="receivedyes")
{ {
//actually set it to 'closed' //actually set it to 'complete'
mysql_query("UPDATE registrations SET status='complete' WHERE num='".$_POST['registration_number']."'"); mysql_query("UPDATE registrations SET status='complete' WHERE num='".$_POST['registration_number']."'");
//FIXME: set the to, subsub and subbod!
email_send("register_participants_received",$to,$subsub,$subbod);
echo happy(i18n("Registration of form %1 successfully completed",array($registration_number))); echo happy(i18n("Registration of form %1 successfully completed",array($registration_number)));
} }
else if($_POST['action']=="receivedyesnocash") else if($_POST['action']=="receivedyesnocash")
{ {
//actually set it to 'closed' //actually set it to 'paymentpending'
mysql_query("UPDATE registrations SET status='paymentpending' WHERE num='".$_POST['registration_number']."'"); mysql_query("UPDATE registrations SET status='paymentpending' WHERE num='".$_POST['registration_number']."'");
//FIXME: set the to, subsub and subbod!
email_send("register_participants_paymentpending",$to,$subsub,$subbod);
echo happy(i18n("Registration of form %1 marked as payment pending",array($registration_number))); echo happy(i18n("Registration of form %1 marked as payment pending",array($registration_number)));
} }

View File

@ -797,6 +797,8 @@ function outputStatus($status)
function email_send($val,$to,$sub_subject=array(),$sub_body=array()) function email_send($val,$to,$sub_subject=array(),$sub_body=array())
{ {
global $config;
//if our "to" doesnt look like a valid email, then forget about sending it. //if our "to" doesnt look like a valid email, then forget about sending it.
if(!eregi('[a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.([a-zA-Z]{2,4})', $to)) if(!eregi('[a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.([a-zA-Z]{2,4})', $to))
return; return;
@ -841,12 +843,24 @@ function email_send($val,$to,$sub_subject=array(),$sub_body=array())
} }
*/ */
if($r->from)
$fr=$r->from;
else if ($config['fairmanageremail'])
$fr=$config['fairmanageremail'];
else
$fr="";
mail($to,$subject,$body,"From: $r->from\r\nReply-To: $r->from\r\nReturn-Path: $r->from"); //only send the email if we have a from
if($fr) {
$extraheaders="From: $fr\r\bReply-To: $fr\r\nREturn-Path: $fr";
mail($to,$subject,$body,$extraheaders);
}
else
echo error(i18n("CRITICAL ERROR: email '%1' does not have a 'From' and the Fair Manager Email is not configured",array($val),array("email key name")));
} }
else else
{ {
echo error(i18n("CRITICAL ERROR: email '%1' not found",array($val),array("email address"))); echo error(i18n("CRITICAL ERROR: email '%1' not found",array($val),array("email key name")));
} }
} }

3
db/db.update.53.sql Normal file
View File

@ -0,0 +1,3 @@
INSERT INTO `emails` (`val`, `name`, `description`, `from`, `subject`, `body`, `type`) VALUES ('register_participants_received', 'Participant Registration - Form Received', 'Sent to the participant when the admin flags their signature form as received', 'james@lightbox.org', 'Registration for [FAIRNAME] Complete', 'Dear [FIRSTNAME],\r\nYour registration for the [FAIRNAME] is now complete.\r\nYour project number is [PROJECTNUMBER]. Please write down your project number and bring it with you to the fair in order to expedite the check-in process.\r\n\r\nSincerely,\r\n [FAIRNAME]', 'system');
INSERT INTO `emails` (`val`, `name`, `description`, `from`, `subject`, `body`, `type`) VALUES ('register_participants_paymentpending', 'Participant Registration - Payment Pending', 'Sent to the participant when the admin flags their signature form as received but payment pending', 'james@lightbox.org', 'Registration for [FAIRNAME] Not Complete - Payment Pending', 'Dear [FIRSTNAME],\r\nYour registration for the [FAIRNAME] is not yet complete. We received your registration form however it was missing the required registration fee. Please send the required registration fee in aso soon as possible in order to complete your registration.\r\n\r\nYour project number is [PROJECTNUMBER]. Please write down your project number and bring it with you to the fair in order to expedite the check-in process.\r\n\r\nSincerely,\r\n [FAIRNAME]', 'system');
UPDATE `emails` SET `from`='' WHERE `from`='info@sfiab.ca';

View File

@ -83,12 +83,15 @@ else
//query all of the awards //query all of the awards
$q=mysql_query("SELECT award_awards.id, $q=mysql_query("SELECT award_awards.id,
award_awards.name, award_awards.name,
award_awards.criteria award_awards.criteria,
award_sponsors.organization
FROM FROM
award_awards, award_awards,
award_types award_types,
award_sponsors
WHERE WHERE
award_types.id=award_awards.award_types_id award_types.id=award_awards.award_types_id
AND award_sponsors.id=award_awards.award_sponsors_id
AND (award_types.type='Special' OR award_types.type='Other') AND (award_types.type='Special' OR award_types.type='Other')
AND award_awards.year='{$config['FAIRYEAR']}' AND award_awards.year='{$config['FAIRYEAR']}'
AND award_types.year='{$config['FAIRYEAR']}' AND award_types.year='{$config['FAIRYEAR']}'
@ -101,7 +104,7 @@ else
$ch = (in_array($r->id,$spawards)) ? "checked=\"checked\"" : ""; $ch = (in_array($r->id,$spawards)) ? "checked=\"checked\"" : "";
echo "<input onclick=\"checkboxclicked(this)\" $ch type=\"checkbox\" name=\"spaward[]\" value=\"{$r->id}\" />"; echo "<input onclick=\"checkboxclicked(this)\" $ch type=\"checkbox\" name=\"spaward[]\" value=\"{$r->id}\" />";
echo "</td><td>"; echo "</td><td>";
echo "<b>{$r->name}</b>"; echo "<b>{$r->name}</b> ($r->organization)";
echo "</td></tr>"; echo "</td></tr>";
echo "<tr><td>"; echo "<tr><td>";
echo "{$r->criteria}"; echo "{$r->criteria}";
@ -110,7 +113,6 @@ else
} }
echo "</table>"; echo "</table>";
echo "<br />";
echo "<input type=\"submit\" value=\"".i18n("Save Special Award Preferences")."\" />\n"; echo "<input type=\"submit\" value=\"".i18n("Save Special Award Preferences")."\" />\n";
echo "</form>"; echo "</form>";