mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-09 09:27: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();
|
||||
break;
|
||||
case 'domain':
|
||||
// Providers\Domain\DomainAdminInterface
|
||||
// Providers\Domain\DomainInterface
|
||||
$mResult = new Providers\Domain\DefaultDomain(APP_PRIVATE_DATA . 'domains', $this->Cacher());
|
||||
break;
|
||||
case 'filters':
|
||||
|
|
|
|||
|
|
@ -14,22 +14,11 @@ class Domain extends AbstractProvider
|
|||
*/
|
||||
private $oPlugins;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $bAdmin;
|
||||
|
||||
public function __construct(Domain\DomainInterface $oDriver,
|
||||
\RainLoop\Plugins\Manager $oPlugins)
|
||||
{
|
||||
$this->oDriver = $oDriver;
|
||||
$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
|
||||
|
|
@ -45,7 +34,7 @@ class Domain extends AbstractProvider
|
|||
|
||||
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
|
||||
|
|
@ -55,30 +44,28 @@ class Domain extends AbstractProvider
|
|||
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
|
||||
{
|
||||
return $this->bAdmin ? $this->oDriver->Delete($sName) : false;
|
||||
return $this->oDriver->Delete($sName);
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
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
|
||||
{
|
||||
$oDomain = null;
|
||||
|
||||
if ($this->bAdmin)
|
||||
{
|
||||
$sName = (string) $oActions->GetActionParam('Name', '');
|
||||
|
||||
if (\strlen($sName) && $sNameForTest && !\str_contains($sName, '*'))
|
||||
|
|
@ -129,7 +116,6 @@ class Domain extends AbstractProvider
|
|||
$sOutHost, $iOutPort, $iOutSecure, $bOutShortLogin, $bOutAuth, $bOutSetSender, $bOutUsePhpMail,
|
||||
$sWhiteList);
|
||||
}
|
||||
}
|
||||
|
||||
return $oDomain;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace RainLoop\Providers\Domain;
|
||||
|
||||
class DefaultDomain implements \RainLoop\Providers\Domain\DomainAdminInterface
|
||||
class DefaultDomain implements DomainInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
|
|
@ -22,25 +22,17 @@ class DefaultDomain implements \RainLoop\Providers\Domain\DomainAdminInterface
|
|||
|
||||
public function codeFileName(string $sName, bool $bBack = false) : string
|
||||
{
|
||||
if ($bBack && 'default' === $sName)
|
||||
{
|
||||
if ($bBack && 'default' === $sName) {
|
||||
return '*';
|
||||
}
|
||||
else if (!$bBack && '*' === $sName)
|
||||
{
|
||||
|
||||
if (!$bBack && '*' === $sName) {
|
||||
return 'default';
|
||||
}
|
||||
|
||||
if ($bBack)
|
||||
{
|
||||
$sName = \MailSo\Base\Utils::IdnToUtf8($sName, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
$sName = \MailSo\Base\Utils::IdnToAscii($sName, true);
|
||||
}
|
||||
|
||||
return $bBack ? \str_replace('_wildcard_', '*', $sName) : \str_replace('*', '_wildcard_', $sName);
|
||||
return $bBack
|
||||
? \str_replace('_wildcard_', '*', \MailSo\Base\Utils::IdnToUtf8($sName, true))
|
||||
: \str_replace('*', '_wildcard_', \MailSo\Base\Utils::IdnToAscii($sName, true));
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
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