diff options
author | Georg Ehrke <dev@georgswebsite.de> | 2012-06-08 22:22:16 +0200 |
---|---|---|
committer | Georg Ehrke <dev@georgswebsite.de> | 2012-06-08 22:22:16 +0200 |
commit | ac74d87e3eef1e53f168d350f7e38e495e0746f0 (patch) | |
tree | a5ca159463ed62cbba99a301093b7363604fa6e3 /apps/calendar/lib | |
parent | 4f2993cb1d94b4136a7a429e8edf082f7b559ddc (diff) | |
download | nextcloud-server-ac74d87e3eef1e53f168d350f7e38e495e0746f0.tar.gz nextcloud-server-ac74d87e3eef1e53f168d350f7e38e495e0746f0.zip |
some work on repeating events caching
Diffstat (limited to 'apps/calendar/lib')
-rw-r--r-- | apps/calendar/lib/repeat.php | 47 |
1 files changed, 43 insertions, 4 deletions
diff --git a/apps/calendar/lib/repeat.php b/apps/calendar/lib/repeat.php index 89cafa388c6..3117d306c8a 100644 --- a/apps/calendar/lib/repeat.php +++ b/apps/calendar/lib/repeat.php @@ -32,7 +32,17 @@ class OC_Calendar_Repeat{ * @return (array) */ public static function get_inperiod($id, $from, $until){ - + $stmt = OCP\DB::prepare( 'SELECT * FROM *PREFIX*calendar_repeat WHERE eventid = ?' + .' AND ((startdate >= ? AND startdate <= ?)' + .' OR (enddate >= ? AND enddate <= ?)'); + $result = $stmt->execute(array($id, + $from, $until, + $from, $until)); + $return = array(); + while($row = $result->fetchRow()){ + $return[] = $row; + } + return $return; } /* * @brief returns the cache of all repeating events of a calendar @@ -40,22 +50,51 @@ class OC_Calendar_Repeat{ * @return (array) */ public static function getcalendar($id){ - + $stmt = OCP\DB::prepare('SELECT * FROM *PREFIX*calendar_repeat WHERE calid = ?'); + $result = $stmt->execute(array($id)); + $return = array(); + while($row = $result->fetchRow()){ + $return[] = $row; + } + return $return; } /* * @brief returns the cache of all repeating events of a calendar in a specific period * @param (int) $id - id of the event * @param (string) $from - start for period in UTC * @param (string) $until - end for period in UTC + * @return (array) */ public static function getcalendar_inperiod($id, $from, $until){ - + $stmt = OCP\DB::prepare( 'SELECT * FROM *PREFIX*calendar_repeat WHERE calid = ?' + .' AND ((startdate >= ? AND startdate <= ?)' + .' OR (enddate >= ? AND enddate <= ?)'); + $result = $stmt->execute(array($id, + $from, $until, + $from, $until)); + $return = array(); + while($row = $result->fetchRow()){ + $return[] = $row; + } + return $return; } /* * @brief generates the cache the first time + * @param (int) id - id of the event + * @return (bool) */ public static function generate($id){ - + $event = OC_Calendar_Object::find(id); + if($event['repeating'] == 0){ + return false; + } + $object = OC_VObject::parse($event['calendardata']); + $start = new DateTime('first day of January', new DateTimeZone('UTC')); + $start->modify('-5 years'); + $end = new DateTime('last day of December', new DateTimeZone('UTC')); + $end->modify('+5 years'); + $object->expand($start, $end); + } /* * @brief generates the cache the first time for all repeating event of an calendar |