Remove geolocation data from storage when events are deleted.
authorMichael J. Rubinsky <mrubinsk@horde.org>
Fri, 18 Dec 2009 05:22:09 +0000 (00:22 -0500)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Fri, 18 Dec 2009 05:22:09 +0000 (00:22 -0500)
kronolith/lib/Driver/Sql.php
kronolith/lib/Geo.php

index c50988c..ed4f4d8 100644 (file)
@@ -788,6 +788,11 @@ class Kronolith_Driver_Sql extends Kronolith_Driver
         $tagger = Kronolith::getTagger();
         $tagger->replaceTags($event->uid, array(), 'event');
 
+        /* Remove any geolocation data */
+        if ($gDriver = Kronolith::getGeoDriver()) {
+            $gDriver->deleteLocation($event->id);
+        }
+
         /* Notify about the deleted event. */
         if (!$silent) {
             $result = Kronolith::sendNotification($event, 'delete');
index ad10d03..9e477f1 100644 (file)
@@ -42,6 +42,22 @@ abstract class Kronolith_Geo
         return $driver;
     }
 
+    /**
+     * Delete an entry from storage
+     *
+     * @param string $event_id
+     *
+     * @return void
+     */
+    public function deleteLocation($event_id)
+    {
+        $sql = "DELETE FROM kronolith_events_geo WHERE event_id = '" . $event_id . "'";
+        $result = $this->_write_db->query($sql);
+        if ($result instanceof PEAR_Error) {
+            throw new Horde_Exception($result->getMessage());
+        }
+    }
+
     abstract public function setLocation($event_id, $point);
     abstract public function getLocation($event_id);
     abstract public function removeLocation($event_id);