From 8b2372d1c9cac0001bc3f6af191729ce6975a4d6 Mon Sep 17 00:00:00 2001
From: Jens-U. Mozdzen <jmozdzen@nde.ag>
Date: Wed, 30 Jan 2013 16:51:02 +0100
Subject: [PATCH] re-vamped files to work with Horde5


Signed-off-by: Jens-U. Mozdzen <jmozdzen@nde.ag>
---
 bundles/kolab_webmail/bin/kolab-webmail-install    |    4 +-
 bundles/kolab_webmail/config/conf.d/20-kolab.xml   |   42 +++++-
 bundles/kolab_webmail/config/prefs.d/20-kolab.php  |    9 +-
 bundles/kolab_webmail/docs/CHANGES                 |    2 +-
 .../imp/config/backends.d/20-kolab.php             |    3 +-
 .../kolab_webmail/imp/config/conf.d/20-kolab.php   |    4 +-
 bundles/kolab_webmail/imp/config/hooks.php         |  148 +++++++++---------
 .../ingo/config/backends.d/20-kolab.php            |    2 +-
 bundles/kolab_webmail/lib/Bundle.php               |   40 ++++--
 bundles/kolab_webmail/package.xml                  |  162 +++++++++++--------
 .../turba/config/backends.d/20-kolab.php           |   33 ++--
 bundles/kolab_webmail/turba/config/hooks.php       |   22 +++
 12 files changed, 285 insertions(+), 186 deletions(-)

diff --git a/bundles/kolab_webmail/bin/kolab-webmail-install b/bundles/kolab_webmail/bin/kolab-webmail-install
index c61251e..41d7b44 100755
--- a/bundles/kolab_webmail/bin/kolab-webmail-install
+++ b/bundles/kolab_webmail/bin/kolab-webmail-install
@@ -29,9 +29,9 @@ $cli->writeln($cli->yellow($cli->bold('Installing ' . Horde_Bundle::FULLNAME)));
 $bundle = new Horde_Bundle($cli, $pear_config->getConfFile('system'));
 $bundle->init();
 $bundle->configDb();
-$bundle->migrateDb();
-$bundle->writeAllConfigs();
 $bundle->configAuth();
+$bundle->writeAllConfigs();
+$bundle->migrateDb();
 
 // Finished.
 $cli->writeln();
diff --git a/bundles/kolab_webmail/config/conf.d/20-kolab.xml b/bundles/kolab_webmail/config/conf.d/20-kolab.xml
index d38dbbd..5d60cae 100644
--- a/bundles/kolab_webmail/config/conf.d/20-kolab.xml
+++ b/bundles/kolab_webmail/config/conf.d/20-kolab.xml
@@ -4,15 +4,47 @@
  <configsection name="auth">
    <configlist name="admins" desc="Which users should be treated as
    administrators (root, super-user) by Horde?">manager</configlist>
+   <configswitch name="driver" desc="What backend should we use for
+   authenticating users to Horde?">kolab</configswitch>
  </configsection>
- <configsection name="share">
+ <configsection name="prefs">
+  <configswitch name="driver" desc="What preferences driver should we
+   use?">KolabImap</configswitch>
+ </configsection>
+ <configsection name="group">
   <configswitch name="driver" desc="What backend should we use for Horde
-   Shares?">Kolab</configswitch>
+   Groups?">Kolab</configswitch>
+   <configsection name="params">
+     <!-- <configldap switchname="driverconfig"> -->
+       <configstring name="gid" desc="The group search key">cn</configstring>
+       <configstring name="scope" desc="where to search, starting from basedn">sub</configstring>
+       <configstring name="memberuid" desc="Group membership field">member</configstring>
+       <configboolean name="attrisdn" required="false" desc="If checked, the user member attributes returned from LDAP are expected to be fully qualified DNs">true</configboolean>
+       <configlist name="newgroup_objectclass" desc="What objectclasses should a new group be member of? These objectclasses should cover the mail and gidnumber attributes as well as the group search key">kolabGroupOfNames</configlist>
+       <!-- the following three will be set by Bundle.php -->
+       <configstring name="basedn" desc="Base DN of all entries." required="false"/>
+       <configstring name="writedn" desc="DN used to bind for creating and editing LDAP groups." required="false"/>
+       <configstring name="writepw" desc="Password for bind DN." required="false"/>
+       <configsection name="search">
+         <configstring name="filter_type" desc="How to specify a filter for the group lists">objectClass</configstring>
+	 <configlist name="objectclass" desc="The objectclass filter used to search for groups. Can be a single objectclass or a list.">kolabGroupOfNames</configlist>
+       </configsection>
+     <!-- </configldap> -->
+   </configsection>
+ </configsection>
+ <configsection name="share">
+  <configenum name="driver" desc="What backend should we use for Horde
+   Shares?">Kolab</configenum>
+ </configsection>
+ <configsection name="mailer">
+  <configswitch name="type" desc="What method should we use for sending
+   mail?">smtp</configswitch>
+ </configsection>
+ <configsection name="kolab">
+  <configswitch name="enabled" quote="false" desc="Horde/Kolab integration
+    status">true</configswitch>
  </configsection>
 <!--
