Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
socnetgroup.php
1<?php
2
4
7
8class SocNetGroup extends Handler
9{
15 public static function onSocNetUserToGroupAdd(int $id, array $arFields): void
16 {
17 if (
18 empty($arFields['ROLE'])
19 || empty($arFields['GROUP_ID'])
20 || !Loader::includeModule("socialnetwork")
21 || self::isInvitee($arFields['ROLE'])
22 )
23 {
24 return;
25 }
26
27 self::sendMessageToQueue(self::WORK_GROUP_TYPE, $arFields['GROUP_ID']);
28 }
29
36 public static function onSocNetUserToGroupUpdate(int $id, array $arFields, array $oldUser2GroupArFields): void
37 {
38 if (
39 empty($oldUser2GroupArFields['GROUP_ID'])
40 || empty($oldUser2GroupArFields['ROLE'])
41 ||!Loader::includeModule("socialnetwork")
42 )
43 {
44 return;
45 }
46 $groupId = $oldUser2GroupArFields['GROUP_ID'];
47 $group = WorkgroupTable::getById($groupId)->fetch();
48
49 if (empty($group['ID']) || !isset($group['PROJECT']))
50 {
51 return;
52 }
53
54 if(!self::isInvitee($oldUser2GroupArFields['ROLE']) && !self::isScrum($group['PROJECT']))
55 {
56 return;
57 }
58
59 self::sendMessageToQueue(self::WORK_GROUP_TYPE, $group['ID']);
60 }
61
67 public static function onSocNetUserToGroupDelete(int $id, array $arFields): void
68 {
69 if (
70 empty($arFields['ROLE'])
71 || empty($arFields['GROUP_ID'])
72 ||!Loader::includeModule("socialnetwork")
73 || self::isInvitee($arFields['ROLE'])
74 )
75 {
76 return;
77 }
78
79 self::sendMessageToQueue(self::WORK_GROUP_TYPE, $arFields['GROUP_ID']);
80 }
81
87 public static function onSocNetGroupUpdate(int $id, array $arFields): void
88 {
89 if (!isset($arFields['SCRUM_MASTER_ID']) || !Loader::includeModule("socialnetwork"))
90 {
91 return;
92 }
93
94 self::sendMessageToQueue(self::WORK_GROUP_TYPE, $id);
95 }
96
101 private static function isInvitee(string $role): bool
102 {
103 return $role === \Bitrix\Socialnetwork\UserToGroupTable::ROLE_REQUEST;
104 }
105
110 private static function isScrum(string $projectField): bool
111 {
112 return $projectField === 'Y';
113 }
114}
static sendMessageToQueue(string $entityType, $entityId=null)
Definition handler.php:42
static onSocNetUserToGroupUpdate(int $id, array $arFields, array $oldUser2GroupArFields)
static onSocNetUserToGroupDelete(int $id, array $arFields)
static onSocNetGroupUpdate(int $id, array $arFields)
static onSocNetUserToGroupAdd(int $id, array $arFields)