forked from science-ation/science-ation
Added team management for SOIAB. Minor typo correction in conferences.php
This commit is contained in:
parent
bd7e107c0e
commit
f116d9c5fc
7
db/db.update.180.sql
Normal file
7
db/db.update.180.sql
Normal file
@ -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;
|
||||
|
127
manage_teams.php
Normal file
127
manage_teams.php
Normal file
@ -0,0 +1,127 @@
|
||||
<?php
|
||||
require_once('common.inc.php');
|
||||
require_once('user.inc.php');
|
||||
|
||||
if($_SESSION['schoolid'] && $_SESSION['schoolaccesscode']){
|
||||
switch($_GET['action']){
|
||||
case 'saveNew':
|
||||
$teamName = mysql_real_escape_string($_POST['teamname']);
|
||||
$query = 'INSERT INTO so_teams (schools_id, name) VALUES (' . $_SESSION['schoolid'] . ', "' . $teamName . '")';
|
||||
$success = mysql_query($query);
|
||||
draw_page();
|
||||
break;
|
||||
case 'save':
|
||||
$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 = 'UPDATE so_teams SET name="' . $teamName . '" ';
|
||||
$query .= 'WHERE schools_id=' . $_SESSION['schoolid'] . ' ';
|
||||
$query .= 'AND id=' . $teamId;
|
||||
$success = mysql_query($query);
|
||||
}
|
||||
if($success){
|
||||
happy_(i18n("Team successfully updated"));
|
||||
echo("<script type=\"text/javascript\">newname = '$teamName';</script>");
|
||||
}else{
|
||||
error_(i18n("Unable to update record"));
|
||||
echo("<script type=\"text/javascript\">newname = null;</script>");
|
||||
}
|
||||
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("<script type=\"text/javascript\">deleteId = '$teamId';</script>");
|
||||
}else{
|
||||
error_(i18n("Unable to delete record"));
|
||||
echo("<script type=\"text/javascript\">deleteId = null;</script>");
|
||||
}
|
||||
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"));
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
$('#teamaccordion').accordion();
|
||||
$('#teamaccordion').css('visibility', 'visible');
|
||||
});
|
||||
|
||||
function delete_team(teamId){
|
||||
var data = $("#editTeam_" + teamId).serializeArray();
|
||||
$("#debug").load("manage_teams.php?action=delete", data, function(){
|
||||
$('#teamHeader_' + teamId).remove();
|
||||
$('#team_' + teamId).remove();
|
||||
});
|
||||
}
|
||||
|
||||
function saveData(teamId){
|
||||
var data = $("#editTeam_" + teamId).serializeArray();
|
||||
|
||||
$("#debug").load("manage_teams.php?action=save&", data, function(){
|
||||
if(newname != undefined){
|
||||
newname = '<span class="ui-icon ui-icon-triangle-1-e"></span><a href="#" tabindex="-1">' + newname + '</a>';
|
||||
$('#teamHeader_' + teamId).html(newname);
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
<?php
|
||||
echo '<div id="teamaccordion" style="width:40em; visibility:hidden;">';
|
||||
$teamList = mysql_query("SELECT * FROM so_teams WHERE schools_id = " . $_SESSION['schoolid']);
|
||||
while($team = mysql_fetch_array($teamList)){
|
||||
echo '<h3 id="teamHeader_' . $team['id'] . '"><a href="#">' . $team['name'] . "</a></h3>\n";
|
||||
echo '<div id="team_' . $team['id'] . '">' . "\n";
|
||||
echo '<form id="editTeam_' . $team['id'] . '" onsubmit="return false;">';
|
||||
echo i18n('name') . ': <input type="text" name="teamname" value="' . $team['name'] . '"></input>';
|
||||
echo '<div style="height:1em;"></div>';
|
||||
echo "<button onclick=\"saveData('" . $team['id'] . "');\">" . i18n('Save') . '</button>';
|
||||
echo "<button onclick=\"delete_team('" . $team['id'] . "');\">" . i18n('Delete') . '</button>';
|
||||
echo "<input type=\"hidden\" name=\"teamId\" value=\"" . $team['id'] . "\"></input>";
|
||||
echo '</form>';
|
||||
echo "</div>";
|
||||
}
|
||||
echo '<h3><a href="#">' . i18n("New Team") . '</a></h3>';
|
||||
echo '<div id="newTeam">';
|
||||
echo '<form method="POST" action="manage_teams.php?action=saveNew">';
|
||||
echo '<label>' . i18n('Name') . '</label><input type="text" style="width:100%" name="teamname"></input>' . "\n";
|
||||
echo '<div style="height:1em;"></div>';
|
||||
echo '<input type="submit" value="' . i18n("Save") . '"></input>';
|
||||
echo '</form>';
|
||||
echo "</div>\n";
|
||||
echo '</div>';
|
||||
send_footer();
|
||||
}
|
||||
|
||||
?>
|
213
schoolaccess.php
213
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 "<h3>$school->school</h3>";
|
||||
echo "<h4>".i18n("School Information")."</h4>";
|
||||
echo i18n("Please make sure your school contact information is correct, make any necessary changes:");
|
||||
echo "<form method=POST action=\"schoolaccess.php\">";
|
||||
echo "<input type=hidden name=action value=\"save\">";
|
||||
echo "<table border=0 cellspacing=0 cellpadding=3>";
|
||||
echo "<tr><td>".i18n("School Name")."</td><td><input value=\"$school->school\" type=text name=school size=40></td></tr>";
|
||||
// echo "<tr><td>Registration Password</td><td><input value=\"$school->registration_password\" type=text name=\"registration_password\" size=\"20\"></td></tr>";
|
||||
echo "<tr><td>".i18n("Address")."</td><td><input value=\"$school->address\" type=text name=address size=40></td></tr>";
|
||||
echo "<tr><td>".i18n("City")."</td><td><input value=\"$school->city\" type=text name=city size=30></td></tr>";
|
||||
echo "<tr><td>".i18n($config['provincestate'])."</td><td>";
|
||||
emit_province_selector("province_code",$school->province_code);
|
||||
echo "</td></tr>\n";
|
||||
echo "<tr><td>".i18n($config['postalzip'])."</td><td><input value=\"$school->postalcode\" type=text name=postalcode size=10></td></tr>";
|
||||
echo "<tr><td>".i18n("Phone Number")."</td><td><input value=\"$school->phone\" type=text name=phone size=30></td></tr>";
|
||||
echo "<tr><td>".i18n("Fax Number")."</td><td><input value=\"$school->fax\" type=text name=fax size=30></td></tr>";
|
||||
|
||||
echo "<tr><td>".i18n("Science Teacher")."</td><td><input value=\"{$sh['name']}\" type=text name=sciencehead size=40></td></tr>";
|
||||
echo "<tr><td>".i18n("Science Teacher Email")."</td><td><input value=\"$sh_email\" type=text name=scienceheademail size=40></td></tr>";
|
||||
echo "<tr><td>".i18n("Science Teacher Phone")."<br><font size=1>(".i18n("If different than above").")</font></td><td><input value=\"{$sh['phonework']}\" type=text name=scienceheadphone size=30></td></tr>";
|
||||
echo "</table>";
|
||||
echo "<input type=submit value=\"".i18n("Save Changes")."\">";
|
||||
echo "</form>";
|
||||
echo "<br>";
|
||||
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 "<h4>".i18n("Participant Registration Password")."</h4>";
|
||||
|
||||
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 "<br />";
|
||||
echo "<br />";
|
||||
echo i18n("Registration Password: <b>%1</b>",array($school->registration_password));
|
||||
echo "<br />";
|
||||
echo "<br />";
|
||||
break;
|
||||
}
|
||||
else if($config['participant_registration_type']=="invite" || $config['participant_registration_type']=="openorinvite" )
|
||||
{
|
||||
|
||||
echo "<h4>".i18n("Participant Registration Invitations")."</h4>";
|
||||
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 "<br />";
|
||||
echo "<br />";
|
||||
echo " <a href=\"schoolinvite.php\">".i18n("Participant Registration Invitations")."</a>";
|
||||
echo "<br />";
|
||||
}
|
||||
|
||||
echo "<br>";
|
||||
echo "<h4>".i18n("School Feedback / Questions")."</h4>";
|
||||
|
||||
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 "<form method=POST action=\"schoolaccess.php\">";
|
||||
echo "<input type=hidden name=action value=\"feedback\">";
|
||||
echo "<br><textarea name=feedbacktext rows=8 cols=60></textarea><br>";
|
||||
echo "<input type=submit value=\"Send Feedback\">";
|
||||
echo "</form>";
|
||||
}
|
||||
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 "<ul>\n";
|
||||
echo '<li><a href="' . $_SERVER['PHP_SELF'] . '?action=schoolinfo">' . i18n("School Information") . "</a></li>\n";
|
||||
if($conference['id'] == 0){
|
||||
if($config['participant_registration_type']=="schoolpassword"
|
||||
|| $config['participant_registration_type']=="invite"
|
||||
|| $config['participant_registration_type']=="openorinvite"
|
||||
){
|
||||
echo '<li><a href="' . $_SERVER['PHP_SELF'] . '?action=participantreg">' . i18n("Participant Registration") . "</a></li>\n";
|
||||
}
|
||||
}else{
|
||||
echo '<li><a href="manage_teams.php">' . i18n("Manage Teams") . "</a></li>\n";
|
||||
}
|
||||
echo '<li><a href="' . $_SERVER['PHP_SELF'] . '?action=givefeedback">' . i18n("School Feedback / Questions") . "</a></li>";
|
||||
echo "</ul>\n";
|
||||
}
|
||||
|
||||
function draw_login(){
|
||||
send_header("School Access");
|
||||
global $errormsg, $happymsg, $config;
|
||||
if($errormsg) echo "<font color=red><b>$errormsg</b></font>";
|
||||
if($happymsg) echo happy($happymsg);
|
||||
|
||||
@ -245,7 +224,85 @@ else {
|
||||
<?
|
||||
}
|
||||
|
||||
function draw_feedback(){
|
||||
global $sh_email;
|
||||
|
||||
send_footer();
|
||||
$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 "<form method=POST action=\"schoolaccess.php\">";
|
||||
echo "<input type=hidden name=action value=\"feedback\">";
|
||||
echo "<br><textarea name=feedbacktext rows=8 cols=60></textarea><br>";
|
||||
echo "<input type=submit value=\"Send Feedback\">";
|
||||
echo "</form>";
|
||||
}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 "<h3>$school->school</h3>";
|
||||
|
||||
echo i18n("Please make sure your school contact information is correct, make any necessary changes:");
|
||||
echo "<form method=POST action=\"schoolaccess.php\">";
|
||||
echo "<input type=hidden name=action value=\"save\">";
|
||||
echo "<table border=0 cellspacing=0 cellpadding=3>";
|
||||
echo "<tr><td>".i18n("School Name")."</td><td><input value=\"$school->school\" type=text name=school size=40></td></tr>";
|
||||
// echo "<tr><td>Registration Password</td><td><input value=\"$school->registration_password\" type=text name=\"registration_password\" size=\"20\"></td></tr>";
|
||||
echo "<tr><td>".i18n("Address")."</td><td><input value=\"$school->address\" type=text name=address size=40></td></tr>";
|
||||
echo "<tr><td>".i18n("City")."</td><td><input value=\"$school->city\" type=text name=city size=30></td></tr>";
|
||||
echo "<tr><td>".i18n($config['provincestate'])."</td><td>";
|
||||
emit_province_selector("province_code",$school->province_code);
|
||||
echo "</td></tr>\n";
|
||||
echo "<tr><td>".i18n($config['postalzip'])."</td><td><input value=\"$school->postalcode\" type=text name=postalcode size=10></td></tr>";
|
||||
echo "<tr><td>".i18n("Phone Number")."</td><td><input value=\"$school->phone\" type=text name=phone size=30></td></tr>";
|
||||
echo "<tr><td>".i18n("Fax Number")."</td><td><input value=\"$school->fax\" type=text name=fax size=30></td></tr>";
|
||||
|
||||
echo "<tr><td>".i18n("Science Teacher")."</td><td><input value=\"{$sh['name']}\" type=text name=sciencehead size=40></td></tr>";
|
||||
echo "<tr><td>".i18n("Science Teacher Email")."</td><td><input value=\"$sh_email\" type=text name=scienceheademail size=40></td></tr>";
|
||||
echo "<tr><td>".i18n("Science Teacher Phone")."<br><font size=1>(".i18n("If different than above").")</font></td><td><input value=\"{$sh['phonework']}\" type=text name=scienceheadphone size=30></td></tr>";
|
||||
echo "</table>";
|
||||
echo "<input type=submit value=\"".i18n("Save Changes")."\">";
|
||||
echo "</form>";
|
||||
echo "<br>";
|
||||
}
|
||||
|
||||
function draw_participantReg(){
|
||||
global $school, $config;
|
||||
|
||||
$title = i18n("Participant Registration");
|
||||
send_header($title, array("School Access" => _THISFILE));
|
||||
|
||||
if($config['participant_registration_type']=="schoolpassword")
|
||||
{
|
||||
echo "<h4>".i18n("Participant Registration Password")."</h4>";
|
||||
|
||||
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 "<br />";
|
||||
echo "<br />";
|
||||
echo i18n("Registration Password: <b>%1</b>",array($school->registration_password));
|
||||
echo "<br />";
|
||||
echo "<br />";
|
||||
}
|
||||
else if($config['participant_registration_type']=="invite" || $config['participant_registration_type']=="openorinvite" )
|
||||
{
|
||||
|
||||
echo "<h4>".i18n("Participant Registration Invitations")."</h4>";
|
||||
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 "<br />";
|
||||
echo "<br />";
|
||||
echo " <a href=\"schoolinvite.php\">".i18n("Participant Registration Invitations")."</a>";
|
||||
echo "<br />";
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
@ -34,7 +34,7 @@
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
};
|
||||
});
|
||||
</script>
|
||||
|
||||
<div id="conferences">
|
||||
|
Loading…
Reference in New Issue
Block a user