diff --git a/admin/user_editor_window.php b/admin/user_editor_window.php
index dfee6b3..cee98da 100644
--- a/admin/user_editor_window.php
+++ b/admin/user_editor_window.php
@@ -31,32 +31,37 @@ $tabs = array('personal' => array(
'name' => 'Personal',
'types' => array('student','judge','committee','volunteer','sponsor'),
'file' => '../user_personal.php',
- ),
+ 'enabled' => true),
'roles' => array(
'name' => 'Roles/Account',
'types' => array('student','judge','committee','volunteer','sponsor'),
'file' => '../user_activate.php',
- ),
+ 'enabled' => true),
'judgeother' => array(
'name' => 'Judge Other',
'types' => array('judge'),
'file' => '../judge_other.php',
- ),
+ 'enabled' => true),
'judgeexpertise' => array(
'name' => 'Expertise',
'types' => array('judge'),
'file' => '../judge_expertise.php',
- ),
+ 'enabled' => true),
+ 'judgeavailability' => array(
+ 'name' => 'Time Avail.',
+ 'types' => array('judge'),
+ 'file' => '../judge_availability.php',
+ 'enabled' => $config['judges_availability_enable'] == 'yes' ? true : false),
'judgesa' => array(
'name' => 'Special Awards',
'types' => array('judge'),
'file' => '../judge_special_awards.php',
- ),
+ 'enabled' => true,),
'volunteerpos' => array(
'name' => 'Volunteer Positions',
'types' => array('volunteer'),
'file' => '../volunteer_position.php',
- ),
+ 'enabled' => true,),
);
@@ -90,8 +95,12 @@ send_popup_header(i18n("User Editor").": {$u['name']}");
echo '
';
foreach($tabs as $k=>$t) {
+ /* Make sure the tab is enabled */
+ if($t['enabled'] == false) continue;
+ /* Make sure the user has the right type to see the tab */
$i = array_intersect($t['types'], $u['types']);
if(count($i) == 0) continue;
+ /* Show the tab */
$sel = ($selected == $k) ? 'htabsel' : '';
$href = "$PHP_SELF?id=$id&tab=$k";
echo "- ".i18n($t['name'])."
";
diff --git a/admin/user_list.php b/admin/user_list.php
index b25a902..1399f8a 100644
--- a/admin/user_list.php
+++ b/admin/user_list.php
@@ -57,7 +57,7 @@ function openeditor(id)
{
if(id) currentid=id;
- window.open("user_editor_window.php?id="+currentid,"User Editor","location=no,menubar=no,directories=no,toolbar=no,width=770,height=500,scrollbars=yes");
+ window.open("user_editor_window.php?id="+currentid,"User Editor","location=no,menubar=no,directories=no,toolbar=no,width=1000,height=640,scrollbars=yes");
return false;
}
diff --git a/db/db.code.version.txt b/db/db.code.version.txt
index 190a180..fc902f4 100644
--- a/db/db.code.version.txt
+++ b/db/db.code.version.txt
@@ -1 +1 @@
-123
+124
diff --git a/db/db.update.124.sql b/db/db.update.124.sql
new file mode 100644
index 0000000..9cb76c0
--- /dev/null
+++ b/db/db.update.124.sql
@@ -0,0 +1,11 @@
+CREATE TABLE `judges_availability` (
+ `id` INT NOT NULL AUTO_INCREMENT ,
+ `users_id` INT NOT NULL ,
+ `date` DATE NOT NULL ,
+ `start` TIME NOT NULL ,
+ `end` TIME NOT NULL ,
+ PRIMARY KEY ( `id` )
+) ENGINE = MYISAM ;
+
+INSERT INTO `config` ( `var` , `val` , `category` , `type` , `type_values` , `ord` , `description` , `year`)
+VALUES ( 'judges_availability_enable', 'no', 'Judge Registration', 'yesno', '', '950', 'Allow judges to specify their time availability on the fair day based on the defined judging rounds/timeslots. The scheduler will then use this judge availability data when assigning judges to teams and projects.', '-1');
diff --git a/judge.inc.php b/judge.inc.php
index cf692fc..47cdb3d 100644
--- a/judge.inc.php
+++ b/judge.inc.php
@@ -5,6 +5,7 @@
Copyright (C) 2005 Sci-Tech Ontario Inc
Copyright (C) 2005 James Grant
+ Copyright (C) 2009 David Grant
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
@@ -100,6 +101,17 @@ function judge_status_special_awards(&$u)
return 'incomplete';
}
+function judge_status_availability(&$u)
+{
+ global $config;
+ if($config['judges_availability_enable'] == 'no') return 'complete';
+
+ $q = mysql_query("SELECT id FROM judges_availability
+ WHERE users_id=\"{$u['id']}\"");
+ if(mysql_num_rows($q) > 0) return 'complete';
+
+ return 'incomplete';
+}
function judge_status_update(&$u)
{
@@ -108,6 +120,7 @@ function judge_status_update(&$u)
if( user_personal_info_status($u) == 'complete'
&& judge_status_expertise($u) == 'complete'
&& judge_status_other($u) == 'complete'
+ && judge_status_availability($u) == 'complete'
&& judge_status_special_awards($u) == 'complete')
$u['judge_complete'] = 'yes';
else
diff --git a/judge_availability.php b/judge_availability.php
new file mode 100644
index 0000000..c3e9ef8
--- /dev/null
+++ b/judge_availability.php
@@ -0,0 +1,140 @@
+
+/*
+ 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
+ Copyright (C) 2009 David 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');
+
+if($_SESSION['embed'] == true) {
+ user_auth_required('committee');
+ $u = user_load($_SESSION['embed_edit_id']);
+} else {
+ user_auth_required('judge');
+ $u = user_load($_SESSION['users_id']);
+}
+
+$times = array();
+
+/* Load the judging rounds */
+$q = mysql_query("SELECT date,starttime,endtime,name FROM judges_timeslots WHERE round_id='0' AND year='{$config['FAIRYEAR']}' ORDER BY starttime,type");
+$x = 0;
+while($r = mysql_fetch_object($q)) {
+ $found = false;
+ foreach($times as $xx => $t) {
+ if($t['date'] == $r->date && $t['starttime'] == $r->starttime && $t['endtime'] == $r->endtime) {
+ $times[$xx]['name'] .= ", {$r->name}";
+ $found = true;
+ break;
+ }
+ }
+ if(!$found) {
+ $times[$x] = array( 'date' => $r->date,
+ 'starttime' => $r->starttime,
+ 'endtime' => $r->endtime,
+ 'name' => $r->name);
+ $x++;
+ }
+}
+
+if($_POST['action']=='save') {
+ mysql_query("DELETE FROM judges_availability WHERE users_id='{$u['id']}'");
+
+ if(is_array($_POST['time']) ) {
+ foreach($_POST['time'] as $x) {
+ if(trim($times[$x]['starttime']) == '') continue;
+
+ mysql_query("INSERT INTO judges_availability (users_id, `date`,`start`,`end`)
+ VALUES ('{$u['id']}',
+ '{$times[$x]['date']}',
+ '{$times[$x]['starttime']}','{$times[$x]['endtime']}')");
+ }
+ }
+ message_push(notice(i18n("Time Availability preferences successfully saved")));
+}
+
+if($_SESSION['embed'] == true) {
+ echo "
";
+ display_messages();
+ echo "".i18n('Time Availability')."
";
+ echo "
";
+} else {
+ //send the header
+ send_header('Time Availability',
+ array('Judge Registration' => 'judge_main.php')
+ );
+}
+
+judge_status_update($u);
+
+if($_SESSION['embed'] != true) {
+ //output the current status
+ $newstatus=judge_status_availability($u);
+ if($newstatus!='complete')
+ echo error(i18n("Time Availability Preferences Incomplete"));
+ else
+ echo happy(i18n("Time Availability Preferences Complete"));
+}
+
+$url = ($_SESSION['embed'] == true) ? $_SESSION['embed_submit_url'] : 'judge_availability.php';
+echo "";
+
+if($_SESSION['embed'] != true) send_footer();
+
+?>
diff --git a/judge_main.php b/judge_main.php
index d0b34f7..8c075d4 100644
--- a/judge_main.php
+++ b/judge_main.php
@@ -65,6 +65,11 @@
user_page_summary_item("Areas of Expertise",
"judge_expertise.php", "judge_status_expertise", array($u));
+ if($config['judges_availability_enable'] == 'yes') {
+ user_page_summary_item("Time Availability",
+ "judge_availability.php", "judge_status_availability", array($u));
+ }
+
if($config['judges_specialaward_enable'] == 'yes' || $u['special_award_only'] == 'yes') {
user_page_summary_item("Special Award Preferences",
"judge_special_awards.php", "judge_status_special_awards", array($u));