From c50d8007e2793e488bfdb1212d3c59de0f32d043 Mon Sep 17 00:00:00 2001 From: nathangray Date: Tue, 19 Jun 2018 14:35:08 -0600 Subject: [PATCH] * Calendar - add context menu actions for email & documents to non-list views --- calendar/inc/class.calendar_uiforms.inc.php | 8 +++++ calendar/inc/class.calendar_uilist.inc.php | 23 ++++++++++++++ calendar/inc/class.calendar_uiviews.inc.php | 13 +++++--- calendar/js/app.js | 34 +++++++++++++++++++++ 4 files changed, 74 insertions(+), 4 deletions(-) diff --git a/calendar/inc/class.calendar_uiforms.inc.php b/calendar/inc/class.calendar_uiforms.inc.php index 02c62f403d..d627399641 100644 --- a/calendar/inc/class.calendar_uiforms.inc.php +++ b/calendar/inc/class.calendar_uiforms.inc.php @@ -1318,6 +1318,14 @@ class calendar_uiforms extends calendar_ui { //error_log(__METHOD__.__LINE__.' '.$uid.':'.array2string($status)); if (empty($status)) continue; + if(!is_array($status)) + { + calendar_so::split_status($status,$quantity,$role); + $status = array( + 'status' => $status, + 'uid' => $uid, + ); + } $toadd = ''; if ((isset($status['status']) && $status['status'] == 'R') || (isset($status['uid']) && $status['uid'] == $this->user)) continue; diff --git a/calendar/inc/class.calendar_uilist.inc.php b/calendar/inc/class.calendar_uilist.inc.php index 50c5fe35cf..6e3ddb7d19 100644 --- a/calendar/inc/class.calendar_uilist.inc.php +++ b/calendar/inc/class.calendar_uilist.inc.php @@ -954,6 +954,29 @@ class calendar_uilist extends calendar_ui 'popup' => Link::get_registry('infolog', 'add_popup'), ); } + if($GLOBALS['egw_info']['user']['apps']['mail']) + { + //Send to email + $actions['email'] = array( + 'caption' => 'Email', + 'icon' => 'mail/navbar', + 'hideOnDisabled' => true, + 'group' => $group, + 'allowOnMultiple' => false, + 'children' => array( + 'mail' => array( + 'caption' => 'Mail all participants', + 'onExecute' => 'javaScript:app.calendar.action_mail', + + ), + 'sendrequest' => array( + 'caption' => 'Meetingrequest to all participants', + 'onExecute' => 'javaScript:app.calendar.action_mail', + ) + ), + ); + } + if ($GLOBALS['egw_info']['user']['apps']['timesheet']) { $actions['timesheet'] = array( // interactive add for a single event diff --git a/calendar/inc/class.calendar_uiviews.inc.php b/calendar/inc/class.calendar_uiviews.inc.php index c06268ee24..bd95bb5517 100644 --- a/calendar/inc/class.calendar_uiviews.inc.php +++ b/calendar/inc/class.calendar_uiviews.inc.php @@ -931,11 +931,16 @@ class calendar_uiviews extends calendar_ui $actions['infolog_app']['open'] = '{"app": "infolog", "type": "add", "extra": "type=task&action=$app&action_id=$id"}'; $actions['infolog_app']['onExecute'] = 'javaScript:app.calendar.action_open'; } - if ($actions['documents']) + // Get documents working with other views + $set_execute = function(&$action) use (&$set_execute) { - // TODO: See if we can get this working sensibly - $actions['documents']['enabled'] = false; - } + $action['onExecute'] = 'javaScript:app.calendar.action_merge'; + foreach($action['children'] as &$child) + { + $set_execute($child); + } + }; + $set_execute($actions['documents']); $actions['ical']['onExecute'] = 'javaScript:app.calendar.ical'; $actions['delete']['onExecute'] = 'javaScript:app.calendar.delete'; diff --git a/calendar/js/app.js b/calendar/js/app.js index 7c865f5de5..b556d71dff 100644 --- a/calendar/js/app.js +++ b/calendar/js/app.js @@ -1788,6 +1788,40 @@ app.classes.calendar = (function(){ "use strict"; return AppJS.extend( } }, + /** + * Send a mail or meeting request to event participants + * + * @param {egwAction} _action + * @param {egwActionObject[]} _selected + */ + action_mail: function(_action, _selected) + { + var data = egw.dataGetUIDdata(_selected[0].id) || {data:{}}; + var event = data.data; + this.egw.json('calendar.calendar_uiforms.ajax_custom_mail', + [event, false, _action.id==='sendrequest'], + null,null,null,null + ).sendRequest(); + }, + + /** + * Insert selected event(s) into a document + * + * Actually, just pass it off to the nextmatch + * + * @param {egwAction} _action + * @param {egwActionObject[]} _selected + */ + action_merge: function(_action, _selected) + { + var ids = {ids:[]}; + for(var i = 0; i < _selected.length; i++) + { + ids.ids.push(_selected[i].id); + } + nm_action(egw_getAppActionManager('calendar').getActionById('nm').getActionById(_action.id), _selected, null, ids); + }, + /** * Sidebox merge *