mirror of
https://github.com/the-djmaze/snappymail.git
synced 2025-02-24 06:47:05 +08:00
Improve Issue #51
This commit is contained in:
parent
f741ce7b93
commit
4d80671bf3
1 changed files with 25 additions and 2 deletions
|
@ -24,6 +24,29 @@ class ChangePasswordPlugin extends \RainLoop\Plugins\AbstractPlugin
|
|||
$this->addTemplate('templates/SettingsChangePassword.html');
|
||||
}
|
||||
|
||||
public function Supported() : string
|
||||
{
|
||||
$oConfig = $this->Config();
|
||||
foreach (\glob(__DIR__ . '/drivers/*.php') as $file) {
|
||||
$name = \basename($file, '.php');
|
||||
if ($oConfig->Get('plugin', "driver_{$name}_enabled", false)) {
|
||||
require_once $file;
|
||||
$class = 'ChangePasswordDriver' . $name;
|
||||
$name = $class::NAME;
|
||||
try
|
||||
{
|
||||
if ($class::isSupported()) {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
catch (\Throwable $oException)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
return 'There are no change-password drivers enabled';
|
||||
}
|
||||
|
||||
public function configMapping() : array
|
||||
{
|
||||
$result = [];
|
||||
|
@ -32,7 +55,7 @@ class ChangePasswordPlugin extends \RainLoop\Plugins\AbstractPlugin
|
|||
$name = \basename($file, '.php');
|
||||
$class = 'ChangePasswordDriver' . $name;
|
||||
if ($class::isSupported()) {
|
||||
$result[] = \RainLoop\Plugins\Property::NewInstance("driver_{$name}")
|
||||
$result[] = \RainLoop\Plugins\Property::NewInstance("driver_{$name}_enabled")
|
||||
->SetLabel('Enable ' . $class::NAME)
|
||||
->SetType(\RainLoop\Enumerations\PluginPropertyType::BOOL)
|
||||
->SetDescription($class::DESCRIPTION);
|
||||
|
@ -76,7 +99,7 @@ class ChangePasswordPlugin extends \RainLoop\Plugins\AbstractPlugin
|
|||
$oConfig = $this->Config();
|
||||
foreach (\glob(__DIR__ . '/drivers/*.php') as $file) {
|
||||
$name = \basename($file, '.php');
|
||||
if ($oConfig->Get('plugin', "driver_{$name}", false)
|
||||
if ($oConfig->Get('plugin', "driver_{$name}_enabled", false)
|
||||
&& \RainLoop\Plugins\Helper::ValidateWildcardValues($oAccount->Email(), $oConfig->Get('plugin', "driver_{$name}_allowed_emails"))
|
||||
) {
|
||||
require_once $file;
|
||||
|
|
Loading…
Reference in a new issue