diff --git a/manage_teams.php b/manage_teams.php index f44961f..37fbae6 100644 --- a/manage_teams.php +++ b/manage_teams.php @@ -2,7 +2,7 @@ require_once('common.inc.php'); require_once('user.inc.php'); -if($_SESSION['schoolid'] && $_SESSION['schoolaccesscode']){ +if($_SESSION['schoolid'] && $_SESSION['schoolaccesscode'] && $conference['type'] == 'scienceolympics'){ switch($_GET['action']){ case 'saveNew': $teamName = mysql_real_escape_string($_POST['teamname']); @@ -27,10 +27,10 @@ if($_SESSION['schoolid'] && $_SESSION['schoolaccesscode']){ $success = mysql_query($query); } if($success){ - happy_(i18n("Team successfully updated")); + happy_("Team successfully updated"); echo(""); }else{ - error_(i18n("Unable to update record")); + error_("Unable to update record"); echo(""); } break; @@ -53,10 +53,10 @@ if($_SESSION['schoolid'] && $_SESSION['schoolaccesscode']){ } } if($success){ - happy_(i18n("Team successfully deleted")); + happy_("Team successfully deleted"); echo(""); }else{ - error_(i18n("Unable to delete record")); + error_("Unable to delete record"); echo(""); } break; @@ -65,7 +65,7 @@ if($_SESSION['schoolid'] && $_SESSION['schoolaccesscode']){ draw_page(); } }else{ - echo "this should be redirecting to shcoolaccess.php"; + header('Location: schoolaccess.php'); } function draw_page(){ diff --git a/schoolaccess.php b/schoolaccess.php index 9af4859..7d5e434 100644 --- a/schoolaccess.php +++ b/schoolaccess.php @@ -2,10 +2,7 @@ require_once('common.inc.php'); require_once('user.inc.php'); -$parts = explode('/', $_SERVER['PHP_SELF']); -define("_THISFILE", $parts[count($parts) - 1]); - - +// authenticate the login if($_POST['schoolid'] && $_POST['accesscode']) { $q=mysql_query("SELECT * FROM schools WHERE id='".$_POST['schoolid']."' AND accesscode='".$_POST['accesscode']."' AND year='".$config['FAIRYEAR']."'"); @@ -20,6 +17,7 @@ if($_POST['schoolid'] && $_POST['accesscode']) $errormsg="Invalid School ID or Access Code"; } +// handle a logout request if($_GET['action']=="logout") { unset($_SESSION['schoolid']); @@ -28,147 +26,40 @@ if($_GET['action']=="logout") } -if($_SESSION['schoolid'] && $_SESSION['schoolaccesscode']) -{ +if($_SESSION['schoolid'] && $_SESSION['schoolaccesscode']){ + // we're logged in, draw the dashboard $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($_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(); - /* Load existing record, or create new if there's something - * to insert */ - 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")); - - //and reselect it - $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($_POST['action']=="numbers") - { - mysql_query("UPDATE schools SET - junior='".$_POST['junior']."', - intermediate='".$_POST['intermediate']."', - senior='".$_POST['senior']."' - WHERE id='$school->id'"); - - echo mysql_error(); - - $q=mysql_query("SELECT * FROM schools WHERE id='".$_SESSION['schoolid']."' AND accesscode='".$_SESSION['schoolaccesscode']."'"); - echo "Participation Information Successfully Updated
\n"; - $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'] == "feedback"){ - $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(i18n("Your feedback has been sent")); - } - - switch($_GET['action']){ - case "givefeedback": - draw_feedback(); - break; - case "schoolinfo": - draw_schoolInfo(); - break; - case "participantreg": - draw_participantReg(); - break; - default: - draw_dashboard(); - - break; - } + draw_dashboard(); }else{ echo error(i18n("Invalid School ID or Access Code")); } -} -else { +}else { draw_login(); } send_footer(); + // FIXME - this needs to be beautified function draw_dashboard(){ send_header("School Access"); global $config; global $conference; echo "\n"; } @@ -223,86 +114,3 @@ function draw_login(){ _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 "
"; - echo ""; - echo "

"; - echo ""; - 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 ""; - echo ""; - echo ""; -// echo ""; - echo ""; - echo ""; - echo "\n"; - echo ""; - echo ""; - echo ""; - - echo ""; - echo ""; - echo ""; - echo "
".i18n("School Name")."school\" type=text name=school size=40>
Registration Passwordregistration_password\" type=text name=\"registration_password\" size=\"20\">
".i18n("Address")."address\" type=text name=address size=40>
".i18n("City")."city\" type=text name=city size=30>
".i18n($config['provincestate']).""; - emit_province_selector("province_code",$school->province_code); - echo "
".i18n($config['postalzip'])."postalcode\" type=text name=postalcode size=10>
".i18n("Phone Number")."phone\" type=text name=phone size=30>
".i18n("Fax Number")."fax\" type=text name=fax size=30>
".i18n("Science Teacher")."
".i18n("Science Teacher Email")."
".i18n("Science Teacher Phone")."
(".i18n("If different than above").")
"; - echo ""; - 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 "
"; + echo "

"; + echo ""; + 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 ""; + echo ""; + echo ""; +// echo ""; + echo ""; + echo ""; + echo "\n"; + echo ""; + echo ""; + echo ""; + + echo ""; + echo ""; + echo ""; + echo "
".i18n("School Name")."school\" type=text name=school size=40>
Registration Passwordregistration_password\" type=text name=\"registration_password\" size=\"20\">
".i18n("Address")."address\" type=text name=address size=40>
".i18n("City")."city\" type=text name=city size=30>
".i18n($config['provincestate']).""; + emit_province_selector("province_code",$school->province_code); + echo "
".i18n($config['postalzip'])."postalcode\" type=text name=postalcode size=10>
".i18n("Phone Number")."phone\" type=text name=phone size=30>
".i18n("Fax Number")."fax\" type=text name=fax size=30>
".i18n("Science Teacher")."
".i18n("Science Teacher Email")."
".i18n("Science Teacher Phone")."
(".i18n("If different than above").")
"; + echo ""; + echo "
"; + echo "
"; +} + +?> diff --git a/schoolinvite.php b/schoolinvite.php index 8009286..a9c0249 100644 --- a/schoolinvite.php +++ b/schoolinvite.php @@ -1,269 +1,288 @@ << ".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 "
"; + echo ""; + + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + + 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 "
"; + echo ""; + echo "
"; + } + else + { + echo notice(i18n("You have invited the maximum number of participants for your school")); + + } } echo "
"; - if(count($okaygrades)) + echo "

".i18n("Invited participants from your school")."

"; + if(mysql_num_rows($q)) { - - echo "
"; - echo ""; - - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - 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 ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + while($r=mysql_fetch_object($q)) { - echo "\n"; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + } - - echo ""; - echo "
".i18n("Last Name")."".i18n("First Name")."".i18n("Email Address")."".i18n("Grade")."".i18n("Registration Number")."".i18n("Actions")."
$r->lastname$r->firstname$r->email"; + if($r->emailcontact) + echo " / $r->emailcontact"; + echo "$r->grade$r->num"; + echo ""; + echo ""; + echo "email\">"; + echo "num\">"; + echo ""; + echo ""; + echo ""; + echo "id\">"; + echo "
"; - echo ""; - echo ""; } else - { - echo notice(i18n("You have invited the maximum number of participants for your school")); - - } - } - echo "
"; - - echo "

".i18n("Invited participants from your school")."

"; - if(mysql_num_rows($q)) - { - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - while($r=mysql_fetch_object($q)) - { - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; + echo i18n("You have not yet invited any participants from your school"); } - echo "
".i18n("Last Name")."".i18n("First Name")."".i18n("Email Address")."".i18n("Grade")."".i18n("Registration Number")."".i18n("Actions")."
$r->lastname$r->firstname$r->email"; - if($r->emailcontact) - echo " / $r->emailcontact"; - echo "$r->grade$r->num"; - echo "
"; - echo ""; - echo "email\">"; - echo "num\">"; - echo ""; - echo "
"; - echo "
"; - echo "id\">"; - echo "
"; - } - else - echo i18n("You have not yet invited any participants from your school"); } }