blob: 25a0c0e75f9ef83c57894d8b2a091f03bc733bd0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
<?php
namespace dokuwiki\plugin\config\core\Setting;
/**
* Class setting_email
*/
class SettingEmail extends SettingString {
protected $multiple = false;
protected $placeholders = false;
/** @inheritdoc */
public function update($input) {
if(is_null($input)) return false;
if($this->isProtected()) return false;
$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(',', $mail)));
} else {
$mails = array($mail);
}
// check them all
foreach($mails as $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;
}
}
$this->local = $input;
return true;
}
}
|