Admin panel forms improvement

Domain system  improvement
This commit is contained in:
RainLoop Team 2014-04-26 03:41:47 +04:00
parent 79721f60df
commit de0648a392
17 changed files with 265 additions and 179 deletions

View file

@ -166,8 +166,9 @@ class Account
*/
public function Hash()
{
return md5(APP_SALT.$this->Email().APP_SALT.$this->oDomain->IncHost().APP_SALT.$this->oDomain->IncPort().
APP_SALT.$this->Password().APP_SALT.'0'.APP_SALT.$this->ParentEmail().APP_SALT);
return md5(APP_SALT.$this->Email().APP_SALT.$this->oDomain->IncHost(\MailSo\Base\Utils::GetDomainFromEmail($this->Email())).
APP_SALT.$this->oDomain->IncPort().APP_SALT.$this->Password().APP_SALT.'0'.APP_SALT.$this->ParentEmail().APP_SALT);
}
/**

View file

@ -231,10 +231,8 @@ class Actions
$oResult = new \RainLoop\Providers\Login\DefaultLogin();
break;
case 'domain':
// \RainLoop\Providers\Domain\DomainSimpleInterface
// \RainLoop\Providers\Domain\DomainAdminInterface
$oResult = new \RainLoop\Providers\Domain\DefaultDomain(APP_PRIVATE_DATA.'domains',
$this->Cacher());
$oResult = new \RainLoop\Providers\Domain\DefaultDomain(APP_PRIVATE_DATA.'domains', $this->Cacher());
break;
case 'address-book':
// \RainLoop\Providers\AddressBook\AddressBookInterface
@ -849,7 +847,7 @@ class Actions
if (0 < \strlen($sEmail) && 0 < \strlen($sLogin) && 0 < \strlen($sPassword))
{
$oDomain = $this->DomainProvider()->Load(\MailSo\Base\Utils::GetDomainFromEmail($sEmail), true);
if ($oDomain instanceof \RainLoop\Domain && !$oDomain->Disabled() && $oDomain->ValidateWhiteList($sEmail, $sLogin))
if ($oDomain instanceof \RainLoop\Domain && $oDomain->ValidateWhiteList($sEmail, $sLogin))
{
$oResult = \RainLoop\Account::NewInstance($sEmail, $sLogin, $sPassword, $oDomain, $sSignMeToken);
}
@ -892,7 +890,7 @@ class Actions
$oDomain = $this->DomainProvider()->Load(\MailSo\Base\Utils::GetDomainFromEmail($aAccountHash[1]), true);
if ($bThrowExceptionOnFalse)
{
if (!($oDomain instanceof \RainLoop\Domain) || $oDomain->Disabled())
if (!($oDomain instanceof \RainLoop\Domain))
{
throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::DomainNotAllowed);
}
@ -1374,7 +1372,7 @@ class Actions
$this->loginErrorDelay();
$oDomain = $this->DomainProvider()->Load(\MailSo\Base\Utils::GetDomainFromEmail($sEmail), true);
if (!($oDomain instanceof \RainLoop\Domain) || $oDomain->Disabled())
if (!($oDomain instanceof \RainLoop\Domain))
{
throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::DomainNotAllowed);
}
@ -1439,7 +1437,8 @@ class Actions
try
{
$this->MailClient()
->Connect($oAccount->Domain()->IncHost(), $oAccount->Domain()->IncPort(), $oAccount->Domain()->IncSecure())
->Connect($oAccount->Domain()->IncHost(\MailSo\Base\Utils::GetDomainFromEmail($oAccount->Email())),
$oAccount->Domain()->IncPort(), $oAccount->Domain()->IncSecure())
->Login($oAccount->IncLogin(), $oAccount->Password())
;
}
@ -2458,9 +2457,9 @@ class Actions
$oImapClient = \MailSo\Imap\ImapClient::NewInstance()->SetLogger($this->Logger());
$oImapClient->SetTimeOuts(5);
$iTime = microtime(true);
$oImapClient->Connect($oDomain->IncHost(), $oDomain->IncPort(), $oDomain->IncSecure());
$iImapTime = microtime(true) - $iTime;
$iTime = \microtime(true);
$oImapClient->Connect($oDomain->IncHost($oDomain->Name()), $oDomain->IncPort(), $oDomain->IncSecure());
$iImapTime = \microtime(true) - $iTime;
$oImapClient->Disconnect();
$bImapResult = true;
}
@ -2474,9 +2473,9 @@ class Actions
$oSmtpClient = \MailSo\Smtp\SmtpClient::NewInstance()->SetLogger($this->Logger());
$oSmtpClient->SetTimeOuts(5);
$iTime = microtime(true);
$oSmtpClient->Connect($oDomain->OutHost(), $oDomain->OutPort(), '127.0.0.1', $oDomain->OutSecure());
$iSmtpTime = microtime(true) - $iTime;
$iTime = \microtime(true);
$oSmtpClient->Connect($oDomain->OutHost($oDomain->Name()), $oDomain->OutPort(), '127.0.0.1', $oDomain->OutSecure());
$iSmtpTime = \microtime(true) - $iTime;
$oSmtpClient->Disconnect();
$bSmtpResult = true;
}
@ -4249,7 +4248,7 @@ class Actions
$aSmtpCredentials = array(
'Ehlo' => \MailSo\Smtp\SmtpClient::EhloHelper(),
'Host' => $oAccount->Domain()->OutHost(),
'Host' => $oAccount->Domain()->OutHost(\MailSo\Base\Utils::GetDomainFromEmail($oAccount->Email())),
'Port' => $oAccount->Domain()->OutPort(),
'Secure' => $oAccount->Domain()->OutSecure(),
'UseAuth' => $oAccount->Domain()->OutAuth(),
@ -6160,7 +6159,8 @@ class Actions
try
{
$this->MailClient()
->Connect($oAccount->Domain()->IncHost(), $oAccount->Domain()->IncPort(), $oAccount->Domain()->IncSecure())
->Connect($oAccount->Domain()->IncHost(\MailSo\Base\Utils::GetDomainFromEmail($oAccount->Email())),
$oAccount->Domain()->IncPort(), $oAccount->Domain()->IncSecure())
->Login($oAccount->IncLogin(), $oAccount->Password(), !!$this->Config()->Get('labs', 'use_imap_auth_plain'))
;
}

View file

@ -63,11 +63,6 @@ class Domain
*/
private $sWhiteList;
/**
* @var bool
*/
private $bDisabled;
/**
* @param string $sName
* @param string $sIncHost
@ -95,7 +90,6 @@ class Domain
$this->bOutShortLogin = $bOutShortLogin;
$this->bOutAuth = $bOutAuth;
$this->sWhiteList = \trim($sWhiteList);
$this->bDisabled = false;
}
/**
@ -125,6 +119,7 @@ class Domain
}
/**
* @param string $sName
* @param array $aDomain
*
* @return \RainLoop\Domain|null
@ -171,14 +166,6 @@ class Domain
return str_replace('"', '\\"', $sStr);
}
/**
* @param bool0 $bDisabled
*/
public function SetDisabled($bDisabled)
{
$this->bDisabled = (bool) $bDisabled;
}
public function Normalize()
{
$this->sIncHost = \trim($this->sIncHost);
@ -299,11 +286,13 @@ class Domain
}
/**
* @param string $sRealDomainName = ''
*
* @return string
*/
public function IncHost()
public function IncHost($sRealDomainName = '')
{
return $this->sIncHost;
return 0 < \strlen($sRealDomainName) ? \str_replace('{domain:name}', $sRealDomainName, $this->sIncHost) : $this->sIncHost;
}
/**
@ -331,11 +320,12 @@ class Domain
}
/**
* @param string $sRealDomainName = ''
* @return string
*/
public function OutHost()
public function OutHost($sRealDomainName = '')
{
return $this->sOutHost;
return 0 < \strlen($sRealDomainName) ? \str_replace('{domain:name}', $sRealDomainName, $this->sOutHost) : $this->sOutHost;
}
/**
@ -378,14 +368,6 @@ class Domain
return $this->sWhiteList;
}
/**
* @return bool
*/
public function Disabled()
{
return $this->bDisabled;
}
/**
* @param string $sEmail
* @param string $sLogin = ''

View file

@ -35,13 +35,13 @@ class Domain extends \RainLoop\Providers\AbstractProvider
/**
* @param string $sName
* @param bool $bDefaultOnNull = false
* @param bool $bFindWithWildCard = false
*
* @return \RainLoop\Domain|null
*/
public function Load($sName, $bDefaultOnNull = false)
public function Load($sName, $bFindWithWildCard = false)
{
return $this->oDriver->Load($sName, $bDefaultOnNull);
return $this->oDriver->Load($sName, $bFindWithWildCard);
}
/**
@ -122,6 +122,11 @@ class Domain extends \RainLoop\Providers\AbstractProvider
$bOutAuth = '1' === (string) $oActions->GetActionParam('OutAuth', '1');
$sWhiteList = (string) $oActions->GetActionParam('WhiteList', '');
if (0 < \strlen($sName) && 0 < strlen($sNameForTest) && false === \strpos($sName, '*'))
{
$sNameForTest = '';
}
if (0 < strlen($sName) || 0 < strlen($sNameForTest))
{
$oDomain = 0 < strlen($sNameForTest) ? null : $this->Load($sName);

View file

@ -141,15 +141,22 @@ class DefaultDomain implements \RainLoop\Providers\Domain\DomainAdminInterface
public function Load($sName, $bFindWithWildCard = false)
{
$mResult = null;
$sDisabled = '';
$sFoundedValue = '';
$sName = \strtolower($sName);
$sRealFileName = $this->codeFileName($sName);
if (\file_exists($this->sDomainPath.'/'.$sRealFileName.'.ini'))
if (\file_exists($this->sDomainPath.'/disabled'))
{
$aDomain = @\parse_ini_file($this->sDomainPath.'/'.$sRealFileName.'.ini');
$sDisabled = @\file_get_contents($this->sDomainPath.'/disabled');
}
if (\file_exists($this->sDomainPath.'/'.$sRealFileName.'.ini') &&
(0 === \strlen($sDisabled) || false === \strpos(\strtolower(','.$sDisabled.','), \strtolower(','.$sName.','))))
{
$aDomain = @\parse_ini_file($this->sDomainPath.'/'.$sRealFileName.'.ini');
// fix misspellings (#119)
if (\is_array($aDomain))
{
@ -184,20 +191,10 @@ class DefaultDomain implements \RainLoop\Providers\Domain\DomainAdminInterface
{
if (\RainLoop\Plugins\Helper::ValidateWildcardValues($sName, $sNames, $sFoundedValue) && 0 < \strlen($sFoundedValue))
{
$mResult = $this->Load($sFoundedValue, false);
}
}
}
if ($mResult instanceof \RainLoop\Domain)
{
if (\file_exists($this->sDomainPath.'/disabled'))
{
$sDisabled = @\file_get_contents($this->sDomainPath.'/disabled');
if (false !== $sDisabled && 0 < \strlen($sDisabled))
{
$sDisabledName = 0 < \strlen($sFoundedValue) ? $sFoundedValue : $sName;
$mResult->SetDisabled(false !== \strpos(strtolower(','.$sDisabled.','), \strtolower(','.$sDisabledName.',')));
if (0 === \strlen($sDisabled) || false === \strpos(\strtolower(','.$sDisabled.','), \strtolower(','.$sFoundedValue.',')))
{
$mResult = $this->Load($sFoundedValue, false);
}
}
}
}

View file

@ -1,49 +1,50 @@
<?php
namespace RainLoop\Providers\Domain;
interface DomainAdminInterface extends DomainInterface
{
/**
* @param string $sName
* @param bool $bDisable
*
* @return bool
*/
public function Disable($sName, $bDisable);
/**
* @param string $sName
*
* @return \RainLoop\Domain | null
*/
public function Load($sName);
/**
* @param \RainLoop\Domain $oDomain
*
* @return bool
*/
public function Save(\RainLoop\Domain $oDomain);
/**
* @param string $sName
*
* @return bool
*/
public function Delete($sName);
/**
* @param int $iOffset
* @param int $iLimit = 20
*
* @return array
*/
public function GetList($iOffset, $iLimit = 20);
/**
* @return int
*/
public function Count();
<?php
namespace RainLoop\Providers\Domain;
interface DomainAdminInterface extends DomainInterface
{
/**
* @param string $sName
* @param bool $bDisable
*
* @return bool
*/
public function Disable($sName, $bDisable);
/**
* @param string $sName
* @param bool $bFindWithWildCard = false
*
* @return \RainLoop\Domain | null
*/
public function Load($sName, $bFindWithWildCard = false);
/**
* @param \RainLoop\Domain $oDomain
*
* @return bool
*/
public function Save(\RainLoop\Domain $oDomain);
/**
* @param string $sName
*
* @return bool
*/
public function Delete($sName);
/**
* @param int $iOffset
* @param int $iLimit = 20
*
* @return array
*/
public function GetList($iOffset, $iLimit = 20);
/**
* @return int
*/
public function Count();
}

View file

@ -1,13 +0,0 @@
<?php
namespace RainLoop\Providers\Domain;
interface DomainSimpleInterface extends DomainInterface
{
/**
* @param string $sName
*
* @return \RainLoop\Domain | null
*/
public function Load($sName);
}