-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathModule.php
executable file
·78 lines (66 loc) · 2.08 KB
/
Module.php
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php
namespace vova07\users;
use Yii;
/**
* Module [[Users]]
* Yii2 users module.
*/
class Module extends \yii\base\Module
{
/**
* @var boolean If true after registration user will be required to confirm his e-mail address.
*/
public $requireEmailConfirmation = true;
/**
* @var string E-mail address from that will be sent the module messages
*/
public $robotEmail;
/**
* @var string Name of e-mail sender.
* By default is `Yii::$app->name . ' robot'`.
*/
public $robotName;
/**
* @var integer The time before a sent activation token becomes invalid.
* By default is 24 hours.
*/
public $activationWithin = 86400; // 24 hours
/**
* @var integer The time before a sent recovery token becomes invalid.
* By default is 4 hours.
*/
public $recoveryWithin = 14400; // 4 hours
/**
* @var integer The time before a sent confirmation token becomes invalid.
* By default is 4 hours.
*/
public $emailWithin = 14400; // 4 hours
/**
* @var integer Users per page
*/
public $recordsPerPage = 10;
/**
* @var array User roles that can access backend module.
*/
public $adminRoles = ['superadmin', 'admin'];
/**
* @var \yii\swiftmailer\Mailer Mailer instance
*/
private $_mail;
/**
* @return \yii\swiftmailer\Mailer Mailer instance with predefined templates.
*/
public function getMail()
{
if ($this->_mail === null) {
$this->_mail = Yii::$app->getMailer();
$this->_mail->htmlLayout = '@vova07/users/mails/layouts/html';
$this->_mail->textLayout = '@vova07/users/mails/layouts/text';
$this->_mail->viewPath = '@vova07/users/mails/views';
if ($this->robotEmail !== null) {
$this->_mail->messageConfig['from'] = $this->robotName === null ? $this->robotEmail : [$this->robotEmail => $this->robotName];
}
}
return $this->_mail;
}
}