diff --git a/lib/plugins/config/settings/config.class.php b/lib/plugins/config/settings/config.class.php index 9c4cca49c8e9d16336b62b4c0e5fd51495dae1bb..0942a6d23cd1cad4059888d8f51f173e70e31cce 100644 --- a/lib/plugins/config/settings/config.class.php +++ b/lib/plugins/config/settings/config.class.php @@ -1191,6 +1191,7 @@ if (!class_exists('setting_multicheckbox')) { var $_choices = array(); var $_combine = array(); + var $_other = 'always'; /** * update changed setting with user provided value $input @@ -1274,16 +1275,21 @@ if (!class_exists('setting_multicheckbox')) { } // handle any remaining values - $other = join(',',$value); - - $class = ((count($default) == count($value)) && (count($value) == count(array_intersect($value,$default)))) ? - " selectiondefault" : ""; - - $input .= '<div class="other'.$class.'">'."\n"; - $input .= '<label for="config___'.$key.'_other">'.$plugin->getLang($key.'_other')."</label>\n"; - $input .= '<input id="config___'.$key.'_other" name="config['.$key.'][other]" type="text" class="edit" value="'.htmlspecialchars($other).'" '.$disable." />\n"; - $input .= "</div>\n"; - + if ($this->_other != 'never'){ + $other = join(',',$value); + // test equivalent to ($this->_other == 'always' || ($other && $this->_other == 'exists') + // use != 'exists' rather than == 'always' to ensure invalid values default to 'always' + if ($this->_other != 'exists' || $other) { + + $class = ((count($default) == count($value)) && (count($value) == count(array_intersect($value,$default)))) ? + " selectiondefault" : ""; + + $input .= '<div class="other'.$class.'">'."\n"; + $input .= '<label for="config___'.$key.'_other">'.$plugin->getLang($key.'_other')."</label>\n"; + $input .= '<input id="config___'.$key.'_other" name="config['.$key.'][other]" type="text" class="edit" value="'.htmlspecialchars($other).'" '.$disable." />\n"; + $input .= "</div>\n"; + } + } $label = '<label>'.$this->prompt($plugin).'</label>'; return array($label,$input); } diff --git a/lib/plugins/config/settings/config.metadata.php b/lib/plugins/config/settings/config.metadata.php index aaa32cd70b9b15ca2210817d1548a93cc59af00e..c362a9f1af144e5a7104a29dda7f277f4e747e5d 100644 --- a/lib/plugins/config/settings/config.metadata.php +++ b/lib/plugins/config/settings/config.metadata.php @@ -70,6 +70,12 @@ * '_pregflags' - string, default 'ui', valid preg pattern modifiers used when testing regex input values, for more * information see http://uk1.php.net/manual/en/reference.pcre.pattern.modifiers.php * '_multiple' - bool, allow multiple comma separated email values; optional for 'email', ignored by others + * '_other' - how to handle other values (not listed in _choices). accepted values: 'always','exists','never' + * default value 'always'. 'exists' only shows 'other' input field when the setting contains value(s) + * not listed in choices (e.g. due to manual editing or update changing _choices). This is safer than + * 'never' as it will not discard unknown/other values. + * optional for 'multicheckbox', ignored by others + * * * @author Chris Smith <chris@jalakai.co.uk> */