本文整理汇总了PHP中CForumTopic::SetStat方法的典型用法代码示例。如果您正苦于以下问题:PHP CForumTopic::SetStat方法的具体用法?PHP CForumTopic::SetStat怎么用?PHP CForumTopic::SetStat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CForumTopic
的用法示例。
在下文中一共展示了CForumTopic::SetStat方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: foreach
foreach ($arForum["TOPICS"] as $arTopic) {
$arTopic["FORUM_ID"] = $forumID;
$topicID = CForumTopic::Add($arTopic);
if ($topicID < 1 || !isset($arTopic["MESSAGES"]) || !is_array($arTopic["MESSAGES"])) {
continue;
}
foreach ($arTopic["MESSAGES"] as $arMessage) {
$arMessage["FORUM_ID"] = $forumID;
$arMessage["TOPIC_ID"] = $topicID;
$messageID = CForumMessage::Add($arMessage, false);
if ($messageID < 1) {
CForumTopic::Delete($topicID);
continue 2;
}
}
CForumTopic::SetStat($topicID);
}
}
$fidParameter = "";
$dbForum = CForumNew::GetList(array(), array("SITE_ID" => WIZARD_SITE_ID));
while ($arForum = $dbForum->Fetch()) {
if ($arForum["FORUM_GROUP_ID"] != $arGroupID["HIDDEN"] && $arForum["FORUM_GROUP_ID"] != $arGroupID["COMMENTS"]) {
$fidParameter .= $arForum["ID"] . ",";
}
}
$fidParameter = rtrim($fidParameter, ",");
$forum_theme = 'blue';
switch (WIZARD_THEME_ID) {
case 'green':
$forum_theme = "green";
break;
示例2: Delete
function Delete($ID)
{
global $DB;
$ID = intVal($ID);
$arMessage = array();
if ($ID > 0) {
$arMessage = CForumMessage::GetByID($ID, array("FILTER" => "N"));
}
if (empty($arMessage)) {
return false;
}
/***************** Event onBeforeMessageAdd ************************/
foreach (GetModuleEvents("forum", "onBeforeMessageDelete", true) as $arEvent) {
if (ExecuteModuleEventEx($arEvent, array(&$ID, $arMessage)) === false) {
return false;
}
}
/***************** /Event ******************************************/
$AUTHOR_ID = intVal($arMessage["AUTHOR_ID"]);
$TOPIC_ID = intVal($arMessage["TOPIC_ID"]);
$FORUM_ID = intVal($arMessage["FORUM_ID"]);
$DB->StartTransaction();
// delete votes
if ($arMessage["PARAM1"] == "VT" && intVal($arMessage["PARAM2"]) > 0 && IsModuleInstalled("vote")) {
CModule::IncludeModule("vote");
CVote::Delete($arMessage["PARAM2"]);
}
// delete files
CForumFiles::Delete(array("MESSAGE_ID" => $ID), array("DELETE_MESSAGE_FILE" => "Y"));
// delete message
$DB->Query("DELETE FROM b_forum_message WHERE ID=" . $ID);
// after delete
$db_res = CForumMessage::GetList(array("ID" => "ASC"), array("TOPIC_ID" => $TOPIC_ID), false, 1);
$res = false;
if (!($db_res && ($res = $db_res->Fetch()))) {
CForumTopic::Delete($TOPIC_ID);
} else {
// if deleted message was first
if ($arMessage["NEW_TOPIC"] == "Y") {
$DB->Update('b_forum_message', array('NEW_TOPIC' => '"Y"'), "WHERE ID=" . $res["ID"]);
}
CForumTopic::SetStat($TOPIC_ID);
}
$DB->Commit();
$GLOBALS["USER_FIELD_MANAGER"]->Delete("FORUM_MESSAGE", $ID);
if ($AUTHOR_ID > 0) {
CForumUser::SetStat($AUTHOR_ID);
}
CForumNew::SetStat($FORUM_ID);
/***************** Event onBeforeMessageAdd ************************/
foreach (GetModuleEvents("forum", "onAfterMessageDelete", true) as $arEvent) {
ExecuteModuleEventEx($arEvent, array($ID, $arMessage));
}
/***************** /Event ******************************************/
if (CModule::IncludeModule("search")) {
CSearch::DeleteIndex("forum", $ID);
if (is_array($res) && !empty($res)) {
CForumMessage::Reindex($res["ID"], $res);
}
}
return true;
}
示例3: ForumMoveMessage
//.........这里部分代码省略.........
if ($db_res && ($res = $db_res->Fetch())) {
$arRes["NAME"] = $res["AUTHOR_NAME"];
$arRes["ID"] = $res["AUTHOR_ID"];
}
$arFieldsTopic = array("TITLE" => $arFields["TITLE"], "TITLE_SEO" => $arFields["TITLE_SEO"], "DESCRIPTION" => $arFields["DESCRIPTION"], "ICON" => $arFields["ICON"], "TAGS" => $arFields["TAGS"], "FORUM_ID" => $FID, "USER_START_ID" => $arRes["ID"], "USER_START_NAME" => $arRes["NAME"], "LAST_POSTER_NAME" => $arRes["NAME"], "LAST_POSTER_ID" => $arRes["ID"], "APPROVED" => $arFields["APPROVED"]);
$NewTID = CForumTopic::Add($arFieldsTopic);
if (IntVal($NewTID) <= 0) {
$arError[] = GetMessage("FMM_NO_TOPIC_NOT_CREATED");
} else {
$arNewTopic = CForumTopic::GetByID($NewTID);
if ($arNewTopic) {
$NewFID = $FID;
$arNewForum = $arForum;
$SendSubscribe = true;
} else {
$arError[] = GetMessage("FMM_NO_TOPIC_NOT_CREATED");
}
}
}
}
if (count($arError) <= 0) {
// Move message
$db_res = CForumMessage::GetList(array(), array("@ID" => implode(",", $Message), "TOPIC_ID" => $TID));
if ($db_res && ($res = $db_res->Fetch())) {
do {
// echo "NewFID: ".$NewFID." -- FID:".$FID."<br/>";
$arMessage = array();
if ($NewFID != $FID) {
$arMessage["APPROVED"] = $arNewForum["MODERATION"] == "Y" ? "N" : "Y";
if ($arCurrUser["Perms"]["NewFID"] >= "Q") {
$arMessage["APPROVED"] = "Y";
}
$arMessage["FORUM_ID"] = $NewFID;
$arMessage["POST_MESSAGE_HTML"] = "";
}
if ($NewTID != $TID) {
$arMessage["NEW_TOPIC"] = "N";
$arMessage["TOPIC_ID"] = $NewTID;
}
if (count($arMessage) > 0) {
$MID = CForumMessage::Update($res["ID"], $arMessage, true);
$res_log = $SendSubscribe == true ? GetMessage("F_MESSAGE_WAS_MOVED_TO_NEW") : GetMessage("F_MESSAGE_WAS_MOVED");
$res_log = str_replace(array("#ID#", "#TOPIC_TITLE#", "#TOPIC_ID#", "#NEW_TOPIC_TITLE#", "#NEW_TOPIC_ID#"), array($MID, $arTopic["TITLE"], $arTopic["ID"], $arNewTopic['TITLE'], $arNewTopic['ID']), $res_log);
$res["TITLE"] = $arNewTopic['TITLE'];
$res["TOPIC_ID"] = $arNewTopic['ID'];
$res["beforeTITLE"] = $arTopic["TITLE"];
$res["DESCRIPTION"] = $res_log;
CForumEventLog::Log("message", "move", $MID, serialize($res));
$db_res2 = CForumFiles::GetList(array(), array("FILE_MESSAGE_ID" => $res["ID"]));
if ($db_res2 && ($res2 = $db_res2->Fetch())) {
$arFiles = array();
do {
$arFiles[] = $res2["FILE_ID"];
} while ($res2 = $db_res2->Fetch());
CForumFiles::UpdateByID($arFiles, $arMessage);
}
if (IntVal($MID) <= 0) {
$arError[] = str_replace("##", $res["ID"], GetMessage("FMM_NO_MESSAGE_MOVE"));
break;
}
}
} while ($res = $db_res->Fetch());
}
}
if (count($arError) <= 0) {
$db_res = CForumMessage::GetList(array(), array("TOPIC_ID" => $TID), false, 1);
if (!($db_res && ($res = $db_res->Fetch()))) {
CForumTopic::Delete($TID);
} else {
CForumTopic::SetStat($TID);
}
$db_res = CForumMessage::GetList(array(), array("TOPIC_ID" => $NewTID), false, 1);
if (!($db_res && ($res = $db_res->Fetch()))) {
CForumTopic::Delete($NewTID);
} else {
CForumTopic::SetStat($NewTID);
}
CForumNew::SetStat($FID);
if ($NewFID != $FID) {
CForumNew::SetStat($NewFID);
}
}
if (count($arError) <= 0) {
$DB->Commit();
} else {
$DB->Rollback();
}
if (count($arError) > 0) {
$strErrorMessage .= implode(". \n", $arError) . ". \n";
} else {
$strOKMessage .= GetMessage("FMM_YES_MESSAGE_MOVE");
if ($SendSubscribe) {
foreach ($Message as $MID) {
CForumMessage::SendMailMessage($MID, array(), false, "NEW_FORUM_MESSAGE");
}
}
return true;
}
return false;
}
示例4: Add
function Add($arFields, $strUploadDir = false, $arParams = array())
{
global $DB;
$strUploadDir = ($strUploadDir === false ? "forum/upload" : $strUploadDir);
if (!CForumMessage::CheckFields("ADD", $arFields))
return false;
$arForum = CForumNew::GetByID($arFields["FORUM_ID"]);
$arParams["SKIP_STATISTIC"] = ($arParams["SKIP_STATISTIC"] == "Y" ? "Y" : "N");
$arParams["SKIP_INDEXING"] = ($arParams["SKIP_INDEXING"] == "Y" || $arForum["INDEXATION"] != "Y" ? "Y" : "N");
$POST_MESSAGE = $arFields["POST_MESSAGE"];
$parser = new forumTextParser(LANGUAGE_ID);
$allow = forumTextParser::GetFeatures($arForum);
$allow['SMILES'] = (($arFields["USE_SMILES"] != "Y") ? 'N' : $allow['SMILES']);
if (COption::GetOptionString("forum", "FILTER", "Y") == "Y")
{
$POST_MESSAGE = CFilterUnquotableWords::Filter($POST_MESSAGE);
$arFields["POST_MESSAGE_FILTER"] = (empty($POST_MESSAGE) ? "*" : $POST_MESSAGE);
}
/***************** Attach ******************************************/
$arFiles = array();
if (is_array($arFields["ATTACH_IMG"]))
$arFields["FILES"] = array($arFields["ATTACH_IMG"]);
unset($arFields["ATTACH_IMG"]);
if (is_array($arFields["FILES"]) && !empty($arFields["FILES"]))
{
$res = array("FORUM_ID" => $arFields["FORUM_ID"], "USER_ID" => $arFields["AUTHOR_ID"], "upload_dir" => $strUploadDir);
$arFiles = CForumFiles::Save($arFields["FILES"], $res, false);
if (!empty($arFiles))
{
$arFiles = array_keys($arFiles);
sort($arFiles);
$arFields["ATTACH_IMG"] = $arFiles[0];
$arFields["ATTACHED_FILES"] = $arFiles;
}
unset($arFields["FILES"]);
}
/***************** Attach/******************************************/
if (COption::GetOptionString("forum", "MESSAGE_HTML", "N") == "Y")
$POST_MESSAGE = $parser->convert($POST_MESSAGE, $allow, "html", $arFiles);
$arFields["POST_MESSAGE_HTML"] = $POST_MESSAGE;
/***************** Event onBeforeMessageAdd ************************/
foreach(GetModuleEvents("forum", "onBeforeMessageAdd", true) as $arEvent)
{
if (ExecuteModuleEventEx($arEvent, array(&$arFields, &$strUploadDir)) === false)
return false;
}
/***************** /Event ******************************************/
if (empty($arFields))
return false;
$arInsert = $DB->PrepareInsert("b_forum_message", $arFields, $strUploadDir);
$strDatePostField = "";
$strDatePostValue = "";
if (!is_set($arFields, "POST_DATE"))
{
$strDatePostField = ", POST_DATE";
$strDatePostValue = ", ".$DB->GetNowFunction()."";
}
$strSql = "INSERT INTO b_forum_message(".$arInsert[0].$strDatePostField.") VALUES(".$arInsert[1].$strDatePostValue.")";
$DB->Query($strSql, false, "File: ".__FILE__."<br>Line: ".__LINE__);
$ID = intVal($DB->LastID());
/***************** Attach ******************************************/
if (!empty($arFiles))
CForumFiles::UpdateByID($arFiles, array("FORUM_ID" => $arFields["FORUM_ID"],
"TOPIC_ID" => $arFields["TOPIC_ID"], "MESSAGE_ID" => $ID));
/***************** Attach/******************************************/
/***************** Quota *******************************************/
$_SESSION["SESS_RECOUNT_DB"] = "Y";
$GLOBALS["USER_FIELD_MANAGER"]->Update("FORUM_MESSAGE", $ID, $arFields);
if ($arParams["SKIP_STATISTIC"] == "Y" && $arParams["SKIP_INDEXING"] == "Y")
return $ID;
$arMessage = CForumMessage::GetByIDEx($ID, array("GET_FORUM_INFO" => "N", "GET_TOPIC_INFO" => "Y", "FILTER" => "Y"));
if ($arParams["SKIP_STATISTIC"] != "Y")
{
if (intVal($arMessage["AUTHOR_ID"]) > 0)
{
CForumUser::SetStat($arMessage["AUTHOR_ID"], array("MESSAGE" => $arMessage));
}
CForumTopic::SetStat($arMessage["TOPIC_ID"], array("MESSAGE" => $arMessage));
CForumNew::SetStat($arMessage["FORUM_ID"], array("MESSAGE" => $arMessage));
}
/***************** Events onAfterMessageAdd ************************/
foreach(GetModuleEvents("forum", "onAfterMessageAdd", true) as $arEvent)
ExecuteModuleEventEx($arEvent, array(&$ID, $arMessage, $arMessage["TOPIC_INFO"], $arMessage["FORUM_INFO"], $arFields));
/***************** /Events *****************************************/
if ($arMessage["APPROVED"] == "Y")
{
if ($arParams["SKIP_INDEXING"] != "Y" && CModule::IncludeModule("search"))
{
$arMessage["POST_MESSAGE"] = (COption::GetOptionString("forum", "FILTER", "Y") == "Y" ?
$arMessage["POST_MESSAGE_FILTER"] : $arMessage["POST_MESSAGE"]);
$arParams = array(
"PERMISSION" => array(),
//.........这里部分代码省略.........
示例5: Delete
/**
* <p>Удаляет сообщение с кодом <i>ID</i>.</p> <p><b>Примечание</b>. Метод использует внутреннюю транзакцию. Если у вас используется <b>MySQL</b> и <b>InnoDB</b>, и ранее была открыта транзакция, то ее необходимо закрыть до подключения метода.</p>
*
*
*
*
* @param int $ID Код сообщения, которое необходимо удалить.
*
*
*
* @return bool
*
*
* <h4>See Also</h4>
* <ul><li>Перед удалением сообщения следует проверить возможность
* удаления методом <a
* href="http://dev.1c-bitrix.ru/api_help/forum/developer/cforummessage/canuserdeletemessage.php">CForumMessage::CanUserDeleteMessage</a>
* </li></ul>
*
*
* @static
* @link http://dev.1c-bitrix.ru/api_help/forum/developer/cforummessage/delete.php
* @author Bitrix
*/
public static function Delete($ID)
{
global $DB;
$ID = intVal($ID);
$arMessage = array();
if ($ID > 0)
$arMessage = CForumMessage::GetByID($ID, array("FILTER" => "N"));
if (empty($arMessage))
return false;
/***************** Event onBeforeMessageAdd ************************/
$events = GetModuleEvents("forum", "onBeforeMessageDelete");
while ($arEvent = $events->Fetch())
{
if (ExecuteModuleEventEx($arEvent, array(&$ID, $arMessage)) === false)
return false;
}
/***************** /Event ******************************************/
$AUTHOR_ID = intVal($arMessage["AUTHOR_ID"]);
$TOPIC_ID = intVal($arMessage["TOPIC_ID"]);
$FORUM_ID = intVal($arMessage["FORUM_ID"]);
$DB->StartTransaction();
// delete votes
if ($arMessage["PARAM1"] == "VT" && intVal($arMessage["PARAM2"]) > 0 && IsModuleInstalled("vote")):
CModule::IncludeModule("vote");
CVote::Delete($arMessage["PARAM2"]);
endif;
// delete files
CForumFiles::Delete(array("MESSAGE_ID" => $ID), array("DELETE_MESSAGE_FILE" => "Y"));
// delete message
$DB->Query("DELETE FROM b_forum_message WHERE ID=".$ID);
// after delete
$db_res = CForumMessage::GetList(array("ID" => "ASC"), array("TOPIC_ID" => $TOPIC_ID), false, 1);
$res = false;
if (!($db_res && $res = $db_res->Fetch())):
CForumTopic::Delete($TOPIC_ID);
else:
// if deleted message was first
if ($arMessage["NEW_TOPIC"] == "Y"):
$DB->Query("UPDATE b_forum_message SET NEW_TOPIC='Y' WHERE ID=".$res["ID"]);
endif;
CForumTopic::SetStat($TOPIC_ID);
endif;
$DB->Commit();
$GLOBALS["USER_FIELD_MANAGER"]->Delete("FORUM_MESSAGE", $ID);
if ($AUTHOR_ID > 0):
CForumUser::SetStat($AUTHOR_ID);
endif;
CForumNew::SetStat($FORUM_ID);
/***************** Event onBeforeMessageAdd ************************/
$events = GetModuleEvents("forum", "onAfterMessageDelete");
while ($arEvent = $events->Fetch())
ExecuteModuleEventEx($arEvent, array($ID, $arMessage));
/***************** /Event ******************************************/
if (CModule::IncludeModule("search"))
{
CSearch::DeleteIndex("forum", $ID);
}
return true;
}