Fix the id generation for object modifications.
authorGunnar Wrobel <p@rdus.de>
Wed, 29 Apr 2009 08:20:31 +0000 (10:20 +0200)
committerGunnar Wrobel <p@rdus.de>
Wed, 29 Apr 2009 08:20:31 +0000 (10:20 +0200)
framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Inetorgperson.php
framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Person.php

index a467df0..9d865fc 100644 (file)
@@ -377,6 +377,19 @@ class Horde_Kolab_Server_Object_Inetorgperson extends Horde_Kolab_Server_Object_
      */
     public function generateId($info)
     {
+        if ($this->exists()) {
+            if (!isset($info[self::ATTRIBUTE_GIVENNAME])
+                && !isset($info[self::ATTRIBUTE_SN])) {
+                return false;
+            }
+            if (!isset($info[self::ATTRIBUTE_GIVENNAME])) {
+                $info[self::ATTRIBUTE_GIVENNAME] = $this->get(self::ATTRIBUTE_GIVENNAME);
+            }
+            if (!isset($info[self::ATTRIBUTE_SN])) {
+                $info[self::ATTRIBUTE_SN] = $this->get(self::ATTRIBUTE_SN);
+            }
+        }
+
         $id_mapfields = array(self::ATTRIBUTE_GIVENNAME,
                               self::ATTRIBUTE_SN);
         $id_format    = self::ATTRIBUTE_CN . '=' . '%s %s';
index 8c9e511..6ffad5a 100644 (file)
@@ -215,6 +215,19 @@ class Horde_Kolab_Server_Object_Person extends Horde_Kolab_Server_Object
      */
     public function generateId($info)
     {
+        if ($this->exists()) {
+            if (!isset($info[self::ATTRIBUTE_CN])
+                && !isset($info[self::ATTRIBUTE_SN])) {
+                return false;
+            }
+            if (!isset($info[self::ATTRIBUTE_CN])) {
+                $old = $this->get(self::ATTRIBUTE_CN);
+                if (!empty($old)) {
+                    return false;
+                }
+            }            
+        }
+
         if (!empty($info[self::ATTRIBUTE_CN])) {
             $id = $info[self::ATTRIBUTE_CN];
         } else {