- Модуль: forum
- Путь к файлу: ~/bitrix/modules/forum/classes/general/points.php
- Класс: CAllForumPoints2Post
- Вызов: CAllForumPoints2Post::CheckFields
static function CheckFields($ACTION, &$arFields, $ID = 0)
{
$aMsg = array();
if (is_set($arFields, "MIN_NUM_POSTS") || $ACTION=="ADD")
{
$arFields["MIN_NUM_POSTS"] = trim($arFields["MIN_NUM_POSTS"]);
if (empty($arFields["MIN_NUM_POSTS"]))
{
$aMsg[] = array(
"id"=>'POINTS2POST[MIN_NUM_POSTS]',
"text" => GetMessage("FORUM_PE_ERROR_MIN_NUM_POSTS_EMPTY"));
}
elseif (mb_strlen($arFields["MIN_NUM_POSTS"]) > 18 || preg_match("/[^0-9]/", $arFields["MIN_NUM_POSTS"]))
{
$aMsg[] = array(
"id"=>'POINTS2POST[MIN_NUM_POSTS]',
"text" => GetMessage("FORUM_PE_ERROR_MIN_NUM_POSTS_BAD"));
}
else
{
$arFields["MIN_NUM_POSTS"] = intval($arFields["MIN_NUM_POSTS"]);
$db_res = CForumPoints2Post::GetList(array(), array("MIN_NUM_POSTS" => $arFields["MIN_NUM_POSTS"]));
if ($db_res && $res = $db_res->GetNext())
{
if ($ACTION=="ADD" || $ID == 0 || $ID != $res["ID"])
{
$aMsg[] = array(
"id"=>'POINTS2POST[MIN_NUM_POSTS]',
"text" => GetMessage("FORUM_PE_ERROR_MIN_NUM_POSTS_EXIST"));
}
}
}
}
if ((is_set($arFields, "POINTS_PER_POST") || $ACTION=="ADD") && DoubleVal($arFields["POINTS_PER_POST"])<=0)
$arFields["POINTS_PER_POST"] = 0;
else {
$arFields["POINTS_PER_POST"] = round(doubleval($arFields["POINTS_PER_POST"]), 4);
if (mb_strlen(round($arFields["POINTS_PER_POST"], 0)) > 14 || mb_strlen(mb_strstr($arFields["POINTS_PER_POST"], ".")) > 5 ||
preg_match("/[^0-9.]/", $arFields["POINTS_PER_POST"]))
$aMsg[] = array(
"id" => 'POINTS2POST[POINTS_PER_POST]',
"text" => GetMessage("FORUM_PE_ERROR_MIN_POINTS_BAD"));
}
if(!empty($aMsg))
{
$e = new CAdminException(array_reverse($aMsg));
$GLOBALS["APPLICATION"]->ThrowException($e);
return false;
}
return true;
return True;
}