1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
calendarprocessor.php
См. документацию.
1<?php
2
3namespace Bitrix\Socialnetwork\Integration\Calendar\RecentActivity;
4
5use Bitrix\Main\Loader;
6use Bitrix\Socialnetwork\Internals\EventService\EventDictionary;
7use Bitrix\Socialnetwork\Space\List\RecentActivity\Dictionary;
8use Bitrix\Socialnetwork\Space\List\RecentActivity\Event\Processor\AbstractProcessor;
9use Bitrix\Socialnetwork\Space\List\RecentActivity\Event\Trait\AccessCodeTrait;
10
12{
13 use AccessCodeTrait;
14
15 public function isAvailable(): bool
16 {
17 return Loader::includeModule('calendar');
18 }
19
20 protected function getTypeId(): string
21 {
22 return Dictionary::ENTITY_TYPE['calendar'];
23 }
24
25 public function process(): void
26 {
27 $eventId = (int)($this->event->getData()['ID'] ?? null);
28
29 if ($eventId <= 0)
30 {
31 return;
32 }
33
34 switch ($this->event->getType())
35 {
36 case EventDictionary::EVENT_SPACE_CALENDAR_EVENT_DEL:
37 $this->onEventDelete($eventId);
38 break;
39 case EventDictionary::EVENT_SPACE_CALENDAR_EVENT_REMOVE_USERS:
40 $this->onEventRemoveUsers($eventId);
41 break;
42 default:
43 $this->onDefaultEvent($eventId);
44 break;
45 }
46 }
47
48 private function onDefaultEvent(int $eventId): void
49 {
50 $attendeeCodes = $this->event->getData()['ATTENDEES_CODES'] ?? null;
51
52 if (is_string($attendeeCodes))
53 {
54 $attendeeCodes = explode(',', $attendeeCodes);
55 }
56 else
57 {
58 $attendeeCodes = [];
59 }
60
61 $spaceIds = $this->getSpaceIdsFromCodes($attendeeCodes, $this->recipient);
62
63 $spaceIds = array_unique($spaceIds);
64 foreach ($spaceIds as $spaceId)
65 {
66 $this->saveRecentActivityData($spaceId, $eventId);
67 }
68 }
69
70 private function onEventDelete(int $eventId): void
71 {
72 $this->deleteRecentActivityData($eventId);
73 }
74
75 private function onEventRemoveUsers(int $eventId): void
76 {
77 $this->deleteRecentActivityData($eventId);
78 }
79}
saveRecentActivityData(int $spaceId, int $entityId, ?int $secondaryEntityId=null)
Определения AbstractProcessor.php:31