Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions www/go/modules/community/calendar/model/CalendarEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,7 @@ protected function internalSave() : bool {

if($success) {
$this->addToResourceCalendars();
$this->addToParticipantCalendars();
$this->updateAlerts(go()->getUserId());
$this->changeEventsWithSameUID();
$this->incrementCalendarModSeq();
Expand Down Expand Up @@ -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) {
Expand All @@ -736,6 +757,7 @@ private function addToResourceCalendars() {
}
}
}

private function updateAlerts($userId) {
if(!CoreAlert::$enabled) {
return;
Expand Down