gunnar: server/patches/horde HK-GW-framework_3.2_ALPHA-Fix_the_share_params.patch, NONE, 1.1 HK-GW-mnemo_2.2_ALPHA-Edit_share_rights.patch, NONE, 1.1 HK-GW-turba_2.2-Changes_after_ALPHA.patch, NONE, 1.1 HK-GW-turba_2.2-Fix_address_book_deletion_1.patch, NONE, 1.1 HK-GW-turba_2.2-Fix_editing_contacts.patch, NONE, 1.1 HK-GW-turba_2.2-Fix_notice_on_addressbook_creation.patch, NONE, 1.1 HK-GW-turba_2.2-Fix_share_id_change.patch, NONE, 1.1 HK-GW-turba_2.2-Ldap_read_only_fix.patch, NONE, 1.1 README_Changes_after_ALPHA.patch, NONE, 1.1 README_Edit_share_rights.patch, NONE, 1.1 README_Fix_address_book_deletion_1.patch, NONE, 1.1 README_Fix_editing_contacts.patch, NONE, 1.1 README_Fix_notice_on_addressbook_creation.patch, NONE, 1.1 README_Fix_share_id_change.patch, NONE, 1.1 README_Fix_the_share_params.patch, NONE, 1.1 README_Ldap_read_only_fix.patch, NONE, 1.1

cvs at kolab.org cvs at kolab.org
Tue Oct 2 16:21:36 CEST 2007


Author: gunnar

Update of /kolabrepository/server/patches/horde
In directory doto:/tmp/cvs-serv6110/patches/horde

Added Files:
	HK-GW-framework_3.2_ALPHA-Fix_the_share_params.patch 
	HK-GW-mnemo_2.2_ALPHA-Edit_share_rights.patch 
	HK-GW-turba_2.2-Changes_after_ALPHA.patch 
	HK-GW-turba_2.2-Fix_address_book_deletion_1.patch 
	HK-GW-turba_2.2-Fix_editing_contacts.patch 
	HK-GW-turba_2.2-Fix_notice_on_addressbook_creation.patch 
	HK-GW-turba_2.2-Fix_share_id_change.patch 
	HK-GW-turba_2.2-Ldap_read_only_fix.patch 
	README_Changes_after_ALPHA.patch 
	README_Edit_share_rights.patch 
	README_Fix_address_book_deletion_1.patch 
	README_Fix_editing_contacts.patch 
	README_Fix_notice_on_addressbook_creation.patch 
	README_Fix_share_id_change.patch 
	README_Fix_the_share_params.patch 
	README_Ldap_read_only_fix.patch 
Log Message:
Adding the necessary turba and mnemo fixes for the next beta release.

--- NEW FILE: HK-GW-framework_3.2_ALPHA-Fix_the_share_params.patch ---
Fixes the params array now used in turba.

