mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-09 06:28:28 +03:00
Code refactoring
This commit is contained in:
parent
78ce33e77c
commit
2545ce3cd9
17 changed files with 946 additions and 1034 deletions
|
|
@ -92,7 +92,7 @@
|
|||
sString = Utils.trim(sString);
|
||||
|
||||
var
|
||||
mRegex = /(?:"([^"]+)")? ?<?(.*?@[^>,]+)>?,? ?/g,
|
||||
mRegex = /(?:"([^"]+)")? ?[<]?(.*?@[^>,]+)>?,? ?/g,
|
||||
mMatch = mRegex.exec(sString)
|
||||
;
|
||||
|
||||
|
|
|
|||
|
|
@ -210,8 +210,8 @@
|
|||
};
|
||||
|
||||
RemoteAdminStorage.prototype.createOrUpdateDomain = function (fCallback,
|
||||
bCreate, sName, sIncHost, iIncPort, sIncSecure, bIncVerifySsl, bIncShortLogin,
|
||||
sOutHost, iOutPort, sOutSecure, bOutShortLogin, bOutVerifySsl, bOutAuth, sWhiteList)
|
||||
bCreate, sName, sIncHost, iIncPort, sIncSecure, bIncShortLogin,
|
||||
sOutHost, iOutPort, sOutSecure, bOutShortLogin, bOutAuth, sWhiteList)
|
||||
{
|
||||
this.defaultRequest(fCallback, 'AdminDomainSave', {
|
||||
'Create': bCreate ? '1' : '0',
|
||||
|
|
@ -219,12 +219,10 @@
|
|||
'IncHost': sIncHost,
|
||||
'IncPort': iIncPort,
|
||||
'IncSecure': sIncSecure,
|
||||
'IncVerifySsl': bIncVerifySsl ? '1' : '0',
|
||||
'IncShortLogin': bIncShortLogin ? '1' : '0',
|
||||
'OutHost': sOutHost,
|
||||
'OutPort': iOutPort,
|
||||
'OutSecure': sOutSecure,
|
||||
'OutVerifySsl': bOutVerifySsl ? '1' : '0',
|
||||
'OutShortLogin': bOutShortLogin ? '1' : '0',
|
||||
'OutAuth': bOutAuth ? '1' : '0',
|
||||
'WhiteList': sWhiteList
|
||||
|
|
@ -232,19 +230,16 @@
|
|||
};
|
||||
|
||||
RemoteAdminStorage.prototype.testConnectionForDomain = function (fCallback, sName,
|
||||
sIncHost, iIncPort, sIncSecure, bIncVerifySsl,
|
||||
sOutHost, iOutPort, sOutSecure, bOutVerifySsl, bOutAuth)
|
||||
sIncHost, iIncPort, sIncSecure, sOutHost, iOutPort, sOutSecure, bOutAuth)
|
||||
{
|
||||
this.defaultRequest(fCallback, 'AdminDomainTest', {
|
||||
'Name': sName,
|
||||
'IncHost': sIncHost,
|
||||
'IncPort': iIncPort,
|
||||
'IncSecure': sIncSecure,
|
||||
'IncVerifySsl': bIncVerifySsl ? '1' : '0',
|
||||
'OutHost': sOutHost,
|
||||
'OutPort': iOutPort,
|
||||
'OutSecure': sOutSecure,
|
||||
'OutVerifySsl': bOutVerifySsl ? '1' : '0',
|
||||
'OutAuth': bOutAuth ? '1' : '0'
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -63,12 +63,10 @@
|
|||
this.imapServer = ko.observable('');
|
||||
this.imapPort = ko.observable('' + Consts.Values.ImapDefaulPort);
|
||||
this.imapSecure = ko.observable(Enums.ServerSecure.None);
|
||||
this.imapVerifySsl = ko.observable(false);
|
||||
this.imapShortLogin = ko.observable(false);
|
||||
this.smtpServer = ko.observable('');
|
||||
this.smtpPort = ko.observable('' + Consts.Values.SmtpDefaulPort);
|
||||
this.smtpSecure = ko.observable(Enums.ServerSecure.None);
|
||||
this.smtpVerifySsl = ko.observable(false);
|
||||
this.smtpShortLogin = ko.observable(false);
|
||||
this.smtpAuth = ko.observable(true);
|
||||
this.whiteList = ko.observable('');
|
||||
|
|
@ -106,12 +104,10 @@
|
|||
this.imapServer(),
|
||||
Utils.pInt(this.imapPort()),
|
||||
this.imapSecure(),
|
||||
this.imapVerifySsl(),
|
||||
this.imapShortLogin(),
|
||||
this.smtpServer(),
|
||||
Utils.pInt(this.smtpPort()),
|
||||
this.smtpSecure(),
|
||||
this.smtpVerifySsl(),
|
||||
this.smtpShortLogin(),
|
||||
this.smtpAuth(),
|
||||
this.whiteList()
|
||||
|
|
@ -130,11 +126,9 @@
|
|||
this.imapServer(),
|
||||
Utils.pInt(this.imapPort()),
|
||||
this.imapSecure(),
|
||||
this.imapVerifySsl(),
|
||||
this.smtpServer(),
|
||||
Utils.pInt(this.smtpPort()),
|
||||
this.smtpSecure(),
|
||||
this.smtpVerifySsl(),
|
||||
this.smtpAuth()
|
||||
);
|
||||
}, this.canBeTested);
|
||||
|
|
@ -289,12 +283,10 @@
|
|||
this.imapServer(Utils.trim(oDomain.IncHost));
|
||||
this.imapPort('' + Utils.pInt(oDomain.IncPort));
|
||||
this.imapSecure(Utils.trim(oDomain.IncSecure));
|
||||
this.imapVerifySsl(!!oDomain.IncVerifySsl);
|
||||
this.imapShortLogin(!!oDomain.IncShortLogin);
|
||||
this.smtpServer(Utils.trim(oDomain.OutHost));
|
||||
this.smtpPort('' + Utils.pInt(oDomain.OutPort));
|
||||
this.smtpSecure(Utils.trim(oDomain.OutSecure));
|
||||
this.smtpVerifySsl(!!oDomain.OutVerifySsl);
|
||||
this.smtpShortLogin(!!oDomain.OutShortLogin);
|
||||
this.smtpAuth(!!oDomain.OutAuth);
|
||||
this.whiteList(Utils.trim(oDomain.WhiteList));
|
||||
|
|
@ -325,12 +317,10 @@
|
|||
this.imapServer('');
|
||||
this.imapPort('' + Consts.Values.ImapDefaulPort);
|
||||
this.imapSecure(Enums.ServerSecure.None);
|
||||
this.imapVerifySsl(false);
|
||||
this.imapShortLogin(false);
|
||||
this.smtpServer('');
|
||||
this.smtpPort('' + Consts.Values.SmtpDefaulPort);
|
||||
this.smtpSecure(Enums.ServerSecure.None);
|
||||
this.smtpVerifySsl(false);
|
||||
this.smtpShortLogin(false);
|
||||
this.smtpAuth(true);
|
||||
this.whiteList('');
|
||||
|
|
|
|||
|
|
@ -189,7 +189,8 @@
|
|||
this.facebookCommand = Utils.createCommand(this, function () {
|
||||
|
||||
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;
|
||||
|
||||
}, function () {
|
||||
|
|
@ -201,7 +202,8 @@
|
|||
this.googleCommand = Utils.createCommand(this, function () {
|
||||
|
||||
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;
|
||||
|
||||
}, function () {
|
||||
|
|
@ -213,7 +215,7 @@
|
|||
this.twitterCommand = Utils.createCommand(this, function () {
|
||||
|
||||
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;
|
||||
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ var
|
|||
rename = require('gulp-rename'),
|
||||
replace = require('gulp-replace'),
|
||||
uglify = require('gulp-uglify'),
|
||||
plumber = require('gulp-plumber'),
|
||||
gutil = require('gulp-util')
|
||||
;
|
||||
|
||||
|
|
@ -191,11 +192,12 @@ gulp.task('css:main', ['less:main'], function() {
|
|||
|
||||
var
|
||||
// csslint = require('gulp-csslint'),
|
||||
csscomb = require('gulp-csscomb'),
|
||||
// csscomb = require('gulp-csscomb'),
|
||||
autoprefixer = require('gulp-autoprefixer')
|
||||
;
|
||||
|
||||
return gulp.src(cfg.paths.css.main.src)
|
||||
.pipe(plumber())
|
||||
.pipe(concat(cfg.paths.css.main.name))
|
||||
.pipe(autoprefixer('last 3 versions', '> 1%', 'ie 9', 'Firefox ESR', 'Opera 12.1'))
|
||||
// .pipe(csscomb())
|
||||
|
|
@ -209,6 +211,7 @@ gulp.task('css:main', ['less:main'], function() {
|
|||
gulp.task('css:main:min', ['css:main'], function() {
|
||||
var minifyCss = require('gulp-minify-css');
|
||||
return gulp.src(cfg.paths.staticCSS + cfg.paths.css.main.name)
|
||||
.pipe(plumber())
|
||||
.pipe(minifyCss({
|
||||
'keepSpecialComments': 0
|
||||
}))
|
||||
|
|
|
|||
|
|
@ -64,6 +64,7 @@
|
|||
"gulp-closure-compiler": "*",
|
||||
"gulp-csslint": "*",
|
||||
"gulp-beautify": "*",
|
||||
"gulp-plumber": "*",
|
||||
"gulp-concat-util": "*"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,457 +2,5 @@
|
|||
|
||||
namespace RainLoop;
|
||||
|
||||
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\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;
|
||||
}
|
||||
}
|
||||
// for backward compatibility
|
||||
class Account extends \RainLoop\Model\Account {}
|
||||
|
|
|
|||
|
|
@ -869,7 +869,7 @@ class Actions
|
|||
if (0 < \strlen($sEmail) && 0 < \strlen($sLogin) && 0 < \strlen($sPassword))
|
||||
{
|
||||
$oDomain = $this->DomainProvider()->Load(\MailSo\Base\Utils::GetDomainFromEmail($sEmail), true);
|
||||
if ($oDomain instanceof \RainLoop\Domain)
|
||||
if ($oDomain instanceof \RainLoop\Model\Domain)
|
||||
{
|
||||
if ($oDomain->ValidateWhiteList($sEmail, $sLogin))
|
||||
{
|
||||
|
|
@ -1529,7 +1529,7 @@ class Actions
|
|||
$sLine = \trim(\implode('.', $aDomainParts), '. ');
|
||||
|
||||
$oDomain = $oDomainProvider->Load($sLine);
|
||||
if ($oDomain && $oDomain instanceof \RainLoop\Domain)
|
||||
if ($oDomain && $oDomain instanceof \RainLoop\Model\Domain)
|
||||
{
|
||||
$bAdded = true;
|
||||
$this->Logger()->Write('Check "'.$sLine.'": OK ('.$sEmail.' > '.$sEmail.'@'.$sLine.')',
|
||||
|
|
@ -2950,7 +2950,7 @@ class Actions
|
|||
$oDomain = $this->DomainProvider()->LoadOrCreateNewFromAction($this);
|
||||
|
||||
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);
|
||||
|
||||
$iTime = \microtime(true);
|
||||
$oImapClient->Connect($oDomain->IncHost($oDomain->Name()), $oDomain->IncPort(),
|
||||
$oDomain->IncSecure(), $oDomain->IncVerifySsl(!!$this->Config()->Get('ssl', 'verify_certificate')));
|
||||
$oImapClient->Connect($oDomain->IncHost(), $oDomain->IncPort(),
|
||||
$oDomain->IncSecure(), !!$this->Config()->Get('ssl', 'verify_certificate'));
|
||||
|
||||
$iImapTime = \microtime(true) - $iTime;
|
||||
$oImapClient->Disconnect();
|
||||
|
|
@ -3005,8 +3005,8 @@ class Actions
|
|||
$oSmtpClient->SetTimeOuts(5);
|
||||
|
||||
$iTime = \microtime(true);
|
||||
$oSmtpClient->Connect($oDomain->OutHost($oDomain->Name()), $oDomain->OutPort(), '127.0.0.1',
|
||||
$oDomain->OutSecure(), $oDomain->OutVerifySsl(!!$this->Config()->Get('ssl', 'verify_certificate')));
|
||||
$oSmtpClient->Connect($oDomain->OutHost(), $oDomain->OutPort(), '127.0.0.1',
|
||||
$oDomain->OutSecure(), !!$this->Config()->Get('ssl', 'verify_certificate'));
|
||||
|
||||
$iSmtpTime = \microtime(true) - $iTime;
|
||||
$oSmtpClient->Disconnect();
|
||||
|
|
@ -3422,11 +3422,10 @@ class Actions
|
|||
{
|
||||
$this->Logger()->Write('Versions GC: Begin');
|
||||
|
||||
$iLimitToDelete = 3;
|
||||
|
||||
$sVPath = APP_INDEX_ROOT_PATH.'rainloop/v/';
|
||||
$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))
|
||||
{
|
||||
\uasort($aDirs, 'version_compare');
|
||||
|
|
@ -3439,12 +3438,7 @@ class Actions
|
|||
@\MailSo\Base\Utils::RecRmDir($sVPath.$sName);
|
||||
$this->Logger()->Write('Versions GC: End to remove "'.$sVPath.$sName.'" version');
|
||||
|
||||
$iLimitToDelete--;
|
||||
|
||||
if (0 > $iLimitToDelete)
|
||||
{
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
438
rainloop/v/0.0.0/app/src/RainLoop/Model/Account.php
Normal file
438
rainloop/v/0.0.0/app/src/RainLoop/Model/Account.php
Normal 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;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace RainLoop;
|
||||
namespace RainLoop\Model;
|
||||
|
||||
use MailSo\Net\Enumerations\ConnectionSecurityType;
|
||||
|
||||
|
|
@ -28,11 +28,6 @@ class Domain
|
|||
*/
|
||||
private $iIncSecure;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $bIncVerifySsl;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
|
|
@ -53,11 +48,6 @@ class Domain
|
|||
*/
|
||||
private $iOutSecure;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $bOutVerifySsl;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
|
|
@ -78,29 +68,25 @@ class Domain
|
|||
* @param string $sIncHost
|
||||
* @param int $iIncPort
|
||||
* @param int $iIncSecure
|
||||
* @param bool $bIncVerifySsl
|
||||
* @param bool $bIncShortLogin
|
||||
* @param string $sOutHost
|
||||
* @param int $iOutPort
|
||||
* @param int $iOutSecure
|
||||
* @param bool $bOutVerifySsl
|
||||
* @param bool $bOutShortLogin
|
||||
* @param bool $bOutAuth
|
||||
* @param string $sWhiteList = ''
|
||||
*/
|
||||
private function __construct($sName, $sIncHost, $iIncPort, $iIncSecure, $bIncVerifySsl, $bIncShortLogin,
|
||||
$sOutHost, $iOutPort, $iOutSecure, $bOutVerifySsl, $bOutShortLogin, $bOutAuth, $sWhiteList = '')
|
||||
private function __construct($sName, $sIncHost, $iIncPort, $iIncSecure, $bIncShortLogin,
|
||||
$sOutHost, $iOutPort, $iOutSecure, $bOutShortLogin, $bOutAuth, $sWhiteList = '')
|
||||
{
|
||||
$this->sName = $sName;
|
||||
$this->sIncHost = $sIncHost;
|
||||
$this->iIncPort = $iIncPort;
|
||||
$this->iIncSecure = $iIncSecure;
|
||||
$this->bIncVerifySsl = !!$bIncVerifySsl;
|
||||
$this->bIncShortLogin = $bIncShortLogin;
|
||||
$this->sOutHost = $sOutHost;
|
||||
$this->iOutPort = $iOutPort;
|
||||
$this->iOutSecure = $iOutSecure;
|
||||
$this->bOutVerifySsl = !!$bOutVerifySsl;
|
||||
$this->bOutShortLogin = $bOutShortLogin;
|
||||
$this->bOutAuth = $bOutAuth;
|
||||
$this->sWhiteList = \trim($sWhiteList);
|
||||
|
|
@ -111,26 +97,24 @@ class Domain
|
|||
* @param string $sIncHost
|
||||
* @param int $iIncPort
|
||||
* @param int $iIncSecure
|
||||
* @param bool $bIncVerifySsl
|
||||
* @param bool $bIncShortLogin
|
||||
* @param string $sOutHost
|
||||
* @param int $iOutPort
|
||||
* @param int $iOutSecure
|
||||
* @param bool $bOutVerifySsl
|
||||
* @param bool $bOutShortLogin
|
||||
* @param bool $bOutAuth
|
||||
* @param string $sWhiteList = ''
|
||||
*
|
||||
* @return \RainLoop\Domain
|
||||
* @return \RainLoop\Model\Domain
|
||||
*/
|
||||
public static function NewInstance($sName,
|
||||
$sIncHost, $iIncPort, $iIncSecure, $bIncVerifySsl, $bIncShortLogin,
|
||||
$sOutHost, $iOutPort, $iOutSecure, $bOutVerifySsl, $bOutShortLogin, $bOutAuth,
|
||||
$sIncHost, $iIncPort, $iIncSecure, $bIncShortLogin,
|
||||
$sOutHost, $iOutPort, $iOutSecure, $bOutShortLogin, $bOutAuth,
|
||||
$sWhiteList = '')
|
||||
{
|
||||
return new self($sName,
|
||||
$sIncHost, $iIncPort, $iIncSecure, $bIncVerifySsl, $bIncShortLogin,
|
||||
$sOutHost, $iOutPort, $iOutSecure, $bOutVerifySsl, $bOutShortLogin, $bOutAuth,
|
||||
$sIncHost, $iIncPort, $iIncSecure, $bIncShortLogin,
|
||||
$sOutHost, $iOutPort, $iOutSecure, $bOutShortLogin, $bOutAuth,
|
||||
$sWhiteList);
|
||||
}
|
||||
|
||||
|
|
@ -138,7 +122,7 @@ class Domain
|
|||
* @param string $sName
|
||||
* @param array $aDomain
|
||||
*
|
||||
* @return \RainLoop\Domain|null
|
||||
* @return \RainLoop\Model\Domain|null
|
||||
*/
|
||||
public static function NewInstanceFromDomainConfigArray($sName, $aDomain)
|
||||
{
|
||||
|
|
@ -152,15 +136,11 @@ class Domain
|
|||
$iIncSecure = self::StrConnectionSecurityTypeToCons(
|
||||
!empty($aDomain['imap_secure']) ? $aDomain['imap_secure'] : '');
|
||||
|
||||
$bIncVerifySsl = isset($aDomain['imap_verify_ssl']) ? (bool) $aDomain['smtp_verify_ssl'] : false;;
|
||||
|
||||
$sOutHost = (string) $aDomain['smtp_host'];
|
||||
$iOutPort = (int) $aDomain['smtp_port'];
|
||||
$iOutSecure = self::StrConnectionSecurityTypeToCons(
|
||||
!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;
|
||||
$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;
|
||||
|
||||
$oDomain = self::NewInstance($sName,
|
||||
$sIncHost, $iIncPort, $iIncSecure, $bIncVerifySsl, $bIncShortLogin,
|
||||
$sOutHost, $iOutPort, $iOutSecure, $bOutVerifySsl, $bOutShortLogin, $bOutAuth,
|
||||
$sIncHost, $iIncPort, $iIncSecure, $bIncShortLogin,
|
||||
$sOutHost, $iOutPort, $iOutSecure, $bOutShortLogin, $bOutAuth,
|
||||
$sWhiteList);
|
||||
}
|
||||
|
||||
|
|
@ -213,12 +193,10 @@ class Domain
|
|||
'imap_host = "'.$this->encodeIniString($this->sIncHost).'"',
|
||||
'imap_port = '.$this->iIncPort,
|
||||
'imap_secure = "'.self::ConstConnectionSecurityTypeToStr($this->iIncSecure).'"',
|
||||
'imap_verify_ssl = '.($this->bIncVerifySsl ? 'On' : 'Off'),
|
||||
'imap_short_login = '.($this->bIncShortLogin ? 'On' : 'Off'),
|
||||
'smtp_host = "'.$this->encodeIniString($this->sOutHost).'"',
|
||||
'smtp_port = '.$this->iOutPort,
|
||||
'smtp_secure = "'.self::ConstConnectionSecurityTypeToStr($this->iOutSecure).'"',
|
||||
'smtp_verify_ssl = '.($this->bOutVerifySsl ? 'On' : 'Off'),
|
||||
'smtp_short_login = '.($this->bOutShortLogin ? 'On' : 'Off'),
|
||||
'smtp_auth = '.($this->bOutAuth ? 'On' : 'Off'),
|
||||
'white_list = "'.$this->encodeIniString($this->sWhiteList).'"'
|
||||
|
|
@ -270,32 +248,28 @@ class Domain
|
|||
* @param string $sIncHost
|
||||
* @param int $iIncPort
|
||||
* @param int $iIncSecure
|
||||
* @param bool $bIncVerifySsl
|
||||
* @param bool $bIncShortLogin
|
||||
* @param string $sOutHost
|
||||
* @param int $iOutPort
|
||||
* @param int $iOutSecure
|
||||
* @param bool $bOutVerifySsl
|
||||
* @param bool $bOutShortLogin
|
||||
* @param bool $bOutAuth
|
||||
* @param string $sWhiteList = ''
|
||||
*
|
||||
* @return \RainLoop\Domain
|
||||
* @return \RainLoop\Model\Domain
|
||||
*/
|
||||
public function UpdateInstance(
|
||||
$sIncHost, $iIncPort, $iIncSecure, $bIncVerifySsl, $bIncShortLogin,
|
||||
$sOutHost, $iOutPort, $iOutSecure, $bOutVerifySsl, $bOutShortLogin, $bOutAuth,
|
||||
$sIncHost, $iIncPort, $iIncSecure, $bIncShortLogin,
|
||||
$sOutHost, $iOutPort, $iOutSecure, $bOutShortLogin, $bOutAuth,
|
||||
$sWhiteList = '')
|
||||
{
|
||||
$this->sIncHost = \MailSo\Base\Utils::IdnToAscii($sIncHost);
|
||||
$this->iIncPort = $iIncPort;
|
||||
$this->iIncSecure = $iIncSecure;
|
||||
$this->bIncVerifySsl = !!$bIncVerifySsl;
|
||||
$this->bIncShortLogin = $bIncShortLogin;
|
||||
$this->sOutHost = \MailSo\Base\Utils::IdnToAscii($sOutHost);
|
||||
$this->iOutPort = $iOutPort;
|
||||
$this->iOutSecure = $iOutSecure;
|
||||
$this->bOutVerifySsl = !!$bOutVerifySsl;
|
||||
$this->bOutShortLogin = $bOutShortLogin;
|
||||
$this->bOutAuth = $bOutAuth;
|
||||
$this->sWhiteList = \trim($sWhiteList);
|
||||
|
|
@ -312,13 +286,11 @@ class Domain
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $sRealDomainName = ''
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool|null $bGlobalVerify = null
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function IncVerifySsl($bGlobalVerify = null)
|
||||
{
|
||||
return null === $bGlobalVerify ? $this->bIncVerifySsl : !!$bGlobalVerify;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
|
|
@ -356,12 +318,11 @@ class Domain
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $sRealDomainName = ''
|
||||
* @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(),
|
||||
'IncPort' => $this->IncPort(),
|
||||
'IncSecure' => $this->IncSecure(),
|
||||
'IncVerifySsl' => $this->IncVerifySsl(),
|
||||
'IncShortLogin' => $this->IncShortLogin(),
|
||||
'OutHost' => $bAjax ? \MailSo\Base\Utils::IdnToUtf8($this->OutHost()) : $this->OutHost(),
|
||||
'OutPort' => $this->OutPort(),
|
||||
'OutSecure' => $this->OutSecure(),
|
||||
'OutVerifySsl' => $this->OutVerifySsl(),
|
||||
'OutShortLogin' => $this->OutShortLogin(),
|
||||
'OutAuth' => $this->OutAuth(),
|
||||
'WhiteList' => $this->WhiteList()
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace RainLoop;
|
||||
namespace RainLoop\Model;
|
||||
|
||||
class Identity
|
||||
{
|
||||
|
|
@ -54,7 +54,7 @@ class Identity
|
|||
* @param string $sReplyTo = ''
|
||||
* @param string $sBcc = ''
|
||||
*
|
||||
* @return \RainLoop\Identity
|
||||
* @return \RainLoop\Model\Identity
|
||||
*/
|
||||
public static function NewInstance($sId, $sEmail, $sName = '', $sReplyTo = '', $sBcc = '')
|
||||
{
|
||||
|
|
@ -72,12 +72,12 @@ class Identity
|
|||
/**
|
||||
* @param string $sId
|
||||
*
|
||||
* @return \RainLoop\Identity
|
||||
* @return \RainLoop\Model\Identity
|
||||
*/
|
||||
public function SetId($sId)
|
||||
{
|
||||
$this->sId = $sId;
|
||||
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
@ -92,7 +92,7 @@ class Identity
|
|||
/**
|
||||
* @param string $sEmail
|
||||
*
|
||||
* @return \RainLoop\Identity
|
||||
* @return \RainLoop\Model\Identity
|
||||
*/
|
||||
public function SetEmail($sEmail)
|
||||
{
|
||||
|
|
@ -112,7 +112,7 @@ class Identity
|
|||
/**
|
||||
* @param string $sName
|
||||
*
|
||||
* @return \RainLoop\Identity
|
||||
* @return \RainLoop\Model\Identity
|
||||
*/
|
||||
public function SetName($sName)
|
||||
{
|
||||
|
|
@ -132,7 +132,7 @@ class Identity
|
|||
/**
|
||||
* @param string $sReplyTo
|
||||
*
|
||||
* @return \RainLoop\Identity
|
||||
* @return \RainLoop\Model\Identity
|
||||
*/
|
||||
public function SetReplyTo($sReplyTo)
|
||||
{
|
||||
|
|
@ -152,7 +152,7 @@ class Identity
|
|||
/**
|
||||
* @param string $sBcc
|
||||
*
|
||||
* @return \RainLoop\Identity
|
||||
* @return \RainLoop\Model\Identity
|
||||
*/
|
||||
public function SetBcc($sBcc)
|
||||
{
|
||||
|
|
@ -163,7 +163,7 @@ class Identity
|
|||
|
||||
/**
|
||||
* @param bool $bAjax = false
|
||||
*
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function ToSimpleJSON($bAjax = false)
|
||||
|
|
@ -45,12 +45,12 @@ class Domain extends \RainLoop\Providers\AbstractProvider
|
|||
* @param bool $bFindWithWildCard = false
|
||||
* @param bool $bCheckDisabled = true
|
||||
*
|
||||
* @return \RainLoop\Domain|null
|
||||
* @return \RainLoop\Model\Domain|null
|
||||
*/
|
||||
public function Load($sName, $bFindWithWildCard = false, $bCheckDisabled = true)
|
||||
{
|
||||
$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));
|
||||
}
|
||||
|
|
@ -59,11 +59,11 @@ class Domain extends \RainLoop\Providers\AbstractProvider
|
|||
}
|
||||
|
||||
/**
|
||||
* @param \RainLoop\Domain $oDomain
|
||||
* @param \RainLoop\Model\Domain $oDomain
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function Save(\RainLoop\Domain $oDomain)
|
||||
public function Save(\RainLoop\Model\Domain $oDomain)
|
||||
{
|
||||
return $this->bAdmin ? $this->oDriver->Save($oDomain) : false;
|
||||
}
|
||||
|
|
@ -115,7 +115,7 @@ class Domain extends \RainLoop\Providers\AbstractProvider
|
|||
* @param \RainLoop\Actions $oActions
|
||||
* @param string $sNameForTest = ''
|
||||
*
|
||||
* @return \RainLoop\Domain | null
|
||||
* @return \RainLoop\Model\Domain | null
|
||||
*/
|
||||
public function LoadOrCreateNewFromAction(\RainLoop\Actions $oActions, $sNameForTest = '')
|
||||
{
|
||||
|
|
@ -128,12 +128,10 @@ class Domain extends \RainLoop\Providers\AbstractProvider
|
|||
$sIncHost = (string) $oActions->GetActionParam('IncHost', '');
|
||||
$iIncPort = (int) $oActions->GetActionParam('IncPort', 143);
|
||||
$iIncSecure = (int) $oActions->GetActionParam('IncSecure', \MailSo\Net\Enumerations\ConnectionSecurityType::NONE);
|
||||
$bIncVerifySsl = '1' === (string) $oActions->GetActionParam('IncVerifySsl', '0');
|
||||
$bIncShortLogin = '1' === (string) $oActions->GetActionParam('IncShortLogin', '0');
|
||||
$sOutHost = (string) $oActions->GetActionParam('OutHost', '');
|
||||
$iOutPort = (int) $oActions->GetActionParam('OutPort', 25);
|
||||
$iOutSecure = (int) $oActions->GetActionParam('OutSecure', \MailSo\Net\Enumerations\ConnectionSecurityType::NONE);
|
||||
$bOutVerifySsl = '1' === (string) $oActions->GetActionParam('OutVerifySsl', '0');
|
||||
$bOutShortLogin = '1' === (string) $oActions->GetActionParam('OutShortLogin', '0');
|
||||
$bOutAuth = '1' === (string) $oActions->GetActionParam('OutAuth', '1');
|
||||
$sWhiteList = (string) $oActions->GetActionParam('WhiteList', '');
|
||||
|
|
@ -146,7 +144,7 @@ class Domain extends \RainLoop\Providers\AbstractProvider
|
|||
if (0 < strlen($sName) || 0 < strlen($sNameForTest))
|
||||
{
|
||||
$oDomain = 0 < strlen($sNameForTest) ? null : $this->Load($sName);
|
||||
if ($oDomain instanceof \RainLoop\Domain)
|
||||
if ($oDomain instanceof \RainLoop\Model\Domain)
|
||||
{
|
||||
if ($bCreate)
|
||||
{
|
||||
|
|
@ -155,16 +153,16 @@ class Domain extends \RainLoop\Providers\AbstractProvider
|
|||
else
|
||||
{
|
||||
$oDomain->UpdateInstance(
|
||||
$sIncHost, $iIncPort, $iIncSecure, $bIncVerifySsl, $bIncShortLogin,
|
||||
$sOutHost, $iOutPort, $iOutSecure, $bOutVerifySsl, $bOutShortLogin, $bOutAuth,
|
||||
$sIncHost, $iIncPort, $iIncSecure, $bIncShortLogin,
|
||||
$sOutHost, $iOutPort, $iOutSecure, $bOutShortLogin, $bOutAuth,
|
||||
$sWhiteList);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$oDomain = \RainLoop\Domain::NewInstance(0 < strlen($sNameForTest) ? $sNameForTest : $sName,
|
||||
$sIncHost, $iIncPort, $iIncSecure, $bIncVerifySsl, $bIncShortLogin,
|
||||
$sOutHost, $iOutPort, $iOutSecure, $bOutVerifySsl, $bOutShortLogin, $bOutAuth,
|
||||
$oDomain = \RainLoop\Model\Domain::NewInstance(0 < strlen($sNameForTest) ? $sNameForTest : $sName,
|
||||
$sIncHost, $iIncPort, $iIncSecure, $bIncShortLogin,
|
||||
$sOutHost, $iOutPort, $iOutSecure, $bOutShortLogin, $bOutAuth,
|
||||
$sWhiteList);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -147,7 +147,7 @@ class DefaultDomain implements \RainLoop\Providers\Domain\DomainAdminInterface
|
|||
* @param bool $bFindWithWildCard = false
|
||||
* @param bool $bCheckDisabled = true
|
||||
*
|
||||
* @return \RainLoop\Domain|null
|
||||
* @return \RainLoop\Model\Domain|null
|
||||
*/
|
||||
public function Load($sName, $bFindWithWildCard = false, $bCheckDisabled = true)
|
||||
{
|
||||
|
|
@ -155,14 +155,14 @@ class DefaultDomain implements \RainLoop\Providers\Domain\DomainAdminInterface
|
|||
|
||||
$sDisabled = '';
|
||||
$sFoundedValue = '';
|
||||
|
||||
|
||||
$sRealFileName = $this->codeFileName($sName);
|
||||
|
||||
if (\file_exists($this->sDomainPath.'/disabled'))
|
||||
{
|
||||
$sDisabled = @\file_get_contents($this->sDomainPath.'/disabled');
|
||||
}
|
||||
|
||||
|
||||
if (\file_exists($this->sDomainPath.'/'.$sRealFileName.'.ini') &&
|
||||
(!$bCheckDisabled || 0 === \strlen($sDisabled) || false === \strpos(','.$sDisabled.',', ','.\MailSo\Base\Utils::IdnToAscii($sName, 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)
|
||||
{
|
||||
|
|
@ -214,11 +214,11 @@ class DefaultDomain implements \RainLoop\Providers\Domain\DomainAdminInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* @param \RainLoop\Domain $oDomain
|
||||
* @param \RainLoop\Model\Domain $oDomain
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function Save(\RainLoop\Domain $oDomain)
|
||||
public function Save(\RainLoop\Model\Domain $oDomain)
|
||||
{
|
||||
$sRealFileName = $this->codeFileName($oDomain->Name());
|
||||
|
||||
|
|
|
|||
|
|
@ -18,16 +18,16 @@ interface DomainAdminInterface extends DomainInterface
|
|||
* @param bool $bFindWithWildCard = false
|
||||
* @param bool $bCheckDisabled = true
|
||||
*
|
||||
* @return \RainLoop\Domain|null
|
||||
* @return \RainLoop\Model\Domain|null
|
||||
*/
|
||||
public function Load($sName, $bFindWithWildCard = false, $bCheckDisabled = true);
|
||||
|
||||
/**
|
||||
* @param \RainLoop\Domain $oDomain
|
||||
* @param \RainLoop\Model\Domain $oDomain
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function Save(\RainLoop\Domain $oDomain);
|
||||
public function Save(\RainLoop\Model\Domain $oDomain);
|
||||
|
||||
/**
|
||||
* @param string $sName
|
||||
|
|
|
|||
|
|
@ -6,16 +6,16 @@
|
|||
</div>
|
||||
<div class="modal-body">
|
||||
<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">
|
||||
Name <span style="color: #aaa">(wildcard supported)</span>
|
||||
<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" />
|
||||
|
||||
<span class="error-desc" data-bind="text: savingError"></span>
|
||||
</div>
|
||||
</div>
|
||||
<br />
|
||||
<div class="row">
|
||||
<div class="span5" data-bind="css: { 'testing-done': testingDone, 'testing-error': testingImapError }">
|
||||
<div class="legend imap-header">
|
||||
|
|
@ -47,21 +47,13 @@
|
|||
<option value="1">SSL/TLS</option>
|
||||
<option value="2">STARTTLS</option>
|
||||
</select>
|
||||
|
||||
<div data-bind="visible: '1' === imapSecure() && false, component: {
|
||||
name: 'Checkbox',
|
||||
params: {
|
||||
label: 'Verify ssl certificate',
|
||||
value: imapVerifySsl
|
||||
}
|
||||
}"></div>
|
||||
</div>
|
||||
</div>
|
||||
<br />
|
||||
<div data-bind="component: {
|
||||
name: 'Checkbox',
|
||||
params: {
|
||||
label: 'Use short login form',
|
||||
label: 'Use short login',
|
||||
value: imapShortLogin,
|
||||
inline: true
|
||||
}
|
||||
|
|
@ -99,21 +91,13 @@
|
|||
<option value="1">SSL/TLS</option>
|
||||
<option value="2">STARTTLS</option>
|
||||
</select>
|
||||
|
||||
<div data-bind="visible: '1' === smtpSecure() && false, component: {
|
||||
name: 'Checkbox',
|
||||
params: {
|
||||
label: 'Verify ssl certificate',
|
||||
value: smtpVerifySsl
|
||||
}
|
||||
}"></div>
|
||||
</div>
|
||||
</div>
|
||||
<br />
|
||||
<div data-bind="component: {
|
||||
name: 'Checkbox',
|
||||
params: {
|
||||
label: 'Use short login form',
|
||||
label: 'Use short login',
|
||||
value: smtpShortLogin,
|
||||
inline: true
|
||||
}
|
||||
|
|
@ -151,7 +135,7 @@
|
|||
Test
|
||||
</a>
|
||||
<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>
|
||||
|
||||
<span data-bind="visible: !whiteListPage()">White List</span>
|
||||
<span data-bind="visible: whiteListPage()">Back</span>
|
||||
|
|
|
|||
858
vendors/jua/_/jua.js
vendored
858
vendors/jua/_/jua.js
vendored
|
|
@ -1,435 +1,435 @@
|
|||
(function(){function a(a){function l(){if(g&&d<a){var b=g,c=b[0],f=Array.prototype.slice.call(b,1),m=b.index;g===h?g=h=null:g=g.next,++d,f.push(function(a,b){--d;if(i)return;a?e&&k(i=a,e=j=g=h=null):(j[m]=b,--e?l():k(null,j))}),c.apply(null,f)}}var c={},d=0,e=0,f=-1,g,h,i=null,j=[],k=b;return arguments.length<1&&(a=Infinity),c.defer=function(){if(!i){var a=arguments;a.index=++f,h?(h.next=a,h=h.next):g=h=a,++e,l()}return c},c.await=function(a){return k=a,e||k(i,j),c},c}function b(){}typeof module=="undefined"?self.queue=a:module.exports=a,a.version="0.0.2"})();(function ($, window, queue) {
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* @param {*} mValue
|
||||
* @return {boolean}
|
||||
*/
|
||||
function isUndefined(mValue)
|
||||
{
|
||||
return 'undefined' === typeof mValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Object} mObjectFirst
|
||||
* @param {Object=} mObjectSecond
|
||||
* @return {Object}
|
||||
*/
|
||||
function extend(mObjectFirst, mObjectSecond)
|
||||
{
|
||||
if (mObjectSecond)
|
||||
{
|
||||
for (var sProp in mObjectSecond)
|
||||
{
|
||||
if (mObjectSecond.hasOwnProperty(sProp))
|
||||
{
|
||||
mObjectFirst[sProp] = mObjectSecond[sProp];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return mObjectFirst;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {*} oParent
|
||||
* @param {*} oDescendant
|
||||
*
|
||||
* @return {boolean}
|
||||
*/
|
||||
function contains(oParent, oDescendant)
|
||||
{
|
||||
var bResult = false;
|
||||
if (oParent && oDescendant)
|
||||
{
|
||||
if (oParent === oDescendant)
|
||||
{
|
||||
bResult = true;
|
||||
}
|
||||
else if (oParent.contains)
|
||||
{
|
||||
bResult = oParent.contains(oDescendant);
|
||||
}
|
||||
else
|
||||
{
|
||||
/*jshint bitwise: false*/
|
||||
bResult = oDescendant.compareDocumentPosition ?
|
||||
!!(oDescendant.compareDocumentPosition(oParent) & 8) : false;
|
||||
/*jshint bitwise: true*/
|
||||
}
|
||||
}
|
||||
|
||||
return bResult;
|
||||
}
|
||||
|
||||
function mainClearTimeout(iTimer)
|
||||
{
|
||||
if (0 < iTimer)
|
||||
{
|
||||
clearTimeout(iTimer);
|
||||
}
|
||||
|
||||
iTimer = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Event} oEvent
|
||||
* @return {?Event}
|
||||
*/
|
||||
function getEvent(oEvent)
|
||||
{
|
||||
oEvent = (oEvent && (oEvent.originalEvent ?
|
||||
oEvent.originalEvent : oEvent)) || window.event;
|
||||
|
||||
return oEvent.dataTransfer ? oEvent : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Object} oValues
|
||||
* @param {string} sKey
|
||||
* @param {?} mDefault
|
||||
* @return {?}
|
||||
*/
|
||||
function getValue(oValues, sKey, mDefault)
|
||||
{
|
||||
return (!oValues || !sKey || isUndefined(oValues[sKey])) ? mDefault : oValues[sKey];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Object} oOwner
|
||||
* @param {string} sPublicName
|
||||
* @param {*} mObject
|
||||
*/
|
||||
function setValue(oOwner, sPublicName, mObject)
|
||||
{
|
||||
oOwner[sPublicName] = mObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {*} aData
|
||||
* @return {boolean}
|
||||
*/
|
||||
function isNonEmptyArray(aData)
|
||||
{
|
||||
return aData && aData.length && 0 < aData.length ? true : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {*} mValue
|
||||
* @return {number}
|
||||
*/
|
||||
function pInt(mValue)
|
||||
{
|
||||
return parseInt(mValue || 0, 10);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Function} fFunction
|
||||
* @param {Object=} oScope
|
||||
* @return {Function}
|
||||
*/
|
||||
function scopeBind(fFunction, oScope)
|
||||
{
|
||||
return function () {
|
||||
return fFunction.apply(isUndefined(oScope) ? null : oScope,
|
||||
Array.prototype.slice.call(arguments));
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {number=} iLen
|
||||
* @return {string}
|
||||
*/
|
||||
function fakeMd5(iLen)
|
||||
{
|
||||
var
|
||||
sResult = '',
|
||||
sLine = '0123456789abcdefghijklmnopqrstuvwxyz'
|
||||
;
|
||||
|
||||
iLen = isUndefined(iLen) ? 32 : pInt(iLen);
|
||||
|
||||
while (sResult.length < iLen)
|
||||
{
|
||||
sResult += sLine.substr(Math.round(Math.random() * sLine.length), 1);
|
||||
}
|
||||
|
||||
return sResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
function getNewUid()
|
||||
{
|
||||
return 'jua-uid-' + fakeMd5(16) + '-' + (new Date()).getTime().toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {*} oFile
|
||||
* @param {string=} sPath
|
||||
* @return {Object}
|
||||
*/
|
||||
function getDataFromFile(oFile, sPath)
|
||||
{
|
||||
var
|
||||
sFileName = isUndefined(oFile.fileName) ? (isUndefined(oFile.name) ? null : oFile.name) : oFile.fileName,
|
||||
iSize = isUndefined(oFile.fileSize) ? (isUndefined(oFile.size) ? null : oFile.size) : oFile.fileSize,
|
||||
sType = isUndefined(oFile.type) ? null : oFile.type
|
||||
;
|
||||
|
||||
return {
|
||||
'FileName': sFileName,
|
||||
'Size': iSize,
|
||||
'Type': sType,
|
||||
'Folder': isUndefined(sPath) ? '' : sPath,
|
||||
'File' : oFile
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {*} aItems
|
||||
* @param {Function} fFileCallback
|
||||
* @param {boolean=} bEntry = false
|
||||
* @param {boolean=} bAllowFolderDragAndDrop = true
|
||||
* @param {number=} iLimit = 20
|
||||
* @param {Function=} fLimitCallback
|
||||
*/
|
||||
function getDataFromFiles(aItems, fFileCallback, bEntry, bAllowFolderDragAndDrop, iLimit, fLimitCallback)
|
||||
{
|
||||
var
|
||||
iInputLimit = 0,
|
||||
iLen = 0,
|
||||
iIndex = 0,
|
||||
oItem = null,
|
||||
oEntry = null,
|
||||
bUseLimit = false,
|
||||
bCallLimit = false,
|
||||
fTraverseFileTree = function (oItem, sPath, fCallback, fLimitCallbackProxy) {
|
||||
|
||||
if (oItem && !isUndefined(oItem['name']))
|
||||
{
|
||||
sPath = sPath || '';
|
||||
if (oItem['isFile'])
|
||||
{
|
||||
oItem.file(function (oFile) {
|
||||
if (!bUseLimit || 0 <= --iLimit)
|
||||
{
|
||||
fCallback(getDataFromFile(oFile, sPath));
|
||||
}
|
||||
else if (bUseLimit && !bCallLimit)
|
||||
{
|
||||
if (0 > iLimit && fLimitCallback)
|
||||
{
|
||||
bCallLimit = true;
|
||||
fLimitCallback(iInputLimit);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
else if (bAllowFolderDragAndDrop && oItem['isDirectory'] && oItem['createReader'])
|
||||
{
|
||||
var
|
||||
oDirReader = oItem['createReader'](),
|
||||
iIndex = 0,
|
||||
iLen = 0
|
||||
;
|
||||
|
||||
if (oDirReader && oDirReader['readEntries'])
|
||||
{
|
||||
oDirReader['readEntries'](function (aEntries) {
|
||||
if (aEntries && isNonEmptyArray(aEntries))
|
||||
{
|
||||
for (iIndex = 0, iLen = aEntries.length; iIndex < iLen; iIndex++)
|
||||
{
|
||||
fTraverseFileTree(aEntries[iIndex], sPath + oItem['name'] + '/', fCallback, fLimitCallbackProxy);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
bAllowFolderDragAndDrop = isUndefined(bAllowFolderDragAndDrop) ? true : !!bAllowFolderDragAndDrop;
|
||||
|
||||
bEntry = isUndefined(bEntry) ? false : !!bEntry;
|
||||
iLimit = isUndefined(iLimit) ? Jua.iDefLimit : pInt(iLimit);
|
||||
iInputLimit = iLimit;
|
||||
bUseLimit = 0 < iLimit;
|
||||
|
||||
aItems = aItems && 0 < aItems.length ? aItems : null;
|
||||
if (aItems)
|
||||
{
|
||||
for (iIndex = 0, iLen = aItems.length; iIndex < iLen; iIndex++)
|
||||
{
|
||||
oItem = aItems[iIndex];
|
||||
if (oItem)
|
||||
{
|
||||
if (bEntry)
|
||||
{
|
||||
if ('file' === oItem['kind'] && oItem['webkitGetAsEntry'])
|
||||
{
|
||||
oEntry = oItem['webkitGetAsEntry']();
|
||||
if (oEntry)
|
||||
{
|
||||
fTraverseFileTree(oEntry, '', fFileCallback, fLimitCallback);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!bUseLimit || 0 <= --iLimit)
|
||||
{
|
||||
fFileCallback(getDataFromFile(oItem));
|
||||
}
|
||||
else if (bUseLimit && !bCallLimit)
|
||||
{
|
||||
if (0 > iLimit && fLimitCallback)
|
||||
{
|
||||
bCallLimit = true;
|
||||
fLimitCallback(iInputLimit);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {*} oInput
|
||||
* @param {Function} fFileCallback
|
||||
* @param {number=} iLimit = 20
|
||||
* @param {Function=} fLimitCallback
|
||||
*/
|
||||
function getDataFromInput(oInput, fFileCallback, iLimit, fLimitCallback)
|
||||
{
|
||||
var aFiles = oInput && oInput.files && 0 < oInput.files.length ? oInput.files : null;
|
||||
if (aFiles)
|
||||
{
|
||||
getDataFromFiles(aFiles, fFileCallback, false, false, iLimit, fLimitCallback);
|
||||
}
|
||||
else
|
||||
{
|
||||
fFileCallback({
|
||||
'FileName': oInput.value.split('\\').pop().split('/').pop(),
|
||||
'Size': null,
|
||||
'Type': null,
|
||||
'Folder': '',
|
||||
'File' : null
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function eventContainsFiles(oEvent)
|
||||
{
|
||||
var bResult = false;
|
||||
if (oEvent && oEvent.dataTransfer && oEvent.dataTransfer.types && oEvent.dataTransfer.types.length)
|
||||
{
|
||||
var
|
||||
iIindex = 0,
|
||||
iLen = oEvent.dataTransfer.types.length
|
||||
;
|
||||
|
||||
for (; iIindex < iLen; iIindex++)
|
||||
{
|
||||
if (oEvent.dataTransfer.types[iIindex].toLowerCase() === 'files')
|
||||
{
|
||||
bResult = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return bResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Event} oEvent
|
||||
* @param {Function} fFileCallback
|
||||
* @param {number=} iLimit = 20
|
||||
* @param {Function=} fLimitCallback
|
||||
* @param {boolean=} bAllowFolderDragAndDrop = true
|
||||
*/
|
||||
function getDataFromDragEvent(oEvent, fFileCallback, iLimit, fLimitCallback, bAllowFolderDragAndDrop)
|
||||
{
|
||||
var
|
||||
aItems = null,
|
||||
aFiles = null
|
||||
;
|
||||
|
||||
oEvent = getEvent(oEvent);
|
||||
if (oEvent)
|
||||
{
|
||||
aItems = (oEvent.dataTransfer ? getValue(oEvent.dataTransfer, 'items', null) : null) || getValue(oEvent, 'items', null);
|
||||
if (aItems && 0 < aItems.length && aItems[0] && aItems[0]['webkitGetAsEntry'])
|
||||
{
|
||||
getDataFromFiles(aItems, fFileCallback, true, bAllowFolderDragAndDrop, iLimit, fLimitCallback);
|
||||
}
|
||||
else if (eventContainsFiles(oEvent))
|
||||
{
|
||||
aFiles = (getValue(oEvent, 'files', null) || (oEvent.dataTransfer ?
|
||||
getValue(oEvent.dataTransfer, 'files', null) : null));
|
||||
|
||||
if (aFiles && 0 < aFiles.length)
|
||||
{
|
||||
getDataFromFiles(aFiles, fFileCallback, false, false, iLimit, fLimitCallback);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function createNextLabel()
|
||||
{
|
||||
return $('<label style="' +
|
||||
'position: absolute; background-color:#fff; right: 0px; top: 0px; left: 0px; bottom: 0px; margin: 0px; padding: 0px; cursor: pointer;' +
|
||||
'"></label>').css({
|
||||
'opacity': 0
|
||||
});
|
||||
}
|
||||
|
||||
function createNextInput()
|
||||
{
|
||||
return $('<input type="file" tabindex="-1" hidefocus="hidefocus" style="position: absolute; left: -9999px;" />');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string=} sName
|
||||
* @param {boolean=} bMultiple = true
|
||||
* @return {?Object}
|
||||
*/
|
||||
function getNewInput(sName, bMultiple)
|
||||
{
|
||||
sName = isUndefined(sName) ? '' : sName.toString();
|
||||
|
||||
var oLocal = createNextInput();
|
||||
if (0 < sName.length)
|
||||
{
|
||||
oLocal.attr('name', sName);
|
||||
}
|
||||
|
||||
if (isUndefined(bMultiple) ? true : bMultiple)
|
||||
{
|
||||
oLocal.prop('multiple', true);
|
||||
}
|
||||
|
||||
return oLocal;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {?} mStringOrFunction
|
||||
* @param {Array=} aFunctionParams
|
||||
* @return {string}
|
||||
*/
|
||||
function getStringOrCallFunction(mStringOrFunction, aFunctionParams)
|
||||
{
|
||||
return $.isFunction(mStringOrFunction) ?
|
||||
mStringOrFunction.apply(null, $.isArray(aFunctionParams) ? aFunctionParams : []).toString() :
|
||||
mStringOrFunction.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {*} mValue
|
||||
* @return {boolean}
|
||||
*/
|
||||
function isUndefined(mValue)
|
||||
{
|
||||
return 'undefined' === typeof mValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Object} mObjectFirst
|
||||
* @param {Object=} mObjectSecond
|
||||
* @return {Object}
|
||||
*/
|
||||
function extend(mObjectFirst, mObjectSecond)
|
||||
{
|
||||
if (mObjectSecond)
|
||||
{
|
||||
for (var sProp in mObjectSecond)
|
||||
{
|
||||
if (mObjectSecond.hasOwnProperty(sProp))
|
||||
{
|
||||
mObjectFirst[sProp] = mObjectSecond[sProp];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return mObjectFirst;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {*} oParent
|
||||
* @param {*} oDescendant
|
||||
*
|
||||
* @return {boolean}
|
||||
*/
|
||||
function contains(oParent, oDescendant)
|
||||
{
|
||||
var bResult = false;
|
||||
if (oParent && oDescendant)
|
||||
{
|
||||
if (oParent === oDescendant)
|
||||
{
|
||||
bResult = true;
|
||||
}
|
||||
else if (oParent.contains)
|
||||
{
|
||||
bResult = oParent.contains(oDescendant);
|
||||
}
|
||||
else
|
||||
{
|
||||
/*jshint bitwise: false*/
|
||||
bResult = oDescendant.compareDocumentPosition ?
|
||||
!!(oDescendant.compareDocumentPosition(oParent) & 8) : false;
|
||||
/*jshint bitwise: true*/
|
||||
}
|
||||
}
|
||||
|
||||
return bResult;
|
||||
}
|
||||
|
||||
function mainClearTimeout(iTimer)
|
||||
{
|
||||
if (0 < iTimer)
|
||||
{
|
||||
clearTimeout(iTimer);
|
||||
}
|
||||
|
||||
iTimer = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Event} oEvent
|
||||
* @return {?Event}
|
||||
*/
|
||||
function getEvent(oEvent)
|
||||
{
|
||||
oEvent = (oEvent && (oEvent.originalEvent ?
|
||||
oEvent.originalEvent : oEvent)) || window.event;
|
||||
|
||||
return oEvent.dataTransfer ? oEvent : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Object} oValues
|
||||
* @param {string} sKey
|
||||
* @param {?} mDefault
|
||||
* @return {?}
|
||||
*/
|
||||
function getValue(oValues, sKey, mDefault)
|
||||
{
|
||||
return (!oValues || !sKey || isUndefined(oValues[sKey])) ? mDefault : oValues[sKey];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Object} oOwner
|
||||
* @param {string} sPublicName
|
||||
* @param {*} mObject
|
||||
*/
|
||||
function setValue(oOwner, sPublicName, mObject)
|
||||
{
|
||||
oOwner[sPublicName] = mObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {*} aData
|
||||
* @return {boolean}
|
||||
*/
|
||||
function isNonEmptyArray(aData)
|
||||
{
|
||||
return aData && aData.length && 0 < aData.length ? true : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {*} mValue
|
||||
* @return {number}
|
||||
*/
|
||||
function pInt(mValue)
|
||||
{
|
||||
return parseInt(mValue || 0, 10);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Function} fFunction
|
||||
* @param {Object=} oScope
|
||||
* @return {Function}
|
||||
*/
|
||||
function scopeBind(fFunction, oScope)
|
||||
{
|
||||
return function () {
|
||||
return fFunction.apply(isUndefined(oScope) ? null : oScope,
|
||||
Array.prototype.slice.call(arguments));
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {number=} iLen
|
||||
* @return {string}
|
||||
*/
|
||||
function fakeMd5(iLen)
|
||||
{
|
||||
var
|
||||
sResult = '',
|
||||
sLine = '0123456789abcdefghijklmnopqrstuvwxyz'
|
||||
;
|
||||
|
||||
iLen = isUndefined(iLen) ? 32 : pInt(iLen);
|
||||
|
||||
while (sResult.length < iLen)
|
||||
{
|
||||
sResult += sLine.substr(Math.round(Math.random() * sLine.length), 1);
|
||||
}
|
||||
|
||||
return sResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
function getNewUid()
|
||||
{
|
||||
return 'jua-uid-' + fakeMd5(16) + '-' + (new Date()).getTime().toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {*} oFile
|
||||
* @param {string=} sPath
|
||||
* @return {Object}
|
||||
*/
|
||||
function getDataFromFile(oFile, sPath)
|
||||
{
|
||||
var
|
||||
sFileName = isUndefined(oFile.fileName) ? (isUndefined(oFile.name) ? null : oFile.name) : oFile.fileName,
|
||||
iSize = isUndefined(oFile.fileSize) ? (isUndefined(oFile.size) ? null : oFile.size) : oFile.fileSize,
|
||||
sType = isUndefined(oFile.type) ? null : oFile.type
|
||||
;
|
||||
|
||||
return {
|
||||
'FileName': sFileName,
|
||||
'Size': iSize,
|
||||
'Type': sType,
|
||||
'Folder': isUndefined(sPath) ? '' : sPath,
|
||||
'File' : oFile
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {*} aItems
|
||||
* @param {Function} fFileCallback
|
||||
* @param {boolean=} bEntry = false
|
||||
* @param {boolean=} bAllowFolderDragAndDrop = true
|
||||
* @param {number=} iLimit = 20
|
||||
* @param {Function=} fLimitCallback
|
||||
*/
|
||||
function getDataFromFiles(aItems, fFileCallback, bEntry, bAllowFolderDragAndDrop, iLimit, fLimitCallback)
|
||||
{
|
||||
var
|
||||
iInputLimit = 0,
|
||||
iLen = 0,
|
||||
iIndex = 0,
|
||||
oItem = null,
|
||||
oEntry = null,
|
||||
bUseLimit = false,
|
||||
bCallLimit = false,
|
||||
fTraverseFileTree = function (oItem, sPath, fCallback, fLimitCallbackProxy) {
|
||||
|
||||
if (oItem && !isUndefined(oItem['name']))
|
||||
{
|
||||
sPath = sPath || '';
|
||||
if (oItem['isFile'])
|
||||
{
|
||||
oItem.file(function (oFile) {
|
||||
if (!bUseLimit || 0 <= --iLimit)
|
||||
{
|
||||
fCallback(getDataFromFile(oFile, sPath));
|
||||
}
|
||||
else if (bUseLimit && !bCallLimit)
|
||||
{
|
||||
if (0 > iLimit && fLimitCallback)
|
||||
{
|
||||
bCallLimit = true;
|
||||
fLimitCallback(iInputLimit);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
else if (bAllowFolderDragAndDrop && oItem['isDirectory'] && oItem['createReader'])
|
||||
{
|
||||
var
|
||||
oDirReader = oItem['createReader'](),
|
||||
iIndex = 0,
|
||||
iLen = 0
|
||||
;
|
||||
|
||||
if (oDirReader && oDirReader['readEntries'])
|
||||
{
|
||||
oDirReader['readEntries'](function (aEntries) {
|
||||
if (aEntries && isNonEmptyArray(aEntries))
|
||||
{
|
||||
for (iIndex = 0, iLen = aEntries.length; iIndex < iLen; iIndex++)
|
||||
{
|
||||
fTraverseFileTree(aEntries[iIndex], sPath + oItem['name'] + '/', fCallback, fLimitCallbackProxy);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
bAllowFolderDragAndDrop = isUndefined(bAllowFolderDragAndDrop) ? true : !!bAllowFolderDragAndDrop;
|
||||
|
||||
bEntry = isUndefined(bEntry) ? false : !!bEntry;
|
||||
iLimit = isUndefined(iLimit) ? Jua.iDefLimit : pInt(iLimit);
|
||||
iInputLimit = iLimit;
|
||||
bUseLimit = 0 < iLimit;
|
||||
|
||||
aItems = aItems && 0 < aItems.length ? aItems : null;
|
||||
if (aItems)
|
||||
{
|
||||
for (iIndex = 0, iLen = aItems.length; iIndex < iLen; iIndex++)
|
||||
{
|
||||
oItem = aItems[iIndex];
|
||||
if (oItem)
|
||||
{
|
||||
if (bEntry)
|
||||
{
|
||||
if ('file' === oItem['kind'] && oItem['webkitGetAsEntry'])
|
||||
{
|
||||
oEntry = oItem['webkitGetAsEntry']();
|
||||
if (oEntry)
|
||||
{
|
||||
fTraverseFileTree(oEntry, '', fFileCallback, fLimitCallback);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!bUseLimit || 0 <= --iLimit)
|
||||
{
|
||||
fFileCallback(getDataFromFile(oItem));
|
||||
}
|
||||
else if (bUseLimit && !bCallLimit)
|
||||
{
|
||||
if (0 > iLimit && fLimitCallback)
|
||||
{
|
||||
bCallLimit = true;
|
||||
fLimitCallback(iInputLimit);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {*} oInput
|
||||
* @param {Function} fFileCallback
|
||||
* @param {number=} iLimit = 20
|
||||
* @param {Function=} fLimitCallback
|
||||
*/
|
||||
function getDataFromInput(oInput, fFileCallback, iLimit, fLimitCallback)
|
||||
{
|
||||
var aFiles = oInput && oInput.files && 0 < oInput.files.length ? oInput.files : null;
|
||||
if (aFiles)
|
||||
{
|
||||
getDataFromFiles(aFiles, fFileCallback, false, false, iLimit, fLimitCallback);
|
||||
}
|
||||
else
|
||||
{
|
||||
fFileCallback({
|
||||
'FileName': oInput.value.split('\\').pop().split('/').pop(),
|
||||
'Size': null,
|
||||
'Type': null,
|
||||
'Folder': '',
|
||||
'File' : null
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function eventContainsFiles(oEvent)
|
||||
{
|
||||
var bResult = false;
|
||||
if (oEvent && oEvent.dataTransfer && oEvent.dataTransfer.types && oEvent.dataTransfer.types.length)
|
||||
{
|
||||
var
|
||||
iIindex = 0,
|
||||
iLen = oEvent.dataTransfer.types.length
|
||||
;
|
||||
|
||||
for (; iIindex < iLen; iIindex++)
|
||||
{
|
||||
if (oEvent.dataTransfer.types[iIindex].toLowerCase() === 'files')
|
||||
{
|
||||
bResult = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return bResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Event} oEvent
|
||||
* @param {Function} fFileCallback
|
||||
* @param {number=} iLimit = 20
|
||||
* @param {Function=} fLimitCallback
|
||||
* @param {boolean=} bAllowFolderDragAndDrop = true
|
||||
*/
|
||||
function getDataFromDragEvent(oEvent, fFileCallback, iLimit, fLimitCallback, bAllowFolderDragAndDrop)
|
||||
{
|
||||
var
|
||||
aItems = null,
|
||||
aFiles = null
|
||||
;
|
||||
|
||||
oEvent = getEvent(oEvent);
|
||||
if (oEvent)
|
||||
{
|
||||
aItems = (oEvent.dataTransfer ? getValue(oEvent.dataTransfer, 'items', null) : null) || getValue(oEvent, 'items', null);
|
||||
if (aItems && 0 < aItems.length && aItems[0] && aItems[0]['webkitGetAsEntry'])
|
||||
{
|
||||
getDataFromFiles(aItems, fFileCallback, true, bAllowFolderDragAndDrop, iLimit, fLimitCallback);
|
||||
}
|
||||
else if (eventContainsFiles(oEvent))
|
||||
{
|
||||
aFiles = (getValue(oEvent, 'files', null) || (oEvent.dataTransfer ?
|
||||
getValue(oEvent.dataTransfer, 'files', null) : null));
|
||||
|
||||
if (aFiles && 0 < aFiles.length)
|
||||
{
|
||||
getDataFromFiles(aFiles, fFileCallback, false, false, iLimit, fLimitCallback);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function createNextLabel()
|
||||
{
|
||||
return $('<label style="' +
|
||||
'position: absolute; background-color:#fff; right: 0px; top: 0px; left: 0px; bottom: 0px; margin: 0px; padding: 0px; cursor: pointer;' +
|
||||
'"></label>').css({
|
||||
'opacity': 0
|
||||
});
|
||||
}
|
||||
|
||||
function createNextInput()
|
||||
{
|
||||
return $('<input type="file" tabindex="-1" hidefocus="hidefocus" style="position: absolute; left: -9999px;" />');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string=} sName
|
||||
* @param {boolean=} bMultiple = true
|
||||
* @return {?Object}
|
||||
*/
|
||||
function getNewInput(sName, bMultiple)
|
||||
{
|
||||
sName = isUndefined(sName) ? '' : sName.toString();
|
||||
|
||||
var oLocal = createNextInput();
|
||||
if (0 < sName.length)
|
||||
{
|
||||
oLocal.attr('name', sName);
|
||||
}
|
||||
|
||||
if (isUndefined(bMultiple) ? true : bMultiple)
|
||||
{
|
||||
oLocal.prop('multiple', true);
|
||||
}
|
||||
|
||||
return oLocal;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {?} mStringOrFunction
|
||||
* @param {Array=} aFunctionParams
|
||||
* @return {string}
|
||||
*/
|
||||
function getStringOrCallFunction(mStringOrFunction, aFunctionParams)
|
||||
{
|
||||
return $.isFunction(mStringOrFunction) ?
|
||||
mStringOrFunction.apply(null, $.isArray(aFunctionParams) ? aFunctionParams : []).toString() :
|
||||
mStringOrFunction.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
|
|
|
|||
2
vendors/jua/jua.min.js
vendored
2
vendors/jua/jua.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue