[sync] Syncing Turba contacts

Karsten Fourmont fourmont at gmx.de
Sun Oct 15 09:30:41 PDT 2006


Hi,

my initial posting lacked the sources.php and contained an error in the 
sql script: the object_bday should be varchar(10) rather than 
bigint(10). So once again:

the current default turba (address book) database structure is not very 
suitable for SyncML: only one name field instead of separate first name 
last name, address in one multi line field instead of split into city 
and so on.

The sql script below provides a better structure. Run the sql script to 
create the table. You need to have to rename/delete/backup your orginal 
turba_objects table first.

You also have to use the sources.php below (in the conf directory) or 
paste it into your existing sources.php if you want to use multiple 
sources.


Here's the sql script:

-----8<---cut here----------

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_homestreet` varchar(255),
   `object_homecity` varchar(255),
   `object_homeprovince` varchar(255),
   `object_homepostalcode` varchar(255),
   `object_homecountry` varchar(255),
   `object_workstreet` 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),
   `object_role` varchar(255),
   `object_category` varchar(80),
   `object_photo` blob,
   `object_blobtype` varchar(10),
   `object_bday` varchar(10),

     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;

-----8<---cut here----------

and here's the php code for turba/conf/sources.php. Replaces the 
existing $cfgSources['localsql']

-----8<---cut here----------

$cfgSources['localsql'] = array(
     'title' => _("My Addressbook"),
     'type' => 'sql',
     // The default connection details are pulled from the Horde-wide SQL
     // connection configuration.
     //
     // The old example illustrates how to use an alternate database
     // configuration.
     //
     // New Example:
     'params' => array_merge($GLOBALS['conf']['sql'], array('table' => 
'turba_objects')),

     'map' => array(
         '__key' => 'object_id',
         '__owner' => 'owner_id',
         '__type' => 'object_type',
         '__members' => 'object_members',
         '__uid' => 'object_uid',
         'name' => array('fields' => array('firstname', 'lastname'),
                         'format' => '%s %s'),
         'firstname' => 'object_firstname',
         'lastname' => 'object_lastname',
         'name_prefix' => 'object_nameprefix',
         'email' => 'object_email',
         'alias' => 'object_alias',
         'homeStreet'  => 'object_homestreet',
         'homeCity'     => 'object_homecity',
         'homeProvince'     => 'object_homeprovince',
         'homePostalCode' => 'object_homepostalcode',
         'homeCountry' => 'object_homecountry',
         'workStreet' => 'object_workstreet',
         'workCity'     => 'object_workcity',
         'workProvince'     => 'object_workprovince',
         'workPostalCode' => 'object_workpostalcode',
         'workCountry' => 'object_workcountry',
         'homePhone' => 'object_homephone',
         'workPhone' => 'object_workphone',
         'cellPhone' => 'object_cellphone',
         'fax' => 'object_fax',
         'pager' => 'object_pager',
         'title' => 'object_title',
         'company' => 'object_company',
         'birthday' => 'object_bday',
         'website' => 'object_url',
         'notes' => 'object_notes',
         'pgpPublicKey' => 'object_pgppublickey',
         'smimePublicKey' => 'object_smimepublickey',
         'freebusyUrl' => 'object_freebusyurl'
     ),
     'search' => array(
         'name',
         'email'
     ),
     'strict' => array(
         'object_id',
         'owner_id',
         'object_type',
     ),
     'export' => true,
     'browse' => true,
     'use_shares' => true,
);

-----8<---cut here----------

Cheers,
   Karsten


More information about the sync mailing list