[turba] Adding and changing fields in the turba "Contacts" records

Eric spamsink at scoot.netis.com
Sun Nov 5 18:49:10 PST 2006


First of all, please remember that you're reading the ravings of someone 
who knows virtually nothing that's worth knowing about either SQL or PHP.  :-)

I think I almost have figured out much of what I'm doing here, but it 
doesn't seem like it should be this easy :-), so I'd like to run this past 
you all and ask you to tell me where I'm screwing it up.

I'm putting together a contacts database for my consulting partnership 
(meaning that if I screw it up too badly, normally the worst that will 
happen is that my partners will show up here and kick my ass <g>).  I need 
to do quite a bit of modification on the format of the Turba "Contacts" 
record as displayed on the web browser.

The presence and order of things that show up on a "Contact" screen are 
controlled by the presence and order in the "map" block sources.php, e.g.:

     'map' => array(
         '__key' => 'object_id',
         '__owner' => 'owner_id',
         '__type' => 'object_type',
         '__members' => 'object_members',
         '__uid' => 'object_uid',
         'name' => 'object_name',
         'email' => 'object_email',
         'title' => 'object_title',
         'company' => 'object_company',
         'workAddress' => 'object_workaddress',
         'workPhone' => 'object_workphone',
         'fax' => 'object_fax',
         'cellPhone' => 'object_cellphone',
         'homeAddress' => 'object_homeaddress',
         'homePhone' => 'object_homephone',
         'notes' => 'object_notes',
     ),

(I've already modified this somewhat, from the file that came with the 
distribution.)

So if I want to delete certain items or change the order in which they 
appear, all I have to do is delete or move them in the "map"  block above, 
right?  I tried that and it worked, I just wanted to make sure there isn't 
some other hidden thing I have to do that I didn't do and will come back to 
bite me later..

Next, sources.php says:

     'search' => array(
         'name',
         'email'
     ),

So, that means that ONLY name and email can be searched, right?  If I want 
it to be able to search on other attribute names (e.g. 'company' or 
'title'), all I have to do is add those attribute names to this block, 
right?  For example...

     'search' => array(
         'name',
         'title',
         'company',
         'email'
     ),

I can do this anytime, right?  So that if, later, after we've added a bunch 
of records, we decide we want to add to the things on which we can search, 
all I need to do is add it to the list, right?

Now, I notice that to the right of the => are things like 'object_company' 
and 'object_name'.  If I call up mysql, set the "horde" database, and say 
"describe turba_objects", I get the following (HOPING AGAINST HOPE that the 
table shown below doesn't get too badly trashed by formatting...):

+-----------------------+--------------+
| Field                 | Type         |
+-----------------------+--------------+
| object_id             | varchar(32)  |
| owner_id              | varchar(255) |
| object_type           | varchar(255) |
| object_uid            | varchar(255) |
| object_members        | blob         |
| object_name           | varchar(255) |
| object_alias          | varchar(32)  |
| object_email          | varchar(255) |
| object_homeaddress    | varchar(255) |
| object_workaddress    | varchar(255) |
| object_homephone      | varchar(25)  |
| object_workphone      | varchar(25)  |
| object_cellphone      | varchar(25)  |
| object_fax            | varchar(25)  |
| object_title          | varchar(255) |
| object_company        | varchar(255) |
| object_notes          | text         |
| object_pgppublickey   | text         |
| object_smimepublickey | text         |
| object_freebusyurl    | varchar(255) |
+-----------------------+--------------+

(I edited out the Null, Key, Default, and Extra columns above so that 
hopefully there will be a better chance for it to survive reformatting in 
people's mail readers.)

I notice that all of the rvalues (or whatever they're called in PHP) like 
object_name and object_workaddress are all represented in the list above, 
so I assume that means if it ain't in the list above, Turba can't use it.

Now I want to add the contact's city, which isn't in the above list (I 
assume the intent is for people to put the city and state in with the 
address).  I see that in the "attributes.php" file there is already a 
"workCity" attribute specified; however there is no corresponding field in 
the turba_objects table.  So if I want to add a "workCity" to the contacts 
record, I think I need to do the following:

1.  add 'workCity' = 'object_workcity' to the map block in sources.php

2.  say the following from within mysql:

mysql> alter table turba_objects add column object_workcity varchar (20);

(... if I want the city to be a max of 20 characters long).

Right?

Anything else I need to do?

Can I do that any time, e.g. after we have added a bunch of records and 
then decide we need some new fields?

Finally, this contacts database needs to be accessible by all of us.  Is 
there anywhere in particular that I need to put the use_shares 
statement?  For example, will the following work?

$cfgSources['localsql'] = array(
     'title' => _("My Address Book"),
     'type' => 'sql',
     'use_shares' => true,

That's enough for now... :-)

Thanks...

Eric




More information about the turba mailing list