forked from science-ation/science-ation
Added user settings config for science olympic judges
This commit is contained in:
parent
941b5e127f
commit
9229b1665b
@ -1 +1 @@
|
||||
210
|
||||
211
|
||||
|
6
db/db.update.211.sql
Normal file
6
db/db.update.211.sql
Normal file
@ -0,0 +1,6 @@
|
||||
CREATE TABLE `schedule_users_availability_link` (
|
||||
`schedule_id` INT NOT NULL ,
|
||||
`users_id` INT NOT NULL ,
|
||||
`roles_id` INT NOT NULL ,
|
||||
PRIMARY KEY ( `schedule_id` , `users_id` , `roles_id`)
|
||||
) ENGINE = MYISAM ;
|
@ -74,6 +74,14 @@ function judge_status_other(&$u)
|
||||
return 'complete';
|
||||
}
|
||||
|
||||
function so_judge_status_other(&$u)
|
||||
{
|
||||
global $config;
|
||||
|
||||
/* They must select a language to judge in */
|
||||
if(count($u['languages']) < 1) return 'incomplete';
|
||||
return 'complete';
|
||||
}
|
||||
|
||||
|
||||
function judge_status_special_awards(&$u)
|
||||
|
@ -41,7 +41,7 @@ $u = user_load($edit_id);
|
||||
|
||||
/* Load the judging rounds */
|
||||
$times = array();
|
||||
$q = mysql_query("SELECT date,starttime,endtime,name FROM judges_timeslots WHERE round_id='0' AND year='{$config['FAIRYEAR']}' ORDER BY starttime,type");
|
||||
$q = mysql_query("SELECT date,starttime,endtime,name FROM judges_timeslots WHERE round_id='0' AND conferences_id='{$conference['id']}' ORDER BY starttime,type");
|
||||
$x = 0;
|
||||
while($r = mysql_fetch_object($q)) {
|
||||
$found = false;
|
||||
@ -61,8 +61,6 @@ while($r = mysql_fetch_object($q)) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
switch($_GET['action']) {
|
||||
case 'save':
|
||||
if(!is_array($_POST['languages'])) $_POST['languages']=array();
|
||||
|
204
so_judge_other.php
Normal file
204
so_judge_other.php
Normal file
@ -0,0 +1,204 @@
|
||||
<?php
|
||||
/*
|
||||
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 <info@scitechontario.org>
|
||||
Copyright (C) 2005 James Grant <james@lightbox.org>
|
||||
|
||||
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.
|
||||
*/
|
||||
?>
|
||||
<?php
|
||||
require_once('common.inc.php');
|
||||
require_once('user.inc.php');
|
||||
require_once('judge.inc.php');
|
||||
require_once("questions.inc.php");
|
||||
require_once('user_edit.inc.php');
|
||||
|
||||
/* Ensure they're logged in as a judge or admin */
|
||||
user_auth_required(array(), array('judge','admin'));
|
||||
|
||||
$edit_id = isset($_GET['users_id']) ? intval($_GET['users_id']) : $_SESSION['users_id'];
|
||||
if($edit_id != $_SESSION['users_id'])
|
||||
user_auth_required('admin');
|
||||
else
|
||||
user_auth_required();
|
||||
|
||||
$u = user_load($edit_id);
|
||||
|
||||
// load the times at which the various events are happening
|
||||
$times = array();
|
||||
$q = mysql_query("SELECT schedule.id, date, hour, minute, duration, title FROM schedule JOIN events ON schedule.events_id = events.id WHERE schedule.conferences_id = 7 AND max_judges > 0 ORDER BY date, hour, minute");
|
||||
$x = 0;
|
||||
while($r = mysql_fetch_assoc($q)){
|
||||
$dateParts = explode('-', $r['date']);
|
||||
$startTime = mktime($r['hour'], $r['minute'], 0, $dateParts[1], $dateParts[2], $dateParts[0]);
|
||||
$endTime = $startTime + $r['duration'] * 60;
|
||||
$times[$r['id']] = array(
|
||||
'date' => $r['date'],
|
||||
'starttime' => date('g:ia', $startTime),
|
||||
'endtime' => date('g:ia', $endTime),
|
||||
'name' => $r['title'],
|
||||
);
|
||||
}
|
||||
|
||||
switch($_GET['action']) {
|
||||
case 'save':
|
||||
if(!is_array($_POST['languages'])) $_POST['languages']=array();
|
||||
|
||||
$u['languages'] = array();
|
||||
foreach($_POST['languages'] AS $val)
|
||||
$u['languages'][] = $val;
|
||||
|
||||
$u['willing_chair'] = ($_POST['willing_chair'] == 'yes') ? 'yes' : 'no';
|
||||
$u['highest_psd'] = stripslashes($_POST['highest_psd']);
|
||||
user_save($u);
|
||||
|
||||
if(is_array($_POST['questions'])){
|
||||
questions_save_answers("judgereg",$u['id'],$_POST['questions']);
|
||||
}
|
||||
|
||||
// save the judging availability selection
|
||||
mysql_query("DELETE FROM schedule_users_availability_link WHERE users_id='{$u['id']}'");
|
||||
if(is_array($_POST['time']) ) {
|
||||
$judgeRole = mysql_result(mysql_query("SELECT id FROM roles WHERE type = 'judge'"), 0, 0);
|
||||
foreach($_POST['time'] as $idx) {
|
||||
mysql_query("
|
||||
INSERT INTO schedule_users_availability_link (schedule_id, users_id, roles_id)
|
||||
VALUES($idx, {$u['id']}, $judgeRole)
|
||||
");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
happy_("Preferences successfully saved");
|
||||
|
||||
$u = user_load($u['id']);
|
||||
$newstatus=judge_status_other($u);
|
||||
echo "\$newstatus = $newstatus";
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
user_update_tab_status('sojudge','<?=$newstatus?>');
|
||||
</script>
|
||||
<?php
|
||||
exit;
|
||||
}
|
||||
|
||||
$fields = array('languages[]', 'willing_chair','highest_psd','time[]');
|
||||
$required = array('languages[]');
|
||||
|
||||
if(count($times) > 1) $required[] = 'time[]';
|
||||
|
||||
?>
|
||||
<h4><?=i18n("Judge Information")?> - <span class="status_sojudge"></span></h4>
|
||||
<br/>
|
||||
<form class="editor" id="judgeother_form">
|
||||
<table width="90%">
|
||||
<tr><td style="text-align: left" colspan="2"><b><?=i18n('Judging Language(s)')?></b><hr /></td></tr>
|
||||
<tr><?=user_edit_item($u, 'Languages', 'languages[]', 'languages')?></tr>
|
||||
<?php if(count($times) > 1) { ?>
|
||||
<tr><td style="text-align: left" colspan="2"><br /><b><?=i18n('Time Availability')?></b><hr />
|
||||
<i><?=i18n('Please specify the events you are available to judge')?></i>
|
||||
</td></tr>
|
||||
|
||||
<?php
|
||||
// get a list of the times they already have selected
|
||||
$sel = array();
|
||||
$q = mysql_query("
|
||||
SELECT eual.* FROM schedule_users_availability_link eual
|
||||
JOIN schedule ON schedule.id = eual.schedule_id
|
||||
JOIN roles ON roles.id = eual.roles_id
|
||||
WHERE eual.users_id=\"{$u['id']}\"
|
||||
AND schedule.conferences_id = {$conference['id']}
|
||||
AND roles.type = 'judge'
|
||||
ORDER BY `schedule`.`date`, `schedule`.`hour`, `schedule`.`minute`
|
||||
");
|
||||
|
||||
while($r = mysql_fetch_assoc($q)) {
|
||||
foreach($times as $x => $t) {
|
||||
if($x == $r['schedule_id']){
|
||||
$sel[] = $x;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$items = array();
|
||||
foreach($times as $x => $t) {
|
||||
$items[$x] = "{$t['name']} ({$t['date']} {$t['starttime']} - {$t['endtime']})";
|
||||
}
|
||||
|
||||
echo '<tr>';
|
||||
user_edit_item($u, 'Time Availability', 'time[]', 'checklist', $items, $sel);
|
||||
echo '</tr>';
|
||||
}
|
||||
?>
|
||||
|
||||
<tr><td style="text-align: left" colspan="2"><br /><b><?=i18n('Judging Questions')?></b><hr /></td></tr>
|
||||
<tr><?=user_edit_item($u, 'I am willing to be the lead for my judging team', 'willing_chair', 'yesno')?></tr>
|
||||
<tr><?=user_edit_item($u, 'Highest post-secondary degree', 'highest_psd', 'textbox')?></tr>
|
||||
|
||||
<?php
|
||||
questions_print_answer_editor('judgereg', $u, 'questions');
|
||||
?>
|
||||
</table>
|
||||
<br />
|
||||
<button><?=i18n("Save Information")?></button>
|
||||
</form>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
function so_judgeother_save()
|
||||
{
|
||||
$("#debug").load("<?=$config['SFIABDIRECTORY']?>/so_judge_other.php?action=save&users_id=<?=$u['id']?>", $("#judgeother_form").serializeArray());
|
||||
return false;
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
$("#judgeother_form").validate({
|
||||
errorPlacement: function(error, element) {
|
||||
if( element.attr('type') == 'checkbox' ) {
|
||||
error.insertAfter( element.parent("span") );
|
||||
} else {
|
||||
error.insertAfter(element);
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
rules: {
|
||||
"languages[]": { required: true },
|
||||
"time[]": { required: <?=in_array('time[]', $required)?'true':'false'?> },
|
||||
},
|
||||
|
||||
messages: {
|
||||
"languages[]": { required: "<?=i18n('Please select the language(s) you can judge in')?>" },
|
||||
"time[]": { required: "<?=i18n('Please select the time(s) you are available for judging')?>" }
|
||||
},
|
||||
submitHandler: function() {
|
||||
so_judgeother_save();
|
||||
return false;
|
||||
},
|
||||
cancelHandler: function() {
|
||||
so_judgeother_save();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
user_update_tab_status('sojudge');
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
|
10
user.inc.php
10
user.inc.php
@ -755,8 +755,14 @@ function user_judge_registration_status()
|
||||
{
|
||||
global $config;
|
||||
$now = date('Y-m-d H:i:s');
|
||||
if($now < $config['dates']['judgeregopen']) return "notopenyet";
|
||||
if($now > $config['dates']['judgeregclose']) return "closed";
|
||||
if(array_key_exists('judgeregopen', $config['dates'])){
|
||||
if($now < $config['dates']['judgeregopen']) return "notopenyet";
|
||||
if($now > $config['dates']['judgeregclose']) return "closed";
|
||||
}
|
||||
if(array_key_exists('regopen', $config['dates'])){
|
||||
if($now < $config['dates']['regopen']) return "notopenyet";
|
||||
if($now > $config['dates']['regclose']) return "closed";
|
||||
}
|
||||
return "open";
|
||||
}
|
||||
|
||||
|
@ -95,7 +95,7 @@ function user_edit_item(&$u, $label, $fname, $type='textbox', $data1=NULL, $data
|
||||
foreach($data1 AS $key=>$txt) {
|
||||
$ch = (in_array($key,$data2)) ? 'checked="checked"' : '';
|
||||
if($x) echo '<br />';
|
||||
echo "<input $ch type=\"checkbox\" name=\"$fname\" value=\"$l\" />$txt";
|
||||
echo "<input $ch type=\"checkbox\" name=\"$fname\" value=\"$key\" />$txt";
|
||||
$x=1;
|
||||
}
|
||||
echo "</span>";
|
||||
|
@ -111,6 +111,14 @@ $tabs = array( 'fairinfo' => array(
|
||||
'types' => array('judge'),
|
||||
'file' => 'judge_other.php',
|
||||
'status_func' => 'judge_status_other',
|
||||
'conference_types' => array('sciencefair'),
|
||||
),
|
||||
'sojudge' => array(
|
||||
'label' => 'Judge',
|
||||
'types' => array('judge'),
|
||||
'file' => 'so_judge_other.php',
|
||||
'status_func' => 'so_judge_status_other',
|
||||
'conference_types' => array('scienceolympics'),
|
||||
),
|
||||
'judgeexpertise' => array(
|
||||
'label' => 'Expertise',
|
||||
@ -172,7 +180,7 @@ if(!array_key_exists($selected, $tabs)) {
|
||||
if(in_array('fair', $types) )
|
||||
$selected = 'fairinfo';
|
||||
else
|
||||
$selected = 'personal';
|
||||
$selected = '';
|
||||
}
|
||||
|
||||
$fields = array();
|
||||
@ -204,6 +212,14 @@ $selected_index = 0;
|
||||
foreach($tabs as $k=>$t) {
|
||||
/* Make sure the tab is enabled */
|
||||
if($t['disabled'] == true) continue;
|
||||
|
||||
// Make sure the tab is applicable to this conference
|
||||
if(array_key_exists('conference_types', $t)){
|
||||
if(!in_array($conference['type'], $t['conference_types'])){
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
/* Make sure the user has the right type to see the tab */
|
||||
$i = array_intersect($t['types'], $types);
|
||||
if(count($i) == 0) {
|
||||
@ -242,6 +258,13 @@ foreach($tabs as $k=>$t) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Make sure the tab is applicable to this conference
|
||||
if(array_key_exists('conference_types', $t)){
|
||||
if(!in_array($conference['type'], $t['conference_types'])){
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
/* Get the status */
|
||||
if(is_callable($t['status_func'])) {
|
||||
$s = call_user_func($t['status_func'], &$u);
|
||||
@ -308,7 +331,7 @@ foreach($tabs as $k=>$t) {
|
||||
|
||||
$(document).ready(function() {
|
||||
$("#tabs").tabs({
|
||||
// selected: <?=$selected_index?>
|
||||
selected: <?=$selected_index?>
|
||||
});
|
||||
|
||||
/* Update each tab for complete/incomplete */
|
||||
@ -347,7 +370,7 @@ function user_update_tab_status(tabkey,newstatus)
|
||||
* of each tab doesn't get out of sync) */
|
||||
var overall = 'complete';
|
||||
for(var key in stat) {
|
||||
if(stat[key] != 'complete') {
|
||||
if(stat[key] != '' && stat[key] != 'complete') {
|
||||
overall = 'incomplete';
|
||||
}
|
||||
}
|
||||
|
@ -214,7 +214,8 @@ function draw_roles(){
|
||||
<button style="width: 100px;" id="activate_<?=$role?>" <?=$a?> onclick="activate('<?=$role?>');return false;" ><?=i18n("Activate")?></button>
|
||||
<button style="width: 100px;" id="deactivate_<?=$role?>" <?=$d?> onclick="deactivate('<?=$role?>');return false;" ><?=i18n("Deactivate")?></button>
|
||||
<button style="width: 100px;" id="remove_<?=$role?>" <?=$d?> onclick="remove('<?=$role?>');return false;" ><?=i18n("Remove")?></button>
|
||||
|
||||
<button style="width: 100px;" id="settings_<?=$role?>" <?=$d?> onclick="location.href='user_edit.php?tab=<?=$role?>';return false;" ><?=i18n("Settings")?></button>
|
||||
|
||||
</td>
|
||||
<?php
|
||||
|
||||
@ -289,7 +290,7 @@ function draw_signup_form($type){
|
||||
break;
|
||||
case 'singlepassword':
|
||||
echo '<p>';
|
||||
echo i18n("{$roles[$type]['name']} Registration is protected by a password. You must know the <b>{$roles[$type]['name']} Registration Password</b> in order to create an account. Please contact the committee to obtain the password if you wish to register.");
|
||||
echo i18n("{$roles[$type]['name']} Registration is protected by a password. You must know the <b>{$roles[$type]['name']} Registration Password</b> in order to register for this role. Please contact the committee to obtain the password if you wish to register.");
|
||||
echo "</p><p>";
|
||||
echo i18n("{$roles[$type]['name']} Password").":<input type=\"password\" size=\"20\" id=\"{$type}_password\" />";
|
||||
echo "<button onclick=\"register('" . $type . "');\">Register</button>";
|
||||
|
Loading…
Reference in New Issue
Block a user