diff --git a/admin/committees.php b/admin/committees.php
index 5d36dfa..f047efc 100644
--- a/admin/committees.php
+++ b/admin/committees.php
@@ -189,9 +189,9 @@ if($_GET['deletecommittee'])
if($_POST['action']=="remove")
{
+ /* user_delete takes care of unlinking the user in other tables */
user_delete($uid, 'committee');
- mysql_query("DELETE FROM committees_link WHERE users_id='$uid'");
- echo happy(i18n("Committee member removed"));
+ echo happy(i18n("Committee member deleted"));
}
if($_GET['unlinkmember'] && $_GET['unlinkcommittee'])
diff --git a/committee_main.php b/committee_main.php
index 5ac06b9..a91bf8c 100644
--- a/committee_main.php
+++ b/committee_main.php
@@ -31,18 +31,6 @@
send_header("Committee Main", array());
- switch($_GET['notice']) {
- case 'password_changed':
- echo happy(i18n('Your password has been successfully updated'));
- break;
- case 'already_logged_in':
- echo error(i18n('You are already logged in, please use the [Logout] link in the upper right to logout'));
- break;
- case 'no_auth':
- echo error(i18n('You do not have permission to view that page'));
- break;
- }
-
//only display the named greeting if we have their name
echo i18n("Hello %1",array($_SESSION['name']));
echo " ";
@@ -61,6 +49,7 @@
echo "
";
+/* Dump any messages in the queue */
+if(is_array($_SESSION['messages'])) {
+ foreach($_SESSION['messages'] as $m) echo $m;
+}
+$_SESSION['messages'] = array();
+
if($title)
echo "
".i18n($title)."
";
@@ -1135,4 +1133,11 @@ function format_datetime($dt) {
return format_date($d)." ".i18n("at")." ".format_time($t);
}
}
+
+function message_push($m)
+{
+ if(!is_array($_SESSION['messages'])) $_SESSION['messages'] = array();
+ $_SESSION['messages'][] = $m;
+}
+
?>
diff --git a/db/db.update.116.php b/db/db.update.116.php
new file mode 100644
index 0000000..4bdc210
--- /dev/null
+++ b/db/db.update.116.php
@@ -0,0 +1,203 @@
+
+function db_update_116_post()
+{
+ global $config;
+
+ /* Fix the users that have a 0 year */
+ $q = mysql_query("UPDATE `users` SET year={$config['FAIRYEAR']} WHERE year=0");
+ echo mysql_error();
+
+ /* Create volunteer database entries for any that don't exist */
+ $q = mysql_query("SELECT * FROM users WHERE types LIKE '%volunteer%'");
+ while($i = mysql_fetch_object($q)) {
+ mysql_query("INSERT INTO users_volunteer(`users_id`,`volunteer_active`,`volunteer_complete`)
+ VALUES ('{$i->id}','yes','{$i->complete}')");
+ }
+
+ /* Update any remaining volunteer entries */
+ $q = mysql_query("SELECT * FROM users WHERE types LIKE '%volunteer%'");
+ while($i = mysql_fetch_object($q)) {
+ mysql_query("UPDATE users_volunteer
+ SET volunteer_complete='{$i->complete}'
+ WHERE users_id='{$i->id}'");
+ echo mysql_error();
+ }
+
+ /* Every committee member role should be activated */
+ $q = mysql_query("SELECT * FROM users WHERE types LIKE '%committee%'");
+ while($i = mysql_fetch_object($q)) {
+ mysql_query("UPDATE users_committee
+ SET committee_active='yes'
+ WHERE users_id='{$i->id}'");
+ echo mysql_error();
+ }
+
+ /* Convert Judges */
+ $map = array();
+ $jtl = array();
+ $jsal = array();
+
+ /* Select all judges, duplicate rows for each year */
+ $jq = mysql_query("SELECT * FROM judges
+ LEFT JOIN judges_years ON judges_years.judges_id=judges.id
+ ORDER BY year");
+
+ while($j = mysql_fetch_object($jq)) {
+
+ if(!is_array($map[$j->id])) {
+ $map[$j->id] = array('uid' => '');
+ }
+
+ $u = array( 'id' => '',
+ 'uid' => $map[$j->id]['uid'],
+ 'types' => 'judge',
+ 'firstname' => mysql_escape_string($j->firstname),
+ 'lastname' => mysql_escape_string($j->lastname),
+ 'username' => mysql_escape_string($j->email),
+ 'email' => mysql_escape_string($j->email),
+ 'sex' => '',
+ 'password' => mysql_escape_string($j->password),
+ 'passwordset' => $j->lastlogin,
+ 'oldpassword' => '',
+ 'year' => $j->year,
+ 'phonehome' => mysql_escape_string($j->phonehome),
+ 'phonework' => mysql_escape_string($j->phonework.(($j->phoneworkext=='') ? '' : " x{$j->phoneworkext}")),
+ 'phonecell' => mysql_escape_string($j->phonecell),
+ 'fax' => '',
+ 'organization' => mysql_escape_string($j->organization),
+ 'lang' => '', /* FIXME, or unused for judges?, this is preferred communication language, not judging languages */
+ 'created' => $j->created,
+ 'lastlogin' => $j->lastlogin,
+ 'address' => mysql_escape_string($j->address),
+ 'address2' => mysql_escape_string($j->address2),
+ 'city' => mysql_escape_string($j->city),
+ 'province' => mysql_escape_string($j->province),
+ 'postalcode' => mysql_escape_string($j->postalcode),
+ 'firstaid' => 'no',
+ 'cpr' => 'no',
+ 'deleted' => $j->deleted,
+ 'deleteddatetime' => $j->deleteddatetime );
+
+ /* Insert the judge */
+ $fields = '`'.join('`,`', array_keys($u)).'`';
+ $vals = "'".join("','", array_values($u))."'";
+ $q = mysql_query("INSERT INTO users ($fields) VALUES ($vals)");
+ $id = mysql_insert_id();
+
+ if($map[$j->id]['uid'] == '') {
+ $map[$j->id]['uid'] = $id;
+ $q = mysql_query("UPDATE users SET `uid`='$id' WHERE id='$id'");
+ }
+
+ $uj = array( 'users_id' => "$id",
+ 'judge_active' => 'yes',
+ 'highest_psd' => mysql_escape_string($j->highest_psd),
+ 'special_award_only' => ($j->typepref == 'speconly') ? 'yes' : 'no',
+ 'expertise_other' => mysql_escape_string((($j->professional_quals != '')?($j->professional_quals."\n"):'').
+ $j->expertise_other),
+ /* These need to get pulled from the questions */
+ 'years_school' => $j->years_school,
+ 'years_regional' => $j->years_regional,
+ 'years_national' => $j->years_national,
+ 'willing_chair' => $j->willing_chair,
+ 'judge_complete' => $j->complete,
+ );
+// $j->attending_lunch,
+
+ /* catprefs */
+ $q = mysql_query("SELECT * FROM judges_catpref WHERE judges_id='{$j->id}' AND year='{$j->year}'");
+ $catpref = array();
+ while($i = mysql_fetch_object($q)) {
+ $catpref[$i->projectcategories_id] = $i->rank;
+ }
+ $uj['cat_prefs'] = mysql_escape_string(serialize($catpref));
+
+ /* divprefs and subdivision prefs */
+ $q = mysql_query("SELECT * FROM judges_expertise WHERE judges_id='{$j->id}' AND year='{$j->year}'");
+ $divpref = array();
+ $divsubpref = array();
+ while($i = mysql_fetch_object($q)) {
+ if($i->projectdivisions_id)
+ $divpref[$i->projectdivisions_id] = $i->val;
+ else if ($i->projectsubdivisions_id)
+ $divsubpref[$i->projectsubdivisions_id] = $i->val;
+ }
+ $uj['div_prefs'] = mysql_escape_string(serialize($divpref));
+ $uj['divsub_prefs'] = mysql_escape_string(serialize($divsubpref));
+
+ /* languages */
+ $q = mysql_query("SELECT * FROM judges_languages WHERE judges_id='{$j->id}'");
+ $langs = array();
+ while($i = mysql_fetch_object($q)) {
+ $langs[] = $i->languages_lang;
+ }
+ $uj['languages'] = mysql_escape_string(serialize($langs));
+
+ /* Map judges questions back to the profile. We're going to keep questions we need for
+ * judge scheduling as hard-coded questions so users can't erase them.
+ * "Years School" "Years Regional" "Years National" "Willing Chair" */
+ $qmap = array('years_school' => 'Years School',
+ 'years_regional' => 'Years Regional',
+ 'years_national' => 'Years National',
+ 'willing_chair' => 'Willing Chair');
+ foreach($qmap as $field=>$head) {
+ /* Find the question ID */
+ $q = mysql_query("SELECT id FROM questions WHERE year='{$j->year}' AND db_heading='{$head}'");
+ if(mysql_num_rows($q) == 0) {
+ echo "Warning: Question '$head' for judge {$j->id} doesn't exist in year '{$j->year}', cannot copy answer.\n";
+ continue;
+ }
+
+ $i = mysql_fetch_object($q);
+
+ /* Now find the answer */
+ $q = mysql_query("SELECT * FROM question_answers WHERE
+ year='{$j->year}' AND
+ registrations_id='{$j->id}' AND
+ questions_id='{$i->id}'");
+ echo mysql_error();
+ if(mysql_num_rows($q) == 0) {
+ echo "Warning: Judge {$j->id} did not answer question '$head' in year '{$j->year}', cannot copy answer.\n";
+ continue;
+ }
+ $i = mysql_fetch_assoc($q);
+ $uj[$field] = $i['answer'];
+ }
+
+// print_r($uj);
+
+ $fields = '`'.join('`,`', array_keys($uj)).'`';
+ $vals = "'".join("','", array_values($uj))."'";
+ $q = mysql_query("INSERT INTO users_judge ($fields) VALUES ($vals)");
+ echo mysql_error();
+
+ /* FIXUP all the judging tables (bit don't write back yet, we don't want to
+ * accidentally create a duplicate judges_id and overwrite it later) */
+
+ /* judges_teams_link */
+ $q = mysql_query("SELECT * FROM judges_teams_link WHERE judges_id='{$j->id}' AND year='{$j->year}'");
+ while($i = mysql_fetch_object($q))
+ $jtl[$i->id] = $id;
+
+ /* judges_specialawards_sel */
+ $q = mysql_query("SELECT * FROM judges_specialaward_sel WHERE judges_id='{$j->id}' AND year='{$j->year}'");
+ echo mysql_error();
+ while($i = mysql_fetch_object($q))
+ $jsal[$i->id] = $id;
+
+
+
+ }
+
+ /* Now write back the judge ids */
+ foreach($jtl as $id=>$new_id)
+ $q = mysql_query("UPDATE judges_teams_link SET judges_id='$new_id' WHERE id='$id' ");
+
+ foreach($jsal as $id=>$new_id)
+ $q = mysql_query("UPDATE judges_specialaward_sel SET judges_id='$new_id' WHERE id='$id' ");
+
+
+
+
+}
+?>
diff --git a/db/db.update.116.sql b/db/db.update.116.sql
new file mode 100644
index 0000000..f40b84b
--- /dev/null
+++ b/db/db.update.116.sql
@@ -0,0 +1,25 @@
+
+ALTER TABLE `users` ADD `uid` INT NOT NULL AFTER `id` ;
+
+ALTER TABLE `users_committee` CHANGE `active` `committee_active` ENUM( 'no', 'yes' ) NOT NULL DEFAULT 'no';
+ALTER TABLE `users_committee` ADD `committee_complete` ENUM( 'no', 'yes' ) NOT NULL DEFAULT 'no' AFTER `committee_active` ;
+
+ALTER TABLE `users_fair` CHANGE `active` `fair_active` ENUM( 'no', 'yes' ) NOT NULL DEFAULT 'no';
+ALTER TABLE `users_fair` ADD `fair_complete` ENUM( 'no', 'yes' ) NOT NULL DEFAULT 'no' AFTER `fair_active` ;
+
+ALTER TABLE `users_judge` CHANGE `active` `judge_active` ENUM( 'no', 'yes' ) NOT NULL DEFAULT 'no';
+ALTER TABLE `users_judge` ADD `judge_complete` ENUM( 'no', 'yes' ) NOT NULL DEFAULT 'no' AFTER `judge_active` ;
+ALTER TABLE `users_judge` ADD `cat_prefs` TINYTEXT NOT NULL AFTER `special_award_only` ;
+ALTER TABLE `users_judge` ADD `div_prefs` TINYTEXT NOT NULL AFTER `cat_prefs` ;
+ALTER TABLE `users_judge` ADD `divsub_prefs` TINYTEXT NOT NULL AFTER `div_prefs` ;
+ALTER TABLE `users_judge` ADD `languages` TINYTEXT NOT NULL AFTER `divsub_prefs` ;
+ALTER TABLE `users_judge` ADD `highest_psd` TINYTEXT NOT NULL AFTER `languages` ;
+ALTER TABLE `users_judge` ADD `expertise_other` TINYTEXT NOT NULL AFTER `highest_psd` ;
+
+ALTER TABLE `users_volunteer` CHANGE `active` `volunteer_active` ENUM( 'no', 'yes' ) NOT NULL DEFAULT 'no';
+ALTER TABLE `users_volunteer` ADD `volunteer_complete` ENUM( 'no', 'yes' ) NOT NULL DEFAULT 'no' AFTER `volunteer_active` ;
+ALTER TABLE `users_volunteer` DROP `tmp`;
+
+DROP TABLE users_years;
+
+
diff --git a/judge.inc.php b/judge.inc.php
new file mode 100644
index 0000000..0823e55
--- /dev/null
+++ b/judge.inc.php
@@ -0,0 +1,152 @@
+
+/*
+ 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.
+*/
+?>
+
+
+$preferencechoices=array(
+ -2=>"Very Low",
+ -1=>"Low",
+ 0=>"Indifferent",
+ 1=>"Medium",
+ 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)
+{
+ global $config;
+
+ /* If the judging special awards are active, and the judge has
+ * selected "I am a special awards judge", then disable
+ * expertise checking */
+ if($config['judges_specialaward_only_enable'] == 'yes') {
+ if($u['special_award_only'] == 'yes')
+ return 'complete';
+ }
+
+ /* Check to see if they have ranked all project age categories, and all divisions */
+ $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";
+ }
+
+ $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['divprefs'])) {
+ return "incomplete";
+ }
+
+ return "complete";
+}
+
+function judge_status_other($u)
+{
+ global $config;
+
+ return 'complete';
+}
+
+
+
+function specialawardStatus()
+{
+ global $config;
+
+ /* 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);
+
+ $qq = mysql_query("SELECT COUNT(id) AS num FROM judges_specialaward_sel
+ WHERE judges_id='{$_SESSION['judges_id']}'
+ AND year={$config['FAIRYEAR']}");
+ $rr = mysql_fetch_object($qq);
+ $awards_selected = $rr->num;
+
+ switch($r->typepref) {
+ case "speconly": /* 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;
+
+ case "pref": /* Special award preferences specified */
+ default:
+ if( ($awards_selected >= $config['judges_specialaward_min'])
+ &&($awards_selected <= $config['judges_specialaward_max']) ){
+ return "complete";
+ }
+ break;
+ }
+
+ return "incomplete";
+}
+
+//ji = judgeinfo record from database (select * from judges where id='whatever')
+function updateJudgeCompleteStatus($ji)
+{
+ if( personalStatus()=="complete" &&
+ expertiseStatus()=="complete"
+ )
+ $complete="yes";
+ else
+ $complete="no";
+
+ 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
new file mode 100644
index 0000000..d33d4dc
--- /dev/null
+++ b/judge_expertise.php
@@ -0,0 +1,185 @@
+
+/*
+ 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
+ $type = $_SESSION['users_type'];
+ send_header('Category and Division Preferences',
+ 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();
+
+ $u['div_prefs'] = array();
+ foreach($_POST['division'] AS $key=>$val)
+ $u['div_prefs'][$key] = $val;
+
+ $u['div_prefs_sub'] = array();
+ foreach($_POST['subdivision'] AS $key=>$val)
+ $u['div_prefs_sub'][$key] = $val;
+
+ if($_POST['expertise_other'])
+ $u['expertise_other'] = stripslashes($_POST['expertise_other']);
+ else
+ $u['expertise_other'] = NULL;
+
+ $u['cat_prefs'] = array();
+ if(is_array($_POST['catpref'])) {
+ foreach($_POST['catpref'] AS $k=>$v) {
+ if($v == '') continue;
+
+ $u['cat_prefs'][$k] = $v;
+ }
+ }
+ user_save($u);
+ message_push(notice(i18n("Preferences successfully saved")));
+ $u = user_load($_SESSION['users_id'], true);
+ }
+
+// updateJudgeCompleteStatus($judgeinfo);
+
+//output the current status
+$newstatus=judge_status_expertise($u);
+if($newstatus!="complete")
+ echo error(i18n("Divisional Judging Information Incomplete"));
+else
+ echo happy(i18n("Divisional Judging Information Complete"));
+
+ if($u['special_award_only'] == 'yes') {
+ echo i18n("You have specified that you are a judge for a specific special award. Divisional Judging preferences have been disabled because they do not apply to you.");
+ echo " ";
+ send_footer();
+ exit;
+ }
+
+ echo "
\n";
echo "\n";
echo "
\n";
diff --git a/user_personal.php b/user_personal.php
index 06ff640..5f18098 100644
--- a/user_personal.php
+++ b/user_personal.php
@@ -148,7 +148,7 @@
$em = mysql_escape_string(stripslashes($_POST['email']));
$q=mysql_query("SELECT id FROM users WHERE email='$em' AND id!='{$u['id']}'");
if(mysql_num_rows($q) > 0) {
- $notice = 'email_exists';
+ message_push(error(i18n("That email address is in use by another user")));
$save = false;
}
@@ -158,7 +158,7 @@
header("location: {$config['SFIABDIRECTORY']}/admin/committees.php");
exit;
}
- $notice = 'success';
+ message_push(notice(i18n("%1 %2 successfully updated",array($_POST['firstname'],$_POST['lastname']))));
}
@@ -188,15 +188,6 @@
}
}
- switch($notice) {
- case 'success':
- echo notice(i18n("%1 %2 successfully updated",array($_POST['firstname'],$_POST['lastname'])));
- break;
- case 'email_exists':
- echo error(i18n("That email address is in use by another user"));
- break;
- }
-
foreach($errorfields as $f) {
echo error(i18n('\'%1\' must use the format: %2',
array(i18n($user_personal_fields[$f]['name']),
diff --git a/volunteer_main.php b/volunteer_main.php
index 76a5437..10aaff3 100644
--- a/volunteer_main.php
+++ b/volunteer_main.php
@@ -30,20 +30,16 @@
user_auth_required('volunteer');
- send_header("Volunteer Registration", array());
+ $u = user_load($_SESSION['users_id'], true);
- switch($_GET['notice']) {
- case 'password_changed':
- echo happy(i18n('Your password has been successfully updated'));
- break;
- case 'already_logged_in':
- echo error(i18n('You are already logged in, please use the [Logout] link in the upper right to logout before loggin in as different user'));
- break;
- case 'attached':
- echo happy(i18n('The Volunteer role has been attached to your account. Use the [Switch Roles] link in the upper right to change roles while you are logged in'));
- break;
+ if($u['volunteer_active'] == 'no') {
+ message_push(notice(i18n("Your volunteer role is not active. If you would like to participate as a volunteer for the %1 %2 please click the 'Activate Role' button in the Volunteer section below",array($config['FAIRYEAR'],$config['fairname']))));
+ header('Location: user_activate.php');
+ exit;
}
+ send_header("Volunteer Main", array());
+
//only display the named greeting if we have their name
echo i18n("Hello %1",array($_SESSION['name']));
echo " ";
@@ -66,6 +62,7 @@
this page, they will never be marked as complete. Not sure how to handle
this, it's kinda hackey to call EVERY status() fucntion within EACH page to
get teh overall status. */
+ /* Change this to volunteer_status */
user_update_complete($u, $overallstatus);
echo " ";
@@ -82,7 +79,11 @@
echo " ";
echo i18n('Other Options and Things To Do').': ';
echo '