PoppassdChangePasswordPlugin::MainFabrica()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 20

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 2
dl 0
loc 20
rs 9.6
c 0
b 0
f 0
1
<?php
2
3
class PoppassdChangePasswordPlugin extends \RainLoop\Plugins\AbstractPlugin
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
				include_once __DIR__.'/ChangePasswordPoppassdDriver.php';
21
22
				$oProvider = new ChangePasswordPoppassdDriver();
23
24
				$oProvider
25
					->SetHost($this->Config()->Get('plugin', 'host', ''))
26
					->SetPort((int) $this->Config()->Get('plugin', 'port', 106))
27
					->SetAllowedEmails(\strtolower(\trim($this->Config()->Get('plugin', 'allowed_emails', ''))))
28
					->SetLogger($this->Manager()->Actions()->Logger())
29
				;
30
31
				break;
32
		}
33
	}
34
35
	/**
36
	 * @return array
37
	 */
38
	public function configMapping()
39
	{
40
		return array(
41
			\RainLoop\Plugins\Property::NewInstance('host')->SetLabel('POPPASSD Host')
42
				->SetDefaultValue('127.0.0.1'),
43
			\RainLoop\Plugins\Property::NewInstance('port')->SetLabel('POPPASSD Port')
44
				->SetType(\RainLoop\Enumerations\PluginPropertyType::INT)
45
				->SetDefaultValue(106),
46
			\RainLoop\Plugins\Property::NewInstance('allowed_emails')->SetLabel('Allowed emails')
47
				->SetType(\RainLoop\Enumerations\PluginPropertyType::STRING_TEXT)
48
				->SetDescription('Allowed emails, space as delimiter, wildcard supported. Example: [email protected] [email protected] *@domain2.net')
49
				->SetDefaultValue('*')
50
		);
51
	}
52
}
53