function ForumActions($action, $arFields, &$strErrorMessage, &$strOKMessage) { $result = false; $sError = ""; $sNote = ""; if (empty($action)) { $sError = GetMessage("FORUM_NO_ACTION"); } else { switch ($action) { case "REPLY": $result = ForumAddMessage("REPLY", $arFields["FID"], $arFields["TID"], 0, $arFields, $sError, $sNote, false, $arFields["captcha_word"], 0, $arFields["captcha_code"], $arFields["NAME_TEMPLATE"]); break; case "DEL": $result = ForumDeleteMessage($arFields["MID"], $sError, $sNote, $arFields); break; case "SHOW": case "HIDE": $result = ForumModerateMessage($arFields["MID"], $action, $sError, $sNote, $arFields); break; case "VOTE4USER": $result = ForumVote4User($arFields["UID"], $arFields["VOTES"], $arFields["VOTE"], $sError, $sNote, $arFields); break; case "FORUM_MESSAGE2SUPPORT": $result = ForumMoveMessage2Support($arFields["MID"], $sError, $sNote, $arFields); break; case "FORUM_SUBSCRIBE": case "TOPIC_SUBSCRIBE": case "FORUM_SUBSCRIBE_TOPICS": $result = ForumSubscribeNewMessagesEx($arFields["FID"], $arFields["TID"], $arFields["NEW_TOPIC_ONLY"], $sError, $sNote); break; case "SET_ORDINARY": case "SET_TOP": case "ORDINARY": case "TOP": if ($action == "SET_ORDINARY") { $action = "ORDINARY"; } elseif ($action == "SET_TOP") { $action = "TOP"; } $result = ForumTopOrdinaryTopic($arFields["TID"], $action, $sError, $sNote, $arFields); break; case "DEL_TOPIC": $result = ForumDeleteTopic($arFields["TID"], $sError, $sNote, $arFields); break; case "OPEN": case "CLOSE": case "STATE_Y": case "STATE_N": if ($action == "STATE_Y") { $action = "OPEN"; } elseif ($action == "STATE_N") { $action = "CLOSE"; } $result = ForumOpenCloseTopic($arFields["TID"], $action, $sError, $sNote, $arFields); break; case "SHOW_TOPIC": case "HIDE_TOPIC": $db_res = CForumMessage::GetList(array(), array("TOPIC_ID" => $arFields["TID"], "APPROVED" => $action == "HIDE_TOPIC" ? "Y" : "N")); $message = array(); if ($db_res && ($res = $db_res->Fetch())) { do { $message[] = $res["ID"]; } while ($res = $db_res->Fetch()); } if (!empty($message)) { $s = ""; $result = ForumModerateMessage($message, $action == "HIDE_TOPIC" ? "HIDE" : "SHOW", $sError, $s, $arFields); } else { $result = true; } CForumEventLog::Log("topic", $action == "HIDE_TOPIC" ? "unapprove" : "approve", $arFields["TID"], serialize(CForumTopic::GetByID($arFields["TID"]))); break; case "SPAM_TOPIC": $result = ForumSpamTopic($arFields["TID"], $sError, $sNote, $arFields); break; case "SPAM": $result = ForumSpamMessage($arFields["MID"], $sError, $sNote, $arFields); break; default: $sError = GetMessage("FORUM_NO_ACTION") . " (" . htmlspecialcharsbx($action) . ")"; break; } } $strErrorMessage = $sError; $strOKMessage = $sNote; return $result; }
$arResult["read"] = $arResult["URL"]["TOPIC"]; $arResult["message"] = $arResult["URL"]["MESSAGE"]; $arResult["pm_edit"] = $arResult["URL"]["USER_PM"]; $arResult["user_post_lta"] = $arResult["URL"]["USER_POSTS_AUTHOR"]; $arResult["user_post_lt"] = $arResult["URL"]["USER_POSTS_MEMBER"]; $arResult["user_post_all"] = $arResult["URL"]["USER_POSTS"]; /******************************************************************** /Default values ********************************************************************/ /******************************************************************** Data ********************************************************************/ /************** Votings ********************************************/ if ($arResult["SHOW_VOTES"] == "Y") { if ($_GET["VOTE_USER"] == "Y" && $USER->IsAuthorized() && check_bitrix_sessid()) { ForumVote4User($arParams["UID"], $_GET["VOTES"], strlen($_GET["CANCEL_VOTE"]) > 0 ? True : False, $strErrorMessage, $strOKMessage); if (empty($strErrorMessage)) { LocalRedirect($arResult["URL"]["~PROFILE_VIEW"]); } } $strNotesText = ""; $bCanVote = CForumUser::IsAdmin(); $bCanUnVote = False; $arUserRank = CForumUser::GetUserRank(intVal($USER->GetParam("USER_ID"))); $arUserPoints = CForumUserPoints::GetByID(intVal($USER->GetParam("USER_ID")), $arParams["UID"]); if ($arUserPoints) { $bCanUnVote = True; $strNotesText .= str_replace("#POINTS#", $arUserPoints["POINTS"], str_replace("#END#", ForumNumberRusEnding($arUserPoints["POINTS"]), GetMessage("F_ALREADY_VOTED1"))) . ". \n"; if (CForumUser::IsAdmin()) { $strNotesText .= GetMessage("F_ALREADY_VOTED_ADMIN"); } elseif (intVal($arUserPoints["POINTS"]) < intVal($arUserRank["VOTES"])) {
if ($MID <= 0) { $bVarsFromForm = true; } else { LocalRedirect($APPLICATION->GetCurPage() . "?FID=" . $FID . "&TID=" . $TID . "&MID=" . $MID . "#message" . $MID); } } elseif ($_SERVER["REQUEST_METHOD"] == "GET" && ($_GET["ACTION"] == "FORUM_SUBSCRIBE" || $_GET["ACTION"] == "TOPIC_SUBSCRIBE" || $_GET["ACTION"] == "FORUM_SUBSCRIBE_TOPICS") && check_bitrix_sessid()) { if (ForumSubscribeNewMessagesEx($FID, $_GET["ACTION"] == "FORUM_SUBSCRIBE" ? 0 : $TID, $_GET["ACTION"] == "FORUM_SUBSCRIBE_TOPICS" ? "Y" : "N", $strErrorMessage, $strOKMessage)) { LocalRedirect("subscr_list.php?FID=" . $FID . "&TID=" . $TID); } } elseif ($_SERVER["REQUEST_METHOD"] == "GET" && $_GET["VOTE4USER"] == "Y" && check_bitrix_sessid()) { $UID = IntVal($_GET["UID"]); if ($UID <= 0) { $strErrorMessage .= GetMessage("FR_NO_VPERS") . ".\n"; } if (strlen($strErrorMessage) <= 0) { ForumVote4User($UID, $_GET["VOTES"], $_GET["VOTES_TYPE"] == "U" ? True : False, $strErrorMessage, $strOKMessage); } LocalRedirect("read.php?FID=" . $FID . "&TID=" . $TID); } elseif ($_SERVER["REQUEST_METHOD"] == "GET" && check_bitrix_sessid()) { $action = strToUpper($_GET["ACTION"]); switch ($action) { case "FORUM_MESSAGE2SUPPORT": if (CModule::IncludeModule("support")) { $SuID = ForumMoveMessage2Support($MID, $strErrorMessage, $strOKMessage); if (IntVal($SuID) > 0) { LocalRedirect("/bitrix/admin/ticket_edit.php?ID=" . IntVal($SuID) . "&lang=" . LANGUAGE_ID); } } break; case "FORUM_SUBSCRIBE": case "TOPIC_SUBSCRIBE":