diff --git a/mail/inc/class.mail_compose.inc.php b/mail/inc/class.mail_compose.inc.php index 4b538f0974..1ccb72e78a 100644 --- a/mail/inc/class.mail_compose.inc.php +++ b/mail/inc/class.mail_compose.inc.php @@ -101,6 +101,86 @@ class mail_compose $this->mailPreferences =& $this->mail_bo->mailPreferences; } } + + /** + * Provide toolbar actions used for compose toolbar + * + * @return array an array of actions + */ + function getToolbarActions() + { + $actions = array( + 'send' => array( + 'caption' => 'Send', + 'icon' => 'mail_send', + 'group' => ++$group, + 'onExecute' => 'javaScript:app.mail.compose_submitAction', + 'hint' => 'Send' + ), + 'button[saveAsDraft]' => array( + 'caption' => 'Save', + 'icon' => 'save', + 'group' => ++$group, + 'onExecute' => 'javaScript:app.mail.saveAsDraft', + 'hint' => 'Save as Draft' + ), + 'button[saveAsDraftAndPrint]' => array( + 'caption' => 'Print', + 'icon' => 'print', + 'group' => ++$group, + 'onExecute' => 'javaScript:app.mail.saveAsDraft', + 'hint' => 'Save as Draft and Print' + ), + 'selectFromVFSForCompose' => array( + 'caption' => 'VFS', + 'icon' => 'filemanager', + 'group' => ++$group, + 'onExecute' => 'javaScript:app.mail.compose_triggerWidget', + 'hint' => 'Select file(s) from VFS' + ), + 'uploadForCompose' => array( + 'caption' => 'Upload files...', + 'icon' => 'attach', + 'group' => ++$group, + 'onExecute' => 'javaScript:app.mail.compose_triggerWidget', + 'hint' => 'Select files to upload' + ), + 'to_infolog' => array( + 'caption' => 'Infolog', + 'icon' => 'infolog/navbar', + 'group' => ++$group, + 'checkbox' => true, + 'hint' => 'check to save as infolog on send' + ), + 'to_tracker' => array( + 'caption' => 'Tracker', + 'icon' => 'tracker/navbar', + 'group' => $group, + 'checkbox' => true, + 'hint' => 'check to save as trackerentry on send' + ), + 'disposition' => array( + 'caption' => 'Notification', + 'icon' => 'notification', + 'group' => ++$group, + 'checkbox' => true, + 'hint' => 'check to recieve a notification when the message is read (note: not all clients support this and/or the reciever may not authorize the notification)' + ), + 'prty' => array( + 'caption' => 'Priority', + 'group' => ++$group, + 'children' => array(), + 'hint' => '', + ) + ); + foreach (self::$priorities as $priority) + { + $actions['prty']['children'][$priority] = array( + 'caption' => $priority, + ); + } + return $actions; + } /** * Compose dialog @@ -252,14 +332,14 @@ class mail_compose } //error_log(__METHOD__.__LINE__.array2string($_content)); if (!empty($_content['serverID']) && $_content['serverID'] != $this->mail_bo->profileID && - ($_content['button']['send'] || $_content['button']['saveAsDraft']||$_content['button']['saveAsDraftAndPrint']) + ($_content['toolbar'] === 'send' || $_content['button']['saveAsDraft']||$_content['button']['saveAsDraftAndPrint']) ) { $this->changeProfile($_content['serverID']); $composeProfile = $this->mail_bo->profileID; } $buttonClicked = false; - if ($_content['button']['send']) + if ($_content['toolbar'] === 'send') { $buttonClicked = $suppressSigOnTop = true; $sendOK = true; @@ -1120,7 +1200,8 @@ class mail_compose if (!isset($content['priority']) || empty($content['priority'])) $content['priority']=3; //$GLOBALS['egw_info']['flags']['currentapp'] = 'mail';//should not be needed $etpl = new etemplate_new('mail.compose'); - + + $etpl->setElementAttribute('toolbar', 'actions', $this->getToolbarActions()); if ($content['mimeType']=='html') { //mode="$cont[rtfEditorFeatures]" validation_rules="$cont[validation_rules]" base_href="$cont[upload_dir]" diff --git a/mail/js/app.js b/mail/js/app.js index 8acf1ee80e..11f82a59a4 100644 --- a/mail/js/app.js +++ b/mail/js/app.js @@ -3185,13 +3185,13 @@ app.classes.mail = AppJS.extend( * @param {widget object} _widget * @param {string} _action autosaving trigger action */ - saveAsDraft: function(_egw, _widget, _action) + saveAsDraft: function(_egw_action, _action) { //this.et2_obj.submit(); var content = this.et2.getArrayMgr('content').data; - if (_widget ) + if (_egw_action ) { - var action = _action == 'autosaving'?_action: _widget.id; + var action = _action == 'autosaving'?_action: _egw_action.id; } var widgets = ['from','to','cc','bcc','subject','folder','replyto','mailaccount', 'mail_htmltext', 'mail_plaintext', 'lastDrafted']; @@ -4071,8 +4071,8 @@ app.classes.mail = AppJS.extend( }); //Make used email-tag list widgets in mail compose droppable emailTags.droppable({ - access:'.ms-sel-item', - + accept:'.ms-sel-item', + /** * Run after a draggable email item dropped over one of the email-taglists * -Set the dropped item to the dropped current target widget @@ -4218,5 +4218,61 @@ app.classes.mail = AppJS.extend( if (widget) return widget.get_value(); break; } - } + }, + + /** + * Set the relevant widget to toolbar actions and submit + * @param {type} _action toolbar action + */ + compose_submitAction: function (_action) + { + var action_widget = ['to_infolog','to_tracker','priority']; + var toolbar = this.et2.getWidgetById('toolbar'); + for(var i=0;action_widget.length>i;i++) + { + var widget = this.et2.getWidgetById(action_widget[i]); + if (toolbar._actionManager) + { + var action_event = toolbar._actionManager.getActionById(action_widget[i]== 'priority'?'prty':action_widget[i]); + if (typeof action_event.checkbox != 'undefined' && action_event.checkbox) + { + widget.set_value(action_event.checked?"on":"off"); + } + else if (action_event && toolbar.options) + { + var regex = new RegExp(toolbar.options.actions[action_event.id]['value'],'ig'); + jQuery(widget.options.select_options).each(function(_i,_a){ + + if (_a.label.match(regex)) + { + widget.set_value(_a.value); + } + }) + + } + } + } + + this.et2._inst.submit(null,null,true); + }, + + /** + * Triger relative widget via its toolbar identical action + * @param {type} _action toolbar action + */ + compose_triggerWidget:function (_action) + { + var widget = this.et2.getWidgetById(_action.id); + if (widget) + { + switch(widget.id) + { + case 'uploadForCompose': + document.getElementById('mail-compose_uploadForCompose').click(); + break; + default: + widget.click(); + } + } + }, }); diff --git a/mail/templates/default/app.css b/mail/templates/default/app.css index b143d78f06..264d5d0c4f 100644 --- a/mail/templates/default/app.css +++ b/mail/templates/default/app.css @@ -858,4 +858,16 @@ span#mail-compose_replyto_expander { margin-left: 12px; text-align: right; padding: 0; +} +/*Make file uploads in compose dialog invisible*/ +div.mail-compose_toolbar_assist div.mail-compose_fileselector, #mail-compose_selectFromVFSForCompose, div.mail-compose_toolbar_assist { + display:none; +} +/*Make file uploads in compose dialog invisible*/ +div.mail-compose_toolbar_assist div.mail-compose_fileselector, #mail-compose_selectFromVFSForCompose, div.mail-compose_toolbar_assist { + display:none; +} + +div.mailComposeHeaderSection>table { + padding-top: 10px; } \ No newline at end of file diff --git a/mail/templates/default/compose.xet b/mail/templates/default/compose.xet index 8b3b3d60d0..7f453932b4 100644 --- a/mail/templates/default/compose.xet +++ b/mail/templates/default/compose.xet @@ -3,40 +3,18 @@