- Модуль: blog
- Путь к файлу: ~/bitrix/modules/blog/lib/item/comment.php
- Класс: BitrixBlogItemComment
- Вызов: Comment::checkDuplicate
static function checkDuplicate(array $params = [], int &$duplicateCommentId = 0): bool
{
$message = (
isset($params['MESSAGE'])
&& trim((string)$params['MESSAGE']) !== ''
? trim((string)$params['MESSAGE'])
: ''
);
$blogId = (
isset($params['BLOG_ID'])
&& (int)$params['BLOG_ID'] > 0
? (int)$params['BLOG_ID']
: 0
);
$postId = (
isset($params['POST_ID'])
&& (int)$params['POST_ID'] > 0
? (int)$params['POST_ID']
: 0
);
$authorId = (
isset($params['AUTHOR_ID'])
&& (int)$params['AUTHOR_ID'] > 0
? (int)$params['AUTHOR_ID']
: 0
);
if (
$message === ''
|| $blogId <= 0
|| $postId <= 0
)
{
return false;
}
CTimeZone::Disable();
$res = CBlogComment::getList(
[ "ID" => "DESC" ],
[
"BLOG_ID" => $blogId,
"POST_ID" => $postId,
"AUTHOR_ID" => $authorId,
">DATE_CREATE" => ConvertTimeStamp(time() - 60*30, "FULL")
],
false,
[ "nTopCount" => 1 ],
[ 'ID', 'POST_TEXT' ]
);
CTimeZone::Enable();
if (
($duplicateComment = $res->fetch())
&& mb_strlen($message) > 10
&& md5((string)$duplicateComment['POST_TEXT']) === md5($message)
)
{
$duplicateCommentId = (int)$duplicateComment['ID'];
return false;
}
return true;
}