=================
 Upgrading Turba
=================

:Contact: turba@lists.horde.org

.. contents:: Contents
.. section-numbering::


General instructions
====================

These are instructions to upgrade from earlier Turba versions. Please backup
your existing data before running any of the steps described below. You can't
use the updated data with your old Turba version anymore.

Upgrading Turba is as easy as running::

   pear upgrade -a -B horde/turba

If you want to upgrade Turba with all binary dependencies, you need to remove
the ``-B`` flag. Please note that this might also try to install PHP extensions
through PECL that might need further configuration or activation in your PHP
configuration::

   pear upgrade -a horde/turba

If you want to upgrade to an alpha or beta version of Turba, you need to tell
the PEAR installer to prefer non-stable package versions. Please note that this
might also install pre-release 3rd-party PEAR packages::

   pear -d preferred_state=alpha upgrade -a horde/turba

If you want to upgrade from a Turba version prior to 3.0, please follow the
instructions in INSTALL_ to install the most recent Turba version using the
PEAR installer.

After updating to a newer Turba version, you **always** need to update
configurations and database schemes. Log in as an administrator, go to
Administration => Configuration and update anything that's highlighted as
outdated.


Upgrading Turba from 4.1 to 4.2
===============================

Attribute Changes
-----------------

  - Categories have been replaced by Tags. As such, you **must** update any
    local source definitions and remove the "Category" attribute.


Configuration Options (conf.php)
--------------------------------

The following options have been added::

   $conf['tags']['enabled']



Upgrading Turba from 4.0 to 4.1
===============================

Attribute Changes
-----------------

  - The "instantMessenger" attribute has been replaced by the "imaddress",
    "imaddress2", and "imaddress3" attributes.

  - The default SQL schema has been updated, as well as the out of the box
    field definitions for the 'localsql' source. You must execute the database
    migrations for Turba to ensure you have the latest schema.



Upgrading Turba from 3.x to 4.x
===============================

Attribute Changes
-----------------

  - The "gender" attribute sets values of (literally) "male" or "female" now,
    and no longer 0 or 1.


Preference Changes
------------------

  - The "addressbooks" preference has been removed.


API Changes
-----------

  - search

    The $sources, $fields, $matchBegin, $forceSource and $returnFields
    parameters have been removed and replaced by the $opts parameter.

    Added a 'rfc822Return' option to return a Horde_Mail_Rfc822_List object
    instead of the search results array (which remains the default).



Upgrading Turba from 2.x to 3.x
===============================

.. Important:: These upgrade instructions assume that you are upgrading from
               at least Turba 2.2.  If you have an older version of Turba,
               you must upgrade to at least Turba 2.2 before attempting to
               install Turba 3.

Configuration files
-------------------

The ``config/sources.php`` configuration file has been renamed to
``config/backends.php``.  The entry for defining the connection parameters for
an SQL backend other than the default Horde backend has changed - see the
'params' -> 'sql' configuration value.


Hooks
-----

The ``_turba_hook_encode_{attribute}`` hook has been moved to the
'encode_attribute' hook.

The ``_turba_hook_decode_{attribute}`` hook has been moved to the
'decode_attribute' hook.


Upgrading Turba from 2.3.x to 2.3.3
===================================


Share Table Updates
-------------------

The SQL script for PostgreSQL used a wrong column type for the share
tables. If you have many users or shares, this could cause an overrun at some
point. Execute the provided SQL script to update your database if you are
using the native SQL share driver on PostgresSQL::

   psql <db name> < scripts/upgrades/2.3_to_2.3.3.pgsql.sql


Upgrading Turba from 2.2.1 to 2.3
=================================


Share Table Updates
-------------------

Some fields in the SQL share driver tables have been changed. Execute the
provided SQL script to update your database if you are using the native SQL
share driver::

   mysql --user=root --password=<MySQL-root-password>  <db name> < scripts/upgrades/2.2.1_to_2.3.sql


New fields
----------

Examples for a few new fields have been added to
``config/attributes.php.dist`` and ``config/sources.php.dist``. These field
require Horde 3.3 or later though, so they are disabled by default. If you
update your ``attributes.php`` and ``sources.php`` files and are using a
sufficiently recent Horde version, you may want to uncomment those
examples. These are the ``photo``, ``phototype``, ``logo``, ``logotype``,
``pgpPublicKey`` and ``smimePublicKey`` fields.


Upgrading to Turba 2.2
======================

These are notes on upgrading from Turba 2.1.x to Turba 2.2.x.

.. Important:: These upgrade instructions assume that you are upgrading from
               at least Turba 2.1.  If you have an older version of Turba,
               follow the upgrade steps described in `Upgrading to Turba 2.1`_
               first.


New Default Schema
------------------

The default database address book schema has been changed to better match
other address book applications and to ease synchronization with those.

You can still use your old address book schema without any restrictions, but
if you want to migrate existing address books to the new default scheme, you
can use the provided upgrade script. This script assumes that you use the old
default schema from Turba 2.1 and doesn't permanently change any data unless
you edit it.

To run the script you have to open it in any text editor and change the three
variables at the top of the script ``$db_user``, ``$db_pass`` and
``$db_table`` to fit your current Turba installation. You can then run the
script to see how the data //would// be changed::

   php scripts/upgrades/2.1_to_2.2_sql_schema.php

If you are happy with the results, you can edit the script again and change
the ``$for_real`` variable::

   $for_real = true;

