Add Horde_History::removeByParent()
authorMichael M Slusarz <slusarz@curecanti.org>
Sat, 30 Jan 2010 18:53:52 +0000 (11:53 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Sun, 31 Jan 2010 04:15:12 +0000 (21:15 -0700)
framework/History/lib/Horde/History.php
kronolith/lib/Application.php
nag/lib/Application.php

index d94ca8a..ebf9020 100644 (file)
@@ -313,6 +313,23 @@ class Horde_History
     }
 
     /**
+     * Remove one or more history entries by parent.
+     *
+     * @param string $parent  The parent name to remove.
+     *
+     * @throws Horde_Exception
+     */
+    public function removeByParent($parent)
+    {
+        /* Remove entries 100 at a time. */
+        $all = array_keys($this->getByTimestamp('>', 0, array(), $parent));
+
+        while (count($d = array_splice($all, 0, 100)) > 0) {
+            $this->removebyNames($d);
+        }
+    }
+
+    /**
      * Remove one or more history entries by name.
      *
      * @param array $names The history entries to remove.
index ff376c0..2e3a96a 100644 (file)
@@ -327,20 +327,7 @@ class Kronolith_Application extends Horde_Registry_Application
 
         /* Now delete history as well. */
         $history = Horde_History::singleton();
-        if (method_exists($history, 'removeByParent')) {
-            $histories = $history->removeByParent('kronolith:' . $user);
-        } else {
-            /* Remove entries 100 at a time. */
-            $all = $history->getByTimestamp('>', 0, array(), 'kronolith:' . $user);
-            if (is_a($all, 'PEAR_Error')) {
-                Horde::logMessage($all, __FILE__, __LINE__, PEAR_LOG_ERR);
-            } else {
-                $all = array_keys($all);
-                while (count($d = array_splice($all, 0, 100)) > 0) {
-                    $history->removebyNames($d);
-                }
-            }
-        }
+        $histories = $history->removeByParent('kronolith:' . $user);
 
         if (is_a($result, 'PEAR_Error')) {
             return $result;
index a5b4d74..acdc5f8 100644 (file)
@@ -193,20 +193,7 @@ class Nag_Application extends Horde_Registry_Application
 
         /* Now delete history as well. */
         $history = Horde_History::singleton();
-        if (method_exists($history, 'removeByParent')) {
-            $histories = $history->removeByParent('nag:' . $user);
-        } else {
-            /* Remove entries 100 at a time. */
-            $all = $history->getByTimestamp('>', 0, array(), 'nag:' . $user);
-            if (is_a($all, 'PEAR_Error')) {
-                Horde::logMessage($all, __FILE__, __LINE__, PEAR_LOG_ERR);
-            } else {
-                $all = array_keys($all);
-                while (count($d = array_splice($all, 0, 100)) > 0) {
-                    $history->removebyNames($d);
-                }
-            }
-        }
+        $histories = $history->removeByParent('nag:' . $user);
 
         /* ...and finally, delete the actual share */
         if (!empty($share)) {