1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
notificationmanager.php
См. документацию.
1<?php
2
3namespace Bitrix\Calendar\Sync\Managers;
4
5use Bitrix\Main\LoaderException;
6use Bitrix\Main\Localization\Loc;
7use Bitrix\Main;
8use CAgent;
9use CIMNotify;
10use CTimeZone;
11
12use function ConvertTimeStamp;
13
15{
16 private const FINISHED_SYNC_NOTIFICATION_DELAY = 60;
17
26 public static function sendFinishedSyncNotification(int $userId, string $vendorName): void
27 {
28 if (
30 && !empty($vendorName)
31 && Main\Loader::includeModule("im")
32 )
33 {
34 $notificationCallback = fn (?string $languageId = null) => Loc::getMessage(
35 'FINISHED_SYNC_NOTIFICATION_' . mb_strtoupper($vendorName),
36 null,
37 $languageId
38 );
39
40 CIMNotify::Add([
41 'TO_USER_ID' => $userId,
42 'FROM_USER_ID' => $userId,
43 'NOTIFY_TYPE' => IM_NOTIFY_SYSTEM,
44 'NOTIFY_MODULE' => 'calendar',
45 'NOTIFY_TAG' => 'CALENDAR|SYNC_FINISH|'.$userId,
46 'NOTIFY_SUB_TAG' => 'CALENDAR|SYNC_FINISH|'.$userId,
47 'NOTIFY_MESSAGE' => $notificationCallback
48 ]);
49 }
50 }
51
60 public static function sendRollbackSyncNotification(int $userId, string $vendorName): void
61 {
62 if (
64 && !empty($vendorName)
65 && Main\Loader::includeModule("im")
66 )
67 {
68 $notificationCallback = fn (?string $languageId = null) => Loc::getMessage(
69 'ROLLBACK_SYNC_NOTIFICATION_' . mb_strtoupper($vendorName),
70 null,
71 $languageId
72 );
73
74 CIMNotify::Add([
75 'TO_USER_ID' => $userId,
76 'FROM_USER_ID' => $userId,
77 'NOTIFY_TYPE' => IM_NOTIFY_SYSTEM,
78 'NOTIFY_MODULE' => 'calendar',
79 'NOTIFY_TAG' => 'CALENDAR|SYNC_ROLLBACK|'.$userId,
80 'NOTIFY_SUB_TAG' => 'CALENDAR|SYNC_ROLLBACK|'.$userId,
81 'NOTIFY_MESSAGE' => $notificationCallback
82 ]);
83 }
84 }
85
92 public static function clearFinishedSyncNotificationAgent(int $userId, string $vendorName): void
93 {
94 CAgent::RemoveAgent(
95 '\\Bitrix\\Calendar\\Sync\\Managers\\NotificationManager::sendFinishedSyncNotification('
96 . $userId . ', '
97 . "'" . $vendorName . "'" . ');',
98 'calendar'
99 );
100 }
101
108 public static function addFinishedSyncNotificationAgent(int $userId, string $vendorName): void
109 {
110 CAgent::AddAgent(
111 '\\Bitrix\\Calendar\\Sync\\Managers\\NotificationManager::sendFinishedSyncNotification('
112 . $userId . ', '
113 . "'" . $vendorName . "'" . ');',
114 'calendar',
115 'Y',
116 0,
117 '',
118 'Y',
119 ConvertTimeStamp(time() + CTimeZone::GetOffset() + self::FINISHED_SYNC_NOTIFICATION_DELAY, 'FULL')
120 );
121 }
122
131 public static function sendBlockChangeNotification(int $userId, $messageCode, $vars): void
132 {
133 if (
134 $userId
135 && !empty(Loc::getMessage($messageCode))
136 && Main\Loader::includeModule("im")
137 )
138 {
139 $notificationCallback = fn (?string $languageId = null) => Loc::getMessage($messageCode, $vars, $languageId);
140
141 CIMNotify::Add([
142 'TO_USER_ID' => $userId,
143 'FROM_USER_ID' => $userId,
144 'NOTIFY_TYPE' => IM_NOTIFY_SYSTEM,
145 'NOTIFY_MODULE' => 'calendar',
146 'NOTIFY_TAG' => 'CALENDAR|SYNC_ROLLBACK|' . $userId . '|' . ($vars['EVENT_ID'] ?? random_int(1,100)),
147 'NOTIFY_SUB_TAG' => 'CALENDAR|SYNC_ROLLBACK|'.$userId,
148 'NOTIFY_MESSAGE' => $notificationCallback
149 ]);
150 }
151 }
152}
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
Определения check_mail.php:18
static addFinishedSyncNotificationAgent(int $userId, string $vendorName)
Определения notificationmanager.php:108
static sendRollbackSyncNotification(int $userId, string $vendorName)
Определения notificationmanager.php:60
static clearFinishedSyncNotificationAgent(int $userId, string $vendorName)
Определения notificationmanager.php:92
static sendFinishedSyncNotification(int $userId, string $vendorName)
Определения notificationmanager.php:26
static sendBlockChangeNotification(int $userId, $messageCode, $vars)
Определения notificationmanager.php:131
const IM_NOTIFY_SYSTEM
Определения include.php:38