From 4075d18050b8c894fe58c700703ac0844f8b95b8 Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Mon, 17 Oct 2011 19:58:56 +0200 Subject: Implement loading of events in calendar --- apps/calendar/lib/object.php | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'apps/calendar/lib') diff --git a/apps/calendar/lib/object.php b/apps/calendar/lib/object.php index 0c3e497d4f2..4afeb341a9c 100644 --- a/apps/calendar/lib/object.php +++ b/apps/calendar/lib/object.php @@ -30,6 +30,34 @@ class OC_Calendar_Object{ return $calendarobjects; } + /** + * @brief Returns all objects of a calendar between $start and $end + * @param integer $id + * @param DateTime $start + * @param DateTime $end + * @return array + * + * The objects are associative arrays. You'll find the original vObject + * in ['calendardata'] + */ + public static function allInPeriod($id, $start, $end){ + $stmt = OC_DB::prepare( 'SELECT * FROM *PREFIX*calendar_objects WHERE calendarid = ?' + .' AND ((startdate >= ? AND startdate <= ? AND repeating = 0)' + .' OR (startdate <= ? AND enddate >= ? AND repeating = 1))' ); + $start = self::getUTCforMDB($start); + $end = self::getUTCforMDB($end); + $result = $stmt->execute(array($id, + $start, $end, + $end, $start)); + + $calendarobjects = array(); + while( $row = $result->fetchRow()){ + $calendarobjects[] = $row; + } + + return $calendarobjects; + } + /** * @brief Returns an object * @param integer $id -- cgit v1.2.3