summaryrefslogtreecommitdiff
path: root/lib/plugins/config/settings
diff options
context:
space:
mode:
authorKlap-in <klapinklapin@gmail.com>2013-02-16 23:08:08 +0100
committerKlap-in <klapinklapin@gmail.com>2013-02-16 23:08:08 +0100
commite57cf65d092c1a6458c3a468b017018905018eeb (patch)
treecb06ff0cf82afed514aa95c5c33e5faef8a9ef62 /lib/plugins/config/settings
parenta0e625181ad2e2369e8db0e5691f7356363776d0 (diff)
parent9bbf02e86e5c1181bbc288ce42f1937f309a7e79 (diff)
downloadrpg-e57cf65d092c1a6458c3a468b017018905018eeb.tar.gz
rpg-e57cf65d092c1a6458c3a468b017018905018eeb.tar.bz2
Merge remote-tracking branch 'origin/master' into authpluginconfig
Diffstat (limited to 'lib/plugins/config/settings')
-rw-r--r--lib/plugins/config/settings/config.class.php85
-rw-r--r--lib/plugins/config/settings/config.metadata.php10
2 files changed, 42 insertions, 53 deletions
diff --git a/lib/plugins/config/settings/config.class.php b/lib/plugins/config/settings/config.class.php
index a3cfae9f8..4a84d6dc8 100644
--- a/lib/plugins/config/settings/config.class.php
+++ b/lib/plugins/config/settings/config.class.php
@@ -84,7 +84,7 @@ if (!class_exists('configuration')) {
array_shift($param);
} else {
$class = 'setting_undefined';
- $param = NULL;
+ $param = null;
}
if (!in_array($class, $no_default_check) && !isset($default[$key])) {
@@ -358,13 +358,13 @@ if (!class_exists('setting')) {
class setting {
var $_key = '';
- var $_default = NULL;
- var $_local = NULL;
- var $_protected = NULL;
+ var $_default = null;
+ var $_local = null;
+ var $_protected = null;
var $_pattern = '';
var $_error = false; // only used by those classes which error check
- var $_input = NULL; // only used by those classes which error check
+ var $_input = null; // only used by those classes which error check
var $_cautionList = array(
'basedir' => 'danger', 'baseurl' => 'danger', 'savedir' => 'danger', 'cookiedir' => 'danger', 'useacl' => 'danger', 'authtype' => 'danger', 'superuser' => 'danger', 'userewrite' => 'danger',
@@ -372,7 +372,7 @@ if (!class_exists('setting')) {
'allowdebug' => 'security', 'htmlok' => 'security', 'phpok' => 'security', 'iexssprotect' => 'security', 'xmlrpc' => 'security', 'fullpath' => 'security'
);
- function setting($key, $params=NULL) {
+ function setting($key, $params=null) {
$this->_key = $key;
if (is_array($params)) {
@@ -661,6 +661,7 @@ if (!class_exists('setting_email')) {
class setting_email extends setting_string {
var $_pattern = SETTING_EMAIL_PATTERN; // no longer required, retained for backward compatibility - FIXME, may not be necessary
var $_multiple = false;
+ var $_placeholders = false;
/**
* update setting with user provided value $input
@@ -674,15 +675,36 @@ if (!class_exists('setting_email')) {
$value = is_null($this->_local) ? $this->_default : $this->_local;
if ($value == $input) return false;
+ if($input === ''){
+ $this->_local = $input;
+ return true;
+ }
+ $mail = $input;
+
+ if($this->_placeholders){
+ // replace variables with pseudo values
+ $mail = str_replace('@USER@','joe',$mail);
+ $mail = str_replace('@NAME@','Joe Schmoe',$mail);
+ $mail = str_replace('@MAIL@','joe@example.com',$mail);
+ }
+ // multiple mail addresses?
if ($this->_multiple) {
- $mails = array_filter(array_map('trim', explode(',', $input)));
+ $mails = array_filter(array_map('trim', explode(',', $mail)));
} else {
- $mails = array($input);
+ $mails = array($mail);
}
+ // check them all
foreach ($mails as $mail) {
- if (!mail_isvalid($mail)) {
+ // only check the address part
+ if(preg_match('#(.*?)<(.*?)>#', $mail, $matches)){
+ $addr = $matches[2];
+ }else{
+ $addr = $mail;
+ }
+
+ if (!mail_isvalid($addr)) {
$this->_error = true;
$this->_input = $input;
return false;
@@ -695,46 +717,15 @@ if (!class_exists('setting_email')) {
}
}
+/**
+ * @deprecated 2013-02-16
+ */
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 boolean 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 ($test !== '' && !mail_isvalid($addr)) {
- $this->_error = true;
- $this->_input = $input;
- return false;
- }
-
- $this->_local = $input;
- return true;
- }
-
+ function update($input) {
+ $this->_placeholders = true;
+ return parent::update($input);
+ }
}
}
diff --git a/lib/plugins/config/settings/config.metadata.php b/lib/plugins/config/settings/config.metadata.php
index 585015085..bdbc4311f 100644
--- a/lib/plugins/config/settings/config.metadata.php
+++ b/lib/plugins/config/settings/config.metadata.php
@@ -20,9 +20,7 @@
* 'numericopt' - like above, but accepts empty values
* '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 <>)
+ * 'email' - text input, input must conform to email address format
* 'password' - password input, minimal input validation, setting output text in quotes, maybe encoded
* according to the _code parameter
* 'dirchoice' - as multichoice, selection choices based on folders found at location specified in _dir
@@ -129,7 +127,7 @@ $meta['_authentication'] = array('fieldset');
$meta['useacl'] = array('onoff');
$meta['autopasswd'] = array('onoff');
$meta['authtype'] = array('authtype');
-$meta['passcrypt'] = array('multichoice','_choices' => array('smd5','md5','apr1','sha1','ssha','lsmd5','crypt','mysql','my411','kmd5','pmd5','hmd5','mediawiki','bcrypt','sha512'));
+$meta['passcrypt'] = array('multichoice','_choices' => array('smd5','md5','apr1','sha1','ssha','lsmd5','crypt','mysql','my411','kmd5','pmd5','hmd5','mediawiki','bcrypt','djangomd5','djangosha1','sha512'));
$meta['defaultgroup']= array('string');
$meta['superuser'] = array('string');
$meta['manager'] = array('string');
@@ -177,8 +175,8 @@ $meta['_notifications'] = array('fieldset');
$meta['subscribers'] = array('onoff');
$meta['subscribe_time'] = array('numeric');
$meta['notify'] = array('email', '_multiple' => true);
-$meta['registernotify'] = array('email');
-$meta['mailfrom'] = array('richemail');
+$meta['registernotify'] = array('email', '_multiple' => true);
+$meta['mailfrom'] = array('email', '_placeholders' => true);
$meta['mailprefix'] = array('string');
$meta['htmlmail'] = array('onoff');