Modifying fields in the Turba addressbook

I have recently started using the Funambol iPhone app to keep my contacts in sync with my webmail addressbook.  However, some fields aren’t included in Turba by default and need adding.  This post is for system administrators rather than users, so if you don’t run your own webmail then point your friendly geek at this post.

Firstly make sure you are using a recent version of Horde (e.g. 3.3.6). There are three easy steps to adding the fields you would like in Turba:

  • define an attribute (e.g. it is called “Home Email” and is of type “email”)
  • add it to list of fields that Turba uses (so it is displayed in the right place)
  • add the backend storage (so Turba can query/save the values)

For this example, we are adding the home and work email fields, which are compatible with the iPhone contacts.  This post assumes you use a database backend, if you don’t then step 3 will be slightly different.

1: Define an attribute

Firstly, check the file turba/config/attributes.php and make sure the following is present:

$attributes['homeEmail'] = array(
'label' => _("Home Email"),
'type' => 'email',
'required' => false,
'params' => array('allow_multi' => false, 'strip_domain' => false, 'link_compose' => true)

This defines the field “Home Email”. In recent versions of Horde this should already exist, so you shouldn’t need to modify the config. If you are creating a different type of field that does not exist already, it is easiest to copy the definition of something similar and change the label and attribute name.

2: Tell Turba we want to use this field

Next the file turba/config/sources.php needs to be edited. Find the line 'email' => 'object_email' and add below it the following two lines:

'homeEmail' => 'object_homeemail',
'workEmail' => 'object_workemail',

This tells Turba that the fields homeEmail and workEmail come from the database fields object_homeemail and object_workemail, respectively.  We also need to modify the list of tabs so that Turba knows to display our new values in the right place.

Email addresses should go on the “Communications” tab, after the existing email field, so we modify the array and insert the attribute names like below:

_("Communications") => array('email', 'homeEmail', 'workEmail', 'homePhone', 'workPhone', 'cellPhone', 'fax', 'pager'),

3: Add the backend storage

Assuming you use a database backend, this is as easy as creating two new fields in the database.  They should be named according to the values in sources.php that we defined above and should be similar to an existing row of the same type.  As we are creating email fields, we can use the same data type as the object_email row.

For this example, the following SQL will modify the database appropriately:

ALTER TABLE `turba_objects`
ADD `object_homeemail` VARCHAR( 255 ) NOT NULL AFTER `object_email`,
ADD `object_workemail` VARCHAR( 255 ) NOT NULL AFTER `object_homeemail`

The same process above can be followed for other fields that might be missing, post a comment if there is something that you’d like help adding.

David Cannings
Cyber Security Geek

My interests include computer security, digital electronics and writing tools to help analysis of cyber attacks.