forked from science-ation/science-ation
Make judges_jdiv groupings obey the filterdivisionsbycategory config option and dont show div/cat's that shouldnt exist
This commit is contained in:
parent
9a7383f552
commit
93f610c214
@ -52,6 +52,8 @@ function newbuttonclicked(jdivs)
|
||||
|
||||
<?
|
||||
|
||||
$div = array();
|
||||
$divshort = array();
|
||||
$q=mysql_query("SELECT * FROM projectdivisions WHERE year='".$config['FAIRYEAR']."' ORDER BY id");
|
||||
while($r=mysql_fetch_object($q)) {
|
||||
$divshort[$r->id]=$r->division_shortform;
|
||||
@ -64,6 +66,26 @@ function newbuttonclicked(jdivs)
|
||||
$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();
|
||||
$q=mysql_query("SELECT * FROM languages WHERE active='Y'");
|
||||
while($r=mysql_fetch_object($q)) {
|
||||
@ -75,6 +97,7 @@ function get_all_divs()
|
||||
{
|
||||
global $config;
|
||||
global $divshort, $div,$cat, $langr;
|
||||
global $divcat;
|
||||
|
||||
$cdlcheck = array();
|
||||
$cdl = array();
|
||||
@ -93,34 +116,34 @@ function get_all_divs()
|
||||
$divkeys = array_keys($divshort);
|
||||
$catkeys = array_keys($cat);
|
||||
$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
|
||||
* unassigned anymore */
|
||||
mysql_query("INSERT INTO judges_jdiv (id, jdiv_id, projectdivisions_id, projectcategories_id, lang) ".
|
||||
" VALUES('', 0, '$y', '$x', '$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);
|
||||
foreach($divcat AS $dc) {
|
||||
$y=$dc['d'];
|
||||
$x=$dc['c'];
|
||||
foreach($lankeys as $z) {
|
||||
if($cdlcheck[$x][$y][$z] == 1)
|
||||
continue;
|
||||
|
||||
$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;
|
||||
/* Also, make an entry in the DB, so that this isn't
|
||||
* unassigned anymore */
|
||||
mysql_query("INSERT INTO judges_jdiv (id, jdiv_id, projectdivisions_id, projectcategories_id, lang) ".
|
||||
" VALUES('', 0, '$y', '$x', '$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 */
|
||||
$dkeys = array_keys($cdl);
|
||||
|
Loading…
x
Reference in New Issue
Block a user