Sieve configuration form (Domain)

This commit is contained in:
RainLoop Team 2014-11-20 01:32:20 +04:00
parent ebce312d1a
commit 7841658791
9 changed files with 393 additions and 69 deletions

View file

@ -81,6 +81,12 @@
*/ */
Consts.Values.ImapDefaulSecurePort = 993; Consts.Values.ImapDefaulSecurePort = 993;
/**
* @const
* @type {number}
*/
Consts.Values.SieveDefaulPort = 2000;
/** /**
* @const * @const
* @type {number} * @type {number}

View file

@ -210,34 +210,53 @@
}; };
RemoteAdminStorage.prototype.createOrUpdateDomain = function (fCallback, RemoteAdminStorage.prototype.createOrUpdateDomain = function (fCallback,
bCreate, sName, sIncHost, iIncPort, sIncSecure, bIncShortLogin, bCreate, sName,
sOutHost, iOutPort, sOutSecure, bOutShortLogin, bOutAuth, bOutPhpMail, sWhiteList) sIncHost, iIncPort, sIncSecure, bIncShortLogin,
bUseSieve, bUseImapServerForSieve, sSieveHost, iSievePort, sSieveSecure,
sOutHost, iOutPort, sOutSecure, bOutShortLogin, bOutAuth, bOutPhpMail,
sWhiteList)
{ {
this.defaultRequest(fCallback, 'AdminDomainSave', { this.defaultRequest(fCallback, 'AdminDomainSave', {
'Create': bCreate ? '1' : '0', 'Create': bCreate ? '1' : '0',
'Name': sName, 'Name': sName,
'IncHost': sIncHost, 'IncHost': sIncHost,
'IncPort': iIncPort, 'IncPort': iIncPort,
'IncSecure': sIncSecure, 'IncSecure': sIncSecure,
'IncShortLogin': bIncShortLogin ? '1' : '0', 'IncShortLogin': bIncShortLogin ? '1' : '0',
'UseSieve': bUseSieve ? '1' : '0',
'UseImapServerForSieve': bUseImapServerForSieve ? '1' : '0',
'SieveHost': sSieveHost,
'SievePort': iSievePort,
'SieveSecure': sSieveSecure,
'OutHost': sOutHost, 'OutHost': sOutHost,
'OutPort': iOutPort, 'OutPort': iOutPort,
'OutSecure': sOutSecure, 'OutSecure': sOutSecure,
'OutShortLogin': bOutShortLogin ? '1' : '0', 'OutShortLogin': bOutShortLogin ? '1' : '0',
'OutAuth': bOutAuth ? '1' : '0', 'OutAuth': bOutAuth ? '1' : '0',
'OutUsePhpMail': bOutPhpMail ? '1' : '0', 'OutUsePhpMail': bOutPhpMail ? '1' : '0',
'WhiteList': sWhiteList 'WhiteList': sWhiteList
}); });
}; };
RemoteAdminStorage.prototype.testConnectionForDomain = function (fCallback, sName, RemoteAdminStorage.prototype.testConnectionForDomain = function (fCallback, sName,
sIncHost, iIncPort, sIncSecure, sOutHost, iOutPort, sOutSecure, bOutAuth, bOutPhpMail) sIncHost, iIncPort, sIncSecure,
bUseSieve, bUseImapServerForSieve, sSieveHost, iSievePort, sSieveSecure,
sOutHost, iOutPort, sOutSecure, bOutAuth, bOutPhpMail)
{ {
this.defaultRequest(fCallback, 'AdminDomainTest', { this.defaultRequest(fCallback, 'AdminDomainTest', {
'Name': sName, 'Name': sName,
'IncHost': sIncHost, 'IncHost': sIncHost,
'IncPort': iIncPort, 'IncPort': iIncPort,
'IncSecure': sIncSecure, 'IncSecure': sIncSecure,
'UseSieve': bUseSieve ? '1' : '0',
'UseImapServerForSieve': bUseImapServerForSieve ? '1' : '0',
'SieveHost': sSieveHost,
'SievePort': iSievePort,
'SieveSecure': sSieveSecure,
'OutHost': sOutHost, 'OutHost': sOutHost,
'OutPort': iOutPort, 'OutPort': iOutPort,
'OutSecure': sOutSecure, 'OutSecure': sOutSecure,

View file

@ -20,7 +20,7 @@
height: 320px; height: 320px;
} }
&.domain-white-list-page .modal-body { &.domain-second-page .modal-body {
left: -800px; left: -800px;
} }

View file

@ -28,7 +28,8 @@
this.edit = ko.observable(false); this.edit = ko.observable(false);
this.saving = ko.observable(false); this.saving = ko.observable(false);
this.savingError = ko.observable(''); this.savingError = ko.observable('');
this.whiteListPage = ko.observable(false); this.page = ko.observable('main');
this.sieveSettings = ko.observable(false);
this.testing = ko.observable(false); this.testing = ko.observable(false);
this.testingDone = ko.observable(false); this.testingDone = ko.observable(false);
@ -55,15 +56,23 @@
this.testingSmtpErrorDesc = ko.observable(''); this.testingSmtpErrorDesc = ko.observable('');
this.imapServerFocus = ko.observable(false); this.imapServerFocus = ko.observable(false);
this.sieveServerFocus = ko.observable(false);
this.smtpServerFocus = ko.observable(false); this.smtpServerFocus = ko.observable(false);
this.name = ko.observable(''); this.name = ko.observable('');
this.name.focused = ko.observable(false); this.name.focused = ko.observable(false);
this.allowSieve = ko.observable(false);
this.imapServer = ko.observable(''); this.imapServer = ko.observable('');
this.imapPort = ko.observable('' + Consts.Values.ImapDefaulPort); this.imapPort = ko.observable('' + Consts.Values.ImapDefaulPort);
this.imapSecure = ko.observable(Enums.ServerSecure.None); this.imapSecure = ko.observable(Enums.ServerSecure.None);
this.imapShortLogin = ko.observable(false); this.imapShortLogin = ko.observable(false);
this.useSieve = ko.observable(false);
this.useImapServerForSieve = ko.observable(true);
this.sieveServer = ko.observable('');
this.sievePort = ko.observable('' + Consts.Values.SieveDefaulPort);
this.sieveSecure = ko.observable(Enums.ServerSecure.None);
this.smtpServer = ko.observable(''); this.smtpServer = ko.observable('');
this.smtpPort = ko.observable('' + Consts.Values.SmtpDefaulPort); this.smtpPort = ko.observable('' + Consts.Values.SmtpDefaulPort);
this.smtpSecure = ko.observable(Enums.ServerSecure.None); this.smtpSecure = ko.observable(Enums.ServerSecure.None);
@ -81,11 +90,20 @@
}, this); }, this);
this.domainIsComputed = ko.computed(function () { this.domainIsComputed = ko.computed(function () {
var bPhpMail = this.smtpPhpMail();
var
bPhpMail = this.smtpPhpMail(),
bAllowSieve = this.allowSieve(),
bUseSieve = this.useSieve(),
bIseImapServerForSieve = this.useImapServerForSieve()
;
return '' !== this.name() && return '' !== this.name() &&
'' !== this.imapServer() && '' !== this.imapServer() &&
'' !== this.imapPort() && '' !== this.imapPort() &&
(bAllowSieve && bUseSieve ? (bIseImapServerForSieve ? true : ('' !== this.sieveServer() && '' !== this.sievePort())) : true) &&
(('' !== this.smtpServer() && '' !== this.smtpPort()) || bPhpMail); (('' !== this.smtpServer() && '' !== this.smtpPort()) || bPhpMail);
}, this); }, this);
this.canBeTested = ko.computed(function () { this.canBeTested = ko.computed(function () {
@ -102,32 +120,53 @@
_.bind(this.onDomainCreateOrSaveResponse, this), _.bind(this.onDomainCreateOrSaveResponse, this),
!this.edit(), !this.edit(),
this.name(), this.name(),
this.imapServer(), this.imapServer(),
Utils.pInt(this.imapPort()), Utils.pInt(this.imapPort()),
this.imapSecure(), this.imapSecure(),
this.imapShortLogin(), this.imapShortLogin(),
this.useSieve(),
this.useImapServerForSieve(),
this.sieveServer(),
Utils.pInt(this.sievePort()),
this.sieveSecure(),
this.smtpServer(), this.smtpServer(),
Utils.pInt(this.smtpPort()), Utils.pInt(this.smtpPort()),
this.smtpSecure(), this.smtpSecure(),
this.smtpShortLogin(), this.smtpShortLogin(),
this.smtpAuth(), this.smtpAuth(),
this.smtpPhpMail(), this.smtpPhpMail(),
this.whiteList() this.whiteList()
); );
}, this.canBeSaved); }, this.canBeSaved);
this.testConnectionCommand = Utils.createCommand(this, function () { this.testConnectionCommand = Utils.createCommand(this, function () {
this.whiteListPage(false);
this.page('main');
this.sieveSettings(false);
this.testingDone(false); this.testingDone(false);
this.testingImapError(false); this.testingImapError(false);
this.testingSmtpError(false); this.testingSmtpError(false);
this.testing(true); this.testing(true);
Remote.testConnectionForDomain( Remote.testConnectionForDomain(
_.bind(this.onTestConnectionResponse, this), _.bind(this.onTestConnectionResponse, this),
this.name(), this.name(),
this.imapServer(), this.imapServer(),
Utils.pInt(this.imapPort()), Utils.pInt(this.imapPort()),
this.imapSecure(), this.imapSecure(),
this.useSieve(),
this.useImapServerForSieve(),
this.sieveServer(),
Utils.pInt(this.sievePort()),
this.sieveSecure(),
this.smtpServer(), this.smtpServer(),
Utils.pInt(this.smtpPort()), Utils.pInt(this.smtpPort()),
this.smtpSecure(), this.smtpSecure(),
@ -137,9 +176,22 @@
}, this.canBeTested); }, this.canBeTested);
this.whiteListCommand = Utils.createCommand(this, function () { this.whiteListCommand = Utils.createCommand(this, function () {
this.whiteListPage(!this.whiteListPage()); this.page('white-list');
}); });
this.backCommand = Utils.createCommand(this, function () {
this.page('main');
});
this.sieveCommand = Utils.createCommand(this, function () {
this.sieveSettings(!this.sieveSettings());
this.clearTesting();
});
this.page.subscribe(function () {
this.sieveSettings(false);
}, this);
// smart form improvements // smart form improvements
this.imapServerFocus.subscribe(function (bValue) { this.imapServerFocus.subscribe(function (bValue) {
if (bValue && '' !== this.name() && '' === this.imapServer()) if (bValue && '' !== this.name() && '' === this.imapServer())
@ -148,6 +200,13 @@
} }
}, this); }, this);
this.sieveServerFocus.subscribe(function (bValue) {
if (bValue && '' !== this.name() && '' === this.sieveServer())
{
this.sieveServer(this.name().replace(/[.]?[*][.]?/g, ''));
}
}, this);
this.smtpServerFocus.subscribe(function (bValue) { this.smtpServerFocus.subscribe(function (bValue) {
if (bValue && '' !== this.imapServer() && '' === this.smtpServer()) if (bValue && '' !== this.imapServer() && '' === this.smtpServer())
{ {
@ -260,20 +319,29 @@
} }
}; };
DomainPopupView.prototype.onHide = function () DomainPopupView.prototype.clearTesting = function ()
{ {
this.whiteListPage(false);
};
DomainPopupView.prototype.onShow = function (oDomain)
{
this.saving(false);
this.whiteListPage(false);
this.testing(false); this.testing(false);
this.testingDone(false); this.testingDone(false);
this.testingImapError(false); this.testingImapError(false);
this.testingSmtpError(false); this.testingSmtpError(false);
}
DomainPopupView.prototype.onHide = function ()
{
this.page('main');
this.sieveSettings(false);
};
DomainPopupView.prototype.onShow = function (oDomain)
{
this.saving(false);
this.page('main');
this.sieveSettings(false);
this.clearTesting();
this.clearForm(); this.clearForm();
if (oDomain) if (oDomain)
@ -287,6 +355,11 @@
this.imapPort('' + Utils.pInt(oDomain.IncPort)); this.imapPort('' + Utils.pInt(oDomain.IncPort));
this.imapSecure(Utils.trim(oDomain.IncSecure)); this.imapSecure(Utils.trim(oDomain.IncSecure));
this.imapShortLogin(!!oDomain.IncShortLogin); this.imapShortLogin(!!oDomain.IncShortLogin);
this.useSieve(!!oDomain.UseSieve);
this.useImapServerForSieve(!!oDomain.UseImapServerForSieve);
this.sieveServer(Utils.trim(oDomain.SieveHost));
this.sievePort('' + Utils.pInt(oDomain.SievePort));
this.sieveSecure(Utils.trim(oDomain.SieveSecure));
this.smtpServer(Utils.trim(oDomain.OutHost)); this.smtpServer(Utils.trim(oDomain.OutHost));
this.smtpPort('' + Utils.pInt(oDomain.OutPort)); this.smtpPort('' + Utils.pInt(oDomain.OutPort));
this.smtpSecure(Utils.trim(oDomain.OutSecure)); this.smtpSecure(Utils.trim(oDomain.OutSecure));
@ -310,7 +383,10 @@
DomainPopupView.prototype.clearForm = function () DomainPopupView.prototype.clearForm = function ()
{ {
this.edit(false); this.edit(false);
this.whiteListPage(false);
this.page('main');
this.sieveSettings(false);
this.enableSmartPorts(false); this.enableSmartPorts(false);
this.savingError(''); this.savingError('');
@ -322,14 +398,21 @@
this.imapPort('' + Consts.Values.ImapDefaulPort); this.imapPort('' + Consts.Values.ImapDefaulPort);
this.imapSecure(Enums.ServerSecure.None); this.imapSecure(Enums.ServerSecure.None);
this.imapShortLogin(false); this.imapShortLogin(false);
this.useSieve(false);
this.useImapServerForSieve(true);
this.sieveServer('');
this.sievePort('' + Consts.Values.SieveDefaulPort);
this.sieveSecure(Enums.ServerSecure.None);
this.smtpServer(''); this.smtpServer('');
this.smtpPort('' + Consts.Values.SmtpDefaulPort); this.smtpPort('' + Consts.Values.SmtpDefaulPort);
this.smtpSecure(Enums.ServerSecure.None); this.smtpSecure(Enums.ServerSecure.None);
this.smtpShortLogin(false); this.smtpShortLogin(false);
this.smtpAuth(true); this.smtpAuth(true);
this.smtpPhpMail(false); this.smtpPhpMail(false);
this.whiteList('');
this.whiteList('');
this.enableSmartPorts(true); this.enableSmartPorts(true);
}; };

View file

@ -2984,13 +2984,15 @@ class Actions
$iImapTime = 0; $iImapTime = 0;
$iSmtpTime = 0; $iSmtpTime = 0;
$iConnectionTimeout = 5;
$oDomain = $this->DomainProvider()->LoadOrCreateNewFromAction($this, 'domain-test-connection.de'); $oDomain = $this->DomainProvider()->LoadOrCreateNewFromAction($this, 'domain-test-connection.de');
if ($oDomain) if ($oDomain)
{ {
try try
{ {
$oImapClient = \MailSo\Imap\ImapClient::NewInstance()->SetLogger($this->Logger()); $oImapClient = \MailSo\Imap\ImapClient::NewInstance()->SetLogger($this->Logger());
$oImapClient->SetTimeOuts(5); $oImapClient->SetTimeOuts($iConnectionTimeout);
$iTime = \microtime(true); $iTime = \microtime(true);
$oImapClient->Connect($oDomain->IncHost(), $oDomain->IncPort(), $oImapClient->Connect($oDomain->IncHost(), $oDomain->IncPort(),
@ -3028,7 +3030,7 @@ class Actions
try try
{ {
$oSmtpClient = \MailSo\Smtp\SmtpClient::NewInstance()->SetLogger($this->Logger()); $oSmtpClient = \MailSo\Smtp\SmtpClient::NewInstance()->SetLogger($this->Logger());
$oSmtpClient->SetTimeOuts(5); $oSmtpClient->SetTimeOuts($iConnectionTimeout);
$iTime = \microtime(true); $iTime = \microtime(true);
$oSmtpClient->Connect($oDomain->OutHost(), $oDomain->OutPort(), '127.0.0.1', $oSmtpClient->Connect($oDomain->OutHost(), $oDomain->OutPort(), '127.0.0.1',
@ -6994,6 +6996,7 @@ class Actions
@\header('Content-Type: '.$sContentType); @\header('Content-Type: '.$sContentType);
echo \preg_replace('/^data:[^:]+:/', '', $sData); echo \preg_replace('/^data:[^:]+:/', '', $sData);
unset($sData); unset($sData);
return true; return true;
} }
} }

View file

@ -152,11 +152,12 @@ class KeyPathHelper
/** /**
* @param string $sTheme * @param string $sTheme
* @param string $sPluginsHash * @param string $sPluginsHash
* @param string $sPublickHash
* *
* @return string * @return string
*/ */
static public function CssCache($sTheme, $sPluginsHash) static public function CssCache($sTheme, $sPluginsHash, $sPublickHash = '')
{ {
return '/CssCache/'.$sPluginsHash.'/'.$sTheme.'/'.APP_VERSION.'/'; return '/CssCache/'.$sPluginsHash.'/'.$sPublickHash.'/'.$sTheme.'/'.APP_VERSION.'/';
} }
} }

