|
1
|
|
|
<?php
|
|
2
|
|
|
|
|
3
|
|
|
class PostfixadminChangePasswordPlugin extends \RainLoop\Plugins\AbstractPlugin
|
|
4
|
|
|
{
|
|
5
|
|
|
public function Init()
|
|
6
|
|
|
{
|
|
7
|
|
|
$this->addHook('main.fabrica', 'MainFabrica');
|
|
8
|
|
|
}
|
|
9
|
|
|
|
|
10
|
|
|
/**
|
|
11
|
|
|
* @return string
|
|
12
|
|
|
*/
|
|
13
|
|
|
public function Supported()
|
|
14
|
|
|
{
|
|
15
|
|
|
if (!extension_loaded('pdo') || !class_exists('PDO'))
|
|
16
|
|
|
{
|
|
17
|
|
|
return 'The PHP extension PDO must be installed to use this plugin';
|
|
18
|
|
|
}
|
|
19
|
|
|
|
|
20
|
|
|
$aDrivers = \PDO::getAvailableDrivers();
|
|
21
|
|
|
if (!is_array($aDrivers) || (!in_array('mysql', $aDrivers) && !in_array('pgsql', $aDrivers)))
|
|
22
|
|
|
{
|
|
23
|
|
|
return 'The PHP extension PDO (mysql or pgsql) must be installed to use this plugin';
|
|
24
|
|
|
}
|
|
25
|
|
|
|
|
26
|
|
|
return '';
|
|
27
|
|
|
}
|
|
28
|
|
|
|
|
29
|
|
|
/**
|
|
30
|
|
|
* @param string $sName
|
|
31
|
|
|
* @param mixed $oProvider
|
|
32
|
|
|
*/
|
|
33
|
|
|
public function MainFabrica($sName, &$oProvider)
|
|
34
|
|
|
{
|
|
35
|
|
|
switch ($sName)
|
|
36
|
|
|
{
|
|
37
|
|
|
case 'change-password':
|
|
38
|
|
|
|
|
39
|
|
|
include_once __DIR__.'/ChangePasswordPostfixAdminDriver.php';
|
|
40
|
|
|
|
|
41
|
|
|
$oProvider = new ChangePasswordPostfixAdminDriver();
|
|
42
|
|
|
|
|
43
|
|
|
$oProvider
|
|
44
|
|
|
->SetEngine($this->Config()->Get('plugin', 'engine',''))
|
|
45
|
|
|
->SetHost($this->Config()->Get('plugin', 'host', ''))
|
|
46
|
|
|
->SetPort((int) $this->Config()->Get('plugin', 'port', 3306))
|
|
47
|
|
|
->SetDatabase($this->Config()->Get('plugin', 'database', ''))
|
|
48
|
|
|
->SetTable($this->Config()->Get('plugin', 'table', ''))
|
|
49
|
|
|
->SetUserColumn($this->Config()->Get('plugin', 'usercol', ''))
|
|
50
|
|
|
->SetPasswordColumn($this->Config()->Get('plugin', 'passcol', ''))
|
|
51
|
|
|
->SetUser($this->Config()->Get('plugin', 'user', ''))
|
|
52
|
|
|
->SetPassword($this->Config()->Get('plugin', 'password', ''))
|
|
53
|
|
|
->SetEncrypt($this->Config()->Get('plugin', 'encrypt', ''))
|
|
54
|
|
|
->SetAllowedEmails(\strtolower(\trim($this->Config()->Get('plugin', 'allowed_emails', ''))))
|
|
55
|
|
|
->SetLogger($this->Manager()->Actions()->Logger())
|
|
56
|
|
|
;
|
|
57
|
|
|
|
|
58
|
|
|
break;
|
|
59
|
|
|
}
|
|
60
|
|
|
}
|
|
61
|
|
|
|
|
62
|
|
|
/**
|
|
63
|
|
|
* @return array
|
|
64
|
|
|
*/
|
|
65
|
|
|
public function configMapping()
|
|
66
|
|
|
{
|
|
67
|
|
|
return array(
|
|
68
|
|
|
\RainLoop\Plugins\Property::NewInstance('engine')->SetLabel('Engine')
|
|
69
|
|
|
->SetType(\RainLoop\Enumerations\PluginPropertyType::SELECTION)
|
|
70
|
|
|
->SetDefaultValue(array('MySQL', 'PostgreSQL'))
|
|
71
|
|
|
->SetDescription('Database Engine'),
|
|
72
|
|
|
\RainLoop\Plugins\Property::NewInstance('host')->SetLabel('Host')
|
|
73
|
|
|
->SetDefaultValue('127.0.0.1'),
|
|
74
|
|
|
\RainLoop\Plugins\Property::NewInstance('port')->SetLabel('Port')
|
|
75
|
|
|
->SetType(\RainLoop\Enumerations\PluginPropertyType::INT)
|
|
76
|
|
|
->SetDefaultValue(3306),
|
|
77
|
|
|
\RainLoop\Plugins\Property::NewInstance('database')->SetLabel('Database')
|
|
78
|
|
|
->SetDefaultValue('postfixadmin'),
|
|
79
|
|
|
\RainLoop\Plugins\Property::NewInstance('table')->SetLabel('table')
|
|
80
|
|
|
->SetDefaultValue('mailbox'),
|
|
81
|
|
|
\RainLoop\Plugins\Property::NewInstance('usercol')->SetLabel('username column')
|
|
82
|
|
|
->SetDefaultValue('username'),
|
|
83
|
|
|
\RainLoop\Plugins\Property::NewInstance('passcol')->SetLabel('password column')
|
|
84
|
|
|
->SetDefaultValue('password'),
|
|
85
|
|
|
\RainLoop\Plugins\Property::NewInstance('user')->SetLabel('User')
|
|
86
|
|
|
->SetDefaultValue('postfixadmin'),
|
|
87
|
|
|
\RainLoop\Plugins\Property::NewInstance('password')->SetLabel('Password')
|
|
88
|
|
|
->SetType(\RainLoop\Enumerations\PluginPropertyType::PASSWORD)
|
|
89
|
|
|
->SetDefaultValue(''),
|
|
90
|
|
|
\RainLoop\Plugins\Property::NewInstance('encrypt')->SetLabel('Encrypt')
|
|
91
|
|
|
->SetType(\RainLoop\Enumerations\PluginPropertyType::SELECTION)
|
|
92
|
|
|
->SetDefaultValue(array('md5crypt', 'md5', 'system', 'cleartext', 'mysql_encrypt', 'SHA256-CRYPT', 'SHA512-CRYPT'))
|
|
93
|
|
|
->SetDescription('In what way do you want the passwords to be crypted ?'),
|
|
94
|
|
|
\RainLoop\Plugins\Property::NewInstance('allowed_emails')->SetLabel('Allowed emails')
|
|
95
|
|
|
->SetType(\RainLoop\Enumerations\PluginPropertyType::STRING_TEXT)
|
|
96
|
|
|
->SetDescription('Allowed emails, space as delimiter, wildcard supported. Example: [email protected] [email protected] *@domain2.net')
|
|
97
|
|
|
->SetDefaultValue('*')
|
|
98
|
|
|
);
|
|
99
|
|
|
}
|
|
100
|
|
|
}
|
|
101
|
|
|
|