add the ability for schools to invite participants IF participant_registration_type=="invite"

also switch the new participant email to read from the emails table instead of hardcoded from the file
This commit is contained in:
james 2005-11-25 19:37:10 +00:00
parent 122194d296
commit 6eb1a39d0b
4 changed files with 84 additions and 13 deletions

View File

@ -735,7 +735,7 @@ function email_send($val,$to,$sub_subject=array(),$sub_body=array())
*/
mail($to,$subject,$body,"From: $r->from\r\nReply-To: $r->from");
mail($to,$subject,$body,"From: $r->from\r\nReply-To: $r->from\r\nReturn-Path: $r->from");
}
else
{

View File

@ -4,4 +4,6 @@ INSERT INTO `config` ( `var` , `val` , `description` , `year` ) VALUES ( 'judge_
INSERT INTO `config` ( `var` , `val` , `description` , `year` ) VALUES ( 'participant_registration_singlepassword', '', 'The single password to use for participant registraiton if participant_registration_type is singlepassword. Leave blank if not using singlepassword participant registration','-1');
INSERT INTO `config` ( `var` , `val` , `description` , `year` ) VALUES ( 'judge_registration_singlepassword', '', 'The single password to use for judge registration if judge_registration_type is singlepassword. Leave blank if not using singlepassword judge registraiton', '-1');
ALTER TABLE `schools` ADD `registration_password` VARCHAR( 32 ) NOT NULL;
INSERT INTO `emails` VALUES ('', 'register_participants_resend_regnum', 'Participant Registration - Resend Registration Number', 'Resend the password to the participant if they submit a ''forgot regnum'' request', 'website@sfiab.ca', 'Registration for [FAIRNAME]', 'We have received a request for the retrieval if your registration number from this email address. Please find your existing registration number below\r\n\r\nRegistration Number: [REGNUM]\r\n', 'system');
INSERT INTO `emails` VALUES ('', 'new_participant', 'New Participant', 'Email that new participants receive when they are added to the system', 'website@sfiab.ca', 'Registration for [FAIRNAME]', 'A new registration account has been created for you. To access your registration account, please enter enter the following registration number into the registration website:\r\n\r\nRegistration Number: [REGNUM]\r\n', 'system');

View File

@ -321,15 +321,7 @@
$config['FAIRYEAR'].
")");
$mailbody= "A new registration account has been created for you.\n".
"To access your registration account, please enter\n".
"enter the following registration number into the\n".
"registration website:\n".
"\n".
"Registration Number: $regnum\n".
"\n";
mail($_SESSION['email'],i18n("Registration for %1",array(i18n($config['fairname']))),$mailbody);
email_send("new_participant",$_SESSION['email'],array("FAIRNAME"=>i18n($config['fairname'])),array("REGNUM"=>$regnum));
echo i18n("You have been identified as a new registrant. An email has been sent to <b>%1</b> which contains your new <b>registration number</b>. Please check your email to obtain your <b>registration number</b> and then enter it below:",array($_SESSION['email']));
echo "<input type=\"hidden\" name=\"action\" value=\"new\">";

View File

@ -87,6 +87,45 @@ if($_SESSION['schoolid'] && $_SESSION['schoolaccesscode'])
}
if($_POST['action']=="invite")
{
if($_POST['firstname'] && $_POST['lastname'] && $_POST['email'])
{
$regnum=0;
//now create the new registration record, and assign a random/unique registration number to then.
do
{
//random number between
//100000 and 999999 (six digit integer)
$regnum=rand(100000,999999);
$q=mysql_query("SELECT * FROM registrations WHERE num='$regnum' AND year=".$config['FAIRYEAR']);
}while(mysql_num_rows($q)>0);
//actually insert it
mysql_query("INSERT INTO registrations (num,email,start,status,year) VALUES (".
"'$regnum',".
"'".$_POST['email']."',".
"NOW(),".
"'open',".
$config['FAIRYEAR'].
")");
$regid=mysql_insert_id();
mysql_query("INSERT INTO students (registrations_id,email,firstname,lastname,schools_id,year) VALUES (
'$regid',
'".mysql_escape_string($_POST['email'])."',
'".mysql_escape_string($_POST['firstname'])."',
'".mysql_escape_string($_POST['lastname'])."',
'".mysql_escape_string($_SESSION['schoolid'])."',
'".$config['FAIRYEAR']."')");
email_send("new_participant",$_POST['email'],array("FAIRNAME"=>i18n($config['fairname'])),array("REGNUM"=>"$regnum"));
echo happy(i18n("The participant has been successfully invited"));
}
}
echo "<h3>$school->school</h3>";
echo "<h4>School Information</h4>";
echo "Please make sure your school contact information is correct, make any necessary changes:";
@ -122,6 +161,43 @@ if($_SESSION['schoolid'] && $_SESSION['schoolaccesscode'])
echo "<br />";
echo "<br />";
}
else if($config['participant_registration_type']=="invite")
{
$q=mysql_query("SELECT (NOW()>'".$config['dates']['regopen']."' AND NOW()<'".$config['dates']['regclose']."') AS datecheck");
$datecheck=mysql_fetch_object($q);
if($datecheck!=0)
{
echo "<h4>".i18n("Participant Registration Invitations")."</h4>";
echo i18n("In order for your school's students to register for the fair, you will need to invite them to register. Simply enter their email address below to invite them to register. <b>Important</b>: for group projects, only add one of the participants, that participant will then add the other group member(s) to the project");
echo "<br />";
echo "<br />";
echo "<form method=POST action=\"schoolaccess.php\">";
echo "<input type=hidden name=action value=\"invite\">";
echo "<table>";
echo "<tr><td>".i18n("Email Address")."</td><td><input type=\"text\" name=\"email\" /></td></tr>";
echo "<tr><td>".i18n("First Name")."</td><td><input type=\"text\" name=\"firstname\" /></td></tr>";
echo "<tr><td>".i18n("Last Name")."</td><td><input type=\"text\" name=\"lastname\" /></td></tr>";
echo "</table>";
echo "<input type=\"submit\" value=\"Invite Participant\">";
echo "</form>";
}
echo "<br />";
echo "<h4>".i18n("Invited participants from your school")."</h4>";
$q=mysql_query("SELECT * FROM students WHERE schools_id='".$school->id."' AND year='".$config['FAIRYEAR']."' ORDER BY lastname,firstname");
echo "<table class=\"summarytable\">";
echo "<tr><th>".i18n("Last Name")."</th><th>".i18n("First Name")."</th><th>".i18n("Email Address")."</th></tr>";
while($r=mysql_fetch_object($q))
{
echo "<tr><td>$r->lastname</td><td>$r->firstname</td><td>$r->email</td></tr>";
}
echo "</table>";
}
/*
//the participation section needs to be updated to handle the age categories as specified
@ -211,8 +287,9 @@ else
<br><br>
<table border=0 cellspacing=0 cellpadding=5>
<tr><td>School:</td><td>
<tr><td><?=i18n("School")?>:</td><td>
<select name="schoolid">
<option value=""><?=i18n("Choose your school")?></option>
<?
$q=mysql_query("SELECT id,school FROM schools WHERE year='".$config['FAIRYEAR']."'");
while($r=mysql_fetch_object($q))
@ -222,8 +299,8 @@ else
?>
</select>
</td></tr>
<tr><td>Access Code:</td><td><input type=text name=accesscode></td></tr>
<tr><td align=center><input type=submit value="Login"></td></tr>
<tr><td><?=i18n("Access Code")?>:</td><td><input type=text name=accesscode></td></tr>
<tr><td align=center><input type=submit value="<?=i18n("Login")?>"></td></tr>
</table>
</form>