ChangePasswordCustomSqlPlugin::configMapping()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 16
rs 9.7333
c 0
b 0
f 0
1
<?php
2
3
class ChangePasswordCustomSqlPlugin 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
				include_once __DIR__.'/ChangePasswordCustomSqlDriver.php';
20
				$oProvider = new ChangePasswordCustomSqlDriver();
21
				$oProvider
22
					->SetLogger($this->Manager()->Actions()->Logger())
23
					->SetmHost($this->Config()->Get('plugin', 'mHost', ''))
24
					->SetmUser($this->Config()->Get('plugin', 'mUser', ''))
25
					->SetmPass($this->Config()->Get('plugin', 'mPass', ''))
26
					->SetmDatabase($this->Config()->Get('plugin', 'mDatabase', ''))
27
					->SetmTable($this->Config()->Get('plugin', 'mTable', ''))
28
					->SetmSql($this->Config()->Get('plugin', 'mSql', ''))
29
				;
30
				break;
31
		}
32
	}
33
34
	/**
35
	 * @return array
36
	 */
37
	public function configMapping()
38
	{
39
		return array(
40
			\RainLoop\Plugins\Property::NewInstance('mHost')->SetLabel('MySQL Host')
41
				->SetDefaultValue('127.0.0.1'),
42
			\RainLoop\Plugins\Property::NewInstance('mUser')->SetLabel('MySQL User'),
43
			\RainLoop\Plugins\Property::NewInstance('mPass')->SetLabel('MySQL Password')
44
				->SetType(\RainLoop\Enumerations\PluginPropertyType::PASSWORD),
45
			\RainLoop\Plugins\Property::NewInstance('mDatabase')->SetLabel('MySQL Database'),
46
			\RainLoop\Plugins\Property::NewInstance('mTable')->SetLabel('MySQL Table'),
47
			\RainLoop\Plugins\Property::NewInstance('mSql')->SetLabel('SQL statement')
48
				->SetType(\RainLoop\Enumerations\PluginPropertyType::STRING_TEXT)
49
				->SetDescription('SQL statement (allowed wildcards :table, :email, :oldpass, :newpass, :domain, :username). Use SQL functions for encryption.')
50
				->SetDefaultValue('UPDATE :table SET password = md5(:newpass) WHERE domain = :domain AND username = :username and oldpass = md5(:oldpass)')
51
		);
52
	}
53
}
54