From 6bd6f971ac7b64e54577af7857102eb1c1945c13 Mon Sep 17 00:00:00 2001 From: dave Date: Wed, 10 Feb 2010 05:36:07 +0000 Subject: [PATCH] Send a registration email for new regs for awards that are marked as "this student should be registered in this fair" so the student knows how to login. For non-registration awards, set the status to complete so the project is included in awards. --- remote.php | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/remote.php b/remote.php index f1d11cf..ade7b7d 100644 --- a/remote.php +++ b/remote.php @@ -192,9 +192,10 @@ function award_upload_school(&$student, &$school, $year, &$response) return award_upload_update_school($q, $school, $school_id); } -function award_upload_assign(&$fair, &$prize, &$project, $year, &$response) +function award_upload_assign(&$fair, &$award, &$prize, &$project, $year, &$response) { $reg_email_needs_update = false; + $new_reg = false; /* Copied from admin/award_upload.php, this is the * transport name => sql name mapping */ $student_fields = array('firstname'=>'firstname', @@ -247,7 +248,11 @@ function award_upload_assign(&$fair, &$prize, &$project, $year, &$response) '$year', '{$fair['id']}');"); $pid = mysql_insert_id(); $reg_email_needs_update = true; + $new_reg = true; } + $q = mysql_query("SELECT * FROM registrations WHERE id='$registrations_id'"); + $registration = mysql_fetch_assoc($q); + /* Update the project in case anythign changed */ mysql_query("UPDATE projects SET title='".mysql_real_escape_string($project['title'])."', summary='".mysql_real_escape_string($project['abstract'])."', @@ -283,8 +288,23 @@ function award_upload_assign(&$fair, &$prize, &$project, $year, &$response) WHERE id='$registrations_id'"); $reg_email_needs_update = false; } - } + if($award['external_register_winners'] == 1 && $new_reg == true) { + /* This award is for students who are participating in this fair, we need + * to get their reg number to them if this is a new registration */ + email_send("new_participant",$student['email'],array(), + array( "EMAIL"=>$student['email'], + "REGNUM"=>$registration['num']) + ); + $response['notice'][] = " - Sent welcome registration email to: {$student['firstname']} {$student['lastname']} <{$student['email']}>"; + } + } + if($award['external_register_winners'] == 0) { + /* It's not an external, so we don't need the student to login + * or antyhing, we probably want to include it in reports, so set + * it to complete */ + mysql_query("UPDATE registrations SET status='complete' WHERE id='$registrations_id'"); + } } function handle_award_upload(&$u, &$fair, &$data, &$response) @@ -323,7 +343,7 @@ function handle_award_upload(&$u, &$fair, &$data, &$response) if(!is_array($ul_p['projects'])) continue; foreach($ul_p['projects'] as &$project) { - award_upload_assign($fair, $prize, $project, $year, $response); + award_upload_assign($fair, $award, $prize, $project, $year, $response); } } $response['notice'][] = 'Award winners saved';