diff --git a/www/go/modules/community/calendar/model/CalendarEvent.php b/www/go/modules/community/calendar/model/CalendarEvent.php index 5a880731a..2ced83c2d 100644 --- a/www/go/modules/community/calendar/model/CalendarEvent.php +++ b/www/go/modules/community/calendar/model/CalendarEvent.php @@ -688,6 +688,7 @@ protected function internalSave() : bool { if($success) { $this->addToResourceCalendars(); + $this->addToParticipantCalendars(); $this->updateAlerts(go()->getUserId()); $this->changeEventsWithSameUID(); $this->incrementCalendarModSeq(); @@ -723,6 +724,26 @@ public function toArray(array|null $properties = null): array|null return $arr; } + private function addToParticipantCalendars() { + if(empty($this->participants)) return; + + foreach($this->participants as $pid => $participant) { + if($participant->kind == 'individual' && !$participant->isOwner()) { + $personalCalendar = Calendar::fetchPersonal($pid); + if($personalCalendar) { + $user = User::findById(str_replace('User:', '', $pid), ['id','displayName','calendarPreferences']); + // ignore if user has enabled automatic adding of invitations + if (!$user || $user->calendarPreferences->autoAddInvitations == true) { + continue; + } + go()->getDbConnection()->insertIgnore('calendar_calendar_event', [ + ['calendarId'=>$personalCalendar, 'eventId'=>$this->eventId] + ])->execute(); + } + } + } + } + private function addToResourceCalendars() { if(empty($this->participants)) return; foreach($this->participants as $pid => $participant) { @@ -736,6 +757,7 @@ private function addToResourceCalendars() { } } } + private function updateAlerts($userId) { if(!CoreAlert::$enabled) { return;