From 50d02bff8115f5250be686f92d091e2f068d5e9e Mon Sep 17 00:00:00 2001 From: Hadi Nategh Date: Thu, 12 Jul 2018 15:42:07 +0200 Subject: [PATCH] Try to warn user when switching between filemodes in compose dialog, also indicate each filemode with an icon. --- filemanager/js/app.js | 1 + mail/inc/class.mail_compose.inc.php | 14 +++++++- mail/js/app.js | 50 ++++++++++++++++++++++++++++- mail/templates/default/compose.xet | 2 ++ 4 files changed, 65 insertions(+), 2 deletions(-) diff --git a/filemanager/js/app.js b/filemanager/js/app.js index 106fcff696..c325b534b5 100644 --- a/filemanager/js/app.js +++ b/filemanager/js/app.js @@ -266,6 +266,7 @@ app.classes.filemanager = AppJS.extend( params['preset[file]['+i+']'] = 'vfs://default'+attachments[i]; content.data.files.file.push('vfs://default'+attachments[i]); } + content.data.files.filemode = params['preset[filemode]']; // always open compose in html mode, as attachment links look a lot nicer in html params.mimeType = 'html'; return egw.openWithinWindow("mail", "setCompose", content, params, /mail.mail_compose.compose/); diff --git a/mail/inc/class.mail_compose.inc.php b/mail/inc/class.mail_compose.inc.php index a0f9158c38..c185c0ae11 100644 --- a/mail/inc/class.mail_compose.inc.php +++ b/mail/inc/class.mail_compose.inc.php @@ -317,6 +317,7 @@ class mail_compose if ($_content['appendix_data']) { $appendix_data = json_decode($_content['appendix_data'], true); + $_content['appendix_data'] = ''; } if ($appendix_data['emails']) @@ -332,7 +333,6 @@ class mail_compose } $suppressSigOnTop = true; unset($appendix_data); - $_content['appendix_data'] = ''; } if (isset($_GET['reply_id'])) $replyID = $_GET['reply_id']; @@ -811,6 +811,9 @@ class mail_compose { $_REQUEST['preset']['file'] = $appendix_data['files']['file']; $_REQUEST['preset']['type'] = $appendix_data['files']['type']; + $_content['filemode'] = !empty($appendix_data['files']['filemode']) && + isset(Vfs\Sharing::$modes[$appendix_data['files']['filemode']]) ? + $appendix_data['files']['filemode'] : Vfs\Sharing::ATTACH; $suppressSigOnTop = true; unset($_content['attachments']); $this->addPresetFiles($content, $insertSigOnTop, true); @@ -1370,6 +1373,15 @@ class mail_compose if (is_array($content[$f])) $content[$f]= self::resolveEmailAddressList ($content[$f]); } + // set filemode icons for all attachments + foreach($content['attachments'] as &$attach) + { + $attach['is_dir'] = is_dir($attach['file']); + $attach['filemode_icon'] = !is_dir($attach['file']) && + ($content['filemode'] == Vfs\Sharing::READONLY || $content['filemode'] == Vfs\Sharing::WRITABLE) + ? Vfs\Sharing::LINK : $content['filemode']; + } + $content['to'] = self::resolveEmailAddressList($content['to']); //error_log(__METHOD__.__LINE__.array2string($content)); $etpl->exec('mail.mail_compose.compose',$content,$sel_options,array(),$preserv,2); diff --git a/mail/js/app.js b/mail/js/app.js index 00b4d84a19..75ac1de99d 100644 --- a/mail/js/app.js +++ b/mail/js/app.js @@ -694,7 +694,28 @@ app.classes.mail = AppJS.extend( { var w = compose_et2[0].widgetContainer.getWidgetById('appendix_data'); w.set_value(JSON.stringify(content[field])); - return compose_et2[0].widgetContainer._inst.submit(); + var filemode = compose_et2[0].widgetContainer.getWidgetById('filemode'); + if (content[field]['files'] && content[field]['files']['filemode'] + && filemode && filemode.get_value() != content[field]['files']['filemode']) + { + var filemode_label = filemode.options.select_options[content[field]['files']['filemode']]['label']; + var files = content[field]['files']['file'].join('\n\r'); + et2_dialog.show_dialog(function(_button){ + if (_button == 2) + { + compose_et2[0].widgetContainer._inst.submit(); + } + }, + this.egw.lang( + 'Be aware by adding all selected files as %1 mode, it will also change all existing attachments in the list to %2 mode as well. \n\r \n\r\ Would you like to proceed?', + filemode_label, filemode_label, files), + this.egw.lang('Add files as %1', filemode_label), '', et2_dialog.BUTTONS_YES_NO, et2_dialog.WARNING_MESSAGE); + return; + } + else + { + return compose_et2[0].widgetContainer._inst.submit(); + } } var widget = compose_et2[0].widgetContainer.getWidgetById(field); @@ -4970,6 +4991,33 @@ app.classes.mail = AppJS.extend( this.egw.message(this.egw.lang('Writable sharing requires EPL version!'), 'info'); _widget.set_value('share_ro'); } + + if (typeof _node != 'undefined') + { + et2_dialog.alert(this.egw.lang( + 'Be aware that all attachments will be sent as %1!', + _widget.options.select_options[_widget.get_value()]['label'] + ), + this.egw.lang( + 'Filemode has been switched to %1', + _widget.options.select_options[_widget.get_value()]['label'] + ), + et2_dialog.WARNING_MESSAGE); + var content = this.et2.getArrayMgr('content'); + var attachments = this.et2.getWidgetById('attachments'); + for (var i in content.data.attachments) + { + if (content.data.attachments[i] == null) + { + content.data.attachments.splice(i,1); + continue; + } + content.data.attachments[i]['filemode_icon'] = !content.data.attachments[i]['is_dir'] && + (_widget.get_value() == 'share_rw' || _widget.get_value() == 'share_ro') ? 'link' : _widget.get_value(); + } + this.et2.setArrayMgr('content', content); + attachments.set_value({content:content.data.attachments}); + } }, /** diff --git a/mail/templates/default/compose.xet b/mail/templates/default/compose.xet index 5a3dc9c25c..dd47b9038b 100644 --- a/mail/templates/default/compose.xet +++ b/mail/templates/default/compose.xet @@ -100,6 +100,7 @@ + @@ -107,6 +108,7 @@ +