From 8ad304441f8f1d026c6cc58d16a436b71b77e4f2 Mon Sep 17 00:00:00 2001 From: james Date: Thu, 15 Nov 2007 21:17:20 +0000 Subject: [PATCH] Add 'emailcontact' field to registrations table, that SCHOOLINVITE teachers can put their own email address into to receive emails that would normally go to the students. If the students email is valid the student will still get the emails as well. --- common.inc.php | 13 ++++++++++--- db/db.code.version.txt | 2 +- db/db.update.60.sql | 1 + schoolinvite.php | 17 +++++++++++------ 4 files changed, 23 insertions(+), 10 deletions(-) create mode 100644 db/db.update.60.sql diff --git a/common.inc.php b/common.inc.php index c5c70c0..84a2ce1 100644 --- a/common.inc.php +++ b/common.inc.php @@ -922,9 +922,13 @@ function getEmailRecipientsForRegistration($reg_id) $q=mysql_query("SELECT * FROM registrations WHERE id='$reg_id' AND year='{$config['FAIRYEAR']}'"); $registration=mysql_fetch_object($q); - //FIXME: right now it only emails the kids! add fields to registrations table to store who it should email - //and write a way for that info to be updated, especially on the teacher invitation screen to have emails - //go to the teacher. + if($registration->emailcontact) && isEmailAddress($registration->emailcontact)) { + $ret[]=array("to"=>$registration->emailcontact, + "firstname"=>"", + "lastname"=>"", + "email"=>$registration->emailcontact, + ); + } $sq=mysql_query("SELECT * FROM students WHERE registrations_id='$reg_id' AND year='{$config['FAIRYEAR']}'"); $ret=array(); @@ -936,6 +940,9 @@ function getEmailRecipientsForRegistration($reg_id) $to=$sr->firstname." <".$sr->email.">"; else if($sr->lastname) $to=$sr->lastname." <".$sr->email.">"; + else + $to=$sr->email; + $ret[]=array("to"=>$to, "firstname"=>$sr->firstname, "lastname"=>$sr->lastname, diff --git a/db/db.code.version.txt b/db/db.code.version.txt index 04f9fe4..abdfb05 100644 --- a/db/db.code.version.txt +++ b/db/db.code.version.txt @@ -1 +1 @@ -59 +60 diff --git a/db/db.update.60.sql b/db/db.update.60.sql new file mode 100644 index 0000000..7222991 --- /dev/null +++ b/db/db.update.60.sql @@ -0,0 +1 @@ +ALTER TABLE `registrations` ADD `emailcontact` VARCHAR( 64 ) DEFAULT NULL AFTER `email` ; diff --git a/schoolinvite.php b/schoolinvite.php index d401223..65d1579 100644 --- a/schoolinvite.php +++ b/schoolinvite.php @@ -38,9 +38,10 @@ if($_SESSION['schoolid'] && $_SESSION['schoolaccesscode']) }while(mysql_num_rows($q)>0); //actually insert it - mysql_query("INSERT INTO registrations (num,email,start,status,year) VALUES (". + mysql_query("INSERT INTO registrations (num,email,emailcontact,start,status,year) VALUES (". "'$regnum',". "'".$_POST['email']."',". + "'".$_POST['emailcontact']."',". "NOW(),". "'open',". $config['FAIRYEAR']. @@ -197,10 +198,11 @@ if($_SESSION['schoolid'] && $_SESSION['schoolaccesscode']) echo ""; echo ""; - echo ""; - echo ""; - echo ""; - echo ""; + echo ""; + echo ""; + echo ""; + echo ""; - echo ""; + echo ""; echo ""; echo ""; echo "
".i18n("Email Address")."
".i18n("First Name")."
".i18n("Last Name")."
".i18n("Grade").""; + echo "
".i18n("Student Email Address")."".i18n("Or unique username for student")."
".i18n("Contact Email Address")."".i18n("Any emails that would normally go to the student, will also be sent to this address")."
".i18n("Student First Name")."
".i18n("Student Last Name")."
".i18n("Grade").""; echo "
$r->lastname$r->firstname$r->email$r->email"; + if($r->emailcontact) + echo " / $r->emailcontact"; + echo "$r->grade$r->num";