|
1
|
|
|
<?php
|
|
2
|
|
|
|
|
3
|
|
|
class FroxlorchangePasswordPlugin extends \RainLoop\Plugins\AbstractPlugin
|
|
|
|
|
|
|
4
|
|
|
{
|
|
5
|
|
|
public function Init()
|
|
6
|
|
|
{
|
|
7
|
|
|
$this->addHook('main.fabrica', 'MainFabrica');
|
|
8
|
|
|
}
|
|
9
|
|
|
|
|
10
|
|
|
/**
|
|
11
|
|
|
* @return string
|
|
12
|
|
|
*/
|
|
13
|
|
|
public function Supported()
|
|
14
|
|
|
{
|
|
15
|
|
|
if (!extension_loaded('pdo') || !class_exists('PDO'))
|
|
16
|
|
|
{
|
|
17
|
|
|
return 'The PHP exention PDO (mysql) must be installed to use this plugin';
|
|
18
|
|
|
}
|
|
19
|
|
|
|
|
20
|
|
|
$aDrivers = \PDO::getAvailableDrivers();
|
|
21
|
|
|
if (!is_array($aDrivers) || !in_array('mysql', $aDrivers))
|
|
22
|
|
|
{
|
|
23
|
|
|
return 'The PHP exention PDO (mysql) must be installed to use this plugin';
|
|
24
|
|
|
}
|
|
25
|
|
|
|
|
26
|
|
|
return '';
|
|
27
|
|
|
}
|
|
28
|
|
|
|
|
29
|
|
|
/**
|
|
30
|
|
|
* @param string $sName
|
|
31
|
|
|
* @param mixed $oProvider
|
|
32
|
|
|
*/
|
|
33
|
|
|
public function MainFabrica($sName, &$oProvider)
|
|
34
|
|
|
{
|
|
35
|
|
|
switch ($sName)
|
|
36
|
|
|
{
|
|
37
|
|
|
case 'change-password':
|
|
|
|
|
|
|
38
|
|
|
|
|
39
|
|
|
$sDsn = \trim($this->Config()->Get('plugin', 'pdo_dsn', ''));
|
|
40
|
|
|
$sUser = (string) $this->Config()->Get('plugin', 'user', '');
|
|
41
|
|
|
$sPassword = (string) $this->Config()->Get('plugin', 'password', '');
|
|
42
|
|
|
|
|
43
|
|
|
if (!empty($sDsn) && 0 < \strlen($sUser) && 0 < \strlen($sPassword))
|
|
44
|
|
|
{
|
|
45
|
|
|
include_once __DIR__.'/FroxlorChangePasswordDriver.php';
|
|
46
|
|
|
|
|
47
|
|
|
$oProvider = new FroxlorChangePasswordDriver();
|
|
48
|
|
|
$oProvider->SetLogger($this->Manager()->Actions()->Logger());
|
|
49
|
|
|
$oProvider->SetConfig($sDsn, $sUser, $sPassword);
|
|
50
|
|
|
$oProvider->SetAllowedEmails(\strtolower(\trim($this->Config()->Get('plugin', 'allowed_emails', ''))));
|
|
51
|
|
|
}
|
|
52
|
|
|
|
|
53
|
|
|
break;
|
|
54
|
|
|
}
|
|
55
|
|
|
}
|
|
56
|
|
|
|
|
57
|
|
|
/**
|
|
58
|
|
|
* @return array
|
|
59
|
|
|
*/
|
|
60
|
|
View Code Duplication |
public function configMapping()
|
|
|
|
|
|
|
61
|
|
|
{
|
|
62
|
|
|
return array(
|
|
63
|
|
|
\RainLoop\Plugins\Property::NewInstance('pdo_dsn')->SetLabel('Froxlor PDO dsn')
|
|
64
|
|
|
->SetDefaultValue('mysql:host=127.0.0.1;dbname=froxlor'),
|
|
65
|
|
|
\RainLoop\Plugins\Property::NewInstance('user')->SetLabel('DB User')
|
|
66
|
|
|
->SetDefaultValue('root'),
|
|
67
|
|
|
\RainLoop\Plugins\Property::NewInstance('password')->SetLabel('DB Password')
|
|
68
|
|
|
->SetType(\RainLoop\Enumerations\PluginPropertyType::PASSWORD)
|
|
69
|
|
|
->SetDefaultValue(''),
|
|
70
|
|
|
\RainLoop\Plugins\Property::NewInstance('allowed_emails')->SetLabel('Allowed emails')
|
|
71
|
|
|
->SetType(\RainLoop\Enumerations\PluginPropertyType::STRING_TEXT)
|
|
72
|
|
|
->SetDescription('Allowed emails, space as delimiter, wildcard supported. Example: [email protected] [email protected] *@domain2.net')
|
|
73
|
|
|
->SetDefaultValue('*')
|
|
74
|
|
|
);
|
|
75
|
|
|
}
|
|
76
|
|
|
}
|
|
77
|
|
|
|
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.