|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace app\modules\admin\models\forms; |
|
4
|
|
|
|
|
5
|
|
|
use Yii; |
|
6
|
|
|
|
|
7
|
|
|
class SettingsForm extends \yii\base\Model |
|
8
|
|
|
{ |
|
9
|
|
|
/** |
|
10
|
|
|
* @var string |
|
11
|
|
|
*/ |
|
12
|
|
|
public $emailMain; |
|
13
|
|
|
/** |
|
14
|
|
|
* @var string |
|
15
|
|
|
*/ |
|
16
|
|
|
public $emailRequest; |
|
17
|
|
|
/** |
|
18
|
|
|
* @var string |
|
19
|
|
|
*/ |
|
20
|
|
|
public $emailName; |
|
21
|
|
|
/** |
|
22
|
|
|
* @var string |
|
23
|
|
|
*/ |
|
24
|
|
|
public $emailPrefix; |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* @inheritdoc |
|
28
|
|
|
*/ |
|
29
|
1 |
|
public function rules() |
|
30
|
|
|
{ |
|
31
|
|
|
return [ |
|
32
|
1 |
|
['emailRequest', 'filter', 'filter' => function ($value) { |
|
33
|
|
|
if (!empty($value)) { |
|
34
|
|
|
$emails = explode(',', $value); |
|
35
|
|
|
foreach ($emails as $email) { |
|
36
|
|
|
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { |
|
37
|
|
|
$this->addError('emailRequest', $email . ' — неверный электронный адрес'); |
|
38
|
|
|
} |
|
39
|
|
|
} |
|
40
|
|
|
} |
|
41
|
|
|
return $value; |
|
42
|
|
|
}], |
|
43
|
|
|
['emailRequest', 'trim'], |
|
44
|
|
|
|
|
45
|
|
|
[['emailMain', 'emailName', 'emailPrefix'], 'trim'], |
|
46
|
1 |
|
|
|
47
|
|
|
['emailMain', 'email'], |
|
48
|
|
|
['emailName', 'string', 'max' => 255], |
|
49
|
1 |
|
['emailPrefix', 'string', 'max' => 50], |
|
50
|
1 |
|
]; |
|
51
|
1 |
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* @inheritdoc |
|
55
|
|
|
*/ |
|
56
|
|
|
public function attributeLabels() |
|
57
|
|
|
{ |
|
58
|
1 |
|
return [ |
|
59
|
|
|
'emailMain' => Yii::t('app', 'Primary email'), |
|
60
|
|
|
'emailRequest' => Yii::t('app', 'Email for requests'), |
|
61
|
1 |
|
'emailName' => Yii::t('app', 'Sender name'), |
|
62
|
1 |
|
'emailPrefix' => Yii::t('app', 'Prefix'), |
|
63
|
|
|
]; |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* @inheritdoc |
|
68
|
|
|
*/ |
|
69
|
|
|
public function attributeHints() |
|
70
|
|
|
{ |
|
71
|
|
|
return [ |
|
72
|
|
|
'emailMain' => Yii::t('app', 'All notifications for users go to this address'), |
|
73
|
|
|
'emailPrefix' => Yii::t('app', 'Subject in the email: "Prefix: Subject"'), |
|
74
|
|
|
'emailRequest' => Yii::t('app', 'All requests from users go to this address.<br> |
|
75
|
|
|
You can specify multiple addresses separated by a comma'), |
|
76
|
|
|
]; |
|
77
|
|
|
} |
|
78
|
|
|
} |
|
79
|
|
|
|