Add tag field to the edit and create calendar forms
authorMichael J. Rubinsky <mrubinsk@horde.org>
Thu, 29 Jan 2009 22:13:00 +0000 (17:13 -0500)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Thu, 29 Jan 2009 22:39:53 +0000 (17:39 -0500)
kronolith/lib/Forms/CreateCalendar.php
kronolith/lib/Forms/EditCalendar.php

index 61a098a..685da96 100755 (executable)
@@ -32,6 +32,7 @@ class Kronolith_CreateCalendarForm extends Horde_Form {
 
         $this->addVariable(_("Name"), 'name', 'text', true);
         $this->addVariable(_("Description"), 'description', 'longtext', false, false, null, array(4, 60));
+        $this->addVariable(_("Tags"), 'tags', 'text', false);
         $this->setButtons(array(_("Create")));
     }
 
@@ -44,6 +45,8 @@ class Kronolith_CreateCalendarForm extends Horde_Form {
         }
         $calendar->set('name', $this->_vars->get('name'));
         $calendar->set('desc', $this->_vars->get('description'));
+        $tagger = new Kronolith_Tagger();
+        $tagger->tag($calendar->getName(), $this->_vars->get('tags'), 'calendar');
         return $GLOBALS['kronolith_shares']->addShare($calendar);
     }
 
index ee76076..079db82 100644 (file)
@@ -39,6 +39,7 @@ class Kronolith_EditCalendarForm extends Horde_Form {
         $this->addHidden('', 'c', 'text', true);
         $this->addVariable(_("Name"), 'name', 'text', true);
         $this->addVariable(_("Description"), 'description', 'longtext', false, false, null, array(4, 60));
+        $this->addVariable(_("Tags"), 'tags', 'text', false);
         $this->setButtons(array(_("Save")));
     }
 
@@ -59,6 +60,9 @@ class Kronolith_EditCalendarForm extends Horde_Form {
         if (is_a($result, 'PEAR_Error')) {
             return PEAR::raiseError(sprintf(_("Unable to save calendar \"%s\": %s"), $new_name, $result->getMessage()));
         }
+
+        $tagger = new Kronolith_Tagger();
+        $tagger->replaceTags($this->_calendar->getName(), $this->_vars->get('tags'), 'calendar');
         return true;
     }