diff -r e60357d4352e framework/Share/Share/kolab.php
--- a/framework/Share/Share/kolab.php	Tue Oct 02 10:28:53 2007 +0200
+++ b/framework/Share/Share/kolab.php	Tue Oct 02 11:47:54 2007 +0200
@@ -1036,7 +1036,9 @@ class ImapObject_Share {
         case 'params':
             $params = $this->getAttribute('params');
             if (is_a($params, 'PEAR_Error') || $params == '') {
-                $params = serialize(array('source' => 'kolab'));
+                $params = serialize(array('source' => 'kolab',
+                                          'default' => $this->get('default'),
+                                          'name' => $this->get('name')));
             }
             $this->data['params'] = $params;
             break;
@@ -1080,6 +1082,13 @@ class ImapObject_Share {
             }
             $this->data['folder'] = String::convertCharset($value, NLS::getCharset(), 'UTF7-IMAP');
             $this->data['name'] = $this->getTitle($this->data['folder']);
+            break;
+
+        case 'params':
+            $value = unserialize($value);
+            if (isset($value['default'])) {
+                $this->data['default'] = $value['default'];
+            }
             break;
 
         default:

--- NEW FILE: HK-GW-mnemo_2.2_ALPHA-Edit_share_rights.patch ---
Allow to edit Kolab share rights for the notepads displayed by mnemo.

diff -r 2318390b621a mnemo/templates/notepads/notepads.inc
--- a/mnemo/templates/notepads/notepads.inc	Tue Sep 25 11:50:19 2007 +0200
+++ b/mnemo/templates/notepads/notepads.inc	Tue Sep 25 11:52:12 2007 +0200
@@ -53,7 +53,7 @@ function updateForm(share)
 <p><?php echo Horde::label('id', _("Name:")) ?><br />
 <input id="id" name="id" size="30" maxlength="60" /><br />
 <?php if (empty($conf['shares']['no_sharing'])): ?>
-<input type="button" name="accesslist" class="button" onclick="popup(editURL.replace(/%40ID%40/, document.shares.edit_share.value));" value="<?php echo _("Permissions") ?>" style="display:none" />
+<input type="button" name="accesslist" class="button" onclick="popup(editURL.replace(/%40ID%40/, encodeURIComponent(document.shares.edit_share.value)));" value="<?php echo _("Permissions") ?>" style="display:none" />
 <?php endif; ?>
 </p>
 

--- NEW FILE: HK-GW-turba_2.2-Changes_after_ALPHA.patch ---
Some necessary fixes for Turba from CVS.

diff -r 0ca2d81b250b turba/addressbooks.php
--- a/turba/addressbooks.php	Tue Oct 02 15:05:12 2007 +0200
+++ b/turba/addressbooks.php	Tue Oct 02 15:12:26 2007 +0200
@@ -4,7 +4,7 @@
  *
  * Copyright 2005-2007 The Horde Project (http://www.horde.org/)
  *
- * $Horde: turba/addressbooks.php,v 1.32 2007/08/01 10:43:29 jan Exp $
+ * $Horde: turba/addressbooks.php,v 1.33 2007/08/16 17:35:26 mrubinsk Exp $
  *
  * See the enclosed file LICENSE for license information (ASL).  If you did
  * did not receive this file, see http://www.horde.org/licenses/asl.php.
@@ -102,7 +102,6 @@ case 'add':
         $notification->push(sprintf(_("There was an error creating this address book: %s"), $share->getMessage()), 'horde.error');
     } else {
         $notification->push(sprintf(_("The address book \"%s\" was created successfully."), $share->get('name')), 'horde.success');
-        Turba::addSourceFromShare($share);
     }
 
     header('Location: ' . Horde::applicationUrl('addressbooks.php', true));
diff -r 0ca2d81b250b turba/lib/Driver/kolab.php
--- a/turba/lib/Driver/kolab.php	Tue Oct 02 15:05:12 2007 +0200
+++ b/turba/lib/Driver/kolab.php	Tue Oct 02 15:12:26 2007 +0200
@@ -2,7 +2,7 @@
 /**
  * @package Turba
  *
- * $Horde: turba/lib/Driver/kolab.php,v 1.27 2007/06/19 09:50:30 wrobel Exp $
+ * $Horde: turba/lib/Driver/kolab.php,v 1.28 2007/09/19 07:43:19 wrobel Exp $
  */
 
 /** Kolab support class. */
@@ -151,12 +151,36 @@ class Turba_Driver_kolab extends Turba_D
         }
     }
 
+    /**
+     * Creates a new Horde_Share
+     *
+     * @param array  The params for the share.
+     *
+     * @return mixed  The share object or PEAR_Error.
+     * @since Turba 2.2
+     */
+    function &createShare($share_id, $params)
+    {
+        if (isset($params['params']['default']) && $params['params']['default'] === true) {
+            $share_id = Auth::getAuth();
+        }
+        
+        $result = &Turba::createShare($share_id, $params);
+        return $result;
+    }
+
+    function checkDefaultShare(&$share, $srcConfig)
+    {
+        $params = @unserialize($share->get('params'));
+        return $params['default'];
+    }
+
 }
 
 /**
  * Horde Turba wrapper to distinguish between both Kolab driver implementations.
  *
- * $Horde: turba/lib/Driver/kolab.php,v 1.27 2007/06/19 09:50:30 wrobel Exp $
+ * $Horde: turba/lib/Driver/kolab.php,v 1.28 2007/09/19 07:43:19 wrobel Exp $
  *
  * Copyright 2004-2007 The Horde Project (http://www.horde.org/)
  *
diff -r 0ca2d81b250b turba/lib/Turba.php
--- a/turba/lib/Turba.php	Tue Oct 02 15:05:12 2007 +0200
+++ b/turba/lib/Turba.php	Tue Oct 02 15:12:26 2007 +0200
@@ -1,6 +1,6 @@
 <?php
 /**
- * $Horde: turba/lib/Turba.php,v 1.148 2007/08/02 21:19:27 mrubinsk Exp $
+ * $Horde: turba/lib/Turba.php,v 1.152 2007/08/24 19:37:54 mrubinsk Exp $
  *
  * @package Turba
  */
