diff --git a/admin/judges.inc.php b/admin/judges.inc.php index 08719e7..8dcec23 100644 --- a/admin/judges.inc.php +++ b/admin/judges.inc.php @@ -181,11 +181,10 @@ function getJudgingTeam($teamid) function judges_scheduler_load_config() { global $config; - $configq=mysql_query("SELECT * FROM config WHERE year='".$config['FAIRYEAR']."' AND var LIKE 'JSCHEDULER_%'"); + $configq=mysql_query("SELECT * FROM config WHERE year='".$config['FAIRYEAR']."' AND category = 'Judge Scheduler'"); $data=array(); while($configr=mysql_fetch_object($configq)) { - $v = substr($configr->var, 11); - $data[$v]=$configr->val; + $data[$configr->var]=$configr->val; } return $data; } diff --git a/admin/judges_schedulerconfig.php b/admin/judges_schedulerconfig.php index a53d147..f15a78c 100644 --- a/admin/judges_schedulerconfig.php +++ b/admin/judges_schedulerconfig.php @@ -34,7 +34,7 @@ ogram; see the file COPYING. If not, write to echo "<< ".i18n("Back to Administration")."\n"; echo "<< ".i18n("Back to Judges")."\n"; - config_editor("JSCHEDULER_", $config['FAIRYEAR'], "var", $_SERVER['PHP_SELF']); + config_editor("Judge Scheduler", $config['FAIRYEAR'], "var", $_SERVER['PHP_SELF']); echo "
"; $ok = 1; diff --git a/config/variables.php b/config/variables.php index 48393f1..5ad7d5d 100644 --- a/config/variables.php +++ b/config/variables.php @@ -23,6 +23,7 @@ ?> << ".i18n("Back to Configuration")."
"; @@ -30,14 +31,16 @@ $q=mysql_query("SELECT * FROM config WHERE year='-1'"); while($r=mysql_fetch_object($q)) { - mysql_query("INSERT INTO config (var,val,description,year) VALUES ( + mysql_query("INSERT INTO config (var,val,category,ord,description,year) VALUES ( '".mysql_escape_string($r->var)."', '".mysql_escape_string($r->val)."', + '".mysql_escape_string($r->category)."', + '".mysql_escape_string($r->ord)."', '".mysql_escape_string($r->description)."', '".$config['FAIRYEAR']."')"); } - + //for the Special category if($_POST['action']=="save") { if($_POST['specialconfig']) @@ -47,46 +50,71 @@ mysql_query("UPDATE config SET val='".mysql_escape_string(stripslashes($val))."' WHERE year='0' AND var='$key'"); } } - if($_POST['saveconfig']) - { - foreach($_POST['saveconfig'] as $key=>$val) - { - mysql_query("UPDATE config SET val='".mysql_escape_string(stripslashes($val))."' WHERE year='".$config['FAIRYEAR']."' AND var='$key'"); - } - } echo happy(i18n("Configuration successfully saved")); - - } - $q=mysql_query("SELECT * FROM config WHERE year=0 ORDER BY var"); - echo "
"; - echo "\n"; - echo ""; - echo ""; + + //get the category, and if nothing is chosen, default to Global + if($_GET['category']) $category=$_GET['category']; + else if($_POST['category']) $category=$_POST['category']; + else $category="Global"; + + $q=mysql_query("SELECT DISTINCT(category) AS cat FROM config ORDER BY cat"); + echo "
"; + echo "

".i18n("Global configuration settings")."

"; + echo ""; while($r=mysql_fetch_object($q)) { - if($r->var=="FAIRYEAR" || $r->var=="DBVERSION") + echo ""; + } + echo ""; + echo "
"; + if($r->cat==$category) + echo "$r->cat"; + else + echo "cat)."\">$r->cat"; + echo "
"; + echo "
"; + + if($category) + { + + if($category=="Special") { - echo "$r->var - ".i18n($r->description)."$r->val"; + echo ""; + echo "\n"; + echo "\n"; + echo ""; + $q=mysql_query("SELECT * FROM config WHERE year=0 ORDER BY var"); + echo ""; + echo ""; + while($r=mysql_fetch_object($q)) + { + if($r->var=="FAIRYEAR" || $r->var=="DBVERSION") + { + echo ""; + } + else + { + echo ""; + } + } + echo "

