Store the value of display_cal parameter in the session.
authorMichael J. Rubinsky <mrubinsk@horde.org>
Wed, 2 Sep 2009 17:19:03 +0000 (13:19 -0400)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Wed, 2 Sep 2009 18:56:54 +0000 (14:56 -0400)
This makes display_cal do what it was originally inteneded to do.
Does not update user prefs (that's what toggle_calendar is for), but
just makes sure that ONLY the calendar(s) in the parameter are displayed.
Must pass an empty value for display_cal to clear the session value.

Still need to work out how to trigger the emptying of the value...probably
will replace the calendar panel with a 'close' link or similar when the session
variable contains data. This also solves the issue of dealing with the user changing
the calendars displayed via the panel while showing only display_cal.

kronolith/lib/Kronolith.php

index 0000398..39bb89d 100644 (file)
@@ -695,11 +695,20 @@ class Kronolith
 
         /* Update preferences for which calendars to display. If the
          * user doesn't have any selected calendars to view then fall
-         * back to an available calendar. */
+         * back to an available calendar. An empty string passed in this
+         * parameter will clear any existing session value.*/
         if (($calendarId = Horde_Util::getFormData('display_cal')) !== null) {
+            $_SESSION['kronolith']['display_cal'] = $calendarId;
+        }
+        if (!empty($_SESSION['kronolith']['display_cal'])) {
+            /* Specifying a value for display_cal is always to make sure
+             * that only the specified calendars are shown. Use the
+             * "toggle_calendar" argument  to toggle the state of a single
+             * calendar. */
             $GLOBALS['display_calendars'] = array();
             $GLOBALS['display_remote_calendars'] = array();
             $GLOBALS['display_external_calendars'] = array();
+            $calendarId = $_SESSION['kronolith']['display_cal'];
             if (is_array($calendarId)) {
                 $calendars = $calendarId;
                 foreach ($calendars as $calendarId) {