• Модуль: rpa
  • Путь к файлу: ~/bitrix/modules/rpa/lib/controller/comment.php
  • Класс: BitrixRpaControllerComment
  • Вызов: Comment::processFiles
protected function processFiles(array $fields): array
{
	$files = is_array($fields['files']) ? $fields['files'] : [];
	$uiComment = static::getUiComment();
	$userField = $uiComment->getFileUserFields();
	if (!$userField)
	{
		return [];
	}
	$userId = Driver::getInstance()->getUserId();
	$storage = BitrixDiskDriver::getInstance()->addUserStorage($userId);
	if (!$storage)
	{
		return [];
	}
	$securityContext = $storage->getSecurityContext($userId);
	foreach ($files as &$file)
	{
		if ($this->getScope() === self::SCOPE_REST)
		{
			if (
				isset($file['id'])
				&& $file['id'] > 0
				&& $securityContext->canRead((int)$file['id'])
			)
			{
				$file = (int)$file['id'];
			}
			else
			{
				$file = $this->uploadFile($file);
				if($file > 0)
				{
					$file = 'n' . $file;
				}
			}
		}
		else
		{
			$fileId = $file;
			if (mb_substr($fileId, 0, 1) === 'n')
			{
				$fileId = (int)mb_substr($fileId, 1);
			}
			if (!$securityContext->canRead($fileId))
			{
				$file = null;
			}
		}
	}

	return $files;
}