".i18n("Special Configuration Settings")."

"; + echo i18n("Warning, modifying values on this configuration variables page could cause your SFIAB to stop working. Only change anything on this page if you really know what you are doing"); + echo "
$r->var - ".i18n($r->description)."$r->val
$r->var - ".i18n($r->description)."var]\" value=\"$r->val\" />
"; + echo "\n"; + echo "
"; } else { - echo "$r->var - ".i18n($r->description)."var]\" value=\"$r->val\" />"; + echo "

".i18n("Configuration settings for fair year %1",array($config['FAIRYEAR']),array("fair year"))."


".i18n($category)."

"; + + config_editor($category, $config['FAIRYEAR'], "var", $_SERVER['PHP_SELF']); } - } - - echo "

".i18n("Configuration settings for fair year %1",array($config['FAIRYEAR']),array("fair year"))."

"; - - $q=mysql_query("SELECT * FROM config WHERE year='".$config['FAIRYEAR']."' ORDER BY var"); - while($r=mysql_fetch_object($q)) - { - echo "$r->var - ".i18n($r->description)."var]\" value=\"$r->val\" />"; - - - } - echo ""; - echo "\n"; - echo ""; +} +else +{ + echo i18n("Please choose a configuration category"); +} send_footer(); ?> diff --git a/config_editor.inc.php b/config_editor.inc.php index 0e32e81..853aa74 100644 --- a/config_editor.inc.php +++ b/config_editor.inc.php @@ -23,12 +23,9 @@ ?> var]['val'] = $r->val; $var[$r->var]['desc'] = $r->description; + $var[$r->var]['category'] = $r->category; + $var[$r->var]['ord'] = $r->ord; } return $var; } @@ -60,7 +59,7 @@ function config_editor_parse_from_http_headers($array_name) * FUTURE WORK: it would be nice to hide the order, and just implement * a bunch of up/down arrows, and dynamically compute the order for * all elements */ -function config_editor($append, $year, $array_name, $self) +function config_editor($category, $year, $array_name, $self) { global $config; @@ -80,22 +79,33 @@ function config_editor($append, $year, $array_name, $self) /* Load questions, then handle up and down, because with up and down we * have to modify 2 questions to maintain the order */ - $var = config_editor_load($append, $year); + $var = config_editor_load($category, $year); echo "
"; - echo ""; + echo "
"; $varkeys = array_keys($var); + //compute the optimal input size to use + $biggest=0; + foreach($varkeys as $k) { + if(strlen($var[$k]['val'])>$biggest) + $biggest=strlen($var[$k]['val']); + } + if($biggest>30) $size=30; + else $size=$biggest+1; + + foreach($varkeys as $k) { print(""); print(""); print(""; } print("
{$var[$k]['desc']}"); - print("\n"); + print("\n"); echo "
"); - print("\n"); + print("\n"); + print("\n"); print("\n"); echo "
"; diff --git a/db/db.code.version.txt b/db/db.code.version.txt index 209e3ef..aabe6ec 100644 --- a/db/db.code.version.txt +++ b/db/db.code.version.txt @@ -1 +1 @@ -20 +21 diff --git a/db/db.update.21.sql b/db/db.update.21.sql new file mode 100644 index 0000000..257683e --- /dev/null +++ b/db/db.update.21.sql @@ -0,0 +1,44 @@ +ALTER TABLE `config` ADD `category` VARCHAR( 32 ) NOT NULL AFTER `val` , ADD `ord` INT NOT NULL AFTER `category` ; +UPDATE `config` SET `category` = 'Special', ord='0' WHERE `year`=0; +UPDATE `config` SET `category` = 'Global', ord='100' WHERE var='fairname'; +UPDATE `config` SET `category` = 'Global', ord='200' WHERE var='default_language'; +UPDATE `config` SET `category` = 'Global', ord='300' WHERE var='fairmanageremail'; +UPDATE `config` SET `category` = 'Global', ord='400' WHERE var='filterdivisionbycategory'; +UPDATE `config` SET `category` = 'Global', ord='500' WHERE var='committee_publiclayout'; +UPDATE `config` SET `category` = 'Global', ord='600' WHERE var='project_num_format'; +UPDATE `config` SET `category` = 'Judge Scheduler', ord='100' WHERE var='JSCHEDULER_effort'; +UPDATE `config` SET `category` = 'Judge Scheduler', ord='200' WHERE var='JSCHEDULER_min_judges_per_team'; +UPDATE `config` SET `category` = 'Judge Scheduler', ord='300' WHERE var='JSCHEDULER_max_judges_per_team'; +UPDATE `config` SET `category` = 'Judge Scheduler', ord='400' WHERE var='JSCHEDULER_max_projects_per_team'; +UPDATE `config` SET `category` = 'Judge Scheduler', ord='500' WHERE var='JSCHEDULER_times_judged'; +UPDATE `config` SET `category` = 'Judge Registration', ord='100' WHERE var='judge_registration_type'; +UPDATE `config` SET `category` = 'Judge Registration', ord='200' WHERE var='judge_registration_singlepassword'; +UPDATE `config` SET `category` = 'Judge Registration', ord='300' WHERE var='judges_password_expiry_days'; +UPDATE `config` SET `category` = 'Judge Registration', ord='400' WHERE var='minjudgeage'; +UPDATE `config` SET `category` = 'Judge Registration', ord='500' WHERE var='maxjudgeage'; +UPDATE `config` SET `category` = 'Participant Registration', ord='100' WHERE var='participant_registration_type'; +UPDATE `config` SET `category` = 'Participant Registration', ord='200' WHERE var='participant_registration_singlepassword'; +UPDATE `config` SET `category` = 'Participant Registration', ord='300' WHERE var='regfee'; +UPDATE `config` SET `category` = 'Participant Registration', ord='400' WHERE var='regfee_per'; +UPDATE `config` SET `category` = 'Participant Registration', ord='500' WHERE var='minage'; +UPDATE `config` SET `category` = 'Participant Registration', ord='501' WHERE var='maxage'; +UPDATE `config` SET `category` = 'Participant Registration', ord='600' WHERE var='mingrade'; +UPDATE `config` SET `category` = 'Participant Registration', ord='601' WHERE var='maxgrade'; +UPDATE `config` SET `category` = 'Participant Registration', ord='700' WHERE var='minmentorsperproject'; +UPDATE `config` SET `category` = 'Participant Registration', ord='701' WHERE var='maxmentorsperproject'; +UPDATE `config` SET `category` = 'Participant Registration', ord='800' WHERE var='minstudentsperproject'; +UPDATE `config` SET `category` = 'Participant Registration', ord='801' WHERE var='maxstudentsperproject'; +UPDATE `config` SET `category` = 'Participant Registration', ord='900' WHERE var='maxspecialawardsperproject'; +UPDATE `config` SET `category` = 'Participant Registration', ord='1000' WHERE var='participant_student_personal'; +UPDATE `config` SET `category` = 'Participant Registration', ord='1100' WHERE var='participant_project_summary_wordmax'; +UPDATE `config` SET `category` = 'Participant Registration', ord='1200' WHERE var='participant_student_foodreq'; +UPDATE `config` SET `category` = 'Participant Registration', ord='1300' WHERE var='participant_student_tshirt'; +UPDATE `config` SET `category` = 'Participant Registration', ord='1400' WHERE var='specialawardnomination'; +UPDATE `config` SET `category` = 'Participant Registration', ord='1500' WHERE var='usedivisionselector'; + +UPDATE `config` SET var='effort' WHERE var='JSCHEDULER_effort'; +UPDATE `config` SET var='min_judges_per_team' WHERE var='JSCHEDULER_min_judges_per_team'; +UPDATE `config` SET var='max_judges_per_team' WHERE var='JSCHEDULER_max_judges_per_team'; +UPDATE `config` SET var='max_projects_per_team' WHERE var='JSCHEDULER_max_projects_per_team'; +UPDATE `config` SET var='times_judged' WHERE var='JSCHEDULER_times_judged'; +