- Модуль: tasks
- Путь к файлу: ~/bitrix/modules/tasks/classes/general/tasktags.php
- Класс: CTaskTags
- Вызов: CTaskTags::CheckFields
function CheckFields(&$arFields, /** @noinspection PhpUnusedParameterInspection */ $ID = false,
$effectiveUserId = null)
{
/** @global CMain $APPLICATION */
global $APPLICATION;
$arMsg = [];
if (!is_set($arFields, "TASK_ID"))
{
$arMsg[] = ["text" => GetMessage("TASKS_BAD_TASK_ID"), "id" => "ERROR_TASKS_BAD_TASK_ID"];
}
else
{
$arParams = [];
if ($effectiveUserId !== null)
{
$arParams['USER_ID'] = $effectiveUserId;
}
$r = CTasks::GetByID($arFields["TASK_ID"], true, $arParams);
if (!$r->Fetch())
{
$arMsg[] = ["text" => GetMessage("TASKS_BAD_TASK_ID_EX"), "id" => "ERROR_TASKS_BAD_TASK_ID_EX"];
}
}
if ($effectiveUserId !== null && !isset($arFields['USER_ID']))
{
$arFields['USER_ID'] = $effectiveUserId;
}
if (!is_set($arFields, "USER_ID"))
{
$arMsg[] = ["text" => GetMessage("TASKS_BAD_USER_ID"), "id" => "ERROR_TASKS_BAD_USER_ID"];
}
else
{
$r = CUser::GetByID($arFields["USER_ID"]);
if (!$r->Fetch())
{
$arMsg[] = ["text" => GetMessage("TASKS_BAD_USER_ID_EX"), "id" => "ERROR_TASKS_BAD_USER_ID_EX"];
}
}
if (!is_set($arFields, "NAME") || trim($arFields["NAME"]) == '')
{
$arMsg[] = ["text" => GetMessage("TASKS_BAD_NAME"), "id" => "ERROR_BAD_TASKS_NAME"];
}
if (!isset($arFields['GROUP_ID']))
{
$arFields['GROUP_ID'] = 0;
}
if (!empty($arMsg))
{
$e = new CAdminException($arMsg);
$APPLICATION->ThrowException($e);
return false;
}
return true;
}