Autocreate system folders in folder list request.

Additional plugin hooks
This commit is contained in:
RainLoop Team 2013-12-18 03:00:57 +04:00
parent 972067b6d9
commit 394e22520e
19 changed files with 357 additions and 288 deletions

View file

@ -164,18 +164,17 @@ RainLoopApp.prototype.recacheInboxMessageList = function ()
}; };
/** /**
* @param {boolean=} bUseCache = true
* @param {Function=} fCallback * @param {Function=} fCallback
*/ */
RainLoopApp.prototype.folders = function (bUseCache, fCallback) RainLoopApp.prototype.folders = function (fCallback)
{ {
this.data().foldersLoading(true); this.data().foldersLoading(true);
this.remote().folders(_.bind(function (sResult, oData, bCached) { this.remote().folders(_.bind(function (sResult, oData) {
RL.data().foldersLoading(false); RL.data().foldersLoading(false);
if (Enums.StorageResultType.Success === sResult) if (Enums.StorageResultType.Success === sResult)
{ {
this.data().setFolders(oData, bCached); this.data().setFolders(oData);
if (fCallback) if (fCallback)
{ {
fCallback(true); fCallback(true);
@ -188,7 +187,7 @@ RainLoopApp.prototype.folders = function (bUseCache, fCallback)
fCallback(false); fCallback(false);
} }
} }
}, this), bUseCache); }, this));
}; };
RainLoopApp.prototype.accountsAndIdentities = function () RainLoopApp.prototype.accountsAndIdentities = function ()
@ -775,7 +774,7 @@ RainLoopApp.prototype.bootstart = function ()
{ {
this.setTitle(Utils.i18n('TITLES/LOADING')); this.setTitle(Utils.i18n('TITLES/LOADING'));
this.folders(true, _.bind(function (bValue) { this.folders(_.bind(function (bValue) {
kn.hideLoading(); kn.hideLoading();

View file

@ -45,10 +45,6 @@ function FolderModel()
} }
}, this); }, this);
this.canBeEdited = ko.computed(function () {
return Enums.FolderType.User === this.type();
}, this);
this.privateMessageCountAll = ko.observable(0); this.privateMessageCountAll = ko.observable(0);
this.privateMessageCountUnread = ko.observable(0); this.privateMessageCountUnread = ko.observable(0);
@ -77,6 +73,10 @@ FolderModel.prototype.initComputed = function ()
}); });
}, this); }, this);
this.canBeEdited = ko.computed(function () {
return Enums.FolderType.User === this.type() && this.existen && this.selectable;
}, this);
this.visible = ko.computed(function () { this.visible = ko.computed(function () {
var var
bSubScribed = this.subScribed(), bSubScribed = this.subScribed(),

View file

@ -95,7 +95,7 @@ SettingsFolders.prototype.folderEditOnEnter = function (oFolder)
oData && oData.ErrorCode ? Utils.getNotification(oData.ErrorCode) : Utils.i18n('NOTIFICATIONS/CANT_RENAME_FOLDER')); oData && oData.ErrorCode ? Utils.getNotification(oData.ErrorCode) : Utils.i18n('NOTIFICATIONS/CANT_RENAME_FOLDER'));
} }
RL.folders(false); RL.folders();
}, oFolder.fullNameRaw, sEditName); }, oFolder.fullNameRaw, sEditName);
@ -166,7 +166,7 @@ SettingsFolders.prototype.deleteFolder = function (oFolderToRemove)
oData && oData.ErrorCode ? Utils.getNotification(oData.ErrorCode) : Utils.i18n('NOTIFICATIONS/CANT_DELETE_FOLDER')); oData && oData.ErrorCode ? Utils.getNotification(oData.ErrorCode) : Utils.i18n('NOTIFICATIONS/CANT_DELETE_FOLDER'));
} }
RL.folders(false); RL.folders();
}, oFolderToRemove.fullNameRaw); }, oFolderToRemove.fullNameRaw);

View file

