'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;
}
}
}
+ $this->prepareObjectInformation($info);
+
if (!empty($this->attributes)) {
foreach ($info as $key => $value) {
if (!in_array($key, array_keys($this->attributes))) {
}
/**
+ * 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.
*/
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);
}
/**
}
/**
- * 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])
} else if (isset($info[self::ATTRIBUTE_USERPASSWORD])) {
unset($info[self::ATTRIBUTE_USERPASSWORD]);
}
-
- return parent::save($info);
}
/**