1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
commentlistener.php
См. документацию.
1
<?php
2
3
namespace
Bitrix\Bizproc\Integration
;
4
5
use
Bitrix\Bizproc\Api\Request\WorkflowCommentService\CommentRequest
;
6
use
Bitrix\Bizproc\Api\Request\WorkflowCommentService\MarkAsReadRequest
;
7
use
Bitrix\Bizproc\Api\Service\WorkflowCommentService
;
8
use
Bitrix\Main\Event
;
9
use
Bitrix\Main\Loader
;
10
use
Bitrix\Main\Type\DateTime
;
11
12
class
CommentListener
13
{
14
public
static
function
onAfterCommentAdd
(
Event
$event
): void
15
{
16
[$entityType, $workflowIdInt,
$fields
] =
$event
->getParameters();
17
18
if
($entityType !==
'WF'
|| isset(
$fields
[
'PARAMS'
][
'SERVICE_TYPE'
]))
19
{
20
return
;
21
}
22
23
$authorId = (int)(
$fields
[
'PARAMS'
][
'AUTHOR_ID'
] ?? 0);
24
if
(!$authorId)
25
{
26
return
;
27
}
28
29
$workflowId =
\CBPStateService::getWorkflowByIntegerId
($workflowIdInt);
30
if
(!$workflowId)
31
{
32
return
;
33
}
34
35
$created =
$fields
[
'PARAMS'
][
'POST_DATE'
] ??
new
DateTime
();
36
$mentions = [];
37
$messageText =
$fields
[
'PARAMS'
][
'POST_MESSAGE'
] ??
''
;
38
39
if
(preg_match_all(
"/(?<=\[USER=)(?P<id>\d+)(?=])/"
, $messageText,
$matches
))
40
{
41
$mentions =
$matches
[
'id'
];
42
}
43
44
$service
=
new
WorkflowCommentService
();
45
$service
->registerComment(
new
CommentRequest
($workflowId, $authorId, $created, $mentions));
46
}
47
48
public
static
function
onCommentDelete
(
Event
$event
): void
49
{
50
[$entityType, $workflowIdInt,
$fields
] =
$event
->getParameters();
51
52
if
($entityType !==
'WF'
)
53
{
54
return
;
55
}
56
57
$authorId = (int)(
$fields
[
'MESSAGE'
][
'AUTHOR_ID'
] ?? 0);
58
if
(!$authorId)
59
{
60
return
;
61
}
62
63
$workflowId =
\CBPStateService::getWorkflowByIntegerId
($workflowIdInt);
64
if
(!$workflowId)
65
{
66
return
;
67
}
68
69
$created = DateTime::createFromUserTime(
$fields
[
'MESSAGE'
][
'POST_DATE'
]);
70
71
$service
=
new
WorkflowCommentService
();
72
$service
->unRegisterComment(
new
CommentRequest
($workflowId, $authorId, $created));
73
}
74
75
public
static
function
onListsProcessesCommentAdd
(
string
$workflowId,
int
$authorId,
array
$mentions): void
76
{
77
$service
=
new
WorkflowCommentService
();
78
$service
->registerComment(
new
CommentRequest
($workflowId, $authorId,
new
DateTime
(), $mentions));
79
}
80
81
public
static
function
onListsProcessesCommentDelete
(
string
$workflowId,
int
$authorId,
DateTime
$created): void
82
{
83
$service
=
new
WorkflowCommentService
();
84
$service
->unRegisterComment(
new
CommentRequest
($workflowId, $authorId, $created));
85
}
86
87
public
static
function
onSocnetContentViewed
(
Event
$event
): void
88
{
89
$params
=
$event
->getParameters();
90
91
if
((
$params
[
'typeId'
] ??
''
) !==
'FORUM_POST'
|| empty(
$params
[
'entityId'
]) || empty(
$params
[
'userId'
]))
92
{
93
return
;
94
}
95
96
if
(!Loader::includeModule(
'forum'
))
97
{
98
return
;
99
}
100
101
$xmlId = \Bitrix\Forum\MessageTable::query()
102
->setSelect([
'XML_ID'
])
103
->where(
'ID'
,
$params
[
'entityId'
])
104
->fetch()[
'XML_ID'
] ?? null
105
;
106
107
if
(!$xmlId || strpos($xmlId,
'WF_'
) !== 0)
108
{
109
return
;
110
}
111
112
$workflowId = substr($xmlId, 3);
113
114
$service
=
new
WorkflowCommentService
();
115
$service
->markAsRead(
new
MarkAsReadRequest
($workflowId, (
int
)
$params
[
'userId'
]));
116
}
117
}
Bitrix\Bizproc\Api\Request\WorkflowCommentService\CommentRequest
Определения
CommentRequest.php:8
Bitrix\Bizproc\Api\Request\WorkflowCommentService\MarkAsReadRequest
Определения
MarkAsReadRequest.php:6
Bitrix\Bizproc\Integration\CommentListener
Определения
commentlistener.php:13
Bitrix\Bizproc\Integration\CommentListener\onCommentDelete
static onCommentDelete(Event $event)
Определения
commentlistener.php:48
Bitrix\Bizproc\Integration\CommentListener\onAfterCommentAdd
static onAfterCommentAdd(Event $event)
Определения
commentlistener.php:14
Bitrix\Bizproc\Integration\CommentListener\onListsProcessesCommentAdd
static onListsProcessesCommentAdd(string $workflowId, int $authorId, array $mentions)
Определения
commentlistener.php:75
Bitrix\Bizproc\Integration\CommentListener\onSocnetContentViewed
static onSocnetContentViewed(Event $event)
Определения
commentlistener.php:87
Bitrix\Bizproc\Integration\CommentListener\onListsProcessesCommentDelete
static onListsProcessesCommentDelete(string $workflowId, int $authorId, DateTime $created)
Определения
commentlistener.php:81
Bitrix\Main\Event
Определения
event.php:5
Bitrix\Main\Loader
Определения
loader.php:13
Bitrix\Main\Type\DateTime
Определения
datetime.php:9
CBPStateService\getWorkflowByIntegerId
static getWorkflowByIntegerId($integerId)
Определения
stateservice.php:440
array
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения
file_new.php:804
Bitrix\Bizproc\Api\Request\WorkflowCommentService
Определения
AddSystemCommentRequest.php:3
Bitrix\Bizproc\Integration
Определения
commentlistener.php:3
$service
$service
Определения
payment.php:18
$event
$event
Определения
prolog_after.php:141
$params
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
Определения
template.php:799
$matches
$matches
Определения
index.php:22
$fields
$fields
Определения
yandex_run.php:501
bitrix
modules
bizproc
lib
integration
commentlistener.php
Создано системой
1.14.0