-//@todo: Fix Kolab driver
-//$conf['group']['driver'] = 'kolab';
-$conf['group']['driver'] = 'Mock';
 //@todo: check
 //$conf['group']['cache'] = true;
 
diff --git a/bundles/kolab_webmail/config/prefs.d/20-kolab.php b/bundles/kolab_webmail/config/prefs.d/20-kolab.php
index 5868be3..3613ac7 100644
--- a/bundles/kolab_webmail/config/prefs.d/20-kolab.php
+++ b/bundles/kolab_webmail/config/prefs.d/20-kolab.php
@@ -1,5 +1,6 @@
 <?php
-$_prefs['from_addr']['hook'] = true;
-$_prefs['from_addr']['locked'] = true;
-$_prefs['fullname']['hook'] = true;
-$_prefs['fullname']['locked'] = true;
+// we have to support multi-entity users
+// $_prefs['from_addr']['hook'] = false;
+// $_prefs['from_addr']['locked'] = false;
+// $_prefs['fullname']['hook'] = false;
+// $_prefs['fullname']['locked'] = false;
diff --git a/bundles/kolab_webmail/docs/CHANGES b/bundles/kolab_webmail/docs/CHANGES
index f9d827b..8654932 100644
--- a/bundles/kolab_webmail/docs/CHANGES
+++ b/bundles/kolab_webmail/docs/CHANGES
@@ -1,4 +1,4 @@
 ----------
-v4.0.0-git
+v5.0.0-git
 ----------
 
diff --git a/bundles/kolab_webmail/imp/config/backends.d/20-kolab.php b/bundles/kolab_webmail/imp/config/backends.d/20-kolab.php
index 6459ea7..be2e2bb 100644
--- a/bundles/kolab_webmail/imp/config/backends.d/20-kolab.php
+++ b/bundles/kolab_webmail/imp/config/backends.d/20-kolab.php
@@ -4,7 +4,8 @@ $servers = array();
 
 $servers['kolab'] = array(
     'name' => 'Kolab Cyrus IMAP Server',
-    'hostspec' => $GLOBALS['injector']->getInstance('Horde_Kolab_Session')->getImapServer(),
+    // 'hostspec' => $GLOBALS['injector']->getInstance('Horde_Kolab_Session')->getImapServer(),
+    'hostspec' => $GLOBALS['conf']['kolab']['imap']['server'],
     'hordeauth' => 'full',
     'protocol' => 'imap',
     'port' => $GLOBALS['conf']['kolab']['imap']['port'],
diff --git a/bundles/kolab_webmail/imp/config/conf.d/20-kolab.php b/bundles/kolab_webmail/imp/config/conf.d/20-kolab.php
index ba3bbcd..df8e435 100644
--- a/bundles/kolab_webmail/imp/config/conf.d/20-kolab.php
+++ b/bundles/kolab_webmail/imp/config/conf.d/20-kolab.php
@@ -1,5 +1,5 @@
 <?php
 
 $conf['hooks']['mbox_redirect'] = true;
-$conf['hooks']['mbox_icon'] = true;
-$conf['hooks']['display_folder'] = true;
+// $conf['hooks']['mbox_icon'] = true;
+// $conf['hooks']['display_folder'] = true;
diff --git a/bundles/kolab_webmail/imp/config/hooks.php b/bundles/kolab_webmail/imp/config/hooks.php
index 436f190..b285361 100644
--- a/bundles/kolab_webmail/imp/config/hooks.php
+++ b/bundles/kolab_webmail/imp/config/hooks.php
@@ -82,78 +82,78 @@ class IMP_Hooks
    }
 
 
