• Модуль: forum
  • Путь к файлу: ~/bitrix/modules/forum/classes/general/points.php
  • Класс: CAllForumPoints
  • Вызов: CAllForumPoints::CheckFields
static function CheckFields($ACTION, &$arFields, $ID = 0)
{
	$aMsg = array();

	if (is_set($arFields, "LANG") || $ACTION=="ADD")
	{
		if (!is_array($arFields["LANG"]))
			$arFields["LANG"] = array();

		$db_lang = CLangAdmin::GetList();
		while ($arLang = $db_lang->Fetch())
		{
			$bFound = False;
			foreach ($arFields["LANG"] as $key => $res)
			{
				if (is_array($res) && $res["LID"] == $arLang["LID"])
				{
					$arFields["LANG"][$key]["NAME"] = trim($res["NAME"]);
					if ($arFields["LANG"][$key]["NAME"] <> '')
					{
						$bFound = True;
						break;
					}
				}
			}
			if (!$bFound)
			{
				$aMsg[] = array(
					"id"=>'POINTS[NAME][LID]['.$arLang["LID"].']',
					"text" => str_replace("#LANG#", $arLang["NAME"]." [".$arLang["LID"]."]", GetMessage("FORUM_PE_ERROR_NONAME")));
			}
		}
	}

	if (is_set($arFields, "MIN_POINTS") || $ACTION=="ADD")
	{
		$arFields["MIN_POINTS"] = trim($arFields["MIN_POINTS"]);
		if ($arFields["MIN_POINTS"] == '')
		{
			$aMsg[] = array(
				"id"=>'POINTS[MIN_POINTS]',
				"text" => GetMessage("FORUM_PE_ERROR_MIN_POINTS_EMPTY"));
		}
		elseif (preg_match("/[^0-9]/", $arFields["MIN_POINTS"]))
		{
			$aMsg[] = array(
				"id"=>'POINTS[MIN_POINTS]',
				"text" => GetMessage("FORUM_PE_ERROR_MIN_POINTS_BAD"));
		}
		else
		{
			$arFields["MIN_POINTS"] = intval($arFields["MIN_POINTS"]);
			$db_res = CForumPoints::GetList(array(), array("MIN_POINTS" => $arFields["MIN_POINTS"]));
			if ($db_res && $res = $db_res->GetNext())
			{
				if ($ACTION=="ADD" || $ID == 0 || $ID != $res["ID"])
				{
					$aMsg[] = array(
						"id"=>'POINTS[MIN_POINTS]',
						"text" => GetMessage("FORUM_PE_ERROR_MIN_POINTS_EXIST"));
				}
			}
		}
	}
	$arFields["VOTES"] = intval($arFields["VOTES"]);

	if(!empty($aMsg))
	{
		$e = new CAdminException(array_reverse($aMsg));
		$GLOBALS["APPLICATION"]->ThrowException($e);
		return false;
	}

	return true;
}