From 57f62f7ab47d55dfd121691a080b8d06e1b409ad Mon Sep 17 00:00:00 2001 From: dave Date: Sun, 25 Nov 2007 23:30:51 +0000 Subject: [PATCH] - Add a multiselect option to the config editor --- config_editor.inc.php | 27 +++++++++++++++++++++++---- db/db.code.version.txt | 2 +- db/db.update.67.sql | 3 +++ 3 files changed, 27 insertions(+), 5 deletions(-) create mode 100644 db/db.update.67.sql diff --git a/config_editor.inc.php b/config_editor.inc.php index 0ab52ed..66bb15d 100644 --- a/config_editor.inc.php +++ b/config_editor.inc.php @@ -48,7 +48,14 @@ function config_editor_parse_from_http_headers($array_name) $keys = array_keys($_POST[$array_name]); foreach($keys as $id) { - $ans[$id] = stripslashes($_POST[$array_name][$id]); + if(is_array($_POST[$array_name][$id])) { + $ans[$id] = array(); + foreach($_POST[$array_name][$id] as $k=>$v) { + $ans[$id][$k]=stripslashes($v); + } + } else { + $ans[$id] = stripslashes($_POST[$array_name][$id]); + } } return $ans; } @@ -122,7 +129,10 @@ function config_editor($category, $year, $array_name, $self) $var = config_editor_parse_from_http_headers($array_name); $varkeys = array_keys($var); foreach($varkeys as $k) { - $val = mysql_escape_string(stripslashes($var[$k])); + if(is_array($var[$k])) + $val = mysql_escape_string(implode(',',$var[$k])); + else + $val = mysql_escape_string($var[$k]); $v = mysql_escape_string(stripslashes($k)); mysql_query("UPDATE config SET val=\"$val\" WHERE var=\"$v\" AND `year`='$year'"); print mysql_error(); @@ -171,7 +181,10 @@ function config_editor($category, $year, $array_name, $self) print(""); print(""); break; + case 'multisel': + $multiple = "multiple=\"multiple\""; case "enum": + $val = split(',', $val); $values = $var[$k]['type_values']; /* Split values */ /* The PERL regex here matches any string of the form @@ -198,13 +211,19 @@ function config_editor($category, $year, $array_name, $self) preg_match_all("/([^\|=]+)(?:=([^\|]+))?\|?/", $values, $regs); // print_r($regs); - print(""); for($x=0; $x$e_val"); } print(""); diff --git a/db/db.code.version.txt b/db/db.code.version.txt index 69a893a..3fdcd7c 100644 --- a/db/db.code.version.txt +++ b/db/db.code.version.txt @@ -1 +1 @@ -66 +67 diff --git a/db/db.update.67.sql b/db/db.update.67.sql new file mode 100644 index 0000000..7acf635 --- /dev/null +++ b/db/db.update.67.sql @@ -0,0 +1,3 @@ +ALTER TABLE `config` CHANGE `type` `type` ENUM( '', 'yesno', 'number', 'text', 'enum', 'multisel' ) NOT NULL; + +