Implement getter method for a single event

This commit is contained in:
Thomas Bruederli 2011-07-27 16:06:06 +02:00
parent 021f8b51e8
commit 7e4287e1c5
4 changed files with 50 additions and 20 deletions

View file

@ -180,6 +180,16 @@ abstract class calendar_driver
return false; return false;
} }
/**
* Return data of a single event
*
* @param array Hash array with event properties:
* id: Event identifier
* calendar: Calendar identifier
* @return array Event object as hash array
*/
abstract function get_event($event);
/** /**
* Get events from source. * Get events from source.
* *

View file

@ -173,7 +173,7 @@ class database_driver extends calendar_driver
* Add a single event to the database * Add a single event to the database
* *
* @param array Hash array with event properties * @param array Hash array with event properties
* @see Driver:new_event() * @see calendar_driver::new_event()
*/ */
public function new_event($event) public function new_event($event)
{ {
@ -233,7 +233,7 @@ class database_driver extends calendar_driver
* Update an event entry with the given data * Update an event entry with the given data
* *
* @param array Hash array with event properties * @param array Hash array with event properties
* @see Driver:edit_event() * @see calendar_driver::edit_event()
*/ */
public function edit_event($event) public function edit_event($event)
{ {
@ -502,7 +502,7 @@ class database_driver extends calendar_driver
* Move a single event * Move a single event
* *
* @param array Hash array with event properties * @param array Hash array with event properties
* @see Driver:move_event() * @see calendar_driver::move_event()
*/ */
public function move_event($event) public function move_event($event)
{ {
@ -514,7 +514,7 @@ class database_driver extends calendar_driver
* Resize a single event * Resize a single event
* *
* @param array Hash array with event properties * @param array Hash array with event properties
* @see Driver:resize_event() * @see calendar_driver::resize_event()
*/ */
public function resize_event($event) public function resize_event($event)
{ {
@ -528,7 +528,7 @@ class database_driver extends calendar_driver
* @param array Hash array with event properties * @param array Hash array with event properties
* @param boolean Remove record irreversible (@TODO) * @param boolean Remove record irreversible (@TODO)
* *
* @see Driver:remove_event() * @see calendar_driver::remove_event()
*/ */
public function remove_event($event, $force = true) public function remove_event($event, $force = true)
{ {
@ -601,13 +601,15 @@ class database_driver extends calendar_driver
/** /**
* Return data of a specific event * Return data of a specific event
* @param string Event ID * @param mixed Hash array with event properties or event ID
* @return array Hash array with event properties * @return array Hash array with event properties
*/ */
public function get_event($id) public function get_event($event)
{ {
static $cache = array(); static $cache = array();
$id = is_array($event) ? $event['id'] : $event;
if ($cache[$id]) if ($cache[$id])
return $cache[$id]; return $cache[$id];
@ -630,7 +632,7 @@ class database_driver extends calendar_driver
/** /**
* Get event data * Get event data
* *
* @see Driver:load_events() * @see calendar_driver::load_events()
*/ */
public function load_events($start, $end, $query = null, $calendars = null) public function load_events($start, $end, $query = null, $calendars = null)
{ {
@ -726,7 +728,7 @@ class database_driver extends calendar_driver
/** /**
* Get a list of pending alarms to be displayed to the user * Get a list of pending alarms to be displayed to the user
* *
* @see Driver:pending_alarms() * @see calendar_driver::pending_alarms()
*/ */
public function pending_alarms($time, $calendars = null) public function pending_alarms($time, $calendars = null)
{ {
@ -759,7 +761,7 @@ class database_driver extends calendar_driver
/** /**
* Feedback after showing/sending an alarm notification * Feedback after showing/sending an alarm notification
* *
* @see Driver:dismiss_alarm() * @see calendar_driver::dismiss_alarm()
*/ */
public function dismiss_alarm($event_id, $snooze = 0) public function dismiss_alarm($event_id, $snooze = 0)
{ {

View file

@ -242,7 +242,7 @@ class kolab_calendar
/** /**
* Create a new event record * Create a new event record
* *
* @see Driver:new_event() * @see calendar_driver::new_event()
* *
* @return mixed The created record ID on success, False on error * @return mixed The created record ID on success, False on error
*/ */
@ -263,6 +263,9 @@ class kolab_calendar
true, false); true, false);
$saved = false; $saved = false;
} }
else {
$this->events[$event['uid']] = $event;
}
return $saved; return $saved;
} }
@ -270,7 +273,7 @@ class kolab_calendar
/** /**
* Update a specific event record * Update a specific event record
* *
* @see Driver:new_event() * @see calendar_driver::new_event()
* @return boolean True on success, False on error * @return boolean True on success, False on error
*/ */
@ -289,6 +292,7 @@ class kolab_calendar
} }
else { else {
$updated = true; $updated = true;
$this->events[$event['id']] = $this->_to_rcube_event($object);
} }
return $updated; return $updated;
@ -297,7 +301,7 @@ class kolab_calendar
/** /**
* Delete an event record * Delete an event record
* *
* @see Driver:remove_event() * @see calendar_driver::remove_event()
* @return boolean True on success, False on error * @return boolean True on success, False on error
*/ */
public function delete_event($event, $force = true) public function delete_event($event, $force = true)
@ -332,7 +336,7 @@ class kolab_calendar
/** /**
* Restore deleted event record * Restore deleted event record
* *
* @see Driver:undelete_event() * @see calendar_driver::undelete_event()
* @return boolean True on success, False on error * @return boolean True on success, False on error
*/ */
public function restore_event($event) public function restore_event($event)

View file

@ -274,10 +274,24 @@ class kolab_driver extends calendar_driver
} }
/**
* Move a single event
*
* @see calendar_driver::get_event()
* @return array Hash array with event properties, false if not found
*/
public function get_event($event)
{
if ($storage = $this->calendars[$event['calendar']])
return $storage->get_event($event['id']);
return false;
}
/** /**
* Add a single event to the database * Add a single event to the database
* *
* @see Driver:new_event() * @see calendar_driver::new_event()
*/ */
public function new_event($event) public function new_event($event)
{ {
@ -307,7 +321,7 @@ class kolab_driver extends calendar_driver
/** /**
* Update an event entry with the given data * Update an event entry with the given data
* *
* @see Driver:new_event() * @see calendar_driver::new_event()
* @return boolean True on success, False on error * @return boolean True on success, False on error
*/ */
public function edit_event($event) public function edit_event($event)
@ -318,7 +332,7 @@ class kolab_driver extends calendar_driver
/** /**
* Move a single event * Move a single event
* *
* @see Driver:move_event() * @see calendar_driver::move_event()
* @return boolean True on success, False on error * @return boolean True on success, False on error
*/ */
public function move_event($event) public function move_event($event)
@ -332,7 +346,7 @@ class kolab_driver extends calendar_driver
/** /**
* Resize a single event * Resize a single event
* *
* @see Driver:resize_event() * @see calendar_driver::resize_event()
* @return boolean True on success, False on error * @return boolean True on success, False on error
*/ */
public function resize_event($event) public function resize_event($event)
@ -578,7 +592,7 @@ class kolab_driver extends calendar_driver
/** /**
* Get a list of pending alarms to be displayed to the user * Get a list of pending alarms to be displayed to the user
* *
* @see Driver:pending_alarms() * @see calendar_driver::pending_alarms()
*/ */
public function pending_alarms($time, $calendars = null) public function pending_alarms($time, $calendars = null)
{ {
@ -649,7 +663,7 @@ class kolab_driver extends calendar_driver
/** /**
* Feedback after showing/sending an alarm notification * Feedback after showing/sending an alarm notification
* *
* @see Driver:dismiss_alarm() * @see calendar_driver::dismiss_alarm()
*/ */
public function dismiss_alarm($event_id, $snooze = 0) public function dismiss_alarm($event_id, $snooze = 0)
{ {