From: Michael J. Rubinsky Date: Mon, 9 Feb 2009 00:41:12 +0000 (-0500) Subject: consistent variable naming, use a static Kronolith:: method to X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=093a12dfd5fbeb6a4eee86f4c2a1236848f507ab;p=horde.git consistent variable naming, use a static Kronolith:: method to obtain a tagger object. --- diff --git a/kronolith/add.php b/kronolith/add.php index e1ff14e5c..35d3c2fa4 100644 --- a/kronolith/add.php +++ b/kronolith/add.php @@ -50,7 +50,7 @@ if (!Util::getFormData('cancel')) { } } } - $tagger = new Kronolith_Tagger(); + $tagger = Kronolith::getTagger(); $tagger->tag($event->getUID(), Util::getFormData('tags'), 'event'); } } diff --git a/kronolith/calendars/edit.php b/kronolith/calendars/edit.php index ab8e31ec3..02d8275cb 100644 --- a/kronolith/calendars/edit.php +++ b/kronolith/calendars/edit.php @@ -54,8 +54,8 @@ if ($form->validate($vars)) { $vars->set('name', $calendar->get('name')); $vars->set('color', $calendar->get('color')); $vars->set('description', $calendar->get('desc')); -$tags = new Kronolith_Tagger(); -$vars->set('tags', implode(',', array_values($tags->getTags($calendar->getName(), 'calendar')))); +$tagger = Kronolith::getTagger(); +$vars->set('tags', implode(',', array_values($tagger->getTags($calendar->getName(), 'calendar')))); $title = $form->getTitle(); require KRONOLITH_TEMPLATES . '/common-header.inc'; require KRONOLITH_TEMPLATES . '/menu.inc'; diff --git a/kronolith/edit.php b/kronolith/edit.php index 4132ad21b..441ef4f63 100644 --- a/kronolith/edit.php +++ b/kronolith/edit.php @@ -12,7 +12,7 @@ function _save(&$event) { $res = $event->save(); - $tagger = new Kronolith_Tagger(); + $tagger = Kronolith::getTagger(); $tagger->replaceTags($event->getUID(), Util::getFormData('tags')); if (is_a($res, 'PEAR_Error')) { $GLOBALS['notification']->push(sprintf(_("There was an error editing the event: %s"), $res->getMessage()), 'horde.error'); diff --git a/kronolith/lib/Driver/sql.php b/kronolith/lib/Driver/sql.php index b70061836..51c42f637 100644 --- a/kronolith/lib/Driver/sql.php +++ b/kronolith/lib/Driver/sql.php @@ -678,6 +678,10 @@ class Kronolith_Driver_sql extends Kronolith_Driver { $alarm->delete($event->getUID()); } + /* Remove any tags */ + $tagger = Kronolith::getTagger(); + $tagger->replaceTags($event->getUID(), array(), 'event'); + /* Notify about the deleted event. */ if (!$silent) { $result = Kronolith::sendNotification($event, 'delete'); diff --git a/kronolith/lib/Forms/CreateCalendar.php b/kronolith/lib/Forms/CreateCalendar.php index 7ebe8c9df..b529fcead 100755 --- a/kronolith/lib/Forms/CreateCalendar.php +++ b/kronolith/lib/Forms/CreateCalendar.php @@ -47,7 +47,8 @@ class Kronolith_CreateCalendarForm extends Horde_Form { $calendar->set('name', $this->_vars->get('name')); $calendar->set('color', $this->_vars->get('color')); $calendar->set('desc', $this->_vars->get('description')); - $tagger = new Kronolith_Tagger(); + $tagger = Kronolith::getTagger(); + $tagger->tag($calendar->getName(), $this->_vars->get('tags'), 'calendar'); return $GLOBALS['kronolith_shares']->addShare($calendar); } diff --git a/kronolith/lib/Forms/EditCalendar.php b/kronolith/lib/Forms/EditCalendar.php index 6dbdc0b8d..8b5951767 100644 --- a/kronolith/lib/Forms/EditCalendar.php +++ b/kronolith/lib/Forms/EditCalendar.php @@ -63,7 +63,7 @@ class Kronolith_EditCalendarForm extends Horde_Form { return PEAR::raiseError(sprintf(_("Unable to save calendar \"%s\": %s"), $new_name, $result->getMessage())); } - $tagger = new Kronolith_Tagger(); + $tagger = Kronolith::getTagger(); $tagger->replaceTags($this->_calendar->getName(), $this->_vars->get('tags'), 'calendar'); return true; } diff --git a/kronolith/lib/Imple/TagActions.php b/kronolith/lib/Imple/TagActions.php index c0df540b6..c6732d1c3 100644 --- a/kronolith/lib/Imple/TagActions.php +++ b/kronolith/lib/Imple/TagActions.php @@ -61,7 +61,7 @@ class Kronolith_Imple_TagActions extends Kronolith_Imple if ($perm) { /* Get the resource owner */ - $tagger = new Kronolith_Tagger(); + $tagger = Kronolith::getTagger(); switch ($request) { case 'add': $tagger->tag($args['resource'], $tags, $args['type']); diff --git a/kronolith/lib/Kronolith.php b/kronolith/lib/Kronolith.php index dbd381be2..7f9af7173 100644 --- a/kronolith/lib/Kronolith.php +++ b/kronolith/lib/Kronolith.php @@ -2447,4 +2447,16 @@ class Kronolith { } } + function getTagger() + { + static $_tagger; + + if (empty($_tagger)) { + $_tagger = new Kronolith_Tagger(); + } + + return $_tagger; + } + + } diff --git a/kronolith/lib/Views/EditEvent.php b/kronolith/lib/Views/EditEvent.php index 3a6fb8d05..6ff2cd395 100644 --- a/kronolith/lib/Views/EditEvent.php +++ b/kronolith/lib/Views/EditEvent.php @@ -100,7 +100,7 @@ class Kronolith_View_EditEvent { $event = &$this->event; // Tags - $tagger = new Kronolith_Tagger(); + $tagger = Kronolith::getTagger(); $tags = $tagger->getTags($event->getUID(), 'event'); $tags = implode(',', array_values($tags)); diff --git a/kronolith/lib/Views/Event.php b/kronolith/lib/Views/Event.php index 40938878c..02a01555c 100644 --- a/kronolith/lib/Views/Event.php +++ b/kronolith/lib/Views/Event.php @@ -96,7 +96,7 @@ class Kronolith_View_Event { $timeFormat = $prefs->getValue('twentyFour') ? 'G:i' : 'g:ia'; // Tags - $tagger = new Kronolith_Tagger(); + $tagger = Kronolith::getTagger(); $tags = $tagger->getTags($this->event->getUID(), 'event'); $tags = implode(', ', array_values($tags)); diff --git a/kronolith/templates/panel.inc b/kronolith/templates/panel.inc index a19b851d0..55032bb55 100644 --- a/kronolith/templates/panel.inc +++ b/kronolith/templates/panel.inc @@ -25,7 +25,7 @@ foreach (Kronolith::listCalendars() as $id => $cal) { } } -$tagger = new Kronolith_Tagger(); +$tagger = Kronolith::getTagger(); ?>