From: Michael J. Rubinsky Date: Thu, 24 Jun 2010 20:33:42 +0000 (-0400) Subject: Do not tag the resource's copy of the event. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=5e9d4507d1a72b2e7e9b6ae56c69f83044ed1920;p=horde.git Do not tag the resource's copy of the event. No need for this, plus this was throwing exceptions the way it was implemented since resources are not shares. Also add some logging. --- diff --git a/kronolith/lib/Driver/Resource.php b/kronolith/lib/Driver/Resource.php index 1c985ffbe..513fbf1a8 100644 --- a/kronolith/lib/Driver/Resource.php +++ b/kronolith/lib/Driver/Resource.php @@ -244,4 +244,25 @@ class Kronolith_Driver_Resource extends Kronolith_Driver_Sql return $return; } + + /** + * Helper function to update an existing event's tags to tagger storage. + * + * @param Kronolith_Event $event The event to update + */ + protected function _updateTags($event) + { + // noop + } + + /** + * Helper function to add tags from a newly creted event to the tagger. + * + * @param Kronolith_Event $event The event to save tags to storage for. + */ + protected function _addTags($event) + { + // noop + } + } diff --git a/kronolith/lib/Driver/Sql.php b/kronolith/lib/Driver/Sql.php index dc5c0dec2..58786a81c 100644 --- a/kronolith/lib/Driver/Sql.php +++ b/kronolith/lib/Driver/Sql.php @@ -591,17 +591,7 @@ class Kronolith_Driver_Sql extends Kronolith_Driver Horde::logMessage($e, 'ERR'); } } - - /* Update tags */ - Kronolith::getTagger()->replaceTags($event->uid, $event->tags, $event->creator, 'event'); - - /* Add tags again, but as the share owner (replaceTags removes ALL tags). */ - try { - $cal = $GLOBALS['kronolith_shares']->getShare($event->calendar); - } catch (Horde_Share_Exception $e) { - throw new Kronolith_Exception($e); - } - Kronolith::getTagger()->tag($event->uid, $event->tags, $cal->get('owner'), 'event'); + $this->_updateTags($event); /* Update Geolocation */ if ($gDriver = Kronolith::getGeoDriver()) { @@ -659,6 +649,45 @@ class Kronolith_Driver_Sql extends Kronolith_Driver Horde::logMessage($e, 'ERR'); } + $this->_addTags($event); + + /* Update Geolocation */ + if ($event->geoLocation && $gDriver = Kronolith::getGeoDriver()) { + $gDriver->setLocation($event->id, $event->geoLocation); + } + + /* Notify users about the new event. */ + Kronolith::sendNotification($event, 'add'); + + return $id; + } + + /** + * Helper function to update an existing event's tags to tagger storage. + * + * @param Kronolith_Event $event The event to update + */ + protected function _updateTags($event) + { + /* Update tags */ + Kronolith::getTagger()->replaceTags($event->uid, $event->tags, $event->creator, 'event'); + + /* Add tags again, but as the share owner (replaceTags removes ALL tags). */ + try { + $cal = $GLOBALS['kronolith_shares']->getShare($event->calendar); + } catch (Horde_Share_Exception $e) { + throw new Kronolith_Exception($e); + } + Kronolith::getTagger()->tag($event->uid, $event->tags, $cal->get('owner'), 'event'); + } + + /** + * Helper function to add tags from a newly creted event to the tagger. + * + * @param Kronolith_Event $event The event to save tags to storage for. + */ + protected function _addTags($event) + { /* Deal with any tags */ $tagger = Kronolith::getTagger(); $tagger->tag($event->uid, $event->tags, $event->creator, 'event'); @@ -672,16 +701,6 @@ class Kronolith_Driver_Sql extends Kronolith_Driver throw new Kronolith_Exception($e); } $tagger->tag($event->uid, $event->tags, $cal->get('owner'), 'event'); - - /* Update Geolocation */ - if ($event->geoLocation && $gDriver = Kronolith::getGeoDriver()) { - $gDriver->setLocation($event->id, $event->geoLocation); - } - - /* Notify users about the new event. */ - Kronolith::sendNotification($event, 'add'); - - return $id; } /** diff --git a/kronolith/lib/Event.php b/kronolith/lib/Event.php index cd9b3510c..419697935 100644 --- a/kronolith/lib/Event.php +++ b/kronolith/lib/Event.php @@ -438,6 +438,7 @@ abstract class Kronolith_Event /* Get the resource and protect against infinite recursion in case * someone is silly enough to add a resource to it's own event.*/ $resource = Kronolith::getDriver('Resource')->getResource($id); + Horde::logMessage('Kronolith_Event::save() checking resource ' . $id); $rcal = $resource->get('calendar'); if ($rcal == $this->calendar) { continue; @@ -462,6 +463,7 @@ abstract class Kronolith_Event /* Remember accepted resources so we can add the event to their * calendars. Otherwise, clear the lock. */ + Horde::logMessage('Kronolith_Event::save() response for resource ' . $id . ': ' . $response); if ($response == Kronolith::RESPONSE_ACCEPTED) { $add_events[] = $resource; } else { @@ -483,6 +485,7 @@ abstract class Kronolith_Event * calendar before it is saved, they will have different GUIDs, and * hence no longer refer to the same event. */ foreach ($add_events as $resource) { + Horde::logMessage('Kronolith_Event::save() Adding event ' . $this->uid . ' to resource ' . $resource->getId() . ' calendar. '); $resource->addEvent($this); if ($resource->get('response_type') == Kronolith_Resource::RESPONSETYPE_AUTO) { $locks->clearLock($lock[$resource->getId()]);