From 934650c64ac06461b0e0b873db15ce9ef31722f0 Mon Sep 17 00:00:00 2001 From: Klaus Leithoff Date: Wed, 12 Feb 2014 10:56:44 +0000 Subject: [PATCH] fix a problem regarding the deletion from messages from display-popup; handle glitch of name used for downloading attachments --- mail/inc/class.mail_compose.inc.php | 8 +++-- mail/inc/class.mail_ui.inc.php | 7 ++-- mail/js/app.js | 54 ++++++++++++++++++++++++----- 3 files changed, 54 insertions(+), 15 deletions(-) diff --git a/mail/inc/class.mail_compose.inc.php b/mail/inc/class.mail_compose.inc.php index 2b88bcae31..20f756bb5f 100644 --- a/mail/inc/class.mail_compose.inc.php +++ b/mail/inc/class.mail_compose.inc.php @@ -1875,13 +1875,15 @@ class mail_compose //Import failed, download content anyway } } - header ("Content-Type: ".$attachment['type']."; name=\"". $attachment['filename'] ."\""); + //error_log(__METHOD__.__LINE__.'->'.array2string($attachment)); + $filename = ($attachment['name']?$attachment['name']:($attachment['filename']?$attachment['filename']:$mailbox.'_uid'.$uid.'_part'.$part)); + header ("Content-Type: ".$attachment['type']."; name=\"". $filename ."\""); if($_GET['mode'] == "save") { // ask for download - header ("Content-Disposition: attachment; filename=\"". $attachment['filename'] ."\""); + header ("Content-Disposition: attachment; filename=\"". $filename ."\""); } else { // display it - header ("Content-Disposition: inline; filename=\"". $attachment['filename'] ."\""); + header ("Content-Disposition: inline; filename=\"". $filename ."\""); } header("Expires: 0"); // the next headers are for IE and SSL diff --git a/mail/inc/class.mail_ui.inc.php b/mail/inc/class.mail_ui.inc.php index 28b40b2d3f..52d0eb13b8 100644 --- a/mail/inc/class.mail_ui.inc.php +++ b/mail/inc/class.mail_ui.inc.php @@ -408,7 +408,8 @@ class mail_ui // Tree does support this one 'add' => array( 'caption' => 'Add Folder', - 'onExecute' => 'javaScript:app.mail.mail_AddFolder' + 'onExecute' => 'javaScript:app.mail.mail_AddFolder', + 'enabled' => 'javaScript:app.mail.mail_CheckFolderNoSelect', ), 'edit' => array( 'caption' => 'Rename Folder', @@ -2457,14 +2458,14 @@ unset($query['actions']); } } //error_log(__METHOD__.__LINE__.'->'.array2string($attachment)); - $filename = ($attachment['filename']?$attachment['filename']:$mailbox.'_uid'.$uid.'_part'.$part); + $filename = ($attachment['name']?$attachment['name']:($attachment['filename']?$attachment['filename']:$mailbox.'_uid'.$uid.'_part'.$part)); header ("Content-Type: ".$attachment['type']."; name=\"". $filename ."\""); if($_GET['mode'] == "save") { // ask for download header ("Content-Disposition: attachment; filename=\"". $filename ."\""); } else { // display it - header ("Content-Disposition: inline; filename=\"". $attachment['filename'] ."\""); + header ("Content-Disposition: inline; filename=\"". $filename ."\""); } header("Expires: 0"); // the next headers are for IE and SSL diff --git a/mail/js/app.js b/mail/js/app.js index 00f108e8e5..c9d0617804 100644 --- a/mail/js/app.js +++ b/mail/js/app.js @@ -9,6 +9,10 @@ * @version $Id$ */ +/*egw:uses + phpgwapi.jquery.jquery.base64; +*/ + /** * UI for mail * @@ -1072,6 +1076,21 @@ app.classes.mail = AppJS.extend( */ _unseen_regexp: / \([0-9]+\)$/, + /** + * mail_splitRowId + */ + mail_splitRowId: function(_rowID) + { + res = _rowID.split('::'); + // as a rowID is perceeded by app::, should be mail! + if (res.length==4 && parseInt(res[0])!=NaN ) + { + // we have an own created rowID; prepend app=mail + res.unshift('mail'); + } + return res; + }, + /** * Delete mails - actually calls the backend function for deletion * takes in all arguments @@ -1080,21 +1099,31 @@ app.classes.mail = AppJS.extend( */ mail_deleteMessages: function(_msg,_action,_calledFromPopup) { + var message, ftree, _foldernode, displayname; ftree = this.et2.getWidgetById(this.nm_index+'[foldertree]'); - var _foldernode = ftree.getSelectedNode(); + if (ftree) + { + _foldernode = ftree.getSelectedNode(); - var displayname = _foldernode.label.replace(this._unseen_regexp, ''); + displayname = _foldernode.label.replace(this._unseen_regexp, ''); + } + else + { + 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); // Update list - var ids = []; - for (var i = 0; i < _msg['msg'].length; i++) - { - ids.push(_msg['msg'][i].replace(/mail::/,'')); - } - egw_refresh(this.egw.lang("deleted %1 messages in %2",_msg['msg'].length,displayname),'mail',ids,'delete'); + //var ids = []; + //for (var i = 0; i < _msg['msg'].length; i++) + //{ + // ids.push(_msg['msg'][i].replace(/mail::/,'')); + //} + //egw_refresh(this.egw.lang("deleted %1 messages in %2",_msg['msg'].length,(displayname?displayname:egw.lang('current folder'))),'mail',ids,'delete'); + egw_message(this.egw.lang("deleted %1 messages in %2",_msg['msg'].length,(displayname?displayname:egw.lang('current Folder')))); }, /** @@ -1104,7 +1133,14 @@ app.classes.mail = AppJS.extend( */ mail_deleteMessagesShowResult: function(_msg) { - egw_message(_msg['egw_message']); + // Update list + var ids = []; + for (var i = 0; i < _msg['msg'].length; i++) + { + ids.push(_msg['msg'][i].replace(/mail::/,'')); + } + //egw_message(_msg['egw_message']); + egw_refresh(_msg['egw_message'],'mail',ids,'delete'); }, /**