\documentclass{article}
\usepackage{ulem}
\pagestyle{headings}
\begin{document}
\tableofcontents

\part{ Importing data into Turba's address book}
\section{ 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.

\subsection{ \_\_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.

\subsection{ \_\_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.

\subsection{ \_\_owner (owner\_id)}
The Horde username of the object's owner (or alternately a share name).

\subsection{ \_\_type (object\_type)}
Either 'Object' or 'Group'

\subsection{ \_\_members (object\_members)}
A serialized PHP array of members of a Group.

\section{ 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.

\begin{verbatim}

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'
\end{verbatim}

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

Please note that Turba is usually flexible enough to connect to \textsl{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.

\end{document}
