Get addressbook organisation list -> Infolog -> View linked Infolog entries context menu option working, with organisation list still working after.

This commit is contained in:
Nathan Gray 2014-03-18 19:20:29 +00:00
parent 08c67c8eed
commit 44bddc9eb7
2 changed files with 55 additions and 6 deletions

View File

@ -517,7 +517,8 @@ class addressbook_ui extends addressbook_bo
'infolog' => array( 'infolog' => array(
'caption' => lang('View linked InfoLog entries'), 'caption' => lang('View linked InfoLog entries'),
'icon' => 'infolog/navbar', 'icon' => 'infolog/navbar',
'onExecute' => 'javaScript:app.addressbook.view_infolog' 'onExecute' => 'javaScript:app.addressbook.view_infolog',
'allowOnMultiple' => true,
), ),
'infolog_add' => array( 'infolog_add' => array(
'caption' => 'Add a new Infolog', 'caption' => 'Add a new Infolog',
@ -744,6 +745,36 @@ window.egw_LAB.wait(function() {
return $this->index($content,$msg,true); 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 * Show the infologs of an whole organisation
* *

View File

@ -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 {egwAction} _action Select action
* @param {egwActionObject[]} _senders Selected contact(s) * @param {egwActionObject[]} _senders Selected contact(s)
*/ */
@ -183,6 +183,7 @@ app.classes.addressbook = AppJS.extend(
action_id: [], action_id: [],
action_title: _senders.length > 1 ? this.egw.lang('selected contacts') : '' action_title: _senders.length > 1 ? this.egw.lang('selected contacts') : ''
}; };
var orgs = [];
for(var i = 0; i < _senders.length; i++) for(var i = 0; i < _senders.length; i++)
{ {
// Remove UID prefix for just contact_id // Remove UID prefix for just contact_id
@ -190,15 +191,32 @@ app.classes.addressbook = AppJS.extend(
ids.shift(); ids.shift();
ids = ids.join('::'); 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:') 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');
}
}, },
/** /**