diff --git a/addressbook/inc/class.addressbook_ui.inc.php b/addressbook/inc/class.addressbook_ui.inc.php index 075494c4f4..6133bb948f 100644 --- a/addressbook/inc/class.addressbook_ui.inc.php +++ b/addressbook/inc/class.addressbook_ui.inc.php @@ -592,17 +592,15 @@ class addressbook_ui extends addressbook_bo 'calendar_view' => array( 'caption' => 'Show', 'icon' => 'view', - 'url' => 'menuaction=calendar.calendar_uilist.listview&filter=all&owner=0,c$id&ajax=true', + 'onExecute' => 'javaScript:app.addressbook.view_calendar', 'targetapp' => 'calendar', // open in calendar tab, - 'disableClass' => 'contact_organisation', 'hideOnDisabled' => true, ), '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:app.addressbook.add_cal', // call server for org-view only + 'onExecute' => 'javaScript:app.addressbook.add_cal', ), ), ); @@ -1091,7 +1089,7 @@ window.egw_LAB.wait(function() { $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 + case 'calendar_view': // show calendar for org-views, although all 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', diff --git a/addressbook/js/app.js b/addressbook/js/app.js index 6c004000e4..a480742ae3 100644 --- a/addressbook/js/app.js +++ b/addressbook/js/app.js @@ -157,6 +157,57 @@ app.classes.addressbook = AppJS.extend( } }, + /** + * Open the calender to view the selected contacts + * @param {egwAction} _action + * @param {egwActionObject[]} _senders + */ + view_calendar: function(_action, _senders) + { + var extras = { + filter: 'all', + owner: [] + }; + var orgs = []; + for(var i = 0; i < _senders.length; i++) + { + // Remove UID prefix for just contact_id + var ids = _senders[i].id.split('::'); + ids.shift(); + ids = ids.join('::'); + + // Orgs need to get all the contact IDs first + if (ids.substr(0,9) == 'org_name:') + { + orgs.push(ids); + } + else + { + extras.owner.push('c'+ids); + } + } + + if(orgs.length > 0) + { + // Get organisation contacts, then show infolog list + this.egw.json('addressbook.addressbook_ui.ajax_organisation_contacts', + [orgs], + function(contacts) { + for(var i = 0; i < contacts.length; i++) + { + extras.owner.push('c'+contacts[i]); + } + extras.owner = extras.owner.join(','); + this.egw.open('','calendar','list',extras,'calendar'); + },this,true,this + ).sendRequest(); + } + else + { + extras.owner = extras.owner.join(','); + egw.open('', 'calendar', 'list', extras, 'calendar'); + } + }, /** * Add appointment or show calendar for selected contacts, call default nm_action after some checks *