diff --git a/db/db.update.117.sql b/db/db.update.117.sql
index 1f3cfd9..6a8b88f 100644
--- a/db/db.update.117.sql
+++ b/db/db.update.117.sql
@@ -10,4 +10,10 @@ ALTER TABLE `question_answers` CHANGE `registrations_id` `users_id` INT( 10 ) UN
-- The answer has been linked to a users_id that is unique per-year, so we don't need to duplicate the year storage
ALTER TABLE `question_answers` DROP `year`;
+-- Use users_id instead of judges_id now, the judges_id was converted to the proper users_id in the 116 update
+ALTER TABLE `judges_specialaward_sel` CHANGE `judges_id` `users_id` INT( 11 ) NOT NULL DEFAULT '0';
+ALTER TABLE `judges_teams_link` CHANGE `judges_id` `users_id` INT( 11 ) NOT NULL DEFAULT '0' ;
+
+-- The users_id is linked with the year, don't need to store it here too
+ALTER TABLE `judges_specialaward_sel` DROP `year`;
diff --git a/judge.inc.php b/judge.inc.php
index d1602d3..a5278a5 100644
--- a/judge.inc.php
+++ b/judge.inc.php
@@ -31,26 +31,13 @@ $preferencechoices=array(
2=>"High"
);
-
-
-function personalStatus()
-{
- global $config;
-
- //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";
-}
-
-function judge_status_expertise($u)
+function judge_status_expertise(&$u)
{
global $config;
+ if($u['load_full'] == false) {
+ echo "ERROR: judge_status_expertise() called without a full user.";
+ exit;
+ }
/* If the judging special awards are active, and the judge has
* selected "I am a special awards judge", then disable
@@ -74,9 +61,13 @@ function judge_status_expertise($u)
return 'complete';
}
-function judge_status_other($u)
+function judge_status_other(&$u)
{
global $config;
+ if($u['load_full'] == false) {
+ echo "ERROR: judge_status_other() called without a full user.";
+ exit;
+ }
/* They must select a language to judge in */
if(count($u['languages']) < 1) return 'incomplete';
@@ -86,64 +77,61 @@ function judge_status_other($u)
-function specialawardStatus()
+function judge_status_special_awards(&$u)
{
global $config;
+ if($u['load_full'] == false) {
+ echo "ERROR: judge_status_special_awards() called without a full user.";
+ exit;
+ }
/* Complete if:
* - judge has selected (none) "no special award preferences"
- * - judge has selected (pref) "i would like to specify awards", and has
- * selected between min and max preferences
- * - judge has selected "i am a special awards judge, and has
- * selected an award */
-
- $q = mysql_query("SELECT typepref FROM judges WHERE
- id='{$_SESSION['judges_id']}'");
- if(mysql_num_rows($q) != 1) return "incomplete";
- $r = mysql_fetch_object($q);
+ * - judge has selected between min and max preferences
+ */
$qq = mysql_query("SELECT COUNT(id) AS num FROM judges_specialaward_sel
- WHERE judges_id='{$_SESSION['judges_id']}'
- AND year={$config['FAIRYEAR']}");
+ WHERE users_id='{$u['id']}'");
$rr = mysql_fetch_object($qq);
$awards_selected = $rr->num;
+// echo "$awards_selected awards selected, ({$config['judges_specialaward_min']} - {$config['judges_specialaward_max']})";
- switch($r->typepref) {
- case "speconly": /* Judge for special award */
+ if($u['special_award_only'] == 'yes') {
+ /* Judge for special award */
/* They may judge more than one award, so don't limit them
* to one */
- if($awards_selected >= 1) return "complete";
- break;
+ if($awards_selected >= 1) return 'complete';
+ return 'incomplete';
+ }
- case "pref": /* Special award preferences specified */
- default:
- if( ($awards_selected >= $config['judges_specialaward_min'])
- &&($awards_selected <= $config['judges_specialaward_max']) ){
- return "complete";
- }
- break;
+ if( ($awards_selected >= $config['judges_specialaward_min'])
+ &&($awards_selected <= $config['judges_specialaward_max']) ){
+ return 'complete';
}
- return "incomplete";
+ return 'incomplete';
}
-//ji = judgeinfo record from database (select * from judges where id='whatever')
-function updateJudgeCompleteStatus($ji)
+
+function judge_status_update(&$u)
{
- if( personalStatus()=="complete" &&
- expertiseStatus()=="complete"
- )
- $complete="yes";
- else
- $complete="no";
+ if($u['load_full'] == false) {
+ echo "ERROR: judge_status_update() called without a full user.";
+ exit;
+ }
+
+ if( user_personal_info_status($u) == 'complete'
+ && judge_status_expertise($u) == 'complete'
+ && judge_status_other($u) == 'complete'
+ && judge_status_special_awards($u) == 'complete')
+ $u['judge_complete'] = 'yes';
+ else
+ $u['judge_complete'] = 'no';
+
+ user_save($u);
+ return ($u['judge_complete'] == 'yes') ? 'complete' : 'incomplete';
- if($complete!=$ji->complete)
- {
- mysql_query("UPDATE judges SET complete='$complete' WHERE id='".$ji->id."'");
- }
}
-//finally, if everything else is good, update their 'overall status' if it needs to be
-//updateJudgeCompleteStatus($judgeinfo);
?>
diff --git a/judge_expertise.php b/judge_expertise.php
index 9336de4..b21fe5c 100644
--- a/judge_expertise.php
+++ b/judge_expertise.php
@@ -67,7 +67,7 @@
$u = user_load($_SESSION['users_id'], true);
}
-// updateJudgeCompleteStatus($judgeinfo);
+judge_status_update($u);
//output the current status
$newstatus=judge_status_expertise($u);
diff --git a/judge_main.php b/judge_main.php
index b850308..664d0d1 100644
--- a/judge_main.php
+++ b/judge_main.php
@@ -67,14 +67,14 @@
if($config['judges_specialaward_enable'] == 'yes' || $u['special_award_only'] == 'yes') {
user_page_summary_item("Special Award Preferences",
- "register_judges_specialawards.php", "specialawardStatus", array($u));
+ "judge_special_awards.php", "judge_status_special_awards", array($u));
}
// user_page_summary_item("Areas of Expertise",
// "register_judges_expertise.php", "expertiseStatus", array($u));
$overallstatus = user_page_summary_end(true);
- user_update_complete($u, $overallstatus);
+ judge_status_update($u);
echo '
';
if($overallstatus!="complete")
diff --git a/judge_other.php b/judge_other.php
index 9f5a3f2..7051e91 100644
--- a/judge_other.php
+++ b/judge_other.php
@@ -55,7 +55,7 @@
$u = user_load($_SESSION['users_id'], true);
}
-// updateJudgeCompleteStatus($judgeinfo);
+judge_status_update($u);
//output the current status
$newstatus=judge_status_other($u);
diff --git a/judge_special_awards.php b/judge_special_awards.php
new file mode 100644
index 0000000..b4c6778
--- /dev/null
+++ b/judge_special_awards.php
@@ -0,0 +1,117 @@
+
+/*
+ This file is part of the 'Science Fair In A Box' project
+ SFIAB Website: http://www.sfiab.ca
+
+ Copyright (C) 2005 Sci-Tech Ontario Inc
+ Copyright (C) 2005 James Grant
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public
+ License as published by the Free Software Foundation, version 2.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; see the file COPYING. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+?>
+
+ require_once('common.inc.php');
+ require_once('user.inc.php');
+ require_once('judge.inc.php');
+
+ $u = user_load($_SESSION['users_id'], true);
+
+ //send the header
+ send_header('Special Awards',
+ array('Judge Registration' => 'judge_main.php')
+ );
+
+ if($_POST['action']=="save") {
+ //first delete all their old associations for this year..
+ mysql_query("DELETE FROM judges_specialaward_sel WHERE users_id='{$u['id']}'");
+
+ if(array_key_exists('spaward', $_POST)) {
+ foreach($_POST['spaward'] AS $aid) {
+ mysql_query("INSERT INTO judges_specialaward_sel (users_id, award_awards_id)
+ VALUES ('{$u['id']}','$aid')");
+ }
+ }
+ echo notice(i18n("Special Award preferences successfully saved"));
+ }
+
+
+ judge_status_update($u);
+
+//output the current status
+$newstatus=judge_status_special_awards($u);
+if($newstatus!='complete')
+ echo error(i18n("Special Award Preferences Incomplete"));
+else
+ echo happy(i18n("Special Award Preferences Complete"));
+
+ echo "";
+
+
+ send_footer();
+?>
diff --git a/user.inc.php b/user.inc.php
index 7d416b9..a6fac9a 100644
--- a/user.inc.php
+++ b/user.inc.php
@@ -89,6 +89,7 @@ function user_load_judge($u)
$r = mysql_fetch_object($q);
$ret = array();
$ret['judge_active'] = $r->judge_active;
+ $ret['judge_complete'] = $r->judge_complete;
$ret['years_school'] = intval($r->years_school);
$ret['years_regional'] = intval($r->years_regional);
$ret['years_national'] = intval($r->years_national);
@@ -304,12 +305,13 @@ function user_save_type_list($u, $db, $fields)
if($set != "") {
$query = "UPDATE $db SET $set WHERE users_id='{$u['id']}'";
mysql_query($query);
+ echo mysql_error();
}
}
function user_save_volunteer($u)
{
- $fields = array('volunteer_active');
+ $fields = array('volunteer_active','volunteer_complete');
user_save_type_list($u, 'users_volunteer', $fields);
}
@@ -322,7 +324,7 @@ function user_save_committee($u)
function user_save_judge($u)
{
- $fields = array('judge_active','years_school','years_regional','years_national',
+ $fields = array('judge_active','judge_complete','years_school','years_regional','years_national',
'willing_chair','special_award_only',
'cat_prefs','div_prefs','divsub_prefs',
'expertise_other','languages', 'highest_psd');
@@ -331,7 +333,7 @@ function user_save_judge($u)
function user_save_student($u)
{
-// $fields = array('student_active',);
+// $fields = array('student_active','student_complete');
// user_save_type_list($u, 'users_student', $fields);
}
@@ -399,8 +401,8 @@ function user_delete_judge($u)
{
global $config;
$id = $u['id'];
- mysql_query("DELETE FROM judges_teams_link WHERE judges_id='$id' AND year='{$config['FAIRYEAR']}'");
- mysql_query("DELETE FROM judges_years WHERE judges_id='$id' AND year='{$config['FAIRYEAR']}'");
+ mysql_query("DELETE FROM judges_teams_link WHERE users_id='$id'");
+ mysql_query("DELETE FROM judges_specialawards_sel WHERE users_id='$id'");
}
function user_delete_fair($u)