1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
commentlistener.php
См. документацию.
1<?php
2
4
11
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
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
72 $service->unRegisterComment(new CommentRequest($workflowId, $authorId, $created));
73 }
74
75 public static function onListsProcessesCommentAdd(string $workflowId, int $authorId, array $mentions): void
76 {
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 {
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
115 $service->markAsRead(new MarkAsReadRequest($workflowId, (int)$params['userId']));
116 }
117}
static onCommentDelete(Event $event)
Определения commentlistener.php:48
static onAfterCommentAdd(Event $event)
Определения commentlistener.php:14
static onListsProcessesCommentAdd(string $workflowId, int $authorId, array $mentions)
Определения commentlistener.php:75
static onSocnetContentViewed(Event $event)
Определения commentlistener.php:87
static onListsProcessesCommentDelete(string $workflowId, int $authorId, DateTime $created)
Определения commentlistener.php:81
Определения event.php:5
Определения loader.php:13
static getWorkflowByIntegerId($integerId)
Определения stateservice.php:440
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$service
Определения payment.php:18
$event
Определения prolog_after.php:141
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
Определения template.php:799
$matches
Определения index.php:22
$fields
Определения yandex_run.php:501