From: Gunnar Wrobel Date: Tue, 12 May 2009 15:01:03 +0000 (+0200) Subject: Reorder the handling of the object information when adding objects. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=688f79edeacafd48ab9b4a378f67b7c99f18a2c8;p=horde.git Reorder the handling of the object information when adding objects. --- diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server.php b/framework/Kolab_Server/lib/Horde/Kolab/Server.php index b3a996b45..68e264033 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server.php @@ -278,14 +278,15 @@ abstract class Horde_Kolab_Server 'The type of a new object must be specified!'); } - $object = &Horde_Kolab_Server_Object::factory($info['type'], null, $this, $info); + $type = $info['type']; + unset($info['type']); + $object = &Horde_Kolab_Server_Object::factory($type, null, $this, $info); if ($object->exists()) { throw new Horde_Kolab_Server_Exception( sprintf(_("The object with the uid \"%s\" does already exist!"), $object->get(Horde_Kolab_Server_Object::ATTRIBUTE_UID))); } - unset($info['type']); - $object->save($info); + $object->save(); return $object; } diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Object.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Object.php index c62793668..26b7d478b 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Object.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Object.php @@ -720,6 +720,8 @@ class Horde_Kolab_Server_Object } } + $this->prepareObjectInformation($info); + if (!empty($this->attributes)) { foreach ($info as $key => $value) { if (!in_array($key, array_keys($this->attributes))) { @@ -818,6 +820,19 @@ class Horde_Kolab_Server_Object } /** + * Distill the server side object information to save. + * + * @param array $info The information about the object. + * + * @return NULL. + * + * @throws Horde_Kolab_Server_Exception If the given information contains errors. + */ + public function prepareObjectInformation(&$info) + { + } + + /** * Prepare the server changes before saving. * * @param array $info The information to store. diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Person.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Person.php index 6ffad5a28..4131056cf 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Person.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Person.php @@ -156,7 +156,7 @@ class Horde_Kolab_Server_Object_Person extends Horde_Kolab_Server_Object */ protected function sha256($string, $salt) { - return '{SHA256}' . base64_encode(pack('H*', hash('sha256', $string . $salt)) . $salt); + return '{SSHA256}' . base64_encode(pack('H*', hash('sha256', $string . $salt)) . $salt); } /** @@ -240,18 +240,15 @@ class Horde_Kolab_Server_Object_Person extends Horde_Kolab_Server_Object } /** - * Saves object information. This may either create a new entry or modify an - * existing entry. - * - * Please note that fields with multiple allowed values require the callee - * to provide the full set of values for the field. Any old values that are - * not resubmitted will be considered to be deleted. + * Distill the server side object information to save. * * @param array $info The information about the object. * - * @return boolean|PEAR_Error True on success. + * @return array The set of information. + * + * @throws Horde_Kolab_Server_Exception If the given information contains errors. */ - public function save($info = null) + public function prepareObjectInformation(&$info) { if (!$this->exists() && empty($info[self::ATTRIBUTE_CN]) @@ -264,8 +261,6 @@ class Horde_Kolab_Server_Object_Person extends Horde_Kolab_Server_Object } else if (isset($info[self::ATTRIBUTE_USERPASSWORD])) { unset($info[self::ATTRIBUTE_USERPASSWORD]); } - - return parent::save($info); } /**