|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
class HmailserverChangePasswordPlugin 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 (!class_exists('COM')) |
|
16
|
|
|
{ |
|
17
|
|
|
return 'The PHP extension COM must be installed to use this plugin'; |
|
18
|
|
|
} |
|
19
|
|
|
|
|
20
|
|
|
return ''; |
|
21
|
|
|
} |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* @param string $sName |
|
25
|
|
|
* @param mixed $oProvider |
|
26
|
|
|
*/ |
|
27
|
|
|
public function MainFabrica($sName, &$oProvider) |
|
28
|
|
|
{ |
|
29
|
|
|
switch ($sName) |
|
30
|
|
|
{ |
|
31
|
|
|
case 'change-password': |
|
32
|
|
|
|
|
33
|
|
|
$sLogin = (string) $this->Config()->Get('plugin', 'login', ''); |
|
34
|
|
|
$sPassword = (string) $this->Config()->Get('plugin', 'password', ''); |
|
35
|
|
|
|
|
36
|
|
|
if (0 < \strlen($sLogin) && 0 < \strlen($sPassword)) |
|
37
|
|
|
{ |
|
38
|
|
|
include_once __DIR__.'/HmailserverChangePasswordDriver.php'; |
|
39
|
|
|
|
|
40
|
|
|
$oProvider = new HmailserverChangePasswordDriver(); |
|
41
|
|
|
$oProvider->SetLogger($this->Manager()->Actions()->Logger()); |
|
42
|
|
|
$oProvider->SetConfig($sLogin, $sPassword); |
|
43
|
|
|
$oProvider->SetAllowedEmails(\strtolower(\trim($this->Config()->Get('plugin', 'allowed_emails', '')))); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
break; |
|
47
|
|
|
} |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* @return array |
|
52
|
|
|
*/ |
|
53
|
|
|
public function configMapping() |
|
54
|
|
|
{ |
|
55
|
|
|
return array( |
|
56
|
|
|
\RainLoop\Plugins\Property::NewInstance('login')->SetLabel('HmailServer Admin Login') |
|
57
|
|
|
->SetDefaultValue('Administrator'), |
|
58
|
|
|
\RainLoop\Plugins\Property::NewInstance('password')->SetLabel('HmailServer Admin Password') |
|
59
|
|
|
->SetType(\RainLoop\Enumerations\PluginPropertyType::PASSWORD) |
|
60
|
|
|
->SetDefaultValue(''), |
|
61
|
|
|
\RainLoop\Plugins\Property::NewInstance('allowed_emails')->SetLabel('Allowed emails') |
|
62
|
|
|
->SetType(\RainLoop\Enumerations\PluginPropertyType::STRING_TEXT) |
|
63
|
|
|
->SetDescription('Allowed emails, space as delimiter, wildcard supported. Example: [email protected] [email protected] *@domain2.net') |
|
64
|
|
|
->SetDefaultValue('*') |
|
65
|
|
|
); |
|
66
|
|
|
} |
|
67
|
|
|
} |