make the display of addressbook-links configurable:

- own sorting (default: Company: Last name, First name)
- Company: Last name, First name
- Company, Department: Last name, First name
- Company, City: Last name, First name
- Company, Department, City: Last name, First name
This commit is contained in:
Ralf Becker 2006-10-19 08:50:25 +00:00
parent 6a35c9812c
commit 01286bbc9b
5 changed files with 49 additions and 26 deletions

View File

@ -105,6 +105,12 @@ class bocontacts extends socontacts
* @var string/boolean
*/
var $error;
/**
* Addressbook preferences of the user
*
* @var array
*/
var $prefs;
function bocontacts($contact_app='addressbook')
{
@ -113,19 +119,8 @@ class bocontacts extends socontacts
$this->tz_offset_s = 3600 * $GLOBALS['egw_info']['user']['preferences']['common']['tz_offset'];
$this->now_su = time() + $this->tz_offset_s;
/* foreach(array(
'so' => $appname. 'soadb',
) as $my => $app_class)
{
list(,$class) = explode('.',$app_class);
$this->prefs =& $GLOBALS['egw_info']['user']['preferences']['addressbook'];
if (!is_object($GLOBALS['egw']->$class))
{
$GLOBALS['egw']->$class =& CreateObject($app_class);
}
$this->$my = &$GLOBALS['egw']->$class;
}*/
$this->contact_fields = array(
'id' => lang('Contact ID'),
'tid' => lang('Type'),
@ -239,14 +234,21 @@ class bocontacts extends socontacts
function fileas($contact,$type=null)
{
if (is_null($type)) $type = $contact['fileas_type'];
if (!$type || !in_array($type,$this->fileas_types)) $type = $this->fileas_types[0];
if (!$type) $type = $this->fileas_types[0];
if (strstr($type,'n_fn')) $contact['n_fn'] = $this->fullname($contact);
$fileas = str_replace(array('n_prefix','n_given','n_middle','n_family','n_suffix','n_fn','org_name'),
array($contact['n_prefix'],$contact['n_given'],$contact['n_middle'],$contact['n_family'],$contact['n_suffix'],$contact['n_fn'],$contact['org_name']),$type);
return $fileas{0} == ':' ? substr($fileas,2) : $fileas;
$fileas = str_replace(array('n_prefix','n_given','n_middle','n_family','n_suffix','n_fn','org_name','org_unit','adr_one_locality'),
array($contact['n_prefix'],$contact['n_given'],$contact['n_middle'],$contact['n_family'],$contact['n_suffix'],
$contact['n_fn'],$contact['org_name'],$contact['org_unit'],$contact['adr_one_locality']),$type);
// removing empty delimiters, caused by empty contact fields
$fileas = str_replace(array(', : ',': , ',', , ',': : '),array(': ',': ',', ',': '),$fileas);
while ($fileas{0} == ':' || $fileas{0} == ',') $fileas = substr($fileas,2);
while (substr($fileas,-2) == ': ' || substr($fileas,-2) == ', ') $fileas = substr($fileas,0,-2);
//echo "<p align=right>bocontacts::fileas(,$type)='$fileas'</p>\n";
return $fileas;
}
/**
@ -289,6 +291,8 @@ class bocontacts extends socontacts
'n_suffix' => lang('suffix'),
'n_fn' => lang('full name'),
'org_name' => lang('company'),
'org_unit' => lang('department'),
'adr_one_locality' => lang('city'),
);
foreach($labels as $name => $label)
{
@ -692,10 +696,11 @@ class bocontacts extends socontacts
/**
* get title for a contact identified by $contact
*
* Is called as hook to participate in the linking
* Is called as hook to participate in the linking. The format is determined by the link_title preference.
*
* @param int/string/array $contact int/string id or array with contact
* @param string/boolean string with the title, null if contact does not exitst, false if no perms to view it
* @return string
*/
function link_title($contact)
{
@ -707,7 +712,13 @@ class bocontacts extends socontacts
{
return $contact;
}
return $contact['n_fileas'] ? $contact['n_fileas'] : $this->fileas($contact);
$type = $this->prefs['link_title'];
if (!$type || $type === 'n_fileas')
{
if ($contact['n_fileas']) return $contact['n_fileas'];
$type = null;
}
return $this->fileas($contact,$type);
}
/**

View File

@ -199,6 +199,21 @@ class contacts_admin_prefs
'admin' => False,
);
}
$GLOBALS['settings']['link_title'] = array(
'type' => 'select',
'label' => 'Link title for contacts show',
'name' => 'link_title',
'values' => array(
'n_fileas' => lang('own sorting').' ('.lang('default').': '.lang('Company').': '.lang('lastname').', '.lang('firstname').')',
'org_name: n_family, n_given' => lang('Company').': '.lang('lastname').', '.lang('firstname'),
'org_name, org_unit: n_family, n_given' => lang('Company').', '.lang('Department').': '.lang('lastname').', '.lang('firstname'),
'org_name, adr_one_locality: n_family, n_given' => lang('Company').', '.lang('City').': '.lang('lastname').', '.lang('firstname'),
'org_name, org_unit, adr_one_locality: n_family, n_given' => lang('Company').', '.lang('Department').', '.lang('City').': '.lang('lastname').', '.lang('firstname'),
),
'help' => 'What should links to the addressbook display in other applications. Empty values will be left out. You need to log in anew, if you change this setting!',
'xmlrpc' => True,
'admin' => false,
);
return true; // otherwise prefs say it cant find the file ;-)
}

View File

@ -33,12 +33,6 @@ class uicontacts extends bocontacts
'emailpopup'=> True,
'migrate2ldap' => True,
);
/**
* Addressbook preferences of the user
*
* @var array
*/
var $prefs;
/**
* use a separate private addressbook (former private flag), for contacts not shareable via regular read acl
*
@ -65,7 +59,6 @@ class uicontacts extends bocontacts
}
$this->$my = &$GLOBALS['egw']->$class;
}
$this->prefs =& $GLOBALS['egw_info']['user']['preferences']['addressbook'];
$this->private_addressbook = $this->contact_repository == 'sql' && $this->prefs['private_addressbook'];
$this->org_views = array(

View File

@ -169,6 +169,7 @@ ldap host for contacts admin de LDAP Host f
ldap settings for contacts admin de LDAP Einstellungen für Kontakte
ldif addressbook de LDIF
line 2 addressbook de Zeile 2
link title for contacts show addressbook de Titel der Verknüpfung für Kontakte zeigt
links addressbook de Verknüpfungen
list all categories addressbook de Liste alle Kategorien
list all customfields addressbook de Liste alle benutzerdefinierten Felder
@ -265,6 +266,7 @@ vcards require a first name entry. addressbook de VCards ben
vcards require a last name entry. addressbook de VCards benötigen einen Nachnamen.
warning!! ldap is valid only if you are not using contacts for accounts storage! admin de WARNUNG!! LDAP darf nur verwendet werden, wenn sie die Benutzerkonten nicht im Adressbuch speichern!
warning: all contacts found will be deleted! addressbook de WARNUNG: Alle gefundenen Kontakte werden gelöscht!
what should links to the addressbook display in other applications. empty values will be left out. you need to log in anew, if you change this setting! addressbook de Was sollen Verknüpfungen zum Adressbuch in anderen Anwendungen anzeigen. Leere Werte werden ausgelassen. Sie müssen sich neu anmelden, wenn Sie hier eine Änderung vornehmen!
when should the contacts list display that colum. "only if there is content" hides the column, unless there is some content in the view. addressbook de Wann soll die Adressliste diese Spalte anzeigen. "Nur wenn etwas angezeigt wird" blendet die Spalte aus, wenn Sie in dieser Anzeige leer wäre.
which addressbook should be selected when adding a contact and you have no add rights to the current addressbook. addressbook de Welches Adressbuch soll ausgewählt sein beim Hinzfügen von Kontakten, wenn Sie keine Hinzufügen Rechte zum aktuellen Adressbuch haben.
which charset should be used for the csv export. the system default is the charset of this egroupware installation. addressbook de Welcher Zeichensatz soll für den CSV Export verwendet werden. Die systemweite Vorgabe ist der Zeichensatz der eGroupWare Installation.

View File

@ -169,6 +169,7 @@ ldap host for contacts admin en LDAP host for contacts
ldap settings for contacts admin en LDAP settings for contacts
ldif addressbook en LDIF
line 2 addressbook en Line 2
link title for contacts show addressbook en Link title for contacts show
links addressbook en Links
list all categories addressbook en List all categories
list all customfields addressbook en List all customfields
@ -265,6 +266,7 @@ vcards require a first name entry. addressbook en VCards require a first name en
vcards require a last name entry. addressbook en Vcards require a last name entry.
warning!! ldap is valid only if you are not using contacts for accounts storage! admin en WARNING!! LDAP is valid only if you are NOT using contacts for accounts storage!
warning: all contacts found will be deleted! addressbook en WARNING: All contacts found will be deleted!
what should links to the addressbook display in other applications. empty values will be left out. you need to log in anew, if you change this setting! addressbook en What should links to the addressbook display in other applications. Empty values will be left out. You need to log in anew, if you change this setting!
when should the contacts list display that colum. "only if there is content" hides the column, unless there is some content in the view. addressbook en When should the contacts list display that colum. "Only if there is content" hides the column, unless there is some content in the view.
which addressbook should be selected when adding a contact and you have no add rights to the current addressbook. addressbook en Which addressbook should be selected when adding a contact AND you have no add rights to the current addressbook.
which charset should be used for the csv export. the system default is the charset of this egroupware installation. addressbook en Which charset should be used for the CSV export. The system default is the charset of this eGroupWare installation.