1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
OpenEventPullService.php
См. документацию.
1<?php
2
4
11
13{
14 public const EVENT_USER_FIELDS_KEY = 'userFields';
15
16 private static ?self $instance;
17
18 public static function getInstance(): self
19 {
20 self::$instance ??= new self();
21
22 return self::$instance;
23 }
24
25 public function createCalendarEvent(Event $event): void
26 {
27 $eventCommonParams = [
28 'module_id' => PushService::MODULE_ID,
29 'command' => PushCommandEnum::OPEN_EVENT_CREATED->name,
30 'params' => [
32 event: $event,
33 userId: 0,
34 isAttendee: false,
35 commentsCount: 0,
36 ))->toArray(),
37 ],
38 ];
39
40 $tag = $this->generateTagByEvent($event);
41 $this->sendEvent($eventCommonParams, tag: $tag);
42 }
43
44 public function updateCalendarEvent(Event $event, array $userParams = []): void
45 {
46 $eventCommonParams = [
47 'module_id' => PushService::MODULE_ID,
48 'command' => PushCommandEnum::OPEN_EVENT_UPDATED->name,
49 'params' => [
51 event: $event,
52 userId: 0,
53 isAttendee: null,
54 commentsCount: null,
55 ))->toArray(),
56 ],
57 ];
58
59 if ($userParams)
60 {
61 $eventCommonParams['user_params'] = $userParams;
62 }
63
64 $tag = $this->generateTagByEvent($event);
65 $this->sendEvent($eventCommonParams, tag: $tag);
66 }
67
68 public function deleteCalendarEvent(Event $event): void
69 {
70 $eventCommonParams = [
71 'module_id' => PushService::MODULE_ID,
72 'command' => PushCommandEnum::OPEN_EVENT_DELETED->name,
73 'params' => [
74 'fields' => [
75 'eventId' => $event->getId(),
76 'categoryId' => $event->getEventOption()->getCategoryId()
77 ],
78 ],
79 ];
80
81 $tag = $this->generateTagByEvent($event);
82 $this->sendEvent($eventCommonParams, tag: $tag);
83 }
84
85 public function addToWatch(int $userId): void
86 {
87 if (!Loader::includeModule('pull'))
88 {
89 return;
90 }
91
92 \CPullWatch::Add($userId, \Bitrix\Calendar\Event\Enum\PushTagEnum::OPEN_EVENT->name);
93 }
94
95 private function sendEvent(array $params, int $userId = null, string $tag = null): void
96 {
97 if (!Loader::includeModule('pull'))
98 {
99 return;
100 }
101
102 if ($userId)
103 {
105 }
106 else
107 {
109 }
110 }
111
112 private function generateTagByEvent(Event $event): string
113 {
114 $isCategoryClosed = $event->getEventOption()->getCategory()->getClosed();
115 $categoryId = $event->getEventOption()->getCategory()->getId();
116
117 return $isCategoryClosed ? $this->generateTagByCategoryId($categoryId) : PushTagEnum::EVENT_CATEGORY->name;
118 }
119
120 private function generateTagByCategoryId(int $eventCategoryId): string
121 {
122 return sprintf('%s_%d', PushTagEnum::EVENT_CATEGORY->name, $eventCategoryId);
123 }
124
125 private function __construct()
126 {
127 }
128}
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
Определения check_mail.php:18
static buildFromEvent(Event $event, int $userId, ?bool $isAttendee, ?int $commentsCount,)
updateCalendarEvent(Event $event, array $userParams=[])
Определения OpenEventPullService.php:44
static addEvent($recipients, array $params)
Определения pushservice.php:43
static addEventByTag(string $tag, array $params)
Определения pushservice.php:55
Определения loader.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
$event
Определения prolog_after.php:141
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
Определения template.php:799