Make judges_jdiv groupings obey the filterdivisionsbycategory config option and dont show div/cat's that shouldnt exist

This commit is contained in:
james 2007-12-20 15:47:19 +00:00
parent 9a7383f552
commit 93f610c214

View File

@ -52,6 +52,8 @@ function newbuttonclicked(jdivs)
<? <?
$div = array();
$divshort = array();
$q=mysql_query("SELECT * FROM projectdivisions WHERE year='".$config['FAIRYEAR']."' ORDER BY id"); $q=mysql_query("SELECT * FROM projectdivisions WHERE year='".$config['FAIRYEAR']."' ORDER BY id");
while($r=mysql_fetch_object($q)) { while($r=mysql_fetch_object($q)) {
$divshort[$r->id]=$r->division_shortform; $divshort[$r->id]=$r->division_shortform;
@ -64,6 +66,26 @@ function newbuttonclicked(jdivs)
$cat[$r->id]=$r->category; $cat[$r->id]=$r->category;
} }
$dkeys = array_keys($div);
$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");
$divcat=array();
while($r=mysql_fetch_object($q)) {
$divcat[]=array("c"=>$r->projectcategories_id,"d"=>$r->projectdivisions_id);
}
}
else {
$divcat=array();
foreach($dkeys AS $d) {
foreach($ckeys AS $c) {
$divcat[]=array("c"=>$c,"d"=>$d);
}
}
}
$langr = array(); $langr = array();
$q=mysql_query("SELECT * FROM languages WHERE active='Y'"); $q=mysql_query("SELECT * FROM languages WHERE active='Y'");
while($r=mysql_fetch_object($q)) { while($r=mysql_fetch_object($q)) {
@ -75,6 +97,7 @@ function get_all_divs()
{ {
global $config; global $config;
global $divshort, $div,$cat, $langr; global $divshort, $div,$cat, $langr;
global $divcat;
$cdlcheck = array(); $cdlcheck = array();
$cdl = array(); $cdl = array();
@ -93,34 +116,34 @@ function get_all_divs()
$divkeys = array_keys($divshort); $divkeys = array_keys($divshort);
$catkeys = array_keys($cat); $catkeys = array_keys($cat);
$lankeys = array_keys($langr); $lankeys = array_keys($langr);
foreach($catkeys as $x) {
foreach($divkeys as $y) {
foreach($lankeys as $z) {
if($cdlcheck[$x][$y][$z] == 1)
continue;
/* Also, make an entry in the DB, so that this isn't foreach($divcat AS $dc) {
* unassigned anymore */ $y=$dc['d'];
mysql_query("INSERT INTO judges_jdiv (id, jdiv_id, projectdivisions_id, projectcategories_id, lang) ". $x=$dc['c'];
" VALUES('', 0, '$y', '$x', '$z')"); foreach($lankeys as $z) {
$q = mysql_query("SELECT id FROM judges_jdiv WHERE ". if($cdlcheck[$x][$y][$z] == 1)
" projectdivisions_id='$y' ". continue;
" AND projectcategories_id='$x' ".
" AND lang='$z' ");
$r = mysql_fetch_object($q);
$cdl[$r->id]['id'] = $r->id; /* Also, make an entry in the DB, so that this isn't
$cdl[$r->id]['jdiv'] = 0; /* Unassigned */ * unassigned anymore */
$cdl[$r->id]['cat'] = $x; mysql_query("INSERT INTO judges_jdiv (id, jdiv_id, projectdivisions_id, projectcategories_id, lang) ".
$cdl[$r->id]['div'] = $y; " VALUES('', 0, '$y', '$x', '$z')");
$cdl[$r->id]['lang'] = $z; $q = mysql_query("SELECT id FROM judges_jdiv WHERE ".
" projectdivisions_id='$y' ".
" AND projectcategories_id='$x' ".
" AND lang='$z' ");
$r = mysql_fetch_object($q);
$cdl[$r->id]['id'] = $r->id;
$cdl[$r->id]['jdiv'] = 0; /* Unassigned */
$cdl[$r->id]['cat'] = $x;
$cdl[$r->id]['div'] = $y;
$cdl[$r->id]['lang'] = $z;
}
reset($lankeys);
} }
reset($catkeys); reset($lankeys);
} }
reset($divkeys); reset($divcat);
/* Make names for all the DCLs, and count the number of projects */ /* Make names for all the DCLs, and count the number of projects */
$dkeys = array_keys($cdl); $dkeys = array_keys($cdl);