diff --git a/addressbook/inc/class.addressbook_ui.inc.php b/addressbook/inc/class.addressbook_ui.inc.php index 04f44f0a69..c89804b443 100644 --- a/addressbook/inc/class.addressbook_ui.inc.php +++ b/addressbook/inc/class.addressbook_ui.inc.php @@ -517,7 +517,8 @@ class addressbook_ui extends addressbook_bo 'infolog' => array( 'caption' => lang('View linked InfoLog entries'), 'icon' => 'infolog/navbar', - 'onExecute' => 'javaScript:app.addressbook.view_infolog' + 'onExecute' => 'javaScript:app.addressbook.view_infolog', + 'allowOnMultiple' => true, ), 'infolog_add' => array( 'caption' => 'Add a new Infolog', @@ -744,6 +745,36 @@ window.egw_LAB.wait(function() { return $this->index($content,$msg,true); } + /** + * Return the contacts in an organisation via AJAX + * + * @param string|string[] $org Organisation ID + * @param mixed $query Query filters (category, etc) to use, or null to use session + * @return array + */ + public function ajax_organisation_contacts($org, $query = null) + { + $org_contacts = array(); + $query = $query == null ? egw_session::appsession('index','addressbook') : $query; + $query['num_rows'] = -1; // all + if(!is_array($query['col_filter'])) $query['col_filter'] = array(); + + if(!is_array($org)) $org = array($org); + foreach($org as $org_name) + { + error_log("Org: $org_name"); + $query['org_view'] = $org_name; + $checked = array(); + $count = $this->get_rows($query,$checked,$readonlys,true); // true = only return the id's + error_log("Count: $count " . array2string($checked)); + if($checked[0]) + { + $org_contacts = array_merge($org_contacts,$checked); + } + } + egw_json_response::get()->data(array_unique($org_contacts)); + } + /** * Show the infologs of an whole organisation * diff --git a/addressbook/js/app.js b/addressbook/js/app.js index 2104b920cc..663615d2e9 100644 --- a/addressbook/js/app.js +++ b/addressbook/js/app.js @@ -172,7 +172,7 @@ app.classes.addressbook = AppJS.extend( }, /** - * View infolog entries linked to selected contact - just one, infolog fails with multiple + * View infolog entries linked to selected contact * @param {egwAction} _action Select action * @param {egwActionObject[]} _senders Selected contact(s) */ @@ -183,6 +183,7 @@ app.classes.addressbook = AppJS.extend( action_id: [], action_title: _senders.length > 1 ? this.egw.lang('selected contacts') : '' }; + var orgs = []; for(var i = 0; i < _senders.length; i++) { // Remove UID prefix for just contact_id @@ -190,15 +191,32 @@ app.classes.addressbook = AppJS.extend( ids.shift(); ids = ids.join('::'); - // Orgs go through the server to get all IDs + // Orgs need to get all the contact IDs first if (ids.substr(0,9) == 'org_name:') { - return nm_action(_action,_senders); + orgs.push(ids); + } + else + { + extras.action_id.push(ids); } - extras.action_id.push(ids); } - egw.open('', 'infolog', 'list', extras, 'infolog'); + if(orgs.length > 0) + { + // Get organisation contacts, then show infolog list + this.egw.json('addressbook.addressbook_ui.ajax_organisation_contacts', + [orgs], + function(contacts) { + extras.action_id = extras.action_id.concat(contacts); + this.egw.open('','infolog','list',extras,'infolog'); + },this,true,this + ).sendRequest(); + } + else + { + egw.open('', 'infolog', 'list', extras, 'infolog'); + } }, /**