Actually retrieve and set the calendar tags.
authorMichael J. Rubinsky <mrubinsk@horde.org>
Wed, 10 Mar 2010 04:54:03 +0000 (23:54 -0500)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Wed, 10 Mar 2010 04:54:03 +0000 (23:54 -0500)
Still an issue with the very first time the calendar chunk loads due
to the timing of the callbacks, but this gets calendar tags *mostly* working

kronolith/js/kronolith.js
kronolith/lib/Ajax/Application.php
kronolith/lib/Kronolith.php

index 5f5d06d..494ecbd 100644 (file)
@@ -2210,6 +2210,7 @@ KronolithCore = {
             if (calendar && type == 'remote') {
                 $('kronolithCalendarremoteUrl').setValue(calendar);
             }
+            $('kronolithCalendarinternalTags').autocompleter.init();
         } else {
             info = Kronolith.conf.calendars[type][calendar];
 
@@ -2222,6 +2223,7 @@ KronolithCore = {
                 $('kronolithCalendarinternalDescription').setValue(info.desc);
                 $('kronolithCalendarinternalLinkImportExport').up('span').show();
                 $('kronolithCalendarinternalExport').href = Kronolith.conf.URI_CALENDAR_EXPORT + '=' + calendar;
+                $('kronolithCalendarinternalTags').autocompleter.init(Kronolith.conf.calendars.internal[calendar].tg);
                 break;
             case 'tasklists':
                 $('kronolithCalendartasklistsDescription').setValue(info.desc);
@@ -2630,6 +2632,7 @@ KronolithCore = {
                                   if (r.response.perms) {
                                       cal.perms = r.response.perms;
                                   }
+                                  cal.tg = data.tags.split(',');
                                   this.getCalendarList(type, cal.owner).select('div').each(function(element) {
                                       if (element.retrieve('calendar') == data.calendar) {
                                           element
index 987030a..18bccaf 100644 (file)
@@ -460,6 +460,7 @@ class Kronolith_Ajax_Application extends Horde_Ajax_Application_Base
 
         switch ($this->_vars->type) {
         case 'internal':
+            $tagger = Kronolith::getTagger();
             $info = array();
             foreach (array('name', 'color', 'description', 'tags') as $key) {
                 $info[$key] = $this->_vars->$key;
@@ -480,6 +481,7 @@ class Kronolith_Ajax_Application extends Horde_Ajax_Application_Base
                 Kronolith::readPermsForm($calendar);
                 $GLOBALS['notification']->push(sprintf(_("The calendar \"%s\" has been created."), $info['name']), 'horde.success');
                 $result->calendar = $calendar->getName();
+                $tagger->tag($result->calendar, $this->_vars->tags, $calendar->get('owner'), 'calendar');
                 break;
             }
 
@@ -498,6 +500,8 @@ class Kronolith_Ajax_Application extends Horde_Ajax_Application_Base
                 return $result;
 
             }
+            $tagger->replaceTags($calendar->getName(), $this->_vars->tags, $calendar->get('owner'), 'calendar');
+
             Kronolith::readPermsForm($calendar);
             $result->perms = $calendar->getPermission()->data;
             if ($calendar->get('name') != $original_name) {
@@ -643,6 +647,7 @@ class Kronolith_Ajax_Application extends Horde_Ajax_Application_Base
             return $result;
         }
         $calendar = $GLOBALS['all_calendars'][$this->_vars->cal];
+        $tagger = Kronolith::getTagger();
         $result->calendar = array(
             'name' => (!$calendar->get('owner') ? '' : '[' . Horde_Auth::convertUsername($calendar->get('owner'), false) . '] ') . $calendar->get('name'),
             'desc' => $calendar->get('desc'),
@@ -651,7 +656,8 @@ class Kronolith_Ajax_Application extends Horde_Ajax_Application_Base
             'bg' => Kronolith::backgroundColor($calendar),
             'show' => false,
             'perms' => $calendar->getPermission()->data,
-            'edit' => $calendar->hasPermission(Horde_Auth::getAuth(), Horde_Perms::EDIT));
+            'edit' => $calendar->hasPermission(Horde_Auth::getAuth(), Horde_Perms::EDIT),
+            'tg' => array_values($tagger->getTags($calendar->getName(), 'calendar')));
         return $result;
     }
 
index 21a99a3..5b3b354 100644 (file)
@@ -182,6 +182,8 @@ class Kronolith
             }
         }
 
+        $tagger = self::getTagger();
+
         /* Variables used in core javascript files. */
         $code['conf'] = array(
             'URI_AJAX' => (string)Horde::getServiceLink('ajax', 'kronolith'),
@@ -257,7 +259,8 @@ class Kronolith
                         'bg' => self::backgroundColor($calendar),
                         'show' => in_array($id, $GLOBALS['display_calendars']),
                         'perms' => $calendar->getPermission()->data,
-                        'edit' => $calendar->hasPermission(Horde_Auth::getAuth(), Horde_Perms::EDIT));
+                        'edit' => $calendar->hasPermission(Horde_Auth::getAuth(), Horde_Perms::EDIT),
+                        'tg' => array_values($tagger->getTags($calendar->getName(), 'calendar')));
                 }
             }