Modding RoundCube to Add Contact Information

30 November -0001

Roundcube is a wonderful dynamic web based e-mail client. It serves pretty much all of my needs, except a few. Recently I’ve been working on taking advantage of the fact that it’s open source software to add some new features that I feel are critical for me. One such feature was to expand the built in contacts function. I like to keep track of additional information, such as phone numbers, addresses, etc. in my online contact directory. Altering RoundCube to facilitate this functionality was actually quite simple and I’ve outlined the steps below to add a ‘Phone’ field to a contact record, but you can repeat the process to add pretty much any field you’d like.

The first step is to create a column in the correct database table. Log into your database and use the roundcube database. You’re going to want to alter the contacts table with the following command:

mysql>alter table contacts add column phone varchar(20) default NULL;

At this point the heavy lifting is done, all that is left to do is to update the files in the program to display and allow editing of this new database field. Doing this is fairly straightforward. Simply follow the following steps:

Change line 56 in roundcube/program/steps/show.inc from:

$a_show_cols = array('name', 'firstname', 'surname', 'email');

to

$a_show_cols = array('name', 'firstname', 'surname', 'email', 'phone');

Change line 68 in roundcube/program/steps/edit.inc from:

$a_show_cols = array('name', 'firstname', 'surname', 'email');

to

$a_show_cols = array('name', 'firstname', 'surname', 'email', 'phone');

Change line 31 in roundcube/program/steps/save.inc from:

$a_save_cols = array('name', 'firstname', 'surname', 'email');

to

$a_save_cols = array('name', 'firstname', 'surname', 'email', 'phone');

Add to line 140 in roundcube/program/localization/en_US/labels.inc

$labels['phone']     = 'Phone';

And you’re done, it’s that simple :)