From bc1578693cf7a0330eecbe7b5d8d5dde71830240 Mon Sep 17 00:00:00 2001 From: Hadi Nategh Date: Thu, 8 Jan 2015 17:06:56 +0000 Subject: [PATCH] Implement save into VFS for mail compose toolbar --- mail/inc/class.mail_compose.inc.php | 7 +++++++ mail/js/app.js | 24 +++++++++++++++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/mail/inc/class.mail_compose.inc.php b/mail/inc/class.mail_compose.inc.php index b32f6d6a06..a7f1e8f8ed 100644 --- a/mail/inc/class.mail_compose.inc.php +++ b/mail/inc/class.mail_compose.inc.php @@ -178,6 +178,13 @@ class mail_compose 'children' => array(), 'toolbarDefault' => true, 'hint' => 'Select the message priority tag' + ), + 'save2vfs' => array ( + 'caption' => 'Save to VFS', + 'icon' => 'filesave', + 'group' => ++$group, + 'onExecute' => 'javaScript:app.mail.compose_saveDraft2fm', + 'hint' => 'Save the drafted message as eml file into VFS' ) ); foreach (self::$priorities as $priority) diff --git a/mail/js/app.js b/mail/js/app.js index f09a3fe127..8109c33b3e 100644 --- a/mail/js/app.js +++ b/mail/js/app.js @@ -2567,7 +2567,8 @@ app.classes.mail = AppJS.extend( var url = window.egw_webserverUrl+'/index.php?'; url += 'menuaction=filemanager.filemanager_select.select'; // todo compose for Draft folder url += '&mode=saveas'; - var filename =dataElem.data.subject.replace(/[\f\n\t\v/\\:*#?<>\|]/g,"_"); + var subject = dataElem? dataElem.data.subject: _elems[0].subject; + var filename = subject.replace(/[\f\n\t\v/\\:*#?<>\|]/g,"_")|| 'unknown'; url += '&name='+encodeURIComponent(filename+'.eml'); url += '&mime=message'+encodeURIComponent('/')+'rfc822'; url += '&method=mail.mail_ui.vfsSaveMessage'; @@ -4275,4 +4276,25 @@ app.classes.mail = AppJS.extend( } } }, + + /** + * Save drafted compose as eml file into VFS + * @param {type} _action action + */ + compose_saveDraft2fm: function (_action) + { + var content = this.et2.getArrayMgr('content').data; + var subject = this.et2.getWidgetById('subject'); + var elem = {0:{id:"", subject:""}}; + if (typeof content != 'undefined' && content.lastDrafted && subject) + { + elem[0].id = content.lastDrafted; + elem[0].subject = subject.get_value(); + this.mail_save2fm(_action, elem); + } + else + { + et2_dialog.alert('You need to save the message as draft first before to be able to save it into VFS','Save into VFS','info'); + } + } });