• Модуль: tasks
  • Путь к файлу: ~/bitrix/modules/tasks/classes/general/taskfiles.php
  • Класс: CTaskFiles
  • Вызов: CTaskFiles::CheckFieldsMultiple
static function CheckFieldsMultiple($taskId, $arFilesIds)
{
	/**
	 * @global CMain $APPLICATION
	 */
	global $APPLICATION;

	$arMsg = array();

	if ( ! ($taskId > 0) )
	{
		$arMsg[] = array("text" => GetMessage("TASKS_BAD_TASK_ID"), "id" => "ERROR_TASKS_BAD_TASK_ID");
	}
	else
	{
		/** @noinspection PhpDeprecationInspection */
		$r = CTasks::GetByID($taskId, false);
		if (!$r->Fetch())
		{
			$arMsg[] = array("text" => GetMessage("TASKS_BAD_TASK_ID_EX"), "id" => "ERROR_TASKS_BAD_TASK_ID_EX");
		}
	}


	if ( ! is_array($arFilesIds) )
	{
		$arMsg[] = array("text" => GetMessage("TASKS_BAD_FILE_ID"), "id" => "ERROR_TASKS_BAD_FILE_ID");
	}
	elseif ( ! empty($arFilesIds) )
	{
		$arFilesIds = array_unique($arFilesIds);
		$arNotFetchedFilesIds = $arFilesIds;

		$r = CFile::GetList(array(), array('@ID' => implode(',', $arFilesIds)));

		while ($ar = $r->Fetch())
		{
			$fileId = (int) $ar['ID'];

			$key = array_search($fileId, $arFilesIds);

			if ($key !== false)
				unset ($arNotFetchedFilesIds[$key]);
		}

		if (count($arNotFetchedFilesIds))
		{
			$arMsg[] = array("text" => GetMessage("TASKS_BAD_FILE_ID_EX"), "id" => "ERROR_TASKS_BAD_FILE_ID_EX");
		}
	}

	if (!empty($arMsg))
	{
		$e = new CAdminException($arMsg);
		$APPLICATION->ThrowException($e);
		return false;
	}

	return true;
}