3namespace Bitrix\Socialnetwork\Internals\Space;
5use Bitrix\Socialnetwork\Integration\Tasks;
6use Bitrix\Socialnetwork\Integration\Calendar;
7use Bitrix\Socialnetwork\Integration\SocialNetwork\WorkGroup;
8use Bitrix\Socialnetwork\Integration\SocialNetwork\LiveFeed;
9use Bitrix\Socialnetwork\Internals\Space\Counter\Cache;
10use Bitrix\Socialnetwork\Internals\Space\Counter\Dictionary;
11use Bitrix\Socialnetwork\Internals\Space\Counter\ProviderCollection;
15 private static array $instance = [];
20 if (!array_key_exists(
$userId, self::$instance))
22 self::$instance[
$userId] =
new self(
33 return self::$instance[
$userId];
43 public function getTotal(
int $spaceId = 0): int
47 foreach ($this->providerCollection as
$provider)
71 foreach ($this->providerCollection as
$provider)
73 $value +=
$provider->getValue($spaceId, $metrics);
85 $availableMetrics = [];
87 foreach ($this->providerCollection as
$provider)
89 $availableMetrics = array_merge($availableMetrics,
$provider->getAvailableMetrics());
92 return $availableMetrics;
109 $spacesTotal = $this->getMemberSpacesTotal();
110 $invitationsTotal = $this->getInvitationsTotal();
111 $total += $invitationsTotal;
112 $total += $spacesTotal[
'total'];
117 'spaces' => $spacesTotal[
'spaces'],
118 'invitations' => $invitationsTotal,
124 $this->cache =
new Cache($this->userId);
125 $this->updateLeftMenuCounter();
131 $value = $memberCounters[
'total'];
132 $code = Dictionary::LEFT_MENU_SPACES;
134 if (!$this->cache->isSameLeftMenuTotal(
$code, $value))
147 private function getMemberSpacesTotal():
array
152 $userSpaces = $this->cache->getUserSpaceIds();
154 foreach ($userSpaces as $spaceId)
156 $spaceTotal = $this->getTotal($spaceId);
158 if ($spaceTotal === 0)
163 $total += $spaceTotal;
167 'total' => $spaceTotal,
170 foreach ($this->getAvailableMetrics() as $metric)
172 $spaceCounters[
'metrics'][$metric] = $this->getValue($spaceId, [$metric]);
175 $spaces[] = $spaceCounters;
184 private function getInvitationsTotal(): int
188 $invitations = $this->cache->getUserInvitationIds();
190 foreach ($invitations as $invitationId)
192 $total += $this->getValue($invitationId, [Dictionary::COUNTERS_WORKGROUP_REQUEST_OUT]);
if(!Loader::includeModule('messageservice')) $provider
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
getValue(int $spaceId=0, array $metrics=[])
static getInstance(int $userId)
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
if(!is_null($config))($config as $configItem)(! $configItem->isVisible()) $code