diff options
-rw-r--r-- | lib/plugins/config/settings/config.class.php | 54 | ||||
-rw-r--r-- | lib/plugins/config/settings/config.metadata.php | 4 |
2 files changed, 52 insertions, 6 deletions
diff --git a/lib/plugins/config/settings/config.class.php b/lib/plugins/config/settings/config.class.php index 4b77d7065..36464c8e3 100644 --- a/lib/plugins/config/settings/config.class.php +++ b/lib/plugins/config/settings/config.class.php @@ -248,7 +248,7 @@ if (!class_exists('configuration')) { } closedir($dh); } - + // the same for the active template if (@file_exists(DOKU_TPLINC.$file)){ $meta = array(); @@ -262,7 +262,7 @@ if (!class_exists('configuration')) { $metadata['tpl'.CM_KEYMARKER.$tpl.CM_KEYMARKER.$key] = $value; } } - + return $metadata; } @@ -285,7 +285,7 @@ if (!class_exists('configuration')) { } closedir($dh); } - + // the same for the active template if (@file_exists(DOKU_TPLINC.$file)){ $conf = array(); @@ -294,7 +294,7 @@ if (!class_exists('configuration')) { $default['tpl'.CM_KEYMARKER.$tpl.CM_KEYMARKER.$key] = $value; } } - + return $default; } @@ -486,6 +486,50 @@ if (!class_exists('setting_email')) { } } +if (!class_exists('setting_richemail')) { + class setting_richemail extends setting_email { + + /** + * update setting with user provided value $input + * if value fails error check, save it + * + * @return true if changed, false otherwise (incl. on error) + */ + function update($input) { + if (is_null($input)) return false; + if ($this->is_protected()) return false; + + $value = is_null($this->_local) ? $this->_default : $this->_local; + if ($value == $input) return false; + + // replace variables with pseudo values + $test = $input; + $test = str_replace('@USER@','joe',$test); + $test = str_replace('@NAME@','Joe Schmoe',$test); + $test = str_replace('@MAIL@','joe@example.com',$test); + + // now only check the address part + if(preg_match('#(.*?)<(.*?)>#',$test,$matches)){ + $text = trim($matches[1]); + $addr = $matches[2]; + }else{ + $addr = $test; + } + + if ($this->_pattern && !preg_match($this->_pattern,$addr)) { + $this->_error = true; + $this->_input = $input; + return false; + } + + $this->_local = $input; + return true; + } + + } +} + + if (!class_exists('setting_numeric')) { class setting_numeric extends setting_string { // This allows for many PHP syntax errors... @@ -688,7 +732,7 @@ if (!class_exists('setting_multicheckbox')) { if ($this->is_protected()) return false; // split any combined values + convert from array to comma separated string - $input = ($input) ? $input : array(); + $input = ($input) ? $input : array(); $input = $this->_array2str($input); $value = is_null($this->_local) ? $this->_default : $this->_local; diff --git a/lib/plugins/config/settings/config.metadata.php b/lib/plugins/config/settings/config.metadata.php index 55ddb1e55..226ae8b58 100644 --- a/lib/plugins/config/settings/config.metadata.php +++ b/lib/plugins/config/settings/config.metadata.php @@ -20,6 +20,8 @@ * 'onoff' - checkbox input, setting output 0|1 * 'multichoice' - select input (single choice), setting output with quotes, required _choices parameter * 'email' - text input, input must conform to email address format, setting output in quotes + * 'richemail' - text input, input must conform to email address format but accepts variables and + * emails with a real name prepended (when email address is given in <>) * 'password' - password input, minimal input validation, setting output plain text in quotes * 'dirchoice' - as multichoice, selection choices based on folders found at location specified in _dir * parameter (required). A pattern can be used to restrict the folders to only those which @@ -158,7 +160,7 @@ $meta['useslash'] = array('onoff'); $meta['sepchar'] = array('sepchar'); $meta['canonical'] = array('onoff'); $meta['autoplural'] = array('onoff'); -$meta['mailfrom'] = array('email'); +$meta['mailfrom'] = array('richemail'); $meta['compress'] = array('onoff'); $meta['gzip_output'] = array('onoff'); $meta['hidepages'] = array('string'); |