@@ -245,28 +245,30 @@ private function addVEvent(CalendarEventIF $item, bool $isRecurrenceChild = fals
245245 }
246246 }
247247
248- $ organizer = $ item ->getOrganizer ();
249- if ($ organizer instanceof User) {
250- $ evt ->add (
251- 'ORGANIZER;CN= ' . $ this ->getCN ($ organizer ),
252- 'mailto: ' . $ this ->getMailto ($ organizer ),
253- );
248+ $ eventType = $ item ->getEventType ();
249+
250+ if ($ eventType instanceof CalendarEntryType && !empty ($ category = $ eventType ->name )) {
251+ $ evt ->add ('CATEGORIES ' , $ category );
254252 }
255253
256- if ($ this -> includeParticipantInfo && $ item instanceof CalendarEventParticipationIF) {
257- foreach ( $ item ->findParticipants ()-> limit ( self :: MAX_PARTICIPANTS_COUNT )-> all () as $ participant ) {
258- /* @var $user User */
254+ if ($ item instanceof CalendarEventParticipationIF) {
255+ $ organizer = $ item ->getOrganizer ();
256+ if ( $ organizer instanceof User) {
259257 $ evt ->add (
260- 'ATTENDEE ;CN= ' . $ this ->getCN ($ participant ),
261- 'mailto: ' . $ this ->getMailto ($ participant ),
258+ 'ORGANIZER ;CN= ' . $ this ->getCN ($ organizer ),
259+ 'mailto: ' . $ this ->getMailto ($ organizer ),
262260 );
263261 }
264- }
265262
266- $ eventType = $ item ->getEventType ();
267-
268- if ($ eventType instanceof CalendarEntryType && !empty ($ category = $ eventType ->name )) {
269- $ evt ->add ('CATEGORIES ' , $ category );
263+ if ($ this ->includeParticipantInfo ) {
264+ foreach ($ item ->findParticipants ()->limit (self ::MAX_PARTICIPANTS_COUNT )->all () as $ participant ) {
265+ /* @var $user User */
266+ $ evt ->add (
267+ 'ATTENDEE;CN= ' . $ this ->getCN ($ participant ),
268+ 'mailto: ' . $ this ->getMailto ($ participant ),
269+ );
270+ }
271+ }
270272 }
271273
272274 return $ this ;
0 commit comments