- Модуль: forum
- Путь к файлу: ~/bitrix/modules/forum/lib/topic.php
- Класс: BitrixForumTopic
- Вызов: Topic::onBeforeUpdate
static function onBeforeUpdate(MainORMEvent $event)
{
$result = new MainORMEventResult();
/** @var array $data */
$data = $event->getParameter("fields");
$id = $event->getParameter("id");
$id = $id["ID"];
$topic = TopicTable::getById($id)->fetch();
if (MainConfigOption::get("forum", "FILTER", "Y") == "Y")
{
$filteredFields = self::getFilteredFields();
if (!empty(array_intersect($filteredFields, array_keys($data))))
{
$res = [];
foreach ($filteredFields as $key)
{
$res[$key] = $val = array_key_exists($key, $data) ? $data[$key] : $topic[$key];
if (!empty($val))
{
$res[$key] = CFilterUnquotableWords::Filter($val);
if (empty($res[$key]))
{
$res[$key] = "*";
}
}
}
$data["HTML"] = serialize($res);
}
}
if (array_key_exists("TITLE_SEO", $data) || array_key_exists("TITLE", $data))
{
$data["TITLE_SEO"] = trim($data["TITLE_SEO"], " -");
if ($data["TITLE_SEO"] == '')
{
$title = array_key_exists("TITLE", $data) ? $data["TITLE"] : $topic["TITLE"];
$data["TITLE_SEO"] = CUtil::translit($title, LANGUAGE_ID, array("max_len"=>255, "safe_chars"=>".", "replace_space" => '-'));
}
}
if ($data != $event->getParameter("fields"))
{
$result->modifyFields($data);
}
return self::modifyData($event, $result);
}