[sync] Turba and Syncml: new database fields

Karsten Fourmont fourmont at gmx.de
Tue Nov 30 12:53:15 PST 2004


You have to add a few fields to the default localsql installation to get 
turba syncing done. Most noteably the name is split into first and last 
name and the address into address/city/province/pocode/country.

Attached are appropriate sources.syncml.php and 
turba_objects.mysql.syncml.sql.

sources.syncml.php should be incoporated into your source.php and can 
replace the existing localsql entry.

The database has to be updated to reflect the additional fields.
You don't have to completely recreate the database from 
turba_objects.mysql.syncml.sql.
Adding the following fields will do:

      object_lastname varchar(255) NOT NULL default '',
      object_firstname varchar(255),
      object_nameprefix varchar(255),
      object_homecity varchar(255),
      object_homeprovince varchar(255),
      object_homepostalcode varchar(255),
      object_homecountry varchar(255),
      object_workcity varchar(255),
      object_workprovince varchar(255),
      object_workpostalcode varchar(255),
      object_workcountry varchar(255),
      object_pager varchar(25),
      object_url varchar(255),

object_name is no longer used. So you might rename object_name to 
object_lastname instead of adding it. Or write a script to split 
firstname and lastname from the single name field. You don't need to add 
all those fields, just the ones you want to sync.

You also need a recent config/attributes.php (i.e. copied from the 
latest attributes.php.dist).

You can add
$attributes['name_prefix'] = array(
     'label' => _("Name Prefix"),
     'type' => 'text',
     'required' => false
);
to get support for the name prefix field (like "Dr.")

Once that is done, syncing should work. At least it works for me with a 
P900. Any feedback is welcome.

Some additional documentation:

If you have a SyncML device with additional fields to those already 
there: here are the changes you have to make to add a complete new field 
to turba and sync:

Let's assume we want to add the "URL" field for vcard-lines like 
"URL:www.horde.org".
We choose the database field to be named object_url and the horde hash 
internal name 'website'.

1) add database field object_url to turba_objects (or other datasource 
as desired)
2) modify turba/lib/Driver.php:tovCard() by adding
             case 'website':
                 $vcard->setAttribute('URL', $val);
                 break;
3) modify turba/lib/Driver.php:tovCard() by adding
             case 'URL':
                 $hash['website'] = $item['value'];
                 break;
4) modify sources.php by adding
         'website'     => 'object_url',
5) modify attributes.php by adding
$attributes['website'] = array(
      'label' => _("Website URL"),
      'type' => 'text',
      'required' => false,
);

Voila!

  Karsten



-------------- next part --------------
-- $Horde: turba/scripts/sql/turba_objects.mysql.sql,v 1.2 2004/11/15 04:27:04 chuck Exp $
-- You can simply execute this file in your database.
--
-- Run as:
--
-- $ mysql --user=root --password=<MySQL-root-password> <db name> < mysql_create.sql

CREATE TABLE turba_objects (
    object_id VARCHAR(32) NOT NULL,
    owner_id VARCHAR(255) NOT NULL,
    object_type VARCHAR(255) NOT NULL DEFAULT 'Object',
    object_uid VARCHAR(255),
    object_members blob,
    object_lastname varchar(255) NOT NULL default '',
    object_firstname varchar(255),
    object_alias varchar(32),
    object_nameprefix varchar(255),
    object_email varchar(255),
    object_homeaddress varchar(255),
    object_homecity varchar(255),
    object_homeprovince varchar(255),
    object_homepostalcode varchar(255),
    object_homecountry varchar(255),
    object_workaddress varchar(255),
    object_workcity varchar(255),
    object_workprovince varchar(255),
    object_workpostalcode varchar(255),
    object_workcountry varchar(255),
    object_homephone varchar(25),
    object_workphone varchar(25),
    object_cellphone varchar(25),
    object_fax varchar(25),
    object_pager varchar(25),
    object_title varchar(255),
    object_company varchar(255),
    object_notes text,
    object_url varchar(255),
    object_pgppublickey text,
    object_smimepublickey text,
    object_freebusyurl varchar(255),

    PRIMARY KEY  (object_id),
);



CREATE INDEX turba_owner_idx ON turba_objects (owner_id);

GRANT SELECT, INSERT, UPDATE, DELETE ON turba_objects TO horde at localhost;


More information about the sync mailing list