From f8a53514be411ad81333c7cb26b07eaac2014ace Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Fri, 10 May 2013 08:52:06 +0000 Subject: [PATCH] * Addressbook: allow to add a customfield to link title of addressbook --- addressbook/inc/class.addressbook_bo.inc.php | 39 +++++++++++++++++-- .../inc/class.addressbook_hooks.inc.php | 11 +++++- addressbook/lang/egw_de.lang | 2 + addressbook/lang/egw_en.lang | 2 + 4 files changed, 50 insertions(+), 4 deletions(-) diff --git a/addressbook/inc/class.addressbook_bo.inc.php b/addressbook/inc/class.addressbook_bo.inc.php index 1d2b1f3b29..cddd4a5db6 100755 --- a/addressbook/inc/class.addressbook_bo.inc.php +++ b/addressbook/inc/class.addressbook_bo.inc.php @@ -435,6 +435,22 @@ class addressbook_bo extends addressbook_so return $this->prefs['fileas_default'] ? $this->prefs['fileas_default'] : $this->fileas_types[0]; } + /** + * get selectbox options for the customfields + * + * @param array $field=null + * @return array with options: + */ + public static function cf_options() + { + $cf_fields = config::get_customfields('addressbook',TRUE); + foreach ($cf_fields as $key => $value ) + { + $options[$key]= $value['label']; + } + return $options; + } + /** * get selectbox options for the fileas types with translated labels, or real content * @@ -1359,7 +1375,12 @@ class addressbook_bo extends addressbook_so if ($contact['n_fileas']) return $contact['n_fileas']; $type = null; } - return $this->fileas($contact,$type); + $title = $this->fileas($contact,$type); + if ($this->prefs['link_title_cf'] && $contact['#'.$this->prefs['link_title_cf']]) + { + $title .= ' ' . $contact['#'.$this->prefs['link_title_cf']]; + } + return $title ; } /** @@ -1375,9 +1396,15 @@ class addressbook_bo extends addressbook_so $titles = array(); if (($contacts =& $this->search(array('contact_id' => $ids),false))) { + $ids = array(); foreach($contacts as $contact) { - $titles[$contact['id']] = $this->link_title($contact); + $ids[] = $contact['id']; + } + $cfs = $this->read_customfields($ids); + foreach($contacts as $contact) + { + $titles[$contact['id']] = $this->link_title($contact+(array)$cfs[$contact['id']]); } } // we assume all not returned contacts are not readable for the user (as we report all deleted contacts to egw_link) @@ -1416,9 +1443,15 @@ class addressbook_bo extends addressbook_so if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts']) $filter['account_id'] = null; if (($contacts =& parent::search($criteria,false,'org_name,n_family,n_given,cat_id,contact_email','','%',false,'OR', $limit, $filter))) { + $ids = array(); foreach($contacts as $contact) { - $result[$contact['id']] = $this->link_title($contact). + $ids[] = $contact['id']; + } + $cfs = $this->read_customfields($ids); + foreach($contacts as $contact) + { + $result[$contact['id']] = $this->link_title($contact+(array)$cfs[$contact['id']]). ($options['type'] === 'email' ? ' <'.$contact['email'].'>' : ''); // show category color if ($contact['cat_id'] && ($color = etemplate::cats2color($contact['cat_id']))) diff --git a/addressbook/inc/class.addressbook_hooks.inc.php b/addressbook/inc/class.addressbook_hooks.inc.php index 2cfe71acb6..e2a8efe56a 100644 --- a/addressbook/inc/class.addressbook_hooks.inc.php +++ b/addressbook/inc/class.addressbook_hooks.inc.php @@ -207,6 +207,15 @@ class addressbook_hooks 'admin' => false, 'default'=> 'org_name: n_family, n_given', ); + $settings['link_title_cf'] = array( + 'type' => 'select', + 'label' => 'Add a customfield to link title', + 'name' => 'link_title_cf', + 'values' => addressbook_bo::cf_options(), + 'help' => 'Add customfield to links of addressbook, which displays in other applications. The default value is none customfield.', + 'xmlrpc' => True, + 'admin' => false, + ); $settings['addr_format'] = array( 'type' => 'select', 'label' => 'Default address format', @@ -316,7 +325,7 @@ class addressbook_hooks 'values' => $options, 'label' => 'Export definition to use for nextmatch export', 'name' => 'nextmatch-export-definition', - 'help' => lang('If you specify an export definition, it will be used when you export'), + 'help' => 'If you specify an export definition, it will be used when you export', 'run_lang' => false, 'xmlrpc' => True, 'admin' => False, diff --git a/addressbook/lang/egw_de.lang b/addressbook/lang/egw_de.lang index 6c18d17102..3a422ed162 100644 --- a/addressbook/lang/egw_de.lang +++ b/addressbook/lang/egw_de.lang @@ -18,6 +18,7 @@ accounts addressbook de Benutzerkonten actions addressbook de Befehle add %1 addressbook de %1 hinzufügen add a contact to this organisation addressbook de Einen Kontakt zu dieser Organisation hinzufügen +add a customfield to link title addressbook de Benutzerdefiniertes Feld zu Link-Titel hinzufügen add a new contact addressbook de Neuen Kontakt anlegen add a new infolog addressbook de Neuen Infolog Eintrag hinzufügen add a new list addressbook de Neuen Verteiler hinzufügen @@ -25,6 +26,7 @@ add a single entry by passing the fields. addressbook de Hinzufügen eines einze add appointment addressbook de Termin hinzufügen add business email of whole distribution list? addressbook de E-Mail geschäftl. der kompletten Liste hinzufügen? add custom field addressbook de Benutzerdefiniertes Feld hinzufügen +add customfield to links of addressbook, which displays in other applications. the default value is none customfield. addressbook de Fügt ein benutzerdefiniertes Feld zum Titel der Verknüpfung eines Kontakts hinzu. Dieser wird in anderen Anwendungen angezeigt. Die Vorgabe ist kein benutzerdefiniertes Feld hinzuzufügen. add emails of whole distribution list? addressbook de E-Mails der gesamten Verteilerliste hinzufügen? add or delete categories addressbook de Kategorien hinzufügen oder löschen add to distribution list addressbook de Zu Verteilerliste hinzufügen diff --git a/addressbook/lang/egw_en.lang b/addressbook/lang/egw_en.lang index 5cbbeb146d..e36d0d4489 100644 --- a/addressbook/lang/egw_en.lang +++ b/addressbook/lang/egw_en.lang @@ -18,6 +18,7 @@ accounts addressbook en Accounts actions addressbook en Actions add %1 addressbook en Add %1 add a contact to this organisation addressbook en Add a contact to this organisation +add a customfield to link title addressbook en Add a customfield to link title add a new contact addressbook en Add a new contact add a new infolog addressbook en Add a new InfoLog add a new list addressbook en Add a new list @@ -25,6 +26,7 @@ add a single entry by passing the fields. addressbook en Add a single entry by p add appointment addressbook en Add appointment add business email of whole distribution list? addressbook en Add business email of whole distribution list? add custom field addressbook en Add custom field +add customfield to links of addressbook, which displays in other applications. the default value is none customfield. addressbook en Add customfield to links of addressbook, which displays in other applications. The default value is none customfield. add emails of whole distribution list? addressbook en Add emails of whole distribution list? add or delete categories addressbook en Add or delete categories add to distribution list addressbook en Add to distribution list