index.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. class HestiaChangePasswordPlugin extends \RainLoop\Plugins\AbstractPlugin
  3. {
  4. public function Init()
  5. {
  6. $this->addHook('main.fabrica', 'MainFabrica');
  7. }
  8. /**
  9. * @param string $sName
  10. * @param mixed $oProvider
  11. */
  12. public function MainFabrica($sName, &$oProvider)
  13. {
  14. switch ($sName)
  15. {
  16. case 'change-password':
  17. $sHost = \trim($this->Config()->Get('plugin', 'hestia_host', ''));
  18. $iPort = (int) $this->Config()->Get('plugin', 'hestia_port', 8083);
  19. if (!empty($sHost) && 0 < $iPort)
  20. {
  21. include_once __DIR__.'/HestiaChangePasswordDriver.php';
  22. $oProvider = new HestiaChangePasswordDriver();
  23. $oProvider->SetLogger($this->Manager()->Actions()->Logger());
  24. $oProvider->SetConfig($sHost, $iPort);
  25. $oProvider->SetAllowedEmails(\strtolower(\trim($this->Config()->Get('plugin', 'allowed_emails', ''))));
  26. }
  27. break;
  28. }
  29. }
  30. /**
  31. * @return array
  32. */
  33. public function configMapping()
  34. {
  35. return array(
  36. \RainLoop\Plugins\Property::NewInstance('hestia_host')->SetLabel('Hestia Host')
  37. ->SetDefaultValue('')
  38. ->SetDescription('Ex: localhost or domain.com'),
  39. \RainLoop\Plugins\Property::NewInstance('hestia_port')->SetLabel('Hestia Port')
  40. ->SetType(\RainLoop\Enumerations\PluginPropertyType::INT)
  41. ->SetDefaultValue(8083),
  42. \RainLoop\Plugins\Property::NewInstance('allowed_emails')->SetLabel('Allowed emails')
  43. ->SetType(\RainLoop\Enumerations\PluginPropertyType::STRING_TEXT)
  44. ->SetDescription('Allowed emails, space as delimiter, wildcard supported. Example: user1@domain1.net user2@domain1.net *@domain2.net')
  45. ->SetDefaultValue('*')
  46. );
  47. }
  48. }