Code Duplication    Length = 46-52 lines in 2 locations

plugins/mailinabox-change-password/index.php 1 location

@@ 9-54 (lines=46) @@
6
 *
7
 * Author: Marius Gripsgard
8
 */
9
class MailInABoxChangePasswordPlugin extends \RainLoop\Plugins\AbstractPlugin
10
{
11
	public function Init()
12
	{
13
		$this->addHook('main.fabrica', 'MainFabrica');
14
	}
15
	/**
16
	 * @param string $sName
17
	 * @param mixed $oProvider
18
	 */
19
	public function MainFabrica($sName, &$oProvider)
20
	{
21
		switch ($sName)
22
		{
23
			case 'change-password':
24
				include_once __DIR__.'/MailInABoxChangePasswordDriver.php';
25
				$sHost = \trim($this->Config()->Get('plugin', 'host', ''));
26
				$sAdminUser = (string) $this->Config()->Get('plugin', 'admin_user', '');
27
				$sAdminPassword = (string) $this->Config()->Get('plugin', 'admin_password', '');
28
				$oProvider = new \MailInABoxChangePasswordDriver();
29
				$oProvider->SetLogger($this->Manager()->Actions()->Logger());
30
				$oProvider->SetConfig($sHost, $sAdminUser, $sAdminPassword);
31
				$oProvider->SetAllowedEmails(\strtolower(\trim($this->Config()->Get('plugin', 'allowed_emails', ''))));
32
				break;
33
		}
34
	}
35
	/**
36
	 * @return array
37
	 */
38
	public function configMapping()
39
	{
40
		return array(
41
			\RainLoop\Plugins\Property::NewInstance('host')->SetLabel('Mail-in-a-box Host')
42
					->SetDefaultValue('https://box.mailinabox.email')
43
					->SetDescription('Mail-in-a-box host URL. Example: https://box.mailinabox.email'),
44
			\RainLoop\Plugins\Property::NewInstance('admin_user')->SetLabel('Admin User')
45
					->SetDefaultValue(''),
46
			\RainLoop\Plugins\Property::NewInstance('admin_password')->SetLabel('Admin Password')
47
					->SetDefaultValue(''),
48
			\RainLoop\Plugins\Property::NewInstance('allowed_emails')->SetLabel('Allowed emails')
49
				->SetType(\RainLoop\Enumerations\PluginPropertyType::STRING_TEXT)
50
				->SetDescription('Allowed emails, space as delimiter, wildcard supported. Example: [email protected] [email protected] *@domain2.net')
51
				->SetDefaultValue('*')
52
		);
53
	}
54
}
55

plugins/virtualmin-change-password/index.php 1 location

@@ 3-54 (lines=52) @@
1
<?php
2
3
class VirtualminChangePasswordPlugin 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__.'/VirtualminChangePasswordDriver.php';
21
22
				$sHost = \trim($this->Config()->Get('plugin', 'host', ''));
23
				$sAdminUser = (string) $this->Config()->Get('plugin', 'admin_user', '');
24
				$sAdminPassword = (string) $this->Config()->Get('plugin', 'admin_password', '');
25
26
				$oProvider = new \VirtualminChangePasswordDriver();
27
				$oProvider->SetLogger($this->Manager()->Actions()->Logger());
28
				$oProvider->SetConfig($sHost, $sAdminUser, $sAdminPassword);
29
				$oProvider->SetAllowedEmails(\strtolower(\trim($this->Config()->Get('plugin', 'allowed_emails', ''))));
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('Virtualmin Host')
42
					->SetDefaultValue('https://localhost:10000')
43
					->SetDescription('Virtualmin host URL. Example: https://example.com:10000'),
44
			\RainLoop\Plugins\Property::NewInstance('admin_user')->SetLabel('Admin User')
45
					->SetDefaultValue(''),
46
			\RainLoop\Plugins\Property::NewInstance('admin_password')->SetLabel('Admin Password')
47
					->SetDefaultValue(''),
48
			\RainLoop\Plugins\Property::NewInstance('allowed_emails')->SetLabel('Allowed emails')
49
				->SetType(\RainLoop\Enumerations\PluginPropertyType::STRING_TEXT)
50
				->SetDescription('Allowed emails, space as delimiter, wildcard supported. Example: [email protected] [email protected] *@domain2.net')
51
				->SetDefaultValue('*')
52
		);
53
	}
54
}
55