• Модуль: im
  • Путь к файлу: ~/bitrix/modules/im/classes/general/im_disk.php
  • Класс: CIMDisk
  • Вызов: CIMDisk::GetMaxFileId
static function GetMaxFileId($chatId)
{
	$maxId = 0;
	if (!self::Enabled())
	{
		return $maxId;
	}

	if ((int)$chatId <= 0)
	{
		return $maxId;
	}

	$folderModel = self::getFolderModel($chatId, false);
	if (!$folderModel)
	{
		return $maxId;
	}

	$result = BitrixDiskInternalsObjectTable::getList(array(
		'select' => array('MAX_ID'),
		'filter' => array(
			'=PARENT_ID' => $folderModel->getId(),
			'=TYPE' => BitrixDiskInternalsObjectTable::TYPE_FILE
		),
		'runtime' => array(
			'MAX_ID' => array(
				'data_type' => 'integer',
				'expression' => array('MAX(ID)')
			)
		)
	));
	if ($data = $result->fetch())
	{
		$maxId = $data['MAX_ID'];
	}

	return (int)$maxId;
}