some work on repeating events caching
This commit is contained in:
parent
4f2993cb1d
commit
ac74d87e3e
|
@ -290,4 +290,56 @@
|
|||
|
||||
</table>
|
||||
|
||||
<table>
|
||||
|
||||
<name>*dbprefix*calendar_repeat</name>
|
||||
|
||||
<declaration>
|
||||
|
||||
<field>
|
||||
<name>id</name>
|
||||
<type>integer</type>
|
||||
<default>0</default>
|
||||
<notnull>true</notnull>
|
||||
<autoincrement>1</autoincrement>
|
||||
<unsigned>true</unsigned>
|
||||
<length>4</length>
|
||||
</field>
|
||||
|
||||
<field>
|
||||
<name>eventid</name>
|
||||
<type>integer</type>
|
||||
<default>0</default>
|
||||
<notnull>true</notnull>
|
||||
<unsigned>true</unsigned>
|
||||
<length>4</length>
|
||||
</field>
|
||||
|
||||
<field>
|
||||
<name>calid</name>
|
||||
<type>integer</type>
|
||||
<default>0</default>
|
||||
<notnull>true</notnull>
|
||||
<unsigned>true</unsigned>
|
||||
<length>4</length>
|
||||
</field>
|
||||
|
||||
<field>
|
||||
<name>startdate</name>
|
||||
<type>timestamp</type>
|
||||
<default>0000-00-00 00:00:00</default>
|
||||
<notnull>false</notnull>
|
||||
</field>
|
||||
|
||||
<field>
|
||||
<name>enddate</name>
|
||||
<type>timestamp</type>
|
||||
<default>0000-00-00 00:00:00</default>
|
||||
<notnull>false</notnull>
|
||||
</field>
|
||||
|
||||
</declaration>
|
||||
|
||||
</table>
|
||||
|
||||
</database>
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue