1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
add.php
См. документацию.
1<?php
2
4
12
13class Add extends Base
14{
15 public function checkPermissions(): void
16 {
17 $canAdd = $this->getAccessController()->check(ActionDictionary::ACTION_EVENT_ADD, $this->getEventModel());
18 if (!$canAdd)
19 {
20 throw new PermissionDenied();
21 }
22 }
23
24 public function execute(): Result
25 {
26 $params = $this->getInitialParams();
27 $section = $this->getSection();
28 $meetingHost = $params['meeting_host'] ?? \CCalendar::GetUserId();
29
30 $entryFields = [
31 'ID' => 0,
32 'DATE_FROM' => $params['dates']['date_from'],
33 'DATE_TO' => $params['dates']['date_to'],
34 'SKIP_TIME' => $params['dates']['skip_time'],
35 'TZ_FROM' => $params['timezones']['timezone_from'],
36 'TZ_TO' => $params['timezones']['timezone_to'],
37 'NAME' => $params['name'],
38 'DESCRIPTION' => $params['description'],
39 'SECTIONS' => [$this->getSectionId()],
40 'COLOR' => $params['color'],
41 'ACCESSIBILITY' => $params['accessibility'],
42 'IMPORTANCE' => $params['importance'],
43 'PRIVATE_EVENT' => $params['private_event'],
44 'RRULE' => $params['rrule'],
45 'REMIND' => $params['remind'],
46 'SECTION_CAL_TYPE' => $section['CAL_TYPE'],
47 'SECTION_OWNER_ID' => $section['OWNER_ID'],
48 'MEETING_HOST' => $meetingHost,
49 'MEETING' => [
50 'HOST_NAME' => \CCalendar::GetUserName($meetingHost),
51 'NOTIFY' => $params['meeting_notify'] === 'Y',
52 'REINVITE' => $params['meeting_reinvite'] === 'Y',
53 'ALLOW_INVITE' => $params['allow_invite'] === 'Y',
54 'MEETING_CREATOR' => $meetingHost,
55 'HIDE_GUESTS' => $params['hide_guests'] === 'Y',
56 'CHAT_ID' => $params['chat_id'] ?? null,
57 ],
58 ];
59
60 // Attendees
61 $entryFields['ATTENDEES_CODES'] = $this->getAttendeeAccessCodes();
62 $entryFields['ATTENDEES'] = \CCalendar::GetDestinationUsers($entryFields['ATTENDEES_CODES']);
63 $entryFields['IS_MEETING'] = $this->isMeeting($entryFields['ATTENDEES_CODES']);
64 $entryFields = $this->excludeAttendees($entryFields);
65 $this->checkBusyAttendies($entryFields);
66
67 // Location
68 $entryFields['LOCATION'] = $params['location'];
69
70 if (!AccessibilityManager::checkAccessibility($entryFields['LOCATION'], ['fields' => $entryFields]))
71 {
72 throw new LocationBusy();
73 }
74
75 $newId = \CCalendar::SaveEvent([
76 'arFields' => $entryFields,
77 'UF' => $params['uf_fields'],
78 'silentErrorMode' => false,
79 'recursionEditMode' => $params['rec_edit_mode'],
80 'currentEventDateFrom' => $params['current_date_from'],
81 'sendInvitesToDeclined' => $params['send_invites_again'],
82 'requestUid' => $params['request_uid'],
83 'checkLocationOccupancy' => $params['check_location_occupancy'],
84 ]);
85
86 $errors = \CCalendar::GetErrors();
87
88 return new Result($newId, $errors);
89 }
90
91 private function getEventModel(): EventModel
92 {
93 $section = $this->getSection();
94 return
95 EventModel::createNew()
96 ->setOwnerId((int)($section['OWNER_ID'] ?? 0))
97 ->setSectionId($this->getSectionId())
98 ->setSectionType($section['CAL_TYPE'] ?? '')
99 ;
100 }
101}
isMeeting(array $accessCodes)
Определения base.php:107
checkBusyAttendies(array $entryFields)
Определения base.php:143
excludeAttendees(array $entryFields)
Определения base.php:116
Определения util.php:21
$errors
Определения iblock_catalog_edit.php:74
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
Определения template.php:799