From 5941ff6a268cc50b67685029282d99ca6aa3d9a0 Mon Sep 17 00:00:00 2001 From: Hadi Nategh <hn@stylite.de> Date: Mon, 11 Aug 2014 14:02:26 +0000 Subject: [PATCH] Refresh the nm and lock the tree if current active folder is the Trash Folder, when calling "Empty Trash" action, otherwise no need to refresh or lock the tree --- mail/inc/class.mail_ui.inc.php | 16 ++++++++++------ mail/js/app.js | 5 +++-- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/mail/inc/class.mail_ui.inc.php b/mail/inc/class.mail_ui.inc.php index 8ecf2029f7..2d9cbdfb66 100644 --- a/mail/inc/class.mail_ui.inc.php +++ b/mail/inc/class.mail_ui.inc.php @@ -4010,16 +4010,17 @@ class mail_ui } /** - * empty trash folder - its called via json, so the function must start with ajax (or the class-name must contain ajax) + * Empty trash folder * * @param string $icServerID id of the server to empty its trashFolder + * @param string $selectedFolder seleted(active) folder by nm filter * @return nothing */ - function ajax_emptyTrash($icServerID) + function ajax_emptyTrash($icServerID, $selectedFolder) { //error_log(__METHOD__.__LINE__.' '.$icServerID); translation::add_app('mail'); - + $response = egw_json_response::get(); $rememberServerID = $this->mail_bo->profileID; if ($icServerID && $icServerID != $this->mail_bo->profileID) { @@ -4028,20 +4029,23 @@ class mail_ui } $trashFolder = $this->mail_bo->getTrashFolder(); if(!empty($trashFolder)) { + if ($selectedFolder == $icServerID.self::$delimiter.$trashFolder) + { + // Lock the tree if the active folder is Trash folder + $response->call('app.mail.lock_tree'); + } $this->mail_bo->compressFolder($trashFolder); } if ($rememberServerID != $this->mail_bo->profileID) { $oldFolderInfo = $this->mail_bo->getFolderStatus($trashFolder,false,false,false); - $response = egw_json_response::get(); $response->call('egw.message',lang('empty trash')); $response->call('app.mail.mail_reloadNode',array($icServerID.self::$delimiter.$trashFolder=>$oldFolderInfo['shortDisplayName'])); //error_log(__METHOD__.__LINE__.' change Profile to ->'.$rememberServerID); $this->changeProfile($rememberServerID); } - else + else if ($selectedFolder == $icServerID.self::$delimiter.$trashFolder) { - $response = egw_json_response::get(); $response->call('egw.refresh',lang('empty trash'),'mail'); } } diff --git a/mail/js/app.js b/mail/js/app.js index 32d35040e7..06321e48be 100644 --- a/mail/js/app.js +++ b/mail/js/app.js @@ -1472,10 +1472,11 @@ app.classes.mail = AppJS.extend( */ mail_emptyTrash: function(action,_senders) { var server = _senders[0].iface.id.split('::'); + var activeFilters = this.mail_getActiveFilters(); var self = this; + this.egw.message(this.egw.lang('empty trash')); - this.lock_tree(); - egw.json('mail.mail_ui.ajax_emptyTrash',[server[0]],function(){self.unlock_tree();}) + egw.json('mail.mail_ui.ajax_emptyTrash',[server[0], activeFilters['selectedFolder']? activeFilters['selectedFolder']:null],function(){self.unlock_tree()}) .sendRequest(true); },