View file

@ -63,6 +63,31 @@ class Domain
*/ */
private $bOutUsePhpMail; private $bOutUsePhpMail;
/**
* @var bool
*/
private $bUseSieve;
/**
* @var bool
*/
private $bUseImapServerForSieve;
/**
* @var string
*/
private $sSieveHost;
/**
* @var int
*/
private $iSievePort;
/**
* @var int
*/
private $iSieveSecure;
/** /**
* @var string * @var string
*/ */
@ -74,6 +99,11 @@ class Domain
* @param int $iIncPort * @param int $iIncPort
* @param int $iIncSecure * @param int $iIncSecure
* @param bool $bIncShortLogin * @param bool $bIncShortLogin
* @param bool $bUseSieve
* @param bool $bUseImapServerForSieve
* @param string $sSieveHost
* @param int $iSievePort
* @param int $iSieveSecure
* @param string $sOutHost * @param string $sOutHost
* @param int $iOutPort * @param int $iOutPort
* @param int $iOutSecure * @param int $iOutSecure
@ -82,20 +112,31 @@ class Domain
* @param bool $bOutUsePhpMail = false * @param bool $bOutUsePhpMail = false
* @param string $sWhiteList = '' * @param string $sWhiteList = ''
*/ */
private function __construct($sName, $sIncHost, $iIncPort, $iIncSecure, $bIncShortLogin, private function __construct($sName,
$sOutHost, $iOutPort, $iOutSecure, $bOutShortLogin, $bOutAuth, $bOutUsePhpMail = false, $sWhiteList = '') $sIncHost, $iIncPort, $iIncSecure, $bIncShortLogin,
$bUseSieve, $bUseImapServerForSieve, $sSieveHost, $iSievePort, $iSieveSecure,
$sOutHost, $iOutPort, $iOutSecure, $bOutShortLogin, $bOutAuth, $bOutUsePhpMail = false,
$sWhiteList = '')
{ {
$this->sName = $sName; $this->sName = $sName;
$this->sIncHost = $sIncHost; $this->sIncHost = $sIncHost;
$this->iIncPort = $iIncPort; $this->iIncPort = $iIncPort;
$this->iIncSecure = $iIncSecure; $this->iIncSecure = $iIncSecure;
$this->bIncShortLogin = $bIncShortLogin; $this->bIncShortLogin = $bIncShortLogin;
$this->sOutHost = $sOutHost; $this->sOutHost = $sOutHost;
$this->iOutPort = $iOutPort; $this->iOutPort = $iOutPort;
$this->iOutSecure = $iOutSecure; $this->iOutSecure = $iOutSecure;
$this->bOutShortLogin = $bOutShortLogin; $this->bOutShortLogin = $bOutShortLogin;
$this->bOutAuth = $bOutAuth; $this->bOutAuth = $bOutAuth;
$this->bOutUsePhpMail = $bOutUsePhpMail; $this->bOutUsePhpMail = $bOutUsePhpMail;
$this->bUseSieve = $bUseSieve;
$this->bUseImapServerForSieve = $bUseImapServerForSieve;
$this->sSieveHost = $sSieveHost;
$this->iSievePort = $iSievePort;
$this->iSieveSecure = $iSieveSecure;
$this->sWhiteList = \trim($sWhiteList); $this->sWhiteList = \trim($sWhiteList);
} }
@ -105,6 +146,11 @@ class Domain
* @param int $iIncPort * @param int $iIncPort
* @param int $iIncSecure * @param int $iIncSecure
* @param bool $bIncShortLogin * @param bool $bIncShortLogin
* @param bool $bUseSieve
* @param bool $bUseImapServerForSieve
* @param string $sSieveHost
* @param int $iSievePort
* @param int $iSieveSecure
* @param string $sOutHost * @param string $sOutHost
* @param int $iOutPort * @param int $iOutPort
* @param int $iOutSecure * @param int $iOutSecure
@ -117,11 +163,13 @@ class Domain
*/ */
public static function NewInstance($sName, public static function NewInstance($sName,
$sIncHost, $iIncPort, $iIncSecure, $bIncShortLogin, $sIncHost, $iIncPort, $iIncSecure, $bIncShortLogin,
$bUseSieve, $bUseImapServerForSieve, $sSieveHost, $iSievePort, $iSieveSecure,
$sOutHost, $iOutPort, $iOutSecure, $bOutShortLogin, $bOutAuth, $bOutUsePhpMail, $sOutHost, $iOutPort, $iOutSecure, $bOutShortLogin, $bOutAuth, $bOutUsePhpMail,
$sWhiteList = '') $sWhiteList = '')
{ {
return new self($sName, return new self($sName,
$sIncHost, $iIncPort, $iIncSecure, $bIncShortLogin, $sIncHost, $iIncPort, $iIncSecure, $bIncShortLogin,
$bUseSieve, $bUseImapServerForSieve, $sSieveHost, $iSievePort, $iSieveSecure,
$sOutHost, $iOutPort, $iOutSecure, $bOutShortLogin, $bOutAuth, $bOutUsePhpMail, $sOutHost, $iOutPort, $iOutSecure, $bOutShortLogin, $bOutAuth, $bOutUsePhpMail,
$sWhiteList); $sWhiteList);
} }
@ -143,6 +191,11 @@ class Domain
$iIncSecure = self::StrConnectionSecurityTypeToCons( $iIncSecure = self::StrConnectionSecurityTypeToCons(
!empty($aDomain['imap_secure']) ? $aDomain['imap_secure'] : ''); !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']; $sOutHost = empty($aDomain['smtp_host']) ? '' : (string) $aDomain['smtp_host'];
$iOutPort = empty($aDomain['smtp_port']) ? 25 : (int) $aDomain['smtp_port']; $iOutPort = empty($aDomain['smtp_port']) ? 25 : (int) $aDomain['smtp_port'];
$iOutSecure = self::StrConnectionSecurityTypeToCons( $iOutSecure = self::StrConnectionSecurityTypeToCons(
@ -152,11 +205,15 @@ class Domain
$bOutUsePhpMail = isset($aDomain['smtp_php_mail']) ? (bool) $aDomain['smtp_php_mail'] : false; $bOutUsePhpMail = isset($aDomain['smtp_php_mail']) ? (bool) $aDomain['smtp_php_mail'] : false;
$sWhiteList = (string) (isset($aDomain['white_list']) ? $aDomain['white_list'] : ''); $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; $bIncShortLogin = isset($aDomain['imap_short_login']) ? (bool) $aDomain['imap_short_login'] : false;
$bOutShortLogin = isset($aDomain['smtp_short_login']) ? (bool) $aDomain['smtp_short_login'] : false; $bOutShortLogin = isset($aDomain['smtp_short_login']) ? (bool) $aDomain['smtp_short_login'] : false;
$oDomain = self::NewInstance($sName, $oDomain = self::NewInstance($sName,
$sIncHost, $iIncPort, $iIncSecure, $bIncShortLogin, $sIncHost, $iIncPort, $iIncSecure, $bIncShortLogin,
$bUseSieve, $bUseImapServerForSieve, $sSieveHost, $iSievePort, $iSieveSecure,
$sOutHost, $iOutPort, $iOutSecure, $bOutShortLogin, $bOutAuth, $bOutUsePhpMail, $sOutHost, $iOutPort, $iOutSecure, $bOutShortLogin, $bOutAuth, $bOutUsePhpMail,
$sWhiteList); $sWhiteList);
} }
@ -177,6 +234,7 @@ class Domain
public function Normalize() public function Normalize()
{ {
$this->sIncHost = \trim($this->sIncHost); $this->sIncHost = \trim($this->sIncHost);
$this->sSieveHost = \trim($this->sSieveHost);
$this->sOutHost = \trim($this->sOutHost); $this->sOutHost = \trim($this->sOutHost);
$this->sWhiteList = \trim($this->sWhiteList); $this->sWhiteList = \trim($this->sWhiteList);
@ -185,6 +243,11 @@ class Domain
$this->iIncPort = 143; $this->iIncPort = 143;
} }
if ($this->iSievePort <= 0)
{
$this->iSievePort = 2000;
}
if ($this->iOutPort <= 0) if ($this->iOutPort <= 0)
{ {
$this->iOutPort = 25; $this->iOutPort = 25;
@ -197,11 +260,16 @@ class Domain
public function ToIniString() public function ToIniString()
{ {
$this->Normalize(); $this->Normalize();
return implode("\n", array( return \implode("\n", array(
'imap_host = "'.$this->encodeIniString($this->sIncHost).'"', 'imap_host = "'.$this->encodeIniString($this->sIncHost).'"',
'imap_port = '.$this->iIncPort, 'imap_port = '.$this->iIncPort,
'imap_secure = "'.self::ConstConnectionSecurityTypeToStr($this->iIncSecure).'"', 'imap_secure = "'.self::ConstConnectionSecurityTypeToStr($this->iIncSecure).'"',
'imap_short_login = '.($this->bIncShortLogin ? 'On' : 'Off'), '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_host = "'.$this->encodeIniString($this->sOutHost).'"',
'smtp_port = '.$this->iOutPort, 'smtp_port = '.$this->iOutPort,
'smtp_secure = "'.self::ConstConnectionSecurityTypeToStr($this->iOutSecure).'"', 'smtp_secure = "'.self::ConstConnectionSecurityTypeToStr($this->iOutSecure).'"',
@ -258,6 +326,8 @@ class Domain
* @param int $iIncPort * @param int $iIncPort
* @param int $iIncSecure * @param int $iIncSecure
* @param bool $bIncShortLogin * @param bool $bIncShortLogin
* @param bool $bUseSieve
* @param bool $bUseImapServerForSieve
* @param string $sOutHost * @param string $sOutHost
* @param int $iOutPort * @param int $iOutPort
* @param int $iOutSecure * @param int $iOutSecure
@ -270,6 +340,7 @@ class Domain
*/ */
public function UpdateInstance( public function UpdateInstance(
$sIncHost, $iIncPort, $iIncSecure, $bIncShortLogin, $sIncHost, $iIncPort, $iIncSecure, $bIncShortLogin,
$bUseSieve, $bUseImapServerForSieve, $sSieveHost, $iSievePort, $iSieveSecure,
$sOutHost, $iOutPort, $iOutSecure, $bOutShortLogin, $bOutAuth, $bOutUsePhpMail, $sOutHost, $iOutPort, $iOutSecure, $bOutShortLogin, $bOutAuth, $bOutUsePhpMail,
$sWhiteList = '') $sWhiteList = '')
{ {
@ -277,12 +348,20 @@ class Domain
$this->iIncPort = $iIncPort; $this->iIncPort = $iIncPort;
$this->iIncSecure = $iIncSecure; $this->iIncSecure = $iIncSecure;
$this->bIncShortLogin = $bIncShortLogin; $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->sOutHost = \MailSo\Base\Utils::IdnToAscii($sOutHost);
$this->iOutPort = $iOutPort; $this->iOutPort = $iOutPort;
$this->iOutSecure = $iOutSecure; $this->iOutSecure = $iOutSecure;
$this->bOutShortLogin = $bOutShortLogin; $this->bOutShortLogin = $bOutShortLogin;
$this->bOutAuth = $bOutAuth; $this->bOutAuth = $bOutAuth;
$this->bOutUsePhpMail = $bOutUsePhpMail; $this->bOutUsePhpMail = $bOutUsePhpMail;
$this->sWhiteList = \trim($sWhiteList); $this->sWhiteList = \trim($sWhiteList);
return $this; return $this;
@ -328,6 +407,46 @@ class Domain
return $this->bIncShortLogin; 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 * @return string
*/ */
@ -421,6 +540,11 @@ class Domain
'IncPort' => $this->IncPort(), 'IncPort' => $this->IncPort(),
'IncSecure' => $this->IncSecure(), 'IncSecure' => $this->IncSecure(),
'IncShortLogin' => $this->IncShortLogin(), '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(), 'OutHost' => $bAjax ? \MailSo\Base\Utils::IdnToUtf8($this->OutHost()) : $this->OutHost(),
'OutPort' => $this->OutPort(), 'OutPort' => $this->OutPort(),
'OutSecure' => $this->OutSecure(), 'OutSecure' => $this->OutSecure(),

View file

@ -129,6 +129,11 @@ class Domain extends \RainLoop\Providers\AbstractProvider
$iIncPort = (int) $oActions->GetActionParam('IncPort', 143); $iIncPort = (int) $oActions->GetActionParam('IncPort', 143);
$iIncSecure = (int) $oActions->GetActionParam('IncSecure', \MailSo\Net\Enumerations\ConnectionSecurityType::NONE); $iIncSecure = (int) $oActions->GetActionParam('IncSecure', \MailSo\Net\Enumerations\ConnectionSecurityType::NONE);
$bIncShortLogin = '1' === (string) $oActions->GetActionParam('IncShortLogin', '0'); $bIncShortLogin = '1' === (string) $oActions->GetActionParam('IncShortLogin', '0');
$bUseSieve = '1' === (string) $oActions->GetActionParam('UseSieve', '0');
$bUseImapServerForSieve = '1' === (string) $oActions->GetActionParam('UseImapServerForSieve', '1');
$sSieveHost = (string) $oActions->GetActionParam('SieveHost', '');
$iSievePort = (int) $oActions->GetActionParam('SievePort', 2000);
$iSieveSecure = (int) $oActions->GetActionParam('SieveSecure', \MailSo\Net\Enumerations\ConnectionSecurityType::NONE);
$sOutHost = (string) $oActions->GetActionParam('OutHost', ''); $sOutHost = (string) $oActions->GetActionParam('OutHost', '');
$iOutPort = (int) $oActions->GetActionParam('OutPort', 25); $iOutPort = (int) $oActions->GetActionParam('OutPort', 25);
$iOutSecure = (int) $oActions->GetActionParam('OutSecure', \MailSo\Net\Enumerations\ConnectionSecurityType::NONE); $iOutSecure = (int) $oActions->GetActionParam('OutSecure', \MailSo\Net\Enumerations\ConnectionSecurityType::NONE);
@ -155,6 +160,7 @@ class Domain extends \RainLoop\Providers\AbstractProvider
{ {
$oDomain->UpdateInstance( $oDomain->UpdateInstance(
$sIncHost, $iIncPort, $iIncSecure, $bIncShortLogin, $sIncHost, $iIncPort, $iIncSecure, $bIncShortLogin,
$bUseSieve, $bUseImapServerForSieve, $sSieveHost, $iSievePort, $iSieveSecure,
$sOutHost, $iOutPort, $iOutSecure, $bOutShortLogin, $bOutAuth, $bOutUsePhpMail, $sOutHost, $iOutPort, $iOutSecure, $bOutShortLogin, $bOutAuth, $bOutUsePhpMail,
$sWhiteList); $sWhiteList);
} }
@ -163,6 +169,7 @@ class Domain extends \RainLoop\Providers\AbstractProvider
{ {
$oDomain = \RainLoop\Model\Domain::NewInstance(0 < strlen($sNameForTest) ? $sNameForTest : $sName, $oDomain = \RainLoop\Model\Domain::NewInstance(0 < strlen($sNameForTest) ? $sNameForTest : $sName,
$sIncHost, $iIncPort, $iIncSecure, $bIncShortLogin, $sIncHost, $iIncPort, $iIncSecure, $bIncShortLogin,
$bUseSieve, $bUseImapServerForSieve, $sSieveHost, $iSievePort, $iSieveSecure,
$sOutHost, $iOutPort, $iOutSecure, $bOutShortLogin, $bOutAuth, $bOutUsePhpMail, $sOutHost, $iOutPort, $iOutSecure, $bOutShortLogin, $bOutAuth, $bOutUsePhpMail,
$sWhiteList); $sWhiteList);
} }

View file

@ -1,5 +1,6 @@
<div class="popups"> <div class="popups">
<div class="modal hide b-domain-content g-ui-user-select-none" data-bind="modal: modalVisibility, css: {'domain-edit': edit, 'domain-white-list-page': whiteListPage}"> <div class="modal hide b-domain-content g-ui-user-select-none"
data-bind="modal: modalVisibility, css: {'domain-edit': edit, 'domain-second-page': 'main' !== page()}">
<div class="modal-header"> <div class="modal-header">
<button type="button" class="close" data-bind="command: cancelCommand">&times;</button> <button type="button" class="close" data-bind="command: cancelCommand">&times;</button>
<h3 data-bind="text: headerText"></h3> <h3 data-bind="text: headerText"></h3>
@ -20,48 +21,124 @@
<div class="span5" data-bind="css: { 'testing-done': testingDone, 'testing-error': testingImapError }"> <div class="span5" data-bind="css: { 'testing-done': testingDone, 'testing-error': testingImapError }">
<div class="legend imap-header"> <div class="legend imap-header">
<span data-placement="bottom" data-bind="tooltip3: testingImapErrorDesc"> <span data-placement="bottom" data-bind="tooltip3: testingImapErrorDesc">
IMAP <span data-bind="text: sieveSettings() ? 'SIEVE' : 'IMAP'">IMAP</span>
</span> </span>
</div> </div>
<div class="row"> <div data-bind="visible: !sieveSettings()">
<div class="span3"> <div class="row">
Server <div class="span3">
<br /> Server
<input type="text" class="span3" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" <br />
data-bind="textInput: imapServer, hasfocus: imapServerFocus" /> <input type="text" class="span3" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"
data-bind="textInput: imapServer, hasfocus: imapServerFocus" />
</div>
<div class="span1">
Port
<br />
<input type="text" class="span1" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"
data-bind="textInput: imapPort" />
</div>
</div> </div>
<div class="span1"> <br />
Port <div class="row">
<br /> <div class="span4">
<input type="text" class="span1" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" Secure
data-bind="textInput: imapPort" /> <br />
<select class="span2" data-bind="value: imapSecure">
<option value="0">None</option>
<option value="1">SSL/TLS</option>
<option value="2">STARTTLS</option>
</select>
</div>
</div>
<br />
<div class="row">
<div class="span5">
<div data-bind="component: {
name: 'Checkbox',
params: {
label: 'Use short login',
value: imapShortLogin,
inline: true
}
}"></div>
&nbsp;&nbsp;
<span style="color: #aaa">(user@domain.com &rarr; user)</span>
</div>
</div>
<br />
<br />
<div class="row" data-bind="visible: allowSieve">
<div class="span5">
<span data-bind="command: sieveCommand">
<i class="icon-filter"></i>
&nbsp;
<a href="#" class="g-ui-link">Sieve configuration</a>
</span>
</div>
</div> </div>
</div> </div>
<br /> <div data-bind="visible: sieveSettings">
<div class="row"> <div class="row">
<div class="span4"> <div class="span5">
Secure <div data-bind="component: {
<br /> name: 'Checkbox',
<select class="span2" data-bind="value: imapSecure"> params: {
<option value="0">None</option> label: 'use Sieve for this domain',
<option value="1">SSL/TLS</option> value: useSieve
<option value="2">STARTTLS</option> }
</select> }"></div>
</div>
</div> </div>
</div> <div class="row" data-bind="visible: useSieve">
<br /> <div class="span5">
<div class="row"> <div data-bind="component: {
<div class="span5"> name: 'Checkbox',
<div data-bind="component: { params: {
name: 'Checkbox', label: 'use IMAP Server',
params: { value: useImapServerForSieve
label: 'Use short login', }
value: imapShortLogin, }"></div>
inline: true </div>
} </div>
}"></div> <div data-bind="visible: !useImapServerForSieve() && useSieve()">
&nbsp;&nbsp; <br />
<span style="color: #aaa">(user@domain.com &rarr; user)</span> <div class="row">
<div class="span3">
Server
<br />
<input type="text" class="span3" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"
data-bind="textInput: sieveServer, hasfocus: sieveServerFocus" />
</div>
<div class="span1">
Port
<br />
<input type="text" class="span1" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"
data-bind="textInput: sievePort" />
</div>
</div>
<br />
<div class="row">
<div class="span4">
Secure
<br />
<select class="span2" data-bind="value: sieveSecure">
<option value="0">None</option>
<option value="1">SSL/TLS</option>
<option value="2">STARTTLS</option>
</select>
</div>
</div>
</div>
<br />
<div class="row">
<div class="span5">
<span data-bind="command: sieveCommand">
<i class="icon-left"></i>
&nbsp;
<a href="#" class="g-ui-link">Back to IMAP settings</a>
</span>
</div>
</div> </div>
</div> </div>
</div> </div>
@ -138,7 +215,7 @@
</div> </div>
</div> </div>
</div> </div>
<div class="span10"> <div class="span10" data-bind="visible: 'white-list' === page()">
<div class="legend white-list-header"> <div class="legend white-list-header">
White List White List
</div> </div>
@ -152,18 +229,22 @@
</form> </form>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<a class="btn button-test-connection pull-left" data-bind="command: testConnectionCommand, css: { <a class="btn button-test-connection pull-left" data-bind="visible: 'main' === page(), command: testConnectionCommand, css: {
'btn-success': testingDone() && !testingImapError() && !testingSmtpError(), 'btn-success': testingDone() && !testingImapError() && !testingSmtpError(),
'btn-danger': testingDone() && (testingImapError() || testingSmtpError()) }"> 'btn-danger': testingDone() && (testingImapError() || testingSmtpError()) }">
<i data-bind="css: {'icon-info': !testing(), 'icon-spinner animated': testing(), 'icon-white': testingDone()}"></i> <i data-bind="css: {'icon-info': !testing(), 'icon-spinner animated': testing(), 'icon-white': testingDone()}"></i>
&nbsp;&nbsp; &nbsp;&nbsp;
Test Test
</a> </a>
<a class="btn button-white-list pull-left" data-bind="command: whiteListCommand"> <a class="btn button-white-list pull-left" data-bind="command: whiteListCommand, visible: 'main' === page()">
<i data-bind="css: {'icon-users': !whiteListPage(), 'icon-left': whiteListPage()}"></i> <i class="icon-users"></i>
&nbsp;&nbsp; &nbsp;&nbsp;
<span data-bind="visible: !whiteListPage()">White List</span> White List
<span data-bind="visible: whiteListPage()">Back</span> </a>
<a class="btn button-white-list pull-left" data-bind="command: backCommand, visible: 'main' !== page()">
<i class="icon-left"></i>
&nbsp;&nbsp;
Back
</a> </a>
<a class="btn buttonClose" data-bind="command: cancelCommand"> <a class="btn buttonClose" data-bind="command: cancelCommand">
<i class="icon-remove"></i> <i class="icon-remove"></i>