DirectadminChangePasswordPlugin::Init()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 4
Ratio 100 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 4
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3 View Code Duplication
class DirectadminChangePasswordPlugin extends \RainLoop\Plugins\AbstractPlugin
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
4
{
5
	public function Init()
6
	{
7
		$this->addHook('main.fabrica', 'MainFabrica');
8
	}
9
10
	/**
11
	 * @param string $sName
12
	 * @param mixed $oProvider
13
	 */
14
	public function MainFabrica($sName, &$oProvider)
15
	{
16
		switch ($sName)
17
		{
18
			case 'change-password':
19
20
				$sHost = \trim($this->Config()->Get('plugin', 'direct_admin_host', ''));
21
				$iPort = (int) $this->Config()->Get('plugin', 'direct_admin_port', 2222);
22
23
				if (!empty($sHost) && 0 < $iPort)
24
				{
25
					include_once __DIR__.'/DirectAdminChangePasswordDriver.php';
26
27
					$oProvider = new DirectAdminChangePasswordDriver();
28
					$oProvider->SetLogger($this->Manager()->Actions()->Logger());
29
					$oProvider->SetConfig($sHost, $iPort);
30
					$oProvider->SetAllowedEmails(\strtolower(\trim($this->Config()->Get('plugin', 'allowed_emails', ''))));
31
				}
32
33
				break;
34
		}
35
	}
36
37
	/**
38
	 * @return array
39
	 */
40
	public function configMapping()
41
	{
42
		return array(
43
			\RainLoop\Plugins\Property::NewInstance('direct_admin_host')->SetLabel('DirectAdmin Host')
44
				->SetDefaultValue('')
45
				->SetDescription('Allowed patterns: {user:host-imap}, {user:host-smtp}, {user:domain}'),
46
			\RainLoop\Plugins\Property::NewInstance('direct_admin_port')->SetLabel('DirectAdmin Port')
47
				->SetType(\RainLoop\Enumerations\PluginPropertyType::INT)
48
				->SetDefaultValue(2222),
49
			\RainLoop\Plugins\Property::NewInstance('allowed_emails')->SetLabel('Allowed emails')
50
				->SetType(\RainLoop\Enumerations\PluginPropertyType::STRING_TEXT)
51
				->SetDescription('Allowed emails, space as delimiter, wildcard supported. Example: [email protected] [email protected] *@domain2.net')
52
				->SetDefaultValue('*')
53
		);
54
	}
55
}