As always make sure you have a recent backup before running the script once
more, this time the changes will be permanent. Don't forget to update your
configuration files or to re-create them from the ``.php.dist`` examples.

A few advanced attribute definitions have been commented out in
``config/attributes.php`` by default because they require Horde 3.2 or later
to be installed. If you have a sufficiently recent Horde version you can
uncomment those lines in ``attributes.php``.

As part of the new default schema, the various address fields have been split
into individual fields (such as homeStreet, homeProvince etc...). If you still
wish to display an individual composite address field (which will give you the
map links) you must add a composite field (such as homeAddress). There is an
example entry in the sources.php.dist file.

The new schema also uses the "phone" field type that has been introduced with
Horde 3.2. If you still run earlier Horde versions, change the phone field
types in ``attributes.php`` to anything that fits your needs, e.g "cellphone"
or "text".


New Beta SQL Share Driver Support
---------------------------------

A new beta-level SQL Horde_Share driver has been added in Horde 3.2. This
driver offers significant performance improvements over the existing Datatree
driver but it has not received the same level of testing, thus the beta
designation.  In order to make use of this driver, you must be running Horde
3.2-RC3 or later. To add the new SQL tables for this driver, execute the sql
script ``2.1_to_2.2_add_sql_share_tables`` that is appropriate for your
RDBMS. You then must execute the ``turba-convert-datatree-shares-to-sql``
upgrade script to migrate your existing share data.


Flattened Horde Shares
----------------------

Shared address books are now stored in a flat namespace in order
to remove dependency on the hierarchal properties of the Horde_Share api.  You
must run the upgrade script ``scripts/upgrades/2007-06-17_flatten_shares.php``.

.. Important:: You must run these scripts BEFORE any user logs in to your
               upgraded installation to avoid the creation of any duplicate
               shares.

All user preferences related to address books will be checked and updated by
Turba transparently during each user's first login after the update.

Additionally, if you are currently using the configuration setting,
``Name of Client Address Book`` and have it set to a share enabled source, you
will most likely have to change the entry.  The correct share key to enter here
is the share name and can be found by browsing the datatree via the
administration UI if using datatree shares, or by looking in the turba_shares
table if using SQL based shares.


IMSP Driver and Share Support
-----------------------------

Share support has been added to the IMSP driver.  This support requires at
least a Horde 3.2 install.  With this change, any IMSP address books the user
has rights to will be represented internally as a Horde share.  Permissions
changed on the share will be reflected back to the IMSP server.  If you set
the configuration setting ``Name of source for creating new shares`` to
``imsp`` then any shares created by the user will result in a new IMSP address
book being created on the IMSP server.  Likewise, any IMSP address book
deleted in Turba will be removed from the IMSP server.

To enable this support, make sure you are using at least Horde 3.2, set the
``use_shares`` attribute to true, and uncomment the IMSP
``_horde_hook_share_*`` functions in ``horde/config/hooks.php``.

With this change, the ``IMSP Address Book Administration`` option page has
been removed, as the creation/deletion of address books is now handled with
shares.

.. Important:: IMSP contacts contained in contact groups that are not from an
               IMSP source may not be visible within that group when migrating
               an IMSP source to a share.


Application Hooks
-----------------

All hooks that are specific to Turba have been moved from the
``horde/config/hooks.php`` file. Move your existing Turba Hooks from there to
``turba/config/hooks.php``.


Upgrading to Turba 2.1
======================


These are notes on upgrading from Turba 2.0.x to Turba 2.1.

.. Important:: These upgrade instructions assume that you are upgrading from at
               least Turba 2.0.  If you have an older version of Turba, get a
               copy of Turba 2.0 and follow the upgrade steps described there
               first.


Synchronization Support
-----------------------

Synchronization with SyncML capable devices is possible now if you have at
least Horde 3.1.  You need to create a History backend with
``horde/scripts/sql/horde_histories.sql`` to allow synchronization.  You also
need to create default history entries for existing contacts by running the
script ``scripts/upgrades/create_default_histories.php``.


New Hook Parameters
-------------------

The ``_turba_hook_encode_{attribute}`` and ``_turba_hook_decode_{attribute}``
functions are now passed an additional parameter - the object that is being
loaded/saved. This enables you to create more powerful custom hooks that build
a field from several other field's values (the opposite of composite fields),
or otherwise modify a value based on other properties of the object.


Share Support
-------------

Share support has been added to Turba.  This allows the sharing, adding, and
deleting of addressbooks for those sources that support it.  Currently, this is
supported by the SQL driver.  With this change, the ``public`` attribute of the
params array has been removed in favor of the ``use_share`` attribute.  If you
are currently using a SQL source as a public source, you must run the upgrade
script ``turba-public-to-horde-share``.  Be sure to read the script comments
and backup all data before conversion.  This script will create a new share
that is viewable by all users.  If you choose not to use shares, set the
``use_shares`` attribute to ``false`` and the SQL driver will behave as in
previous versions, that is, a seperate, private addressbook for each user.

.. Important:: If you are currently using two seperate ``turba_objects`` tables
               - one for personal address books and one for a public address
               book, you should run the upgrade script on the public table,
               then merge the public table into the private table and enable
               share support on the private table.  There is no longer any
               need for maintaining the two seperate tables. If you desire not
               to enable share support, you may still use seperate tables and
               set permissions via the administration interface.


.. _INSTALL: INSTALL
