diff --git a/dev/ViewModels/PopupsDomainViewModel.js b/dev/ViewModels/PopupsDomainViewModel.js index c87f5ecbd..9c1b415ac 100644 --- a/dev/ViewModels/PopupsDomainViewModel.js +++ b/dev/ViewModels/PopupsDomainViewModel.js @@ -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); diff --git a/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/Domain/DefaultDomain.php b/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/Domain/DefaultDomain.php index d11213dd2..cbbfcccae 100644 --- a/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/Domain/DefaultDomain.php +++ b/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/Domain/DefaultDomain.php @@ -1,247 +1,246 @@ -sDomainPath = \rtrim(\trim($sDomainPath), '\\/'); - } - - /** - * @param string $sName - * @param bool $bBack = false - * - * @return string - */ - public function codeFileName($sName, $bBack = false) - { - if ($bBack && 'default' === $sName) - { - return '*'; - } - else if (!$bBack && '*' === $sName) - { - return 'default'; - } - - $sName = \strtolower($sName); - return $bBack ? \str_replace('_wildcard_', '*', $sName) : \str_replace('*', '_wildcard_', $sName); - } - - /** - * @param string $sName - * @param bool $bDisable - * - * @return bool - */ - public function Disable($sName, $bDisable) - { - $sFile = ''; - if (\file_exists($this->sDomainPath.'/disabled')) - { - $sFile = @\file_get_contents($this->sDomainPath.'/disabled'); - } - - $aResult = array(); - $aNames = \explode(',', $sFile); - if ($bDisable) - { - \array_push($aNames, $sName); - $aResult = $aNames; - } - else - { - foreach ($aNames as $sItem) - { - if ($sName !== $sItem) - { - $aResult[] = $sItem; - } - } - } - - $aResult = \array_unique($aResult); - return false !== \file_put_contents($this->sDomainPath.'/disabled', \trim(\implode(',', $aResult), ', ')); - } - - /** - * @param string $sName - * @param bool $bFindWithWildCard = false - * - * @return \RainLoop\Domain | null - */ - 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')); - - if ($mResult instanceof \RainLoop\Domain) - { - if (\file_exists($this->sDomainPath.'/disabled')) - { - $sDisabled = @\file_get_contents($this->sDomainPath.'/disabled'); - if (false !== $sDisabled && 0 < \strlen($sDisabled)) - { - $mResult->SetDisabled(false !== \strpos(strtolower(','.$sDisabled.','), \strtolower(','.$sName.','))); - } - } - } - } - 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; - } - - /** - * @param \RainLoop\Domain $oDomain - * - * @return bool - */ - public function Save(\RainLoop\Domain $oDomain) - { - $sName = \strtolower($oDomain->Name()); - $sRealFileName = $this->codeFileName($sName); - - $mResult = \file_put_contents($this->sDomainPath.'/'.$sRealFileName.'.ini', $oDomain->ToIniString()); - return \is_int($mResult) && 0 < $mResult; - } - - /** - * @param string $sName - * - * @return bool - */ - public function Delete($sName) - { - $bResult = true; - $sName = \strtolower($sName); - $sRealFileName = $this->codeFileName($sName); - - if (0 < \strlen($sName) && \file_exists($this->sDomainPath.'/'.$sRealFileName.'.ini')) - { - $bResult = \unlink($this->sDomainPath.'/'.$sRealFileName.'.ini'); - } - - if ($bResult) - { - $this->Disable($sName, false); - } - - return $bResult; - } - - /** - * @param int $iOffset - * @param int $iLimit = 20 - * - * @return array - */ - public function GetList($iOffset, $iLimit = 20) - { - $aResult = array(); - $aWildCards = array(); - $aList = \glob($this->sDomainPath.'/*.ini'); - - foreach ($aList as $sFile) - { - $sName = \strtolower(\substr(\basename($sFile), 0, -4)); - $sName = $this->codeFileName($sName, true); - if (false === \strpos($sName, '*')) - { - $aResult[] = $sName; - } - else - { - $aWildCards[] = $sName; - } - } - - \sort($aResult, SORT_STRING); - \rsort($aWildCards, SORT_STRING); - - $aResult = \array_merge($aResult, $aWildCards); - - $iOffset = (0 > $iOffset) ? 0 : $iOffset; - $iLimit = (0 > $iLimit) ? 0 : ((999 < $iLimit) ? 999 : $iLimit); - - $aResult = \array_slice($aResult, $iOffset, $iLimit); - - $aDisabledNames = array(); - if (0 < \count($aResult) && \file_exists($this->sDomainPath.'/disabled')) - { - $sDisabled = @\file_get_contents($this->sDomainPath.'/disabled'); - if (false !== $sDisabled && 0 < strlen($sDisabled)) - { - $aDisabledNames = \explode(',', strtolower($sDisabled)); - $aDisabledNames = \array_unique($aDisabledNames); - } - } - - $aReturn = array(); - foreach ($aResult as $sName) - { - $aReturn[$sName] = !\in_array(\strtolower($sName), $aDisabledNames); - } - - return $aReturn; - } - - /** - * @param string $sSearch = '' - * - * @return int - */ - public function Count() - { - return \count($this->GetList(0, 999)); - } +sDomainPath = \rtrim(\trim($sDomainPath), '\\/'); + } + + /** + * @param string $sName + * @param bool $bBack = false + * + * @return string + */ + public function codeFileName($sName, $bBack = false) + { + if ($bBack && 'default' === $sName) + { + return '*'; + } + else if (!$bBack && '*' === $sName) + { + return 'default'; + } + + $sName = \strtolower($sName); + return $bBack ? \str_replace('_wildcard_', '*', $sName) : \str_replace('*', '_wildcard_', $sName); + } + + /** + * @param string $sName + * @param bool $bDisable + * + * @return bool + */ + public function Disable($sName, $bDisable) + { + $sFile = ''; + if (\file_exists($this->sDomainPath.'/disabled')) + { + $sFile = @\file_get_contents($this->sDomainPath.'/disabled'); + } + + $aResult = array(); + $aNames = \explode(',', $sFile); + if ($bDisable) + { + \array_push($aNames, $sName); + $aResult = $aNames; + } + else + { + foreach ($aNames as $sItem) + { + if ($sName !== $sItem) + { + $aResult[] = $sItem; + } + } + } + + $aResult = \array_unique($aResult); + return false !== \file_put_contents($this->sDomainPath.'/disabled', \trim(\implode(',', $aResult), ', ')); + } + + /** + * @param string $sName + * @param bool $bFindWithWildCard = false + * + * @return \RainLoop\Domain | null + */ + 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) + { + if (\file_exists($this->sDomainPath.'/disabled')) + { + $sDisabled = @\file_get_contents($this->sDomainPath.'/disabled'); + if (false !== $sDisabled && 0 < \strlen($sDisabled)) + { + $mResult->SetDisabled(false !== \strpos(strtolower(','.$sDisabled.','), \strtolower(','.$sName.','))); + } + } + } + + return $mResult; + } + + /** + * @param \RainLoop\Domain $oDomain + * + * @return bool + */ + public function Save(\RainLoop\Domain $oDomain) + { + $sName = \strtolower($oDomain->Name()); + $sRealFileName = $this->codeFileName($sName); + + $mResult = \file_put_contents($this->sDomainPath.'/'.$sRealFileName.'.ini', $oDomain->ToIniString()); + return \is_int($mResult) && 0 < $mResult; + } + + /** + * @param string $sName + * + * @return bool + */ + public function Delete($sName) + { + $bResult = true; + $sName = \strtolower($sName); + $sRealFileName = $this->codeFileName($sName); + + if (0 < \strlen($sName) && \file_exists($this->sDomainPath.'/'.$sRealFileName.'.ini')) + { + $bResult = \unlink($this->sDomainPath.'/'.$sRealFileName.'.ini'); + } + + if ($bResult) + { + $this->Disable($sName, false); + } + + return $bResult; + } + + /** + * @param int $iOffset + * @param int $iLimit = 20 + * + * @return array + */ + public function GetList($iOffset, $iLimit = 20) + { + $aResult = array(); + $aWildCards = array(); + $aList = \glob($this->sDomainPath.'/*.ini'); + + foreach ($aList as $sFile) + { + $sName = \strtolower(\substr(\basename($sFile), 0, -4)); + $sName = $this->codeFileName($sName, true); + if (false === \strpos($sName, '*')) + { + $aResult[] = $sName; + } + else + { + $aWildCards[] = $sName; + } + } + + \sort($aResult, SORT_STRING); + \rsort($aWildCards, SORT_STRING); + + $aResult = \array_merge($aResult, $aWildCards); + + $iOffset = (0 > $iOffset) ? 0 : $iOffset; + $iLimit = (0 > $iLimit) ? 0 : ((999 < $iLimit) ? 999 : $iLimit); + + $aResult = \array_slice($aResult, $iOffset, $iLimit); + + $aDisabledNames = array(); + if (0 < \count($aResult) && \file_exists($this->sDomainPath.'/disabled')) + { + $sDisabled = @\file_get_contents($this->sDomainPath.'/disabled'); + if (false !== $sDisabled && 0 < strlen($sDisabled)) + { + $aDisabledNames = \explode(',', strtolower($sDisabled)); + $aDisabledNames = \array_unique($aDisabledNames); + } + } + + $aReturn = array(); + foreach ($aResult as $sName) + { + $aReturn[$sName] = !\in_array(\strtolower($sName), $aDisabledNames); + } + + return $aReturn; + } + + /** + * @param string $sSearch = '' + * + * @return int + */ + public function Count() + { + return \count($this->GetList(0, 999)); + } } \ No newline at end of file diff --git a/rainloop/v/0.0.0/app/templates/Views/PopupsDomain.html b/rainloop/v/0.0.0/app/templates/Views/PopupsDomain.html index b5e607903..731ed545e 100644 --- a/rainloop/v/0.0.0/app/templates/Views/PopupsDomain.html +++ b/rainloop/v/0.0.0/app/templates/Views/PopupsDomain.html @@ -8,9 +8,9 @@
diff --git a/rainloop/v/0.0.0/static/js/admin.js b/rainloop/v/0.0.0/static/js/admin.js index 84cf9efd0..1fb97e829 100644 --- a/rainloop/v/0.0.0/static/js/admin.js +++ b/rainloop/v/0.0.0/static/js/admin.js @@ -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); diff --git a/rainloop/v/0.0.0/static/js/admin.min.js b/rainloop/v/0.0.0/static/js/admin.min.js index 87e19a789..03ad0e8f7 100644 --- a/rainloop/v/0.0.0/static/js/admin.min.js +++ b/rainloop/v/0.0.0/static/js/admin.min.js @@ -1,4 +1,4 @@ /*! RainLoop Webmail Admin Module (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */ -!function(a,b,c,d,e,f){"use strict";function g(){this.sBase="#/",this.sCdnStaticDomain=fb.settingsGet("CdnStaticDomain"),this.sVersion=fb.settingsGet("Version"),this.sSpecSuffix=fb.settingsGet("AuthAccountHash")||"0",this.sServer=(fb.settingsGet("IndexFile")||"./")+"?",this.sCdnStaticDomain=""===this.sCdnStaticDomain?this.sCdnStaticDomain:"/"===this.sCdnStaticDomain.substr(-1)?this.sCdnStaticDomain:this.sCdnStaticDomain+"/"}function h(){}function i(){}function j(){var a=[i,h],b=f.find(a,function(a){return a.supported()});b&&(b=b,this.oDriver=new b)}function k(){}function l(a,b){this.sPosition=V.pString(a),this.sTemplate=V.pString(b),this.viewModelName="",this.viewModelVisibility=c.observable(!1),"Popups"===this.sPosition&&(this.modalVisibility=c.observable(!1)),this.viewModelDom=null}function m(a,b){this.sScreenName=a,this.aViewModels=V.isArray(b)?b:[]}function n(){this.sDefaultScreenName="",this.oScreens={},this.oBoot=null,this.oCurrentScreen=null,this.popupVisibility=c.observable(!1),this.popupVisibility.subscribe(function(a){fb&&fb.popupVisibility(a)})}function o(a,b){this.email=a||"",this.name=b||"",this.privateType=null,this.clearDuplicateName()}function p(){l.call(this,"Popups","PopupsDomain"),this.edit=c.observable(!1),this.saving=c.observable(!1),this.savingError=c.observable(""),this.whiteListPage=c.observable(!1),this.testing=c.observable(!1),this.testingDone=c.observable(!1),this.testingImapError=c.observable(!1),this.testingSmtpError=c.observable(!1),this.imapServerFocus=c.observable(!1),this.smtpServerFocus=c.observable(!1),this.name=c.observable(""),this.imapServer=c.observable(""),this.imapPort=c.observable(S.Values.ImapDefaulPort),this.imapSecure=c.observable(T.ServerSecure.None),this.imapShortLogin=c.observable(!1),this.smtpServer=c.observable(""),this.smtpPort=c.observable(S.Values.SmtpDefaulPort),this.smtpSecure=c.observable(T.ServerSecure.None),this.smtpShortLogin=c.observable(!1),this.smtpAuth=c.observable(!0),this.whiteList=c.observable(""),this.imapServerFocus.subscribe(function(a){a&&""!==this.name()&&""===this.imapServer()&&this.imapServer(this.name())},this),this.smtpServerFocus.subscribe(function(a){a&&""!==this.imapServer()&&""===this.smtpServer()&&this.smtpServer(this.imapServer())},this),this.headerText=c.computed(function(){var a=this.name();return this.edit()?'Edit Domain "'+a+'"':"Add Domain"+(""===a?"":' "'+a+'"')},this),this.domainIsComputed=c.computed(function(){return""!==this.name()&&""!==this.imapServer()&&""!==this.imapPort()&&""!==this.smtpServer()&&""!==this.smtpPort()},this),this.canBeTested=c.computed(function(){return!this.testing()&&this.domainIsComputed()},this),this.canBeSaved=c.computed(function(){return!this.saving()&&this.domainIsComputed()},this),this.createOrAddCommand=V.createCommand(this,function(){this.saving(!0),fb.remote().createOrUpdateDomain(f.bind(this.onDomainCreateOrSaveResponse,this),!this.edit(),this.name(),this.imapServer(),this.imapPort(),this.imapSecure(),this.imapShortLogin(),this.smtpServer(),this.smtpPort(),this.smtpSecure(),this.smtpShortLogin(),this.smtpAuth(),this.whiteList())},this.canBeSaved),this.testConnectionCommand=V.createCommand(this,function(){this.whiteListPage(!1),this.testingDone(!1),this.testingImapError(!1),this.testingSmtpError(!1),this.testing(!0),fb.remote().testConnectionForDomain(f.bind(this.onTestConnectionResponse,this),this.imapServer(),this.imapPort(),this.imapSecure(),this.smtpServer(),this.smtpPort(),this.smtpSecure(),this.smtpAuth())},this.canBeTested),this.whiteListCommand=V.createCommand(this,function(){this.whiteListPage(!this.whiteListPage())}),n.constructorEnd(this)}function q(){l.call(this,"Popups","PopupsPlugin");var a=this;this.onPluginSettingsUpdateResponse=f.bind(this.onPluginSettingsUpdateResponse,this),this.saveError=c.observable(""),this.name=c.observable(""),this.readme=c.observable(""),this.configures=c.observableArray([]),this.hasReadme=c.computed(function(){return""!==this.readme()},this),this.hasConfiguration=c.computed(function(){return 0 ').appendTo("body"),cb.on("error",function(a){fb&&a&&a.originalEvent&&a.originalEvent.message&&-1===V.inArray(a.originalEvent.message,["Script error.","Uncaught Error: Error calling method on NPObject."])&&fb.remote().jsError(V.emptyFunction,a.originalEvent.message,a.originalEvent.filename,a.originalEvent.lineno,location&&location.toString?location.toString():"",bb.attr("class"),V.microtime()-Y.now)})}function R(){Q.call(this),this.oData=null,this.oRemote=null,this.oCache=null}var S={},T={},U={},V={},W={},X={},Y={},Z={settings:[],"settings-removed":[],"settings-disabled":[]},$=null,_=a.rainloopAppData||{},ab=a.rainloopI18N||{},bb=b("html"),cb=b(a),db=b(a.document),eb=a.Notification&&a.Notification.requestPermission?a.Notification:null,fb=null;Y.now=(new Date).getTime(),Y.momentTrigger=c.observable(!0),Y.langChangeTrigger=c.observable(!0),Y.iAjaxErrorCount=0,Y.iTokenErrorCount=0,Y.iMessageBodyCacheCount=0,Y.bUnload=!1,Y.sUserAgent=(navigator.userAgent||"").toLowerCase(),Y.bIsiOSDevice=-1