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.
This commit is contained in:
jacob 2010-10-20 21:58:26 +00:00
parent 78bf0c8751
commit b9bcb127a6
21 changed files with 239 additions and 183 deletions

View File

@ -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))."<br />";
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 "&nbsp;&nbsp;".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 "</td></tr>";
echo "<tr><td>".i18n("Prizes")."</td><td><a href=\"award_awards.php?action=edit_prize_template\">Edit prize template for divisional awards</a>";
//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))
{

View File

@ -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() {
</td></tr>
<tr><td><?=i18n("Type")?>:</td><td>
<?
$tq=mysql_query("SELECT id,type FROM award_types WHERE year='{$config['FAIRYEAR']}' ORDER BY type");
$tq=mysql_query("SELECT id,type FROM award_types WHERE conferences_id='{$conference['id']}' ORDER BY type");
echo "<select id=\"awardinfo_award_types_id\" name=\"award_types_id\">";
//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 "<input type=\"checkbox\" id=\"eligibility_categories_{$cr->id}\" name=\"categories[]\" value=\"$cr->id\" />".i18n($cr->category)."<br />";
@ -748,7 +748,7 @@ $(document).ready(function() {
<tr><td><?=i18n("Divisions")?>:</td><td>
<?
$dq=mysql_query("SELECT * FROM projectdivisions WHERE year='{$config['FAIRYEAR']}' ORDER BY division");
$dq=mysql_query("SELECT * FROM projectdivisions WHERE conferences_id='{$conference['id']}' ORDER BY division");
echo mysql_error();
while($dr=mysql_fetch_object($dq)) {
echo "<input type=\"checkbox\" id=\"eligibility_divisions_{$dr->id}\" name=\"divisions[]\" value=\"$dr->id\" />".i18n($dr->division)."<br />";
@ -991,7 +991,7 @@ echo "</select>";
echo "</td></tr>";
echo "<tr><td>";
$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 "<select name=\"award_types_id\" onchange=\"document.forms.filterchange.submit()\">";
echo "<option value=\"all\">".i18n("All Award Types")."</option>";
while($r=mysql_fetch_object($q)) {
@ -1072,10 +1072,10 @@ function draw_awards_table(){
LEFT JOIN sponsors ON sponsors.id = award_awards.sponsors_id
LEFT JOIN award_types ON award_types.id = award_awards.award_types_id
WHERE
award_awards.year='{$config['FAIRYEAR']}'
award_awards.conferences_id='{$conference['id']}'
$where_asi
$where_ati
AND award_types.year='{$config['FAIRYEAR']}'
AND award_types.conferences_id='{$conference['id']}'
ORDER BY `$orderby`");
echo mysql_error();

View File

@ -71,7 +71,7 @@ case 'check':
}
//get a list of all the existing awards for this external source
$aq=mysql_query("SELECT * FROM award_awards WHERE award_source_fairs_id='$fairs_id' AND year='{$config['FAIRYEAR']}'");
$aq=mysql_query("SELECT * FROM award_awards WHERE award_source_fairs_id='$fairs_id' AND conferences_id='{$conference['id']}'");
$existingawards=array();
while($ar=mysql_fetch_object($aq)) {
$existingawards[$ar->id] = true;
@ -109,7 +109,7 @@ case 'check':
$tq=mysql_query("SELECT * FROM award_awards WHERE
external_identifier='$identifier' AND
award_source_fairs_id='$fairs_id' AND
year='$year'");
conferences_id='{$conference['id']}'");
if(mysql_num_rows($tq) == 0) {
/* Award doesn't exist, create it, then update it with the common code below */
mysql_query("INSERT INTO award_awards (award_types_id,
@ -121,9 +121,9 @@ case 'check':
$award_id=mysql_insert_id();
/* By default make all divs/cats eligible */
foreach($divs as $id=>$d)
mysql_query("INSERT INTO award_awards_projectdivisions(award_awards_id,projectdivisions_id,year) VALUES ('$award_id','$id','{$config['FAIRYEAR']}')");
mysql_query("INSERT INTO award_awards_projectdivisions(award_awards_id,projectdivisions_id,conferences_id) VALUES ('$award_id','$id','{$conference['id']}')");
foreach($cats as $id=>$c)
mysql_query("INSERT INTO award_awards_projectcategories(award_awards_id,projectcategories_id,year) VALUES ('$award_id','$id','{$config['FAIRYEAR']}')");
mysql_query("INSERT INTO award_awards_projectcategories(award_awards_id,projectcategories_id,conferences_id) VALUES ('$award_id','$id','{$conference['id']}')");
} else {
echo i18n("Award already exists, updating info")."<br />";
$awardrecord=mysql_fetch_object($tq);

View File

@ -68,7 +68,7 @@ function get_winners($awardid, $fairs_id)
$awards = array();
if($awardid == -1) {
/* Get all for this fair */
$q=mysql_query("SELECT * FROM award_awards WHERE award_source_fairs_id='$fairs_id' AND year='{$config['FAIRYEAR']}'");
$q=mysql_query("SELECT * FROM award_awards WHERE award_source_fairs_id='$fairs_id' AND conferences_id='{$conference['id']}'");
if(mysql_num_rows($q) == 0) {
error_("Can't find award id $awardid");
return false;
@ -78,7 +78,7 @@ function get_winners($awardid, $fairs_id)
}
} else {
/* Get the award */
$q=mysql_query("SELECT * FROM award_awards WHERE id='$awardid' AND year='{$config['FAIRYEAR']}'");
$q=mysql_query("SELECT * FROM award_awards WHERE id='$awardid' AND conferences_id='{$conference['id']}'");
if(mysql_num_rows($q)!=1) {
error_("Can't find award id $awardid");
return false;
@ -98,7 +98,7 @@ function get_winners($awardid, $fairs_id)
$winners=array( 'id' => $award['id'],
'award_name' => $award['name'],
'external_identifier' => $award['external_identifier'],
'year' => $config['FAIRYEAR'],
'year' => $config['FAIRYEAR'], // FIXME - this needs to be updated to use conference id's
'prizes' => array());
if($fair['type'] != 'sfiab') {
@ -115,7 +115,7 @@ function get_winners($awardid, $fairs_id)
LEFT JOIN projects ON projects.id=winners.projects_id
WHERE
awards_prizes_id='$pid' AND
winners.year='{$config['FAIRYEAR']}'");
winners.conferences_id='{$conference['id']}'");
echo mysql_error();
/* Get all projects assigned to this prize */
$prizewinners = array();
@ -123,7 +123,7 @@ function get_winners($awardid, $fairs_id)
/* Get the students */
$sq=mysql_query("SELECT * FROM students WHERE registrations_id='{$project['registrations_id']}'
AND year='{$config['FAIRYEAR']}'");
AND conferences_id='{$conference['id']}'");
$students=array();
while($s=mysql_fetch_assoc($sq)) {
@ -179,7 +179,7 @@ function count_winners($awardid, $fairs_id)
$awards = array();
if($awardid == -1) {
/* Get all for this fair */
$q=mysql_query("SELECT * FROM award_awards WHERE award_source_fairs_id='$fairs_id' AND year='{$config['FAIRYEAR']}'");
$q=mysql_query("SELECT * FROM award_awards WHERE award_source_fairs_id='$fairs_id' AND conferences_id='{$conference['id']}'");
if(mysql_num_rows($q) == 0) {
error_("Can't find award id $awardid");
return 0;
@ -189,7 +189,7 @@ function count_winners($awardid, $fairs_id)
}
} else {
/* Get the award */
$q=mysql_query("SELECT * FROM award_awards WHERE id='$awardid' AND year='{$config['FAIRYEAR']}'");
$q=mysql_query("SELECT * FROM award_awards WHERE id='$awardid' AND conferences_id='{$conference['id']}'");
if(mysql_num_rows($q)!=1) {
error_("Can't find award id $awardid");
return 0;
@ -208,7 +208,7 @@ function count_winners($awardid, $fairs_id)
LEFT JOIN projects ON projects.id=winners.projects_id
WHERE
awards_prizes_id='$pid' AND
winners.year='{$config['FAIRYEAR']}'");
winners.conferences_id='{$conference['id']}'");
$wc = mysql_fetch_assoc($wq);
$count += $wc['C'];
}
@ -224,7 +224,7 @@ function load_server_cats_divs($fairs_id)
$q = mysql_query("SELECT * FROM fairs WHERE id='$fairs_id'");
$fair = mysql_fetch_assoc($q);
$req = array('get_categories' => array('year' => $config['FAIRYEAR']),
$req = array('get_categories' => array('year' => $config['FAIRYEAR']), // FIXME - this needs to be updated to use conference id's
'get_divisions' => array('year' => $config['FAIRYEAR'])
);
$data = curl_query($fair, $req);
@ -235,7 +235,7 @@ function load_server_cats_divs($fairs_id)
} else {
$catmap = array();
/* Load ours */
$q=mysql_query("SELECT * FROM projectcategories WHERE year='{$config['FAIRYEAR']}' ORDER BY mingrade");
$q=mysql_query("SELECT * FROM projectcategories WHERE conferences_id='{$conference['id']}' ORDER BY mingrade");
while($r=mysql_fetch_object($q)) {
foreach($data['categories'] as $id=>$c) {
if($c['mingrade'] == $r->mingrade) {
@ -249,7 +249,7 @@ function load_server_cats_divs($fairs_id)
$divmap = unserialize($fair['divmap']);
} else {
$ret['divmap'] = array();
$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)) {
$lowest = 999;
$lowest_id = 0;
@ -423,7 +423,7 @@ case 'additional_materials':
$q = mysql_query("SELECT * FROM fairs WHERE id='{$a['award_source_fairs_id']}'");
$fair = mysql_fetch_assoc($q);
$req = array('award_additional_materials' => array(
'year'=>$config['FAIRYEAR'],
'year'=>$config['FAIRYEAR'], // FIXME - this needs to be updated to use conference id's
'identifier'=>$a['external_identifier'])
);
$data = curl_query($fair, $req, $url);
@ -662,7 +662,7 @@ if(!function_exists('curl_init')) {
$q = mysql_query("SELECT fairs.id, fairs.name, fairs.type, COUNT(award_awards.id) as AWARD_COUNT FROM fairs
LEFT JOIN award_awards ON award_awards.award_source_fairs_id=fairs.id
WHERE award_awards.award_source_fairs_id IS NOT NULL
AND award_awards.year='{$config['FAIRYEAR']}'
AND award_awards.conferences_id='{$conference['id']}'
GROUP BY fairs.id
ORDER BY fairs.name ");
echo mysql_error();
@ -706,7 +706,7 @@ $q = mysql_query("SELECT award_awards.id, award_awards.name AS awardname,
FROM award_awards
LEFT JOIN fairs ON fairs.id=award_awards.award_source_fairs_id
WHERE award_awards.award_source_fairs_id IS NOT NULL
AND award_awards.year='{$config['FAIRYEAR']}'
AND award_awards.conferences_id='{$conference['id']}'
ORDER BY fairs.name, award_awards.name");
echo mysql_error();

View File

@ -30,7 +30,7 @@ include "xml.inc.php";
$winners=array();
$winners_ids=array();
$q=mysql_query("SELECT * FROM award_awards WHERE cwsfaward='1' AND year='".$config['FAIRYEAR']."'");
$q=mysql_query("SELECT * FROM award_awards WHERE cwsfaward='1' AND conferences_id='".$conference['id']."'");
while($award=mysql_fetch_object($q))
{
$pq=mysql_query("SELECT * FROM award_prizes WHERE award_awards_id='$award->id'");
@ -51,7 +51,7 @@ include "xml.inc.php";
WHERE
winners.projects_id=projects.id AND
awards_prizes_id='$prize->id' AND
winners.year='".$config['FAIRYEAR']."'");
winners.conferences_id='".$conference['id']."'");
echo mysql_error();
while($project=mysql_fetch_object($wq))
{
@ -60,7 +60,7 @@ include "xml.inc.php";
} else {
$winners_ids[$project->id] = true;
}
$sq=mysql_query("SELECT * FROM students WHERE registrations_id='$project->registrations_id' AND year='".$config['FAIRYEAR']."'");
$sq=mysql_query("SELECT * FROM students WHERE registrations_id='$project->registrations_id' AND conferences_id='".$conference['id']."'");
$students=array();
$cwsf_agecategory=0;
while($s=mysql_fetch_object($sq))
@ -193,7 +193,7 @@ include "xml.inc.php";
if($ok)
{
$q=mysql_query("SELECT * FROM award_awards WHERE cwsfaward='1' AND year='".$config['FAIRYEAR']."'");
$q=mysql_query("SELECT * FROM award_awards WHERE cwsfaward='1' AND conferences_id='".$conference['id']."'");
if(!mysql_num_rows($q))
{
echo error(i18n("Cannot find an award that is specified as the Canada-Wide Science Fair Award"));
@ -262,7 +262,7 @@ include "xml.inc.php";
echo "</td><td>";
$t=mysql_query("SELECT * FROM projectdivisions WHERE year='".$config['FAIRYEAR']."' AND id='".$winner['projectdivisions_id']."'");
$t=mysql_query("SELECT * FROM projectdivisions WHERE conferences_id='".$conference['id']."' AND id='".$winner['projectdivisions_id']."'");
$tr=mysql_fetch_object($t);
echo $tr->division;
echo "<br />";

View File

@ -1,7 +1,7 @@
<?
function getJudgingTeams()
{
global $config;
global $config, $conference;
$q=mysql_query("SELECT judges_teams.id,
judges_teams.num,
@ -9,7 +9,7 @@ function getJudgingTeams()
FROM
judges_teams
WHERE
judges_teams.year='".$config['FAIRYEAR']."'
judges_teams.conferences_id='".$conference['id']."'
ORDER BY
num,name
");
@ -87,7 +87,7 @@ function getJudgingTeams()
$lq=mysql_query("SELECT projects.language
FROM judges_teams_timeslots_projects_link
LEFT JOIN projects ON judges_teams_timeslots_projects_link.projects_id=projects.id
WHERE judges_teams_timeslots_projects_link.year='{$config['FAIRYEAR']}' AND
WHERE judges_teams_timeslots_projects_link.conferences_id='{$conference['id']}' AND
judges_teams_id='$r->id' ");
echo mysql_error();
$projectlangs=array();
@ -114,7 +114,7 @@ function getJudgingTeams()
judges_teams_awards_link.award_awards_id=award_awards.id
AND judges_teams_awards_link.judges_teams_id='$r->id'
AND award_awards.award_types_id=award_types.id
AND award_types.year='{$config['FAIRYEAR']}'
AND award_types.conferences_id='{$conference['id']}'
ORDER BY
name
");
@ -143,7 +143,7 @@ function getJudgingTeam($teamid)
FROM
judges_teams
WHERE
judges_teams.year='".$config['FAIRYEAR']."' AND
judges_teams.conferences_id='".$conference['id']."' AND
judges_teams.id='$teamid'
ORDER BY
num,
@ -203,7 +203,7 @@ function getJudgingTeam($teamid)
judges_teams_awards_link.award_awards_id=award_awards.id
AND judges_teams_awards_link.judges_teams_id='$r->id'
AND award_awards.award_types_id=award_types.id
AND award_types.year='{$config['FAIRYEAR']}'
AND award_types.conferences_id='{$conference['id']}'
ORDER BY
name
");
@ -250,11 +250,13 @@ function judges_load_all()
$ret = array();
$query = "SELECT id FROM users WHERE types LIKE '%judge%'
AND year='{$config['FAIRYEAR']}'
AND deleted='no'
ORDER BY lastname, firstname";
$r = mysql_query($query);
$r = mysql_query("
SELECT users.id FROM users JOIN user_roles ur ON ur.users_id = users.id
JOIN roles ON roles.id = ur.roles_id WHERE roles.type = 'judge'
AND conferences_id='{$conference['id']}'
AND deleted='no'
ORDER BY lastname, firstname
");
while($i = mysql_fetch_assoc($r)) {
$u = user_load($i['id']);
if($u['judge_complete'] == 'no') continue;

View File

@ -141,7 +141,7 @@ if($judgeinfo['special_award_only'] == "yes"){
}
// get their preference for age category
$q=mysql_query("SELECT * FROM projectcategories WHERE year='{$config['FAIRYEAR']}'");
$q=mysql_query("SELECT * FROM projectcategories WHERE conferences_id='{$conference['id']}'");
$catPreferenceText = mysql_error() . "<ul>";
while($r=mysql_fetch_object($q)) {
@ -182,7 +182,7 @@ $catPreferenceText .= "</ul>";
<?php
//grab the list of divisions, because the last fields of the table will be the sub-divisions
$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");
$divs=array();
while($r=mysql_fetch_object($q))
{
@ -198,7 +198,7 @@ foreach($divs as $div)
echo "<td>";
$subq=mysql_query("SELECT * FROM projectsubdivisions WHERE
projectdivisions_id='$div' AND year='{$config['FAIRYEAR']}' ORDER BY subdivision");
projectdivisions_id='$div' AND conferences_id='{$conference['id']}' ORDER BY subdivision");
$sd = array();
while($subr=mysql_fetch_object($subq)) {
if($u['div_prefs_sub'][$subr->id] == 1) {

View File

@ -349,7 +349,7 @@ set_status("Loading Data From Database...");
TRACE("\n\n");
$div = array();
TRACE("Loading Project Divisions...\n");
$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))
{
$divshort[$r->id]=$r->division_shortform;
@ -359,7 +359,7 @@ while($r=mysql_fetch_object($q))
TRACE("Loading Project Age Categories...\n");
$cat = array();
$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;
TRACE(" {$r->id} - {$r->category}\n");
@ -376,7 +376,7 @@ while($r=mysql_fetch_object($q)) {
TRACE("Loading Judging Round time data...\n");
$round_special_awards = array();
$round = array();
$q = mysql_query("SELECT * FROM judges_timeslots WHERE round_id='0' AND `year`='{$config['FAIRYEAR']}'");
$q = mysql_query("SELECT * FROM judges_timeslots WHERE round_id='0' AND `conferences_id`='{$conference['id']}'");
/* Loads judges_timeslots.id, .starttime, .endtime, .date, .name */
while($r = mysql_fetch_assoc($q)) {
TRACE(" id:{$r['id']} type:{$r['type']} name:{$r['name']}\n");
@ -423,7 +423,7 @@ foreach($keys as $jdiv_id) {
if($x > 0) TRACE("\t- ");
TRACE($cat[$d['cat']]." ".$div[$d['div']]." - ".$langr[$d['lang']]);
$qp = mysql_query("SELECT projects.* FROM projects, registrations WHERE ".
" projects.year='".$config['FAIRYEAR']."' AND ".
" projects.conferences_id='".$conference['id']."' AND ".
" projectdivisions_id='{$d['div']}' AND ".
" projectcategories_id='{$d['cat']}' AND ".
" language='{$d['lang']}' AND " .
@ -450,27 +450,27 @@ foreach($keys as $jdiv_id) {
/* Clean out the judging teams that were autocreated in a previous run */
TRACE("Deleting autocreated divisional and special award judging teams:");
$q = mysql_query("SELECT * FROM judges_teams WHERE autocreate_type_id=1 AND year={$config['FAIRYEAR']}");
$q = mysql_query("SELECT * FROM judges_teams WHERE autocreate_type_id=1 AND conferences_id={$conference['id']}");
while($r = mysql_fetch_object($q)) {
$id = $r->id;
print(" $id");
/* Clean out the judges_teams_link */
mysql_query("DELETE FROM judges_teams_link WHERE judges_teams_id='$id' AND year={$config['FAIRYEAR']}");
mysql_query("DELETE FROM judges_teams_link WHERE judges_teams_id='$id' AND conferences_id={$conference['id']}");
print mysql_error();
/* Awards */
mysql_query("DELETE FROM judges_teams_awards_link WHERE judges_teams_id='$id' AND year={$config['FAIRYEAR']}");
mysql_query("DELETE FROM judges_teams_awards_link WHERE judges_teams_id='$id' AND conferences_id={$conference['id']}");
print mysql_error();
/* Timeslots */
mysql_query("DELETE FROM judges_teams_timeslots_link WHERE judges_teams_id='$id' AND year={$config['FAIRYEAR']}");
mysql_query("DELETE FROM judges_teams_timeslots_link WHERE judges_teams_id='$id' AND conferences_id={$conference['id']}");
print mysql_error();
/* Timeslots projects */
mysql_query("DELETE FROM judges_teams_timeslots_projects_link WHERE judges_teams_id='$id' AND year={$config['FAIRYEAR']}");
mysql_query("DELETE FROM judges_teams_timeslots_projects_link WHERE judges_teams_id='$id' AND conferences_id={$conference['id']}");
print mysql_error();
}
echo "\n";
/* Finally, delete all the autocreated judges teams */
mysql_query("DELETE FROM judges_teams WHERE autocreate_type_id=1 AND year={$config['FAIRYEAR']}");
mysql_query("DELETE FROM judges_teams WHERE autocreate_type_id=1 AND conferences_id={$conference['id']}");
print mysql_error();
/* Also delete any judges_teams_link that link to teams that dont exist, just
@ -478,7 +478,7 @@ print mysql_error();
$q=mysql_query("SELECT judges_teams_link.id, judges_teams.id AS judges_teams_id
FROM judges_teams_link
LEFT JOIN judges_teams ON judges_teams_link.judges_teams_id=judges_teams.id
WHERE judges_teams_link.year={$config['FAIRYEAR']}");
WHERE judges_teams_link.conferences_id={$conference['id']}");
$n=0;
while($r=mysql_fetch_object($q)) {
if(!$r->judges_teams_id) {
@ -509,7 +509,7 @@ foreach($judges as &$j) {
$q = mysql_query("SELECT users_id FROM judges_teams_link WHERE
users_id='{$j['id']}'
AND year='{$config['FAIRYEAR']}'");
AND conferences_id='{$conference['id']}'");
if(mysql_num_rows($q) != 0) {
TRACE(" {$j['name']} is already on a judging team, skipping.\n");
unset($judges[$j['id']]);
@ -535,7 +535,7 @@ foreach($judges as &$j) {
WHERE
award_awards.id=judges_specialaward_sel.award_awards_id
AND judges_specialaward_sel.users_id='{$j['id']}'
AND award_awards.year='{$config['FAIRYEAR']}'");
AND award_awards.conferences_id='{$conference['id']}'");
echo mysql_error();
if($j['special_award_only'] == 'yes') {
@ -578,7 +578,7 @@ if(count($judges)==0) {
/* Load the numbers for any user-defined judge teams that already exist,
* these numbers will be off-limits for auto-assigning numbers */
$q = mysql_query("SELECT * FROM judges_teams WHERE year={$config['FAIRYEAR']}");
$q = mysql_query("SELECT * FROM judges_teams WHERE conferences_id={$conference['id']}");
$used_judges_teams_numbers = array();
while($i = mysql_fetch_assoc($q)) {
$used_judges_teams_numbers[] = $i['num'];
@ -607,8 +607,8 @@ function judge_team_create($num, $name)
{
global $config;
$name = mysql_escape_string($name);
mysql_query("INSERT INTO judges_teams (num,name,autocreate_type_id,year)
VALUES ('$num','$name','1','{$config['FAIRYEAR']}')");
mysql_query("INSERT INTO judges_teams (num,name,autocreate_type_id,conferences_id)
VALUES ('$num','$name','1','{$conference['id']}')");
$id = mysql_insert_id();
return $id;
}
@ -617,9 +617,9 @@ function judge_team_add_judge($team_id, $users_id)
{
global $config, $judges;
mysql_query("INSERT INTO judges_teams_link
(users_id,judges_teams_id,captain,year)
(users_id,judges_teams_id,captain,conferences_id)
VALUES ('$users_id','$team_id','{$judges[$users_id]['willing_chair']}',
'{$config['FAIRYEAR']}')");
'{$conferences['id']}')");
echo mysql_error();
}
@ -805,7 +805,7 @@ for($x=1;$x<count($jteam); $x++) {
award_awards_projectcategories,
award_awards_projectdivisions
WHERE
award_awards.year='{$config['FAIRYEAR']}'
award_awards.conferences_id='{$conference['id']}'
AND award_awards.id=award_awards_projectcategories.award_awards_id
AND award_awards.id=award_awards_projectdivisions.award_awards_id
AND award_awards_projectcategories.projectcategories_id='{$cfg['cat']}'
@ -816,7 +816,7 @@ for($x=1;$x<count($jteam); $x++) {
echo error(i18n("Cannot find award for %1 - %2",array($cat[$cfg['cat']],$div[$cfg['div']])));
} else {
$r=mysql_fetch_object($q);
mysql_query("INSERT INTO judges_teams_awards_link (award_awards_id,judges_teams_id,year) VALUES ('$r->id','$team_id','{$config['FAIRYEAR']}')");
mysql_query("INSERT INTO judges_teams_awards_link (award_awards_id,judges_teams_id,conferences_id) VALUES ('$r->id','$team_id','{$conferences['id']}')");
/* Add the award ID to the jdiv, if it's not already there */
if(!in_array($r->id, $jdiv[$t['jdiv_id']]['award_ids'])) {
$jdiv[$t['jdiv_id']]['award_ids'][] = $r->id;
@ -892,7 +892,7 @@ if($round_divisional2 == NULL) {
/* Assign all the awards in this jdiv */
foreach($jd['award_ids'] as $aid) {
mysql_query("INSERT INTO judges_teams_awards_link (award_awards_id,judges_teams_id,year) VALUES ('$aid','$team_id','{$config['FAIRYEAR']}')");
mysql_query("INSERT INTO judges_teams_awards_link (award_awards_id,judges_teams_id,conferences_id) VALUES ('$aid','$team_id','{$conference['id']}')");
}
}
@ -1010,10 +1010,10 @@ if($config['scheduler_enable_sa_scheduling'] == 'yes') {
/* Load special awards */
$q = "SELECT award_awards.name,award_awards.id FROM award_awards,award_types
WHERE
award_awards.year='{$config['FAIRYEAR']}'
award_awards.conferences_id='{$conference['id']}'
AND award_types.id=award_awards.award_types_id
AND award_awards.schedule_judges='yes'
AND award_types.year='{$config['FAIRYEAR']}'
AND award_types.conferences_id='{$conference['id']}'
AND award_types.type='Special'
";
$r = mysql_query($q);
@ -1050,8 +1050,8 @@ if($config['scheduler_enable_sa_scheduling'] == 'yes') {
$required_judges += $min;
/* Link the award to this team */
mysql_query("INSERT INTO judges_teams_awards_link (award_awards_id,judges_teams_id,year)
VALUES ('{$i->id}','{$sa_jteam[$x]['id']}','{$config['FAIRYEAR']}')");
mysql_query("INSERT INTO judges_teams_awards_link (award_awards_id,judges_teams_id,conferences_id)
VALUES ('{$i->id}','{$sa_jteam[$x]['id']}','{$conference['id']}')");
TRACE("Created Team: {$i->name}, ".count($projects)." projects => $min judges needed (db id:{$sa_jteam[$x]['id']}) \n");
$x++;
@ -1242,15 +1242,15 @@ if($config['scheduler_enable_sa_scheduling'] == 'yes') {
/* Do timeslot and project timeslot assignment */
mysql_query("INSERT INTO judges_teams_timeslots_link
(judges_teams_id,judges_timeslots_id,year)
VALUES ('{$t['id']}', '{$r['timeslots'][0]['id']}', '{$config['FAIRYEAR']}')");
(judges_teams_id,judges_timeslots_id,conferences_id)
VALUES ('{$t['id']}', '{$r['timeslots'][0]['id']}', '{$conference['id']}')");
echo mysql_error();
foreach($t['projects'] as $proj) {
$pid = $proj['id'];
mysql_query("INSERT INTO judges_teams_timeslots_projects_link
(judges_teams_id,judges_timeslots_id,projects_id,year)
VALUES ('{$t['id']}', '{$r['timeslots'][0]['id']}', '$pid', '{$config['FAIRYEAR']}')");
(judges_teams_id,judges_timeslots_id,projects_id,conferences_id)
VALUES ('{$t['id']}', '{$r['timeslots'][0]['id']}', '$pid', '{$conference['id']}')");
echo mysql_error();
}
$ids = $a->bucket[$x];
@ -1283,7 +1283,7 @@ $available_timeslots=array();
$q=mysql_query("SELECT * FROM judges_timeslots WHERE
round_id='{$round_divisional1['id']}'
AND year='{$config['FAIRYEAR']}'
AND conferences_id='{$conference['id']}'
AND type='timeslot'
ORDER BY date,starttime");
$x=0;
@ -1452,16 +1452,16 @@ for($k=0; $k<$keys_count; $k++) {
/* if jteam_id isn't 0, instert it into the db */
mysql_query("INSERT INTO judges_teams_timeslots_link ".
" (judges_teams_id,judges_timeslots_id,year)".
" (judges_teams_id,judges_timeslots_id,conferences_id)".
" VALUES ('{$jteam[$jteam_id]['team_id']}', ".
" '{$available_timeslots[$y]['id']}', ".
" '{$config['FAIRYEAR']}')");
" '{$conference['id']}')");
mysql_query("INSERT INTO judges_teams_timeslots_projects_link ".
" (judges_teams_id,judges_timeslots_id,projects_id,year) ".
" (judges_teams_id,judges_timeslots_id,projects_id,conferences_id) ".
" VALUES ('{$jteam[$jteam_id]['team_id']}', ".
" '{$available_timeslots[$y]['id']}', ".
" '$pid', '{$config['FAIRYEAR']}')");
" '$pid', '{$conference['id']}')");
}
printf("\n");

View File

@ -2,10 +2,10 @@
function judges_scheduler_check_timeslots()
{
global $config;
global $conference;
$q=mysql_query("SELECT * FROM judges_timeslots WHERE ".
" year='".$config['FAIRYEAR']."'".
" conferences_id='".$conference['id']."'".
" AND `type`='divisional1'" );
if(mysql_num_rows($q)) {
$round=mysql_fetch_object($q);
@ -18,11 +18,11 @@ function judges_scheduler_check_timeslots()
function judges_scheduler_check_timeslots_sa()
{
global $config;
global $conference;
$rows = 0;
$q=mysql_query("SELECT * FROM judges_timeslots WHERE ".
" year='".$config['FAIRYEAR']."'".
" conferences_id='".$conference['id']."'".
" AND `type`='special'" );
if(mysql_num_rows($q)) {
while(( $round=mysql_fetch_object($q))) {
@ -35,13 +35,13 @@ function judges_scheduler_check_timeslots_sa()
function judges_scheduler_check_awards()
{
global $config;
global $config, $conferenece;
$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;
@ -49,7 +49,7 @@ function judges_scheduler_check_awards()
$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);
@ -75,9 +75,9 @@ function judges_scheduler_check_awards()
award_awards_projectcategories,
award_awards_projectdivisions
WHERE
award_awards.year='{$config['FAIRYEAR']}'
AND award_awards_projectcategories.year='{$config['FAIRYEAR']}'
AND award_awards_projectdivisions.year='{$config['FAIRYEAR']}'
award_awards.conferences_id='{$conference['id']}'
AND award_awards_projectcategories.conferences_id='{$conference['id']}'
AND award_awards_projectdivisions.conferences_id='{$conference['id']}'
AND award_awards.id=award_awards_projectcategories.award_awards_id
AND award_awards.id=award_awards_projectdivisions.award_awards_id
AND award_awards_projectcategories.projectcategories_id='$c'
@ -95,8 +95,6 @@ function judges_scheduler_check_awards()
function judges_scheduler_check_jdivs()
{
global $config;
$q=mysql_query("SELECT DISTINCT jdiv_id FROM judges_jdiv ");
$rows = mysql_num_rows($q);
@ -106,7 +104,7 @@ function judges_scheduler_check_jdivs()
function judges_scheduler_check_judges()
{
global $config;
global $config, $conference;
$ok = 1;
$jdiv = array();
@ -120,7 +118,7 @@ function judges_scheduler_check_judges()
$l = $r->lang;
$qp = mysql_query("SELECT COUNT(projects.id) as cnt FROM projects, registrations WHERE ".
" projects.year='".$config['FAIRYEAR']."' AND ".
" projects.conferences_id='".$conference['id']."' AND ".
" projectdivisions_id='$d' AND ".
" projectcategories_id='$c' AND ".
" language='$l' AND " .
@ -208,7 +206,7 @@ function judges_scheduler_check_judges()
echo "<br />";
echo "<br />";
/* $jq=mysql_query("SELECT COUNT(judges.id) AS num FROM judges,judges_years WHERE complete='yes' AND deleted='no' AND judges_years.year='{$config['FAIRYEAR']}' AND judges_years.judges_id=judges.id");
/* $jq=mysql_query("SELECT COUNT(judges.id) AS num FROM judges,judges_years WHERE complete='yes' AND deleted='no' AND judges_years.conferences_id='{$conference['id']}' AND judges_years.judges_id=judges.id");
$jr=mysql_fetch_object($jq);
$currentjudges=$jr->num;*/
/* FIXME: this his highly inefficient :), but won't be done very often */

View File

@ -35,11 +35,11 @@
if($action=="delete" && $_GET['delete'])
{
//ALSO DELETE: team members, timeslots, projects, awards
mysql_query("DELETE FROM judges_teams_link WHERE judges_teams_id='".$_GET['delete']."' AND year='".$config['FAIRYEAR']."'");
mysql_query("DELETE FROM judges_teams_timeslots_link WHERE judges_teams_id='".$_GET['delete']."' AND year='".$config['FAIRYEAR']."'");
mysql_query("DELETE FROM judges_teams_timeslots_projects_link WHERE judges_teams_id='".$_GET['delete']."' AND year='".$config['FAIRYEAR']."'");
mysql_query("DELETE FROM judges_teams_awards_link WHERE judges_teams_id='".$_GET['delete']."' AND year='".$config['FAIRYEAR']."'");
mysql_query("DELETE FROM judges_teams WHERE id='".$_GET['delete']."' AND year='".$config['FAIRYEAR']."'");
mysql_query("DELETE FROM judges_teams_link WHERE judges_teams_id='".$_GET['delete']."' AND conferences_id='".$conference['id']."'");
mysql_query("DELETE FROM judges_teams_timeslots_link WHERE judges_teams_id='".$_GET['delete']."' AND conferences_id='".$conference['id']."'");
mysql_query("DELETE FROM judges_teams_timeslots_projects_link WHERE judges_teams_id='".$_GET['delete']."' AND conferences_id='".$conference['id']."'");
mysql_query("DELETE FROM judges_teams_awards_link WHERE judges_teams_id='".$_GET['delete']."' AND conferences_id='".$conference['id']."'");
mysql_query("DELETE FROM judges_teams WHERE id='".$_GET['delete']."' AND conferences_id='".$conference['id']."'");
message_push(happy(i18n("Judge team successfully removed, and all of its corresponding members, timeslots, projects and awards unlinked from team")));
}
@ -49,7 +49,7 @@
FROM
judges_teams
WHERE
year='".$config['FAIRYEAR']."'
conferences_id='".$conference['id']."'
AND autocreate_type_id='1'
");
echo mysql_error();
@ -58,11 +58,11 @@
{
//okay now we can start deleting things! whew!
//first delete any linkings to the team
mysql_query("DELETE FROM judges_teams_link WHERE judges_teams_id='$r2->id' AND year='".$config['FAIRYEAR']."'");
mysql_query("DELETE FROM judges_teams_timeslots_link WHERE judges_teams_id='$r2->id' AND year='".$config['FAIRYEAR']."'");
mysql_query("DELETE FROM judges_teams_timeslots_projects_link WHERE judges_teams_id='$r2->id' AND year='".$config['FAIRYEAR']."'");
mysql_query("DELETE FROM judges_teams_awards_link WHERE judges_teams_id='$r2->id' AND year='".$config['FAIRYEAR']."'");
mysql_query("DELETE FROM judges_teams WHERE id='$r2->id' AND year='".$config['FAIRYEAR']."'");
mysql_query("DELETE FROM judges_teams_link WHERE judges_teams_id='$r2->id' AND conferences_id='".$conference['id']."'");
mysql_query("DELETE FROM judges_teams_timeslots_link WHERE judges_teams_id='$r2->id' AND conferences_id='".$conference['id']."'");
mysql_query("DELETE FROM judges_teams_timeslots_projects_link WHERE judges_teams_id='$r2->id' AND conferences_id='".$conference['id']."'");
mysql_query("DELETE FROM judges_teams_awards_link WHERE judges_teams_id='$r2->id' AND conferences_id='".$conference['id']."'");
mysql_query("DELETE FROM judges_teams WHERE id='$r2->id' AND conferences_id='".$conference['id']."'");
$numdeleted++;
}
if($numdeleted)
@ -76,18 +76,18 @@
$q2=mysql_query("SELECT *
FROM judges_teams
WHERE
year='".$config['FAIRYEAR']."'
conferences_id='".$conference['id']."'
");
$numdeleted=0;
while($r2=mysql_fetch_object($q2))
{
//okay now we can start deleting things! whew!
//first delete any linkings to the team
mysql_query("DELETE FROM judges_teams_link WHERE judges_teams_id='$r2->id' AND year='".$config['FAIRYEAR']."'");
mysql_query("DELETE FROM judges_teams_timeslots_link WHERE judges_teams_id='$r2->id' AND year='".$config['FAIRYEAR']."'");
mysql_query("DELETE FROM judges_teams_timeslots_projects_link WHERE judges_teams_id='$r2->id' AND year='".$config['FAIRYEAR']."'");
mysql_query("DELETE FROM judges_teams_awards_link WHERE judges_teams_id='$r2->id' AND year='".$config['FAIRYEAR']."'");
mysql_query("DELETE FROM judges_teams WHERE id='$r2->id' AND year='".$config['FAIRYEAR']."'");
mysql_query("DELETE FROM judges_teams_link WHERE judges_teams_id='$r2->id' AND conferences_id='".$conference['id']."'");
mysql_query("DELETE FROM judges_teams_timeslots_link WHERE judges_teams_id='$r2->id' AND conferences_id='".$conference['id']."'");
mysql_query("DELETE FROM judges_teams_timeslots_projects_link WHERE judges_teams_id='$r2->id' AND conferences_id='".$conference['id']."'");
mysql_query("DELETE FROM judges_teams_awards_link WHERE judges_teams_id='$r2->id' AND conferences_id='".$conference['id']."'");
mysql_query("DELETE FROM judges_teams WHERE id='$r2->id' AND conferences_id='".$conference['id']."'");
$numdeleted++;
}
if($numdeleted)
@ -148,7 +148,7 @@
if($addaward)
{
//link up the award
mysql_query("INSERT INTO judges_teams_awards_link (award_awards_id,judges_teams_id,year) VALUES ('".$_POST['award']."','$edit','".$config['FAIRYEAR']."')");
mysql_query("INSERT INTO judges_teams_awards_link (award_awards_id,judges_teams_id,conferences_id) VALUES ('".$_POST['award']."','$edit','".$conference['id']."')");
message_push(happy(i18n("Award assigned to team")));
}
}
@ -171,7 +171,7 @@
if($action=="unassign")
{
mysql_query("DELETE FROM judges_teams_awards_link WHERE judges_teams_id='$edit' AND award_awards_id='".$_GET['unassign']."' AND year='".$config['FAIRYEAR']."'");
mysql_query("DELETE FROM judges_teams_awards_link WHERE judges_teams_id='$edit' AND award_awards_id='".$_GET['unassign']."' AND conferences_id='".$conference['id']."'");
message_push(happy(i18n("Award unassigned from judge team")));
//keep editing the same team
$action="edit";
@ -180,7 +180,7 @@
if($action=="createall")
{
//first make sure we dont have any non-divisional award teams (dont want people hitting refresh and adding all the teams twice
$q=mysql_query("SELECT COUNT(*) AS c FROM judges_teams WHERE autocreate_type_id!='1' AND year='".$config['FAIRYEAR']."'");
$q=mysql_query("SELECT COUNT(*) AS c FROM judges_teams WHERE autocreate_type_id!='1' AND conferences_id='".$conference['id']."'");
$r=mysql_fetch_object($q);
if($r->c)
{
@ -198,8 +198,8 @@
award_types
WHERE
award_awards.award_types_id=award_types.id
AND award_awards.year='".$config['FAIRYEAR']."'
AND award_types.year='".$config['FAIRYEAR']."'
AND award_awards.conferences_id='".$conference['id']."'
AND award_types.conferences_id='".$conference['id']."'
AND award_types_id!='1'
ORDER BY
award_types_order,
@ -210,11 +210,11 @@
{
// print_r($r);
$name=mysql_escape_string("($r->award_type) $r->name");
mysql_query("INSERT INTO judges_teams(num,name,autocreate_type_id,year) VALUES ('$num','$name','$r->award_types_id','".$config['FAIRYEAR']."')");
mysql_query("INSERT INTO judges_teams(num,name,autocreate_type_id,conferences_id) VALUES ('$num','$name','$r->award_types_id','".$conference['id']."')");
echo mysql_error();
$team_id=mysql_insert_id();
//now link the new team to the award
mysql_query("INSERT INTO judges_teams_awards_link (award_awards_id,judges_teams_id,year) VALUES ('$r->id','$team_id','".$config['FAIRYEAR']."')");
mysql_query("INSERT INTO judges_teams_awards_link (award_awards_id,judges_teams_id,conferences_id) VALUES ('$r->id','$team_id','".$conference['id']."')");
message_push(happy(i18n("Created team #%1: %2",array($num,$name))));
$num++;
}
@ -223,7 +223,7 @@
if($action=="add" && $_GET['num'])
{
mysql_query("INSERT INTO judges_teams(num,year) VALUES ('".$_GET['num']."','".$config['FAIRYEAR']."')");
mysql_query("INSERT INTO judges_teams(num,conferences_id) VALUES ('".$_GET['num']."','".$conference['id']."')");
echo mysql_error();
$edit=mysql_insert_id();
$action="edit";
@ -301,9 +301,9 @@ function addclicked()
award_awards,
award_types
WHERE
award_awards.year='".$config['FAIRYEAR']."'
award_awards.conferences_id='".$conference['id']."'
AND award_types.id=award_awards.award_types_id
AND award_types.year='{$config['FAIRYEAR']}'
AND award_types.conferences_id='{$conference['id']}'
ORDER BY
award_type_order,
name
@ -323,10 +323,10 @@ function addclicked()
)
LEFT JOIN judges_teams_awards_link ON award_awards.id = judges_teams_awards_link.award_awards_id
WHERE
award_awards.year='".$config['FAIRYEAR']."' AND
award_awards.conferences_id='".$conference['id']."' AND
judges_teams_awards_link.award_awards_id IS NULL
AND award_types.id=award_awards.award_types_id
AND award_types.year='{$config['FAIRYEAR']}'
AND award_types.conferences_id='{$conference['id']}'
ORDER BY
award_type_order,
name";

View File

@ -688,6 +688,9 @@ foreach($report_stock as $n=>$v) {
if(!isset($report['year'])) {
$report['year'] = $config['FAIRYEAR'];
}
if(!isset($report['conference_id'])){
$report['conference_id'] = $conference['id'];
}
$group_by = array_merge($group_by, $post_group_by);
$group_query = "";

View File

@ -5,8 +5,17 @@
require("../lpdf.php");
require("../lcsv.php");
if($_GET['year']) $foryear=$_GET['year'];
else $foryear=$config['FAIRYEAR'];
if($_GET['foryear']){
// backwards compatability
$r = mysql_fetch_assoc(mysql_query("SELECT id FROM conferences WHERE year = " . $_GET['foryear']));
if(is_array($r)){
$forconference = $r['id'];
}else{
$forconference = $conference['id'];
}
}
if($_GET['conference']) $forconference=$_GET['conference'];
else $forconference=$conference['id'];
if($_GET['awardtype']=="All") $awardtype="";
else if($_GET['awardtype']) $awardtype=" AND award_types.type='".mysql_escape_string($_GET['awardtype'])."'";
@ -67,8 +76,8 @@ if(!$scriptformat) $scriptformat="default";
sponsors,
award_awards_projectcategories
WHERE
award_awards.year='$foryear'
AND award_types.year='$foryear'
award_awards.conferences_id='$forconference'
AND award_types.conferences_id='$forconference'
AND award_awards.award_types_id=award_types.id
AND award_awards.sponsors_id=sponsors.id
AND award_awards.id=award_awards_projectcategories.award_awards_id
@ -105,7 +114,7 @@ if(!$scriptformat) $scriptformat="default";
LEFT JOIN projects ON projects.id=winners.projects_id
WHERE
award_awards_id='{$r->id}'
AND award_prizes.year='$foryear'
AND award_prizes.conferences_id='$forconference'
AND award_prizes.excludefromac='0'
ORDER BY
`order`,

View File

@ -370,15 +370,15 @@ $report_awards_fields = array(
global $config, $report_awards_fields;
$fields = $report_awards_fields;
$year = $report['year'];
$conferenceId = $report['conference_id'];
$judges_join = '';
$judges_where = '';
if(in_array('judgingteam', $components)) {
$judges_join = 'LEFT JOIN judges_teams_awards_link ON judges_teams_awards_link.award_awards_id=award_awards.id
LEFT JOIN judges_teams ON judges_teams.id=judges_teams_awards_link.judges_teams_id';
$judges_where = "AND judges_teams_awards_link.year='$year'
AND judges_teams.year='$year'";
$judges_where = "AND judges_teams_awards_link.conferences_id='$conferenceId'
AND judges_teams.conferences_id='$conferenceId'";
}
$judges_members_join = '';
@ -387,14 +387,14 @@ $report_awards_fields = array(
$judges_members_join = 'LEFT JOIN judges_teams_link ON judges_teams_link.judges_teams_id=judges_teams.id
LEFT JOIN judges ON judges.id=judges_teams_link.judges_id';
$judges_members_where = "AND judges_teams_link.year='$year'";
$judges_members_where = "AND judges_teams_link.conferences_id='$conferenceId'";
}
$prizes_join = '';
if(in_array('prizes', $components)) {
$prizes_join = 'LEFT JOIN award_prizes ON award_prizes.award_awards_id=award_awards.id';
/* Don't need a where filter, the prize is attached by unique ID to an award
* that is already from the correct year. */
* that is already from the correct conference. */
}
@ -411,13 +411,12 @@ $report_awards_fields = array(
$judges_members_join
$prizes_join
WHERE
award_awards.year='$year'
AND award_types.year='$year'
award_awards.conferences_id='$conferenceId'
AND award_types.conferences_id='$conferenceId'
$judges_where
$judges_members_where
";
return $q;
}
?>

View File

@ -65,7 +65,7 @@
echo "<tr>";
//list award subsets to output
echo "<td><b>".i18n("Award Type").":</b></td> <td> <select name=\"awardtype\" size=1>";
$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 "<option value=\"All\">".i18n("All")."</option>";
while($r=mysql_fetch_object($results)) {
echo "<option value=\"$r->type\">".i18n("$r->type")."</option>";
@ -97,7 +97,7 @@
echo "<tr><td><b>".i18n("Include the following age categories").":</b></td>";
echo "<td>";
$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 "<input name=\"show_category[{$r->id}]\" type=\"checkbox\" checked=\"checked\" />";
echo "".i18n($r->category)."<br />";

View File

@ -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
");

View File

@ -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`");

View File

@ -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();

View File

@ -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();

View File

@ -1 +1 @@
215
216

44
db/db.update.216.php Normal file
View File

@ -0,0 +1,44 @@
<?
function db_update_216_pre()
{
}
function db_update_216_post()
{
$tables=array(
"award_awards",
"award_prizes",
"award_types",
"award_awards_projectcategories",
"award_awards_projectdivisions",
"winners",
"students",
"projects",
"registrations"
);
// add the conferences_id field
foreach($tables as $tableName){
$query = "ALTER TABLE `$tableName` ADD `conferences_id` INT NOT NULL";
mysql_query($query);
echo $query . ";\n";
}
// get the year => 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";
}
?>

View File

@ -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'];