mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-23 00:13:35 +01:00
* Mail: feature to allow to void the (configured) spam/junk folder on right-click action on foldertree
This commit is contained in:
parent
212e98ccdb
commit
acb4f11d24
@ -624,6 +624,19 @@ class mail_ui
|
||||
);
|
||||
break;
|
||||
}
|
||||
++$group; // put empty spam immediately in own group
|
||||
$junkFolder = $this->mail_bo->getJunkFolder();
|
||||
//error_log(__METHOD__.__LINE__.$junkFolder);
|
||||
if ($junkFolder && !empty($junkFolder))
|
||||
{
|
||||
$tree_actions['empty_spam'] = array(
|
||||
'caption' => 'empty spam',
|
||||
'icon' => 'dhtmlxtree/MailFolderJunk',
|
||||
'enabled' => 'javaScript:app.mail.spamfolder_enabled',
|
||||
'onExecute' => 'javaScript:app.mail.mail_emptySpam',
|
||||
'group' => $group,
|
||||
);
|
||||
}
|
||||
|
||||
// enforce global (group-specific) ACL
|
||||
if (!mail_hooks::access('aclmanagement'))
|
||||
@ -817,7 +830,7 @@ class mail_ui
|
||||
'child'=> (int)($acc_id != $_profileID || $folderObjects), // dynamic loading on unfold
|
||||
'parent' => '',
|
||||
// mark on account if Sieve is enabled
|
||||
'data' => array('sieve' => $accountObj->imapServer()->acc_sieve_enabled),
|
||||
'data' => array('sieve' => $accountObj->imapServer()->acc_sieve_enabled,'spamfolder'=>($accountObj->imapServer()->acc_folder_junk?true:false)),
|
||||
);
|
||||
$this->setOutStructure($oA, $out, self::$delimiter);
|
||||
|
||||
@ -4213,6 +4226,56 @@ class mail_ui
|
||||
$response->call('app.mail.mail_setQuotaDisplay',array('data'=>$content));
|
||||
}
|
||||
|
||||
/**
|
||||
* Empty spam/junk folder
|
||||
*
|
||||
* @param string $icServerID id of the server to empty its junkFolder
|
||||
* @param string $selectedFolder seleted(active) folder by nm filter
|
||||
* @return nothing
|
||||
*/
|
||||
function ajax_emptySpam($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)
|
||||
{
|
||||
//error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID);
|
||||
$this->changeProfile($icServerID);
|
||||
}
|
||||
$junkFolder = $this->mail_bo->getJunkFolder();
|
||||
if(!empty($junkFolder)) {
|
||||
if ($selectedFolder == $icServerID.self::$delimiter.$junkFolder)
|
||||
{
|
||||
// Lock the tree if the active folder is Trash folder
|
||||
$response->call('app.mail.lock_tree');
|
||||
}
|
||||
$this->mail_bo->deleteMessages('all',$junkFolder,'remove_immediately');
|
||||
|
||||
$heirarchyDelimeter = $this->mail_bo->getHierarchyDelimiter(true);
|
||||
$fShortName = array_pop(explode($heirarchyDelimeter, $junkFolder));
|
||||
$fStatus = array(
|
||||
$icServerID.self::$delimiter.$trashFolder => lang($fShortName)
|
||||
);
|
||||
//Call to reset folder status counter, after junkFolder triggered not from Junk folder
|
||||
//-as we don't have trash folder specific information available on client-side we need to deal with it on server
|
||||
$response->call('app.mail.mail_setFolderStatus',$fStatus);
|
||||
}
|
||||
if ($rememberServerID != $this->mail_bo->profileID)
|
||||
{
|
||||
$oldFolderInfo = $this->mail_bo->getFolderStatus($junkFolder,false,false,false);
|
||||
$response->call('egw.message',lang('empty junk'));
|
||||
$response->call('app.mail.mail_reloadNode',array($icServerID.self::$delimiter.$junkFolder=>$oldFolderInfo['shortDisplayName']));
|
||||
//error_log(__METHOD__.__LINE__.' change Profile to ->'.$rememberServerID);
|
||||
$this->changeProfile($rememberServerID);
|
||||
}
|
||||
else if ($selectedFolder == $icServerID.self::$delimiter.$junkFolder)
|
||||
{
|
||||
$response->call('egw.refresh',lang('empty junk'),'mail');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Empty trash folder
|
||||
*
|
||||
|
@ -1210,6 +1210,25 @@ app.classes.mail = AppJS.extend(
|
||||
return true;
|
||||
},
|
||||
|
||||
/**
|
||||
* Check if SpamFolder is enabled on that account
|
||||
*
|
||||
* SpamFolder enabled is stored as data { spamfolder: true/false } on account node.
|
||||
*
|
||||
* @param {object} _action
|
||||
* @param {object} _senders the representation of the tree leaf to be manipulated
|
||||
* @param {object} _currentNode
|
||||
*/
|
||||
spamfolder_enabled: function(_action,_senders,_currentNode)
|
||||
{
|
||||
var ftree = this.et2.getWidgetById(this.nm_index+'[foldertree]');
|
||||
var acc_id = _senders[0].id.split('::')[0];
|
||||
var node = ftree ? ftree.getNode(acc_id) : null;
|
||||
|
||||
return node && node.data && node.data.spamfolder;
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Check if Sieve is enabled on that account
|
||||
*
|
||||
@ -1574,6 +1593,38 @@ app.classes.mail = AppJS.extend(
|
||||
// setting class of row, the old style
|
||||
},
|
||||
|
||||
/**
|
||||
* mail_emptySpam
|
||||
*
|
||||
* @param {object} action
|
||||
* @param {object} _senders
|
||||
*/
|
||||
mail_emptySpam: 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 spam'));
|
||||
egw.json('mail.mail_ui.ajax_emptySpam',[server[0], activeFilters['selectedFolder']? activeFilters['selectedFolder']:null],function(){self.unlock_tree();})
|
||||
.sendRequest(true);
|
||||
|
||||
// Directly delete any trash cache for selected server
|
||||
if(window.localStorage)
|
||||
{
|
||||
for(var i = 0; i < window.localStorage.length; i++)
|
||||
{
|
||||
var key = window.localStorage.key(i);
|
||||
|
||||
// Find directly by what the key would look like
|
||||
if(key.indexOf('cached_fetch_mail::{"selectedFolder":"'+server[0]+'::') == 0 &&
|
||||
key.toLowerCase().indexOf(egw.lang('junk').toLowerCase()) > 0)
|
||||
{
|
||||
window.localStorage.removeItem(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* mail_emptyTrash
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user