diff --git a/addressbook/inc/class.addressbook_hooks.inc.php b/addressbook/inc/class.addressbook_hooks.inc.php index 7655fedf04..a32a6401fd 100644 --- a/addressbook/inc/class.addressbook_hooks.inc.php +++ b/addressbook/inc/class.addressbook_hooks.inc.php @@ -236,6 +236,7 @@ class addressbook_hooks $crm_list_options = array( '~edit~' => lang('Edit contact'), 'infolog' => lang('Open %1 CRM view', lang('infolog')), + 'infolog-organisation' => lang('infolog-organisation'), ); if($GLOBALS['egw_info']['user']['apps']['tracker']) { diff --git a/addressbook/inc/class.addressbook_ui.inc.php b/addressbook/inc/class.addressbook_ui.inc.php index d9902bbf7e..479487fa35 100644 --- a/addressbook/inc/class.addressbook_ui.inc.php +++ b/addressbook/inc/class.addressbook_ui.inc.php @@ -402,6 +402,10 @@ class addressbook_ui extends addressbook_bo { if ($GLOBALS['egw_info']['user']['apps'][$app]) $crm_count++; } + if($GLOBALS['egw_info']['user']['apps']['infolog']) + { + array_splice($crm_apps, 1, 0, 'infolog-organisation'); + } if($crm_count > 1) { foreach($crm_apps as $app) @@ -2697,6 +2701,9 @@ class addressbook_ui extends addressbook_bo { switch($crm_list) { + case 'infolog-organisation': + $contact_id = $this->get_all_org_contacts($contact_id); + // Fall through case 'infolog': case 'tracker': default: @@ -2905,6 +2912,13 @@ class addressbook_ui extends addressbook_bo // Sending it again (via ajax) will break the addressbook.view etemplate2 if($contact_id) { + // Show for whole organisation, not just selected contact + if($crm_list == 'infolog-organisation' && $content['org_name']) + { + $crm_list = str_replace('-organisation','',$crm_list); + $_query = Api\Cache::getSession('addressbook', 'index'); + $content['id'] = $this->get_all_org_contacts($content['id']); + } Api\Hooks::single(array( 'location' => 'addressbook_view', 'ab_id' => $content['id'] @@ -2912,6 +2926,36 @@ class addressbook_ui extends addressbook_bo } } + /** + * Get all the contact IDs in the given contact's organisation + * + * @param int $contact_id + * @param Array $query Optional base query + * + * @return array of contact IDs in the organisation + */ + function get_all_org_contacts($contact_id, $query = array()) + { + $contact = $this->read($contact_id); + $query['num_rows'] = -1; + $query['start'] = 0; + if(!array_key_exists('filter', $query)) + { + $query['filter'] = ''; + } + if(!is_array($query['col_filter'])) + { + $query['col_filter'] = array(); + } + $query['grouped_view'] = 'org_name:'.$contact['org_name']; + + $org_contacts = array(); + $readonlys = null; + $this->get_rows($query,$org_contacts,$readonlys,true); // true = only return the id's + + return $org_contacts ? $org_contacts : array($contact_id); + } + /** * convert email-address in compose link * diff --git a/addressbook/lang/egw_en.lang b/addressbook/lang/egw_en.lang index 2e6d48112b..a7444eac83 100644 --- a/addressbook/lang/egw_en.lang +++ b/addressbook/lang/egw_en.lang @@ -317,6 +317,7 @@ imports contacts into your addressbook from a vcard file. addressbook en Imports in %1 days (%2) is %3's birthday. addressbook en In %1 days (%2) is %3's birthday. income addressbook en Income infolog addressbook en InfoLog +infolog-organisation addressbook en Infolog CRM for organisation insert addressbook en Insert insufficent rights to delete this list! addressbook en Insufficient rights to delete this list! insufficent rights to edit this list! addressbook en Insufficent rights to edit this list!