Added function for saving submitted settings when science fair/olympic inclusion is chosen

This commit is contained in:
jacob 2010-06-11 14:48:29 +00:00
parent 7d38b43cfc
commit 44fd9bea1f

View File

@ -146,13 +146,26 @@
else
$notice = 'saved';
}
else if($_POST['action'] == "participation")
else if($_POST['action'] == "save_participation")
{
// WRITE ME!
// this needs to list through a list of _POST elements that will have the indicies
// "[school id]_fairs" and "[school id]"_olympics, with true/false values for each.
// they should be written to the "schools" table.
// update the schools' participation in fairs an olympics to reflect the settings submitted
$olympicSet = array();
$fairSet = array();
foreach($_POST as $idx => $value){
if(preg_match('/_olympics$/', $idx)){
$parts = explode('_', $idx);
$olympicSet[] = $parts[0];
}else if(preg_match('/_fairs$/', $idx)){
$parts = explode('_', $idx);
$fairSet[] = $parts[0];
}
}
$fairString = '(' . implode(',', $fairSet) . ')';
$olympicString = '(' . implode(',', $olympicSet) . ')';
mysql_query("UPDATE schools SET include_fairs = TRUE WHERE id IN $fairString");
mysql_query("UPDATE schools SET include_fairs = FALSE WHERE id NOT IN $fairString");
mysql_query("UPDATE schools SET include_olympics = TRUE WHERE id IN $olympicString");
mysql_query("UPDATE schools SET include_olympics = FALSE WHERE id NOT IN $olympicString");
}
if($_GET['action']=="delete" && $_GET['delete'])
@ -334,7 +347,7 @@
echo "> " . i18n("olympics") . "</label>";
echo "</td></tr>";
}
echo "<tr><td colspan=\"2\" align=\"center\"><input type=\"submit\" /></td></tr>\n";
echo "<tr><td colspan=\"2\" align=\"center\"><input type=\"submit\" value=\"" . i18n('Save') . "\" /></td></tr>\n";
echo "</table>\n";
echo '<input type="hidden" name="action" value="save_participation"></input>' . "\n";
echo "</form>\n";
@ -375,12 +388,12 @@
echo "<br />";
echo "<a onclick=\"return confirmClick('".i18n("Are you sure you want to remove all access codes from all schools?")."')\" href=\"schools.php?action=clearaccesscodes\">".i18n("Remove Access Codes from all schools")."</a>\n";
echo "<br />";
// we only need to see this option if we are managing both types of conferences
$q = mysql_fetch_array(mysql_query('SELECT COUNT(DISTINCT(`type`)) as taly FROM conferences'));
// if($q['tally'] > 1){
if($q['tally'] > 1){
echo "<a href=\"schools.php?action=participation\">".i18n("Set SFIAB/SOIAB participation")."</a>\n";
echo "<br />";
// }
}
echo "<table class=\"tableview\">";
echo "<thead><tr>";
echo " <th>".i18n("School")."</th>";