*
* @param string $uid The UID of the object to be deleted.
*
- * @return boolean True if saving succeeded.
+ * @return boolean True if deleting the object succeeded.
*
* @throws Horde_Kolab_Server_Exception
*/
abstract public function delete($uid);
/**
+ * Stub for renaming an object.
+ *
+ * @param string $uid The UID of the object to be renamed.
+ * @param string $new The new UID of the object.
+ *
+ * @return boolean True if renaming succeeded.
+ *
+ * @throws Horde_Kolab_Server_Exception
+ */
+ abstract public function rename($uid, $new);
+
+ /**
* List all objects of a specific type
*
* @param string $type The type of the objects to be listed
unset($data[$key]);
}
}
- $result = $this->_ldap->modify($uid, array('delete' => $deletes,
- 'replace' => $data));
+ /* Net_LDAP2 will work on this as a reference */
+ $mod_uid = $uid;
+ $result = $this->_ldap->modify($mod_uid, array('delete' => $deletes,
+ 'replace' => $data));
if ($result instanceOf PEAR_Error) {
throw new Horde_Kolab_Server_Exception($result,
Horde_Kolab_Server_Exception::SYSTEM);
}
/**
+ * Rename an object.
+ *
+ * @param string $uid The UID of the object to be renamed.
+ * @param string $new The new UID of the object.
+ *
+ * @return boolean True if renaming succeeded.
+ *
+ * @throws Horde_Kolab_Server_Exception
+ */
+ public function rename($uid, $new)
+ {
+ /* Net_LDAP modifies the variable */
+ $old = $uid;
+ $result = $this->_ldap->move($old, $new);
+ if ($result instanceOf PEAR_Error) {
+ throw new Horde_Kolab_Server_Exception($result,
+ Horde_Kolab_Server_Exception::SYSTEM);
+ }
+ Horde::logMessage(sprintf('The object \"%s\" has been successfully renamed to \"%s\"!',
+ $uid, $new),
+ __FILE__, __LINE__, PEAR_LOG_DEBUG);
+ return true;
+ }
+
+ /**
* List all objects of a specific type.
*
* @param string $type The type of the objects to be listed
}
/**
+ * Rename an object.
+ *
+ * @param string $uid The UID of the object to be renamed.
+ * @param string $new The new UID of the object.
+ *
+ * @return boolean True if renaming succeeded.
+ *
+ * @throws Horde_Kolab_Server_Exception
+ */
+ public function rename($uid, $new)
+ {
+ if (isset($this->data[$uid])) {
+ $this->data[$new] = $this->data[$uid];
+ unset($this->data[$uid]);
+ }
+ $this->store();
+ Horde::logMessage(sprintf('The object \"%s\" has been successfully renamed to \"%s\"!',
+ $uid, $new),
+ __FILE__, __LINE__, PEAR_LOG_DEBUG);
+ return true;
+ }
+
+ /**
* Return the schema for the given objectClass.
*
* @param string $objectclass Fetch the schema for this objectClass.