Code Duplication    Length = 53-53 lines in 2 locations

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

@@ 3-55 (lines=53) @@
1
<?php
2
3
class DirectadminChangePasswordPlugin 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
				$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
}

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

@@ 3-55 (lines=53) @@
1
<?php
2
3
class VestaChangePasswordPlugin 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
                $sHost = \trim($this->Config()->Get('plugin', 'vesta_host', ''));
21
                $iPort = (int) $this->Config()->Get('plugin', 'vesta_port', 8083);
22
23
                if (!empty($sHost) && 0 < $iPort)
24
                {
25
                    include_once __DIR__.'/VestaChangePasswordDriver.php';
26
27
                    $oProvider = new VestaChangePasswordDriver();
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('vesta_host')->SetLabel('Vesta Host')
44
                ->SetDefaultValue('')
45
                ->SetDescription('Ex: localhost or domain.com'),
46
            \RainLoop\Plugins\Property::NewInstance('Vesta_port')->SetLabel('Vesta Port')
47
                ->SetType(\RainLoop\Enumerations\PluginPropertyType::INT)
48
                ->SetDefaultValue(8083),
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
}
56