diff --git a/mail/inc/class.mail_ui.inc.php b/mail/inc/class.mail_ui.inc.php index c77772aeca..79a42ece87 100644 --- a/mail/inc/class.mail_ui.inc.php +++ b/mail/inc/class.mail_ui.inc.php @@ -4446,34 +4446,76 @@ $this->partID = $partID; $error = null; if ($_messageList=='all' || !empty($_messageList['msg'])) { - if ($_messageList=='all') + if (isset($_messageList['all']) && $_messageList['all']) { - // we have no folder information - $folder=null; + // we have both messageIds AND allFlag folder information + $uidA = self::splitRowID($_messageList['msg'][0]); + $folder = $uidA['folder']; // all messages in one set are supposed to be within the same folder + if (isset($_messageList['activeFilters']) && $_messageList['activeFilters']) + { + $query = $_messageList['activeFilters']; + if (!empty($query['search']) || !empty($query['filter'])) + { + //([filterName] => Schnellsuche[type] => quick[string] => ebay[status] => any + if (is_null(emailadmin_imapbase::$supportsORinQuery) || !isset(emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID])) + { + emailadmin_imapbase::$supportsORinQuery = egw_cache::getCache(egw_cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10); + if (!isset(emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID])) emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID]=true; + } + $filter = array('filterName' => (emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID]?lang('quicksearch'):lang('subject')),'type' => ($query['filter2']?$query['filter2']:(emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID]?'quick':'subject')),'string' => $query['search'],'status' => 'any'); + } + else + { + $filter = array(); + } + $messageList = array(); + $_sR = $this->mail_bo->getSortedList( + $folder, + $sort=0, + $reverse=1, + $filter, + $rByUid=true, + false + ); + $messageList = $_sR['match']->ids; + } + else + { + $messageList='all'; + } + try + { + //error_log(__METHOD__.__LINE__."->".print_r($messageList,true).' folder:'.$folder.' Method:'.$_forceDeleteMethod); + $this->mail_bo->deleteMessages(($messageList=='all' ? 'all':$messageList),$folder,(empty($_forceDeleteMethod)?'no':$_forceDeleteMethod)); + } + catch (egw_exception $e) + { + $error = str_replace('"',"'",$e->getMessage()); + } } else { $uidA = self::splitRowID($_messageList['msg'][0]); $folder = $uidA['folder']; // all messages in one set are supposed to be within the same folder - } - foreach($_messageList['msg'] as $rowID) - { - $hA = self::splitRowID($rowID); - $messageList[] = $hA['msgUID']; - } - try - { - //error_log(__METHOD__."->".print_r($messageList,true).' folder:'.$folder.' Method:'.$_forceDeleteMethod); - $this->mail_bo->deleteMessages(($_messageList=='all' ? 'all':$messageList),$folder,(empty($_forceDeleteMethod)?'no':$_forceDeleteMethod)); - } - catch (egw_exception $e) - { - $error = str_replace('"',"'",$e->getMessage()); + foreach($_messageList['msg'] as $rowID) + { + $hA = self::splitRowID($rowID); + $messageList[] = $hA['msgUID']; + } + try + { + //error_log(__METHOD__.__LINE__."->".print_r($messageList,true).' folder:'.$folder.' Method:'.$_forceDeleteMethod); + $this->mail_bo->deleteMessages($messageList,$folder,(empty($_forceDeleteMethod)?'no':$_forceDeleteMethod)); + } + catch (egw_exception $e) + { + $error = str_replace('"',"'",$e->getMessage()); + } } $response = egw_json_response::get(); if (empty($error)) { - $response->call('app.mail.mail_deleteMessagesShowResult',array('egw_message'=>lang('deleted %1 messages in %2',count($_messageList['msg']),$folder),'msg'=>$_messageList['msg'])); + $response->call('app.mail.mail_deleteMessagesShowResult',array('egw_message'=>lang('deleted %1 messages in %2',($messageList=='all'||$_messageList['all']?lang('all'):count($_messageList['msg'])),$folder),'msg'=>$_messageList['msg'])); } else { diff --git a/mail/js/app.js b/mail/js/app.js index 8d038f1e40..d09819465d 100644 --- a/mail/js/app.js +++ b/mail/js/app.js @@ -1270,6 +1270,8 @@ app.classes.mail = AppJS.extend( } } var msg = this.mail_getFormData(_elems); + msg['all'] = this.mail_checkAllSelected(_action,true); + if (msg['all']) msg['activeFilters'] = this.mail_getActiveFilters(_action); //alert(_action.id+','+ msg); if (!calledFromPopup) this.mail_setRowClass(_elems,'deleted'); this.mail_deleteMessages(msg,'no',calledFromPopup); @@ -1340,6 +1342,7 @@ app.classes.mail = AppJS.extend( message = this.mail_splitRowId(_msg['msg'][0]); if (message[3]) _foldernode = displayname = jQuery.base64Decode(message[3]); } + // Tell server egw.json('mail.mail_ui.ajax_deleteMessages',[_msg,(typeof _action == 'undefined'?'no':_action)]) .sendRequest(true); @@ -1351,7 +1354,7 @@ app.classes.mail = AppJS.extend( // ids.push(_msg['msg'][i].replace(/mail::/,'')); //} //this.egw.refresh(this.egw.lang("deleted %1 messages in %2",_msg['msg'].length,(displayname?displayname:egw.lang('current folder'))),'mail',ids,'delete'); - this.egw.message(this.egw.lang("deleted %1 messages in %2",_msg['msg'].length,(displayname?displayname:egw.lang('current Folder')))); + this.egw.message(this.egw.lang("deleted %1 messages in %2",(_msg['all']?egw.lang('all'):_msg['msg'].length),(displayname?displayname:egw.lang('current Folder')))); }, /** @@ -1368,7 +1371,14 @@ app.classes.mail = AppJS.extend( ids.push(_msg['msg'][i].replace(/mail::/,'')); } //this.egw.message(_msg['egw_message']); - this.egw.refresh(_msg['egw_message'],'mail',ids,'delete'); + if (_msg['all']) + { + this.egw.refresh(_msg['egw_message'],'mail'); + } + else + { + this.egw.refresh(_msg['egw_message'],'mail',ids,'delete'); + } }, /** @@ -2484,6 +2494,9 @@ app.classes.mail = AppJS.extend( //alert('mail_move('+messages.msg.join(',')+' --> '+target+')'); // TODO: Write move/copy function which cares about doing the same stuff // as the "onNodeSelect" function! + messages['all'] = this.mail_checkAllSelected(_action,true); + if (messages['all']) messages['activeFilters'] = this.mail_getActiveFilters(_action); + egw.json('mail.mail_ui.ajax_copyMessages',[target, messages, 'move']) .sendRequest(); var nm = this.et2.getWidgetById(this.nm_index); @@ -2505,6 +2518,9 @@ app.classes.mail = AppJS.extend( //alert('mail_copy('+messages.msg.join(',')+' --> '+target+')'); // TODO: Write move/copy function which cares about doing the same stuff // as the "onNodeSelect" function! + messages['all'] = this.mail_checkAllSelected(_action,true); + if (messages['all']) messages['activeFilters'] = this.mail_getActiveFilters(_action); + egw.json('mail.mail_ui.ajax_copyMessages',[target, messages]) .sendRequest(); // Server response contains refresh