diff --git a/judge.inc.php b/judge.inc.php
index 0823e55..d1602d3 100644
--- a/judge.inc.php
+++ b/judge.inc.php
@@ -64,26 +64,23 @@ function judge_status_expertise($u)
$q=mysql_query("SELECT COUNT(id) AS num FROM projectcategories WHERE year='".$config['FAIRYEAR']."'");
$r=mysql_fetch_object($q);
$numcats=$r->num;
-
- if($numcats != count($u['catprefs'])) {
- return "incomplete";
- }
+ if($numcats != count($u['cat_prefs'])) return 'incomplete';
$q=mysql_query("SELECT COUNT(id) AS num FROM projectdivisions WHERE year='".$config['FAIRYEAR']."'");
$r=mysql_fetch_object($q);
$numdivisions=$r->num;
+ if($numdivisions != count($u['div_prefs'])) return 'incomplete';
- if($numdivisions != count($u['divprefs'])) {
- return "incomplete";
- }
-
- return "complete";
+ return 'complete';
}
function judge_status_other($u)
{
global $config;
+ /* They must select a language to judge in */
+ if(count($u['languages']) < 1) return 'incomplete';
+
return 'complete';
}
diff --git a/judge_expertise.php b/judge_expertise.php
index d33d4dc..9336de4 100644
--- a/judge_expertise.php
+++ b/judge_expertise.php
@@ -29,7 +29,7 @@
$u = user_load($_SESSION['users_id'], true);
//send the header
- $type = $_SESSION['users_type'];
+// $type = $_SESSION['users_type'];
send_header('Category and Division Preferences',
array('Judge Registration' => 'judge_main.php')
);
diff --git a/judge_other.php b/judge_other.php
index 0d94775..9f5a3f2 100644
--- a/judge_other.php
+++ b/judge_other.php
@@ -30,39 +30,26 @@
$u = user_load($_SESSION['users_id'], true);
//send the header
- $type = $_SESSION['users_type'];
send_header('Other Information',
array('Judge Registration' => 'judge_main.php')
);
if($_POST['action']=="save")
{
- if(!is_array($_POST['division']))
- $_POST['division']=array();
- if(!is_array($_POST['subdivision']))
- $_POST['subdivision']=array();
+
+ if(!is_array($_POST['languages'])) $_POST['languages']=array();
- $u['divprefs'] = array();
- foreach($_POST['division'] AS $key=>$val)
- $u['divprefs'][$key] = $val;
+ $u['languages'] = array();
+ foreach($_POST['languages'] AS $val)
+ $u['languages'][] = $val;
- $u['divprefs_sub'] = array();
- foreach($_POST['subdivision'] AS $key=>$val)
- $u['divprefs_sub'][$key] = $val;
+ $u['special_award_only'] = ($_POST['special_award_only'] == 'yes') ? 'yes' : 'no';
+ $u['willing_chair'] = ($_POST['willing_chair'] == 'yes') ? 'yes' : 'no';
+ $u['years_school'] = intval($_POST['years_school']);
+ $u['years_regional'] = intval($_POST['years_regional']);
+ $u['years_national'] = intval($_POST['years_national']);
+ $u['highest_psd'] = stripslashes($_POST['highest_psd']);
- if($_POST['other_other'])
- $u['other_other'] = stripslashes($_POST['other_other']);
- else
- $u['other_other'] = NULL;
-
- $u['catprefs'] = array();
- if(is_array($_POST['catpref'])) {
- foreach($_POST['catpref'] AS $k=>$v) {
- if($v == '') continue;
-
- $u['catprefs'][$k] = $v;
- }
- }
user_save($u);
message_push(notice(i18n("Preferences successfully saved")));
$u = user_load($_SESSION['users_id'], true);
@@ -86,18 +73,11 @@ echo "
\n";
echo " ".i18n("I can judge in the following languages")." ".REQUIREDFIELD." ";
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");
+echo mysql_error();
while($r=mysql_fetch_object($q))
{
- if(in_array($r->lang,$currentlanguages)) $ch="checked=\"checked\""; else $ch="";
+ $ch = (in_array($r->lang,$u['languages'])) ? 'checked="checked"' : '';
echo " lang\" /> $r->langname ";
}
@@ -110,9 +90,8 @@ if($config['judges_specialaward_only_enable'] == 'yes') {
echo " ";
echo "\n";
echo " ".i18n("I am a judge for a specific special award")."(".i18n("Check this box if you are supposed to judge a specific special award, and please select that award on the Special Award Preferences page.").") ";
- if($judgeinfo->typepref == "speconly") $ch = "checked=checked";
- else $ch="";
- echo " ";
+ $ch = ($u['special_award_only'] == 'yes') ? 'checked="checked"' : '';
+ echo " ";
echo " ";
echo " \n";
}
@@ -131,26 +110,20 @@ echo "\n";
echo " ".i18n("Years of judging experience at a National level:")." ";
echo " \n";
echo " \n";
-
echo "\n";
-echo " ".i18n("Other professional qualifications")." ";
-echo " professional_quals\" /> \n";
+echo " ".i18n("I am willing to be the lead for my judging team")." ";
+$ch = ($u['willing_chair'] == 'yes') ? 'checked="checked"' : '';
+echo " ";
echo " \n";
-
-
-questions_print_answer_editor('judgereg',
- $_SESSION['judges_id'], $config['FAIRYEAR'], 'questions');
-
echo "\n";
echo " ".i18n("Highest post-secondary degree")." ";
-echo " highest_psd\" /> \n";
+echo " \n";
echo " \n";
-echo "\n";
-echo " ".i18n("Other professional qualifications")." ";
-echo " professional_quals\" /> \n";
-echo " \n";
+echo " ";
+
+questions_print_answer_editor('judgereg', $u, 'questions');
echo "";
diff --git a/questions.inc.php b/questions.inc.php
index be0743f..8508976 100644
--- a/questions.inc.php
+++ b/questions.inc.php
@@ -24,13 +24,12 @@
-function questions_load_answers($section, $id, $year)
+function questions_load_answers($section, $users_id)
{
$q = mysql_query('SELECT question_answers.*, questions.* '.
'FROM question_answers '.
'LEFT JOIN questions ON questions.id=question_answers.questions_id '.
- "WHERE question_answers.year='$year' ".
- " AND registrations_id='$id' ".
+ "WHERE users_id='$users_id' ".
" AND questions.section='$section' ".
'ORDER BY questions.ord ASC');
@@ -62,13 +61,13 @@ function questions_load_questions($section, $year)
return $qs;
}
-function questions_save_answers($section, $id, $year, $answers)
+function questions_save_answers($section, $id, $answers)
{
- $qs = questions_load_questions($section, $year);
+ $qs = questions_load_questions($section);
$keys = array_keys($answers);
$query = "DELETE FROM question_answers ".
- "WHERE registrations_id='$id' ".
- " AND year='$year' AND (";
+ "WHERE users_id='$id' ".
+ " AND (";
$n = 0;
foreach($keys as $qid) {
if($n == 1) $query .= " OR ";
@@ -82,18 +81,17 @@ function questions_save_answers($section, $id, $year, $answers)
foreach($keys as $qid) {
/* Poll key */
mysql_query("INSERT INTO question_answers ".
- "(year,registrations_id,questions_id,answer) VALUES(".
- "'$year','$id','$qid',".
+ "(users_id,questions_id,answer) VALUES(".
+ "'$id','$qid',".
"'".mysql_escape_string($answers[$qid])."'".
")" );
}
}
-function questions_find_question_id($section, $year, $dbheading)
+function questions_find_question_id($section, $dbheading)
{
$q = mysql_query("SELECT id FROM questions WHERE ".
" section='$section' ".
- " AND year='$year' ".
" AND db_heading='$dbheading' ");
if(mysql_num_rows($q) == 1) {
$r = mysql_fetch_object($q);
@@ -103,10 +101,10 @@ function questions_find_question_id($section, $year, $dbheading)
}
-function questions_print_answer_editor($section, $id, $year, $array_name)
+function questions_print_answer_editor($section, &$u, $array_name)
{
- $ans = questions_load_answers($section, $id, $year);
- $qs = questions_load_questions($section, $year);
+ $ans = questions_load_answers($section, $u['id']);
+ $qs = questions_load_questions($section, $u['year']);
$keys = array_keys($qs);
foreach($keys as $qid) {
@@ -133,10 +131,10 @@ function questions_print_answer_editor($section, $id, $year, $array_name)
}
}
-function questions_print_answers($section, $id, $year)
+function questions_print_answers($section, $id)
{
- $ans = questions_load_answers($section, $id, $year);
- $qs = questions_load_questions($section, $year);
+ $ans = questions_load_answers($section, $id);
+ $qs = questions_load_questions($section);
$keys = array_keys($qs);
foreach($keys as $qid) {
echo "\n";
@@ -158,7 +156,7 @@ function questions_parse_from_http_headers($array_name)
return $ans;
}
-function questions_update_question($qs, $year)
+function questions_update_question($qs)
{
mysql_query("UPDATE questions SET
`question`='".mysql_escape_string($qs['question'])."',
@@ -166,7 +164,7 @@ function questions_update_question($qs, $year)
`db_heading`='".mysql_escape_string($qs['db_heading'])."',
`required`='".mysql_escape_string($qs['required'])."',
`ord`=".intval($qs['ord'])."
- WHERE id='{$qs['id']}' AND year='$year'");
+ WHERE id='{$qs['id']}' ");
echo mysql_error();
}
diff --git a/user.inc.php b/user.inc.php
index 78a1c15..7d416b9 100644
--- a/user.inc.php
+++ b/user.inc.php
@@ -98,7 +98,16 @@ function user_load_judge($u)
$ret['div_prefs'] = unserialize($r->div_prefs);
$ret['divsub_prefs'] = unserialize($r->divsub_prefs);
$ret['expertise_other'] = $r->expertise_other;
-
+ $ret['languages'] = unserialize($r->languages);
+ $ret['highest_psd'] = $r->highest_psd;
+
+ /* Sanity check the arrays, make sure they are arrays */
+ $should_be_arrays = array('cat_prefs','div_prefs',
+ 'divsub_prefs','languages');
+ foreach($should_be_arrays as $k) {
+ if(!is_array($ret[$k])) $ret[$k] = array();
+ }
+
return $ret;
}
@@ -315,7 +324,8 @@ function user_save_judge($u)
{
$fields = array('judge_active','years_school','years_regional','years_national',
'willing_chair','special_award_only',
- 'cat_prefs','div_prefs','divsub_prefs','expertise_other');
+ 'cat_prefs','div_prefs','divsub_prefs',
+ 'expertise_other','languages', 'highest_psd');
user_save_type_list($u, 'users_judge', $fields);
}