-    /**
-     * Allow a custom folder icon to be specified for "standard" mailboxes
-     * ("Standard" means all folders except the INBOX, sent-mail folders and
-     * trash folders.)
-     *
-     * @return array  A list of mailboxes, with the name as keys and the
-     *                values an array with 'icon' and 'alt' entries.
-     *                If a mailbox name doesn't appear in the list, the
-     *                default mailbox icon is displayed.
-     */
-   public function mbox_icons()
-   {
-       $types = $GLOBALS['injector']->getInstance('Horde_Kolab_Storage')
-           ->getList()->listFolderTypes();
-
-       $icons = array();
-       foreach ($types as $folder => $type) {
-           $t = preg_replace('/\.default$/', '', $type);
-           $f = Horde_String::convertCharset($folder, 'UTF-8', 'UTF7-IMAP');
-           switch ($t) {
-           case 'event':
-               $icons[$f] = array(
-                   'alt' => _("Calendar"),
-                   'icon' => Horde_Themes::img('kronolith.png', 'kronolith')
-               );
-               break;
-
-           case 'task':
-               $icons[$f] = array(
-                   'alt' => _("Tasks"),
-                   'icon' => Horde_Themes::img('nag.png', 'nag')
-               );
-               break;
-
-           case 'note':
-               $icons[$f] = array(
-                   'alt' => _("Notes"),
-                   'icon' => Horde_Themes::img('mnemo.png', 'mnemo')
-               );
-               break;
-
-           case 'contact':
-               $icons[$f] = array(
-                   'alt' => _("Contacts"),
-                   'icon' => Horde_Themes::img('turba.png', 'turba')
-               );
-               break;
-
-           case 'h-prefs':
-               $icons[$f] = array(
-                   'alt' => _("Preferences"),
-                   'icon' => Horde_Themes::img('prefs.png', 'horde')
-               );
-               break;
-           }
-       }
-
-       return $icons;
-   }
-
-    /**
-     * Hide specified IMAP mailboxes in folder listings.
-     *
-     * @param string $mailbox  The mailbox name (UTF7-IMAP).
-     *
-     * @return boolean  If false, do not display the mailbox.
-     */
-   public function display_folder($mailbox)
-   {
-       $types = $GLOBALS['injector']->getInstance('Horde_Kolab_Storage')
-           ->getList()->listFolderTypes();
-       $f = Horde_String::convertCharset($mailbox, 'UTF7-IMAP', 'UTF-8');
-       return empty($types[$f]) || ($types[$f] == 'mail');
-   }
+//     /**
+//      * Allow a custom folder icon to be specified for "standard" mailboxes
+//      * ("Standard" means all folders except the INBOX, sent-mail folders and
+//      * trash folders.)
+//      *
+//      * @return array  A list of mailboxes, with the name as keys and the
+//      *                values an array with 'icon' and 'alt' entries.
+//      *                If a mailbox name doesn't appear in the list, the
+//      *                default mailbox icon is displayed.
+//      */
+//    public function mbox_icons()
+//    {
+//        $types = $GLOBALS['injector']->getInstance('Horde_Kolab_Storage')
+//            ->getList()->listFolderTypes();
+// 
+//        $icons = array();
+//        foreach ($types as $folder => $type) {
+//            $t = preg_replace('/\.default$/', '', $type);
+//            $f = Horde_String::convertCharset($folder, 'UTF-8', 'UTF7-IMAP');
+//            switch ($t) {
+//            case 'event':
+//                $icons[$f] = array(
+//                    'alt' => _("Calendar"),
+//                    'icon' => Horde_Themes::img('kronolith.png', 'kronolith')
+//                );
+//                break;
+// 
+//            case 'task':
+//                $icons[$f] = array(
+//                    'alt' => _("Tasks"),
+//                    'icon' => Horde_Themes::img('nag.png', 'nag')
+//                );
+//                break;
+// 
+//            case 'note':
+//                $icons[$f] = array(
+//                    'alt' => _("Notes"),
+//                    'icon' => Horde_Themes::img('mnemo.png', 'mnemo')
+//                );
+//                break;
+// 
+//            case 'contact':
+//                $icons[$f] = array(
+//                    'alt' => _("Contacts"),
+//                    'icon' => Horde_Themes::img('turba.png', 'turba')
+//                );
+//                break;
+// 
+//            case 'h-prefs':
+//                $icons[$f] = array(
+//                    'alt' => _("Preferences"),
+//                    'icon' => Horde_Themes::img('prefs.png', 'horde')
+//                );
+//                break;
+//            }
+//        }
+// 
+//        return $icons;
+//    }
+// 
+//     /**
+//      * Hide specified IMAP mailboxes in folder listings.
+//      *
+//      * @param string $mailbox  The mailbox name (UTF7-IMAP).
+//      *
+//      * @return boolean  If false, do not display the mailbox.
+//      */
+//    public function display_folder($mailbox)
+//    {
+//        $types = $GLOBALS['injector']->getInstance('Horde_Kolab_Storage')
+//            ->getList()->listFolderTypes();
+//        $f = Horde_String::convertCharset($mailbox, 'UTF7-IMAP', 'UTF-8');
+//        return empty($types[$f]) || ($types[$f] == 'mail');
+//    }
 }
