diff --git a/admin/communication.php b/admin/communication.php index 93beb23..3461f1b 100644 --- a/admin/communication.php +++ b/admin/communication.php @@ -232,6 +232,8 @@ if($_POST['from']) $from=stripslashes($_POST['from']); if($_POST['body']) $body=stripslashes($_POST['body']); + if(!$from && $config['fairmanageremail']) $from="Fair Manager <".$config['fairmanageremail'].">"; + echo ""; echo "\n"; echo "
".i18n("Email Name")."
".i18n("Email Key").""; @@ -252,8 +254,10 @@ } 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 "Add New Email"; echo ""; echo ""; diff --git a/admin/registration_receivedforms.php b/admin/registration_receivedforms.php index 907c7a8..6b229d0 100644 --- a/admin/registration_receivedforms.php +++ b/admin/registration_receivedforms.php @@ -216,18 +216,22 @@ echo mysql_Error(); } 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']."'"); - - + + //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))); } 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']."'"); + + //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))); } diff --git a/common.inc.php b/common.inc.php index 97dbde7..1693b03 100644 --- a/common.inc.php +++ b/common.inc.php @@ -797,6 +797,8 @@ function outputStatus($status) 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(!eregi('[a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.([a-zA-Z]{2,4})', $to)) 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 { - 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"))); } } diff --git a/db/db.update.53.sql b/db/db.update.53.sql new file mode 100644 index 0000000..0ad6d00 --- /dev/null +++ b/db/db.update.53.sql @@ -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'; diff --git a/register_judges_specialawards.php b/register_judges_specialawards.php index cecc8ee..0061f3d 100644 --- a/register_judges_specialawards.php +++ b/register_judges_specialawards.php @@ -83,12 +83,15 @@ else //query all of the awards $q=mysql_query("SELECT award_awards.id, award_awards.name, - award_awards.criteria + award_awards.criteria, + award_sponsors.organization FROM award_awards, - award_types + award_types, + award_sponsors WHERE 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_awards.year='{$config['FAIRYEAR']}' AND award_types.year='{$config['FAIRYEAR']}' @@ -101,7 +104,7 @@ else $ch = (in_array($r->id,$spawards)) ? "checked=\"checked\"" : ""; echo "id}\" />"; echo ""; echo "
"; - echo "{$r->name}"; + echo "{$r->name} ($r->organization)"; echo "
"; echo "{$r->criteria}"; @@ -110,7 +113,6 @@ else } echo "
"; - echo "
"; echo "\n"; echo "";