* Addressbook: allow to add a customfield to link title of addressbook

This commit is contained in:
Ralf Becker 2013-05-10 08:52:06 +00:00
parent 6c4a7c5f34
commit f8a53514be
4 changed files with 50 additions and 4 deletions

View File

@ -435,6 +435,22 @@ class addressbook_bo extends addressbook_so
return $this->prefs['fileas_default'] ? $this->prefs['fileas_default'] : $this->fileas_types[0]; 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 * 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']; if ($contact['n_fileas']) return $contact['n_fileas'];
$type = null; $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(); $titles = array();
if (($contacts =& $this->search(array('contact_id' => $ids),false))) if (($contacts =& $this->search(array('contact_id' => $ids),false)))
{ {
$ids = array();
foreach($contacts as $contact) 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) // 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 ($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))) 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) 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'].'>' : ''); ($options['type'] === 'email' ? ' <'.$contact['email'].'>' : '');
// show category color // show category color
if ($contact['cat_id'] && ($color = etemplate::cats2color($contact['cat_id']))) if ($contact['cat_id'] && ($color = etemplate::cats2color($contact['cat_id'])))

View File

@ -207,6 +207,15 @@ class addressbook_hooks
'admin' => false, 'admin' => false,
'default'=> 'org_name: n_family, n_given', '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( $settings['addr_format'] = array(
'type' => 'select', 'type' => 'select',
'label' => 'Default address format', 'label' => 'Default address format',
@ -316,7 +325,7 @@ class addressbook_hooks
'values' => $options, 'values' => $options,
'label' => 'Export definition to use for nextmatch export', 'label' => 'Export definition to use for nextmatch export',
'name' => 'nextmatch-export-definition', '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, 'run_lang' => false,
'xmlrpc' => True, 'xmlrpc' => True,
'admin' => False, 'admin' => False,

View File

@ -18,6 +18,7 @@ accounts addressbook de Benutzerkonten
actions addressbook de Befehle actions addressbook de Befehle
add %1 addressbook de %1 hinzufügen add %1 addressbook de %1 hinzufügen
add a contact to this organisation addressbook de Einen Kontakt zu dieser Organisation 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 contact addressbook de Neuen Kontakt anlegen
add a new infolog addressbook de Neuen Infolog Eintrag hinzufügen add a new infolog addressbook de Neuen Infolog Eintrag hinzufügen
add a new list addressbook de Neuen Verteiler 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 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 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 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 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 or delete categories addressbook de Kategorien hinzufügen oder löschen
add to distribution list addressbook de Zu Verteilerliste hinzufügen add to distribution list addressbook de Zu Verteilerliste hinzufügen

View File

@ -18,6 +18,7 @@ accounts addressbook en Accounts
actions addressbook en Actions actions addressbook en Actions
add %1 addressbook en Add %1 add %1 addressbook en Add %1
add a contact to this organisation addressbook en Add a contact to this organisation 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 contact addressbook en Add a new contact
add a new infolog addressbook en Add a new InfoLog add a new infolog addressbook en Add a new InfoLog
add a new list addressbook en Add a new list 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 appointment addressbook en Add appointment
add business email of whole distribution list? addressbook en Add business email of whole distribution list? 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 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 emails of whole distribution list? addressbook en Add emails of whole distribution list?
add or delete categories addressbook en Add or delete categories add or delete categories addressbook en Add or delete categories
add to distribution list addressbook en Add to distribution list add to distribution list addressbook en Add to distribution list