From 5dc408da3371f3107ce7c236a37936189133c2fc Mon Sep 17 00:00:00 2001 From: james Date: Fri, 11 Feb 2005 16:08:16 +0000 Subject: [PATCH] add judges languages, make sure at least one language is selected --- register_judges.inc.php | 7 +++++++ register_judges_personal.php | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/register_judges.inc.php b/register_judges.inc.php index 5bbdcd3..0de6abf 100644 --- a/register_judges.inc.php +++ b/register_judges.inc.php @@ -40,6 +40,13 @@ function personalStatus() } } + //and they also have to select at least one language to judge in + $q=mysql_query("SELECT COUNT(judges_id) AS num FROM judges_languages WHERE judges_id='".$_SESSION['judges_id']."'"); + $r=mysql_fetch_object($q); + if($r->num==0) + return "incomplete"; + + //if it made it through without returning incomplete, then we must be complete return "complete"; } diff --git a/register_judges_personal.php b/register_judges_personal.php index e503ba8..54fd4ff 100644 --- a/register_judges_personal.php +++ b/register_judges_personal.php @@ -79,6 +79,18 @@ "attending_lunch='".mysql_escape_string(stripslashes($_POST['attending_lunch']))."' ". "WHERE id='".$_SESSION['judges_id']."'"); echo mysql_error(); + + //first we clear out their old languages + mysql_query("DELETE FROM judges_languages WHERE judges_id='".$_SESSION['judges_id']."'"); + if(count($_POST['languages'])) + { + //and now we add back any selected languages + foreach($_POST['languages'] AS $l) + { + mysql_query("INSERT INTO judges_languages (judges_id,languages_lang) VALUES ('".$_SESSION['judges_id']."','$l')"); + } + + } echo notice(i18n("%1 %2 successfully updated",array($_POST['firstname'],$_POST['lastname']))); } $q=mysql_query("SELECT * FROM judges WHERE email='".$_SESSION['email']."' AND id='".$_SESSION['judges_id']."'"); @@ -168,6 +180,29 @@ echo " ".i18n("Highest post-secondary degree").""; echo " highest_psd\" />\n"; echo "\n"; +echo "\n"; +echo " ".i18n("I can judge in the following languages").""; +echo " "; + +//grab the current languages that are selected +$currentlanguages=array(); +$q=mysql_query("SELECT languages_lang FROM judges_languages WHERE judges_id='".$_SESSION['judges_id']."'"); +while($r=mysql_fetch_object($q)) +{ + $currentlanguages[]=$r->languages_lang; +} + +$q=mysql_query("SELECT * FROM languages WHERE active='Y' ORDER BY langname"); +while($r=mysql_fetch_object($q)) +{ + if(in_array($r->lang,$currentlanguages)) $ch="checked=\"checked\""; else $ch=""; + + echo "lang\" /> $r->langname
"; +} + +echo " \n"; +echo "\n"; + echo "\n"; echo " ".i18n("Years of judging experience at school/local level")."\n"; echo " years_school\" size=\"3\" />\n";