diff --git a/bundles/kolab_webmail/ingo/config/backends.d/20-kolab.php b/bundles/kolab_webmail/ingo/config/backends.d/20-kolab.php
index 8a83621..7df1d42 100644
--- a/bundles/kolab_webmail/ingo/config/backends.d/20-kolab.php
+++ b/bundles/kolab_webmail/ingo/config/backends.d/20-kolab.php
@@ -7,7 +7,7 @@ $backends['kolab'] = array(
     'transport' => 'timsieved',
     'hordeauth' => 'full',
     'params' => array(
-        'hostspec' => $GLOBALS['injector']->getInstance('Horde_Kolab_Session')->getImapServer(),
+        'hostspec' => $GLOBALS['conf']['kolab']['imap']['server'],
         'logintype' => 'PLAIN',
         'usetls' => true,
         'port' => $GLOBALS['conf']['kolab']['imap']['sieveport'],
diff --git a/bundles/kolab_webmail/lib/Bundle.php b/bundles/kolab_webmail/lib/Bundle.php
index 0ade912..4af5a3d 100644
--- a/bundles/kolab_webmail/lib/Bundle.php
+++ b/bundles/kolab_webmail/lib/Bundle.php
@@ -19,7 +19,7 @@ class Horde_Bundle extends Horde_Core_Bundle
     /**
      * The bundle version.
      */
-    const VERSION = '4.0-RC1';
+    const VERSION = '5.0';
 
     /**
      * The bundle descriptive name.
@@ -39,28 +39,46 @@ class Horde_Bundle extends Horde_Core_Bundle
     protected function _configAuth(Horde_Variables $vars)
     {
         $vars->auth__driver = 'kolab';
-        $host = $this->_cli->prompt('Provide the host name of your Kolab server:');
+        $kolabhost = $this->_cli->prompt('Provide the host name of your Kolab server:');
+        $smtphost = $this->_cli->prompt('Provide the host name of your SMTP server:', null, $kolabhost);
+        $ldaphost = $this->_cli->prompt('Provide the host name of your LDAP server:', null, $kolabhost);
         $maildomain = $this->_cli->prompt('Provide the primary mail domain of your Kolab server:');
         $basedn = $this->_cli->prompt('Provide the base DN of your Kolab server:');
-        $phppw = $this->_cli->prompt('Provide the PHP pw of your Kolab LDAP nobody user:');
+        $phpdn = $this->_cli->prompt('Provide the DN of your Horde LDAP user:', null, 'cn=nobody,cn=internal,' . $basedn );
+        $phppw = $this->_cli->passwordPrompt('Provide the password of your Horde LDAP user:');
+
         $vars->problems__email = 'postmaster@' . $maildomain;
         $vars->problems__maildomain = $maildomain;
         $vars->kolab__enabled = 'true';
-        $vars->kolab__ldap__server = 'ldap://' . $host . ':389';
-        $vars->kolab__ldap__hostname = $host;
+        $vars->kolab__ldap__server = $ldaphost;
+        $vars->kolab__ldap__hostname = $ldaphost;
         $vars->kolab__ldap__port = '389';
         $vars->kolab__ldap__basedn = $basedn;
-        $vars->kolab__ldap__phpdn = 'cn=nobody,cn=internal,' . $basedn;
+        $vars->kolab__ldap__phpdn = $phpdn;
         $vars->kolab__ldap__phppw = $phppw;
-        $vars->kolab__imap__server = $host;
-        $vars->kolab__imap__port = '993';
+        $vars->kolab__smtp__server = $smtphost;
+        $vars->kolab__imap__server = $kolabhost;
+        $vars->kolab__imap__port = '143';
         $vars->kolab__imap__sieveport = '2000';
         $vars->kolab__imap__maildomain = $maildomain;
+        $vars->kolab__freebusy__server = 'https://' . $kolabhost . '/freebusy';
         $vars->mailer__type = 'smtp';
-        $vars->mailer__params__auth = 'true';
-        $vars->mailer__params__port = 587;
-        $vars->mailer__params__host = $host;
+        $vars->mailer__params__auth = 'false';
+        $vars->mailer__params__port = 25;
+        $vars->mailer__params__host = $smtphost;
         $vars->prefs__driver = 'KolabImap';
+
+        $vars->group__params__basedn = $basedn;
+        $vars->group__params__writedn = $phpdn;
+        $vars->group__params__writepw = $phppw;
+
+	$vars->ldap__hostspec = $ldaphost;
+	$vars->ldap__tls = 'false';
+	$vars->ldap__version = 3;
+	$vars->ldap__binddn = $phpdn;
+	$vars->ldap__bindpw = $phppw;
+	$vars->ldap__useldap = 'true';
+
         return 'manager';
     }
 }
diff --git a/bundles/kolab_webmail/package.xml b/bundles/kolab_webmail/package.xml
index 2b5a667..dc89a2c 100644
--- a/bundles/kolab_webmail/package.xml
+++ b/bundles/kolab_webmail/package.xml
@@ -10,19 +10,19 @@
   <email>wrobel@horde.org</email>
   <active>yes</active>
  </lead>
- <date>2011-11-29</date>
- <time>19:43:49</time>
+ <date>2013-01-30</date>
+ <time>20:00:00</time>
  <version>
-  <release>4.0.0alpha1</release>
-  <api>4.0.0alpha1</api>
+  <release>5.0.0</release>
+  <api>5.0.0</api>
  </version>
  <stability>
-  <release>alpha</release>
-  <api>alpha</api>
+  <release>stable</release>
+  <api>stable</api>
  </stability>
  <license uri="http://www.horde.org/licenses/gpl">GPL-2.0</license>
  <notes>
-* First release candidate of Horde Kolab Edition 4.0.
+* First release candidate of Horde Kolab Edition 5.0.
  </notes>
  <contents>
   <dir baseinstalldir="/" name="/">
@@ -56,13 +56,13 @@
       <file name="20-kolab.php" role="horde" />
      </dir> <!-- /imp/config/backends.d -->
      <dir name="conf.d">
-      <file name="10-webmail.xml" role="horde" />
+      <!-- <file name="10-webmail.xml" role="horde" /> -->
       <file name="20-kolab.php" role="horde" />
      </dir> <!-- /imp/config/conf.d -->
+     <file name="hooks.php" role="horde" />
      <dir name="prefs.d">
       <file name="10-webmail.php" role="horde" />
      </dir> <!-- /imp/config/prefs.d -->
-     <file name="hooks.php" role="horde" />
     </dir> <!-- /imp/config -->
    </dir> <!-- /imp -->
    <dir name="ingo">
@@ -78,10 +78,11 @@
    <dir name="kronolith">
     <dir name="config">
      <dir name="conf.d">
-      <file name="10-webmail.xml" role="horde" />
+      <!-- <file name="10-webmail.xml" role="horde" /> -->
       <file name="20-kolab.php" role="horde" />
       <file name="20-kolab.xml" role="horde" />
      </dir> <!-- /kronolith/config/conf.d -->
+     <file name="hooks.php" role="horde" />
     </dir> <!-- /kronolith/config -->
    </dir> <!-- /kronolith -->
    <dir name="lib">
@@ -92,6 +93,10 @@
      <dir name="conf.d">
       <file name="20-kolab.xml" role="horde" />
      </dir> <!-- /mnemo/config/conf.d -->
+     <file name="hooks.php" role="horde" />
+     <dir name="prefs.d">
+      <file name="20-kolab.php" role="horde" />
+     </dir> <!-- /mnemo/config/prefs.d -->
     </dir> <!-- /mnemo/config -->
    </dir> <!-- /mnemo -->
    <dir name="nag">
@@ -99,6 +104,10 @@
      <dir name="conf.d">
       <file name="20-kolab.xml" role="horde" />
      </dir> <!-- /nag/config/conf.d -->
+     <file name="hooks.php" role="horde" />
+     <dir name="prefs.d">
+      <file name="20-kolab.php" role="horde" />
+     </dir> <!-- /nag/config/prefs.d -->
     </dir> <!-- /nag/config -->
    </dir> <!-- /nag -->
    <dir name="turba">
@@ -110,6 +119,10 @@
       <file name="10-webmail.xml" role="horde" />
       <file name="20-kolab.xml" role="horde" />
      </dir> <!-- /turba/config/conf.d -->
+     <file name="hooks.php" role="horde" />
+     <dir name="prefs.d">
+      <file name="20-kolab.php" role="horde" />
+     </dir> <!-- /turba/config/prefs.d -->
     </dir> <!-- /turba/config -->
    </dir> <!-- /turba -->
    <file name="COPYING" role="doc" />
@@ -137,98 +150,105 @@
    <package>
     <name>content</name>
     <channel>pear.horde.org</channel>
-    <min>1.0.0</min>
-    <max>2.0.0</max>
-    <exclude>2.0.0</exclude>
+    <min>2.0.1</min>
+    <max>3.0.0</max>
+    <exclude>3.0.0</exclude>
    </package>
    <package>
     <name>horde</name>
     <channel>pear.horde.org</channel>
-    <min>4.0.7</min>
-    <max>5.0.0</max>
-    <exclude>5.0.0</exclude>
+    <min>5.0.3</min>
+    <max>6.0.0</max>
+    <exclude>6.0.0</exclude>
    </package>
    <package>
     <name>imp</name>
     <channel>pear.horde.org</channel>
-    <min>5.0.8</min>
-    <max>6.0.0</max>
-    <exclude>6.0.0</exclude>
+    <min>6.0.3</min>
+    <max>7.0.0</max>
+    <exclude>7.0.0</exclude>
    </package>
    <package>
     <name>ingo</name>
     <channel>pear.horde.org</channel>
-    <min>2.0.3</min>
-    <max>3.0.0</max>
-    <exclude>3.0.0</exclude>
+    <min>3.0.2</min>
+    <max>4.0.0</max>
+    <exclude>4.0.0</exclude>
    </package>
    <package>
     <name>kronolith</name>
     <channel>pear.horde.org</channel>
-    <min>3.0.5</min>
-    <max>4.0.0</max>
-    <exclude>4.0.0</exclude>
+    <min>4.0.3</min>
+    <max>5.0.0</max>
+    <exclude>5.0.0</exclude>
    </package>
    <package>
     <name>mnemo</name>
     <channel>pear.horde.org</channel>
-    <min>3.0.1</min>
-    <max>4.0.0</max>
-    <exclude>4.0.0</exclude>
+    <min>4.0.2</min>
+    <max>5.0.0</max>
+    <exclude>5.0.0</exclude>
    </package>
    <package>
     <name>nag</name>
     <channel>pear.horde.org</channel>
-    <min>3.0.2</min>
-    <max>4.0.0</max>
-    <exclude>4.0.0</exclude>
+    <min>4.0.2</min>
+    <max>5.0.0</max>
+    <exclude>5.0.0</exclude>
    </package>
    <package>
     <name>timeobjects</name>
     <channel>pear.horde.org</channel>
-    <min>1.0.1</min>
-    <max>2.0.0</max>
-    <exclude>2.0.0</exclude>
+    <min>2.0.2</min>
+    <max>3.0.0</max>
+    <exclude>3.0.0</exclude>
    </package>
    <package>
     <name>turba</name>
     <channel>pear.horde.org</channel>
-    <min>3.0.4</min>
-    <max>4.0.0</max>
-    <exclude>4.0.0</exclude>
+    <min>4.0.2</min>
+    <max>5.0.0</max>
+    <exclude>5.0.0</exclude>
+   </package>
+   <package>
+    <name>Horde_Kolab_Format</name>
+    <channel>pear.horde.org</channel>
+    <min>2.0.2</min>
+    <max>3.0.0</max>
+    <exclude>3.0.0</exclude>
    </package>
    <package>
     <name>Horde_Kolab_Server</name>
     <channel>pear.horde.org</channel>
-    <min>1.0.0</min>
-    <max>2.0.0</max>
-    <exclude>2.0.0</exclude>
+    <min>2.0.1</min>
+    <max>3.0.0</max>
+    <exclude>3.0.0</exclude>
    </package>
    <package>
     <name>Horde_Kolab_Session</name>
     <channel>pear.horde.org</channel>
-    <min>1.0.0</min>
-    <max>2.0.0</max>
-    <exclude>2.0.0</exclude>
+    <min>2.0.1</min>
+    <max>3.0.0</max>
+    <exclude>3.0.0</exclude>
    </package>
    <package>
     <name>Horde_Kolab_Storage</name>
     <channel>pear.horde.org</channel>
-    <min>1.0.0</min>
-    <max>2.0.0</max>
-    <exclude>2.0.0</exclude>
+    <min>2.0.3</min>
+    <max>3.0.0</max>
+    <exclude>3.0.0</exclude>
    </package>
    <package>
     <name>Horde_Ldap</name>
     <channel>pear.horde.org</channel>
-    <min>1.0.0</min>
-    <max>2.0.0</max>
-    <exclude>2.0.0</exclude>
+    <min>2.0.1</min>
+    <max>3.0.0</max>
+    <exclude>3.0.0</exclude>
    </package>
    <package>
     <name>Net_SMTP</name>
     <channel>pear.php.net</channel>
-    <min>1.6.0</min>
+    <min>1.6.1</min>
    </package>
    <package>
     <name>Net_Sieve</name>
@@ -247,52 +267,58 @@
  </usesrole>
  <phprelease>
   <filelist>
+   <install as="COPYING" name="COPYING" />
    <install as="README" name="README" />
-   <install as="kolab-webmail-install" name="bin/kolab-webmail-install" />
-   <install as="config/hooks.php" name="config/hooks.php" />
+   <install as="bin/kolab-webmail-install" name="bin/kolab-webmail-install" />
    <install as="config/conf.d/20-kolab.xml" name="config/conf.d/20-kolab.xml" />
+   <install as="config/hooks.php" name="config/hooks.php" />
    <install as="config/prefs.d/10-webmail.php" name="config/prefs.d/10-webmail.php" />
    <install as="config/prefs.d/20-kolab.php" name="config/prefs.d/20-kolab.php" />
    <install as="config/registry.d/20-kolab.php" name="config/registry.d/20-kolab.php" />
-   <install as="CHANGES" name="docs/CHANGES" />
-   <install as="INSTALL" name="docs/INSTALL" />
-   <install as="PERFORMANCE" name="docs/PERFORMANCE" />
-   <install as="RELEASE_NOTES" name="docs/RELEASE_NOTES" />
-   <install as="TODO" name="docs/TODO" />
-   <install as="UPGRADING" name="docs/UPGRADING" />
-   <install as="imp/config/hooks.php" name="imp/config/hooks.php" />
+   <install as="docs/CHANGES" name="docs/CHANGES" />
+   <install as="docs/INSTALL" name="docs/INSTALL" />
+   <install as="docs/PERFORMANCE" name="docs/PERFORMANCE" />
+   <install as="docs/RELEASE_NOTES" name="docs/RELEASE_NOTES" />
+   <install as="docs/TODO" name="docs/TODO" />
+   <install as="docs/UPGRADING" name="docs/UPGRADING" />
    <install as="imp/config/backends.d/20-kolab.php" name="imp/config/backends.d/20-kolab.php" />
-   <install as="imp/config/conf.d/10-webmail.xml" name="imp/config/conf.d/10-webmail.xml" />
    <install as="imp/config/conf.d/20-kolab.php" name="imp/config/conf.d/20-kolab.php" />
    <install as="imp/config/prefs.d/10-webmail.php" name="imp/config/prefs.d/10-webmail.php" />
+   <install as="imp/config/hooks.php" name="imp/config/hooks.php" />
    <install as="ingo/config/backends.d/20-kolab.php" name="ingo/config/backends.d/20-kolab.php" />
    <install as="ingo/config/conf.d/20-kolab.xml" name="ingo/config/conf.d/20-kolab.xml" />
-   <install as="kronolith/config/conf.d/10-webmail.xml" name="kronolith/config/conf.d/10-webmail.xml" />
    <install as="kronolith/config/conf.d/20-kolab.php" name="kronolith/config/conf.d/20-kolab.php" />
    <install as="kronolith/config/conf.d/20-kolab.xml" name="kronolith/config/conf.d/20-kolab.xml" />
+   <install as="kronolith/config/hooks.php" name="kronolith/config/hooks.php" />
+   <install as="kronolith/config/prefs.d/20-kolab.php" name="kronolith/config/prefs.d/20-kolab.php" />
    <install as="lib/Bundle.php" name="lib/Bundle.php" />
    <install as="mnemo/config/conf.d/20-kolab.xml" name="mnemo/config/conf.d/20-kolab.xml" />
+   <install as="mnemo/config/hooks.php" name="mnemo/config/hooks.php" />
+   <install as="mnemo/config/prefs.d/20-kolab.php" name="mnemo/config/prefs.d/20-kolab.php" />
    <install as="nag/config/conf.d/20-kolab.xml" name="nag/config/conf.d/20-kolab.xml" />
+   <install as="nag/config/hooks.php" name="nag/config/hooks.php" />
+   <install as="nag/config/prefs.d/20-kolab.php" name="nag/config/prefs.d/20-kolab.php" />
    <install as="turba/config/backends.d/20-kolab.php" name="turba/config/backends.d/20-kolab.php" />
    <install as="turba/config/conf.d/10-webmail.xml" name="turba/config/conf.d/10-webmail.xml" />
-   <install as="COPYING" name="COPYING" />
    <install as="turba/config/conf.d/20-kolab.xml" name="turba/config/conf.d/20-kolab.xml" />
+   <install as="turba/config/prefs.d/20-kolab.php" name="turba/config/prefs.d/20-kolab.php" />
+   <install as="turba/config/hooks.php" name="turba/config/hooks.php" />
   </filelist>
  </phprelease>
  <changelog>
   <release>
    <version>
-     <release>4.0.0alpha1</release>
-     <api>4.0.0alpha1</api>
+     <release>5.0.0</release>
+     <api>5.0.0</api>
    </version>
    <stability>
-    <release>alpha</release>
-    <api>alpha</api>
+    <release>stable</release>
+    <api>stable</api>
    </stability>
-   <date>2011-11-29</date>
+   <date>2013-01-30</date>
    <license uri="http://www.horde.org/licenses/gpl">GPL-2.0</license>
    <notes>
-* First release candidate of Horde Kolab Edition 4.0.
+* First release candidate of Horde Kolab Edition 5.0.
    </notes>
   </release>
  </changelog>
diff --git a/bundles/kolab_webmail/turba/config/backends.d/20-kolab.php b/bundles/kolab_webmail/turba/config/backends.d/20-kolab.php
index de4bbce..c267017 100644
--- a/bundles/kolab_webmail/turba/config/backends.d/20-kolab.php
+++ b/bundles/kolab_webmail/turba/config/backends.d/20-kolab.php
@@ -78,14 +78,9 @@ $cfgSources['kolab_global'] = array(
     'browse' => true,
 );
 
-/**
- * A local address book on a Kolab or IMAP server. This implements a private
+/* A local address book on a IMAP or Kolab server. This implements a private
  * per-user address book. Sharing of this source with other users is
  * accomplished by IMAP ACLs and by setting 'use_shares' => true.
- *
- * Still missing attributes are:
- *
- *   picture, sensitivity
  */
 $cfgSources['kolab'] = array(
     // ENABLED by default
@@ -95,7 +90,7 @@ $cfgSources['kolab'] = array(
     'params' => array(
     ),
     'map' => array(
-        '__key' => 'uid',
+        '__key' => '__key',
         '__uid' => 'uid',
         '__type' => '__type',
         '__members' => '__members',
@@ -112,11 +107,15 @@ $cfgSources['kolab'] = array(
                                   'format' => '%s, %s'),
                             array('fields' => array('firstname', 'lastname'),
                                   'format' => '%s %s'))),
-        'firstname'         => 'given-name',
-        'lastname'          => 'last-name',
-        'middlenames'       => 'middle-names',
-        'namePrefix'        => 'prefix',
-        'nameSuffix'        => 'suffix',
+        'firstname' => 'given-name',
+        'lastname' => 'last-name',
+        'middlenames' => 'middle-names',
+        'namePrefix' => 'prefix',
+        'nameSuffix' => 'suffix',
+        // This is a shorter version of a "name" composite field which only
+        // consists of the first name and last name.
+        // 'name' => array('fields' => array('firstname', 'lastname'),
+        //                 'format' => '%s %s'),
         'initials'          => 'initials',
         'nickname'          => 'nick-name',
         'photo'             => 'photo',
@@ -131,12 +130,12 @@ $cfgSources['kolab'] = array(
         'workCity'          => 'addr-business-locality',
         'workProvince'      => 'addr-business-region',
         'workPostalCode'    => 'addr-business-postal-code',
-        'workCountry'       => 'addr-business-country',
+        'workCountryFree'   => 'addr-business-country',
         'homeStreet'        => 'addr-home-street',
         'homeCity'          => 'addr-home-locality',
         'homeProvince'      => 'addr-home-region',
         'homePostalCode'    => 'addr-home-postal-code',
-        'homeCountry'       => 'addr-home-country',
+        'homeCountryFree'   => 'addr-home-country',
         /* Communications */
         'emails'            => 'emails',
         'homePhone'         => 'phone-home1',
@@ -161,7 +160,6 @@ $cfgSources['kolab'] = array(
         'latitude'          => 'latitude',
         'longitude'         => 'longitude',
         /* Invisible */
-        'email'             => 'email',
         'pgpPublicKey'      => 'pgp-publickey',
     ),
     'tabs' => array(
@@ -170,9 +168,9 @@ $cfgSources['kolab'] = array(
                                'nickname', 'gender', 'birthday', 'spouse',
                                'anniversary', 'children', 'photo'),
         _("Location") => array('workStreet', 'workCity', 'workProvince',
-                               'workPostalCode', 'workCountry',
+                               'workPostalCode', 'workCountryFree',
                                'homeStreet', 'homeCity', 'homeProvince',
-                               'homePostalCode', 'homeCountry'),
+                               'homePostalCode', 'homeCountryFree'),
         _("Communications") => array('emails', 'homePhone', 'workPhone',
                                      'cellPhone', 'fax', 'instantMessenger'),
         _("Organization") => array('title', 'role', 'company', 'department',
@@ -193,3 +191,4 @@ $cfgSources['kolab'] = array(
     'use_shares' => true,
     'all_shares' => true,
 );
+
diff --git a/bundles/kolab_webmail/turba/config/hooks.php b/bundles/kolab_webmail/turba/config/hooks.php
index ea95aaf..e34b0ed 100644
--- a/bundles/kolab_webmail/turba/config/hooks.php
+++ b/bundles/kolab_webmail/turba/config/hooks.php
@@ -34,4 +34,26 @@ class Turba_Hooks
            return $primary;
        }
    }
+
+   public function prefs_change($pref)
+   {
+       switch ($pref) {
+       case 'default_dir':
+           $value = $GLOBALS['prefs']->getValue('default_dir');
+           $addressbooks = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Share')
+               ->create()
+               ->listShares(
+                   $GLOBALS['registry']->getAuth(),
+                   array('perm' => Horde_Perms::SHOW,
+                         'attributes' => $GLOBALS['registry']->getAuth()));
+           foreach ($addressbooks as $id => $addressbook) {
+               if ($id == $value) {
+                   $addressbook->set('default', true);
+                   $addressbook->save();
+                   break;
+               }
+           }
+           break;
+       }
+   }
 }
\ No newline at end of file
-- 
1.7.3.4