mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-08 17:07:03 +03:00
Merge DomainAdminInterface into DomainInterface
This commit is contained in:
parent
3251611c6d
commit
398c77eb35
5 changed files with 66 additions and 96 deletions
|
|
@ -238,7 +238,7 @@ class Actions
|
||||||
$mResult = new Providers\Login\DefaultLogin();
|
$mResult = new Providers\Login\DefaultLogin();
|
||||||
break;
|
break;
|
||||||
case 'domain':
|
case 'domain':
|
||||||
// Providers\Domain\DomainAdminInterface
|
// Providers\Domain\DomainInterface
|
||||||
$mResult = new Providers\Domain\DefaultDomain(APP_PRIVATE_DATA . 'domains', $this->Cacher());
|
$mResult = new Providers\Domain\DefaultDomain(APP_PRIVATE_DATA . 'domains', $this->Cacher());
|
||||||
break;
|
break;
|
||||||
case 'filters':
|
case 'filters':
|
||||||
|
|
|
||||||
|
|
@ -14,22 +14,11 @@ class Domain extends AbstractProvider
|
||||||
*/
|
*/
|
||||||
private $oPlugins;
|
private $oPlugins;
|
||||||
|
|
||||||
/**
|
|
||||||
* @var bool
|
|
||||||
*/
|
|
||||||
private $bAdmin;
|
|
||||||
|
|
||||||
public function __construct(Domain\DomainInterface $oDriver,
|
public function __construct(Domain\DomainInterface $oDriver,
|
||||||
\RainLoop\Plugins\Manager $oPlugins)
|
\RainLoop\Plugins\Manager $oPlugins)
|
||||||
{
|
{
|
||||||
$this->oDriver = $oDriver;
|
$this->oDriver = $oDriver;
|
||||||
$this->oPlugins = $oPlugins;
|
$this->oPlugins = $oPlugins;
|
||||||
$this->bAdmin = $this->oDriver instanceof Domain\DomainAdminInterface;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function IsAdmin() : bool
|
|
||||||
{
|
|
||||||
return $this->bAdmin;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function Load(string $sName, bool $bFindWithWildCard = false, bool $bCheckDisabled = true, bool $bCheckAliases = true) : ?\RainLoop\Model\Domain
|
public function Load(string $sName, bool $bFindWithWildCard = false, bool $bCheckDisabled = true, bool $bCheckAliases = true) : ?\RainLoop\Model\Domain
|
||||||
|
|
@ -45,7 +34,7 @@ class Domain extends AbstractProvider
|
||||||
|
|
||||||
public function Save(\RainLoop\Model\Domain $oDomain) : bool
|
public function Save(\RainLoop\Model\Domain $oDomain) : bool
|
||||||
{
|
{
|
||||||
return $this->bAdmin ? $this->oDriver->Save($oDomain) : false;
|
return $this->oDriver->Save($oDomain);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function SaveAlias(string $sName, string $sAlias) : bool
|
public function SaveAlias(string $sName, string $sAlias) : bool
|
||||||
|
|
@ -55,30 +44,28 @@ class Domain extends AbstractProvider
|
||||||
throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::DomainAlreadyExists);
|
throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::DomainAlreadyExists);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->bAdmin ? $this->oDriver->SaveAlias($sName, $sAlias) : false;
|
return $this->oDriver->SaveAlias($sName, $sAlias);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function Delete(string $sName) : bool
|
public function Delete(string $sName) : bool
|
||||||
{
|
{
|
||||||
return $this->bAdmin ? $this->oDriver->Delete($sName) : false;
|
return $this->oDriver->Delete($sName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function Disable(string $sName, bool $bDisabled) : bool
|
public function Disable(string $sName, bool $bDisabled) : bool
|
||||||
{
|
{
|
||||||
return $this->bAdmin ? $this->oDriver->Disable($sName, $bDisabled) : false;
|
return $this->oDriver->Disable($sName, $bDisabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function GetList(bool $bIncludeAliases = true) : array
|
public function GetList(bool $bIncludeAliases = true) : array
|
||||||
{
|
{
|
||||||
return $this->bAdmin ? $this->oDriver->GetList($bIncludeAliases) : array();
|
return $this->oDriver->GetList($bIncludeAliases);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function LoadOrCreateNewFromAction(\RainLoop\Actions $oActions, string $sNameForTest = null) : ?\RainLoop\Model\Domain
|
public function LoadOrCreateNewFromAction(\RainLoop\Actions $oActions, string $sNameForTest = null) : ?\RainLoop\Model\Domain
|
||||||
{
|
{
|
||||||
$oDomain = null;
|
$oDomain = null;
|
||||||
|
|
||||||
if ($this->bAdmin)
|
|
||||||
{
|
|
||||||
$sName = (string) $oActions->GetActionParam('Name', '');
|
$sName = (string) $oActions->GetActionParam('Name', '');
|
||||||
|
|
||||||
if (\strlen($sName) && $sNameForTest && !\str_contains($sName, '*'))
|
if (\strlen($sName) && $sNameForTest && !\str_contains($sName, '*'))
|
||||||
|
|
@ -129,7 +116,6 @@ class Domain extends AbstractProvider
|
||||||
$sOutHost, $iOutPort, $iOutSecure, $bOutShortLogin, $bOutAuth, $bOutSetSender, $bOutUsePhpMail,
|
$sOutHost, $iOutPort, $iOutSecure, $bOutShortLogin, $bOutAuth, $bOutSetSender, $bOutUsePhpMail,
|
||||||
$sWhiteList);
|
$sWhiteList);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return $oDomain;
|
return $oDomain;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
namespace RainLoop\Providers\Domain;
|
namespace RainLoop\Providers\Domain;
|
||||||
|
|
||||||
class DefaultDomain implements \RainLoop\Providers\Domain\DomainAdminInterface
|
class DefaultDomain implements DomainInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
|
|
@ -22,25 +22,17 @@ class DefaultDomain implements \RainLoop\Providers\Domain\DomainAdminInterface
|
||||||
|
|
||||||
public function codeFileName(string $sName, bool $bBack = false) : string
|
public function codeFileName(string $sName, bool $bBack = false) : string
|
||||||
{
|
{
|
||||||
if ($bBack && 'default' === $sName)
|
if ($bBack && 'default' === $sName) {
|
||||||
{
|
|
||||||
return '*';
|
return '*';
|
||||||
}
|
}
|
||||||
else if (!$bBack && '*' === $sName)
|
|
||||||
{
|
if (!$bBack && '*' === $sName) {
|
||||||
return 'default';
|
return 'default';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($bBack)
|
return $bBack
|
||||||
{
|
? \str_replace('_wildcard_', '*', \MailSo\Base\Utils::IdnToUtf8($sName, true))
|
||||||
$sName = \MailSo\Base\Utils::IdnToUtf8($sName, true);
|
: \str_replace('*', '_wildcard_', \MailSo\Base\Utils::IdnToAscii($sName, true));
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$sName = \MailSo\Base\Utils::IdnToAscii($sName, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $bBack ? \str_replace('_wildcard_', '*', $sName) : \str_replace('*', '_wildcard_', $sName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function wildcardDomainsCacheKey() : string
|
private function wildcardDomainsCacheKey() : string
|
||||||
|
|
|
||||||
|
|
@ -1,17 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace RainLoop\Providers\Domain;
|
|
||||||
|
|
||||||
interface DomainAdminInterface extends DomainInterface
|
|
||||||
{
|
|
||||||
|
|
||||||
public function Disable(string $sName, bool $bDisable) : bool;
|
|
||||||
|
|
||||||
public function Load(string $sName, bool $bFindWithWildCard = false, bool $bCheckDisabled = true) : ?\RainLoop\Model\Domain;
|
|
||||||
|
|
||||||
public function Save(\RainLoop\Model\Domain $oDomain) : bool;
|
|
||||||
|
|
||||||
public function Delete(string $sName) : bool;
|
|
||||||
|
|
||||||
public function GetList(bool $bIncludeAliases = true) : array;
|
|
||||||
}
|
|
||||||
|
|
@ -4,4 +4,13 @@ namespace RainLoop\Providers\Domain;
|
||||||
|
|
||||||
interface DomainInterface
|
interface DomainInterface
|
||||||
{
|
{
|
||||||
|
public function Disable(string $sName, bool $bDisable) : bool;
|
||||||
|
|
||||||
|
public function Load(string $sName, bool $bFindWithWildCard = false, bool $bCheckDisabled = true) : ?\RainLoop\Model\Domain;
|
||||||
|
|
||||||
|
public function Save(\RainLoop\Model\Domain $oDomain) : bool;
|
||||||
|
|
||||||
|
public function Delete(string $sName) : bool;
|
||||||
|
|
||||||
|
public function GetList(bool $bIncludeAliases = true) : array;
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue