Exemplo n.º 1
0
 /**
  * Save an object.
  *
  * @param array  $object        The array that holds the data object.
  * @param string $old_object_id The id of the object if it existed before.
  *
  * @return boolean True on success.
  *
  * @throws Horde_Kolab_Storage_Exception In case the given old object id
  *                                       is invalid or an error occured
  *                                       while saving the data.
  */
 public function save($object, $old_object_id = null)
 {
     // update existing kolab object
     if ($old_object_id != null) {
         // check if object really exists
         if (!$this->objectUidExists($old_object_id)) {
             throw new Horde_Kolab_Storage_Exception(sprintf(Horde_Kolab_Storage_Translation::t("Old object %s does not exist."), $old_object_id));
         }
         // get the storage ID
         $id = $this->getStorageId($old_object_id);
         if ($id === false) {
             throw new Horde_Kolab_Storage_Exception(sprintf(Horde_Kolab_Storage_Translation::t("Old object %s does not map to a uid."), $old_object_id));
         }
         $old_object = $this->getObject($old_object_id);
     } else {
         $id = null;
         $old_object = null;
     }
     $this->_folder->saveObject($object, $this->_data_version, $this->_object_type, $id, $old_object);
     $this->synchronize($old_object_id);
     return true;
 }