Code refactoring

This commit is contained in:
RainLoop Team 2014-11-12 20:46:05 +04:00
parent 78ce33e77c
commit 2545ce3cd9
17 changed files with 946 additions and 1034 deletions

View file

@ -92,7 +92,7 @@
sString = Utils.trim(sString); sString = Utils.trim(sString);
var var
mRegex = /(?:"([^"]+)")? ?<?(.*?@[^>,]+)>?,? ?/g, mRegex = /(?:"([^"]+)")? ?[<]?(.*?@[^>,]+)>?,? ?/g,
mMatch = mRegex.exec(sString) mMatch = mRegex.exec(sString)
; ;

View file

@ -210,8 +210,8 @@
}; };
RemoteAdminStorage.prototype.createOrUpdateDomain = function (fCallback, RemoteAdminStorage.prototype.createOrUpdateDomain = function (fCallback,
bCreate, sName, sIncHost, iIncPort, sIncSecure, bIncVerifySsl, bIncShortLogin, bCreate, sName, sIncHost, iIncPort, sIncSecure, bIncShortLogin,
sOutHost, iOutPort, sOutSecure, bOutShortLogin, bOutVerifySsl, bOutAuth, sWhiteList) sOutHost, iOutPort, sOutSecure, bOutShortLogin, bOutAuth, sWhiteList)
{ {
this.defaultRequest(fCallback, 'AdminDomainSave', { this.defaultRequest(fCallback, 'AdminDomainSave', {
'Create': bCreate ? '1' : '0', 'Create': bCreate ? '1' : '0',
@ -219,12 +219,10 @@
'IncHost': sIncHost, 'IncHost': sIncHost,
'IncPort': iIncPort, 'IncPort': iIncPort,
'IncSecure': sIncSecure, 'IncSecure': sIncSecure,
'IncVerifySsl': bIncVerifySsl ? '1' : '0',
'IncShortLogin': bIncShortLogin ? '1' : '0', 'IncShortLogin': bIncShortLogin ? '1' : '0',
'OutHost': sOutHost, 'OutHost': sOutHost,
'OutPort': iOutPort, 'OutPort': iOutPort,
'OutSecure': sOutSecure, 'OutSecure': sOutSecure,
'OutVerifySsl': bOutVerifySsl ? '1' : '0',
'OutShortLogin': bOutShortLogin ? '1' : '0', 'OutShortLogin': bOutShortLogin ? '1' : '0',
'OutAuth': bOutAuth ? '1' : '0', 'OutAuth': bOutAuth ? '1' : '0',
'WhiteList': sWhiteList 'WhiteList': sWhiteList
@ -232,19 +230,16 @@
}; };
RemoteAdminStorage.prototype.testConnectionForDomain = function (fCallback, sName, RemoteAdminStorage.prototype.testConnectionForDomain = function (fCallback, sName,
sIncHost, iIncPort, sIncSecure, bIncVerifySsl, sIncHost, iIncPort, sIncSecure, sOutHost, iOutPort, sOutSecure, bOutAuth)
sOutHost, iOutPort, sOutSecure, bOutVerifySsl, bOutAuth)
{ {
this.defaultRequest(fCallback, 'AdminDomainTest', { this.defaultRequest(fCallback, 'AdminDomainTest', {
'Name': sName, 'Name': sName,
'IncHost': sIncHost, 'IncHost': sIncHost,
'IncPort': iIncPort, 'IncPort': iIncPort,
'IncSecure': sIncSecure, 'IncSecure': sIncSecure,
'IncVerifySsl': bIncVerifySsl ? '1' : '0',
'OutHost': sOutHost, 'OutHost': sOutHost,
'OutPort': iOutPort, 'OutPort': iOutPort,
'OutSecure': sOutSecure, 'OutSecure': sOutSecure,
'OutVerifySsl': bOutVerifySsl ? '1' : '0',
'OutAuth': bOutAuth ? '1' : '0' 'OutAuth': bOutAuth ? '1' : '0'
}); });
}; };

View file

@ -63,12 +63,10 @@
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.imapVerifySsl = ko.observable(false);
this.imapShortLogin = ko.observable(false); this.imapShortLogin = ko.observable(false);
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);
this.smtpVerifySsl = ko.observable(false);
this.smtpShortLogin = ko.observable(false); this.smtpShortLogin = ko.observable(false);
this.smtpAuth = ko.observable(true); this.smtpAuth = ko.observable(true);
this.whiteList = ko.observable(''); this.whiteList = ko.observable('');
@ -106,12 +104,10 @@
this.imapServer(), this.imapServer(),
Utils.pInt(this.imapPort()), Utils.pInt(this.imapPort()),
this.imapSecure(), this.imapSecure(),
this.imapVerifySsl(),
this.imapShortLogin(), this.imapShortLogin(),
this.smtpServer(), this.smtpServer(),
Utils.pInt(this.smtpPort()), Utils.pInt(this.smtpPort()),
this.smtpSecure(), this.smtpSecure(),
this.smtpVerifySsl(),
this.smtpShortLogin(), this.smtpShortLogin(),
this.smtpAuth(), this.smtpAuth(),
this.whiteList() this.whiteList()
@ -130,11 +126,9 @@
this.imapServer(), this.imapServer(),
Utils.pInt(this.imapPort()), Utils.pInt(this.imapPort()),
this.imapSecure(), this.imapSecure(),
this.imapVerifySsl(),
this.smtpServer(), this.smtpServer(),
Utils.pInt(this.smtpPort()), Utils.pInt(this.smtpPort()),
this.smtpSecure(), this.smtpSecure(),
this.smtpVerifySsl(),
this.smtpAuth() this.smtpAuth()
); );
}, this.canBeTested); }, this.canBeTested);
@ -289,12 +283,10 @@
this.imapServer(Utils.trim(oDomain.IncHost)); this.imapServer(Utils.trim(oDomain.IncHost));
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.imapVerifySsl(!!oDomain.IncVerifySsl);
this.imapShortLogin(!!oDomain.IncShortLogin); this.imapShortLogin(!!oDomain.IncShortLogin);
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));
this.smtpVerifySsl(!!oDomain.OutVerifySsl);
this.smtpShortLogin(!!oDomain.OutShortLogin); this.smtpShortLogin(!!oDomain.OutShortLogin);
this.smtpAuth(!!oDomain.OutAuth); this.smtpAuth(!!oDomain.OutAuth);
this.whiteList(Utils.trim(oDomain.WhiteList)); this.whiteList(Utils.trim(oDomain.WhiteList));
@ -325,12 +317,10 @@
this.imapServer(''); this.imapServer('');
this.imapPort('' + Consts.Values.ImapDefaulPort); this.imapPort('' + Consts.Values.ImapDefaulPort);
this.imapSecure(Enums.ServerSecure.None); this.imapSecure(Enums.ServerSecure.None);
this.imapVerifySsl(false);
this.imapShortLogin(false); this.imapShortLogin(false);
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.smtpVerifySsl(false);
this.smtpShortLogin(false); this.smtpShortLogin(false);
this.smtpAuth(true); this.smtpAuth(true);
this.whiteList(''); this.whiteList('');

View file

