diff options
Diffstat (limited to 'apps/calendar/lib/repeat.php')
-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 |