\n";
}
@@ -223,86 +114,3 @@ function draw_login(){
}
-
-function draw_feedback(){
- global $sh_email;
-
- $title = i18n("School Feedback / Questions");
- send_header($title, array("School Access" => _THISFILE));
-
- echo i18n("We are always welcome to any feedback (both positive and constructive criticism!), or any questions you may have. Please use the following form to communicate with the science fair committee!");
- if($sh_email != '') {
- echo "";
- }else{
- echo error(i18n("Feedback is disabled until a science teacher email address is entered above"));
- }
-
-}
-
-function draw_schoolInfo(){
- global $school, $sh, $sh_email, $config;
-
- $title = i18n("School Information");
- send_header($title, array("School Access" => _THISFILE));
- echo "
$school->school
";
-
- echo i18n("Please make sure your school contact information is correct, make any necessary changes:");
- echo "";
- echo " ";
-}
-
-function draw_participantReg(){
- global $school, $config;
-
- $title = i18n("Participant Registration");
- send_header($title, array("School Access" => _THISFILE));
-
- if($config['participant_registration_type']=="schoolpassword")
- {
- echo "
".i18n("Participant Registration Password")."
";
-
- echo i18n("In order for your school's students to register for the fair, they will need to know your specific school registration password");
- echo " ";
- echo " ";
- echo i18n("Registration Password: %1",array($school->registration_password));
- echo " ";
- echo " ";
- }
- else if($config['participant_registration_type']=="invite" || $config['participant_registration_type']=="openorinvite" )
- {
-
- echo "
".i18n("Participant Registration Invitations")."
";
- if($config['participant_registration_type']=="invite")
- echo i18n("In order for your school's students to register for the fair, you must first invite them via email. Use the 'Participant Registration Invitations' link below to invite your students to the fair");
- else if($config['participant_registration_type']=="openorinvite" )
- echo i18n("In order for your school's students to register for the fair, you can invite them via email using the 'Participant Registration Invitations' link below, or they can register on their own by accessing the 'Participant Registration' link in the menu.");
- echo " ";
- echo " ";
- echo " ".i18n("Participant Registration Invitations")."";
- echo " ";
- }
-}
-
diff --git a/schoolfeedback.php b/schoolfeedback.php
new file mode 100644
index 0000000..e63f169
--- /dev/null
+++ b/schoolfeedback.php
@@ -0,0 +1,53 @@
+ "schoolaccess.php"));
+
+ // load the school info
+ $q=mysql_query("SELECT * FROM schools WHERE id='".$_SESSION['schoolid']."' AND accesscode='".$_SESSION['schoolaccesscode']."' AND year='".$config['FAIRYEAR']."'");
+ echo mysql_error();
+ $school=mysql_fetch_object($q);
+
+ if($school->sciencehead_uid > 0)
+ $sh = user_load_by_uid($school->sciencehead_uid);
+ else
+ $sh = array();
+ $sh_email = ($sh['email'] != '' && $sh['email'][0] != '*') ? $sh['email'] : '';
+
+ // send the e-mail if we're receiving a post
+ if(array_key_exists('feedbacktext', $_POST)){
+ $body="";
+ $body.=date("r")."\n";
+ $body.=$_SERVER['REMOTE_ADDR']." (".$_SERVER['REMOTE_HOST'].")\n";
+ $body.="School ID: $school->id\n";
+ $body.="School Name: $school->school\n";
+ if($sh['name']) $body.="Science Teacher: {$sh['name']}\n";
+ if($sh['phonework']) $body.="Science Teacher Phone: {$sh['phonework']}\n";
+ if($sh_email) $body.="Science Teacher Email: $sh_email\n";
+ $body.="\nFeedback:\n".stripslashes($_POST['feedbacktext'])."\n";
+ $returnEmailAddress = $sh_email;
+ mail($config['fairmanageremail'],"School Feedback",$body,"From: ". $returnEmailAddress."\nReply-To: ".$returnEmailAddress."\nReturn-Path: ".$returnEmailAddress);
+ echo happy_("Your feedback has been sent");
+ }
+
+ // draw the feedback form
+ echo i18n("We are always welcome to any feedback (both positive and constructive criticism!), or any questions you may have. Please use the following form to communicate with the science fair committee!");
+ if($sh_email != '') {
+ echo "";
+ }else{
+ echo error("Feedback is disabled until a science teacher email address is entered above");
+ }
+
+ send_footer();
+}else{
+ header('Location: schoolaccess.php');
+}
+?>
diff --git a/schoolinfo.php b/schoolinfo.php
new file mode 100644
index 0000000..d53efe1
--- /dev/null
+++ b/schoolinfo.php
@@ -0,0 +1,118 @@
+ "schoolaccess.php"));
+
+ $q=mysql_query("SELECT * FROM schools WHERE id='".$_SESSION['schoolid']."' AND accesscode='".$_SESSION['schoolaccesscode']."' AND year='".$config['FAIRYEAR']."'");
+ echo mysql_error();
+ $school=mysql_fetch_object($q);
+
+ if($school->sciencehead_uid > 0)
+ $sh = user_load_by_uid($school->sciencehead_uid);
+ else
+ $sh = array();
+ $sh_email = ($sh['email'] != '' && $sh['email'][0] != '*') ? $sh['email'] : '';
+
+
+ if($_POST['action']=="save") {
+ /* Get info about science head */
+ $sciencehead_update = '';
+ list($first, $last) = split(' ', $_POST['sciencehead'], 2);
+ $em = $_POST['scienceheademail'];
+ if($em == '' && ($first != '' || $last != '')) $em = "*$first$last".user_generate_password();
+
+ if($school->sciencehead_uid > 0)
+ $sh = user_load_by_uid($school->sciencehead_uid);
+ else if($em != '') {
+ $sh = user_create('teacher', $em);
+ $sciencehead_update = "sciencehead_uid='{$sh['uid']}',";
+ } else
+ $sh = false;
+
+ /* If we have a record, either delete it or update it */
+ if(is_array($sh)) {
+ if($em == '') {
+ user_purge($sh, 'teacher');
+ $sciencehead_update = 'sciencehead_uid=NULL,';
+ } else {
+ $sh['firstname'] = $first;
+ $sh['lastname'] = $last;
+ $sh['phonework'] = $_POST['scienceheadphone'];
+ $sh['email'] = $em;
+ $sh['username'] = $em;
+ user_save($sh);
+ }
+ }
+
+ mysql_query("UPDATE schools SET
+ school='".mysql_escape_string(stripslashes($_POST['school']))."',
+ address='".mysql_escape_string(stripslashes($_POST['address']))."',
+ city='".mysql_escape_string(stripslashes($_POST['city']))."',
+ province_code='".mysql_escape_string(stripslashes($_POST['province_code']))."',
+ postalcode='".mysql_escape_string(stripslashes($_POST['postalcode']))."',
+ phone='".mysql_escape_string(stripslashes($_POST['phone']))."',
+ $sciencehead_update
+ fax='".mysql_escape_string(stripslashes($_POST['fax']))."'
+ WHERE id='$school->id'");
+
+ echo mysql_error();
+ if(mysql_error())
+ echo error(i18n("An Error occured trying to save the school information"));
+ else
+ echo happy(i18n("School information successfully updated"));
+
+ }
+
+}else{
+ header('Location: schoolaccess.php');
+ exit();
+}
+
+// load the school info
+$q=mysql_query("SELECT * FROM schools WHERE id='".$_SESSION['schoolid']."' AND accesscode='".$_SESSION['schoolaccesscode']."' AND year='".$config['FAIRYEAR']."'");
+echo mysql_error();
+$school=mysql_fetch_object($q);
+
+if($school->sciencehead_uid > 0)
+ $sh = user_load_by_uid($school->sciencehead_uid);
+else
+ $sh = array();
+$sh_email = ($sh['email'] != '' && $sh['email'][0] != '*') ? $sh['email'] : '';
+
+
+draw_page();
+send_footer();
+
+function draw_page(){
+ global $config, $school, $sh_email, $sh_email, $sh;
+
+ echo i18n("Please make sure your school contact information is correct, make any necessary changes:");
+ echo "";
+ echo " ";
+}
+
+?>
diff --git a/schoolinvite.php b/schoolinvite.php
index 8009286..a9c0249 100644
--- a/schoolinvite.php
+++ b/schoolinvite.php
@@ -1,269 +1,288 @@
include "common.inc.php";
-if($_SESSION['schoolid'] && $_SESSION['schoolaccesscode'])
-{
+if($_SESSION['schoolid'] && $_SESSION['schoolaccesscode'] && $conference['type'] != 'scienceolympics'){
send_header("School Participant Invitations");
-
- echo "<< ".i18n("Return to school access main page")." ";
- echo " ";
$q=mysql_query("SELECT * FROM schools WHERE id='".$_SESSION['schoolid']."' AND accesscode='".$_SESSION['schoolaccesscode']."' AND year='".$config['FAIRYEAR']."'");
echo mysql_error();
$school=mysql_fetch_object($q);
if($school)
{
- if($config['participant_registration_type']=="invite" || $config['participant_registration_type']=="openorinvite" )
+
+ if($config['participant_registration_type']=="schoolpassword")
{
- if($_POST['action']=="invite")
+ echo "
".i18n("Participant Registration Password")."
";
+
+ echo i18n("In order for your school's students to register for the fair, they will need to know your specific school registration password");
+ echo " ";
+ echo " ";
+ echo i18n("Registration Password: %1",array($school->registration_password));
+ echo " ";
+ echo " ";
+ }
+ else if($config['participant_registration_type']=="invite" || $config['participant_registration_type']=="openorinvite" )
+ {
+
+ echo "
".i18n("Participant Registration Invitations")."
";
+ if($config['participant_registration_type']=="invite")
+ echo i18n("In order for your school's students to register for the fair, you must first invite them via email. Use the 'Participant Registration Invitations' link below to invite your students to the fair");
+ else if($config['participant_registration_type']=="openorinvite" )
+ echo i18n("In order for your school's students to register for the fair, you can invite them via email using the 'Participant Registration Invitations' link below, or they can register on their own by accessing the 'Participant Registration' link in the menu.");
+ echo " ";
+ echo " ";
+ echo " ".i18n("Participant Registration Invitations")."";
+ echo " ";
+
+ echo "<< ".i18n("Return to school access main page")." ";
+ echo " ";
+ if($config['participant_registration_type']=="invite" || $config['participant_registration_type']=="openorinvite" )
{
- if($_POST['firstname'] && $_POST['lastname'] && $_POST['email'] && $_POST['grade'])
+ if($_POST['action']=="invite")
{
- //make sure they arent already invited!
- $q=mysql_query("SELECT firstname, lastname FROM students WHERE year='".$config['FAIRYEAR']."' AND email='".$_POST['email']."'");
- if(mysql_num_rows($q))
+ if($_POST['firstname'] && $_POST['lastname'] && $_POST['email'] && $_POST['grade'])
{
- echo error(i18n("That students email address has already been invited"));
+ //make sure they arent already invited!
+ $q=mysql_query("SELECT firstname, lastname FROM students WHERE year='".$config['FAIRYEAR']."' AND email='".$_POST['email']."'");
+ if(mysql_num_rows($q))
+ {
+ echo error(i18n("That students email address has already been invited"));
+ }
+ else
+ {
+
+ $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,emailcontact,start,status,year) VALUES (".
+ "'$regnum',".
+ "'".$_POST['email']."',".
+ "'".$_POST['emailcontact']."',".
+ "NOW(),".
+ "'open',".
+ $config['FAIRYEAR'].
+ ")");
+ $regid=mysql_insert_id();
+
+ mysql_query("INSERT INTO students (registrations_id,email,firstname,lastname,schools_id,grade,year) VALUES (
+ '$regid',
+ '".mysql_escape_string($_POST['email'])."',
+ '".mysql_escape_string($_POST['firstname'])."',
+ '".mysql_escape_string($_POST['lastname'])."',
+ '".mysql_escape_string($_SESSION['schoolid'])."',
+ '".mysql_escape_string($_POST['grade'])."',
+ '".$config['FAIRYEAR']."')");
+
+ email_send("new_participant",$_POST['email'],array(),array("REGNUM"=>$regnum, "EMAIL"=>$_POST['email']));
+ if($_POST['emailcontact'])
+ email_send("new_participant",$_POST['emailcontact'],array(),array("REGNUM"=>$regnum, "EMAIL"=>$_POST['email']));
+ echo happy(i18n("The participant has been successfully invited"));
+ }
}
else
- {
-
- $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,emailcontact,start,status,year) VALUES (".
- "'$regnum',".
- "'".$_POST['email']."',".
- "'".$_POST['emailcontact']."',".
- "NOW(),".
- "'open',".
- $config['FAIRYEAR'].
- ")");
- $regid=mysql_insert_id();
-
- mysql_query("INSERT INTO students (registrations_id,email,firstname,lastname,schools_id,grade,year) VALUES (
- '$regid',
- '".mysql_escape_string($_POST['email'])."',
- '".mysql_escape_string($_POST['firstname'])."',
- '".mysql_escape_string($_POST['lastname'])."',
- '".mysql_escape_string($_SESSION['schoolid'])."',
- '".mysql_escape_string($_POST['grade'])."',
- '".$config['FAIRYEAR']."')");
-
- email_send("new_participant",$_POST['email'],array(),array("REGNUM"=>$regnum, "EMAIL"=>$_POST['email']));
- if($_POST['emailcontact'])
- email_send("new_participant",$_POST['emailcontact'],array(),array("REGNUM"=>$regnum, "EMAIL"=>$_POST['email']));
- echo happy(i18n("The participant has been successfully invited"));
- }
+ echo error(i18n("All fields are required for invitations"));
}
- else
- echo error(i18n("All fields are required for invitations"));
- }
- if($_GET['action']=="uninvite")
- {
- //first, make sure that this is really their student, and it sfor this year.
- $q=mysql_query("SELECT * FROM students WHERE id='".$_GET['uninvite']."' AND year='".$config['FAIRYEAR']."' AND schools_id='".$_SESSION['schoolid']."'");
- if(mysql_num_rows($q))
+ if($_GET['action']=="uninvite")
{
- $r=mysql_fetch_object($q);
- $registrations_id=$r->registrations_id;
- if($registrations_id) //just to be safe!
+ //first, make sure that this is really their student, and it sfor this year.
+ $q=mysql_query("SELECT * FROM students WHERE id='".$_GET['uninvite']."' AND year='".$config['FAIRYEAR']."' AND schools_id='".$_SESSION['schoolid']."'");
+ if(mysql_num_rows($q))
{
- mysql_query("DELETE FROM students WHERE registrations_id='$registrations_id'");
- mysql_query("DELETE FROM projects WHERE registrations_id='$registrations_id'");
- mysql_query("DELETE FROM mentors WHERE registrations_id='$registrations_id'");
- mysql_query("DELETE FROM safety WHERE registrations_id='$registrations_id'");
- mysql_query("DELETE FROM emergencycontact WHERE registrations_id='$registrations_id'");
- mysql_query("DELETE FROM registrations WHERE id='$registrations_id'");
-
- echo happy(i18n("Student successfully uninvited"));
- }
- }
- else
- echo error(i18n("Invalid student to uninvite"));
- }
-
-
- $q=mysql_query("SELECT (NOW()>'".$config['dates']['regopen']."' AND NOW()<'".$config['dates']['regclose']."') AS datecheck");
- $datecheck=mysql_fetch_object($q);
-
-
- $q=mysql_query("SELECT students.*,
- registrations.num,
- registrations.emailcontact
- FROM
- students,
- registrations
- WHERE
- students.schools_id='".$school->id."'
- AND students.year='".$config['FAIRYEAR']."'
- AND students.registrations_id=registrations.id
- ORDER BY
- lastname,
- firstname");
- $currentinvited=mysql_num_rows($q);
-
- if($datecheck!=0)
- {
- 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. Important: for group projects, only add one of the participants, that participant will then add the other group member(s) to the project");
- echo " ";
- echo " ";
- $okaygrades=array();
- if($config['participant_registration_type']=="invite")
- {
- if($school->projectlimitper=="total")
- {
- if($school->projectlimit)
+ $r=mysql_fetch_object($q);
+ $registrations_id=$r->registrations_id;
+ if($registrations_id) //just to be safe!
{
- echo i18n("You have invited %1 of %2 total projects for your school",array($currentinvited,$school->projectlimit));
- if($currenteinvited<$school->projectlimit)
- {
+ mysql_query("DELETE FROM students WHERE registrations_id='$registrations_id'");
+ mysql_query("DELETE FROM projects WHERE registrations_id='$registrations_id'");
+ mysql_query("DELETE FROM mentors WHERE registrations_id='$registrations_id'");
+ mysql_query("DELETE FROM safety WHERE registrations_id='$registrations_id'");
+ mysql_query("DELETE FROM emergencycontact WHERE registrations_id='$registrations_id'");
+ mysql_query("DELETE FROM registrations WHERE id='$registrations_id'");
+
+ echo happy(i18n("Student successfully uninvited"));
+ }
+ }
+ else
+ echo error(i18n("Invalid student to uninvite"));
+ }
+
+
+ $q=mysql_query("SELECT (NOW()>'".$config['dates']['regopen']."' AND NOW()<'".$config['dates']['regclose']."') AS datecheck");
+ $datecheck=mysql_fetch_object($q);
+
+
+ $q=mysql_query("SELECT students.*,
+ registrations.num,
+ registrations.emailcontact
+ FROM
+ students,
+ registrations
+ WHERE
+ students.schools_id='".$school->id."'
+ AND students.year='".$config['FAIRYEAR']."'
+ AND students.registrations_id=registrations.id
+ ORDER BY
+ lastname,
+ firstname");
+ $currentinvited=mysql_num_rows($q);
+
+ if($datecheck!=0)
+ {
+ 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. Important: for group projects, only add one of the participants, that participant will then add the other group member(s) to the project");
+ echo " ";
+ echo " ";
+ $okaygrades=array();
+ if($config['participant_registration_type']=="invite")
+ {
+ if($school->projectlimitper=="total")
+ {
+ if($school->projectlimit){
+ echo i18n("You have invited %1 of %2 total projects for your school",array($currentinvited,$school->projectlimit));
+ if($currenteinvited<$school->projectlimit){
+ for($a=$config['mingrade'];$a<=$config['maxgrade'];$a++)
+ $okaygrades[]=$a;
+ }
+ }
+ else{
+ echo i18n("You have invited %1 project(s) for your school",array($currentinvited,$school->projectlimit));
for($a=$config['mingrade'];$a<=$config['maxgrade'];$a++)
$okaygrades[]=$a;
+
+ }
+ }
+ else if($school->projectlimitper=="agecategory")
+ {
+ echo " ";
+ $catq=mysql_query("SELECT * FROM projectcategories WHERE year='".$config['FAIRYEAR']."' ORDER BY id");
+ while($catr=mysql_fetch_object($catq)){
+
+ $q2=mysql_query("SELECT COUNT(students.id) AS num
+ FROM
+ students,
+ registrations
+ WHERE
+ students.schools_id='".$school->id."'
+ AND students.grade>='$catr->mingrade'
+ AND students.grade<='$catr->maxgrade'
+ AND students.year='".$config['FAIRYEAR']."'
+ AND students.registrations_id=registrations.id
+ ");
+ echo mysql_error();
+ $r2=mysql_fetch_object($q2);
+ $currentinvited=$r2->num;
+
+ if($currentinvited<$school->projectlimit || $school->projectlimit==0){
+ for($a=$catr->mingrade;$a<=$catr->maxgrade;$a++)
+ $okaygrades[]=$a;
+ }
+
+ echo i18n("You have invited %1 of %2 total projects for for the %3 age category",array($currentinvited,$school->projectlimit,i18n($catr->category)));
+ echo " ";
+
}
}
else
{
- echo i18n("You have invited %1 project(s) for your school",array($currentinvited,$school->projectlimit));
- for($a=$config['mingrade'];$a<=$config['maxgrade'];$a++)
- $okaygrades[]=$a;
-
- }
- }
- else if($school->projectlimitper=="agecategory")
- {
- echo " ";
- $catq=mysql_query("SELECT * FROM projectcategories WHERE year='".$config['FAIRYEAR']."' ORDER BY id");
- while($catr=mysql_fetch_object($catq))
- {
-
- $q2=mysql_query("SELECT COUNT(students.id) AS num
- FROM
- students,
- registrations
- WHERE
- students.schools_id='".$school->id."'
- AND students.grade>='$catr->mingrade'
- AND students.grade<='$catr->maxgrade'
- AND students.year='".$config['FAIRYEAR']."'
- AND students.registrations_id=registrations.id
- ");
- echo mysql_error();
- $r2=mysql_fetch_object($q2);
- $currentinvited=$r2->num;
-
- if($currentinvited<$school->projectlimit || $school->projectlimit==0)
- {
- for($a=$catr->mingrade;$a<=$catr->maxgrade;$a++)
- $okaygrades[]=$a;
- }
-
- echo i18n("You have invited %1 of %2 total projects for for the %3 age category",array($currentinvited,$school->projectlimit,i18n($catr->category)));
- echo " ";
-
+ //hmm projectlimitper has not been set
+ //so we have no limits, anyone can register or they can add as many as they want.
+ for($x=$config['mingrade']; $x<=$config['maxgrade']; $x++)
+ $okaygrades[]=$x;
}
}
else
{
- //hmm projectlimitper has not been set
+ // this could be an else if $config['participant_registration_type']=="openorinvite" )
+ //because openorinvite is the only other option
+
//so we have no limits, anyone can register or they can add as many as they want.
+ //you cannot enforce limits when the system is 'open' because anyone can choose any school
+ //and if its openorinvite then whatever happens in the inviter still morepeople can be added
+ //by themselves, so there's no point in having limits.
for($x=$config['mingrade']; $x<=$config['maxgrade']; $x++)
$okaygrades[]=$x;
+
}
- }
- else
- {
- // this could be an else if $config['participant_registration_type']=="openorinvite" )
- //because openorinvite is the only other option
+ echo " ";
- //so we have no limits, anyone can register or they can add as many as they want.
- //you cannot enforce limits when the system is 'open' because anyone can choose any school
- //and if its openorinvite then whatever happens in the inviter still morepeople can be added
- //by themselves, so there's no point in having limits.
- for($x=$config['mingrade']; $x<=$config['maxgrade']; $x++)
- $okaygrades[]=$x;
+ if(count($okaygrades))
+ {
+ echo "";
+ }
+ else
+ {
+ echo notice(i18n("You have invited the maximum number of participants for your school"));
+
+ }
}
echo " ";
- if(count($okaygrades))
+ echo "