From 018725aebf9808ba6887a973610bfea7366f860e Mon Sep 17 00:00:00 2001 From: dave Date: Sat, 20 Jan 2007 22:23:44 +0000 Subject: [PATCH] - Add a type field to each config variable. The type field is used to tell the editor what type of variable to expect. It can be yesno, enum, text (default), number (unimplemented), or blank (default behaviour of the current system). In response, the editor will use pull down lists instead of text boxes for things like "Yes", and "No", or enumerated fields. - Update the descriptions and type of existing variables. --- config_editor.inc.php | 58 +++++++++++++++++++++++++++++++++++++++++- db/db.code.version.txt | 2 +- db/db.update.37.sql | 29 +++++++++++++++++++++ 3 files changed, 87 insertions(+), 2 deletions(-) create mode 100644 db/db.update.37.sql diff --git a/config_editor.inc.php b/config_editor.inc.php index 44ece74..3fe21c1 100644 --- a/config_editor.inc.php +++ b/config_editor.inc.php @@ -35,6 +35,8 @@ function config_editor_load($category, $year) $var[$r->var]['desc'] = $r->description; $var[$r->var]['category'] = $r->category; $var[$r->var]['ord'] = $r->ord; + $var[$r->var]['type'] = $r->type; + $var[$r->var]['type_values'] = $r->type_values; } return $var; } @@ -124,7 +126,61 @@ function config_editor($category, $year, $array_name, $self) print(""); print("{$var[$k]['desc']}"); print(""); - print("\n"); + + $val = htmlspecialchars($var[$k]['val']); + $name = "${array_name}[$k]"; + + switch($var[$k]['type']) { + case "yesno": + print(""); + break; + case "enum": + $values = $var[$k]['type_values']; + /* Split values */ + /* The PERL regex here matches any string of the form + * key=val| , where the = and 'val' and '|' are + * optional. val is allowed to contain spaces. Using + * preg_match_all runs this regex multiple times, and + * creates arrays for each subpattern that matches. + * For example, "aa=Aye|bb=Bee Bee|cc|dd=Dee" + * Would construct the following Array of Arrays: + * Array ( [0] => Array ( [0] => "aa=Aye|", + [1] => "bb=Bee Bee|", + [2] => "cc|", + [3] => "dd=Dee" ), + [1] => Array ( [0] => "aa", + [1] => "bb", + [2] => "cc", + [3] => "dd" ), + [2] => Array ( [0] => "Aye", + [1] => "Bee Bee", + [2] => "", + [3] => "Dee" ) ) + * neat eh? :) We use [1] and [2] to form the keys and + * values that we show the user */ + + preg_match_all("/([^\|=]+)(?:=([^\|]+))?\|?/", $values, $regs); +// print_r($regs); + print(""); + break; + default: + print("\n"); + break; + } echo ""; } print(""); diff --git a/db/db.code.version.txt b/db/db.code.version.txt index 7facc89..81b5c5d 100644 --- a/db/db.code.version.txt +++ b/db/db.code.version.txt @@ -1 +1 @@ -36 +37 diff --git a/db/db.update.37.sql b/db/db.update.37.sql new file mode 100644 index 0000000..d62a0a2 --- /dev/null +++ b/db/db.update.37.sql @@ -0,0 +1,29 @@ +-- Add type and type_values fields to the config editor. +ALTER TABLE `config` ADD `type` ENUM( '', 'yesno', 'number', 'text', 'enum' ) NOT NULL AFTER `category` , +ADD `type_values` TINYTEXT NOT NULL AFTER `type` ; + +UPDATE `config` SET `type` = 'yesno', +`description` = 'Ask for students special food requirements. Should be ''Yes'' if you plan on providing food to the students.' WHERE `var`='participant_student_foodreq'; + +UPDATE `config` set `type` = 'yesno', `description` = 'Specify whether to use the division selector flowchart questions to help decide on the division' WHERE `var`='usedivisionselector'; +UPDATE `config` set `type` = 'yesno' WHERE `var`='participant_student_personal'; +UPDATE `config` set `type` = 'yesno', `description` = 'Ask for students their T-Shirt size' WHERE `var`='participant_student_tshirt'; +UPDATE `config` set `type` = 'yesno', `description` = 'Ask for mentorship information' WHERE `var`='participant_mentor'; +UPDATE `config` set `type` = 'yesno', `description` = 'Ask if the project requires a table' WHERE `var`='participant_project_table'; +UPDATE `config` set `type` = 'yesno', `description` = 'Ask if the project requires electricity' WHERE `var`='participant_project_electricity'; +UPDATE `config` set `type` = 'yesno' WHERE `var`='tours_enable'; +UPDATE `config` set `type` = 'yesno', `description` = 'Allows for the setup of different divisions for each category' WHERE `var`='filterdivisionbycategory'; + +UPDATE `config` SET `type` = 'enum', `type_values` = 'student=Student|project=Project', `description` = 'Registration fee is per student, or per project?' WHERE `var` = 'regfee_per'; + +UPDATE `config` SET `type` = 'enum', `type_values` = 'open=Open|singlepassword=Single Password|schoolpassword=School Password|invite=Invite|openorinvite=Open or Invite', `description`='The type of Participant Registration to use' WHERE `var` = 'participant_registration_type'; + +UPDATE `config` SET `type` = 'enum', `type_values` = 'open=Open|singlepassword=Single Password|invite=Invite', `description` = 'The type of Judge Registration to use' WHERE `var` = 'judge_registration_type'; + +UPDATE `config` SET `type` = 'enum', `type_values` = 'open=Open|payment_pending=Payment Pending|complete=Complete', `description` = 'The status a project must have have to be considered eligible for judge scheduling. ' WHERE `var` = 'project_status' ; + +UPDATE `config` SET `type` = 'enum', `type_values` = 'none=None|date=By Date|registration=With Registration', `description` = 'Self nominations for special awards are due either with registration ("With Registration"), or on a specific date. If "By Date" is used, it must be configured under "Important Dates" section. If you do not wish to allow students to self-nominate for special awards, set to "None"' WHERE `var` = 'specialawardnomination'; + + + +