18 $workgroupsPushList = [];
20 $workgroupEventsList = [
33 $changedEventTypes = [
37 $deletedEventTypes = [
40 $userChangedEventTypes = [
45 $userAddedAndDeletedEventTypes = [
56 foreach ($events as $event)
59 $event->collectNewData();
60 $eventType = $event->getType();
61 $groupId = $event->getGroupId();
63 if (!in_array($eventType, $workgroupEventsList,
true))
68 $this->groupOldFields[$groupId] = $event->getOldFields();
69 $this->groupNewFields[$groupId] = $event->getNewFields();
71 if (in_array($eventType, $addedEventTypes,
true))
75 elseif (in_array($eventType, $changedEventTypes,
true))
77 $changed[] = $groupId;
79 elseif (in_array($eventType, $deletedEventTypes,
true))
81 $deleted[] = $groupId;
83 elseif (in_array($eventType, $userChangedEventTypes,
true))
85 $userChanged[] = $groupId;
89 $added = array_diff($added, $deleted);
90 $changed = array_diff($changed, $added, $deleted);
91 $changed = $this->clearNotRealChanges($changed);
92 $userChanged = array_diff($userChanged, $added, $changed, $deleted);
94 $notVisibleGroupsUsers = $this->getNotVisibleGroupsUsers([
101 foreach ($events as $event)
104 $eventType = $event->getType();
105 $groupId = $event->getGroupId();
106 $userId = $event->getUserId();
109 in_array($eventType, $userAddedAndDeletedEventTypes,
true)
110 && in_array($groupId, $userChanged,
true)
113 (
new WorkgroupSender())->sendForUserAddedAndRemoved($event, $notVisibleGroupsUsers);
114 unset($userChanged[$groupId]);
119 in_array($eventType, $addedEventTypes,
true)
120 && !in_array($groupId, $added,
true)
123 in_array($eventType, $changedEventTypes,
true)
124 && !in_array($groupId, $changed,
true)
127 in_array($eventType, $userChangedEventTypes,
true)
128 && !in_array($groupId, $userChanged,
true)
135 $workgroupsPushList[] = [
136 'EVENT' => $eventType,
137 'GROUP_ID' => $groupId,
138 'USER_ID' => $userId,
142 if (!empty($workgroupsPushList))
144 (
new WorkgroupSender())->send($workgroupsPushList, $notVisibleGroupsUsers);
210 [ $added, $changed, $deleted, $userChanged ] = $groups;