/**
  * @param \OCA\Calendar\IObject|\OCA\Calendar\IObjectCollection $data
  * @param TimezoneMapper $timezones
  * @param int $statusCode
  */
 public function __construct($data, TimezoneMapper $timezones = null, $statusCode = Http::STATUS_OK)
 {
     $vobject = $data->getVObject();
     if ($vobject) {
         if ($timezones) {
             SabreUtility::addMissingVTimezones($vobject, $timezones);
         }
         $serialized = $vobject->serialize();
         parent::__construct($serialized, $statusCode, ['Content-type' => 'text/calendar; charset=utf-8']);
         if ($data instanceof IObject) {
             $this->setETag($data->getEtag(true));
         }
     } else {
         parent::__construct(null, HTTP::STATUS_NO_CONTENT);
     }
 }
 /**
  * @param ICalendar $calendar
  * @param \OCA\Calendar\IObject|\OCA\Calendar\IObjectCollection $data
  * @param TimezoneMapper $timezones
  */
 public function __construct(ICalendar $calendar, $data, TimezoneMapper $timezones)
 {
     $vobject = $data->getVObject();
     if ($vobject) {
         if ($timezones) {
             SabreUtility::addMissingVTimezones($vobject, $timezones);
         }
         $serialized = $vobject->serialize();
         $contentType = 'application/octet-stream';
         $filename = $calendar->getPublicUri();
         if ($data instanceof IObject) {
             $filename .= '-' . $data->getSummary();
         }
         $filename .= '.ics';
         parent::__construct($serialized, $filename, $contentType);
     }
 }
Ejemplo n.º 3
0
 /**
  * get endDate
  * @return DateTime
  */
 public function getEndDate()
 {
     /** @var \Sabre\VObject\Component $object */
     $object = $this->vObject->{$this->getObjectName()};
     $realEnd = SabreUtility::getDTEnd($object);
     if ($realEnd instanceof SDateTime || $realEnd instanceof SDate) {
         return $realEnd->getDateTime();
     } else {
         return null;
     }
 }
Ejemplo n.º 4
0
 /**
  * create calendar object from VCalendar
  * @param VCalendar $vcalendar
  * @return $this
  */
 public function fromVObject(VCalendar $vcalendar)
 {
     foreach ($this->icsMapper as $classvar => $icsproperty) {
         $setter = 'set' . ucfirst($classvar);
         $value = $vcalendar->select($icsproperty);
         if (!empty($value)) {
             $this->{$setter}(reset($value));
         }
     }
     $tzIds = $vcalendar->select('X-WR-TIMEZONE');
     $tzId = reset($tzIds);
     $tz = SabreUtility::getTimezoneFromVObject($vcalendar, $tzId);
     if ($tz) {
         $this->setTimezone($tz);
     }
     return $this;
 }