- Модуль: socialnetwork
- Путь к файлу: ~/bitrix/modules/socialnetwork/classes/general/event_user_view.php
- Класс: CAllSocNetEventUserView
- Вызов: CAllSocNetEventUserView::CheckFields
static function CheckFields($ACTION, &$arFields)
{
global $DB;
$arSocNetAllowedSubscribeEntityTypes = CSocNetAllowed::GetAllowedEntityTypes();
if (!array_key_exists("ENTITY_TYPE", $arFields))
{
$GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_EUV_EMPTY_ENTITY_TYPE"), "ERROR_EMPTY_ENTITY_TYPE");
return false;
}
if (!in_array($arFields["ENTITY_TYPE"], CSocNetAllowed::GetAllowedEntityTypes()))
{
$GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_EUV_INCORRECT_ENTITY_TYPE"), "ERROR_INCORRECT_ENTITY_TYPE");
return false;
}
if (!array_key_exists("ENTITY_ID", $arFields))
{
$GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_EUV_EMPTY_ENTITY_ID"), "ERROR_EMPTY_ENTITY_ID");
return false;
}
// check primary key
if ($ACTION == "ADD")
{
$dbResult = CSocNetEventUserView::GetList(
Array("ENTITY_ID" => "DESC"),
Array(
"ENTITY_TYPE" => $arFields["ENTITY_TYPE"],
"ENTITY_ID" => intval($arFields["ENTITY_ID"]),
"EVENT_ID" => (array_key_exists("EVENT_ID", $arFields) ? $arFields["EVENT_ID"] : ""),
"USER_ID" => (array_key_exists("USER_ID", $arFields) ? intval($arFields["USER_ID"]) : 0),
"USER_IM_ID" => (array_key_exists("USER_IM_ID", $arFields) ? intval($arFields["USER_IM_ID"]) : 0)
)
);
if ($arRes = $dbResult->Fetch())
{
$GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_EUV_RECORD_EXISTS"), "ERROR_RECORD_EXISTS");
return false;
}
}
return True;
}