@ -189,7 +189,8 @@
this.facebookCommand = Utils.createCommand(this, function () { this.facebookCommand = Utils.createCommand(this, function () {
window.open(Links.socialFacebook(), 'Facebook', window.open(Links.socialFacebook(), 'Facebook',
'left=200,top=100,width=650,height=335,menubar=no,status=no,resizable=yes,scrollbars=yes'); 'left=200,top=100,width=650,height=450,menubar=no,status=no,resizable=yes,scrollbars=yes');
return true; return true;
}, function () { }, function () {
@ -201,7 +202,8 @@
this.googleCommand = Utils.createCommand(this, function () { this.googleCommand = Utils.createCommand(this, function () {
window.open(Links.socialGoogle(), 'Google', window.open(Links.socialGoogle(), 'Google',
'left=200,top=100,width=650,height=335,menubar=no,status=no,resizable=yes,scrollbars=yes'); 'left=200,top=100,width=650,height=450,menubar=no,status=no,resizable=yes,scrollbars=yes');
return true; return true;
}, function () { }, function () {
@ -213,7 +215,7 @@
this.twitterCommand = Utils.createCommand(this, function () { this.twitterCommand = Utils.createCommand(this, function () {
window.open(Links.socialTwitter(), 'Twitter', window.open(Links.socialTwitter(), 'Twitter',
'left=200,top=100,width=650,height=335,menubar=no,status=no,resizable=yes,scrollbars=yes'); 'left=200,top=100,width=650,height=450,menubar=no,status=no,resizable=yes,scrollbars=yes');
return true; return true;

View file

@ -33,6 +33,7 @@ var
rename = require('gulp-rename'), rename = require('gulp-rename'),
replace = require('gulp-replace'), replace = require('gulp-replace'),
uglify = require('gulp-uglify'), uglify = require('gulp-uglify'),
plumber = require('gulp-plumber'),
gutil = require('gulp-util') gutil = require('gulp-util')
; ;
@ -191,11 +192,12 @@ gulp.task('css:main', ['less:main'], function() {
var var
// csslint = require('gulp-csslint'), // csslint = require('gulp-csslint'),
csscomb = require('gulp-csscomb'), // csscomb = require('gulp-csscomb'),
autoprefixer = require('gulp-autoprefixer') autoprefixer = require('gulp-autoprefixer')
; ;
return gulp.src(cfg.paths.css.main.src) return gulp.src(cfg.paths.css.main.src)
.pipe(plumber())
.pipe(concat(cfg.paths.css.main.name)) .pipe(concat(cfg.paths.css.main.name))
.pipe(autoprefixer('last 3 versions', '> 1%', 'ie 9', 'Firefox ESR', 'Opera 12.1')) .pipe(autoprefixer('last 3 versions', '> 1%', 'ie 9', 'Firefox ESR', 'Opera 12.1'))
// .pipe(csscomb()) // .pipe(csscomb())
@ -209,6 +211,7 @@ gulp.task('css:main', ['less:main'], function() {
gulp.task('css:main:min', ['css:main'], function() { gulp.task('css:main:min', ['css:main'], function() {
var minifyCss = require('gulp-minify-css'); var minifyCss = require('gulp-minify-css');
return gulp.src(cfg.paths.staticCSS + cfg.paths.css.main.name) return gulp.src(cfg.paths.staticCSS + cfg.paths.css.main.name)
.pipe(plumber())
.pipe(minifyCss({ .pipe(minifyCss({
'keepSpecialComments': 0 'keepSpecialComments': 0
})) }))

View file

@ -64,6 +64,7 @@
"gulp-closure-compiler": "*", "gulp-closure-compiler": "*",
"gulp-csslint": "*", "gulp-csslint": "*",
"gulp-beautify": "*", "gulp-beautify": "*",
"gulp-plumber": "*",
"gulp-concat-util": "*" "gulp-concat-util": "*"
} }
} }

View file

@ -2,457 +2,5 @@
namespace RainLoop; namespace RainLoop;
class Account // for backward compatibility
{ class Account extends \RainLoop\Model\Account {}
/**
* @var string
*/
private $sEmail;
/**
* @var string
*/
private $sLogin;
/**
* @var int
*/
private $sPassword;
/**
* @var string
*/
private $sProxyAuthUser;
/**
* @var string
*/
private $sProxyAuthPassword;
/**
* @var string
*/
private $sSignMeToken;
/**
* @var \RainLoop\Domain
*/
private $oDomain;
/**
* @var string
*/
private $sParentEmail;
/**
* @param string $sEmail
* @param string $sLogin
* @param string $sPassword
* @param \RainLoop\Domain $oDomain
* @param string $sSignMeToken = ''
* @param string $sProxyAuthUser = ''
* @param string $sProxyAuthPassword = ''
*
* @return void
*/
protected function __construct($sEmail, $sLogin, $sPassword, \RainLoop\Domain $oDomain,
$sSignMeToken = '', $sProxyAuthUser = '', $sProxyAuthPassword = '')
{
$this->sEmail = \MailSo\Base\Utils::IdnToAscii($sEmail, true);
$this->sLogin = \MailSo\Base\Utils::IdnToAscii($sLogin);
$this->sPassword = $sPassword;
$this->oDomain = $oDomain;
$this->sSignMeToken = $sSignMeToken;
$this->sProxyAuthUser = $sProxyAuthUser;
$this->sProxyAuthPassword = $sProxyAuthPassword;
}
/**
* @param string $sEmail
* @param string $sLogin
* @param string $sPassword
* @param \RainLoop\Domain $oDomain
* @param string $sSignMeToken = ''
* @param string $sProxyAuthUser = ''
* @param string $sProxyAuthPassword = ''
*
* @return \RainLoop\Account
*/
public static function NewInstance($sEmail, $sLogin, $sPassword, \RainLoop\Domain $oDomain,
$sSignMeToken = '', $sProxyAuthUser = '', $sProxyAuthPassword = '')
{
return new self($sEmail, $sLogin, $sPassword, $oDomain, $sSignMeToken, $sProxyAuthUser, $sProxyAuthPassword);
}
/**
* @return string
*/
public function Email()
{
return $this->sEmail;
}
/**
* @return string
*/
public function ParentEmail()
{
return $this->sParentEmail;
}
/**
* @return string
*/
public function ProxyAuthUser()
{
return $this->sProxyAuthUser;
}
/**
* @return string
*/
public function ProxyAuthPassword()
{
return $this->sProxyAuthPassword;
}
/**
* @return string
*/
public function ParentEmailHelper()
{
return 0 < \strlen($this->sParentEmail) ? $this->sParentEmail : $this->sEmail;
}
/**
* @return string
*/
public function IncLogin()
{
$sLogin = $this->sLogin;
if ($this->oDomain->IncShortLogin())
{
$sLogin = \MailSo\Base\Utils::GetAccountNameFromEmail($this->sLogin);
}
return $sLogin;
}
/**
* @return string
*/
public function IncPassword()
{
return $this->sPassword;
}
/**
* @return string
*/
public function OutLogin()
{
$sLogin = $this->sLogin;
if ($this->oDomain->OutShortLogin())
{
$sLogin = \MailSo\Base\Utils::GetAccountNameFromEmail($this->sLogin);
}
return $sLogin;
}
/**
* @return string
*/
public function Login()
{
return $this->IncLogin();
}
/**
* @return string
*/
public function Password()
{
return $this->IncPassword();
}
/**
* @return bool
*/
public function SignMe()
{
return 0 < \strlen($this->sSignMeToken);
}
/**
* @return string
*/
public function SignMeToken()
{
return $this->sSignMeToken;
}
/**
* @return \RainLoop\Domain
*/
public function Domain()
{
return $this->oDomain;
}
/**
* @return \RainLoop\Domain
*/
public function Hash()
{
return md5(APP_SALT.$this->Email().APP_SALT.$this->DomainIncHost().
APP_SALT.$this->DomainIncPort().APP_SALT.$this->Password().APP_SALT.'0'.APP_SALT.$this->ParentEmail().APP_SALT);
}
/**
* @param string $sPassword
*
* @return void
*/
public function SetPassword($sPassword)
{
$this->sPassword = $sPassword;
}
/**
* @param string $sParentEmail
*
* @return void
*/
public function SetParentEmail($sParentEmail)
{
$this->sParentEmail = \MailSo\Base\Utils::IdnToAscii($sParentEmail, true);
}
/**
* @param string $sProxyAuthUser
*
* @return void
*/
public function SetProxyAuthUser($sProxyAuthUser)
{
return $this->sProxyAuthUser = $sProxyAuthUser;
}
/**
* @param string $sProxyAuthPassword
*
* @return void
*/
public function SetProxyAuthPassword($sProxyAuthPassword)
{
return $this->sProxyAuthPassword = $sProxyAuthPassword;
}
/**
* @return string
*/
public function DomainIncHost()
{
return $this->Domain()->IncHost(\MailSo\Base\Utils::GetDomainFromEmail($this->Email()));
}
/**
* @return int
*/
public function DomainIncPort()
{
return $this->Domain()->IncPort();
}
/**
* @return int
*/
public function DomainIncSecure()
{
return $this->Domain()->IncSecure();
}
/**
* @param bool|null $bGlobalVerify = null
*
* @return bool
*/
public function DomainIncVerifySsl($bGlobalVerify = null)
{
return $this->Domain()->IncVerifySsl($bGlobalVerify);
}
/**
* @return string
*/
public function DomainOutHost()
{
return $this->Domain()->OutHost(\MailSo\Base\Utils::GetDomainFromEmail($this->Email()));
}
/**
* @return int
*/
public function DomainOutPort()
{
return $this->Domain()->OutPort();
}
/**
* @return int
*/
public function DomainOutSecure()
{
return $this->Domain()->OutSecure();
}
/**
* @return bool
*/
public function DomainOutAuth()
{
return $this->Domain()->OutAuth();
}
/**
* @param bool|null $bGlobalVerify = null
*
* @return bool
*/
public function DomainOutVerifySsl($bGlobalVerify = null)
{
return $this->Domain()->OutVerifySsl($bGlobalVerify);
}
/**
* @return string
*/
public function GetAuthToken()
{
return \RainLoop\Utils::EncodeKeyValues(array(
'token', // 0
$this->sEmail, // 1
$this->sLogin, // 2
$this->sPassword, // 3
\RainLoop\Utils::Fingerprint(), // 4
$this->sSignMeToken, // 5
$this->sParentEmail, // 6
\RainLoop\Utils::GetShortToken(), // 7
$this->sProxyAuthUser, // 8
$this->sProxyAuthPassword, // 9
0 // 10
));
}
/**
* @param \RainLoop\Plugins\Manager $oPlugins
* @param \MailSo\Mail\MailClient $oMailClient
* @param \RainLoop\Application $oConfig
*
* @return bool
*/
public function IncConnectAndLoginHelper($oPlugins, $oMailClient, $oConfig)
{
$bLogin = false;
$aImapCredentials = array(
'UseConnect' => true,
'UseAuth' => true,
'Host' => $this->DomainIncHost(),
'Port' => $this->DomainIncPort(),
'Secure' => $this->DomainIncSecure(),
'Login' => $this->IncLogin(),
'Password' => $this->Password(),
'ProxyAuthUser' => $this->ProxyAuthUser(),
'ProxyAuthPassword' => $this->ProxyAuthPassword(),
'VerifySsl' => $this->DomainIncVerifySsl(!!$oConfig->Get('ssl', 'verify_certificate')),
'UseAuthPlainIfSupported' => !!$oConfig->Get('labs', 'use_imap_auth_plain')
);
$oPlugins->RunHook('filter.imap-credentials', array($this, &$aImapCredentials));
$oPlugins->RunHook('event.imap-pre-connect', array($this, $aImapCredentials['UseConnect'], $aImapCredentials));
if ($aImapCredentials['UseConnect'])
{
$oMailClient
->Connect($aImapCredentials['Host'], $aImapCredentials['Port'],
$aImapCredentials['Secure'], $aImapCredentials['VerifySsl']);
}
$oPlugins->RunHook('event.imap-pre-login', array($this, $aImapCredentials['UseAuth'], $aImapCredentials));
if ($aImapCredentials['UseAuth'])
{
if (0 < \strlen($aImapCredentials['ProxyAuthUser']) &&
0 < \strlen($aImapCredentials['ProxyAuthPassword']))
{
$oMailClient
->Login($aImapCredentials['ProxyAuthUser'], $aImapCredentials['ProxyAuthPassword'],
$aImapCredentials['Login'], $aImapCredentials['UseAuthPlainIfSupported']);
}
else
{
$oMailClient->Login($aImapCredentials['Login'], $aImapCredentials['Password'], '',
$aImapCredentials['UseAuthPlainIfSupported']);
}
$bLogin = true;
}
$oPlugins->RunHook('event.imap-post-login', array($this, $aImapCredentials['UseAuth'], $bLogin, $aImapCredentials));
return $bLogin;
}
/**
* @param \RainLoop\Plugins\Manager $oPlugins
* @param \MailSo\Smtp\SmtpClient $oSmtpClient
* @param \RainLoop\Application $oConfig
*
* @return bool
*/
public function OutConnectAndLoginHelper($oPlugins, $oSmtpClient, $oConfig)
{
$bLogin = false;
$aSmtpCredentials = array(
'UseConnect' => true,
'UseAuth' => $this->DomainOutAuth(),
'Ehlo' => \MailSo\Smtp\SmtpClient::EhloHelper(),
'Host' => $this->DomainOutHost(),
'Port' => $this->DomainOutPort(),
'Secure' => $this->DomainOutSecure(),
'Login' => $this->OutLogin(),
'Password' => $this->Password(),
'ProxyAuthUser' => $this->ProxyAuthUser(),
'ProxyAuthPassword' => $this->ProxyAuthPassword(),
'VerifySsl' => $this->DomainOutVerifySsl(!!$oConfig->Get('ssl', 'verify_certificate'))
);
$oPlugins->RunHook('filter.smtp-credentials', array($this, &$aSmtpCredentials));
$oPlugins->RunHook('event.smtp-pre-connect', array($this, $aSmtpCredentials['UseConnect'], $aSmtpCredentials));
if ($aSmtpCredentials['UseConnect'])
{
$oSmtpClient->Connect($aSmtpCredentials['Host'], $aSmtpCredentials['Port'],
$aSmtpCredentials['Ehlo'], $aSmtpCredentials['Secure'], $aSmtpCredentials['VerifySsl']);
}
$oPlugins->RunHook('event.smtp-post-connect', array($this, $aSmtpCredentials['UseConnect'], $aSmtpCredentials));
$oPlugins->RunHook('event.smtp-pre-login', array($this, $aSmtpCredentials['UseAuth'], $aSmtpCredentials));
if ($aSmtpCredentials['UseAuth'])
{
$oSmtpClient->Login($aSmtpCredentials['Login'], $aSmtpCredentials['Password']);
$bLogin = true;
}
$oPlugins->RunHook('event.smtp-post-login', array($this, $aSmtpCredentials['UseAuth'], $bLogin, $aSmtpCredentials));
return $bLogin;
}
}

View file

@ -869,7 +869,7 @@ class Actions
if (0 < \strlen($sEmail) && 0 < \strlen($sLogin) && 0 < \strlen($sPassword)) if (0 < \strlen($sEmail) && 0 < \strlen($sLogin) && 0 < \strlen($sPassword))
{ {
$oDomain = $this->DomainProvider()->Load(\MailSo\Base\Utils::GetDomainFromEmail($sEmail), true); $oDomain = $this->DomainProvider()->Load(\MailSo\Base\Utils::GetDomainFromEmail($sEmail), true);
if ($oDomain instanceof \RainLoop\Domain) if ($oDomain instanceof \RainLoop\Model\Domain)
{ {
if ($oDomain->ValidateWhiteList($sEmail, $sLogin)) if ($oDomain->ValidateWhiteList($sEmail, $sLogin))
{ {
@ -1529,7 +1529,7 @@ class Actions
$sLine = \trim(\implode('.', $aDomainParts), '. '); $sLine = \trim(\implode('.', $aDomainParts), '. ');
$oDomain = $oDomainProvider->Load($sLine); $oDomain = $oDomainProvider->Load($sLine);
if ($oDomain && $oDomain instanceof \RainLoop\Domain) if ($oDomain && $oDomain instanceof \RainLoop\Model\Domain)
{ {
$bAdded = true; $bAdded = true;
$this->Logger()->Write('Check "'.$sLine.'": OK ('.$sEmail.' > '.$sEmail.'@'.$sLine.')', $this->Logger()->Write('Check "'.$sLine.'": OK ('.$sEmail.' > '.$sEmail.'@'.$sLine.')',
@ -2950,7 +2950,7 @@ class Actions
$oDomain = $this->DomainProvider()->LoadOrCreateNewFromAction($this); $oDomain = $this->DomainProvider()->LoadOrCreateNewFromAction($this);
return $this->DefaultResponse(__FUNCTION__, return $this->DefaultResponse(__FUNCTION__,
$oDomain instanceof \RainLoop\Domain ? $this->DomainProvider()->Save($oDomain) : false); $oDomain instanceof \RainLoop\Model\Domain ? $this->DomainProvider()->Save($oDomain) : false);
} }
/** /**
@ -2977,8 +2977,8 @@ class Actions
$oImapClient->SetTimeOuts(5); $oImapClient->SetTimeOuts(5);
$iTime = \microtime(true); $iTime = \microtime(true);
$oImapClient->Connect($oDomain->IncHost($oDomain->Name()), $oDomain->IncPort(), $oImapClient->Connect($oDomain->IncHost(), $oDomain->IncPort(),
$oDomain->IncSecure(), $oDomain->IncVerifySsl(!!$this->Config()->Get('ssl', 'verify_certificate'))); $oDomain->IncSecure(), !!$this->Config()->Get('ssl', 'verify_certificate'));
$iImapTime = \microtime(true) - $iTime; $iImapTime = \microtime(true) - $iTime;
$oImapClient->Disconnect(); $oImapClient->Disconnect();
@ -3005,8 +3005,8 @@ class Actions
$oSmtpClient->SetTimeOuts(5); $oSmtpClient->SetTimeOuts(5);
$iTime = \microtime(true); $iTime = \microtime(true);
$oSmtpClient->Connect($oDomain->OutHost($oDomain->Name()), $oDomain->OutPort(), '127.0.0.1', $oSmtpClient->Connect($oDomain->OutHost(), $oDomain->OutPort(), '127.0.0.1',
$oDomain->OutSecure(), $oDomain->OutVerifySsl(!!$this->Config()->Get('ssl', 'verify_certificate'))); $oDomain->OutSecure(), !!$this->Config()->Get('ssl', 'verify_certificate'));
$iSmtpTime = \microtime(true) - $iTime; $iSmtpTime = \microtime(true) - $iTime;
$oSmtpClient->Disconnect(); $oSmtpClient->Disconnect();
@ -3422,11 +3422,10 @@ class Actions
{ {
$this->Logger()->Write('Versions GC: Begin'); $this->Logger()->Write('Versions GC: Begin');
$iLimitToDelete = 3;
$sVPath = APP_INDEX_ROOT_PATH.'rainloop/v/'; $sVPath = APP_INDEX_ROOT_PATH.'rainloop/v/';
$aDirs = @\array_map('basename', @\array_filter(@\glob($sVPath.'*'), 'is_dir')); $aDirs = @\array_map('basename', @\array_filter(@\glob($sVPath.'*'), 'is_dir'));
$this->Logger()->Write('Versions GC: Count:'.(\is_array($aDirs) ? \count($aDirs) : 0));
if (\is_array($aDirs) && 5 < \count($aDirs)) if (\is_array($aDirs) && 5 < \count($aDirs))
{ {
\uasort($aDirs, 'version_compare'); \uasort($aDirs, 'version_compare');
@ -3439,12 +3438,7 @@ class Actions
@\MailSo\Base\Utils::RecRmDir($sVPath.$sName); @\MailSo\Base\Utils::RecRmDir($sVPath.$sName);
$this->Logger()->Write('Versions GC: End to remove "'.$sVPath.$sName.'" version'); $this->Logger()->Write('Versions GC: End to remove "'.$sVPath.$sName.'" version');
$iLimitToDelete--; break;
if (0 > $iLimitToDelete)
{
break;
}
} }
} }
} }

View file

@ -0,0 +1,438 @@
<?php
namespace RainLoop\Model;
class Account
{
/**
* @var string
*/
private $sEmail;
/**
* @var string
*/
private $sLogin;
/**
* @var int
*/
private $sPassword;
/**
* @var string
*/
private $sProxyAuthUser;
/**
* @var string
*/
private $sProxyAuthPassword;
/**
* @var string
*/
private $sSignMeToken;
/**
* @var \RainLoop\Model\Domain
*/
private $oDomain;
/**
* @var string
*/
private $sParentEmail;
/**
* @param string $sEmail
* @param string $sLogin
* @param string $sPassword
* @param \RainLoop\Model\Domain $oDomain
* @param string $sSignMeToken = ''
* @param string $sProxyAuthUser = ''
* @param string $sProxyAuthPassword = ''
*
* @return void
*/
protected function __construct($sEmail, $sLogin, $sPassword, \RainLoop\Model\Domain $oDomain,
$sSignMeToken = '', $sProxyAuthUser = '', $sProxyAuthPassword = '')
{
$this->sEmail = \MailSo\Base\Utils::IdnToAscii($sEmail, true);
$this->sLogin = \MailSo\Base\Utils::IdnToAscii($sLogin);
$this->sPassword = $sPassword;
$this->oDomain = $oDomain;
$this->sSignMeToken = $sSignMeToken;
$this->sProxyAuthUser = $sProxyAuthUser;
$this->sProxyAuthPassword = $sProxyAuthPassword;
}
/**
* @param string $sEmail
* @param string $sLogin
* @param string $sPassword
* @param \RainLoop\Model\Domain $oDomain
* @param string $sSignMeToken = ''
* @param string $sProxyAuthUser = ''
* @param string $sProxyAuthPassword = ''
*
* @return \RainLoop\Model\Account
*/
public static function NewInstance($sEmail, $sLogin, $sPassword, \RainLoop\Model\Domain $oDomain,
$sSignMeToken = '', $sProxyAuthUser = '', $sProxyAuthPassword = '')
{
return new self($sEmail, $sLogin, $sPassword, $oDomain, $sSignMeToken, $sProxyAuthUser, $sProxyAuthPassword);
}
/**
* @return string
*/
public function Email()
{
return $this->sEmail;
}
/**
* @return string
*/
public function ParentEmail()
{
return $this->sParentEmail;
}
/**
* @return string
*/
public function ProxyAuthUser()
{
return $this->sProxyAuthUser;
}
/**
* @return string
*/
public function ProxyAuthPassword()
{
return $this->sProxyAuthPassword;
}
/**
* @return string
*/
public function ParentEmailHelper()
{
return 0 < \strlen($this->sParentEmail) ? $this->sParentEmail : $this->sEmail;
}
/**
* @return string
*/
public function IncLogin()
{
$sLogin = $this->sLogin;
if ($this->oDomain->IncShortLogin())
{
$sLogin = \MailSo\Base\Utils::GetAccountNameFromEmail($this->sLogin);
}
return $sLogin;
}
/**
* @return string
*/
public function IncPassword()
{
return $this->sPassword;
}
/**
* @return string
*/
public function OutLogin()
{
$sLogin = $this->sLogin;
if ($this->oDomain->OutShortLogin())
{
$sLogin = \MailSo\Base\Utils::GetAccountNameFromEmail($this->sLogin);
}
return $sLogin;
}
/**
* @return string
*/
public function Login()
{
return $this->IncLogin();
}
/**
* @return string
*/
public function Password()
{
return $this->IncPassword();
}
/**
* @return bool
*/
public function SignMe()
{
return 0 < \strlen($this->sSignMeToken);
}
/**
* @return string
*/
public function SignMeToken()
{
return $this->sSignMeToken;
}
/**
* @return \RainLoop\Model\Domain
*/
public function Domain()
{
return $this->oDomain;
}
/**
* @return string
*/
public function Hash()
{
return md5(APP_SALT.$this->Email().APP_SALT.$this->DomainIncHost().
APP_SALT.$this->DomainIncPort().APP_SALT.$this->Password().APP_SALT.'0'.APP_SALT.$this->ParentEmail().APP_SALT);
}
/**
* @param string $sPassword
*
* @return void
*/
public function SetPassword($sPassword)
{
$this->sPassword = $sPassword;
}
/**
* @param string $sParentEmail
*
* @return void
*/
public function SetParentEmail($sParentEmail)
{
$this->sParentEmail = \MailSo\Base\Utils::IdnToAscii($sParentEmail, true);
}
/**
* @param string $sProxyAuthUser
*
* @return void
*/
public function SetProxyAuthUser($sProxyAuthUser)
{
return $this->sProxyAuthUser = $sProxyAuthUser;
}
/**
* @param string $sProxyAuthPassword
*
* @return void
*/
public function SetProxyAuthPassword($sProxyAuthPassword)
{
return $this->sProxyAuthPassword = $sProxyAuthPassword;
}
/**
* @return string
*/
public function DomainIncHost()
{
return $this->Domain()->IncHost();
}
/**
* @return int
*/
public function DomainIncPort()
{
return $this->Domain()->IncPort();
}
/**
* @return int
*/
public function DomainIncSecure()
{
return $this->Domain()->IncSecure();
}
/**
* @return string
*/
public function DomainOutHost()
{
return $this->Domain()->OutHost();
}
/**
* @return int
*/
public function DomainOutPort()
{
return $this->Domain()->OutPort();
}
/**
* @return int
*/
public function DomainOutSecure()
{
return $this->Domain()->OutSecure();
}
/**
* @return bool
*/
public function DomainOutAuth()
{
return $this->Domain()->OutAuth();
}
/**
* @return string
*/
public function GetAuthToken()
{
return \RainLoop\Utils::EncodeKeyValues(array(
'token', // 0
$this->sEmail, // 1
$this->sLogin, // 2
$this->sPassword, // 3
\RainLoop\Utils::Fingerprint(), // 4
$this->sSignMeToken, // 5
$this->sParentEmail, // 6
\RainLoop\Utils::GetShortToken(), // 7
$this->sProxyAuthUser, // 8
$this->sProxyAuthPassword, // 9
0 // 10
));
}
/**
* @param \RainLoop\Plugins\Manager $oPlugins
* @param \MailSo\Mail\MailClient $oMailClient
* @param \RainLoop\Application $oConfig
*
* @return bool
*/
public function IncConnectAndLoginHelper($oPlugins, $oMailClient, $oConfig)
{
$bLogin = false;
$aImapCredentials = array(
'UseConnect' => true,
'UseAuth' => true,
'Host' => $this->DomainIncHost(),
'Port' => $this->DomainIncPort(),
'Secure' => $this->DomainIncSecure(),
'Login' => $this->IncLogin(),
'Password' => $this->Password(),
'ProxyAuthUser' => $this->ProxyAuthUser(),
'ProxyAuthPassword' => $this->ProxyAuthPassword(),
'VerifySsl' => !!$oConfig->Get('ssl', 'verify_certificate'),
'UseAuthPlainIfSupported' => !!$oConfig->Get('labs', 'use_imap_auth_plain')
);
$oPlugins->RunHook('filter.imap-credentials', array($this, &$aImapCredentials));
$oPlugins->RunHook('event.imap-pre-connect', array($this, $aImapCredentials['UseConnect'], $aImapCredentials));
if ($aImapCredentials['UseConnect'])
{
$oMailClient
->Connect($aImapCredentials['Host'], $aImapCredentials['Port'],
$aImapCredentials['Secure'], $aImapCredentials['VerifySsl']);
}
$oPlugins->RunHook('event.imap-pre-login', array($this, $aImapCredentials['UseAuth'], $aImapCredentials));
if ($aImapCredentials['UseAuth'])
{
if (0 < \strlen($aImapCredentials['ProxyAuthUser']) &&
0 < \strlen($aImapCredentials['ProxyAuthPassword']))
{
$oMailClient
->Login($aImapCredentials['ProxyAuthUser'], $aImapCredentials['ProxyAuthPassword'],
$aImapCredentials['Login'], $aImapCredentials['UseAuthPlainIfSupported']);
}
else
{
$oMailClient->Login($aImapCredentials['Login'], $aImapCredentials['Password'], '',
$aImapCredentials['UseAuthPlainIfSupported']);
}
$bLogin = true;
}
$oPlugins->RunHook('event.imap-post-login', array($this, $aImapCredentials['UseAuth'], $bLogin, $aImapCredentials));
return $bLogin;
}
/**
* @param \RainLoop\Plugins\Manager $oPlugins
* @param \MailSo\Smtp\SmtpClient $oSmtpClient
* @param \RainLoop\Application $oConfig
*
* @return bool
*/
public function OutConnectAndLoginHelper($oPlugins, $oSmtpClient, $oConfig)
{
$bLogin = false;
$aSmtpCredentials = array(
'UseConnect' => true,
'UseAuth' => $this->DomainOutAuth(),
'Ehlo' => \MailSo\Smtp\SmtpClient::EhloHelper(),
'Host' => $this->DomainOutHost(),
'Port' => $this->DomainOutPort(),
'Secure' => $this->DomainOutSecure(),
'Login' => $this->OutLogin(),
'Password' => $this->Password(),
'ProxyAuthUser' => $this->ProxyAuthUser(),
'ProxyAuthPassword' => $this->ProxyAuthPassword(),
'VerifySsl' => !!$oConfig->Get('ssl', 'verify_certificate')
);
$oPlugins->RunHook('filter.smtp-credentials', array($this, &$aSmtpCredentials));
$oPlugins->RunHook('event.smtp-pre-connect', array($this, $aSmtpCredentials['UseConnect'], $aSmtpCredentials));
if ($aSmtpCredentials['UseConnect'])
{
$oSmtpClient->Connect($aSmtpCredentials['Host'], $aSmtpCredentials['Port'],
$aSmtpCredentials['Ehlo'], $aSmtpCredentials['Secure'], $aSmtpCredentials['VerifySsl']);
}
$oPlugins->RunHook('event.smtp-post-connect', array($this, $aSmtpCredentials['UseConnect'], $aSmtpCredentials));
$oPlugins->RunHook('event.smtp-pre-login', array($this, $aSmtpCredentials['UseAuth'], $aSmtpCredentials));
if ($aSmtpCredentials['UseAuth'])
{
$oSmtpClient->Login($aSmtpCredentials['Login'], $aSmtpCredentials['Password']);
$bLogin = true;
}
$oPlugins->RunHook('event.smtp-post-login', array($this, $aSmtpCredentials['UseAuth'], $bLogin, $aSmtpCredentials));
return $bLogin;
}
}

View file

@ -1,6 +1,6 @@
<?php <?php
namespace RainLoop; namespace RainLoop\Model;
use MailSo\Net\Enumerations\ConnectionSecurityType; use MailSo\Net\Enumerations\ConnectionSecurityType;
@ -28,11 +28,6 @@ class Domain
*/ */
private $iIncSecure; private $iIncSecure;
/**
* @var bool
*/
private $bIncVerifySsl;
/** /**
* @var bool * @var bool
*/ */
@ -53,11 +48,6 @@ class Domain
*/ */
private $iOutSecure; private $iOutSecure;
/**
* @var bool
*/
private $bOutVerifySsl;
/** /**
* @var bool * @var bool
*/ */
@ -78,29 +68,25 @@ class Domain
* @param string $sIncHost * @param string $sIncHost
* @param int $iIncPort * @param int $iIncPort
* @param int $iIncSecure * @param int $iIncSecure
* @param bool $bIncVerifySsl
* @param bool $bIncShortLogin * @param bool $bIncShortLogin
* @param string $sOutHost * @param string $sOutHost
* @param int $iOutPort * @param int $iOutPort
* @param int $iOutSecure * @param int $iOutSecure
* @param bool $bOutVerifySsl
* @param bool $bOutShortLogin * @param bool $bOutShortLogin
* @param bool $bOutAuth * @param bool $bOutAuth
* @param string $sWhiteList = '' * @param string $sWhiteList = ''
*/ */
private function __construct($sName, $sIncHost, $iIncPort, $iIncSecure, $bIncVerifySsl, $bIncShortLogin, private function __construct($sName, $sIncHost, $iIncPort, $iIncSecure, $bIncShortLogin,
$sOutHost, $iOutPort, $iOutSecure, $bOutVerifySsl, $bOutShortLogin, $bOutAuth, $sWhiteList = '') $sOutHost, $iOutPort, $iOutSecure, $bOutShortLogin, $bOutAuth, $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->bIncVerifySsl = !!$bIncVerifySsl;
$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->bOutVerifySsl = !!$bOutVerifySsl;
$this->bOutShortLogin = $bOutShortLogin; $this->bOutShortLogin = $bOutShortLogin;
$this->bOutAuth = $bOutAuth; $this->bOutAuth = $bOutAuth;
$this->sWhiteList = \trim($sWhiteList); $this->sWhiteList = \trim($sWhiteList);
@ -111,26 +97,24 @@ class Domain
* @param string $sIncHost * @param string $sIncHost
* @param int $iIncPort * @param int $iIncPort
* @param int $iIncSecure * @param int $iIncSecure
* @param bool $bIncVerifySsl
* @param bool $bIncShortLogin * @param bool $bIncShortLogin
* @param string $sOutHost * @param string $sOutHost
* @param int $iOutPort * @param int $iOutPort
* @param int $iOutSecure * @param int $iOutSecure
* @param bool $bOutVerifySsl
* @param bool $bOutShortLogin * @param bool $bOutShortLogin
* @param bool $bOutAuth * @param bool $bOutAuth
* @param string $sWhiteList = '' * @param string $sWhiteList = ''
* *
* @return \RainLoop\Domain * @return \RainLoop\Model\Domain
*/ */
public static function NewInstance($sName, public static function NewInstance($sName,
$sIncHost, $iIncPort, $iIncSecure, $bIncVerifySsl, $bIncShortLogin, $sIncHost, $iIncPort, $iIncSecure, $bIncShortLogin,
$sOutHost, $iOutPort, $iOutSecure, $bOutVerifySsl, $bOutShortLogin, $bOutAuth, $sOutHost, $iOutPort, $iOutSecure, $bOutShortLogin, $bOutAuth,
$sWhiteList = '') $sWhiteList = '')
{ {
return new self($sName, return new self($sName,
$sIncHost, $iIncPort, $iIncSecure, $bIncVerifySsl, $bIncShortLogin, $sIncHost, $iIncPort, $iIncSecure, $bIncShortLogin,
$sOutHost, $iOutPort, $iOutSecure, $bOutVerifySsl, $bOutShortLogin, $bOutAuth, $sOutHost, $iOutPort, $iOutSecure, $bOutShortLogin, $bOutAuth,
$sWhiteList); $sWhiteList);
} }
@ -138,7 +122,7 @@ class Domain
* @param string $sName * @param string $sName
* @param array $aDomain * @param array $aDomain
* *
* @return \RainLoop\Domain|null * @return \RainLoop\Model\Domain|null
*/ */
public static function NewInstanceFromDomainConfigArray($sName, $aDomain) public static function NewInstanceFromDomainConfigArray($sName, $aDomain)
{ {
@ -152,15 +136,11 @@ class Domain
$iIncSecure = self::StrConnectionSecurityTypeToCons( $iIncSecure = self::StrConnectionSecurityTypeToCons(
!empty($aDomain['imap_secure']) ? $aDomain['imap_secure'] : ''); !empty($aDomain['imap_secure']) ? $aDomain['imap_secure'] : '');
$bIncVerifySsl = isset($aDomain['imap_verify_ssl']) ? (bool) $aDomain['smtp_verify_ssl'] : false;;
$sOutHost = (string) $aDomain['smtp_host']; $sOutHost = (string) $aDomain['smtp_host'];
$iOutPort = (int) $aDomain['smtp_port']; $iOutPort = (int) $aDomain['smtp_port'];
$iOutSecure = self::StrConnectionSecurityTypeToCons( $iOutSecure = self::StrConnectionSecurityTypeToCons(
!empty($aDomain['smtp_secure']) ? $aDomain['smtp_secure'] : ''); !empty($aDomain['smtp_secure']) ? $aDomain['smtp_secure'] : '');
$bOutVerifySsl = isset($aDomain['smtp_verify_ssl']) ? (bool) $aDomain['smtp_verify_ssl'] : false;
$bOutAuth = isset($aDomain['smtp_auth']) ? (bool) $aDomain['smtp_auth'] : true; $bOutAuth = isset($aDomain['smtp_auth']) ? (bool) $aDomain['smtp_auth'] : true;
$sWhiteList = (string) (isset($aDomain['white_list']) ? $aDomain['white_list'] : ''); $sWhiteList = (string) (isset($aDomain['white_list']) ? $aDomain['white_list'] : '');
@ -168,8 +148,8 @@ class Domain
$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, $bIncVerifySsl, $bIncShortLogin, $sIncHost, $iIncPort, $iIncSecure, $bIncShortLogin,
$sOutHost, $iOutPort, $iOutSecure, $bOutVerifySsl, $bOutShortLogin, $bOutAuth, $sOutHost, $iOutPort, $iOutSecure, $bOutShortLogin, $bOutAuth,
$sWhiteList); $sWhiteList);
} }
@ -213,12 +193,10 @@ class Domain
'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_verify_ssl = '.($this->bIncVerifySsl ? 'On' : 'Off'),
'imap_short_login = '.($this->bIncShortLogin ? 'On' : 'Off'), 'imap_short_login = '.($this->bIncShortLogin ? 'On' : 'Off'),
'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).'"',
'smtp_verify_ssl = '.($this->bOutVerifySsl ? 'On' : 'Off'),
'smtp_short_login = '.($this->bOutShortLogin ? 'On' : 'Off'), 'smtp_short_login = '.($this->bOutShortLogin ? 'On' : 'Off'),
'smtp_auth = '.($this->bOutAuth ? 'On' : 'Off'), 'smtp_auth = '.($this->bOutAuth ? 'On' : 'Off'),
'white_list = "'.$this->encodeIniString($this->sWhiteList).'"' 'white_list = "'.$this->encodeIniString($this->sWhiteList).'"'
@ -270,32 +248,28 @@ class Domain
* @param string $sIncHost * @param string $sIncHost
* @param int $iIncPort * @param int $iIncPort
* @param int $iIncSecure * @param int $iIncSecure
* @param bool $bIncVerifySsl
* @param bool $bIncShortLogin * @param bool $bIncShortLogin
* @param string $sOutHost * @param string $sOutHost
* @param int $iOutPort * @param int $iOutPort
* @param int $iOutSecure * @param int $iOutSecure
* @param bool $bOutVerifySsl
* @param bool $bOutShortLogin * @param bool $bOutShortLogin
* @param bool $bOutAuth * @param bool $bOutAuth
* @param string $sWhiteList = '' * @param string $sWhiteList = ''
* *
* @return \RainLoop\Domain * @return \RainLoop\Model\Domain
*/ */
public function UpdateInstance( public function UpdateInstance(
$sIncHost, $iIncPort, $iIncSecure, $bIncVerifySsl, $bIncShortLogin, $sIncHost, $iIncPort, $iIncSecure, $bIncShortLogin,
$sOutHost, $iOutPort, $iOutSecure, $bOutVerifySsl, $bOutShortLogin, $bOutAuth, $sOutHost, $iOutPort, $iOutSecure, $bOutShortLogin, $bOutAuth,
$sWhiteList = '') $sWhiteList = '')
{ {
$this->sIncHost = \MailSo\Base\Utils::IdnToAscii($sIncHost); $this->sIncHost = \MailSo\Base\Utils::IdnToAscii($sIncHost);
$this->iIncPort = $iIncPort; $this->iIncPort = $iIncPort;
$this->iIncSecure = $iIncSecure; $this->iIncSecure = $iIncSecure;
$this->bIncVerifySsl = !!$bIncVerifySsl;
$this->bIncShortLogin = $bIncShortLogin; $this->bIncShortLogin = $bIncShortLogin;
$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->bOutVerifySsl = !!$bOutVerifySsl;
$this->bOutShortLogin = $bOutShortLogin; $this->bOutShortLogin = $bOutShortLogin;
$this->bOutAuth = $bOutAuth; $this->bOutAuth = $bOutAuth;
$this->sWhiteList = \trim($sWhiteList); $this->sWhiteList = \trim($sWhiteList);
@ -312,13 +286,11 @@ class Domain
} }
/** /**
* @param string $sRealDomainName = ''
*
* @return string * @return string
*/ */
public function IncHost($sRealDomainName = '') public function IncHost()
{ {
return 0 < \strlen($sRealDomainName) ? \str_replace('{domain:name}', $sRealDomainName, $this->sIncHost) : $this->sIncHost; return $this->sIncHost;
} }
/** /**
@ -337,16 +309,6 @@ class Domain
return $this->iIncSecure; return $this->iIncSecure;
} }
/**
* @param bool|null $bGlobalVerify = null
*
* @return bool
*/
public function IncVerifySsl($bGlobalVerify = null)
{
return null === $bGlobalVerify ? $this->bIncVerifySsl : !!$bGlobalVerify;
}
/** /**
* @return bool * @return bool
*/ */
@ -356,12 +318,11 @@ class Domain
} }
/** /**
* @param string $sRealDomainName = ''
* @return string * @return string
*/ */
public function OutHost($sRealDomainName = '') public function OutHost()
{ {
return 0 < \strlen($sRealDomainName) ? \str_replace('{domain:name}', $sRealDomainName, $this->sOutHost) : $this->sOutHost; return $this->sOutHost;
} }
/** /**
@ -450,12 +411,10 @@ class Domain
'IncHost' => $bAjax ? \MailSo\Base\Utils::IdnToUtf8($this->IncHost()) : $this->IncHost(), 'IncHost' => $bAjax ? \MailSo\Base\Utils::IdnToUtf8($this->IncHost()) : $this->IncHost(),
'IncPort' => $this->IncPort(), 'IncPort' => $this->IncPort(),
'IncSecure' => $this->IncSecure(), 'IncSecure' => $this->IncSecure(),
'IncVerifySsl' => $this->IncVerifySsl(),
'IncShortLogin' => $this->IncShortLogin(), 'IncShortLogin' => $this->IncShortLogin(),
'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(),
'OutVerifySsl' => $this->OutVerifySsl(),
'OutShortLogin' => $this->OutShortLogin(), 'OutShortLogin' => $this->OutShortLogin(),
'OutAuth' => $this->OutAuth(), 'OutAuth' => $this->OutAuth(),
'WhiteList' => $this->WhiteList() 'WhiteList' => $this->WhiteList()

View file

@ -1,6 +1,6 @@
<?php <?php
namespace RainLoop; namespace RainLoop\Model;
class Identity class Identity
{ {
@ -54,7 +54,7 @@ class Identity
* @param string $sReplyTo = '' * @param string $sReplyTo = ''
* @param string $sBcc = '' * @param string $sBcc = ''
* *
* @return \RainLoop\Identity * @return \RainLoop\Model\Identity
*/ */
public static function NewInstance($sId, $sEmail, $sName = '', $sReplyTo = '', $sBcc = '') public static function NewInstance($sId, $sEmail, $sName = '', $sReplyTo = '', $sBcc = '')
{ {
@ -72,7 +72,7 @@ class Identity
/** /**
* @param string $sId * @param string $sId
* *
* @return \RainLoop\Identity * @return \RainLoop\Model\Identity
*/ */
public function SetId($sId) public function SetId($sId)
{ {
@ -92,7 +92,7 @@ class Identity
/** /**
* @param string $sEmail * @param string $sEmail
* *
* @return \RainLoop\Identity * @return \RainLoop\Model\Identity
*/ */
public function SetEmail($sEmail) public function SetEmail($sEmail)
{ {
@ -112,7 +112,7 @@ class Identity
/** /**
* @param string $sName * @param string $sName
* *
* @return \RainLoop\Identity * @return \RainLoop\Model\Identity
*/ */
public function SetName($sName) public function SetName($sName)
{ {
@ -132,7 +132,7 @@ class Identity
/** /**
* @param string $sReplyTo * @param string $sReplyTo
* *
* @return \RainLoop\Identity * @return \RainLoop\Model\Identity
*/ */
public function SetReplyTo($sReplyTo) public function SetReplyTo($sReplyTo)
{ {
@ -152,7 +152,7 @@ class Identity
/** /**
* @param string $sBcc * @param string $sBcc
* *
* @return \RainLoop\Identity * @return \RainLoop\Model\Identity
*/ */
public function SetBcc($sBcc) public function SetBcc($sBcc)
{ {

View file

@ -45,12 +45,12 @@ class Domain extends \RainLoop\Providers\AbstractProvider
* @param bool $bFindWithWildCard = false * @param bool $bFindWithWildCard = false
* @param bool $bCheckDisabled = true * @param bool $bCheckDisabled = true
* *
* @return \RainLoop\Domain|null * @return \RainLoop\Model\Domain|null
*/ */
public function Load($sName, $bFindWithWildCard = false, $bCheckDisabled = true) public function Load($sName, $bFindWithWildCard = false, $bCheckDisabled = true)
{ {
$oDomain = $this->oDriver->Load($sName, $bFindWithWildCard, $bCheckDisabled); $oDomain = $this->oDriver->Load($sName, $bFindWithWildCard, $bCheckDisabled);
if ($oDomain instanceof \RainLoop\Domain) if ($oDomain instanceof \RainLoop\Model\Domain)
{ {
$this->oPlugins->RunHook('filter.domain', array(&$oDomain)); $this->oPlugins->RunHook('filter.domain', array(&$oDomain));
} }
@ -59,11 +59,11 @@ class Domain extends \RainLoop\Providers\AbstractProvider
} }
/** /**
* @param \RainLoop\Domain $oDomain * @param \RainLoop\Model\Domain $oDomain
* *
* @return bool * @return bool
*/ */
public function Save(\RainLoop\Domain $oDomain) public function Save(\RainLoop\Model\Domain $oDomain)
{ {
return $this->bAdmin ? $this->oDriver->Save($oDomain) : false; return $this->bAdmin ? $this->oDriver->Save($oDomain) : false;
} }
@ -115,7 +115,7 @@ class Domain extends \RainLoop\Providers\AbstractProvider
* @param \RainLoop\Actions $oActions * @param \RainLoop\Actions $oActions
* @param string $sNameForTest = '' * @param string $sNameForTest = ''
* *
* @return \RainLoop\Domain | null * @return \RainLoop\Model\Domain | null
*/ */
public function LoadOrCreateNewFromAction(\RainLoop\Actions $oActions, $sNameForTest = '') public function LoadOrCreateNewFromAction(\RainLoop\Actions $oActions, $sNameForTest = '')
{ {
@ -128,12 +128,10 @@ class Domain extends \RainLoop\Providers\AbstractProvider
$sIncHost = (string) $oActions->GetActionParam('IncHost', ''); $sIncHost = (string) $oActions->GetActionParam('IncHost', '');
$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);
$bIncVerifySsl = '1' === (string) $oActions->GetActionParam('IncVerifySsl', '0');
$bIncShortLogin = '1' === (string) $oActions->GetActionParam('IncShortLogin', '0'); $bIncShortLogin = '1' === (string) $oActions->GetActionParam('IncShortLogin', '0');
$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);
$bOutVerifySsl = '1' === (string) $oActions->GetActionParam('OutVerifySsl', '0');
$bOutShortLogin = '1' === (string) $oActions->GetActionParam('OutShortLogin', '0'); $bOutShortLogin = '1' === (string) $oActions->GetActionParam('OutShortLogin', '0');
$bOutAuth = '1' === (string) $oActions->GetActionParam('OutAuth', '1'); $bOutAuth = '1' === (string) $oActions->GetActionParam('OutAuth', '1');
$sWhiteList = (string) $oActions->GetActionParam('WhiteList', ''); $sWhiteList = (string) $oActions->GetActionParam('WhiteList', '');
@ -146,7 +144,7 @@ class Domain extends \RainLoop\Providers\AbstractProvider
if (0 < strlen($sName) || 0 < strlen($sNameForTest)) if (0 < strlen($sName) || 0 < strlen($sNameForTest))
{ {
$oDomain = 0 < strlen($sNameForTest) ? null : $this->Load($sName); $oDomain = 0 < strlen($sNameForTest) ? null : $this->Load($sName);
if ($oDomain instanceof \RainLoop\Domain) if ($oDomain instanceof \RainLoop\Model\Domain)
{ {
if ($bCreate) if ($bCreate)
{ {
@ -155,16 +153,16 @@ class Domain extends \RainLoop\Providers\AbstractProvider
else else
{ {
$oDomain->UpdateInstance( $oDomain->UpdateInstance(
$sIncHost, $iIncPort, $iIncSecure, $bIncVerifySsl, $bIncShortLogin, $sIncHost, $iIncPort, $iIncSecure, $bIncShortLogin,
$sOutHost, $iOutPort, $iOutSecure, $bOutVerifySsl, $bOutShortLogin, $bOutAuth, $sOutHost, $iOutPort, $iOutSecure, $bOutShortLogin, $bOutAuth,
$sWhiteList); $sWhiteList);
} }
} }
else else
{ {
$oDomain = \RainLoop\Domain::NewInstance(0 < strlen($sNameForTest) ? $sNameForTest : $sName, $oDomain = \RainLoop\Model\Domain::NewInstance(0 < strlen($sNameForTest) ? $sNameForTest : $sName,
$sIncHost, $iIncPort, $iIncSecure, $bIncVerifySsl, $bIncShortLogin, $sIncHost, $iIncPort, $iIncSecure, $bIncShortLogin,
$sOutHost, $iOutPort, $iOutSecure, $bOutVerifySsl, $bOutShortLogin, $bOutAuth, $sOutHost, $iOutPort, $iOutSecure, $bOutShortLogin, $bOutAuth,
$sWhiteList); $sWhiteList);
} }
} }

View file

@ -147,7 +147,7 @@ class DefaultDomain implements \RainLoop\Providers\Domain\DomainAdminInterface
* @param bool $bFindWithWildCard = false * @param bool $bFindWithWildCard = false
* @param bool $bCheckDisabled = true * @param bool $bCheckDisabled = true
* *
* @return \RainLoop\Domain|null * @return \RainLoop\Model\Domain|null
*/ */
public function Load($sName, $bFindWithWildCard = false, $bCheckDisabled = true) public function Load($sName, $bFindWithWildCard = false, $bCheckDisabled = true)
{ {
@ -192,7 +192,7 @@ class DefaultDomain implements \RainLoop\Providers\Domain\DomainAdminInterface
} }
//--- //---
$mResult = \RainLoop\Domain::NewInstanceFromDomainConfigArray($sName, $aDomain); $mResult = \RainLoop\Model\Domain::NewInstanceFromDomainConfigArray($sName, $aDomain);
} }
else if ($bFindWithWildCard) else if ($bFindWithWildCard)
{ {
@ -214,11 +214,11 @@ class DefaultDomain implements \RainLoop\Providers\Domain\DomainAdminInterface
} }
/** /**
* @param \RainLoop\Domain $oDomain * @param \RainLoop\Model\Domain $oDomain
* *
* @return bool * @return bool
*/ */
public function Save(\RainLoop\Domain $oDomain) public function Save(\RainLoop\Model\Domain $oDomain)
{ {
$sRealFileName = $this->codeFileName($oDomain->Name()); $sRealFileName = $this->codeFileName($oDomain->Name());

View file

@ -18,16 +18,16 @@ interface DomainAdminInterface extends DomainInterface
* @param bool $bFindWithWildCard = false * @param bool $bFindWithWildCard = false
* @param bool $bCheckDisabled = true * @param bool $bCheckDisabled = true
* *
* @return \RainLoop\Domain|null * @return \RainLoop\Model\Domain|null
*/ */
public function Load($sName, $bFindWithWildCard = false, $bCheckDisabled = true); public function Load($sName, $bFindWithWildCard = false, $bCheckDisabled = true);
/** /**
* @param \RainLoop\Domain $oDomain * @param \RainLoop\Model\Domain $oDomain
* *
* @return bool * @return bool
*/ */
public function Save(\RainLoop\Domain $oDomain); public function Save(\RainLoop\Model\Domain $oDomain);
/** /**
* @param string $sName * @param string $sName

View file

@ -6,16 +6,16 @@
</div> </div>
<div class="modal-body"> <div class="modal-body">
<form class="form-horizontal domain-form" action="#/" onsubmit="return false;"> <form class="form-horizontal domain-form" action="#/" onsubmit="return false;">
<div class="row" data-bind="visible: !edit()"> <div class="row" data-bind="visible: !edit()" style="margin-bottom: 20px;">
<div class="span10"> <div class="span10">
Name <span style="color: #aaa">(wildcard supported)</span> Name <span style="color: #aaa">(wildcard supported)</span>
<br /> <br />
<input type="text" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" <input type="text" class="span4" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"
data-bind="textInput: name, hasfocus: name.focused" /> data-bind="textInput: name, hasfocus: name.focused" />
<span class="error-desc" data-bind="text: savingError"></span> <span class="error-desc" data-bind="text: savingError"></span>
</div> </div>
</div> </div>
<br />
<div class="row"> <div class="row">
<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">
@ -47,21 +47,13 @@
<option value="1">SSL/TLS</option> <option value="1">SSL/TLS</option>
<option value="2">STARTTLS</option> <option value="2">STARTTLS</option>
</select> </select>
&nbsp;&nbsp;&nbsp;&nbsp;
<div data-bind="visible: '1' === imapSecure() && false, component: {
name: 'Checkbox',
params: {
label: 'Verify ssl certificate',
value: imapVerifySsl
}
}"></div>
</div> </div>
</div> </div>
<br /> <br />
<div data-bind="component: { <div data-bind="component: {
name: 'Checkbox', name: 'Checkbox',
params: { params: {
label: 'Use short login form', label: 'Use short login',
value: imapShortLogin, value: imapShortLogin,
inline: true inline: true
} }
@ -99,21 +91,13 @@
<option value="1">SSL/TLS</option> <option value="1">SSL/TLS</option>
<option value="2">STARTTLS</option> <option value="2">STARTTLS</option>
</select> </select>
&nbsp;&nbsp;&nbsp;&nbsp;
<div data-bind="visible: '1' === smtpSecure() && false, component: {
name: 'Checkbox',
params: {
label: 'Verify ssl certificate',
value: smtpVerifySsl
}
}"></div>
</div> </div>
</div> </div>
<br /> <br />
<div data-bind="component: { <div data-bind="component: {
name: 'Checkbox', name: 'Checkbox',
params: { params: {
label: 'Use short login form', label: 'Use short login',
value: smtpShortLogin, value: smtpShortLogin,
inline: true inline: true
} }
@ -151,7 +135,7 @@
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">
<i data-bind="css: {'icon-right': !whiteListPage(), 'icon-left': whiteListPage()}"></i> <i data-bind="css: {'icon-users': !whiteListPage(), 'icon-left': whiteListPage()}"></i>
&nbsp;&nbsp; &nbsp;&nbsp;
<span data-bind="visible: !whiteListPage()">White List</span> <span data-bind="visible: !whiteListPage()">White List</span>
<span data-bind="visible: whiteListPage()">Back</span> <span data-bind="visible: whiteListPage()">Back</span>