26 $this->userId = $userId;
33 public static function isEnabled(
int $userId = 0): bool
36 if ($isLegacyEnabled ===
'null')
44 && \CUserOptions::GetOption(
65 if ($event->
getType() === EventDictionary::EVENT_SPACE_LIVEFEED_COUNTER_UPD)
77 case EventDictionary::EVENT_SPACE_LIVEFEED_READ_ALL:
78 $this->readAll($event);
80 case EventDictionary::EVENT_SPACE_LIVEFEED_POST_VIEW:
81 $this->viewed($event);
84 $this->recount($event);
96 $type = $queueItem[
'TYPE'] ??
null;
97 $items = $queueItem[
'SONET_LOGS'] ??
null;
98 if (!$type || !is_array($items))
108 $userProcessor->recount($type, $items);
120 if (!$this->isSameValueCached($value))
133 private function recount(
Event $event): void
135 $sonetLogId = $event->
getData()[
'SONET_LOG_ID'] ??
null;
146 private function viewed(
Event $event): void
148 $data = $event->getData();
149 if (!isset($data[
'ENTITY_ID'], $data[
'TYPE_ID'], $data[
'USER_ID']))
154 $contentViewed = UserContentViewTable::query()
155 ->where(
'USER_ID', $data[
'USER_ID'])
156 ->where(
'RATING_TYPE_ID', $data[
'TYPE_ID'])
157 ->where(
'RATING_ENTITY_ID', $data[
'ENTITY_ID'])
163 $this->recount($event);
174 self::reset($this->userId);
179 $this->saveFlag($this->userId);
182 private function readAll(
Event $event): void
189 $groupId = (int)($event->
getData()[
'GROUP_ID'] ?? 0);
193 private function isSameValueCached(
int $value): bool
195 global $CACHE_MANAGER;
197 $cache = $CACHE_MANAGER->Get(
'user_counter' . $this->userId);
203 foreach ($cache as $item)
207 && $item[
'SITE_ID'] ===
'**'
208 && (
int)$item[
'CNT'] === $value