Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
notificationmanager.php
1
<?php
2
3
namespace
Bitrix\Calendar\Sync\Managers
;
4
5
use
Bitrix\Main\LoaderException
;
6
use
Bitrix\Main\Localization\Loc
;
7
use
Bitrix\Main
;
8
use CAgent;
9
use CIMNotify;
10
use CTimeZone;
11
12
use
function
ConvertTimeStamp;
13
14
class
NotificationManager
15
{
16
private
const
FINISHED_SYNC_NOTIFICATION_DELAY = 60;
17
26
public
static
function
sendFinishedSyncNotification
(
int
$userId,
string
$vendorName): void
27
{
28
if
(
29
Main\Loader::includeModule(
"im"
)
30
&& $userId
31
&& !empty($vendorName)
32
)
33
{
34
CIMNotify::Add([
35
'TO_USER_ID'
=> $userId,
36
'FROM_USER_ID'
=> $userId,
37
'NOTIFY_TYPE'
=> IM_NOTIFY_SYSTEM,
38
'NOTIFY_MODULE'
=>
'calendar'
,
39
'NOTIFY_TAG'
=>
'CALENDAR|SYNC_FINISH|'
.$userId,
40
'NOTIFY_SUB_TAG'
=>
'CALENDAR|SYNC_FINISH|'
.$userId,
41
'NOTIFY_MESSAGE'
=>
Loc::getMessage
(
'FINISHED_SYNC_NOTIFICATION_'
.mb_strtoupper($vendorName))
42
]);
43
}
44
}
45
54
public
static
function
sendRollbackSyncNotification
(
int
$userId,
string
$vendorName): void
55
{
56
if
(
57
Main\Loader::includeModule(
"im"
)
58
&& $userId
59
&& !empty($vendorName)
60
)
61
{
62
CIMNotify::Add([
63
'TO_USER_ID'
=> $userId,
64
'FROM_USER_ID'
=> $userId,
65
'NOTIFY_TYPE'
=> IM_NOTIFY_SYSTEM,
66
'NOTIFY_MODULE'
=>
'calendar'
,
67
'NOTIFY_TAG'
=>
'CALENDAR|SYNC_ROLLBACK|'
.$userId,
68
'NOTIFY_SUB_TAG'
=>
'CALENDAR|SYNC_ROLLBACK|'
.$userId,
69
'NOTIFY_MESSAGE'
=>
Loc::getMessage
(
'ROLLBACK_SYNC_NOTIFICATION_'
.mb_strtoupper($vendorName))
70
]);
71
}
72
}
73
80
public
static
function
clearFinishedSyncNotificationAgent
(
int
$userId,
string
$vendorName): void
81
{
82
CAgent::RemoveAgent(
83
'\\Bitrix\\Calendar\\Sync\\Managers\\NotificationManager::sendFinishedSyncNotification('
84
. $userId .
', '
85
.
"'"
. $vendorName .
"'"
.
');'
,
86
'calendar'
87
);
88
}
89
96
public
static
function
addFinishedSyncNotificationAgent
(
int
$userId,
string
$vendorName): void
97
{
98
CAgent::AddAgent(
99
'\\Bitrix\\Calendar\\Sync\\Managers\\NotificationManager::sendFinishedSyncNotification('
100
. $userId .
', '
101
.
"'"
. $vendorName .
"'"
.
');'
,
102
'calendar'
,
103
'Y'
,
104
0,
105
''
,
106
'Y'
,
107
ConvertTimeStamp(time() + CTimeZone::GetOffset() + self::FINISHED_SYNC_NOTIFICATION_DELAY,
'FULL'
)
108
);
109
}
110
119
public
static
function
sendBlockChangeNotification
(
int
$userId, $messageCode, $vars)
120
{
121
if
(
122
Main\Loader::includeModule(
"im"
)
123
&& $userId
124
&& !empty(
Loc::getMessage
($messageCode))
125
)
126
{
127
$message =
Loc::getMessage
($messageCode, $vars);
128
129
CIMNotify::Add([
130
'TO_USER_ID'
=> $userId,
131
'FROM_USER_ID'
=> $userId,
132
'NOTIFY_TYPE'
=> IM_NOTIFY_SYSTEM,
133
'NOTIFY_MODULE'
=>
'calendar'
,
134
'NOTIFY_TAG'
=>
'CALENDAR|SYNC_ROLLBACK|'
. $userId .
'|'
. ($vars[
'EVENT_ID'
] ?? rand(1,100)),
135
'NOTIFY_SUB_TAG'
=>
'CALENDAR|SYNC_ROLLBACK|'
.$userId,
136
'NOTIFY_MESSAGE'
=> $message
137
]);
138
}
139
}
140
}
Bitrix\Calendar\Sync\Managers\NotificationManager
Definition
notificationmanager.php:15
Bitrix\Calendar\Sync\Managers\NotificationManager\addFinishedSyncNotificationAgent
static addFinishedSyncNotificationAgent(int $userId, string $vendorName)
Definition
notificationmanager.php:96
Bitrix\Calendar\Sync\Managers\NotificationManager\sendRollbackSyncNotification
static sendRollbackSyncNotification(int $userId, string $vendorName)
Definition
notificationmanager.php:54
Bitrix\Calendar\Sync\Managers\NotificationManager\clearFinishedSyncNotificationAgent
static clearFinishedSyncNotificationAgent(int $userId, string $vendorName)
Definition
notificationmanager.php:80
Bitrix\Calendar\Sync\Managers\NotificationManager\sendFinishedSyncNotification
static sendFinishedSyncNotification(int $userId, string $vendorName)
Definition
notificationmanager.php:26
Bitrix\Calendar\Sync\Managers\NotificationManager\sendBlockChangeNotification
static sendBlockChangeNotification(int $userId, $messageCode, $vars)
Definition
notificationmanager.php:119
Bitrix\Main\LoaderException
Definition
loader.php:582
Bitrix\Main\Localization\Loc
Definition
loc.php:11
Bitrix\Main\Localization\Loc\getMessage
static getMessage($code, $replace=null, $language=null)
Definition
loc.php:29
Bitrix\Calendar\Sync\Managers
Definition
connectionmanager.php:3
Bitrix\Main
modules
calendar
lib
sync
managers
notificationmanager.php
Создано системой
1.10.0