1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
taskpreprocessor.php
См. документацию.
1<?php
2
3namespace Bitrix\Socialnetwork\Integration\Tasks\RecentActivity;
4
5use Bitrix\Main\Loader;
6use Bitrix\Main\Type\Collection;
7use Bitrix\Socialnetwork\Internals\EventService\EventDictionary;
8use Bitrix\Socialnetwork\Internals\EventService\Push\PushEventDictionary;
9use Bitrix\Socialnetwork\Space\List\RecentActivity\Dictionary;
10use Bitrix\Socialnetwork\Space\List\RecentActivity\Event\PreProcessor\AbstractPreProcessor;
11
13{
14 public function isAvailable(): bool
15 {
16 return Loader::includeModule('tasks');
17 }
18
19 protected function getTypeId(): string
20 {
21 return Dictionary::ENTITY_TYPE['task'];
22 }
23
24 public function process(): void
25 {
26 $taskId = (int)($this->event->getData()['ID'] ?? null);
27
28 if ($taskId <= 0)
29 {
30 return;
31 }
32
33 switch ($this->event->getType())
34 {
35 case EventDictionary::EVENT_SPACE_TASK_UPDATE:
36 $this->onTaskUpdate();
37 break;
38 default:
39 break;
40 }
41 }
42
43 private function onTaskUpdate(): void
44 {
45 $data = $this->event->getData();
46 $taskId = $data['ID'] ?? null;
47 $previousGroupId = $data['PREVIOUS_GROUP_ID'] ?? null;
48 $groupId = $data['GROUP_ID'] ?? null;
49 $oldMemberIds = $data['OLD_MEMBERS'] ?? [];
50 $newMemberIds = $data['NEW_MEMBERS'] ?? [];
51 Collection::normalizeArrayValuesByInt($oldMembers);
52 Collection::normalizeArrayValuesByInt($newMembers);
53
54 if ($taskId > 0 && $previousGroupId > 0 && $previousGroupId !== $groupId)
55 {
56 $this->processPreviousGroupId($taskId, $previousGroupId, $oldMemberIds);
57 }
58
59 $this->processRemovedFromTaskUsers($oldMemberIds, $newMemberIds);
60 }
61
62 private function processPreviousGroupId(int $taskId, int $previousGroupId, array $oldMemberIds): void
63 {
64 $this->service->deleteBySpaceId($previousGroupId, $this->getTypeId(), $taskId);
65
66 $this->pushEvent(
67 $oldMemberIds,
68 PushEventDictionary::EVENT_SPACE_RECENT_ACTIVITY_REMOVE_FROM_SPACE,
69 ['spaceIdsToReload' => [$previousGroupId]],
70 );
71 }
72
73 private function processRemovedFromTaskUsers(array $oldMemberIds, array $newMemberIds): void
74 {
75 if ($oldMemberIds === $newMemberIds)
76 {
77 return;
78 }
79
80 $lostAccessUsers = array_values(array_diff($oldMemberIds, $newMemberIds));
81
82 if (empty($lostAccessUsers))
83 {
84 return;
85 }
86
88 EventDictionary::EVENT_SPACE_TASK_REMOVE_USERS,
89 [
90 'TASK_ID' => $data['ID'] ?? null,
91 'RECEPIENTS' => $lostAccessUsers,
92 ]
93 );
94 }
95}
static addEvent(string $type, array $data)
Определения service.php:45
pushEvent(array $recipients, string $eventType, array $params)
Определения AbstractPreProcessor.php:22
$data['IS_AVAILABLE']
Определения .description.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