• Модуль: socialnetwork
  • Путь к файлу: ~/bitrix/modules/socialnetwork/lib/component/workgrouplist/counter.php
  • Класс: BitrixSocialnetworkComponentWorkgroupListCounter
  • Вызов: Counter::fillTasksCounters
static function fillTasksCounters(array $params = []): array
{
	$result = [];

	$groupIdList = $params['groupIdList'] ?? [];
	if (empty($groupIdList))
	{
		return $result;
	}

	$currentUserId = static::getCurrentUserId();
	if ($currentUserId <= 0)
	{
		return $result;
	}

	$counterData = $params['counterData'] ?? [];

	$scrumIdList = $params['scrumIdList'] ?? [];

	$groupUrlTemplate = ($params['groupUrl'] ?? HelperPath::get('group_path_template'));

	$colorMap = [
		HelperUIGridCounterStyle::STYLE_GRAY => GridCounterColor::GRAY,
		HelperUIGridCounterStyle::STYLE_GREEN => GridCounterColor::SUCCESS,
		HelperUIGridCounterStyle::STYLE_RED => GridCounterColor::DANGER,
	];

	$sliderOptionsData = [
		'contentClassName' => 'bitrix24-group-slider-content',
		'loader' => 'intranet:slider-tasklist',
		'cacheable' => false,
		'customLeftBoundary' => 0,
		'newWindowLabel' => true,
		'copyLinkLabel' => true,
	];

	foreach ($groupIdList as $groupId)
	{
		$groupCounterData = ($counterData[$groupId] ?? []);

		$groupUrl = str_replace([ '#id#', '#ID#', '#GROUP_ID#', '#group_id#' ], $groupId, $groupUrlTemplate);

		if (in_array($groupId, $scrumIdList, true))
		{
			$sliderOptionsData['loader'] = 'intranet:scrum';
		}

		$sliderOptions = Json::encode($sliderOptionsData);

		$result[$groupId] = [
			'ACTIVITY_DATE' => [
				'type' => GridCounterType::LEFT_ALIGNED,
				'color' => $colorMap[$groupCounterData['all']['COLOR']],
				'value' => $groupCounterData['all']['VALUE'],
				'events' => [
					'click' => "BX.SidePanel.Instance.open.bind(BX.SidePanel.Instance, '{$groupUrl}', {$sliderOptions})",
				],
				'class' => 'sonet-ui-grid-counter',
			],
		];
	}

	return $result;
}