From 9d423efda515f75fc205f66032a4373d70407020 Mon Sep 17 00:00:00 2001 From: Jan Schneider Date: Wed, 11 Aug 2010 16:28:06 +0200 Subject: [PATCH] Remove unnecessary toDriver() method. --- kronolith/lib/Driver/Kolab.php | 2 +- kronolith/lib/Driver/Sql.php | 4 +-- kronolith/lib/Event.php | 8 ----- kronolith/lib/Event/Ical.php | 8 ----- kronolith/lib/Event/Kolab.php | 2 +- kronolith/lib/Event/Sql.php | 68 +++++++++++++++++++----------------------- 6 files changed, 34 insertions(+), 58 deletions(-) diff --git a/kronolith/lib/Driver/Kolab.php b/kronolith/lib/Driver/Kolab.php index 7441fda52..e177d8945 100644 --- a/kronolith/lib/Driver/Kolab.php +++ b/kronolith/lib/Driver/Kolab.php @@ -369,7 +369,7 @@ class Kronolith_Driver_Kolab extends Kronolith_Driver ? array('action' => 'modify') : array('action' => 'add'); - $this->_store->save($event->toDriver(), $edit ? $event->uid : null); + $this->_store->save($event->toKolab(), $edit ? $event->uid : null); /* Deal with tags */ if ($edit) { diff --git a/kronolith/lib/Driver/Sql.php b/kronolith/lib/Driver/Sql.php index 031cb45b7..0a81b0ad2 100644 --- a/kronolith/lib/Driver/Sql.php +++ b/kronolith/lib/Driver/Sql.php @@ -548,7 +548,7 @@ class Kronolith_Driver_Sql extends Kronolith_Driver { $values = array(); $query = 'UPDATE ' . $this->_params['table'] . ' SET '; - foreach ($event->getProperties() as $key => $val) { + foreach ($event->toProperties() as $key => $val) { $query .= " $key = ?,"; $values[] = $val; } @@ -610,7 +610,7 @@ class Kronolith_Driver_Sql extends Kronolith_Driver $cols_name = ' (event_id, event_uid,'; $cols_values = ' VALUES (?, ?,'; $values = array($event->id, $event->uid); - foreach ($event->getProperties() as $key => $val) { + foreach ($event->toProperties() as $key => $val) { $cols_name .= " $key,"; $cols_values .= ' ?,'; $values[] = $val; diff --git a/kronolith/lib/Event.php b/kronolith/lib/Event.php index cd446e70d..a2c2e39d1 100644 --- a/kronolith/lib/Event.php +++ b/kronolith/lib/Event.php @@ -474,7 +474,6 @@ abstract class Kronolith_Event } /* Save */ - $this->toDriver(); $result = $this->getDriver()->saveEvent($this); /* Now that the event is definitely commited to storage, we can add @@ -512,13 +511,6 @@ abstract class Kronolith_Event } /** - * Prepares this event to be saved to the backend. - */ - public function toDriver() - { - } - - /** * Exports this event in iCalendar format. * * @param Horde_Icalendar $calendar A Horde_iCalendar object that acts as diff --git a/kronolith/lib/Event/Ical.php b/kronolith/lib/Event/Ical.php index c0425e7a7..4d92d443e 100644 --- a/kronolith/lib/Event/Ical.php +++ b/kronolith/lib/Event/Ical.php @@ -40,14 +40,6 @@ class Kronolith_Event_Ical extends Kronolith_Event } /** - * Prepares this event to be saved to the backend. - */ - public function toDriver() - { - return $this->toiCalendar(); - } - - /** * Encapsulates permissions checking. * * $user is being ignored. diff --git a/kronolith/lib/Event/Kolab.php b/kronolith/lib/Event/Kolab.php index 44e2182e5..178538136 100644 --- a/kronolith/lib/Event/Kolab.php +++ b/kronolith/lib/Event/Kolab.php @@ -167,7 +167,7 @@ class Kronolith_Event_Kolab extends Kronolith_Event /** * Prepares this event to be saved to the backend. */ - public function toDriver() + public function toKolab() { $event = array(); $event['uid'] = $this->uid; diff --git a/kronolith/lib/Event/Sql.php b/kronolith/lib/Event/Sql.php index 0b6dca711..65ab925d6 100644 --- a/kronolith/lib/Event/Sql.php +++ b/kronolith/lib/Event/Sql.php @@ -20,11 +20,6 @@ class Kronolith_Event_Sql extends Kronolith_Event public $calendarType = 'internal'; /** - * @var array - */ - private $_properties = array(); - - /** * Const'r * * @param Kronolith_Driver $driver The backend driver that this event is @@ -153,26 +148,27 @@ class Kronolith_Event_Sql extends Kronolith_Event /** * Prepares this event to be saved to the backend. */ - public function toDriver() + public function toProperties() { $driver = $this->getDriver(); + $properties = array(); /* Basic fields. */ - $this->_properties['event_creator_id'] = $driver->convertToDriver($this->creator); - $this->_properties['event_title'] = $driver->convertToDriver($this->title); - $this->_properties['event_description'] = $driver->convertToDriver($this->description); - $this->_properties['event_location'] = $driver->convertToDriver($this->location); - $this->_properties['event_url'] = (string)$this->url; - $this->_properties['event_private'] = (int)$this->private; - $this->_properties['event_status'] = $this->status; - $this->_properties['event_attendees'] = serialize($driver->convertToDriver($this->attendees)); - $this->_properties['event_resources'] = serialize($driver->convertToDriver($this->getResources())); - $this->_properties['event_modified'] = $_SERVER['REQUEST_TIME']; + $properties['event_creator_id'] = $driver->convertToDriver($this->creator); + $properties['event_title'] = $driver->convertToDriver($this->title); + $properties['event_description'] = $driver->convertToDriver($this->description); + $properties['event_location'] = $driver->convertToDriver($this->location); + $properties['event_url'] = (string)$this->url; + $properties['event_private'] = (int)$this->private; + $properties['event_status'] = $this->status; + $properties['event_attendees'] = serialize($driver->convertToDriver($this->attendees)); + $properties['event_resources'] = serialize($driver->convertToDriver($this->getResources())); + $properties['event_modified'] = $_SERVER['REQUEST_TIME']; if ($this->isAllDay()) { - $this->_properties['event_start'] = $this->start->strftime('%Y-%m-%d %H:%M:%S'); - $this->_properties['event_end'] = $this->end->strftime('%Y-%m-%d %H:%M:%S'); - $this->_properties['event_allday'] = 1; + $properties['event_start'] = $this->start->strftime('%Y-%m-%d %H:%M:%S'); + $properties['event_end'] = $this->end->strftime('%Y-%m-%d %H:%M:%S'); + $properties['event_allday'] = 1; } else { if ($driver->getParam('utc')) { $start = clone $this->start; @@ -183,20 +179,20 @@ class Kronolith_Event_Sql extends Kronolith_Event $start = $this->start; $end = $this->end; } - $this->_properties['event_start'] = $start->strftime('%Y-%m-%d %H:%M:%S'); - $this->_properties['event_end'] = $end->strftime('%Y-%m-%d %H:%M:%S'); - $this->_properties['event_allday'] = 0; + $properties['event_start'] = $start->strftime('%Y-%m-%d %H:%M:%S'); + $properties['event_end'] = $end->strftime('%Y-%m-%d %H:%M:%S'); + $properties['event_allday'] = 0; } /* Alarm. */ - $this->_properties['event_alarm'] = (int)$this->alarm; + $properties['event_alarm'] = (int)$this->alarm; /* Alarm Notification Methods. */ - $this->_properties['event_alarm_methods'] = serialize($driver->convertToDriver($this->methods)); + $properties['event_alarm_methods'] = serialize($driver->convertToDriver($this->methods)); /* Recurrence. */ if (!$this->recurs()) { - $this->_properties['event_recurtype'] = 0; + $properties['event_recurtype'] = 0; } else { $recur = $this->recurrence->getRecurType(); if ($this->recurrence->hasRecurEnd()) { @@ -210,30 +206,26 @@ class Kronolith_Event_Sql extends Kronolith_Event $recur_end = new Horde_Date(array('year' => 9999, 'month' => 12, 'mday' => 31, 'hour' => 23, 'min' => 59, 'sec' => 59)); } - $this->_properties['event_recurtype'] = $recur; - $this->_properties['event_recurinterval'] = $this->recurrence->getRecurInterval(); - $this->_properties['event_recurenddate'] = $recur_end->format('Y-m-d H:i:s'); - $this->_properties['event_recurcount'] = $this->recurrence->getRecurCount(); + $properties['event_recurtype'] = $recur; + $properties['event_recurinterval'] = $this->recurrence->getRecurInterval(); + $properties['event_recurenddate'] = $recur_end->format('Y-m-d H:i:s'); + $properties['event_recurcount'] = $this->recurrence->getRecurCount(); switch ($recur) { case Horde_Date_Recurrence::RECUR_WEEKLY: - $this->_properties['event_recurdays'] = $this->recurrence->getRecurOnDays(); + $properties['event_recurdays'] = $this->recurrence->getRecurOnDays(); break; } - $this->_properties['event_exceptions'] = implode(',', $this->recurrence->getExceptions()); + $properties['event_exceptions'] = implode(',', $this->recurrence->getExceptions()); } /* Exception information */ if (!empty($this->baseid)) { - $this->_properties['event_baseid'] = $this->baseid; - $this->_properties['event_exceptionoriginaldate'] = $this->exceptionoriginaldate; + $properties['event_baseid'] = $this->baseid; + $properties['event_exceptionoriginaldate'] = $this->exceptionoriginaldate; } - } - - public function getProperties() - { - return $this->_properties; + return $properties; } } -- 2.11.0