From 881d6b9be4efd4f76e1ffdbeb37cfb286f7cf776 Mon Sep 17 00:00:00 2001 From: dave Date: Sun, 2 Nov 2008 06:15:05 +0000 Subject: [PATCH] - fix the message in the config editor - add a convenience $user['name'] setting - update the judge SA --- admin/judges_sa.php | 149 ++++++++++++------------------------------ config_editor.inc.php | 13 +--- user.inc.php | 3 + 3 files changed, 47 insertions(+), 118 deletions(-) diff --git a/admin/judges_sa.php b/admin/judges_sa.php index 748d6e9..1de7221 100644 --- a/admin/judges_sa.php +++ b/admin/judges_sa.php @@ -22,12 +22,12 @@ */ ?> id' ". - " AND year='".$config['FAIRYEAR']."'"); - if(mysql_num_rows($q2) != 0) { - TRACE(" {$r->firstname} {$r->lastname} is already on a judging team, skipping.\n"); +foreach($judges as $j) { + $q = mysql_query("SELECT users_id FROM judges_teams_link WHERE + users_id='{$j['id']}' + AND year='{$config['FAIRYEAR']}'"); + if(mysql_num_rows($q) != 0) { + TRACE(" {$j['name']} is already on a judging team, skipping.\n"); + unset($judges[$j['id']]); continue; } - //get category preferences - $q2=mysql_query("SELECT * FROM judges_catpref WHERE judges_id='$r->id' AND year='".$config['FAIRYEAR']."' ORDER BY projectcategories_id"); - $catprefs=array(); - while($r2=mysql_fetch_object($q2)) - $catprefs[$r2->projectcategories_id]=$r2->rank; - - //get division preferences - $q2=mysql_query("SELECT * FROM judges_expertise WHERE judges_id='$r->id' AND year='".$config['FAIRYEAR']."' AND projectsubdivisions_id IS NULL ORDER BY projectdivisions_id"); - //the areas of expertise are ranked from 1 to 5, and we need them as -2,-1,0,1,2 so we simply subtract 3 - $divprefs=array(); - while($r2=mysql_fetch_object($q2)) - $divprefs[$r2->projectdivisions_id]=$r2->val-3; - - $langprefs = array(); - $q3=mysql_query("SELECT * from judges_languages WHERE judges_id='$r->id'"); - while($r3=mysql_fetch_object($q3)) - $langprefs[]=$r3->languages_lang; - - $q2 = mysql_query("SELECT answer FROM question_answers WHERE ". - " registrations_id='{$r->id}' AND ". - " questions_id='$willing_chair_question_id' AND ". - " year='{$config['FAIRYEAR']}' "); - mysql_error(); - $willing_chair = 'no'; - if(mysql_num_rows($q2) == 1) { - $r2 = mysql_fetch_object($q2); - if($r2->answer == 'yes') $willing_chair = 'yes'; - } - - $sa_only = 'no'; - if($r->typepref == 'speconly') $sa_only = 'yes'; - $sa_sel = array(); - - - if($sa_only == 'yes') { - TRACE("Judge [{$r->firstname} {$r->lastname}] is a special awards only.\n"); + if($j['special_award_only'] == 'yes') { + $sa_sel = array(); + TRACE("Judge {$j['name']} is a special awards only.\n"); /* Find their special award id */ - $qq = mysql_query("SELECT award_awards.id,award_awards.name FROM + $q = mysql_query("SELECT award_awards.id,award_awards.name FROM judges_specialaward_sel,award_awards WHERE award_awards.id=judges_specialaward_sel.award_awards_id - AND judges_specialaward_sel.judges_id='{$r->id}' - AND judges_specialaward_sel.year='{$config['FAIRYEAR']}' + AND judges_specialaward_sel.users_id='{$j['id']}' AND award_awards.year='{$config['FAIRYEAR']}'"); echo mysql_error(); - if(mysql_num_rows($qq) == 0) { + if(mysql_num_rows($q) == 0) { TRACE(" - NO special award selected! (removing special award only request)\n"); - $sa_only = 'no'; - } else if(mysql_num_rows($qq) > 1) { + $judges[$j['id']]['special_award_only'] = 'no'; + } else if(mysql_num_rows($q) > 1) { TRACE(" - More than ONE special award selected (removing special award only request):\n"); - $sa_only = 'no'; - } - while($rr = mysql_fetch_object($qq)) { - TRACE(" ".$rr->name."\n"); - $sa_sel[] = $rr->id; - } + $judges[$j['id']]['special_award_only'] = 'no'; + } } - $j=array( - "judges_id"=>"$r->id", - "name"=>"$r->firstname $r->lastname", - "years_school"=>$r->years_school, - "years_regional"=>$r->years_regional, - "years_national"=>$r->years_national, - "willing_chair"=>$willing_chair, - "divprefs"=>$divprefs, - "catprefs"=>$catprefs, - "languages"=>$langprefs, - "sa_only"=>$sa_only, - "sa_sel"=>$sa_sel, - ); - - /* If it's a special award only judge, keep them - * out of the judges list for the divisional annealer */ - if($sa_only == 'yes') { - $sa_judges[$r->id] = $j; - } else { - $judges[$r->id] = $j; + $judges[$j['id']]['special_awards'] = array(); + while($r = mysql_fetch_object($q)) { + TRACE(" {$r->name}\n"); + /* Add them to the SA judge list (modify the actual list, not + * $j, which is a copy */ + $judges[$j['id']]['special_awards'][] = $r->id; } - + if($j['special_award_only'] == 'yes') { + /* Add to sa judge list, remove from the eligible judge list */ + $sa_judges[$j['id']] = $judges[$j['id']]; + unset($judges[$j['id']]); + } } -TRACE("Loaded ".count($judges)." judges.\n"); + +TRACE("Loaded ".count($judges)." judges, and ".count($sa_judges)." special-award-only judges.\n"); $jteam[0]['max_judges'] = count($judges); @@ -560,18 +501,14 @@ function pr_judge(&$jt, $jid) { global $judges; $j =& $judges[$jid]; - print(" - {$j['name']} ("); - for($x=0; $x