forked from science-ation/science-ation
Split the Configuration Variables page into separate 'Category' pages
This commit is contained in:
parent
6d6dd8abb1
commit
14e93e0c12
@ -181,11 +181,10 @@ function getJudgingTeam($teamid)
|
|||||||
function judges_scheduler_load_config()
|
function judges_scheduler_load_config()
|
||||||
{
|
{
|
||||||
global $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();
|
$data=array();
|
||||||
while($configr=mysql_fetch_object($configq)) {
|
while($configr=mysql_fetch_object($configq)) {
|
||||||
$v = substr($configr->var, 11);
|
$data[$configr->var]=$configr->val;
|
||||||
$data[$v]=$configr->val;
|
|
||||||
}
|
}
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ ogram; see the file COPYING. If not, write to
|
|||||||
echo "<a href=\"index.php\"><< ".i18n("Back to Administration")."</a>\n";
|
echo "<a href=\"index.php\"><< ".i18n("Back to Administration")."</a>\n";
|
||||||
echo "<a href=\"judges.php\"><< ".i18n("Back to Judges")."</a>\n";
|
echo "<a href=\"judges.php\"><< ".i18n("Back to Judges")."</a>\n";
|
||||||
|
|
||||||
config_editor("JSCHEDULER_", $config['FAIRYEAR'], "var", $_SERVER['PHP_SELF']);
|
config_editor("Judge Scheduler", $config['FAIRYEAR'], "var", $_SERVER['PHP_SELF']);
|
||||||
|
|
||||||
echo "<hr />";
|
echo "<hr />";
|
||||||
$ok = 1;
|
$ok = 1;
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
?>
|
?>
|
||||||
<?
|
<?
|
||||||
require("../common.inc.php");
|
require("../common.inc.php");
|
||||||
|
require_once("../config_editor.inc.php");
|
||||||
auth_required('config');
|
auth_required('config');
|
||||||
send_header("Configuration - Variables");
|
send_header("Configuration - Variables");
|
||||||
echo "<a href=\"index.php\"><< ".i18n("Back to Configuration")."</a><br />";
|
echo "<a href=\"index.php\"><< ".i18n("Back to Configuration")."</a><br />";
|
||||||
@ -30,14 +31,16 @@
|
|||||||
$q=mysql_query("SELECT * FROM config WHERE year='-1'");
|
$q=mysql_query("SELECT * FROM config WHERE year='-1'");
|
||||||
while($r=mysql_fetch_object($q))
|
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->var)."',
|
||||||
'".mysql_escape_string($r->val)."',
|
'".mysql_escape_string($r->val)."',
|
||||||
|
'".mysql_escape_string($r->category)."',
|
||||||
|
'".mysql_escape_string($r->ord)."',
|
||||||
'".mysql_escape_string($r->description)."',
|
'".mysql_escape_string($r->description)."',
|
||||||
'".$config['FAIRYEAR']."')");
|
'".$config['FAIRYEAR']."')");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//for the Special category
|
||||||
if($_POST['action']=="save")
|
if($_POST['action']=="save")
|
||||||
{
|
{
|
||||||
if($_POST['specialconfig'])
|
if($_POST['specialconfig'])
|
||||||
@ -47,22 +50,45 @@
|
|||||||
mysql_query("UPDATE config SET val='".mysql_escape_string(stripslashes($val))."' WHERE year='0' AND var='$key'");
|
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"));
|
echo happy(i18n("Configuration successfully saved"));
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
$q=mysql_query("SELECT * FROM config WHERE year=0 ORDER BY var");
|
|
||||||
|
//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 "<br />";
|
||||||
|
echo "<table width=\"90%\" align=\"center\" cellspacing=0 cellpadding=0 border=1>";
|
||||||
|
echo "<tr>";
|
||||||
|
while($r=mysql_fetch_object($q))
|
||||||
|
{
|
||||||
|
echo "<td align=\"center\">";
|
||||||
|
if($r->cat==$category)
|
||||||
|
echo "<b>$r->cat</b>";
|
||||||
|
else
|
||||||
|
echo "<a href=\"".$_SERVER['PHP_SELF']."?category=".urlencode($r->cat)."\">$r->cat</a>";
|
||||||
|
echo "</td>";
|
||||||
|
}
|
||||||
|
echo "</tr>";
|
||||||
|
echo "</table>";
|
||||||
|
echo "<hr />";
|
||||||
|
|
||||||
|
if($category)
|
||||||
|
{
|
||||||
|
|
||||||
|
if($category=="Special")
|
||||||
|
{
|
||||||
echo "<form method=\"post\" action=\"variables.php\">";
|
echo "<form method=\"post\" action=\"variables.php\">";
|
||||||
echo "<input type=\"hidden\" name=\"action\" value=\"save\">\n";
|
echo "<input type=\"hidden\" name=\"action\" value=\"save\">\n";
|
||||||
echo "<table cellpadding=\"5\">";
|
echo "<input type=\"hidden\" name=\"category\" value=\"Special\">\n";
|
||||||
echo "<tr><td colspan=\"3\"><h3>".i18n("Global configuration settings")."</h3></td></tr>";
|
echo "<table cellpadding=\"3\">";
|
||||||
|
$q=mysql_query("SELECT * FROM config WHERE year=0 ORDER BY var");
|
||||||
|
echo "<tr><td colspan=\"2\"><h3>".i18n("Special Configuration Settings")."</h3></td></tr>";
|
||||||
|
echo "<tr><td colspan=\"2\">";
|
||||||
|
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 "</td></tr>";
|
||||||
while($r=mysql_fetch_object($q))
|
while($r=mysql_fetch_object($q))
|
||||||
{
|
{
|
||||||
if($r->var=="FAIRYEAR" || $r->var=="DBVERSION")
|
if($r->var=="FAIRYEAR" || $r->var=="DBVERSION")
|
||||||
@ -74,19 +100,21 @@
|
|||||||
echo "<tr><td><b>$r->var</b> - ".i18n($r->description)."</td><td><input type=\"text\" name=\"specialconfig[$r->var]\" value=\"$r->val\" /></td></tr>";
|
echo "<tr><td><b>$r->var</b> - ".i18n($r->description)."</td><td><input type=\"text\" name=\"specialconfig[$r->var]\" value=\"$r->val\" /></td></tr>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "<tr><td colspan=\"3\"><hr /><br /><h3>".i18n("Configuration settings for fair year %1",array($config['FAIRYEAR']),array("fair year"))."</h3></td></tr>";
|
|
||||||
|
|
||||||
$q=mysql_query("SELECT * FROM config WHERE year='".$config['FAIRYEAR']."' ORDER BY var");
|
|
||||||
while($r=mysql_fetch_object($q))
|
|
||||||
{
|
|
||||||
echo "<tr><td><b>$r->var</b> - ".i18n($r->description)."</td><td><input type=\"text\" name=\"saveconfig[$r->var]\" value=\"$r->val\" /></td></tr>";
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
echo "</table>";
|
echo "</table>";
|
||||||
echo "<input type=\"submit\" value=\"".i18n("Save Configuration")."\" />\n";
|
echo "<input type=\"submit\" value=\"".i18n("Save Configuration")."\" />\n";
|
||||||
echo "</form>";
|
echo "</form>";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
echo "<h3>".i18n("Configuration settings for fair year %1",array($config['FAIRYEAR']),array("fair year"))."</h3><br /><h3>".i18n($category)."</h3>";
|
||||||
|
|
||||||
|
config_editor($category, $config['FAIRYEAR'], "var", $_SERVER['PHP_SELF']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
echo i18n("Please choose a configuration category");
|
||||||
|
}
|
||||||
|
|
||||||
send_footer();
|
send_footer();
|
||||||
?>
|
?>
|
||||||
|
@ -23,12 +23,9 @@
|
|||||||
?>
|
?>
|
||||||
<?
|
<?
|
||||||
|
|
||||||
function config_editor_load($append, $year)
|
function config_editor_load($category, $year)
|
||||||
{
|
{
|
||||||
$query = "SELECT * FROM config WHERE year='$year' ";
|
$query = "SELECT * FROM config WHERE year='$year' AND category='$category' ORDER BY ord";
|
||||||
if($append != '') {
|
|
||||||
$query .= " AND var LIKE '{$append}%'";
|
|
||||||
}
|
|
||||||
$q = mysql_query($query);
|
$q = mysql_query($query);
|
||||||
print(mysql_error());
|
print(mysql_error());
|
||||||
|
|
||||||
@ -36,6 +33,8 @@ function config_editor_load($append, $year)
|
|||||||
while($r=mysql_fetch_object($q)) {
|
while($r=mysql_fetch_object($q)) {
|
||||||
$var[$r->var]['val'] = $r->val;
|
$var[$r->var]['val'] = $r->val;
|
||||||
$var[$r->var]['desc'] = $r->description;
|
$var[$r->var]['desc'] = $r->description;
|
||||||
|
$var[$r->var]['category'] = $r->category;
|
||||||
|
$var[$r->var]['ord'] = $r->ord;
|
||||||
}
|
}
|
||||||
return $var;
|
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
|
* 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
|
* a bunch of up/down arrows, and dynamically compute the order for
|
||||||
* all elements */
|
* all elements */
|
||||||
function config_editor($append, $year, $array_name, $self)
|
function config_editor($category, $year, $array_name, $self)
|
||||||
{
|
{
|
||||||
global $config;
|
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
|
/* Load questions, then handle up and down, because with up and down we
|
||||||
* have to modify 2 questions to maintain the order */
|
* have to modify 2 questions to maintain the order */
|
||||||
$var = config_editor_load($append, $year);
|
$var = config_editor_load($category, $year);
|
||||||
|
|
||||||
echo "<form method=\"post\" action=\"$self\">";
|
echo "<form method=\"post\" action=\"$self\">";
|
||||||
|
|
||||||
echo "<table>";
|
echo "<table cellpadding=\"3\">";
|
||||||
|
|
||||||
$varkeys = array_keys($var);
|
$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) {
|
foreach($varkeys as $k) {
|
||||||
print("<tr>");
|
print("<tr>");
|
||||||
print("<td>{$var[$k]['desc']}</td>");
|
print("<td>{$var[$k]['desc']}</td>");
|
||||||
print("<td>");
|
print("<td>");
|
||||||
print("<input size=\"5\" type=\"text\" name=\"${array_name}[$k]\" value=\"".htmlspecialchars($var[$k]['val'])."\">\n");
|
print("<input size=\"$size\" type=\"text\" name=\"${array_name}[$k]\" value=\"".htmlspecialchars($var[$k]['val'])."\">\n");
|
||||||
echo "</td></tr>";
|
echo "</td></tr>";
|
||||||
}
|
}
|
||||||
print("</table>");
|
print("</table>");
|
||||||
print("<input type=hidden name=\"action\" value=\"update\" >\n");
|
print("<input type=\"hidden\" name=\"category\" value=\"$category\" >\n");
|
||||||
|
print("<input type=\"hidden\" name=\"action\" value=\"update\" >\n");
|
||||||
print("<input type=\"submit\" value=\"".i18n("Save Configuration")."\" />\n");
|
print("<input type=\"submit\" value=\"".i18n("Save Configuration")."\" />\n");
|
||||||
|
|
||||||
echo "</form>";
|
echo "</form>";
|
||||||
|
@ -1 +1 @@
|
|||||||
20
|
21
|
||||||
|
44
db/db.update.21.sql
Normal file
44
db/db.update.21.sql
Normal file
@ -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';
|
||||||
|
|
Loading…
Reference in New Issue
Block a user