diff --git a/db/db.update.180.sql b/db/db.update.180.sql new file mode 100644 index 0000000..1e1d78c --- /dev/null +++ b/db/db.update.180.sql @@ -0,0 +1,7 @@ + +CREATE TABLE `so_teams` ( +`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY , +`schools_id` INT NOT NULL , +`name` VARCHAR( 64 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL +) ENGINE = MYISAM CHARACTER SET utf8 COLLATE utf8_general_ci; + diff --git a/manage_teams.php b/manage_teams.php new file mode 100644 index 0000000..f44961f --- /dev/null +++ b/manage_teams.php @@ -0,0 +1,127 @@ +newname = '$teamName';"); + }else{ + error_(i18n("Unable to update record")); + echo(""); + } + break; + case 'delete': + $success = false; + $teamId = mysql_real_escape_string($_POST['teamId']); + $teamName = mysql_real_escape_string($_POST['teamname']); + // a quick check to make sure the team being updated does indeed belong + // to this school + $query = 'SELECT COUNT(*) AS tally FROM so_teams WHERE schools_id=' . $_SESSION['schoolid'] . ' AND id=' . $teamId; + $testResults = mysql_fetch_array(mysql_query($query)); + if($testResults['tally'] == 1){ + // ok, the team belongs to the school that this session belongs to. We can + // can go ahead and save the changes. + $query = 'DELETE FROM so_teams '; + $query .= 'WHERE schools_id=' . $_SESSION['schoolid'] . ' '; + $query .= 'AND id=' . $teamId; + if(mysql_query($query)){ + $success = true; + } + } + if($success){ + happy_(i18n("Team successfully deleted")); + echo(""); + }else{ + error_(i18n("Unable to delete record")); + echo(""); + } + break; + + default: + draw_page(); + } +}else{ + echo "this should be redirecting to shcoolaccess.php"; +} + +function draw_page(){ + $title = i18n("Manage Teams"); + send_header($title, array("School Access" => "schoolaccess.php")); +?> + +'; + $teamList = mysql_query("SELECT * FROM so_teams WHERE schools_id = " . $_SESSION['schoolid']); + while($team = mysql_fetch_array($teamList)){ + echo '

' . $team['name'] . "

\n"; + echo '
' . "\n"; + echo '
'; + echo i18n('name') . ': '; + echo '
'; + echo "'; + echo "'; + echo ""; + echo '
'; + echo "
"; + } + echo '

' . i18n("New Team") . '

'; + echo '
'; + echo '
'; + echo '' . "\n"; + echo '
'; + echo ''; + echo '
'; + echo "
\n"; + echo ''; + send_footer(); +} + +?> diff --git a/schoolaccess.php b/schoolaccess.php index f22c92a..9af4859 100644 --- a/schoolaccess.php +++ b/schoolaccess.php @@ -2,6 +2,10 @@ require_once('common.inc.php'); require_once('user.inc.php'); +$parts = explode('/', $_SERVER['PHP_SELF']); +define("_THISFILE", $parts[count($parts) - 1]); + + if($_POST['schoolid'] && $_POST['accesscode']) { $q=mysql_query("SELECT * FROM schools WHERE id='".$_POST['schoolid']."' AND accesscode='".$_POST['accesscode']."' AND year='".$config['FAIRYEAR']."'"); @@ -22,8 +26,6 @@ if($_GET['action']=="logout") unset($_SESSION['schoolaccesscode']); $happymsg=i18n("You have been logged out from the school access page"); } -send_header("School Access"); - if($_SESSION['schoolid'] && $_SESSION['schoolaccesscode']) @@ -33,7 +35,6 @@ if($_SESSION['schoolid'] && $_SESSION['schoolaccesscode']) $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); @@ -77,15 +78,15 @@ if($_SESSION['schoolid'] && $_SESSION['schoolaccesscode']) 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")); + 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); + //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); } /* @@ -111,8 +112,7 @@ if($_SESSION['schoolid'] && $_SESSION['schoolaccesscode']) $sh = array(); $sh_email = ($sh['email'] != '' && $sh['email'][0] != '*') ? $sh['email'] : ''; - if($_POST['action']=="feedback") - { + if($_POST['action'] == "feedback"){ $body=""; $body.=date("r")."\n"; $body.=$_SERVER['REMOTE_ADDR']." (".$_SERVER['REMOTE_HOST'].")\n"; @@ -127,75 +127,54 @@ if($_SESSION['schoolid'] && $_SESSION['schoolaccesscode']) echo happy(i18n("Your feedback has been sent")); } - echo "

$school->school

"; - echo "

".i18n("School Information")."

"; - 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 "
"; + switch($_GET['action']){ + case "givefeedback": + draw_feedback(); + break; + case "schoolinfo": + draw_schoolInfo(); + break; + case "participantreg": + draw_participantReg(); + break; + default: + draw_dashboard(); - 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 "
"; + break; } - 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 "
"; - echo "

".i18n("School Feedback / Questions")."

"; - - 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")); - } - else { + }else{ echo error(i18n("Invalid School ID or Access Code")); } } else { + draw_login(); +} +send_footer(); + +// FIXME - this needs to be beautified +function draw_dashboard(){ + send_header("School Access"); + global $config; + global $conference; + echo "\n"; +} + +function draw_login(){ + send_header("School Access"); + global $errormsg, $happymsg, $config; if($errormsg) echo "$errormsg"; if($happymsg) echo happy($happymsg); @@ -245,7 +224,85 @@ else { _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/super/conferences.php b/super/conferences.php index 3802362..4a0f5c9 100644 --- a/super/conferences.php +++ b/super/conferences.php @@ -34,7 +34,7 @@ ?>