1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
spaceservice.php
См. документацию.
1<?php
2
3namespace Bitrix\Calendar\Integration\SocialNetwork;
4
5use Bitrix\Main\Loader;
6use Bitrix\Main\LoaderException;
7use Bitrix\Socialnetwork\Internals\EventService\EventDictionary;
8use Bitrix\Socialnetwork\Internals\EventService\Service;
9
11{
12 // TODO uncomment when needed
13 public const SUPPORTED_EVENTS = [
14 'invite',
15 'onAfterCalendarEventDelete',
16// 'onAfterCalendarEventUpdate',
17 'onCalendarEventCommentAdd',
18// 'onCalendarEventCommentDelete',
19 ];
20
24 public static function isAvailable(): bool
25 {
26 if (
27 !Loader::includeModule('socialnetwork')
28 || !class_exists(\Bitrix\Socialnetwork\Space\Service::class)
29 )
30 {
31 return false;
32 }
33
34 return \Bitrix\Socialnetwork\Space\Service::isAvailable();
35 }
36
37 public function addEvent(string $type, array $data): void
38 {
39 if (!static::isAvailable())
40 {
41 return;
42 }
43
44 if (!in_array($type, self::SUPPORTED_EVENTS, true))
45 {
46 return;
47 }
48
49 // enrich payload
50 $data['RECEPIENTS'] = $this->getRecipientIds($data);
51 Service::addEvent($this->mapTaskToSpaceEvent($type), $data);
52 }
53
54 private function mapTaskToSpaceEvent(string $type): string
55 {
56 // TODO uncomment when needed
57 $map = [
59// 'onAfterCalendarEventUpdate' => EventDictionary::EVENT_SPACE_CALENDAR_EVENT_UPD,
60 'onAfterCalendarEventDelete' => EventDictionary::EVENT_SPACE_CALENDAR_EVENT_DEL,
62// 'onCalendarEventCommentDelete' => EventDictionary::EVENT_SPACE_CALENDAR_EVENT_COMMENT_DEL,
63 ];
64
66 }
67
68 private function getRecipientIds(array $data): array
69 {
70 if (isset($data['TO_USER_ID']))
71 {
72 return [$data['TO_USER_ID']];
73 }
74
75 if (is_array($data['ATTENDEE_LIST'] ?? null))
76 {
77 return $this->getRecipientFromAttendeeList($data['ATTENDEE_LIST']);
78 }
79
80 return [];
81 }
82
83 private function getRecipientFromAttendeeList(array $attendeeList): array
84 {
85 $recipients = [];
86
87 foreach ($attendeeList as $attendee)
88 {
89 if (!empty($attendee['id']))
90 {
91 $recipients[] = (int)$attendee['id'];
92 }
93 }
94
95 return $recipients;
96 }
97}
$type
Определения options.php:106
addEvent(string $type, array $data)
Определения spaceservice.php:37
$data['IS_AVAILABLE']
Определения .description.php:13
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$map
Определения config.php:5