Fix the modification of objects for hidden LDAP attributes (e.g. openLDAPaci)
authorGunnar Wrobel <p@rdus.de>
Tue, 16 Jun 2009 14:41:44 +0000 (16:41 +0200)
committerGunnar Wrobel <p@rdus.de>
Tue, 16 Jun 2009 14:41:44 +0000 (16:41 +0200)
framework/Kolab_Server/lib/Horde/Kolab/Server/Ldap.php
framework/Kolab_Server/lib/Horde/Kolab/Server/Object.php

index 1caefa0..898bd01 100644 (file)
@@ -245,9 +245,8 @@ class Horde_Kolab_Server_Ldap extends Horde_Kolab_Server
                                                        Horde_Kolab_Server_Exception::SYSTEM);
             }
         } else {
-            /* Net_LDAP2 will work on this as a reference */
-            $mod_uid = $uid;
-            $result = $this->_ldap->modify($mod_uid, $data);
+            $entry  = $this->_ldap->getEntry($mod_uid, $changes['attributes']);
+            $result = $this->_ldap->modify($entry, $data);
             if ($result instanceOf PEAR_Error) {
                 throw new Horde_Kolab_Server_Exception($result,
                                                        Horde_Kolab_Server_Exception::SYSTEM);
index dcbd528..063b8e0 100644 (file)
@@ -895,8 +895,10 @@ class Horde_Kolab_Server_Object
                 }
                 if ($old === false && !($value === null || $value === '' || $value === array())) {
                     $changes['add'][$key] = $value;
+                    $changes['attributes'][] = $key;
                 } else if ($old !== false && ($value === null || $value === '' || $value === array())) {
                     $changes['delete'][] = $key;
+                    $changes['attributes'][] = $key;
                 } else if (is_array($old) || is_array($value)) {
                     if (!is_array($old)) {
                         $old = array($old);
@@ -907,17 +909,22 @@ class Horde_Kolab_Server_Object
                     $adds = array_diff($value, $old);
                     if (!empty($adds)) {
                         $changes['add'][$key] = $adds;
+                        $changes['attributes'][] = $key;
                     }
                     $deletes = array_diff($old, $value);
                     if (!empty($deletes)) {
                         $changes['delete'][$key] = $deletes;
+                        $changes['attributes'][] = $key;
                     }
                 } else {
                     $changes['replace'][$key] = $value;
+                    $changes['attributes'][] = $key;
                 }
             }
         }
 
+        $changes['attributes'] = array_unique($changes['attributes']);
+
         return $changes;
     }
 
@@ -929,7 +936,7 @@ class Horde_Kolab_Server_Object
      *
      * @return array The differences between both arrays.
      */
-    protected function getArrayChanges($a1, $a2)
+    public function getArrayChanges($a1, $a2)
     {
         if (empty($a1) || empty($a2)) {
             return !empty($a1) ? $a1 : $a2;