From f71782a8e0ff956f045a96f6fe1c8ce901364310 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Thu, 5 Jan 2012 04:10:54 +0000 Subject: [PATCH] * Addressbook: show calendar of contact(s) via context menu --- addressbook/inc/class.addressbook_ui.inc.php | 33 ++++++++++++++++---- addressbook/js/app.js | 6 ++-- 2 files changed, 30 insertions(+), 9 deletions(-) diff --git a/addressbook/inc/class.addressbook_ui.inc.php b/addressbook/inc/class.addressbook_ui.inc.php index 93b473366f..f31f695606 100644 --- a/addressbook/inc/class.addressbook_ui.inc.php +++ b/addressbook/inc/class.addressbook_ui.inc.php @@ -477,7 +477,7 @@ class addressbook_ui extends addressbook_bo 'children' => $add_lists, 'prefix' => 'to_list_', 'icon' => 'foldertree_nolines_plus', - 'enabled' => ($add_lists?true:false), // if there are editable lists, allow to add a contact to one of them, + 'enabled' => ($add_lists?true:false), // if there are editable lists, allow to add a contact to one of them, //'disableClass' => 'rowNoEdit', // wether you are allowed to edit the contact or not, as you alter a list, not the contact ), 'remove_from_list' => array( @@ -551,11 +551,23 @@ class addressbook_ui extends addressbook_bo { $actions['calendar'] = array( 'icon' => 'calendar/navbar', - 'caption' => 'Add appointment', - 'url' => 'menuaction=calendar.calendar_uiforms.edit&participants=c$id', - 'popup' => egw_link::get_registry('calendar', 'add_popup'), + 'caption' => 'Calendar', 'group' => $group, - 'onExecute' => 'javaScript:add_cal', // call server for org-view only + 'children' => array( + 'calendar_view' => array( + 'caption' => 'Show', + 'icon' => 'view', + 'url' => 'menuaction=calendar.calendar_uiviews.index&owner=c$id', + 'onExecute' => 'javaScript:add_cal', // call server for org-view only + ), + 'calendar_add' => array( + 'caption' => 'Add appointment', + 'icon' => 'new', + 'url' => 'menuaction=calendar.calendar_uiforms.edit&participants=c$id', + 'popup' => egw_link::get_registry('calendar', 'add_popup'), + 'onExecute' => 'javaScript:add_cal', // call server for org-view only + ), + ), ); } if ($GLOBALS['egw_info']['user']['apps']['filemanager']) @@ -566,6 +578,8 @@ class addressbook_ui extends addressbook_bo 'url' => 'menuaction=filemanager.filemanager_ui.index&path=/apps/addressbook/$id', 'allowOnMultiple' => false, 'group' => $group, + // disable for for org-views, as it needs contact-ids + 'enabled' => !isset($this->org_views[(string) $org_view]), ); } @@ -885,7 +899,7 @@ class addressbook_ui extends addressbook_bo $msg = ''; // no message, as we send none in javascript too and users sees opening popup return false; - case 'calendar': // add appointment for org-views, other views are handled directly in javascript + case 'calendar_add': // add appointment for org-views, other views are handled directly in javascript list($width,$height) = explode('x',egw_link::get_registry('calendar', 'add_popup')); egw_framework::set_onload( "egw_openWindowCentered2('".egw::link('/index.php',array( @@ -894,6 +908,13 @@ class addressbook_ui extends addressbook_bo ))."','_blank',$width,$height);"); $msg = ''; // no message, as we send none in javascript too and users sees opening popup return false; + + case 'calendar_view': // show calendar for org-views, other views are handled directly in javascript + list($width,$height) = explode('x',egw_link::get_registry('calendar', 'add_popup')); + egw::redirect_link('/index.php',array( + 'menuaction' => 'calendar.calendar_uiviews.index', + 'owner' => 'c'.implode(',c',$checked), + )); } foreach($checked as $id) { diff --git a/addressbook/js/app.js b/addressbook/js/app.js index fb46d07634..df379fe20d 100644 --- a/addressbook/js/app.js +++ b/addressbook/js/app.js @@ -10,7 +10,7 @@ /** - * Add appointment for selected contacts, call default nm_action after some checks + * Add appointment or show calendar for selected contacts, call default nm_action after some checks * * @param _action * @param _senders @@ -25,13 +25,13 @@ function add_cal(_action, _senders) else { // call nm_action's popup, but already replace id's in url, because they need to be prefix with a "c" - _action.data.nm_action = "popup"; + if (_action.data.popup) _action.data.nm_action = "popup"; var ids = ""; for (var i = 0; i < _senders.length; i++) { ids += "c" + _senders[i].id + ((i < _senders.length - 1) ? "," : ""); } - _action.data.url = _action.data.url.replace(/participants=.*$/,"participants="+ids); + _action.data.url = _action.data.url.replace(/=c%24id/,"="+ids); } nm_action(_action, _senders); }