6.0.0-git
2024-04-23

Diff for TurbaImportAddressBook between 1 and 2

[[toc]]

+ Importing data into Turba's address book



++ Special Fields

Different versions of Turba have some of the following fields that are at least somewhat specific to Turba. The name of the Turba attribute is given first, and the standard SQL field name for that attribute in Turba's default schema is given in parentheses.

+++ __key (object_id)

This is a backend-specific ID for the entry. It can have any value that is unique to this source (for a database backend, object_id + owner_id must be unique on a per-table basis). When importing data from external sources this value can be automatically generated to any value as long as this uniqueness criteria is met.

+++ __uid (object_uid)

This value is a globally-unique id for the entry. It is used when synchronizing with PDAs and other addressbooks, or for maintaining relationships with external vCard data. If the data being imported has a UID it should be preserved; otherwise it can be generated. Using Turba's generateUID() method is the best way, but anything that approximates a unique id @ your server should work.

+++ __owner (owner_id)

The Horde username of the object's owner (or alternately a share name).

+++ __type (object_type)

Either 'Object' or 'Group'

+++ __members (object_members)

A serialized PHP array of members of a Group.

++ Migrating from IMP 2

This is a small !MySQL script to import address book data from IMP 2 into Turba 2's default SQL address book. You can tweak the code to import data from any other external database tables. Please adapt it to your needs before running it.



<code type="sql">

INSERT INTO turba_objects

    (object_id, owner_id, object_uid, object_name, object_alias, object_email)

    SELECT

        MD5(CONCAT(user, fullname, address)),

        SUBSTRING(user, 1, LOCATE('@', user) - 1),

        CONCAT(MD5(CONCAT(user, fullname, address)), '@example.com'),

        fullname,

        nickname,

        address

        FROM imp_addr WHERE user LIKE '%@localhost' OR user LIKE '%@example.com'

</code>



This code takes all entries from the {{imp_addr}} table that have the user name ending with {{@localhost}} or {{@example.com}}. This domain part is then stripped from the user name ({{SUBSTRING(...)}}), unique ids are created using the {{user}}, {{fullname}}, and {{address}} columns, the {{fullname}}, {{nickname}}, and {{address}} columns are taken as-is and everything is inserted into the {{turba_objects}} table.



Please note that Turba is usually flexible enough to connect to //any// existing address book, you do not have to use the table scheme that is shipped with Turba. This script only makes sense if you don't need the old address book anymore, or need some of the features or fields provides with newer Turba versions.