Beispiel #1
0
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;
}
Beispiel #2
0
     }
 } 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":
         case "FORUM_SUBSCRIBE_TOPICS":
             if (ForumSubscribeNewMessagesEx($FID, $action == "FORUM_SUBSCRIBE" ? 0 : $TID, $action == "FORUM_SUBSCRIBE_TOPICS" ? "Y" : "N", $strErrorMessage, $strOKMessage)) {
                 LocalRedirect("subscr_list.php?FID=" . $FID . "&TID=" . $TID);
             }
             break;
         case "MOVE_TOPIC":
             LocalRedirect("move.php?FID=" . $FID . "&TID=" . $TID);
             break;