parseEvent() публичный Метод

A VCALENDAR object will be created from the perspective of either an attendee, or an organizer. You must pass a string identifying the current user, so we can figure out who in the list of attendees or the organizer we are sending this message on behalf of. It's possible to specify the current user as an array, in case the user has more than one identifying href (such as multiple emails). It $oldCalendar is specified, it is assumed that the operation is updating an existing event, which means that we need to look at the differences between events, and potentially send old attendees cancellations, and current attendees updates. If $calendar is null, but $oldCalendar is specified, we treat the operation as if the user has deleted an event. If the user was an organizer, this means that we need to send cancellation notices to people. If the user was an attendee, we need to make sure that the organizer gets the 'declined' message.
public parseEvent ( Sabre\VObject\Component\VCalendar | string $calendar = null, string | array $userHref, Sabre\VObject\Component\VCalendar | string $oldCalendar = null ) : array
$calendar Sabre\VObject\Component\VCalendar | string
$userHref string | array
$oldCalendar Sabre\VObject\Component\VCalendar | string
Результат array
Пример #1
0
 function parse($oldMessage, $newMessage, $expected = [], $currentUser = '******')
 {
     $broker = new Broker();
     $result = $broker->parseEvent($newMessage, $currentUser, $oldMessage);
     $this->assertEquals(count($expected), count($result));
     foreach ($expected as $index => $ex) {
         $message = $result[$index];
         foreach ($ex as $key => $val) {
             if ($key === 'message') {
                 $this->assertVObjectEqualsVObject($val, $message->message->serialize());
             } else {
                 $this->assertEquals($val, $message->{$key});
             }
         }
     }
 }
Пример #2
0
 /**
  * This method looks at an old iCalendar object, a new iCalendar object and
  * starts sending scheduling messages based on the changes.
  *
  * A list of addresses needs to be specified, so the system knows who made
  * the update, because the behavior may be different based on if it's an
  * attendee or an organizer.
  *
  * This method may update $newObject to add any status changes.
  *
  * @param VCalendar|string $oldObject
  * @param VCalendar $newObject
  * @param array $addresses
  * @param array $ignore Any addresses to not send messages to.
  * @param boolean $modified A marker to indicate that the original object
  *   modified by this process.
  * @return void
  */
 protected function processICalendarChange($oldObject = null, VCalendar $newObject, array $addresses, array $ignore = [], &$modified = false)
 {
     $broker = new ITip\Broker();
     $messages = $broker->parseEvent($newObject, $addresses, $oldObject);
     if ($messages) {
         $modified = true;
     }
     foreach ($messages as $message) {
         if (in_array($message->recipient, $ignore)) {
             continue;
         }
         $this->deliver($message);
         if (isset($newObject->VEVENT->ORGANIZER) && $newObject->VEVENT->ORGANIZER->getNormalizedValue() === $message->recipient) {
             if ($message->scheduleStatus) {
                 $newObject->VEVENT->ORGANIZER['SCHEDULE-STATUS'] = $message->scheduleStatus;
             }
             unset($newObject->VEVENT->ORGANIZER['SCHEDULE-FORCE-SEND']);
         } else {
             if (isset($newObject->VEVENT->ATTENDEE)) {
                 foreach ($newObject->VEVENT->ATTENDEE as $attendee) {
                     if ($attendee->getNormalizedValue() === $message->recipient) {
                         if ($message->scheduleStatus) {
                             $attendee['SCHEDULE-STATUS'] = $message->scheduleStatus;
                         }
                         unset($attendee['SCHEDULE-FORCE-SEND']);
                         break;
                     }
                 }
             }
         }
     }
 }