@ -15,21 +15,15 @@ _.extend(WebMailAjaxRemoteStorage.prototype, AbstractAjaxRemoteStorage.prototype
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
* @param {boolean=} bUseCache = true
*/ */
WebMailAjaxRemoteStorage.prototype.folders = function (fCallback, bUseCache) WebMailAjaxRemoteStorage.prototype.folders = function (fCallback)
{ {
var sFoldersHash = RL.data().lastFoldersHash; this.defaultRequest(fCallback, 'Folders', {
'SentFolder': RL.settingsGet('SentFolder'),
bUseCache = Utils.isUnd(bUseCache) ? false : !!bUseCache; 'DraftFolder': RL.settingsGet('DraftFolder'),
if (bUseCache && '' !== sFoldersHash) 'SpamFolder': RL.settingsGet('SpamFolder'),
{ 'TrashFolder': RL.settingsGet('TrashFolder')
this.defaultRequest(fCallback, 'Folders', {}, null, 'Folders/' + RL.data().projectHash() + '-' + sFoldersHash, ['Folders']); }, null, '', ['Folders']);
}
else
{
this.defaultRequest(fCallback, 'Folders', {}, null, '', ['Folders']);
}
}; };
/** /**

View file

@ -486,10 +486,9 @@ WebMailDataStorage.prototype.initUidNextAndNewMessages = function (sFolder, sUid
/** /**
* @param {string} sNamespace * @param {string} sNamespace
* @param {Array} aFolders * @param {Array} aFolders
* @param {boolean} bCached
* @return {Array} * @return {Array}
*/ */
WebMailDataStorage.prototype.folderResponseParseRec = function (sNamespace, aFolders, bCached) WebMailDataStorage.prototype.folderResponseParseRec = function (sNamespace, aFolders)
{ {
var var
iIndex = 0, iIndex = 0,
@ -501,8 +500,6 @@ WebMailDataStorage.prototype.folderResponseParseRec = function (sNamespace, aFol
aList = [] aList = []
; ;
bCached = !!bCached;
for (iIndex = 0, iLen = aFolders.length; iIndex < iLen; iIndex++) for (iIndex = 0, iLen = aFolders.length; iIndex < iLen; iIndex++)
{ {
oFolder = aFolders[iIndex]; oFolder = aFolders[iIndex];
@ -536,7 +533,7 @@ WebMailDataStorage.prototype.folderResponseParseRec = function (sNamespace, aFol
{ {
oCacheFolder.collapsed(!Utils.isFolderExpanded(oCacheFolder.fullNameHash)); oCacheFolder.collapsed(!Utils.isFolderExpanded(oCacheFolder.fullNameHash));
if (!bCached && oFolder.Extended) if (oFolder.Extended)
{ {
if (oFolder.Extended.Hash) if (oFolder.Extended.Hash)
{ {
@ -559,7 +556,7 @@ WebMailDataStorage.prototype.folderResponseParseRec = function (sNamespace, aFol
aSubFolders['@Collection'] && Utils.isArray(aSubFolders['@Collection'])) aSubFolders['@Collection'] && Utils.isArray(aSubFolders['@Collection']))
{ {
oCacheFolder.subFolders( oCacheFolder.subFolders(
this.folderResponseParseRec(sNamespace, aSubFolders['@Collection'], bCached)); this.folderResponseParseRec(sNamespace, aSubFolders['@Collection']));
} }
aList.push(oCacheFolder); aList.push(oCacheFolder);
@ -572,16 +569,13 @@ WebMailDataStorage.prototype.folderResponseParseRec = function (sNamespace, aFol
/** /**
* @param {*} oData * @param {*} oData
* @param {boolean=} bCached = false
*/ */
WebMailDataStorage.prototype.setFolders = function (oData, bCached) WebMailDataStorage.prototype.setFolders = function (oData)
{ {
var var
aList = [], aList = [],
bUpdate = false, bUpdate = false,
oRLData = RL.data(), oRLData = RL.data(),
aFolders = oRLData.folderList(),
bFoldersFirst = 0 === aFolders.length,
fNormalizeFolder = function (sFolderFullNameRaw) { fNormalizeFolder = function (sFolderFullNameRaw) {
return ('' === sFolderFullNameRaw || Consts.Values.UnuseOptionValue === sFolderFullNameRaw || return ('' === sFolderFullNameRaw || Consts.Values.UnuseOptionValue === sFolderFullNameRaw ||
null !== RL.cache().getFolderFromCacheList(sFolderFullNameRaw)) ? sFolderFullNameRaw : ''; null !== RL.cache().getFolderFromCacheList(sFolderFullNameRaw)) ? sFolderFullNameRaw : '';
@ -598,12 +592,12 @@ WebMailDataStorage.prototype.setFolders = function (oData, bCached)
this.threading(!!RL.settingsGet('UseImapThread') && oData.Result.IsThreadsSupported && true); this.threading(!!RL.settingsGet('UseImapThread') && oData.Result.IsThreadsSupported && true);
aList = this.folderResponseParseRec(oRLData.namespace, oData.Result['@Collection'], !!bCached); aList = this.folderResponseParseRec(oRLData.namespace, oData.Result['@Collection']);
oRLData.folderList(aList); oRLData.folderList(aList);
if (oData.Result['SystemFolders'] && if (oData.Result['SystemFolders'] &&
'' === '' + RL.settingsGet('SentFolder') + RL.settingsGet('DraftFolder') + '' === '' + RL.settingsGet('SentFolder') + RL.settingsGet('DraftFolder') +
RL.settingsGet('SpamFolder') + RL.settingsGet('TrashFolder')) RL.settingsGet('SpamFolder') + RL.settingsGet('TrashFolder') + RL.settingsGet('NullFolder'))
{ {
// TODO Magic Numbers // TODO Magic Numbers
RL.settingsSet('SentFolder', oData.Result['SystemFolders'][2] || null); RL.settingsSet('SentFolder', oData.Result['SystemFolders'][2] || null);
@ -625,19 +619,12 @@ WebMailDataStorage.prototype.setFolders = function (oData, bCached)
'SentFolder': oRLData.sentFolder(), 'SentFolder': oRLData.sentFolder(),
'DraftFolder': oRLData.draftFolder(), 'DraftFolder': oRLData.draftFolder(),
'SpamFolder': oRLData.spamFolder(), 'SpamFolder': oRLData.spamFolder(),
'TrashFolder': oRLData.trashFolder() 'TrashFolder': oRLData.trashFolder(),
'NullFolder': 'NullFolder'
}); });
} }
if (!bCached) RL.local().set(Enums.ClientSideKeyName.FoldersLashHash, oData.Result.FoldersHash);
{
RL.local().set(Enums.ClientSideKeyName.FoldersLashHash, oData.Result.FoldersHash);
}
if (bFoldersFirst && bCached)
{
RL.folders(false);
}
} }
}; };

View file

@ -1,104 +1,125 @@
.folderPaddingHelper(@i) { /*.folderPaddingHelper(@i) {
(~".folder-padding.deep-@{i}") { (~".folder-padding.deep-@{i}") {
width: 15px * @i + 10px; width: 15px * @i + 10px;
} }
} }*/
.b-settings-folders { .b-settings-folders {
&.ignore-folder-subscribe { &.ignore-folder-subscribe {
.subscribe-folder, .unsubscribe-folder { .subscribe-folder, .unsubscribe-folder {
display: none; display: none;
} }
} }
.process-place { .process-place {
text-align: center; text-align: center;
width: 600px; width: 600px;
padding: 14px 0; padding: 14px 0;
} }
.folders-list-error { .folders-list-error {
width: 550px; width: 550px;
margin: 10px 0px; margin: 10px 0px;
} }
.list-table { .list-table {
width: 600px; width: 600px;
.e-action { .e-action {
cursor: pointer; cursor: pointer;
} }
td { td {
padding: 4px 8px; padding: 4px 8px;
line-height: 30px; line-height: 30px;
} }
.folder-padding { .folder-padding {
display: inline-block; display: inline-block;
width: 0; width: 0;
} }
.folder-name { .folder-name {
display: inline-block; display: inline-block;
word-break: break-all; word-break: break-all;
.box-sizing(border-box); .box-sizing(border-box);
margin-left: 7px; margin-left: 7px;
line-height: 22px; line-height: 22px;
cursor: default; cursor: default;
} }
.folder-system-name { .folder-system-name {
display: inline-block; display: inline-block;
line-height: 22px; line-height: 22px;
color: #999; color: #999;
cursor: default; cursor: default;
} }
.folder-name.can-be-edited:hover { .folder-name.can-be-edited:hover {
border-bottom: 1px dashed #333; border-bottom: 1px dashed #333;
cursor: pointer; cursor: pointer;
} }
.folder-name-input { .folder-name-input {
border-width: 1px; border-width: 1px;
margin-bottom: 0; margin-bottom: 0;
} margin-left: -4px;
} }
}
.folder-item {
.folder-item {
.button-delete {
margin-right: 15px; &.system .folder-name {
margin-top: 5px; font-weight: bold;
visibility: hidden; }
.opacity(0);
} .button-delete {
margin-right: 15px;
.delete-access { margin-top: 5px;
&.button-delete { visibility: hidden;
visibility: visible; .opacity(0);
margin-right: 0; }
.opacity(100);
} .delete-access {
} &.button-delete {
visibility: visible;
.delete-folder, .subscribe-folder, .unsubscribe-folder { margin-right: 0;
cursor: pointer; .opacity(100);
.opacity(60); }
} }
.unsubscribe-folder { .delete-folder, .subscribe-folder, .unsubscribe-folder {
.opacity(25); cursor: pointer;
} .opacity(60);
} }
.folderPaddingHelper(1); .unsubscribe-folder {
.folderPaddingHelper(2); .opacity(25);
.folderPaddingHelper(3); }
.folderPaddingHelper(4); }
.folderPaddingHelper(5);
.folder-padding.deep-1 {
width: 15px * 1 + 10px;
}
.folder-padding.deep-2 {
width: 15px * 2 + 10px;
}
.folder-padding.deep-3 {
width: 15px * 3 + 10px;
}
.folder-padding.deep-4 {
width: 15px * 4 + 10px;
}
.folder-padding.deep-5 {
width: 15px * 5 + 10px;
}
/* .folderPaddingHelper(1);
.folderPaddingHelper(2);
.folderPaddingHelper(3);
.folderPaddingHelper(4);
.folderPaddingHelper(5);*/
} }

View file

@ -1,5 +0,0 @@
input[type="text"], input[type="password"], input[type="email"], input[type="search"] {
height: 20px;
line-height: 21px;
}

View file

@ -63,7 +63,7 @@ function PopupsFolderCreateViewModel()
RL.data().foldersCreating(false); RL.data().foldersCreating(false);
if (Enums.StorageResultType.Success === sResult && oData && oData.Result) if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
{ {
RL.folders(false); RL.folders();
} }
else else
{ {

View file

@ -45,7 +45,8 @@ function PopupsFolderSystemViewModel()
'SentFolder': self.sentFolder(), 'SentFolder': self.sentFolder(),
'DraftFolder': self.draftFolder(), 'DraftFolder': self.draftFolder(),
'SpamFolder': self.spamFolder(), 'SpamFolder': self.spamFolder(),
'TrashFolder': self.trashFolder() 'TrashFolder': self.trashFolder(),
'NullFolder': 'NullFolder'
}); });
}, 1000); }, 1000);

View file

@ -2,7 +2,7 @@
"name": "RainLoop", "name": "RainLoop",
"title": "RainLoop Webmail", "title": "RainLoop Webmail",
"version": "1.5.1", "version": "1.5.1",
"release": "553", "release": "554",
"description": "Simple, modern & fast web-based email client", "description": "Simple, modern & fast web-based email client",
"homepage": "http://rainloop.net", "homepage": "http://rainloop.net",
"main": "Gruntfile.js", "main": "Gruntfile.js",

View file

@ -1653,12 +1653,11 @@ class MailClient
/** /**
* @param string $sParent = '' * @param string $sParent = ''
* @param string $sListPattern = '*' * @param string $sListPattern = '*'
* @param bool $bUseListStatus = false
* @param bool $bUseListSubscribeStatus = false * @param bool $bUseListSubscribeStatus = false
* *
* @return \MailSo\Mail\FolderCollection|false * @return \MailSo\Mail\FolderCollection|false
*/ */
public function Folders($sParent = '', $sListPattern = '*', $bUseListStatus = false, $bUseListSubscribeStatus = true) public function Folders($sParent = '', $sListPattern = '*', $bUseListSubscribeStatus = true)
{ {
$oFolderCollection = false; $oFolderCollection = false;
@ -1671,19 +1670,9 @@ class MailClient
{ {
$aSubscribedFolders = $this->oImapClient->FolderSubscribeList($sParent, $sListPattern); $aSubscribedFolders = $this->oImapClient->FolderSubscribeList($sParent, $sListPattern);
} }
catch (\Exception $oException) catch (\Exception $oException) {}
{
}
} }
// TODO
// $mStatusFolders = null;
// if ($bUseListStatus)
// {
// $mStatusFolders = $this->oImapClient->FolderStatusList($sParent, $sListPattern);
// }
$aImapSubscribedFoldersHelper = null; $aImapSubscribedFoldersHelper = null;
if (\is_array($aSubscribedFolders)) if (\is_array($aSubscribedFolders))
{ {

View file

@ -1063,6 +1063,7 @@ class Actions
$aResult['DraftFolder'] = $oSettings->GetConf('DraftFolder', ''); $aResult['DraftFolder'] = $oSettings->GetConf('DraftFolder', '');
$aResult['SpamFolder'] = $oSettings->GetConf('SpamFolder', ''); $aResult['SpamFolder'] = $oSettings->GetConf('SpamFolder', '');
$aResult['TrashFolder'] = $oSettings->GetConf('TrashFolder', ''); $aResult['TrashFolder'] = $oSettings->GetConf('TrashFolder', '');
$aResult['NullFolder'] = $oSettings->GetConf('NullFolder', '');
$aResult['EditorDefaultType'] = $oSettings->GetConf('EditorDefaultType', $aResult['EditorDefaultType']); $aResult['EditorDefaultType'] = $oSettings->GetConf('EditorDefaultType', $aResult['EditorDefaultType']);
$aResult['ShowImages'] = (bool) $oSettings->GetConf('ShowImages', $aResult['ShowImages']); $aResult['ShowImages'] = (bool) $oSettings->GetConf('ShowImages', $aResult['ShowImages']);
$aResult['MPP'] = (int) $oSettings->GetConf('MPP', $aResult['MPP']); $aResult['MPP'] = (int) $oSettings->GetConf('MPP', $aResult['MPP']);
@ -1749,6 +1750,7 @@ class Actions
$oSettings->SetConf('DraftFolder', $this->GetActionParam('DraftFolder', '')); $oSettings->SetConf('DraftFolder', $this->GetActionParam('DraftFolder', ''));
$oSettings->SetConf('TrashFolder', $this->GetActionParam('TrashFolder', '')); $oSettings->SetConf('TrashFolder', $this->GetActionParam('TrashFolder', ''));
$oSettings->SetConf('SpamFolder', $this->GetActionParam('SpamFolder', '')); $oSettings->SetConf('SpamFolder', $this->GetActionParam('SpamFolder', ''));
$oSettings->SetConf('NullFolder', $this->GetActionParam('NullFolder', ''));
return $this->DefaultResponse(__FUNCTION__, return $this->DefaultResponse(__FUNCTION__,
$this->SettingsProvider()->Save($oAccount, $oSettings)); $this->SettingsProvider()->Save($oAccount, $oSettings));
@ -3151,40 +3153,61 @@ class Actions
return $aResult; return $aResult;
} }
private function systemFoldersNames() /**
* @staticvar array $aCache
* @param \RainLoop\Account $oAccount
*
* @return array
*/
private function systemFoldersNames($oAccount)
{ {
static $aCache = null; static $aCache = null;
if (null === $aCache) if (null === $aCache)
{ {
$aCache = array( $aCache = array(
'Sent' => \MailSo\Imap\Enumerations\FolderType::SENT, 'Sent' => \MailSo\Imap\Enumerations\FolderType::SENT,
'Send' => \MailSo\Imap\Enumerations\FolderType::SENT, 'Send' => \MailSo\Imap\Enumerations\FolderType::SENT,
'Sent Items' => \MailSo\Imap\Enumerations\FolderType::SENT,
'Sent Item' => \MailSo\Imap\Enumerations\FolderType::SENT, 'Sent Item' => \MailSo\Imap\Enumerations\FolderType::SENT,
'Send Items' => \MailSo\Imap\Enumerations\FolderType::SENT, 'Sent Items' => \MailSo\Imap\Enumerations\FolderType::SENT,
'Send Item' => \MailSo\Imap\Enumerations\FolderType::SENT, 'Send Item' => \MailSo\Imap\Enumerations\FolderType::SENT,
'Send Items' => \MailSo\Imap\Enumerations\FolderType::SENT,
'Sent Mail' => \MailSo\Imap\Enumerations\FolderType::SENT, 'Sent Mail' => \MailSo\Imap\Enumerations\FolderType::SENT,
'Sent Mails' => \MailSo\Imap\Enumerations\FolderType::SENT,
'Send Mail' => \MailSo\Imap\Enumerations\FolderType::SENT, 'Send Mail' => \MailSo\Imap\Enumerations\FolderType::SENT,
'Send Mails' => \MailSo\Imap\Enumerations\FolderType::SENT,
'Draft' => \MailSo\Imap\Enumerations\FolderType::DRAFTS, 'Draft' => \MailSo\Imap\Enumerations\FolderType::DRAFTS,
'Drafts' => \MailSo\Imap\Enumerations\FolderType::DRAFTS, 'Drafts' => \MailSo\Imap\Enumerations\FolderType::DRAFTS,
'Draft Mail' => \MailSo\Imap\Enumerations\FolderType::DRAFTS, 'Draft Mail' => \MailSo\Imap\Enumerations\FolderType::DRAFTS,
'Draft Mails' => \MailSo\Imap\Enumerations\FolderType::DRAFTS,
'Drafts Mail' => \MailSo\Imap\Enumerations\FolderType::DRAFTS,
'Drafts Mails' => \MailSo\Imap\Enumerations\FolderType::DRAFTS,
'Spam' => \MailSo\Imap\Enumerations\FolderType::SPAM, 'Spam' => \MailSo\Imap\Enumerations\FolderType::SPAM,
'Junk' => \MailSo\Imap\Enumerations\FolderType::SPAM, 'Junk' => \MailSo\Imap\Enumerations\FolderType::SPAM,
'Bulk Mail' => \MailSo\Imap\Enumerations\FolderType::SPAM, 'Bulk Mail' => \MailSo\Imap\Enumerations\FolderType::SPAM,
'Deleted' => \MailSo\Imap\Enumerations\FolderType::TRASH, 'Bulk Mails' => \MailSo\Imap\Enumerations\FolderType::SPAM,
'Trash' => \MailSo\Imap\Enumerations\FolderType::TRASH, 'Trash' => \MailSo\Imap\Enumerations\FolderType::TRASH,
'Deleted' => \MailSo\Imap\Enumerations\FolderType::TRASH,
'Bin' => \MailSo\Imap\Enumerations\FolderType::TRASH 'Bin' => \MailSo\Imap\Enumerations\FolderType::TRASH
); );
$this->Plugins()->RunHook('filter.system-folders-names', array($oAccount, &$aCache));
} }
return $aCache; return $aCache;
} }
/** /**
* @param \RainLoop\Account $oAccount
* @param \MailSo\Mail\FolderCollection $oFolders * @param \MailSo\Mail\FolderCollection $oFolders
* @param array $aResult * @param array $aResult
* @param bool $bXList = true
*/ */
private function recFoldersTypes($oFolders, &$aResult, $bXList = true) private function recFoldersTypes($oAccount, $oFolders, &$aResult, $bXList = true)
{ {
if ($oFolders) if ($oFolders)
{ {
@ -3209,12 +3232,12 @@ class Actions
$oSub = $oFolder->SubFolders(); $oSub = $oFolder->SubFolders();
if ($oSub && 0 < $oSub->Count()) if ($oSub && 0 < $oSub->Count())
{ {
$this->recFoldersTypes($oSub, $aResult, true); $this->recFoldersTypes($oAccount, $oSub, $aResult, true);
} }
} }
} }
$aMap = $this->systemFoldersNames(); $aMap = $this->systemFoldersNames($oAccount);
foreach ($aFolders as $oFolder) foreach ($aFolders as $oFolder)
{ {
$sName = $oFolder->Name(); $sName = $oFolder->Name();
@ -3235,7 +3258,7 @@ class Actions
$oSub = $oFolder->SubFolders(); $oSub = $oFolder->SubFolders();
if ($oSub && 0 < $oSub->Count()) if ($oSub && 0 < $oSub->Count())
{ {
$this->recFoldersTypes($oSub, $aResult, false); $this->recFoldersTypes($oAccount, $oSub, $aResult, false);
} }
} }
} }
@ -3253,24 +3276,93 @@ class Actions
$this->verifyCacheByKey($sRawKey); $this->verifyCacheByKey($sRawKey);
} }
$this->initMailClientConnection(); $oAccount = $this->initMailClientConnection();
$oFolderCollection = $this->MailClient()->Folders('', '*', $oFolderCollection = null;
!!$this->Config()->Get('labs', 'use_imap_list_status', false), $this->Plugins()->RunHook('filter.folders-before', array($oAccount, &$oFolderCollection));
!!$this->Config()->Get('labs', 'use_imap_list_subscribe', true)
); if (null === $oFolderCollection)
{
$oFolderCollection = $this->MailClient()->Folders('', '*',
!!$this->Config()->Get('labs', 'use_imap_list_subscribe', true)
);
}
$this->Plugins()->RunHook('filter.folders-post', array($oAccount, &$oFolderCollection));
if ($oFolderCollection instanceof \MailSo\Mail\FolderCollection) if ($oFolderCollection instanceof \MailSo\Mail\FolderCollection)
{ {
$oFolderCollection->FoldersHash = \md5(\implode("\x0", $this->recFoldersNames($oFolderCollection)));
$aSystemFolders = array(); $aSystemFolders = array();
$this->recFoldersTypes($oFolderCollection, $aSystemFolders); $this->recFoldersTypes($oAccount, $oFolderCollection, $aSystemFolders);
$oFolderCollection->SystemFolders = $aSystemFolders; $oFolderCollection->SystemFolders = $aSystemFolders;
$this->cacheByKey($sRawKey); if ($this->Config()->Get('labs', 'autocreate_system_folders', true))
{
$bDoItAgain = false;
$sNamespace = $oFolderCollection->GetNamespace();
$sNamespace = empty($sNamespace) ? '' : \substr($sNamespace, 0, -1);
$aList = array();
$aMap = $this->systemFoldersNames($oAccount);
if ('' === $this->GetActionParam('SentFolder', ''))
{
$aList[] = \MailSo\Imap\Enumerations\FolderType::SENT;
}
if ('' === $this->GetActionParam('DraftFolder', ''))
{
$aList[] = \MailSo\Imap\Enumerations\FolderType::DRAFTS;
}
if ('' === $this->GetActionParam('SpamFolder', ''))
{
$aList[] = \MailSo\Imap\Enumerations\FolderType::SPAM;
}
if ('' === $this->GetActionParam('TrashFolder', ''))
{
$aList[] = \MailSo\Imap\Enumerations\FolderType::TRASH;
}
$this->Plugins()->RunHook('filter.folders-system-types', array($oAccount, &$aList));
foreach ($aList as $iType)
{
if (!isset($aSystemFolders[$iType]))
{
$mFolderNameToCreate = \array_search($iType, $aMap);
if (!empty($mFolderNameToCreate))
{
if ($this->MailClient()->FolderCreate($mFolderNameToCreate, $sNamespace))
{
$bDoItAgain = true;
}
}
}
}
if ($bDoItAgain)
{
$oFolderCollection = $this->MailClient()->Folders('', '*',
!!$this->Config()->Get('labs', 'use_imap_list_subscribe', true)
);
if ($oFolderCollection)
{
$aSystemFolders = array();
$this->recFoldersTypes($oAccount, $oFolderCollection, $aSystemFolders);
$oFolderCollection->SystemFolders = $aSystemFolders;
}
}
}
if ($oFolderCollection)
{
$oFolderCollection->FoldersHash = \md5(\implode("\x0", $this->recFoldersNames($oFolderCollection)));
$this->cacheByKey($sRawKey);
}
} }
$this->Plugins()->RunHook('filter.folders-complete', array($oAccount, &$oFolderCollection));
return $this->DefaultResponse(__FUNCTION__, $oFolderCollection); return $this->DefaultResponse(__FUNCTION__, $oFolderCollection);
} }
@ -5266,7 +5358,7 @@ class Actions
public function GetLanguages() public function GetLanguages()
{ {
static $aCache = null; static $aCache = null;
if (is_array($aCache)) if (\is_array($aCache))
{ {
return $aCache; return $aCache;
} }
@ -5274,17 +5366,17 @@ class Actions
$bEn = false; $bEn = false;
$sList = array(); $sList = array();
$sDir = APP_VERSION_ROOT_PATH.'langs/'; $sDir = APP_VERSION_ROOT_PATH.'langs/';
if (@is_dir($sDir)) if (@\is_dir($sDir))
{ {
$rDirH = opendir($sDir); $rDirH = opendir($sDir);
if ($rDirH) if ($rDirH)
{ {
while (($sFile = readdir($rDirH)) !== false) while (($sFile = \readdir($rDirH)) !== false)
{ {
if ('.' !== $sFile{0} && is_file($sDir.'/'.$sFile) && '.ini' === substr($sFile, -4)) if ('.' !== $sFile{0} && \is_file($sDir.'/'.$sFile) && '.ini' === \substr($sFile, -4))
{ {
$sLang = strtolower(substr($sFile, 0, -4)); $sLang = \strtolower(\substr($sFile, 0, -4));
if (0 < strlen($sLang) && 'always' !== $sLang) if (0 < \strlen($sLang) && 'always' !== $sLang)
{ {
if (\in_array($sLang, array('en'))) if (\in_array($sLang, array('en')))
{ {
@ -5298,11 +5390,11 @@ class Actions
} }
} }
@closedir($rDirH); @\closedir($rDirH);
} }
} }
sort($sList); \sort($sList);
if ($bEn) if ($bEn)
{ {
\array_unshift($sList, 'en'); \array_unshift($sList, 'en');

View file

@ -209,11 +209,11 @@ Enables caching in the system'),
'determine_user_language' => array(true), 'determine_user_language' => array(true),
'use_imap_sort' => array(false), 'use_imap_sort' => array(false),
'use_imap_force_selection' => array(false), 'use_imap_force_selection' => array(false),
'use_imap_list_status' => array(false),
'use_imap_list_subscribe' => array(true), 'use_imap_list_subscribe' => array(true),
'use_imap_thread' => array(true), 'use_imap_thread' => array(true),
'use_imap_move' => array(true), 'use_imap_move' => array(true),
'use_imap_auth_plain' => array(false), 'use_imap_auth_plain' => array(false),
'autocreate_system_folders' => array(true),
'repo_type' => array('stable'), 'repo_type' => array('stable'),
'custom_repo' => array(''), 'custom_repo' => array(''),
'additional_repo' => array(''), 'additional_repo' => array(''),

View file

@ -1,26 +1,26 @@
<tr class="folder-item" data-bind="css: { 'selectable': selectable, 'gmailFolder' : isGmailFolder }"> <tr class="folder-item" data-bind="css: { 'selectable': selectable, 'gmailFolder' : isGmailFolder, 'system': isSystemFolder }">
<td> <td>
<span class="folder-padding" data-bind="css: 'deep-' + deep">&nbsp;</span> <span class="folder-padding" data-bind="css: 'deep-' + deep">&nbsp;</span>
<span class="folder-name" data-bind="text: name, visible: !edited(), css: { 'e-action': canBeEdited, 'can-be-edited': canBeEdited }, click: function (oFolder) { $root.folderForEdit(oFolder); }"></span> <span class="folder-name" data-bind="text: name, visible: !edited(), css: { 'e-action': canBeEdited, 'can-be-edited': canBeEdited }, click: function (oFolder) { $root.folderForEdit(oFolder); }"></span>
&nbsp; &nbsp;
<span class="folder-system-name" data-bind="text: manageFolderSystemName, visible: isSystemFolder"></span> <span class="folder-system-name" data-bind="text: manageFolderSystemName, visible: isSystemFolder"></span>
<input type="text" class="folder-name-input" data-bind="value: nameForEdit, visible: edited, hasfocus: edited, onEnter: function () { $root.folderEditOnEnter($data); }, onEsc: function () { $root.folderEditOnEsc($data); }" /> <input type="text" class="folder-name-input" data-bind="value: nameForEdit, visible: edited, hasfocus: edited, onEnter: function () { $root.folderEditOnEnter($data); }, onEsc: function () { $root.folderEditOnEsc($data); }" />
<a class="btn btn-small btn-small-small btn-danger pull-right button-delete" data-bind="css: {'delete-access': deleteAccess()}, click: function() { $root.deleteFolder($data); }"> <a class="btn btn-small btn-small-small btn-danger pull-right button-delete" data-bind="css: {'delete-access': deleteAccess()}, click: function() { $root.deleteFolder($data); }">
<span class="i18n" data-i18n-text="SETTINGS_FOLDERS/DELETING_ASK"></span> <span class="i18n" data-i18n-text="SETTINGS_FOLDERS/DELETING_ASK"></span>
</a> </a>
</td> </td>
<td> <td>
<span class="delete-folder" data-bind="visible: canBeDeleted() && !deleteAccess(), click: function (oFolder) { $root.folderForDeletion(oFolder); }"> <span class="delete-folder" data-bind="visible: canBeDeleted() && !deleteAccess(), click: function (oFolder) { $root.folderForDeletion(oFolder); }">
<i class="icon-trash"></i> <i class="icon-trash"></i>
</span> </span>
</td> </td>
<td> <td>
<span class="unsubscribe-folder" data-bind="visible: canBeSubScribed() && !subScribed(), click: function(oFolder) { $root.subscribeFolder(oFolder); }"> <span class="unsubscribe-folder" data-bind="visible: canBeSubScribed() && !subScribed(), click: function(oFolder) { $root.subscribeFolder(oFolder); }">
<i class="icon-eye"></i> <i class="icon-eye"></i>
</span> </span>
<span class="subscribe-folder" data-bind="visible: canBeSubScribed() && subScribed(), click: function(oFolder) { $root.unSubscribeFolder(oFolder); }"> <span class="subscribe-folder" data-bind="visible: canBeSubScribed() && subScribed(), click: function(oFolder) { $root.unSubscribeFolder(oFolder); }">
<i class="icon-eye"></i> <i class="icon-eye"></i>
</span> </span>
</td> </td>
</tr> </tr>
<!-- ko template: { name: 'SettingsFolderItem', foreach: subFolders } --><!-- /ko --> <!-- ko template: { name: 'SettingsFolderItem', foreach: subFolders } --><!-- /ko -->

View file

@ -1143,7 +1143,7 @@ table {
border-spacing: 0; border-spacing: 0;
} }
@charset "UTF-8"; /*@charset "UTF-8";*/
@font-face { @font-face {
font-family: "rainloop"; font-family: "rainloop";
@ -7903,6 +7903,19 @@ html.rl-message-fullscreen .messageView .b-content .buttonFull {
opacity: 0.5; opacity: 0.5;
filter: alpha(opacity=50); filter: alpha(opacity=50);
} }
/*.folderPaddingHelper(@i) {
(~".folder-padding.deep-@{i}") {
width: 15px * @i + 10px;
}
}*/
.b-settings-folders {
/* .folderPaddingHelper(1);
.folderPaddingHelper(2);
.folderPaddingHelper(3);
.folderPaddingHelper(4);
.folderPaddingHelper(5);*/
}
.b-settings-folders.ignore-folder-subscribe .subscribe-folder, .b-settings-folders.ignore-folder-subscribe .subscribe-folder,
.b-settings-folders.ignore-folder-subscribe .unsubscribe-folder { .b-settings-folders.ignore-folder-subscribe .unsubscribe-folder {
display: none; display: none;
@ -7953,6 +7966,10 @@ html.rl-message-fullscreen .messageView .b-content .buttonFull {
.b-settings-folders .list-table .folder-name-input { .b-settings-folders .list-table .folder-name-input {
border-width: 1px; border-width: 1px;
margin-bottom: 0; margin-bottom: 0;
margin-left: -4px;
}
.b-settings-folders .folder-item.system .folder-name {
font-weight: bold;
} }
.b-settings-folders .folder-item .button-delete { .b-settings-folders .folder-item .button-delete {
margin-right: 15px; margin-right: 15px;
@ -8426,10 +8443,3 @@ html.rl-message-fullscreen .messageView .b-content .buttonFull {
.editorFontStylePicker .editorFpFonts .editorFpFont { .editorFontStylePicker .editorFpFonts .editorFpFont {
padding: 5px; padding: 5px;
} }
input[type="text"],
input[type="password"],
input[type="email"],
input[type="search"] {
height: 20px;
line-height: 21px;
}

File diff suppressed because one or more lines are too long

View file

@ -7180,10 +7180,6 @@ function FolderModel()
} }
}, this); }, this);
this.canBeEdited = ko.computed(function () {
return Enums.FolderType.User === this.type();
}, this);
this.privateMessageCountAll = ko.observable(0); this.privateMessageCountAll = ko.observable(0);
this.privateMessageCountUnread = ko.observable(0); this.privateMessageCountUnread = ko.observable(0);
@ -7212,6 +7208,10 @@ FolderModel.prototype.initComputed = function ()
}); });
}, this); }, this);
this.canBeEdited = ko.computed(function () {
return Enums.FolderType.User === this.type() && this.existen && this.selectable;
}, this);
this.visible = ko.computed(function () { this.visible = ko.computed(function () {
var var
bSubScribed = this.subScribed(), bSubScribed = this.subScribed(),
@ -7689,7 +7689,7 @@ function PopupsFolderCreateViewModel()
RL.data().foldersCreating(false); RL.data().foldersCreating(false);
if (Enums.StorageResultType.Success === sResult && oData && oData.Result) if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
{ {
RL.folders(false); RL.folders();
} }
else else
{ {
@ -7791,7 +7791,8 @@ function PopupsFolderSystemViewModel()
'SentFolder': self.sentFolder(), 'SentFolder': self.sentFolder(),
'DraftFolder': self.draftFolder(), 'DraftFolder': self.draftFolder(),
'SpamFolder': self.spamFolder(), 'SpamFolder': self.spamFolder(),
'TrashFolder': self.trashFolder() 'TrashFolder': self.trashFolder(),
'NullFolder': 'NullFolder'
}); });
}, 1000); }, 1000);
@ -12730,7 +12731,7 @@ SettingsFolders.prototype.folderEditOnEnter = function (oFolder)
oData && oData.ErrorCode ? Utils.getNotification(oData.ErrorCode) : Utils.i18n('NOTIFICATIONS/CANT_RENAME_FOLDER')); oData && oData.ErrorCode ? Utils.getNotification(oData.ErrorCode) : Utils.i18n('NOTIFICATIONS/CANT_RENAME_FOLDER'));
} }
RL.folders(false); RL.folders();
}, oFolder.fullNameRaw, sEditName); }, oFolder.fullNameRaw, sEditName);
@ -12801,7 +12802,7 @@ SettingsFolders.prototype.deleteFolder = function (oFolderToRemove)
oData && oData.ErrorCode ? Utils.getNotification(oData.ErrorCode) : Utils.i18n('NOTIFICATIONS/CANT_DELETE_FOLDER')); oData && oData.ErrorCode ? Utils.getNotification(oData.ErrorCode) : Utils.i18n('NOTIFICATIONS/CANT_DELETE_FOLDER'));
} }
RL.folders(false); RL.folders();
}, oFolderToRemove.fullNameRaw); }, oFolderToRemove.fullNameRaw);
@ -13601,10 +13602,9 @@ WebMailDataStorage.prototype.initUidNextAndNewMessages = function (sFolder, sUid
/** /**
* @param {string} sNamespace * @param {string} sNamespace
* @param {Array} aFolders * @param {Array} aFolders
* @param {boolean} bCached
* @return {Array} * @return {Array}
*/ */
WebMailDataStorage.prototype.folderResponseParseRec = function (sNamespace, aFolders, bCached) WebMailDataStorage.prototype.folderResponseParseRec = function (sNamespace, aFolders)
{ {
var var
iIndex = 0, iIndex = 0,
@ -13616,8 +13616,6 @@ WebMailDataStorage.prototype.folderResponseParseRec = function (sNamespace, aFol
aList = [] aList = []
; ;
bCached = !!bCached;
for (iIndex = 0, iLen = aFolders.length; iIndex < iLen; iIndex++) for (iIndex = 0, iLen = aFolders.length; iIndex < iLen; iIndex++)
{ {
oFolder = aFolders[iIndex]; oFolder = aFolders[iIndex];
@ -13651,7 +13649,7 @@ WebMailDataStorage.prototype.folderResponseParseRec = function (sNamespace, aFol
{ {
oCacheFolder.collapsed(!Utils.isFolderExpanded(oCacheFolder.fullNameHash)); oCacheFolder.collapsed(!Utils.isFolderExpanded(oCacheFolder.fullNameHash));
if (!bCached && oFolder.Extended) if (oFolder.Extended)
{ {
if (oFolder.Extended.Hash) if (oFolder.Extended.Hash)
{ {
@ -13674,7 +13672,7 @@ WebMailDataStorage.prototype.folderResponseParseRec = function (sNamespace, aFol
aSubFolders['@Collection'] && Utils.isArray(aSubFolders['@Collection'])) aSubFolders['@Collection'] && Utils.isArray(aSubFolders['@Collection']))
{ {
oCacheFolder.subFolders( oCacheFolder.subFolders(
this.folderResponseParseRec(sNamespace, aSubFolders['@Collection'], bCached)); this.folderResponseParseRec(sNamespace, aSubFolders['@Collection']));
} }
aList.push(oCacheFolder); aList.push(oCacheFolder);
@ -13687,16 +13685,13 @@ WebMailDataStorage.prototype.folderResponseParseRec = function (sNamespace, aFol
/** /**
* @param {*} oData * @param {*} oData
* @param {boolean=} bCached = false
*/ */
WebMailDataStorage.prototype.setFolders = function (oData, bCached) WebMailDataStorage.prototype.setFolders = function (oData)
{ {
var var
aList = [], aList = [],
bUpdate = false, bUpdate = false,
oRLData = RL.data(), oRLData = RL.data(),
aFolders = oRLData.folderList(),
bFoldersFirst = 0 === aFolders.length,
fNormalizeFolder = function (sFolderFullNameRaw) { fNormalizeFolder = function (sFolderFullNameRaw) {
return ('' === sFolderFullNameRaw || Consts.Values.UnuseOptionValue === sFolderFullNameRaw || return ('' === sFolderFullNameRaw || Consts.Values.UnuseOptionValue === sFolderFullNameRaw ||
null !== RL.cache().getFolderFromCacheList(sFolderFullNameRaw)) ? sFolderFullNameRaw : ''; null !== RL.cache().getFolderFromCacheList(sFolderFullNameRaw)) ? sFolderFullNameRaw : '';
@ -13713,12 +13708,12 @@ WebMailDataStorage.prototype.setFolders = function (oData, bCached)
this.threading(!!RL.settingsGet('UseImapThread') && oData.Result.IsThreadsSupported && true); this.threading(!!RL.settingsGet('UseImapThread') && oData.Result.IsThreadsSupported && true);
aList = this.folderResponseParseRec(oRLData.namespace, oData.Result['@Collection'], !!bCached); aList = this.folderResponseParseRec(oRLData.namespace, oData.Result['@Collection']);
oRLData.folderList(aList); oRLData.folderList(aList);
if (oData.Result['SystemFolders'] && if (oData.Result['SystemFolders'] &&
'' === '' + RL.settingsGet('SentFolder') + RL.settingsGet('DraftFolder') + '' === '' + RL.settingsGet('SentFolder') + RL.settingsGet('DraftFolder') +
RL.settingsGet('SpamFolder') + RL.settingsGet('TrashFolder')) RL.settingsGet('SpamFolder') + RL.settingsGet('TrashFolder') + RL.settingsGet('NullFolder'))
{ {
// TODO Magic Numbers // TODO Magic Numbers
RL.settingsSet('SentFolder', oData.Result['SystemFolders'][2] || null); RL.settingsSet('SentFolder', oData.Result['SystemFolders'][2] || null);
@ -13740,19 +13735,12 @@ WebMailDataStorage.prototype.setFolders = function (oData, bCached)
'SentFolder': oRLData.sentFolder(), 'SentFolder': oRLData.sentFolder(),
'DraftFolder': oRLData.draftFolder(), 'DraftFolder': oRLData.draftFolder(),
'SpamFolder': oRLData.spamFolder(), 'SpamFolder': oRLData.spamFolder(),
'TrashFolder': oRLData.trashFolder() 'TrashFolder': oRLData.trashFolder(),
'NullFolder': 'NullFolder'
}); });
} }
if (!bCached) RL.local().set(Enums.ClientSideKeyName.FoldersLashHash, oData.Result.FoldersHash);
{
RL.local().set(Enums.ClientSideKeyName.FoldersLashHash, oData.Result.FoldersHash);
}
if (bFoldersFirst && bCached)
{
RL.folders(false);
}
} }
}; };
@ -14365,21 +14353,15 @@ _.extend(WebMailAjaxRemoteStorage.prototype, AbstractAjaxRemoteStorage.prototype
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
* @param {boolean=} bUseCache = true
*/ */
WebMailAjaxRemoteStorage.prototype.folders = function (fCallback, bUseCache) WebMailAjaxRemoteStorage.prototype.folders = function (fCallback)
{ {
var sFoldersHash = RL.data().lastFoldersHash; this.defaultRequest(fCallback, 'Folders', {
'SentFolder': RL.settingsGet('SentFolder'),
bUseCache = Utils.isUnd(bUseCache) ? false : !!bUseCache; 'DraftFolder': RL.settingsGet('DraftFolder'),
if (bUseCache && '' !== sFoldersHash) 'SpamFolder': RL.settingsGet('SpamFolder'),
{ 'TrashFolder': RL.settingsGet('TrashFolder')
this.defaultRequest(fCallback, 'Folders', {}, null, 'Folders/' + RL.data().projectHash() + '-' + sFoldersHash, ['Folders']); }, null, '', ['Folders']);
}
else
{
this.defaultRequest(fCallback, 'Folders', {}, null, '', ['Folders']);
}
}; };
/** /**
@ -16226,18 +16208,17 @@ RainLoopApp.prototype.recacheInboxMessageList = function ()
}; };
/** /**
* @param {boolean=} bUseCache = true
* @param {Function=} fCallback * @param {Function=} fCallback
*/ */
RainLoopApp.prototype.folders = function (bUseCache, fCallback) RainLoopApp.prototype.folders = function (fCallback)
{ {
this.data().foldersLoading(true); this.data().foldersLoading(true);
this.remote().folders(_.bind(function (sResult, oData, bCached) { this.remote().folders(_.bind(function (sResult, oData) {
RL.data().foldersLoading(false); RL.data().foldersLoading(false);
if (Enums.StorageResultType.Success === sResult) if (Enums.StorageResultType.Success === sResult)
{ {
this.data().setFolders(oData, bCached); this.data().setFolders(oData);
if (fCallback) if (fCallback)
{ {
fCallback(true); fCallback(true);
@ -16250,7 +16231,7 @@ RainLoopApp.prototype.folders = function (bUseCache, fCallback)
fCallback(false); fCallback(false);
} }
} }
}, this), bUseCache); }, this));
}; };
RainLoopApp.prototype.accountsAndIdentities = function () RainLoopApp.prototype.accountsAndIdentities = function ()
@ -16837,7 +16818,7 @@ RainLoopApp.prototype.bootstart = function ()
{ {
this.setTitle(Utils.i18n('TITLES/LOADING')); this.setTitle(Utils.i18n('TITLES/LOADING'));
this.folders(true, _.bind(function (bValue) { this.folders(_.bind(function (bValue) {
kn.hideLoading(); kn.hideLoading();

File diff suppressed because one or more lines are too long

View file

@ -1,4 +1,4 @@
@charset "UTF-8"; /*@charset "UTF-8";*/
@font-face { @font-face {
font-family: "rainloop"; font-family: "rainloop";