Allow setting the id of a basic object. Fixed a typo.
authorGunnar Wrobel <p@rdus.de>
Mon, 6 Apr 2009 06:11:20 +0000 (08:11 +0200)
committerGunnar Wrobel <p@rdus.de>
Mon, 6 Apr 2009 10:25:59 +0000 (12:25 +0200)
framework/Kolab_Server/lib/Horde/Kolab/Server/Object.php

index 52206e8..e9af973 100644 (file)
@@ -401,6 +401,9 @@ class Horde_Kolab_Server_Object
      */
     public static function generateId($info)
     {
+        if (!empty($info[self::ATTRIBUTE_ID])) {
+            return $info[self::ATTRIBUTE_ID];
+        }
         return hash('sha256', uniqid(mt_rand(), true));
     }
 
@@ -428,7 +431,7 @@ class Horde_Kolab_Server_Object
         }
 
         if (!$this->exists()) {
-            foreach ($this->attribute_map['required'] as $attribute) {
+            foreach ($this->attribute_map['required'] as $key) {
                 if (!in_array($key, array_keys($info)) || empty($info[$key])) {
                     if (empty($this->attributes[$key]['default'])) {
                         throw new Horde_Kolab_Server_Exception(sprintf(_("The value for \"%s\" is empty but required!"),