39 $mapperFactory = ServiceLocator::getInstance()->get(
'calendar.service.mappers.factory');
40 $section = $this->getSection($mapperFactory, $command);
49 $event->setAttendeesCollection(
null);
54 $createdEvent = $mapperFactory->getEvent()->create(
$event, [
56 'silentErrorMode' =>
false,
64 if ($createdEvent ===
null)
77 private function checkPermissions(
int $userId,
Section $section, ?
int $categoryId =
null):
void
80 $eventModel = $this->getEventModel($section);
81 $canAdd = $eventAccessController->check(ActionDictionary::ACTION_EVENT_ADD, $eventModel);
88 if ($categoryId !==
null)
90 $canPostAtCategory = EventCategoryAccessController::can(
92 ActionDictionary::ACTION_EVENT_CATEGORY_POST,
96 if (!$canPostAtCategory)
121 'DT_SKIP_TIME' => $command->
isSkipTime() ?
'Y' :
'N',
130 'PRIVATE_EVENT' => $command->
isPrivate(),
133 'SECTION_CAL_TYPE' => $section->
getType(),
134 'SECTION_OWNER_ID' => $section->
getOwner()?->getId(),
135 'MEETING_HOST' => $meetingHostId,
138 'HOST_NAME' => \CCalendar::GetUserName($meetingHostId),
142 'MEETING_CREATOR' => $meetingHostId,
151 $attendees = \CCalendar::GetDestinationUsers($attendeeCodes);
152 $isMeeting = $attendeeService->isMeeting($attendeeCodes, $section, $command->
getUserId());
153 $attendeesAndCodes = $attendeeService->excludeAttendees($attendees, $attendeeCodes, $command->
getExcludeUsers());
155 $entryFields[
'ATTENDEES_CODES'] = $attendeesAndCodes[
'codes'];
156 $entryFields[
'ATTENDEES'] = $attendeesAndCodes[
'attendees'];
157 $entryFields[
'IS_MEETING'] = $isMeeting;
159 $additionalExcludeUsers = [];
161 $section->
getType() === Dictionary::CALENDAR_TYPE[
'user']
163 && $section->
getOwner()?->getId() !== $meetingHostId
166 $additionalExcludeUsers[] = $section->
getOwner()?->getId();
171 $attendeeService->checkBusyAttendees(
173 paramAttendees: $attendeesAndCodes[
'attendees'],
174 additionalExcludeUsers: $additionalExcludeUsers,
179 $entryFields[
'LOCATION'] = $command->
getLocation();
180 $isLocationBusy = !AccessibilityManager::checkAccessibility($command->
getLocation(), [
'fields' => $entryFields]);
192 EventModel::createNew()
193 ->setOwnerId($section->
getOwner()?->getId() ?? 0)
194 ->setSectionId($section->
getId())
195 ->setSectionType($section->
getType() ??
'')