From fbebe84713c699afc217b985ecca3d321f7e4a15 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Wed, 3 Nov 2010 01:32:31 -0600 Subject: [PATCH] Kronolith: Convert to new Horde_Session API --- kronolith/attendees.php | 29 +++++++++++++++-------------- kronolith/lib/Event.php | 4 ++-- kronolith/lib/Kronolith.php | 18 +++++++++--------- kronolith/lib/View/EditEvent.php | 4 ++-- kronolith/new.php | 4 ++-- kronolith/templates/attendees/attendees.inc | 6 +++--- kronolith/templates/panel.inc | 4 ++-- 7 files changed, 35 insertions(+), 34 deletions(-) diff --git a/kronolith/attendees.php b/kronolith/attendees.php index e69597c2e..a7be69a79 100644 --- a/kronolith/attendees.php +++ b/kronolith/attendees.php @@ -15,8 +15,8 @@ if (Kronolith::showAjaxView()) { } // Get the current attendees array from the session cache. -$attendees = $session['kronolith:attendees;array']; -$resources = $session['kronolith:resources;array']; +$attendees = $session->get('kronolith', 'attendees', Horde_Session::TYPE_ARRAY); +$resources = $session->get('kronolith', 'resources', Horde_Session::TYPE_ARRAY); $editAttendee = null; // Get the action ID and value. This specifies what action the user initiated. @@ -36,7 +36,7 @@ case 'add': $newAttendees = Kronolith::parseAttendees($newAttendees); if ($newAttendees) { - $session['kronolith:attendees'] = $attendees + $newAttendees; + $session->set('kronolith', 'attendees', $attendees + $newAttendees); } // Any new resources? @@ -55,7 +55,7 @@ case 'add': 'name' => $resource->get('name'), ); - $session['kronolith:resources'] = $resources; + $session->set('kronolith', 'resources', $resources); } if (Horde_Util::getFormData('addNewClose')) { @@ -78,7 +78,7 @@ case 'edit': : ' <' . $actionValue . '>')); } unset($attendees[$actionValue]); - $session['kronolith:attendees'] = $attendees; + $session->set('kronolith', 'attendees', $attendees); } break; @@ -87,7 +87,7 @@ case 'remove': $actionValue = Horde_String::lower($actionValue); if (isset($attendees[$actionValue])) { unset($attendees[$actionValue]); - $session['kronolith:attendees'] = $attendees; + $session->set('kronolith', 'attendees', $attendees); } break; @@ -95,16 +95,16 @@ case 'removeResource': // Remove the specified resource if (isset($resources[$actionValue])) { unset($resources[$actionValue]); - $session['kronolith:resources'] = $resources; + $session->set('kronolith', 'resources', $resources); } break; case 'changeResourceResp': - //@TODO: What else to do here? Dissallow if responsetype is auto? + //@TODO: What else to do here? Disallow if responsetype is auto? list($partval, $partname) = explode(' ', $actionValue, 2); if (isset($resources[$partname])) { $resources[$partname]['response'] = $partval; - $session['kronolith:resources'] = $resources; + $session->set('kronolith', 'resources', $resources); } break; @@ -114,7 +114,7 @@ case 'changeatt': $partname = Horde_String::lower($partname); if (isset($attendees[$partname])) { $attendees[$partname]['attendance'] = $partval; - $session['kronolith:attendees'] = $attendees; + $session->set('kronolith', 'attendees', $attendees); } break; @@ -124,7 +124,7 @@ case 'changeResourceAtt': $partname = Horde_String::lower($partname); if (isset($resources[$partname])) { $resources[$partname]['attendance'] = $partval; - $session['kronolith:resources'] = $resources; + $session->set('kronolith', 'resources', $resources); } break; @@ -134,7 +134,7 @@ case 'changeresp': $partname = Horde_String::lower($partname); if (isset($attendees[$partname])) { $attendees[$partname]['response'] = $partval; - $session['kronolith:attendees'] = $attendees; + $session->set('kronolith', 'attendees', $attendees); } break; @@ -159,7 +159,8 @@ case 'dismiss': case 'clear': // Remove all the attendees and resources. - unset($session['kronolith:attendees'], $session['kronolith:resources']); + $session->remove('kronolith', 'attendees'); + $session->remove('kronolith', 'resources'); break; } @@ -209,7 +210,7 @@ try { } // Add the Free/Busy information for each attendee. -foreach ($session['kronolith:attendees;array'] as $email => $status) { +foreach ($session->get('kronolith', 'attendees', Horde_Session::TYPE_ARRAY) as $email => $status) { if (strpos($email, '@') !== false && ($status['attendance'] == Kronolith::PART_REQUIRED || $status['attendance'] == Kronolith::PART_OPTIONAL)) { diff --git a/kronolith/lib/Event.php b/kronolith/lib/Event.php index f057f2e8d..271050315 100644 --- a/kronolith/lib/Event.php +++ b/kronolith/lib/Event.php @@ -2049,10 +2049,10 @@ abstract class Kronolith_Event // Attendees. $this->attendees = ($attendees = Horde_Util::getFormData('attendees')) ? $attendees - : $session['kronolith:attendees;array']; + : $session->get('kronolith', 'attendees', Horde_Session::TYPE_ARRAY); // Resources - $this->_resources = $session['kronolith:resources;array']; + $this->_resources = $session->get('kronolith', 'resources', Horde_Session::TYPE_ARRAY); // strptime() is locale dependent, i.e. %p is not always matching // AM/PM. Set the locale to C to workaround this, but grab the diff --git a/kronolith/lib/Kronolith.php b/kronolith/lib/Kronolith.php index c9c2a7f99..25c573242 100644 --- a/kronolith/lib/Kronolith.php +++ b/kronolith/lib/Kronolith.php @@ -960,10 +960,10 @@ class Kronolith * 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) { - $GLOBALS['session']['kronolith:display_cal'] = $calendarId; + $GLOBALS['session']->set('kronolith', 'display_cal', $calendarId); } - if (isset($GLOBALS['session']['kronolith:display_cal'])) { + if ($GLOBALS['session']->exists('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 @@ -973,7 +973,7 @@ class Kronolith $GLOBALS['display_external_calendars'] = array(); $GLOBALS['display_resource_calendars'] = array(); $GLOBALS['display_holidays'] = array(); - $calendars = $GLOBALS['session']['kronolith:display_cal']; + $calendars = $GLOBALS['session']->get('kronolith', 'display_cal'); if (!is_array($calendars)) { $calendars = array($calendars); } @@ -1098,13 +1098,13 @@ class Kronolith /* Get a list of external calendars. */ $GLOBALS['all_external_calendars'] = array(); - if (isset($GLOBALS['session']['kronolith:all_external_calendars'])) { - foreach ($GLOBALS['session']['kronolith:all_external_calendars'] as $calendar) { + if ($GLOBALS['session']->exists('kronolith', 'all_external_calendars')) { + foreach ($GLOBALS['session']->get('kronolith', 'all_external_calendars') as $calendar) { $GLOBALS['all_external_calendars'][$calendar['a'] . '/' . $calendar['n']] = new Kronolith_Calendar_External(array('api' => $calendar['a'], 'name' => $calendar['d'])); } } else { $apis = array_unique($GLOBALS['registry']->listAPIs()); - $ext_cals = $GLOBALS['session']['kronolith:all_external_calendars;array']; + $ext_cals = $GLOBALS['session']->get('kronolith', 'all_external_calendars', Horde_Session::TYPE_ARRAY); foreach ($apis as $api) { if (!$GLOBALS['registry']->hasMethod($api . '/listTimeObjects')) { @@ -1127,7 +1127,7 @@ class Kronolith } } - $GLOBALS['session']['kronolith:all_external_calendars'] = $ext_cals; + $GLOBALS['session']->set('kronolith', 'all_external_calendars', $ext_cals); } /* Make sure all the external calendars still exist. */ @@ -2207,12 +2207,12 @@ class Kronolith { /* Attendees */ $attendees = array(); - foreach ($GLOBALS['session']['kronolith:attendees;array'] as $email => $attendee) { + foreach ($GLOBALS['session']->get('kronolith', 'attendees', Horde_Session::TYPE_ARRAY) as $email => $attendee) { $attendees[] = empty($attendee['name']) ? $email : Horde_Mime_Address::trimAddress($attendee['name'] . (strpos($email, '@') === false ? '' : ' <' . $email . '>')); } /* Resources */ - foreach ($GLOBALS['session']['kronolith:resources;array'] as $resource) { + foreach ($GLOBALS['session']->get('kronolith', 'resources', Horde_Session::TYPE_ARRAY) as $resource) { $attendees[] = $resource['name']; } diff --git a/kronolith/lib/View/EditEvent.php b/kronolith/lib/View/EditEvent.php index 7613834cc..4c2b3353a 100644 --- a/kronolith/lib/View/EditEvent.php +++ b/kronolith/lib/View/EditEvent.php @@ -58,8 +58,8 @@ class Kronolith_View_EditEvent { } catch (Exception $e) { } } - $GLOBALS['session']['kronolith:attendees'] = $this->event->attendees; - $GLOBALS['session']['kronolith:resources'] = $this->event->getResources(); + $GLOBALS['session']->set('kronolith', 'attendees', $this->event->attendees); + $GLOBALS['session']->set('kronolith', 'resources', $this->event->getResources()); if ($datetime = Horde_Util::getFormData('datetime')) { $datetime = new Horde_Date($datetime); $month = $datetime->month; diff --git a/kronolith/new.php b/kronolith/new.php index 0ea766b14..d9deb1614 100644 --- a/kronolith/new.php +++ b/kronolith/new.php @@ -38,8 +38,8 @@ if ($calendar_id == 'internal_') { } $event = Kronolith::getDriver()->getEvent(); -$session['kronolith:attendees'] = $event->attendees; -$session['kronolith:resources'] = $event->getResources(); +$session->set('kronolith', 'attendees', $event->attendees); +$session->set('kronolith', 'resources', $event->getResources()); $date = Horde_Util::getFormData('datetime'); if (!$date) { diff --git a/kronolith/templates/attendees/attendees.inc b/kronolith/templates/attendees/attendees.inc index f3a7afce4..6053a8b6c 100644 --- a/kronolith/templates/attendees/attendees.inc +++ b/kronolith/templates/attendees/attendees.inc @@ -51,9 +51,9 @@ function switchDateView(view, date) - +get('kronolith', 'attendees')): ?> - $status): ?> +get('kronolith', 'attendees') as $email => $status): ?> link(array('title' => sprintf(_("Remove %s"), $name), 'onclick' => "performAction('remove', decodeURIComponent('" . rawurlencode($email) . "')); return false;")) . Horde::img('delete.png') . ' ' . Horde::url('#')->link(array('title' => sprintf(_("Edit %s"), $name), 'onclick' => "performAction('edit', decodeURIComponent('" . rawurlencode($email) . "')); return false;")) . Horde::img('edit.png') . '' ?> '))) ?> @@ -147,7 +147,7 @@ function switchDateView(view, date)
" /> " /> - " /> + get('kronolith', 'attendees')): ?>" />

diff --git a/kronolith/templates/panel.inc b/kronolith/templates/panel.inc index 7f6f22a0c..2eb848f13 100644 --- a/kronolith/templates/panel.inc +++ b/kronolith/templates/panel.inc @@ -43,11 +43,11 @@ $tagger = Kronolith::getTagger();
- +exists('kronolith', 'display_cal')): ?> getAuth() ? _("Return to my calendars") : _("Return to calendars") ?>
- +exists('kronolith', 'display_cal')): ?>

-- 2.11.0