mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-03 22:47:03 +03:00
Sieve configuration form (Domain)
This commit is contained in:
parent
ebce312d1a
commit
7841658791
9 changed files with 393 additions and 69 deletions
|
|
@ -63,6 +63,31 @@ class Domain
|
|||
*/
|
||||
private $bOutUsePhpMail;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $bUseSieve;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $bUseImapServerForSieve;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $sSieveHost;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $iSievePort;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $iSieveSecure;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
|
|
@ -74,6 +99,11 @@ class Domain
|
|||
* @param int $iIncPort
|
||||
* @param int $iIncSecure
|
||||
* @param bool $bIncShortLogin
|
||||
* @param bool $bUseSieve
|
||||
* @param bool $bUseImapServerForSieve
|
||||
* @param string $sSieveHost
|
||||
* @param int $iSievePort
|
||||
* @param int $iSieveSecure
|
||||
* @param string $sOutHost
|
||||
* @param int $iOutPort
|
||||
* @param int $iOutSecure
|
||||
|
|
@ -82,20 +112,31 @@ class Domain
|
|||
* @param bool $bOutUsePhpMail = false
|
||||
* @param string $sWhiteList = ''
|
||||
*/
|
||||
private function __construct($sName, $sIncHost, $iIncPort, $iIncSecure, $bIncShortLogin,
|
||||
$sOutHost, $iOutPort, $iOutSecure, $bOutShortLogin, $bOutAuth, $bOutUsePhpMail = false, $sWhiteList = '')
|
||||
private function __construct($sName,
|
||||
$sIncHost, $iIncPort, $iIncSecure, $bIncShortLogin,
|
||||
$bUseSieve, $bUseImapServerForSieve, $sSieveHost, $iSievePort, $iSieveSecure,
|
||||
$sOutHost, $iOutPort, $iOutSecure, $bOutShortLogin, $bOutAuth, $bOutUsePhpMail = false,
|
||||
$sWhiteList = '')
|
||||
{
|
||||
$this->sName = $sName;
|
||||
$this->sIncHost = $sIncHost;
|
||||
$this->iIncPort = $iIncPort;
|
||||
$this->iIncSecure = $iIncSecure;
|
||||
$this->bIncShortLogin = $bIncShortLogin;
|
||||
|
||||
$this->sOutHost = $sOutHost;
|
||||
$this->iOutPort = $iOutPort;
|
||||
$this->iOutSecure = $iOutSecure;
|
||||
$this->bOutShortLogin = $bOutShortLogin;
|
||||
$this->bOutAuth = $bOutAuth;
|
||||
$this->bOutUsePhpMail = $bOutUsePhpMail;
|
||||
|
||||
$this->bUseSieve = $bUseSieve;
|
||||
$this->bUseImapServerForSieve = $bUseImapServerForSieve;
|
||||
$this->sSieveHost = $sSieveHost;
|
||||
$this->iSievePort = $iSievePort;
|
||||
$this->iSieveSecure = $iSieveSecure;
|
||||
|
||||
$this->sWhiteList = \trim($sWhiteList);
|
||||
}
|
||||
|
||||
|
|
@ -105,6 +146,11 @@ class Domain
|
|||
* @param int $iIncPort
|
||||
* @param int $iIncSecure
|
||||
* @param bool $bIncShortLogin
|
||||
* @param bool $bUseSieve
|
||||
* @param bool $bUseImapServerForSieve
|
||||
* @param string $sSieveHost
|
||||
* @param int $iSievePort
|
||||
* @param int $iSieveSecure
|
||||
* @param string $sOutHost
|
||||
* @param int $iOutPort
|
||||
* @param int $iOutSecure
|
||||
|
|
@ -117,11 +163,13 @@ class Domain
|
|||
*/
|
||||
public static function NewInstance($sName,
|
||||
$sIncHost, $iIncPort, $iIncSecure, $bIncShortLogin,
|
||||
$bUseSieve, $bUseImapServerForSieve, $sSieveHost, $iSievePort, $iSieveSecure,
|
||||
$sOutHost, $iOutPort, $iOutSecure, $bOutShortLogin, $bOutAuth, $bOutUsePhpMail,
|
||||
$sWhiteList = '')
|
||||
{
|
||||
return new self($sName,
|
||||
$sIncHost, $iIncPort, $iIncSecure, $bIncShortLogin,
|
||||
$bUseSieve, $bUseImapServerForSieve, $sSieveHost, $iSievePort, $iSieveSecure,
|
||||
$sOutHost, $iOutPort, $iOutSecure, $bOutShortLogin, $bOutAuth, $bOutUsePhpMail,
|
||||
$sWhiteList);
|
||||
}
|
||||
|
|
@ -143,6 +191,11 @@ class Domain
|
|||
$iIncSecure = self::StrConnectionSecurityTypeToCons(
|
||||
!empty($aDomain['imap_secure']) ? $aDomain['imap_secure'] : '');
|
||||
|
||||
$sSieveHost = empty($aDomain['sieve_host']) ? '' : (string) $aDomain['sieve_host'];
|
||||
$iSievePort = empty($aDomain['sieve_port']) ? 2000 : (int) $aDomain['sieve_port'];
|
||||
$iSieveSecure = self::StrConnectionSecurityTypeToCons(
|
||||
!empty($aDomain['sieve_secure']) ? $aDomain['sieve_secure'] : '');
|
||||
|
||||
$sOutHost = empty($aDomain['smtp_host']) ? '' : (string) $aDomain['smtp_host'];
|
||||
$iOutPort = empty($aDomain['smtp_port']) ? 25 : (int) $aDomain['smtp_port'];
|
||||
$iOutSecure = self::StrConnectionSecurityTypeToCons(
|
||||
|
|
@ -152,11 +205,15 @@ class Domain
|
|||
$bOutUsePhpMail = isset($aDomain['smtp_php_mail']) ? (bool) $aDomain['smtp_php_mail'] : false;
|
||||
$sWhiteList = (string) (isset($aDomain['white_list']) ? $aDomain['white_list'] : '');
|
||||
|
||||
$bUseSieve = isset($aDomain['sieve_use']) ? (bool) $aDomain['sieve_use'] : false;
|
||||
$bUseImapServerForSieve = isset($aDomain['sieve_use_imap_server']) ? (bool) $aDomain['sieve_use_imap_server'] : ytir;
|
||||
|
||||
$bIncShortLogin = isset($aDomain['imap_short_login']) ? (bool) $aDomain['imap_short_login'] : false;
|
||||
$bOutShortLogin = isset($aDomain['smtp_short_login']) ? (bool) $aDomain['smtp_short_login'] : false;
|
||||
|
||||
$oDomain = self::NewInstance($sName,
|
||||
$sIncHost, $iIncPort, $iIncSecure, $bIncShortLogin,
|
||||
$bUseSieve, $bUseImapServerForSieve, $sSieveHost, $iSievePort, $iSieveSecure,
|
||||
$sOutHost, $iOutPort, $iOutSecure, $bOutShortLogin, $bOutAuth, $bOutUsePhpMail,
|
||||
$sWhiteList);
|
||||
}
|
||||
|
|
@ -177,6 +234,7 @@ class Domain
|
|||
public function Normalize()
|
||||
{
|
||||
$this->sIncHost = \trim($this->sIncHost);
|
||||
$this->sSieveHost = \trim($this->sSieveHost);
|
||||
$this->sOutHost = \trim($this->sOutHost);
|
||||
$this->sWhiteList = \trim($this->sWhiteList);
|
||||
|
||||
|
|
@ -185,6 +243,11 @@ class Domain
|
|||
$this->iIncPort = 143;
|
||||
}
|
||||
|
||||
if ($this->iSievePort <= 0)
|
||||
{
|
||||
$this->iSievePort = 2000;
|
||||
}
|
||||
|
||||
if ($this->iOutPort <= 0)
|
||||
{
|
||||
$this->iOutPort = 25;
|
||||
|
|
@ -197,11 +260,16 @@ class Domain
|
|||
public function ToIniString()
|
||||
{
|
||||
$this->Normalize();
|
||||
return implode("\n", array(
|
||||
return \implode("\n", array(
|
||||
'imap_host = "'.$this->encodeIniString($this->sIncHost).'"',
|
||||
'imap_port = '.$this->iIncPort,
|
||||
'imap_secure = "'.self::ConstConnectionSecurityTypeToStr($this->iIncSecure).'"',
|
||||
'imap_short_login = '.($this->bIncShortLogin ? 'On' : 'Off'),
|
||||
'sieve_use = '.($this->bUseSieve ? 'On' : 'Off'),
|
||||
'sieve_use_imap_server = '.($this->bUseImapServerForSieve ? 'On' : 'Off'),
|
||||
'sieve_host = "'.$this->encodeIniString($this->sSieveHost).'"',
|
||||
'sieve_port = '.$this->iSievePort,
|
||||
'sieve_secure = "'.self::ConstConnectionSecurityTypeToStr($this->iSieveSecure).'"',
|
||||
'smtp_host = "'.$this->encodeIniString($this->sOutHost).'"',
|
||||
'smtp_port = '.$this->iOutPort,
|
||||
'smtp_secure = "'.self::ConstConnectionSecurityTypeToStr($this->iOutSecure).'"',
|
||||
|
|
@ -258,6 +326,8 @@ class Domain
|
|||
* @param int $iIncPort
|
||||
* @param int $iIncSecure
|
||||
* @param bool $bIncShortLogin
|
||||
* @param bool $bUseSieve
|
||||
* @param bool $bUseImapServerForSieve
|
||||
* @param string $sOutHost
|
||||
* @param int $iOutPort
|
||||
* @param int $iOutSecure
|
||||
|
|
@ -270,6 +340,7 @@ class Domain
|
|||
*/
|
||||
public function UpdateInstance(
|
||||
$sIncHost, $iIncPort, $iIncSecure, $bIncShortLogin,
|
||||
$bUseSieve, $bUseImapServerForSieve, $sSieveHost, $iSievePort, $iSieveSecure,
|
||||
$sOutHost, $iOutPort, $iOutSecure, $bOutShortLogin, $bOutAuth, $bOutUsePhpMail,
|
||||
$sWhiteList = '')
|
||||
{
|
||||
|
|
@ -277,12 +348,20 @@ class Domain
|
|||
$this->iIncPort = $iIncPort;
|
||||
$this->iIncSecure = $iIncSecure;
|
||||
$this->bIncShortLogin = $bIncShortLogin;
|
||||
|
||||
$this->bUseSieve = $bUseSieve;
|
||||
$this->bUseImapServerForSieve = $bUseImapServerForSieve;
|
||||
$this->sSieveHost = \MailSo\Base\Utils::IdnToAscii($sSieveHost);
|
||||
$this->iSievePort = $iSievePort;
|
||||
$this->iSieveSecure = $iSieveSecure;
|
||||
|
||||
$this->sOutHost = \MailSo\Base\Utils::IdnToAscii($sOutHost);
|
||||
$this->iOutPort = $iOutPort;
|
||||
$this->iOutSecure = $iOutSecure;
|
||||
$this->bOutShortLogin = $bOutShortLogin;
|
||||
$this->bOutAuth = $bOutAuth;
|
||||
$this->bOutUsePhpMail = $bOutUsePhpMail;
|
||||
|
||||
$this->sWhiteList = \trim($sWhiteList);
|
||||
|
||||
return $this;
|
||||
|
|
@ -328,6 +407,46 @@ class Domain
|
|||
return $this->bIncShortLogin;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function UseSieve()
|
||||
{
|
||||
return $this->bUseSieve;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function UseImapServerForSieve()
|
||||
{
|
||||
return $this->bUseImapServerForSieve;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function SieveHost()
|
||||
{
|
||||
return $this->sSieveHost;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function SievePort()
|
||||
{
|
||||
return $this->iSievePort;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function SieveSecure()
|
||||
{
|
||||
return $this->iSieveSecure;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
|
|
@ -421,6 +540,11 @@ class Domain
|
|||
'IncPort' => $this->IncPort(),
|
||||
'IncSecure' => $this->IncSecure(),
|
||||
'IncShortLogin' => $this->IncShortLogin(),
|
||||
'UseSieve' => $this->UseSieve(),
|
||||
'UseImapServerForSieve' => $this->UseImapServerForSieve(),
|
||||
'SieveHost' => $bAjax ? \MailSo\Base\Utils::IdnToUtf8($this->SieveHost()) : $this->SieveHost(),
|
||||
'SievePort' => $this->SievePort(),
|
||||
'SieveSecure' => $this->SieveSecure(),
|
||||
'OutHost' => $bAjax ? \MailSo\Base\Utils::IdnToUtf8($this->OutHost()) : $this->OutHost(),
|
||||
'OutPort' => $this->OutPort(),
|
||||
'OutSecure' => $this->OutSecure(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue