From 44fd9bea1f48c20d1809b3d7fa919905d72dccbc Mon Sep 17 00:00:00 2001 From: jacob Date: Fri, 11 Jun 2010 14:48:29 +0000 Subject: [PATCH] Added function for saving submitted settings when science fair/olympic inclusion is chosen --- admin/schools.php | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/admin/schools.php b/admin/schools.php index fe24dc5..c4851fc 100644 --- a/admin/schools.php +++ b/admin/schools.php @@ -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") . ""; echo ""; } - echo "\n"; + echo "\n"; echo "\n"; echo '' . "\n"; echo "\n"; @@ -375,12 +388,12 @@ echo "
"; echo "".i18n("Remove Access Codes from all schools")."\n"; echo "
"; + // 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 "".i18n("Set SFIAB/SOIAB participation")."\n"; echo "
"; -// } - + } echo ""; echo ""; echo " ";
".i18n("School")."