Experimental support for wildcards in the domain name.

This commit is contained in:
RainLoop Team 2014-02-08 03:28:11 +04:00
parent ab07d102f9
commit 93e09effba
5 changed files with 276 additions and 253 deletions
dev/ViewModels
rainloop/v/0.0.0
app
libraries/RainLoop/Providers/Domain
templates/Views
static/js

View file

@ -22,6 +22,8 @@ function PopupsDomainViewModel()
this.smtpServerFocus = ko.observable(false);
this.name = ko.observable('');
this.name.focused = ko.observable(false);
this.imapServer = ko.observable('');
this.imapPort = ko.observable(Consts.Values.ImapDefaulPort);
this.imapSecure = ko.observable(Enums.ServerSecure.None);
@ -36,7 +38,7 @@ function PopupsDomainViewModel()
this.imapServerFocus.subscribe(function (bValue) {
if (bValue && '' !== this.name() && '' === this.imapServer())
{
this.imapServer(this.name());
this.imapServer(this.name().replace(/[.]?[*][.]?/g, ''));
}
}, this);
@ -186,6 +188,14 @@ PopupsDomainViewModel.prototype.onShow = function (oDomain)
}
};
PopupsDomainViewModel.prototype.onFocus = function ()
{
if ('' === this.name())
{
this.name.focused(true);
}
};
PopupsDomainViewModel.prototype.onBuild = function ()
{
var self = this;
@ -208,6 +218,8 @@ PopupsDomainViewModel.prototype.clearForm = function ()
this.savingError('');
this.name('');
this.name.focused(false);
this.imapServer('');
this.imapPort(Consts.Values.ImapDefaulPort);
this.imapSecure(Enums.ServerSecure.None);

View file

@ -85,12 +85,45 @@ class DefaultDomain implements \RainLoop\Providers\Domain\DomainAdminInterface
public function Load($sName, $bFindWithWildCard = false)
{
$mResult = null;
$sName = \strtolower($sName);
$sRealFileName = $this->codeFileName($sName);
if (\file_exists($this->sDomainPath.'/'.$sRealFileName.'.ini'))
{
$mResult = \RainLoop\Domain::NewInstanceFromDomainConfigArray(
$sName, @\parse_ini_file($this->sDomainPath.'/'.$sRealFileName.'.ini'));
}
else if ($bFindWithWildCard)
{
$sNames = '';
$aNames = array();
$aList = \glob($this->sDomainPath.'/*.ini');
foreach ($aList as $sFile)
{
$sName = \strtolower(\substr(\basename($sFile), 0, -4));
if ('default' === $sName || false !== strpos($sName, '_wildcard_'))
{
$aNames[] = $this->codeFileName($sName, true);
}
}
if (0 < \count($aNames))
{
\rsort($aNames, SORT_STRING);
$sNames = \implode(' ', $aNames);
}
if (0 < \strlen($sNames))
{
$sFoundedValue = '';
if (\RainLoop\Plugins\Helper::ValidateWildcardValues($sName, $sNames, $sFoundedValue) && 0 < \strlen($sFoundedValue))
{
$mResult = $this->Load($sFoundedValue, false);
}
}
}
if ($mResult instanceof \RainLoop\Domain)
{
@ -103,40 +136,6 @@ class DefaultDomain implements \RainLoop\Providers\Domain\DomainAdminInterface
}
}
}
}
else if ($bFindWithWildCard)
{
// TODO
// $sNames = '';
// $aNames = array();
//
// $aList = \glob($this->sDomainPath.'/*.ini');
// foreach ($aList as $sFile)
// {
// $sName = \strtolower(\substr(\basename($sFile), 0, -4));
// if ('default' === $sName || false !== strpos($sName, '_wildcard_'))
// {
// $aNames[] = $this->codeFileName($sName, true);
// }
// }
//
// if (0 < \count($aNames))
// {
// \rsort($sNames, SORT_STRING);
// $sNames = \implode(' ', $aNames);
// }
//
// if (0 < \strlen($sNames))
// {
// $sFoundedValue = '';
// if (\RainLoop\Plugins\Helper::ValidateWildcardValues($sName, $sNames, $sFoundedValue) && 0 < \strlen($sFoundedValue))
// {
// $mResult = $this->Load($sFoundedValue, false);
// }
// }
$mResult = $this->Load('default', false);
}
return $mResult;
}

View file

@ -8,9 +8,9 @@
<form class="form-horizontal domain-form" action="#/" onsubmit="return false;">
<div class="row" data-bind="visible: !edit()">
<div class="span8">
Name
Name <span style="color: #aaa">(wildcard supported)</span>
<br />
<input type="text" data-bind="value: name, valueUpdate: 'afterkeydown'" />
<input type="text" data-bind="value: name, hasfocus: name.focused, valueUpdate: 'afterkeydown'" />
<span class="error-desc" data-bind="text: savingError"></span>
</div>
</div>
@ -87,7 +87,7 @@
List of users webmail is allowed to access.
Use a space as delimiter.
</div>
<textarea class="input-xxlarge" style="width: 600px" rows="8" data-bind="value: whiteList"></textarea>
<textarea class="input-xxlarge" style="width: 600px" rows="8" data-bind="value: whiteList" tabindex="-1"></textarea>
</div>
</div>
</form>

View file

@ -4498,6 +4498,8 @@ function PopupsDomainViewModel()
this.smtpServerFocus = ko.observable(false);
this.name = ko.observable('');
this.name.focused = ko.observable(false);
this.imapServer = ko.observable('');
this.imapPort = ko.observable(Consts.Values.ImapDefaulPort);
this.imapSecure = ko.observable(Enums.ServerSecure.None);
@ -4512,7 +4514,7 @@ function PopupsDomainViewModel()
this.imapServerFocus.subscribe(function (bValue) {
if (bValue && '' !== this.name() && '' === this.imapServer())
{
this.imapServer(this.name());
this.imapServer(this.name().replace(/[.]?[*][.]?/g, ''));
}
}, this);
@ -4662,6 +4664,14 @@ PopupsDomainViewModel.prototype.onShow = function (oDomain)
}
};
PopupsDomainViewModel.prototype.onFocus = function ()
{
if ('' === this.name())
{
this.name.focused(true);
}
};
PopupsDomainViewModel.prototype.onBuild = function ()
{
var self = this;
@ -4684,6 +4694,8 @@ PopupsDomainViewModel.prototype.clearForm = function ()
this.savingError('');
this.name('');
this.name.focused(false);
this.imapServer('');
this.imapPort(Consts.Values.ImapDefaulPort);
this.imapSecure(Enums.ServerSecure.None);

File diff suppressed because one or more lines are too long