当前位置: 首页>>代码示例>>PHP>>正文


PHP VCalendar::create方法代码示例

本文整理汇总了PHP中Sabre\VObject\Component\VCalendar::create方法的典型用法代码示例。如果您正苦于以下问题:PHP VCalendar::create方法的具体用法?PHP VCalendar::create怎么用?PHP VCalendar::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Sabre\VObject\Component\VCalendar的用法示例。


在下文中一共展示了VCalendar::create方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _convertCalendarModelEvent

 /**
  * convert calendar event to Sabre\VObject\Component
  * 
  * @param  \Sabre\VObject\Component\VCalendar $vcalendar
  * @param  Calendar_Model_Event               $_event
  * @param  Calendar_Model_Event               $_mainEvent
  */
 protected function _convertCalendarModelEvent(\Sabre\VObject\Component\VCalendar $vcalendar, Calendar_Model_Event $_event, Calendar_Model_Event $_mainEvent = null)
 {
     // clone the event and change the timezone
     $event = clone $_event;
     $event->setTimezone($event->originator_tz);
     $lastModifiedDateTime = $_event->last_modified_time ? $_event->last_modified_time : $_event->creation_time;
     if (!$event->creation_time instanceof Tinebase_DateTime) {
         throw new Tinebase_Exception_Record_Validation('creation_time needed for conversion to Sabre\\VObject\\Component');
     }
     $vevent = $vcalendar->create('VEVENT', array('CREATED' => $_event->creation_time->getClone()->setTimezone('UTC'), 'LAST-MODIFIED' => $lastModifiedDateTime->getClone()->setTimezone('UTC'), 'DTSTAMP' => Tinebase_DateTime::now(), 'UID' => $event->uid));
     $vevent->add('SEQUENCE', $event->hasExternalOrganizer() ? $event->external_seq : $event->seq);
     if ($event->isRecurException()) {
         $originalDtStart = $_event->getOriginalDtStart()->setTimezone($_event->originator_tz);
         $recurrenceId = $vevent->add('RECURRENCE-ID', $originalDtStart);
         if ($_mainEvent && $_mainEvent->is_all_day_event == true) {
             $recurrenceId['VALUE'] = 'DATE';
         }
     }
     // dtstart and dtend
     $dtstart = $vevent->add('DTSTART', $_event->dtstart->getClone()->setTimezone($event->originator_tz));
     if ($event->is_all_day_event == true) {
         $dtstart['VALUE'] = 'DATE';
         // whole day events ends at 23:59:(00|59) in Tine 2.0 but 00:00 the next day in vcalendar
         $event->dtend->addSecond($event->dtend->get('s') == 59 ? 1 : 0);
         $event->dtend->addMinute($event->dtend->get('i') == 59 ? 1 : 0);
         $dtend = $vevent->add('DTEND', $event->dtend);
         $dtend['VALUE'] = 'DATE';
     } else {
         $dtend = $vevent->add('DTEND', $event->dtend);
     }
     // auto status for deleted events
     if ($event->is_deleted) {
         $event->status = Calendar_Model_Event::STATUS_CANCELED;
     }
     // event organizer
     if (!empty($event->organizer)) {
         $organizerContact = $event->resolveOrganizer();
         if ($organizerContact instanceof Addressbook_Model_Contact && !empty($organizerContact->email)) {
             $organizer = $vevent->add('ORGANIZER', 'mailto:' . $organizerContact->email, array('CN' => $organizerContact->n_fileas, 'EMAIL' => $organizerContact->email));
         }
     }
     $this->_addEventAttendee($vevent, $event);
     $optionalProperties = array('class', 'status', 'description', 'geo', 'location', 'priority', 'summary', 'transp', 'url');
     foreach ($optionalProperties as $property) {
         if (!empty($event->{$property})) {
             $vevent->add(strtoupper($property), $event->{$property});
         }
     }
     $class = $event->class == Calendar_Model_Event::CLASS_PUBLIC ? 'PUBLIC' : 'CONFIDENTIAL';
     $vcalendar->add('X-CALENDARSERVER-ACCESS', $class);
     $vevent->add('X-CALENDARSERVER-ACCESS', $class);
     // categories
     if (!isset($event->tags)) {
         $event->tags = Tinebase_Tags::getInstance()->getTagsOfRecord($event);
     }
     if (isset($event->tags) && count($event->tags) > 0) {
         $vevent->add('CATEGORIES', (array) $event->tags->name);
     }
     // repeating event properties
     if ($event->rrule) {
         if ($event->is_all_day_event == true) {
             $vevent->add('RRULE', preg_replace_callback('/UNTIL=([\\d :-]{19})(?=;?)/', function ($matches) {
                 $dtUntil = new Tinebase_DateTime($matches[1]);
                 $dtUntil->setTimezone((string) Tinebase_Core::getUserTimezone());
                 return 'UNTIL=' . $dtUntil->format('Ymd');
             }, $event->rrule));
         } else {
             $vevent->add('RRULE', preg_replace('/(UNTIL=)(\\d{4})-(\\d{2})-(\\d{2}) (\\d{2}):(\\d{2}):(\\d{2})/', '$1$2$3$4T$5$6$7Z', $event->rrule));
         }
         if ($event->exdate instanceof Tinebase_Record_RecordSet) {
             $event->exdate->addIndices(array('is_deleted'));
             $deletedEvents = $event->exdate->filter('is_deleted', true);
             foreach ($deletedEvents as $deletedEvent) {
                 $dateTime = $deletedEvent->getOriginalDtStart();
                 $exdate = $vevent->add('EXDATE');
                 if ($event->is_all_day_event == true) {
                     $dateTime->setTimezone($event->originator_tz);
                     $exdate['VALUE'] = 'DATE';
                 }
                 $exdate->setValue($dateTime);
             }
         }
     }
     $ownAttendee = Calendar_Model_Attender::getOwnAttender($event->attendee);
     if ($event->alarms instanceof Tinebase_Record_RecordSet) {
         $mozLastAck = NULL;
         $mozSnooze = NULL;
         foreach ($event->alarms as $alarm) {
             $valarm = $vcalendar->create('VALARM');
             $valarm->add('ACTION', 'DISPLAY');
             $valarm->add('DESCRIPTION', $event->summary);
             if ($dtack = Calendar_Controller_Alarm::getAcknowledgeTime($alarm)) {
                 $valarm->add('ACKNOWLEDGED', $dtack->getClone()->setTimezone('UTC')->format('Ymd\\THis\\Z'));
//.........这里部分代码省略.........
开发者ID:bitExpert,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:101,代码来源:Abstract.php


注:本文中的Sabre\VObject\Component\VCalendar::create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。