@@ -213,8 +213,6 @@ class Turba {
      */
     function guessLastname($name)
     {
-        global $prefs;
-
         $name = trim(preg_replace('|\s|', ' ', $name));
         if (!empty($name)) {
             /* Assume that last names are always before any commas. */
@@ -469,24 +467,27 @@ class Turba {
     }
 
     /**
-     * Add a new source entry based on a Turba share directly to $cfgSources,
-     * bypassing any permission checking.
-     *
-     * @param Horde_Share object  The share to add.
+     * Retrieve a new source config entry based on a Turba share.
+     *
+     * @param Horde_Share object  The share to base config on.
+     *
      * @since Turba 2.2
      */
-    function addSourceFromShare(&$share)
-    {
-        $name = $share->getName();
-        if (!isset($GLOBALS['cfgSources'][$name])) {
-            list($source, $user) = explode(':', $name, 2);
-            if ($user != Auth::getAuth()) {
-                $newSrc = $GLOBALS['cfgSources'][$source];
-                unset($newSrc['use_shares']);
-                $newSrc['title'] = $share->get('name');
-                $GLOBALS['cfgSources'][$name] = $newSrc;
-            }
-        }
+    function getSourceFromShare(&$share)
+    {
+        // Require a fresh config file.
+        require TURBA_BASE . '/config/sources.php';
+
+        $params = @unserialize($share->get('params'));
+        $newConfig = $cfgSources[$params['source']];
+        $newConfig['params']['config'] = $cfgSources[$params['source']];
+        $newConfig['params']['config']['params']['share'] = &$share;
+        $newConfig['params']['config']['params']['name'] = $params['name'];
+        $newConfig['title'] = $share->get('name');
+        $newConfig['type'] = 'share';
+        $newConfig['use_shares'] = false;
+
+        return $newConfig;
     }
 
     /**
@@ -616,10 +617,13 @@ class Turba {
 
         // Kinda hackish way of indicating what tasks need to run, until
         // a more general mechanism is available.
-        $needed_tasks = array('upgradeprefs');
+        $needed_tasks = array('upgradeprefs', 'upgradelists');
 
         $successful = array();
         $existing = @unserialize($GLOBALS['prefs']->getValue('turba_maintenance_tasks'));
+        if (empty($existing)) {
+            $existing = array();
+        }
         foreach ($needed_tasks as $taskname) {
             if (array_search($taskname, $existing) === false) {
                 include dirname(__file__) . '/Maintenance/Task/' . basename($taskname) . '.php';
diff -r 0ca2d81b250b turba/lib/api.php
--- a/turba/lib/api.php	Tue Oct 02 15:05:12 2007 +0200
+++ b/turba/lib/api.php	Tue Oct 02 15:12:26 2007 +0200
@@ -2,7 +2,7 @@
 /**
  * Turba external API interface.
  *
- * $Horde: turba/lib/api.php,v 1.214 2007/08/02 04:37:18 chuck Exp $
+ * $Horde: turba/lib/api.php,v 1.219 2007/08/29 12:13:30 jan Exp $
  *
  * This file defines Turba's external API interface. Other applications can
  * interact with Turba through this API.
@@ -180,18 +180,34 @@ function _turba_removeUserData($user)
 
     /* We need a clean copy of the $cfgSources array here.*/
     require TURBA_BASE . '/config/sources.php';
-
     $hasError = false;
-    $sourceKeys = array_keys($cfgSources);
-    foreach ($sourceKeys as $sourceKey) {
-        $driver = &Turba_Driver::singleton($sourceKey);
-        if (is_a($driver, 'PEAR_Error')) {
+    $shares = null;
+
+    foreach ($cfgSources as $source) {
+        if (empty($source['use_shares'])) {
+            // Shares not enabled for this source
+            $driver = &Turba_Driver::singleton($source);
+            if (is_a($driver, 'PEAR_Error')) {
+                $hasError = true;
+            } else {
+                $result = $driver->removeUserData($user);
+                if (is_a($result, 'PEAR_Error')) {
+                    $hasError = true;
+                }
+            }
+        }
+    }
+
+    $shares = &$GLOBALS['turba_shares']->listShares($user,
+                                                    PERMS_EDIT,
+                                                    $user);
+    foreach ($shares as $share) {
+        $params = @unserialize($share->get('params'));
+        $config = Turba::getSourceFromShare($share);
+        $driver = &Turba_Driver::singleton($config);
+        $result = $driver->removeUserData($user);
+        if (is_a($result, 'PEAR_Error')) {
             $hasError = true;
-        } else {
-            $result = $driver->removeUserData($user);
-            if (is_a($result, 'PEAR_Error')) {
-                $hasError = true;
-            }
         }
     }
 
@@ -918,6 +934,10 @@ function _turba_search($names = array(),
         return array();
     }
 
+    if (!is_array($names)) {
+        $names = is_null($names) ? array() : array($names);
+    }
+
     if (!count($sources)) {
         $sources = array(key($cfgSources));
     }
@@ -934,7 +954,8 @@ function _turba_search($names = array(),
         }
 
         // Skip sources that aren't browseable if the search is empty.
-        if (!count($names) && empty($cfgSources[$source]['browse'])) {
+        if (empty($cfgSources[$source]['browse'])
+            && (!count($names) || (count($names) == 1 && empty($names[0])))) {
             continue;
         }
 
@@ -1024,6 +1045,7 @@ function _turba_search($names = array(),
                     $listatt = $ob->getAttributes();
                     $seeninlist = array();
                     $members = $ob->listMembers();
+                    $listName = $ob->getValue('name');
                     if (is_a($members, 'Turba_List')) {
                         if ($members->count() > 0) {
                             if (!isset($results[$name])) {
@@ -1032,7 +1054,8 @@ function _turba_search($names = array(),
                             $emails = array();
                             while ($ob = $members->next()) {
                                 $att = $ob->getAttributes();
-                                foreach ($att as $key => $value) {
+                                foreach (array_keys($att) as $key) {
+                                    $value = $ob->getValue($key);
                                     if (!empty($value) && isset($attributes[$key]) &&
                                         $attributes[$key]['type'] == 'email' &&
                                         empty($seeninlist[trim(String::lower($att['name'])) . trim(String::lower($value))])) {
@@ -1042,7 +1065,7 @@ function _turba_search($names = array(),
                                     }
                                 }
                             }
-                            $results[$name][] = array('name' => $listatt['name'], 'email' => implode(', ', $emails), 'id' => $listatt['__key'], 'source' => $source);
+                            $results[$name][] = array('name' => $listName, 'email' => implode(', ', $emails), 'id' => $listatt['__key'], 'source' => $source);
                         }
                     }
                 }
diff -r 0ca2d81b250b turba/templates/addressbooks.inc
--- a/turba/templates/addressbooks.inc	Tue Oct 02 15:05:12 2007 +0200
+++ b/turba/templates/addressbooks.inc	Tue Oct 02 15:12:26 2007 +0200
@@ -120,7 +120,7 @@ function verifyDelete()
     <strong><?php echo _("Permissions") ?></strong>
    </td>
    <td>
-    <input type="button" name="perms" class="button" onclick="if (document.editshares.editshare.value) popup(editURL.replace(/%40ID%40/, document.editshares.editshare.value));" value="<?php echo _("Edit") ?>" />
+    <input type="button" name="perms" class="button" onclick="if (document.editshares.editshare.value) popup(editURL.replace(/%40ID%40/, encodeURIComponent(document.editshares.editshare.value)));" value="<?php echo _("Edit") ?>" />
    </td>
   </tr>
 <?php endif; ?>

--- NEW FILE: HK-GW-turba_2.2-Fix_address_book_deletion_1.patch ---
Fixes address book deletion.

diff -r 8e461aedd317 turba/lib/Driver/kolab.php
--- a/turba/lib/Driver/kolab.php	Tue Oct 02 09:24:16 2007 +0200
+++ b/turba/lib/Driver/kolab.php	Tue Oct 02 09:30:45 2007 +0200
@@ -892,11 +892,6 @@ class Turba_Driver_kolab_wrapper_new ext
             return $result;
         }
 
-        if ($sourceName != null) {
-            Horde::logMessage('deleteAll only working for current share. Called for $sourceName', __FILE__, __LINE__, PEAR_LOG_ERR);
-            return PEAR::raiseError(sprintf(_("Cannot delete all address book entries for %s"), $sourceName));
-        }
-
         return $this->_store->deleteAll();
     }
 

--- NEW FILE: HK-GW-turba_2.2-Fix_editing_contacts.patch ---
Fixes editing contacts.

diff -r de15e2f26408 turba/lib/Driver/share.php
--- a/turba/lib/Driver/share.php	Tue Oct 02 12:25:42 2007 +0200
+++ b/turba/lib/Driver/share.php	Tue Oct 02 12:38:50 2007 +0200
@@ -58,7 +58,7 @@ class Turba_Driver_share extends Turba_D
      */
     function getName()
     {
-        $share_parts = explode(':', $this->_share->getName());
+        $share_parts = explode(':', $this->_share->getId());
         return array_pop($share_parts);
     }
 

--- NEW FILE: HK-GW-turba_2.2-Fix_notice_on_addressbook_creation.patch ---
Fixes a notice when creating a new share.

diff -r 6da2fcb4e060 turba/lib/Driver/kolab.php
--- a/turba/lib/Driver/kolab.php	Tue Oct 02 07:47:47 2007 +0200
+++ b/turba/lib/Driver/kolab.php	Tue Oct 02 08:18:26 2007 +0200
@@ -222,7 +222,7 @@ class Turba_Driver_kolab_wrapper {
      */
     function Turba_Driver_kolab_wrapper($addressbook, &$kolab)
     {
-        if ($addressbook[0] == '_') {
+        if ($addressbook && $addressbook[0] == '_') {
             $addressbook = substr($addressbook, 1);
         }
         $this->_addressbook = $addressbook;

--- NEW FILE: HK-GW-turba_2.2-Fix_share_id_change.patch ---
This fixes a problem with the way the Kolab share driver handles ids.

diff -r dd05e667699d turba/lib/Turba.php
--- a/turba/lib/Turba.php	Tue Oct 02 06:47:29 2007 +0200
+++ b/turba/lib/Turba.php	Tue Oct 02 06:55:13 2007 +0200
@@ -439,7 +439,7 @@ class Turba {
 
                         $source_config = $sources[$source];
                         $source_config['params']['share'] = &$share;
-                        $sources[$sourceKey] = $source_config;
+                        $sources[$share->getId()] = $source_config;
                     } else {
                         $notification->push($driver, 'horde.error');
                     }
@@ -564,7 +564,7 @@ class Turba {
         /* Add the new addressbook to the user's list of visible
          * address books. */
         $prefs = explode("\n", $GLOBALS['prefs']->getValue('addressbooks'));
-        if (array_search($share_id, $prefs) === false) {
+        if (array_search($share->getId(), $prefs) === false) {
             $GLOBALS['prefs']->setValue('addressbooks', $GLOBALS['prefs']->getValue('addressbooks') . "\n" . $share_id);
         }
         return $share;

--- NEW FILE: HK-GW-turba_2.2-Ldap_read_only_fix.patch ---
This is a temporary fix to mark the ldap addressbook as read-only. This should be solved with the Horde Perms package but this needs a new driver.

diff -r b7be146cb26a turba/lib/Driver/ldap.php
--- a/turba/lib/Driver/ldap.php	Tue Oct 02 07:18:36 2007 +0200
+++ b/turba/lib/Driver/ldap.php	Tue Oct 02 07:19:20 2007 +0200
@@ -53,6 +53,9 @@ class Turba_Driver_ldap extends Turba_Dr
         }
         if (empty($params['deref'])) {
             $params['deref'] = LDAP_DEREF_NEVER;
+        }
+        if (empty($params['read_only'])) {
+            $params['read_only'] = false;
         }
 
         parent::Turba_Driver($params);
@@ -749,4 +752,25 @@ class Turba_Driver_ldap extends Turba_Dr
         return $dn;
     }
 
+    /**
+     * Checks if the current user has the requested permission
+     * on this source.
+     *
+     * @param integer $perm  The permission to check for.
+     *
+     * @return boolean  true if user has permission, false otherwise.
+     */
+     function hasPermission($perm)
+    {
+        if ($this->_params['read_only'] === false) {
+            return parent::hasPermission($perm);
+        } else {
+            switch ($perm) {
+                case PERMS_EDIT: return false;
+                case PERMS_DELETE: return false;
+                default: return parent::hasPermission($perm);
+            }
+        }
+    }
+
 }

--- NEW FILE: README_Changes_after_ALPHA.patch ---
DESCRIPTION:

These are CVS changes that ocurred in Turba after the ALPHA 
release and are relevant to the share system.

IMPACT:

Turba will fail to work without this patch.

REFERENCES:

Mercurial patch repository:

http://hg.pardus.de/cgi-bin/hg.cgi/horde/HORDE_3_2_ALPHA/summary

HISTORY

Applied upstream.
--- NEW FILE: README_Edit_share_rights.patch ---
DESCRIPTION:

Allows editing share rights for shares other than the default
share. This is a fix that has already been applied upstream but is
still missing from the ALPHA release. This will become obsolete with
the next Horde release.

IMPACT:

Mnemo will not allow you to edit share rights without this.

REFERENCES:

Mercurial patch repository:

http://hg.pardus.de/cgi-bin/hg.cgi/horde/HORDE_3_2_ALPHA/summary

HISTORY

Applied upstream.
--- NEW FILE: README_Fix_address_book_deletion_1.patch ---
DESCRIPTION:

Minor fix to correct deletion of shared addressbooks.

IMPACT:

Probably none.

REFERENCES:

Mercurial patch repository:

http://hg.pardus.de/cgi-bin/hg.cgi/horde/HORDE_3_2_ALPHA/summary

HISTORY

Applied upstream.
--- NEW FILE: README_Fix_editing_contacts.patch ---
DESCRIPTION:

Fixes an issue with some links to the contact editing page.

IMPACT:

Turba will not allow you to edit some contacts.

REFERENCES:

Mercurial patch repository:

http://hg.pardus.de/cgi-bin/hg.cgi/horde/HORDE_3_2_ALPHA/summary

HISTORY

Horde issue # 5763
--- NEW FILE: README_Fix_notice_on_addressbook_creation.patch ---
DESCRIPTION:

Removes a PHP notice when you edit an addressbook.

IMPACT:

Removes the notice.

REFERENCES:

Mercurial patch repository:

http://hg.pardus.de/cgi-bin/hg.cgi/horde/HORDE_3_2_ALPHA/summary

HISTORY

Applied upstream.
--- NEW FILE: README_Fix_share_id_change.patch ---
DESCRIPTION:

Kolab shares currently have a problematic way of handling
share ids. This is a workaround in Turba to fix the problem.

IMPACT:

Turba will behave strange when you create new shares.

REFERENCES:

Mercurial patch repository:

http://hg.pardus.de/cgi-bin/hg.cgi/horde/HORDE_3_2_ALPHA/summary

HISTORY

Horde issue # 5762
--- NEW FILE: README_Fix_the_share_params.patch ---
DESCRIPTION:

Fixes the way Turba now handles share parameters.

IMPACT:

Turba will not allow you to edit shares without this.

REFERENCES:

Mercurial patch repository:

http://hg.pardus.de/cgi-bin/hg.cgi/horde/HORDE_3_2_ALPHA/summary

HISTORY

Applied upstream.
--- NEW FILE: README_Ldap_read_only_fix.patch ---
DESCRIPTION:

Marks the LDAP addressbook as read only.

IMPACT:

Turba will pretend to allow you to write to the global addresses
which will fail lif you really try to do so.

REFERENCES:

Mercurial patch repository:

http://hg.pardus.de/cgi-bin/hg.cgi/horde/HORDE_3_2_ALPHA/summary

HISTORY

Is a bad patch since we currently don't have the permission
system file based.




More information about the commits mailing list