create OC_Calendar_Object::generateStartEndDate function
This commit is contained in:
parent
4767c70578
commit
aa7ce480f4
|
@ -400,36 +400,10 @@ class OC_Calendar_App{
|
||||||
}else{
|
}else{
|
||||||
$object->expand($start, $end);
|
$object->expand($start, $end);
|
||||||
foreach($object->getComponents() as $vevent){
|
foreach($object->getComponents() as $vevent){
|
||||||
if(get_class($vevent) != 'Sabre_VObject_Component_VEvent'){
|
if(!($vevent instanceof Sabre_VObject_Component_VEvent)){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$dynamicoutput = array();
|
$dynamicoutput = OC_Calendar_Object::generateStartEndDate($vevent->DTSTART, OC_Calendar_Object::getDTEndFromVEvent($vevent), self::$tz);
|
||||||
$dtstart = $vevent->DTSTART;
|
|
||||||
$start_dt = $dtstart->getDateTime();
|
|
||||||
$dtend = OC_Calendar_Object::getDTEndFromVEvent($vevent);
|
|
||||||
$end_dt = $dtend->getDateTime();
|
|
||||||
|
|
||||||
if($allday){
|
|
||||||
$dynamicoutput['start'] = $start_dt->format('Y-m-d');
|
|
||||||
$end_dt->modify('-1 sec');
|
|
||||||
$dynamicoutput['end'] = $end_dt->format('Y-m-d');
|
|
||||||
}else{
|
|
||||||
$start_dt->setTimezone(new DateTimeZone(self::$tz));
|
|
||||||
$end_dt->setTimezone(new DateTimeZone(self::$tz));
|
|
||||||
$dynamicoutput['start'] = $start_dt->format('Y-m-d H:i:s');
|
|
||||||
$dynamicoutput['end'] = $end_dt->format('Y-m-d H:i:s');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Handle exceptions to recurring events
|
|
||||||
/*$exceptionDateObjects = $vevent->select('EXDATE');
|
|
||||||
$exceptionDateMap = Array();
|
|
||||||
foreach ($exceptionDateObjects as $exceptionObject) {
|
|
||||||
foreach($exceptionObject->getDateTimes() as $datetime) {
|
|
||||||
$ts = $datetime->getTimestamp();
|
|
||||||
$exceptionDateMap[idate('Y',$ts)][idate('m', $ts)][idate('d', $ts)] = true;
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
$return[] = array_merge($staticoutput, $dynamicoutput);
|
$return[] = array_merge($staticoutput, $dynamicoutput);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -807,4 +807,21 @@ class OC_Calendar_Object{
|
||||||
$event = self::find($id);
|
$event = self::find($id);
|
||||||
return ($event['repeating'] == 1)?true:false;
|
return ($event['repeating'] == 1)?true:false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function generateStartEndDate($dtstart, $dtend, $tz){
|
||||||
|
$start_dt = $dtstart->getDateTime();
|
||||||
|
$end_dt = $dtend->getDateTime();
|
||||||
|
$return = array();
|
||||||
|
if($allday){
|
||||||
|
$return['start'] = $start_dt->format('Y-m-d');
|
||||||
|
$end_dt->modify('-1 hour');
|
||||||
|
$return['end'] = $end_dt->format('Y-m-d');
|
||||||
|
}else{
|
||||||
|
$start_dt->setTimezone(new DateTimeZone($tz));
|
||||||
|
$end_dt->setTimezone(new DateTimeZone($tz));
|
||||||
|
$return['start'] = $start_dt->format('Y-m-d H:i:s');
|
||||||
|
$return['end'] = $end_dt->format('Y-m-d H:i:s');
|
||||||
|
}
|
||||||
|
return $return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,25 +95,12 @@ class OC_Calendar_Repeat{
|
||||||
$end->modify('+5 years');
|
$end->modify('+5 years');
|
||||||
$object->expand($start, $end);
|
$object->expand($start, $end);
|
||||||
foreach($object->getComponents() as $vevent){
|
foreach($object->getComponents() as $vevent){
|
||||||
if(get_class($vevent) != 'Sabre_VObject_Component_VEvent'){
|
if(!($vevent instanceof Sabre_VObject_Component_VEvent)){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$dtstart = $vevent->DTSTART;
|
$startenddate = OC_Calendar_Object::generateStartEndDate($vevent->DTSTART, OC_Calendar_Object::getDTEndFromVEvent($vevent), 'UTC');
|
||||||
$start_dt = $dtstart->getDateTime();
|
|
||||||
$dtend = OC_Calendar_Object::getDTEndFromVEvent($vevent);
|
|
||||||
$end_dt = $dtend->getDateTime();
|
|
||||||
if ($dtstart->getDateType() == Sabre_VObject_Element_DateTime::DATE){
|
|
||||||
$startdate = $start_dt->format('Y-m-d');
|
|
||||||
$end_dt->modify('-1 sec');
|
|
||||||
$enddate = $end_dt->format('Y-m-d');
|
|
||||||
}else{
|
|
||||||
$start_dt->setTimezone(new DateTimeZone('UTC'));
|
|
||||||
$end_dt->setTimezone(new DateTimeZone('UTC'));
|
|
||||||
$startdate = $start_dt->format('Y-m-d H:i:s');
|
|
||||||
$enddate = $end_dt->format('Y-m-d H:i:s');
|
|
||||||
}
|
|
||||||
$stmt = OCP\DB::prepare('INSERT INTO *PREFIX*calendar_repeat (eventid,calid,startdate,enddate) VALUES(?,?,?,?)');
|
$stmt = OCP\DB::prepare('INSERT INTO *PREFIX*calendar_repeat (eventid,calid,startdate,enddate) VALUES(?,?,?,?)');
|
||||||
$stmt->execute(array($id,OC_Calendar_Object::getCalendarid($id),$startdate,$enddate));
|
$stmt->execute(array($id,OC_Calendar_Object::getCalendarid($id),$startenddate['start'],$startenddate['end']));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue