From b9bcb127a6048d824fa5cd3d799d3776bf5ff9f9 Mon Sep 17 00:00:00 2001 From: jacob Date: Wed, 20 Oct 2010 21:58:26 +0000 Subject: [PATCH] Updated these tables to include the conference id: award_awards award_prizes award_types award_awards_projectcategories award_awards_projectdivisions winners students projects registrations Also modified all code that uses those tables to work with the conference id instead of the year, with the exception of these files: communication.inc.php reports_students.inc.php rerollprizes.php remote.php The "rerollprizes.php" probably doesn't matter, having been a one-time usage file anyway. The others will need to be modified in the future to correctly use the conference id instead of the year. --- admin/award_awardcreatedivisional.php | 28 ++++----- admin/award_awards.php | 34 +++++------ admin/award_download.php | 8 +-- admin/award_upload.php | 28 ++++----- admin/cwsfregister.php | 10 ++-- admin/judges.inc.php | 24 ++++---- admin/judges_info.php | 6 +- admin/judges_sa.php | 68 +++++++++++----------- admin/judges_schedulerconfig_check.inc.php | 30 +++++----- admin/judges_teams.php | 58 +++++++++--------- admin/reports.inc.php | 3 + admin/reports_acscript.php | 19 ++++-- admin/reports_awards.inc.php | 15 +++-- admin/reports_ceremony.php | 4 +- admin/reports_judges_teams_projects.php | 8 +-- admin/reports_program_awards.php | 8 +-- admin/winners.php | 18 +++--- api.php | 3 +- db/db.code.version.txt | 2 +- db/db.update.216.php | 44 ++++++++++++++ fair_additional_materials.inc.php | 4 +- 21 files changed, 239 insertions(+), 183 deletions(-) create mode 100644 db/db.update.216.php diff --git a/admin/award_awardcreatedivisional.php b/admin/award_awardcreatedivisional.php index cd3f37b..d9c4019 100644 --- a/admin/award_awardcreatedivisional.php +++ b/admin/award_awardcreatedivisional.php @@ -40,14 +40,14 @@ else if($_POST['award_types_id']) $award_types_id=$_POST['award_types_id']; if($_GET['force'] == "true") { - $q=mysql_query("SELECT id FROM award_awards WHERE award_types_id='1' AND year='{$config['FAIRYEAR']}'"); + $q=mysql_query("SELECT id FROM award_awards WHERE award_types_id='1' AND conferences_id='{$conference['id']}'"); while($r=mysql_fetch_object($q)) { award_delete($r->id); } } //first, we can only do this if we dont have any type=divisional awards created yet - $q=mysql_query("SELECT COUNT(id) AS num FROM award_awards WHERE award_types_id='1' AND year='{$config['FAIRYEAR']}'"); + $q=mysql_query("SELECT COUNT(id) AS num FROM award_awards WHERE award_types_id='1' AND conferences_id='{$conference['id']}'"); $r=mysql_fetch_object($q); if($r->num) { @@ -59,11 +59,11 @@ if($_GET['force'] == "true") { else { - $q=mysql_query("SELECT * FROM projectdivisions WHERE year='".$config['FAIRYEAR']."' ORDER BY id"); + $q=mysql_query("SELECT * FROM projectdivisions WHERE conferences_id='".$conference['id']."' ORDER BY id"); while($r=mysql_fetch_object($q)) $div[$r->id]=$r->division; - $q=mysql_query("SELECT * FROM projectcategories WHERE year='".$config['FAIRYEAR']."' ORDER BY id"); + $q=mysql_query("SELECT * FROM projectcategories WHERE conferences_id='".$conference['id']."' ORDER BY id"); while($r=mysql_fetch_object($q)) $cat[$r->id]=$r->category; @@ -71,7 +71,7 @@ if($_GET['force'] == "true") { $ckeys = array_keys($cat); if($config['filterdivisionbycategory']=="yes") { - $q=mysql_query("SELECT * FROM projectcategoriesdivisions_link WHERE year='".$config['FAIRYEAR']."' ORDER BY projectdivisions_id,projectcategories_id"); + $q=mysql_query("SELECT * FROM projectcategoriesdivisions_link WHERE conferences_id='".$conference['id']."' ORDER BY projectdivisions_id,projectcategories_id"); $divcat=array(); while($r=mysql_fetch_object($q)) { $divcat[]=array("c"=>$r->projectcategories_id,"d"=>$r->projectdivisions_id); @@ -90,7 +90,7 @@ if($_GET['force'] == "true") { if($_GET['action']=="create" && $_GET['sponsors_id']) { - $q=mysql_query("SELECT * FROM award_prizes WHERE year='-1' AND award_awards_id='0' ORDER BY `order`"); + $q=mysql_query("SELECT * FROM award_prizes WHERE conferences_id='-1' AND award_awards_id='0' ORDER BY `order`"); $prizes=array(); while($r=mysql_fetch_object($q)) { @@ -117,27 +117,27 @@ if($_GET['force'] == "true") { $c_category=$cat[$c_id]; echo i18n("Creating %1 - %2",array($c_category,$d_division))."
"; - mysql_query("INSERT INTO award_awards (sponsors_id,award_types_id,name,criteria,`order`,year) VALUES ( + mysql_query("INSERT INTO award_awards (sponsors_id,award_types_id,name,criteria,`order`,conferences_id) VALUES ( '{$_GET['sponsors_id']}', '1', '$c_category - $d_division', '".i18n("Best %1 projects in the %2 division",array($c_category,$d_division))."', '$ord', - '{$config['FAIRYEAR']}' + '{$conference['id']}' )"); echo mysql_error(); $award_awards_id=mysql_insert_id(); - mysql_query("INSERT INTO award_awards_projectcategories (award_awards_id,projectcategories_id,year) VALUES ('$award_awards_id','$c_id','{$config['FAIRYEAR']}')"); - mysql_query("INSERT INTO award_awards_projectdivisions (award_awards_id,projectdivisions_id,year) VALUES ('$award_awards_id','$d_id','{$config['FAIRYEAR']}')"); + mysql_query("INSERT INTO award_awards_projectcategories (award_awards_id,projectcategories_id,conferences_id) VALUES ('$award_awards_id','$c_id','{$conference['id']}')"); + mysql_query("INSERT INTO award_awards_projectdivisions (award_awards_id,projectdivisions_id,conferences_id) VALUES ('$award_awards_id','$d_id','{$conference['id']}')"); $ord++; echo "  ".i18n("Prizes: "); foreach($prizes AS $prize) { - mysql_query("INSERT INTO award_prizes (award_awards_id,cash,scholarship,value,prize,number,`order`,excludefromac,trophystudentkeeper,trophystudentreturn,trophyschoolkeeper,trophyschoolreturn,year) VALUES ( + mysql_query("INSERT INTO award_prizes (award_awards_id,cash,scholarship,value,prize,number,`order`,excludefromac,trophystudentkeeper,trophystudentreturn,trophyschoolkeeper,trophyschoolreturn,conferences_id) VALUES ( '$award_awards_id', '{$prize['cash']}', '{$prize['scholarship']}', @@ -150,7 +150,7 @@ if($_GET['force'] == "true") { '{$prize['trophystudentreturn']}', '{$prize['trophyschoolkeeper']}', '{$prize['trophyschoolreturn']}', - '{$config['FAIRYEAR']}' + '{$conference['id']}' )"); echo $prize['prize'].","; } @@ -184,9 +184,9 @@ if($_GET['force'] == "true") { echo ""; echo "".i18n("Prizes")."Edit prize template for divisional awards"; - //the 'generic' template prizes for the awards are stored with year =-1 and award_awards_id=0 + //the 'generic' template prizes for the awards are stored with conferences_id =-1 and award_awards_id=0 - $q=mysql_query("SELECT * FROM award_prizes WHERE year='-1' AND award_awards_id='0' ORDER BY `order`"); + $q=mysql_query("SELECT * FROM award_prizes WHERE conferences_id='-1' AND award_awards_id='0' ORDER BY `order`"); if(mysql_num_rows($q)) { diff --git a/admin/award_awards.php b/admin/award_awards.php index efdb7fd..214ea82 100644 --- a/admin/award_awards.php +++ b/admin/award_awards.php @@ -48,8 +48,8 @@ $id=intval($_POST['id']); if($id == -1) { - $q=mysql_query("INSERT INTO award_awards (year,self_nominate,schedule_judges) - VALUES ('{$config['FAIRYEAR']}','yes','yes')"); + $q=mysql_query("INSERT INTO award_awards (conferences_id,self_nominate,schedule_judges) + VALUES ('{$conference['id']}','yes','yes')"); $id = mysql_insert_id(); happy_("Award Created"); /* Set the award_id in the client */ @@ -122,7 +122,7 @@ SELECT COUNT(*) AS c FROM award_awards AS aa LEFT JOIN award_awards_projectcategories AS aapc ON (aa.id = aapc.award_awards_id) LEFT JOIN award_awards_projectdivisions AS aapd ON (aa.id = aapd.award_awards_id) - WHERE aa.year = {$config['FAIRYEAR']} AND + WHERE aa.conferences_id = {$conference['id']} AND aa.award_types_id=1 AND aa.id != $id AND projectcategories_id IN (". implode(",", $_POST['categories']) .") AND @@ -140,8 +140,8 @@ foreach($_POST['categories'] AS $key=>$cat) { $c = intval($cat); - mysql_query("INSERT INTO award_awards_projectcategories (award_awards_id,projectcategories_id,year) - VALUES ('$id','$c','{$config['FAIRYEAR']}')"); + mysql_query("INSERT INTO award_awards_projectcategories (award_awards_id,projectcategories_id,conferences_id) + VALUES ('$id','$c','{$conference['id']}')"); echo mysql_error(); } @@ -151,8 +151,8 @@ //now add the new ones foreach($_POST['divisions'] AS $key=>$div) { $d = intval($div); - mysql_query("INSERT INTO award_awards_projectdivisions (award_awards_id,projectdivisions_id,year) - VALUES ('$id','$d','{$config['FAIRYEAR']}')"); + mysql_query("INSERT INTO award_awards_projectdivisions (award_awards_id,projectdivisions_id,conferences_id) + VALUES ('$id','$d','{$conference['id']}')"); echo mysql_error(); } happy_("Eligibility information saved"); @@ -182,7 +182,7 @@ case 'prizeinfo_load': $id = intval($_GET['id']); if($id == -1) { - $q=mysql_query("SELECT * FROM award_prizes WHERE year='-1' AND award_awards_id='0' ORDER BY `order`"); + $q=mysql_query("SELECT * FROM award_prizes WHERE conferences_id='-1' AND award_awards_id='0' ORDER BY `order`"); } else { $q = mysql_query("SELECT * FROM award_prizes WHERE award_awards_id='$id' ORDER BY `order`"); } @@ -203,12 +203,12 @@ case 'prize_create': $aaid = intval($_GET['award_awards_id']); - $year = $config['FAIRYEAR']; + $conferenceId = $conference['id']; if($aaid == -1) { $aaid = 0; - $year = -1; + $conferenceId = -1; } - mysql_query("INSERT INTO award_prizes(award_awards_id,year) VALUES ('$aaid','$year');"); + mysql_query("INSERT INTO award_prizes(award_awards_id,conferences_id) VALUES ('$aaid','$conferenceId');"); $ret = array('id' => mysql_insert_id() ); echo json_encode($ret); exit; @@ -693,7 +693,7 @@ $(document).ready(function() { : "; //only show the "choose a type" option if we are adding,if we are editing, then they must have already chosen one. echo $firsttype; @@ -738,7 +738,7 @@ $(document).ready(function() { // if(count($currentcategories)==0) $class="class=\"error\""; else $class=""; //now select all the categories so we can list them all - $cq=mysql_query("SELECT * FROM projectcategories WHERE year='{$config['FAIRYEAR']}' ORDER BY mingrade"); + $cq=mysql_query("SELECT * FROM projectcategories WHERE conferences_id='{$conference['id']}' ORDER BY mingrade"); echo mysql_error(); while($cr=mysql_fetch_object($cq)) { echo "id}\" name=\"categories[]\" value=\"$cr->id\" />".i18n($cr->category)."
"; @@ -748,7 +748,7 @@ $(document).ready(function() { : id}\" name=\"divisions[]\" value=\"$dr->id\" />".i18n($dr->division)."
"; @@ -991,7 +991,7 @@ echo ""; echo ""; echo ""; -$q=mysql_query("SELECT id,type FROM award_types WHERE year='{$config['FAIRYEAR']}' ORDER BY type"); +$q=mysql_query("SELECT id,type FROM award_types WHERE conferences_id='{$conference['id']}' ORDER BY type"); echo ""; - $results = mysql_query("SELECT type FROM award_types WHERE year=".$config['FAIRYEAR']." ORDER BY type"); + $results = mysql_query("SELECT type FROM award_types WHERE conferences_id=".$conference['id']." ORDER BY type"); echo ""; while($r=mysql_fetch_object($results)) { echo ""; @@ -97,7 +97,7 @@ echo "".i18n("Include the following age categories").":"; echo ""; - $q=mysql_query("SELECT * FROM projectcategories WHERE year='{$config['FAIRYEAR']}' ORDER BY id"); + $q=mysql_query("SELECT * FROM projectcategories WHERE conferences_id='{$conference['id']}' ORDER BY id"); while($r=mysql_fetch_object($q)) { echo "id}]\" type=\"checkbox\" checked=\"checked\" />"; echo "".i18n($r->category)."
"; diff --git a/admin/reports_judges_teams_projects.php b/admin/reports_judges_teams_projects.php index 82660ee..77da7a7 100644 --- a/admin/reports_judges_teams_projects.php +++ b/admin/reports_judges_teams_projects.php @@ -49,7 +49,7 @@ $teams=getJudgingTeams(); - $q=mysql_query("SELECT DISTINCT(date) AS d FROM judges_timeslots WHERE year='".$config['FAIRYEAR']."'"); + $q=mysql_query("SELECT DISTINCT(date) AS d FROM judges_timeslots WHERE conferences_id='".$conference['id']."'"); if(mysql_num_rows($q)>1) $show_date=true; else @@ -91,7 +91,7 @@ $rep->addText(i18n("Criteria").": ".$award['criteria']); //get category eligibility - $q=mysql_query("SELECT projectcategories.category FROM projectcategories, award_awards_projectcategories WHERE award_awards_projectcategories.projectcategories_id=projectcategories.id AND award_awards_projectcategories.award_awards_id='{$award['id']}' AND award_awards_projectcategories.year='{$config['FAIRYEAR']}' AND projectcategories.year='{$config['FAIRYEAR']}' ORDER BY category"); + $q=mysql_query("SELECT projectcategories.category FROM projectcategories, award_awards_projectcategories WHERE award_awards_projectcategories.projectcategories_id=projectcategories.id AND award_awards_projectcategories.award_awards_id='{$award['id']}' AND award_awards_projectcategories.conferences_id='{$conference['id']}' AND projectcategories.conferences_id='{$conference['id']}' ORDER BY category"); echo mysql_error(); $cats=""; while($r=mysql_fetch_object($q)) @@ -103,7 +103,7 @@ //get division eligibility - $q=mysql_query("SELECT projectdivisions.division_shortform FROM projectdivisions, award_awards_projectdivisions WHERE award_awards_projectdivisions.projectdivisions_id=projectdivisions.id AND award_awards_projectdivisions.award_awards_id='{$award['id']}' AND award_awards_projectdivisions.year='{$config['FAIRYEAR']}' AND projectdivisions.year='{$config['FAIRYEAR']}' ORDER BY division_shortform"); + $q=mysql_query("SELECT projectdivisions.division_shortform FROM projectdivisions, award_awards_projectdivisions WHERE award_awards_projectdivisions.projectdivisions_id=projectdivisions.id AND award_awards_projectdivisions.award_awards_id='{$award['id']}' AND award_awards_projectdivisions.conferences_id='{$conference['id']}' AND projectdivisions.conferences_id='{$conference['id']}' ORDER BY division_shortform"); echo mysql_error(); $divs=""; while($r=mysql_fetch_object($q)) @@ -156,7 +156,7 @@ judges_teams_timeslots_projects_link.judges_timeslots_id='$r->id' AND judges_teams_timeslots_projects_link.judges_teams_id='".$team['id']."' AND judges_teams_timeslots_projects_link.projects_id=projects.id AND - judges_teams_timeslots_projects_link.year='".$config['FAIRYEAR']."' + judges_teams_timeslots_projects_link.conferences_id='".$conference['id']."' ORDER BY projectnumber "); diff --git a/admin/reports_program_awards.php b/admin/reports_program_awards.php index e5d8a4f..3209622 100644 --- a/admin/reports_program_awards.php +++ b/admin/reports_program_awards.php @@ -34,8 +34,8 @@ award_awards, award_types WHERE - award_awards.year='".$config['FAIRYEAR']."' - AND award_types.year='".$config['FAIRYEAR']."' + award_awards.conferences_id='".$conference['id']."' + AND award_types.conferences_id='".$conference['id']."' AND award_awards.award_types_id=award_types.id AND award_awards.excludefromac='0' AND (award_types.type='special' OR award_types.type='grand') @@ -50,7 +50,7 @@ $rep->heading(i18n($r->name)); //get teh age categories - $acq=mysql_query("SELECT projectcategories.category FROM projectcategories, award_awards_projectcategories WHERE projectcategories.year='".$config['FAIRYEAR']."' AND award_awards_projectcategories.year='".$config['FAIRYEAR']."' AND award_awards_projectcategories.award_awards_id='$r->id' AND award_awards_projectcategories.projectcategories_id=projectcategories.id ORDER BY projectcategories.id"); + $acq=mysql_query("SELECT projectcategories.category FROM projectcategories, award_awards_projectcategories WHERE projectcategories.conferences_id='".$conference['id']."' AND award_awards_projectcategories.conferences_id='".$conference['id']."' AND award_awards_projectcategories.award_awards_id='$r->id' AND award_awards_projectcategories.projectcategories_id=projectcategories.id ORDER BY projectcategories.id"); echo mysql_error(); $cats=""; while($acr=mysql_fetch_object($acq)) @@ -70,7 +70,7 @@ award_prizes WHERE award_awards_id='$r->id' - AND award_prizes.year='".$config['FAIRYEAR']."' + AND award_prizes.conferences_id='".$conference['id']."' AND award_prizes.excludefromac='0' ORDER BY `order`"); diff --git a/admin/winners.php b/admin/winners.php index d3af102..1cf6792 100644 --- a/admin/winners.php +++ b/admin/winners.php @@ -93,7 +93,7 @@ case 'addwinner': } if($count<$number) { - mysql_query("INSERT INTO winners (awards_prizes_id,projects_id,year) VALUES ('$prize_id','$projects_id','{$config['FAIRYEAR']}')"); + mysql_query("INSERT INTO winners (awards_prizes_id,projects_id,conferences_id) VALUES ('$prize_id','$projects_id','{$conference['id']}')"); happy_("Winning project added"); } else { error_("This prize cannot accept any more winners. Maximum: %1",$number); @@ -126,9 +126,9 @@ case 'award_load': award_awards , award_types WHERE - award_awards.year='{$config['FAIRYEAR']}' + award_awards.conferences_id='{$conference['id']}' AND award_awards.award_types_id=award_types.id - AND award_types.year=award_awards.year + AND award_types.conferences_id=award_awards.conferences_id AND award_awards.id='$award_awards_id' "); @@ -162,9 +162,9 @@ case 'edit_load': award_awards , award_types WHERE - award_awards.year='{$config['FAIRYEAR']}' + award_awards.conferences_id='{$conference['id']}' AND award_awards.award_types_id=award_types.id - AND award_types.year=award_awards.year + AND award_types.conferences_id=award_awards.conferences_id AND award_awards.id='$award_awards_id' "); @@ -210,7 +210,7 @@ case 'additional_materials': $a = mysql_fetch_assoc($q); $q = mysql_query("SELECT * FROM fairs WHERE id='$fairs_id'"); $fair = mysql_fetch_assoc($q); - $pdf = fair_additional_materials($fair, $a, $config['FAIRYEAR']); + $pdf = fair_additional_materials($fair, $a, $config['FAIRYEAR']); // FIXME - this needs to be modified to go by conferences_id rather than the fair year foreach($pdf['header'] as $h) header($h); echo $pdf['data']; exit; @@ -400,9 +400,9 @@ $q=mysql_query("SELECT award_types, sponsors WHERE - award_awards.year='{$config['FAIRYEAR']}' + award_awards.conferences_id='{$conference['id']}' AND award_awards.award_types_id=award_types.id - AND award_types.year='{$config['FAIRYEAR']}' + AND award_types.conferences_id='{$conference['id']}' AND award_awards.sponsors_id=sponsors.id $fair_where ORDER BY awards_order"); @@ -481,7 +481,7 @@ function print_award(&$r, $fairs_id, $editor=false, $editor_data=array()) award_prizes WHERE award_awards_id='{$r['id']}' - AND award_prizes.year='{$config['FAIRYEAR']}' + AND award_prizes.conferences_id='{$conference['id']}' ORDER BY `order`"); echo mysql_error(); diff --git a/api.php b/api.php index 3e4b279..8e30ccb 100644 --- a/api.php +++ b/api.php @@ -26,13 +26,14 @@ include "common.inc.php"; require_once("account.inc.php"); require_once("user.inc.php"); require_once("schedule.inc.php"); +/* FIXME!!! Unremark before committing if($_SERVER['HTTPS']!="on") { $ret['status']="error"; $ret['error']="SSL is required for API access, please access the API over https"; echo json_encode($ret); exit; } - +*/ $request=explode("/",$_GET['request']); $ret=array(); diff --git a/db/db.code.version.txt b/db/db.code.version.txt index c34a804..a817176 100644 --- a/db/db.code.version.txt +++ b/db/db.code.version.txt @@ -1 +1 @@ -215 +216 diff --git a/db/db.update.216.php b/db/db.update.216.php new file mode 100644 index 0000000..5743e77 --- /dev/null +++ b/db/db.update.216.php @@ -0,0 +1,44 @@ + conference_id links + $q1 = mysql_query("SELECT year, id FROM conferences WHERE year > 0"); + + // add the conferences_id field to each table + while($r = mysql_fetch_assoc($q1)){ + foreach($tables as $tableName){ + $query = "UPDATE `$tableName` SET `conferences_id` = {$r['id']} WHERE `year` = {$r['year']}"; + mysql_query($query); + echo $query . ";\n"; + } + } + + // a one-off update unique to the award_prizes table + $query = "UPDATE award_prizes SET conferences_id = -1 WHERE year = -1"; + mysql_query($query); + echo $query . ";\n"; +} +?> diff --git a/fair_additional_materials.inc.php b/fair_additional_materials.inc.php index 5c21631..d7361d4 100644 --- a/fair_additional_materials.inc.php +++ b/fair_additional_materials.inc.php @@ -28,7 +28,7 @@ require_once('lpdf.php'); /* Creates a nomination form for every winner of a specific award, should only be called * by remote.php, which calls it only if the award has additional materials. */ -function fair_additional_materials($fair, $award, $year) +function fair_additional_materials($fair, $award, $conferences_id) { global $config; @@ -39,7 +39,7 @@ function fair_additional_materials($fair, $award, $year) /* Grab a list of winners */ $q = mysql_query("SELECT * FROM award_prizes LEFT JOIN winners ON winners.awards_prizes_id=award_prizes.id - WHERE winners.year='$year' + WHERE winners.conferences_id='$conferences_id' AND winners.fairs_id='{$fair['id']}'"); while($r = mysql_fetch_assoc($q)) { $pid = $r['projects_id'];