• Модуль: calendar
  • Путь к файлу: ~/bitrix/modules/calendar/classes/general/calendar.php
  • Класс: CCalendar
  • Вызов: CCalendar::fetchIconsForSectionList
static function fetchIconsForSectionList($sectionList)
{
	$SECTION_IMG_SIZE = 28;
	$userIdList = [];
	$groupIdList = [];
	$userIndexList = [];
	$groupListIndex = [];

	foreach ($sectionList as $section)
	{
		$ownerId = (int)$section['OWNER_ID'];
		if (
			$section['CAL_TYPE'] === 'user'
			&& !in_array($ownerId, $userIdList)
		)
		{
			$userIdList[] = $ownerId;
		}
		elseif ($section['CAL_TYPE'] === 'group'
			&& !in_array($ownerId, $groupIdList))
		{
			$groupIdList[] = $ownerId;
		}
	}

	if (!empty($userIdList))
	{
		$userIndexList = CCalendarEvent::getUsersDetails($userIdList);
	}

	if (!empty($groupIdList) && Loader::includeModule("socialnetwork"))
	{
		$res = BitrixSocialnetworkWorkgroupTable::getList([
			'filter' => [
				'=ACTIVE' => 'Y',
				'@ID' => $groupIdList,
			],
			'select' => ['ID', 'IMAGE_ID'],
		]);
		while ($workgroupFields = $res->fetch())
		{
			if (!empty($workgroupFields["IMAGE_ID"]))
			{
				$arFileTmp = CFile::ResizeImageGet(
					$workgroupFields["IMAGE_ID"],
					['width' => $SECTION_IMG_SIZE, 'height' => $SECTION_IMG_SIZE],
					BX_RESIZE_IMAGE_EXACT,
					false,
					false,
					true
				);
				$workgroupFields['IMAGE'] = $arFileTmp['src'];
			}
			$groupListIndex[$workgroupFields['ID']] = $workgroupFields;
		}
	}

	foreach ($sectionList as $k => $section)
	{
		$ownerId = (int)$section['OWNER_ID'];
		if ($section['CAL_TYPE'] === 'user'
			&& isset($userIndexList[$ownerId])
			&& !empty($userIndexList[$ownerId]['AVATAR'])
			&& $userIndexList[$ownerId]['AVATAR'] !== '/bitrix/images/1.gif'
		)
		{
			$sectionList[$k]['IMAGE'] = $userIndexList[$ownerId]['AVATAR'];
		}
		elseif (
			$section['CAL_TYPE'] === 'group'
			&& isset($groupListIndex[$ownerId])
			&& !empty($groupListIndex[$ownerId]['IMAGE'])
		)
		{
			$sectionList[$k]['IMAGE'] = $groupListIndex[$ownerId]['IMAGE'];
		}

		$pathesForSite = self::getPathes(SITE_ID);
		if ($section['CAL_TYPE'] === 'user')
		{
			$sectionList[$k]['LINK'] = str_replace(
				['#user_id#', '#USER_ID#'],
				$section['OWNER_ID'],
				$pathesForSite['path_to_user_calendar']
			);
		}
		else if($section['CAL_TYPE'] === 'group')
		{
			$sectionList[$k]['LINK'] = str_replace(
				['#group_id#', '#GROUP_ID#'],
				$section['OWNER_ID'],
				$pathesForSite['path_to_user_calendar']
			);
		}
		else
		{
			$path = $pathesForSite['path_to_type_'.$section['CAL_TYPE']];
			$sectionList[$k]['LINK'] = $path;
		}
	}
	return $sectionList;
}