Support deletion of objects.
authorGunnar Wrobel <p@rdus.de>
Thu, 9 Apr 2009 09:20:30 +0000 (11:20 +0200)
committerGunnar Wrobel <p@rdus.de>
Thu, 9 Apr 2009 09:35:38 +0000 (11:35 +0200)
framework/Kolab_Server/lib/Horde/Kolab/Server.php
framework/Kolab_Server/lib/Horde/Kolab/Server/Test.php

index aedbd64..9ff6fef 100644 (file)
@@ -179,7 +179,7 @@ abstract class Horde_Kolab_Server
         $sparam         = $server_params;
         $sparam['pass'] = isset($sparam['pass']) ? md5($sparam['pass']) : '';
         ksort($sparam);
-        $signature      = serialize(array($driver, $sparam));
+        $signature = serialize(array($driver, $sparam));
         if (empty($instances[$signature])) {
             $instances[$signature] = &Horde_Kolab_Server::factory($driver,
                                                                   $server_params);
@@ -633,6 +633,17 @@ abstract class Horde_Kolab_Server
     abstract public function save($uid, $data, $exists = false);
 
     /**
+     * Delete an object.
+     *
+     * @param string $uid The UID of the object to be deleted.
+     *
+     * @return boolean True if saving succeeded.
+     *
+     * @throws Horde_Kolab_Server_Exception
+     */
+    abstract public function delete($uid);
+
+    /**
      * List all objects of a specific type
      *
      * @param string $type   The type of the objects to be listed
index b525b88..86c9b19 100644 (file)
@@ -540,10 +540,34 @@ class Horde_Kolab_Server_Test extends Horde_Kolab_Server_Ldap
                                       array('dn' => $uid)),
             );
         }
+        Horde::logMessage(sprintf('The object \"%s\" has been successfully saved!',
+                                  $uid),
+                          __FILE__, __LINE__, PEAR_LOG_DEBUG);
         $this->store();
     }
 
     /**
+     * Delete an object.
+     *
+     * @param string $uid The UID of the object to be deleted.
+     *
+     * @return boolean True if saving succeeded.
+     *
+     * @throws Horde_Kolab_Server_Exception
+     */
+    public function delete($uid)
+    {
+        if (isset($this->data[$uid])) {
+            unset($this->data[$uid]);
+        }
+        $this->store();
+        Horde::logMessage(sprintf('The object \"%s\" has been successfully deleted!',
+                                  $uid),
+                          __FILE__, __LINE__, PEAR_LOG_DEBUG);
+        return true;
+    }
+
+    /**
      * Return the schema for the given objectClass.
      *
      * @param string $objectclass Fetch the schema for this objectClass.