- Модуль: forum
- Путь к файлу: ~/bitrix/modules/forum/lib/comments/comment.php
- Класс: BitrixForumCommentsComment
- Вызов: Comment::delete
public function delete()
{
if ($this->message === null)
{
$this->errorCollection->addOne(new Error(Loc::getMessage("FORUM_CM_ERR_COMMENT_IS_LOST2"), self::ERROR_MESSAGE_IS_NULL));
}
else
{
$run = true;
$fields = array(
$this->getEntity()->getType(),
$this->getEntity()->getId(),
array(
"TOPIC_ID" => $this->topic["ID"],
"MESSAGE_ID" => $this->message["ID"],
"MESSAGE" => $this->getComment(),
"ACTION" => "DEL"
));
/***************** Events OnBeforeCommentDelete ******************/
$event = new Event("forum", "OnBeforeCommentDelete", $fields);
$event->send($this);
if($event->getResults())
{
foreach($event->getResults() as $eventResult)
{
if($eventResult->getType() != EventResult::SUCCESS)
{
$run = false;
break;
}
}
}
/***************** /Events *****************************************/
if ($run && CForumMessage::delete($this->message["ID"]))
{
CForumEventLog::log("message", "delete", $this->message["ID"], serialize($this->message + array("TITLE" => $this->topic["TITLE"])));
/***************** Events OnCommentDelete ************************/
$event = new Event("forum", "OnCommentDelete", $fields);
$event->send();
/***************** Events OnAfterCommentUpdate *********************/
$event = new Event("forum", "OnAfterCommentUpdate", $fields); // It is not a mistake
$event->send();
/***************** /Events *****************************************/
}
else
{
$text = Loc::getMessage("FORUM_CM_ERR_DELETE");
if (($ex = $this->getApplication()->getException()) && $ex)
$text = $ex->getString();
$this->errorCollection->addOne(new Error($text, self::ERROR_PARAMS_MESSAGE));
}
}
return true;
}