• Модуль: im
  • Путь к файлу: ~/bitrix/modules/im/lib/recent.php
  • Класс: BitrixImRecent
  • Вызов: Recent::fillFiles
static function fillFiles(array $rows): array
{
	if (!Settings::isBetaActivated())
	{
		foreach ($rows as $key => $row)
		{
			$rows[$key]['MESSAGE_FILE'] = (bool)($row['MESSAGE_FILE'] ?? false);
		}

		return $rows;
	}

	$fileIds = [];

	foreach ($rows as $row)
	{
		if (isset($row['MESSAGE_FILE']) && $row['MESSAGE_FILE'] > 0)
		{
			$fileIds[] = (int)$row['MESSAGE_FILE'];
		}
	}

	$files = FileCollection::initByDiskFilesIds($fileIds);

	foreach ($rows as $key => $row)
	{
		$fileId = $row['MESSAGE_FILE'] ?? null;
		$rows[$key]['MESSAGE_FILE'] = false;
		if (isset($fileId) && $fileId > 0)
		{
			$file = $files->getById((int)$fileId);
			if ($file !== null)
			{
				/** @var FileItem $file */
				$rows[$key]['MESSAGE_FILE'] = [
					'TYPE' => $file->getContentType(),
					'NAME' => $file->getDiskFile()->getName(),
				];
			}
		}
	}

	return $rows;
}