public function moderate($show) { if ($this->message === null) { $this->errorCollection->addOne(new Error(Loc::getMessage("FORUM_CM_ERR_COMMENT_IS_LOST3"), self::ERROR_MESSAGE_IS_NULL)); } else { $fields = array("APPROVED" => $show ? "Y" : "N"); if ($this->message["ID"] == $fields["APPROVED"] || ($mid = \CForumMessage::Update($this->message["ID"], $fields)) > 0) { $this->setComment($this->message["ID"]); /***************** Events ******************************************/ /***************** Event onMessageModerate *************************/ $event = new Event("forum", "onMessageModerate", array($this->message["ID"], $show ? "SHOW" : "HIDE", $this->message, $this->topic)); $event->send(); /***************** Events OnAfterCommentUpdate *********************/ $fields = array($this->entity->getType(), $this->entity->getId(), array("TOPIC_ID" => $this->topic["ID"], "MESSAGE_ID" => $this->message["ID"], "MESSAGE" => $this->getComment(), "ACTION" => $show ? "SHOW" : "HIDE", "PARAMS" => $fields)); $event = new Event("forum", "OnAfterCommentUpdate", $fields); $event->send(); /***************** Events OnCommentModerate ************************/ $event = new Event("forum", "OnCommentModerate", $fields); $event->send(); /***************** /Events *****************************************/ $res = serialize(array("ID" => $this->message["ID"], "AUTHOR_NAME" => $this->message["AUTHOR_NAME"], "POST_MESSAGE" => $this->message["POST_MESSAGE"], "TITLE" => $this->topic["TITLE"], "TOPIC_ID" => $this->topic["ID"], "FORUM_ID" => $this->topic["FORUM_ID"])); \CForumMessage::SendMailMessage($this->message["ID"], array(), false, $show ? "NEW_FORUM_MESSAGE" : "EDIT_FORUM_MESSAGE"); \CForumEventLog::Log("message", $show ? "approve" : "unapprove", $this->message["ID"], $res); return $this->getComment(); } else { $text = Loc::getMessage("FORUM_CM_ERR_MODERATE"); if (($ex = $this->getApplication()->getException()) && $ex) { $text = $ex->getString(); } $this->errorCollection->addOne(new Error($text, self::ERROR_PARAMS_MESSAGE)); } } return false; }
function MoveTopic2Forum($TID, $FID, $leaveLink = "N") { global $DB; $FID = intVal($FID); $arForum = CForumNew::GetByID($FID); $arTopics = is_array($TID) ? $TID : (intVal($TID) > 0 ? array($TID) : array()); $leaveLink = strToUpper($leaveLink) == "Y" ? "Y" : "N"; $arMsg = array(); $arForums = array(); if (empty($arForum)) { $arMsg[] = array("id" => "FORUM_NOT_EXIST", "text" => GetMessage("F_ERR_FORUM_NOT_EXIST", array("#FORUM_ID#" => $FID))); } if (empty($arTopics)) { $arMsg[] = array("id" => "TOPIC_EMPTY", "text" => GetMessage("F_ERR_EMPTY_TO_MOVE")); } if (!empty($arMsg)) { $e = new CAdminException($arMsg); $GLOBALS["APPLICATION"]->ThrowException($e); return false; } $arTopicsCopy = $arTopics; $arTopics = array(); foreach ($arTopicsCopy as $res) { $arTopics[intVal($res)] = array("ID" => intVal($res)); } $db_res = CForumTopic::GetList(array(), array("@ID" => implode(", ", array_keys($arTopics)))); if ($db_res && ($res = $db_res->Fetch())) { do { if (intVal($res["FORUM_ID"]) == $FID) { $arMsg[] = array("id" => "FORUM_ID_IDENTICAL", "text" => GetMessage("F_ERR_THIS_TOPIC_IS_NOT_MOVE", array("#TITLE#" => $res["TITLE"], "#ID#" => $res["ID"]))); continue; } // $DB->StartTransaction(); if ($leaveLink != "N") { CForumTopic::Add(array("TITLE" => $res["TITLE"], "DESCRIPTION" => $res["DESCRIPTION"], "STATE" => "L", "USER_START_NAME" => $res["USER_START_NAME"], "START_DATE" => $res["START_DATE"], "ICON_ID" => $res["ICON_ID"], "POSTS" => "0", "VIEWS" => "0", "FORUM_ID" => $res["FORUM_ID"], "TOPIC_ID" => $res["ID"], "APPROVED" => $res["APPROVED"], "SORT" => $res["SORT"], "LAST_POSTER_NAME" => $res["LAST_POSTER_NAME"], "LAST_POST_DATE" => $res["LAST_POST_DATE"], "HTML" => $res["HTML"], "USER_START_ID" => $res["USER_START_ID"], "SOCNET_GROUP_ID" => $res["SOCNET_GROUP_ID"], "OWNER_ID" => $res["OWNER_ID"])); } CForumTopic::Update($res["ID"], array("FORUM_ID" => $FID), true); // move message $strSql = "UPDATE b_forum_message SET FORUM_ID=" . $FID . ", POST_MESSAGE_HTML='' WHERE TOPIC_ID=" . $res["ID"]; $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__); // move subscribe $strSql = "UPDATE b_forum_subscribe SET FORUM_ID=" . intVal($FID) . " WHERE TOPIC_ID=" . $res["ID"]; $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__); $arForums[$res["FORUM_ID"]] = $res["FORUM_ID"]; unset($GLOBALS["FORUM_CACHE"]["TOPIC"][$res["ID"]]); unset($GLOBALS["FORUM_CACHE"]["TOPIC_FILTER"][$res["ID"]]); $arTopics[intVal($res["ID"])] = $res; // $DB->Commit(); CForumCacheManager::ClearTag("F", $res["ID"]); $res_log["DESCRIPTION"] = str_replace(array("#TOPIC_TITLE#", "#TOPIC_ID#", "#FORUM_TITLE#", "#FORUM_ID#"), array($res["TITLE"], $res["ID"], $arForum["NAME"], $arForum["ID"]), $leaveLink != "N" ? GetMessage("F_LOGS_MOVE_TOPIC_WITH_LINK") : GetMessage("F_LOGS_MOVE_TOPIC")); $res_log["FORUM_ID"] = $arForum["ID"]; $res_log["TOPIC_ID"] = $res["ID"]; $res_log["TITLE"] = $res["TITLE"]; $res_log["FORUM_TITLE"] = $arForum["NAME"]; CForumEventLog::Log("topic", "move", $res["ID"], serialize($res_log)); } while ($res = $db_res->Fetch()); } /***************** Cleaning cache **********************************/ unset($GLOBALS["FORUM_CACHE"]["FORUM"][$FID]); if (CACHED_b_forum !== false) { $GLOBALS["CACHE_MANAGER"]->CleanDir("b_forum"); } /***************** Cleaning cache/**********************************/ CForumNew::SetStat($FID); foreach ($arForums as $key) { CForumNew::SetStat($key); } if (!empty($arMsg)) { $e = new CAdminException($arMsg); $GLOBALS["APPLICATION"]->ThrowException($e); } else { CForumCacheManager::ClearTag("F", $FID); if ($leaveLink != "Y") { foreach ($arTopics as $key => $res) { CForumCacheManager::ClearTag("F", $res["FORUM_ID"]); } } } return true; }
} else { CForumEventLog::Log("topic", "unstick", $res["ID"], $res); } unset($arFields["SORT"]); } if (!empty($arFields)) { foreach ($arFields as $key => $val) { if ($arFields[$key] != $arTopic[$key]) { $res_log[$key] = $arFields[$key]; $res_log["before" . $key] = $arTopic[$key]; } } if (!empty($res_log)) { $arTopic = CForumTopic::GetByID($TID); $res_log['FORUM_ID'] = $arTopic['FORUM_ID']; CForumEventLog::Log("topic", "edit", $TID, serialize($res_log)); } } } } } /*******************************************************************/ if ($arID = $lAdmin->GroupAction()) { $sError = ""; $sOk = ""; if (!check_bitrix_sessid()) { } elseif ($_REQUEST['action'] == "move" && intVal($_REQUEST['move_to']) <= 0) { $lAdmin->AddFilterError(GetMessage("FM_WRONG_FORUM_ID")); } else { $arFilterAction = $arFilter; if ($_REQUEST['action'] == "move") {
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; }