483 $forumId = (int) $this->getId();
487 (SELECT ID, AUTHOR_ID, AUTHOR_NAME, POST_DATE, FORUM_ID FROM b_forum_message WHERE FORUM_ID={$forumId} AND APPROVED=
'Y' ORDER BY ID DESC LIMIT 1) AS last_message,
488 (SELECT ID, AUTHOR_ID, AUTHOR_NAME, POST_DATE, FORUM_ID FROM b_forum_message WHERE FORUM_ID={$forumId} ORDER BY ID DESC LIMIT 1) AS abs_last_message
490 f.TOPICS = (SELECT COUNT(ID) FROM b_forum_topic WHERE FORUM_ID={$forumId} AND APPROVED=
'Y' GROUP BY FORUM_ID),
491 f.POSTS = (SELECT COUNT(ID) FROM b_forum_message WHERE FORUM_ID={$forumId} AND APPROVED=
'Y' GROUP BY FORUM_ID),
492 f.POSTS_UNAPPROVED = (SELECT COUNT(ID) FROM b_forum_message WHERE FORUM_ID={$forumId} AND APPROVED !=
'Y' GROUP BY FORUM_ID),
493 f.LAST_MESSAGE_ID = last_message.ID,
494 f.LAST_POSTER_ID = last_message.AUTHOR_ID,
495 f.LAST_POSTER_NAME = last_message.AUTHOR_NAME,
496 f.LAST_POST_DATE = last_message.POST_DATE,
497 f.ABS_LAST_MESSAGE_ID = abs_last_message.ID,
498 f.ABS_LAST_POSTER_ID = abs_last_message.AUTHOR_ID,
499 f.ABS_LAST_POSTER_NAME = abs_last_message.AUTHOR_NAME,
500 f.ABS_LAST_POST_DATE = abs_last_message.POST_DATE
501WHERE f.ID = {$forumId} AND last_message.FORUM_ID = f.ID AND abs_last_message.FORUM_ID = f.ID
503 Main\Application::getConnection()->queryExecute($sql);
509 "ABS_LAST_POSTER_ID" => $message[
"AUTHOR_ID"],
510 "ABS_LAST_POSTER_NAME" => $message[
"AUTHOR_NAME"],
511 "ABS_LAST_POST_DATE" => $message[
"POST_DATE"],
512 "ABS_LAST_MESSAGE_ID" => $message[
"ID"]
514 if ($message[
"APPROVED"] ==
"Y")
517 "LAST_POSTER_ID" => $message[
"AUTHOR_ID"],
518 "LAST_POSTER_NAME" => $message[
"AUTHOR_NAME"],
519 "LAST_POST_DATE" => $message[
"POST_DATE"],
520 "LAST_MESSAGE_ID" => $message[
"ID"]
522 $fields[
"POSTS"] = new \Bitrix\Main\DB\SqlExpression(
'?# + 1',
"POSTS");
523 if ($message[
"NEW_TOPIC"] ==
"Y")
525 $fields[
"TOPICS"] = new \Bitrix\Main\DB\SqlExpression(
'?# + 1',
"TOPICS");
530 $fields[
"POSTS_UNAPPROVED"] = new \Bitrix\Main\DB\SqlExpression(
'?# + 1',
"POSTS_UNAPPROVED");
535 if (\CModule::IncludeModule(
"statistic"))
537 $F_EVENT1 = $this->data[
"EVENT1"];
538 $F_EVENT2 = $this->data[
"EVENT2"];
539 $F_EVENT3 = $this->data[
"EVENT3"];
540 if (empty($F_EVENT3))
542 $F_EVENT3 = $_SERVER[
"HTTP_REFERER"] ??
'';
544 \CStatistics::Set_Event($F_EVENT1, $F_EVENT2, $F_EVENT3);
550 $forumId = (int) $this->getId();
551 if ($message[
'APPROVED'] ==
'Y')
553 $subQueryTopics =
"";
554 if ($message[
'NEW_TOPIC'] ===
'Y')
556 $subQueryTopics = <<<SQL
557 f.TOPICS = (SELECT COUNT(ID) FROM b_forum_topic WHERE FORUM_ID={$forumId} AND APPROVED=
'Y' GROUP BY FORUM_ID),
563 (SELECT ID, AUTHOR_ID, AUTHOR_NAME, POST_DATE, FORUM_ID FROM b_forum_message WHERE FORUM_ID={$forumId} AND APPROVED=
'Y' ORDER BY ID DESC LIMIT 1) AS last_message,
564 (SELECT ID, AUTHOR_ID, AUTHOR_NAME, POST_DATE, FORUM_ID FROM b_forum_message WHERE FORUM_ID={$forumId} ORDER BY ID DESC LIMIT 1) AS abs_last_message
567 f.POSTS = f.POSTS - 1,
568 f.LAST_MESSAGE_ID = last_message.ID,
569 f.LAST_POSTER_ID = last_message.AUTHOR_ID,
570 f.LAST_POSTER_NAME = last_message.AUTHOR_NAME,
571 f.LAST_POST_DATE = last_message.POST_DATE,
572 f.ABS_LAST_MESSAGE_ID = abs_last_message.ID,
573 f.ABS_LAST_POSTER_ID = abs_last_message.AUTHOR_ID,
574 f.ABS_LAST_POSTER_NAME = abs_last_message.AUTHOR_NAME,
575 f.ABS_LAST_POST_DATE = abs_last_message.POST_DATE,
577WHERE f.ID = {$forumId} AND last_message.FORUM_ID = f.ID AND abs_last_message.FORUM_ID = f.ID
585 (SELECT ID, AUTHOR_ID, AUTHOR_NAME, POST_DATE, FORUM_ID FROM b_forum_message WHERE FORUM_ID={$forumId} ORDER BY ID DESC LIMIT 1) AS abs_last_message
587 f.POSTS_UNAPPROVED = f.POSTS_UNAPPROVED - 1,
588 f.ABS_LAST_MESSAGE_ID = abs_last_message.ID,
589 f.ABS_LAST_POSTER_ID = abs_last_message.AUTHOR_ID,
590 f.ABS_LAST_POSTER_NAME = abs_last_message.AUTHOR_NAME,
591 f.ABS_LAST_POST_DATE = abs_last_message.POST_DATE,
593WHERE f.ID = {$forumId} AND abs_last_message.FORUM_ID = f.ID
597 Main\Application::getConnection()->queryExecute($sql);