当前位置: 首页>>代码示例>>PHP>>正文


PHP CForumMessage::Reindex方法代码示例

本文整理汇总了PHP中CForumMessage::Reindex方法的典型用法代码示例。如果您正苦于以下问题:PHP CForumMessage::Reindex方法的具体用法?PHP CForumMessage::Reindex怎么用?PHP CForumMessage::Reindex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CForumMessage的用法示例。


在下文中一共展示了CForumMessage::Reindex方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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;
 }
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:62,代码来源:message.php

示例2: SetStat

 function SetStat($ID = 0, $arParams = array())
 {
     global $DB;
     $ID = intVal($ID);
     if ($ID <= 0) {
         return false;
     }
     $arParams = is_array($arParams) ? $arParams : array();
     $arMessage = is_array($arParams["MESSAGE"]) ? $arParams["MESSAGE"] : array();
     if ($arMessage["TOPIC_ID"] != $ID) {
         $arMessage = array();
     }
     $arFields = array();
     if (!empty($arMessage)) {
         $arFields = array("ABS_LAST_POSTER_ID" => intVal($arMessage["AUTHOR_ID"]) > 0 ? $arMessage["AUTHOR_ID"] : false, "ABS_LAST_POSTER_NAME" => $arMessage["AUTHOR_NAME"], "ABS_LAST_POST_DATE" => $arMessage["POST_DATE"], "ABS_LAST_MESSAGE_ID" => $arMessage["ID"]);
         if ($arMessage["APPROVED"] == "Y") {
             $arFields["APPROVED"] = "Y";
             $arFields["LAST_POSTER_ID"] = $arFields["ABS_LAST_POSTER_ID"];
             $arFields["LAST_POSTER_NAME"] = $arFields["ABS_LAST_POSTER_NAME"];
             $arFields["LAST_POST_DATE"] = $arFields["ABS_LAST_POST_DATE"];
             $arFields["LAST_MESSAGE_ID"] = $arFields["ABS_LAST_MESSAGE_ID"];
             if ($arMessage["NEW_TOPIC"] != "Y") {
                 $arFields["=POSTS"] = "POSTS+1";
             }
         } else {
             $arFields["=POSTS_UNAPPROVED"] = "POSTS_UNAPPROVED+1";
         }
     } else {
         $res = CForumMessage::GetList(array(), array("TOPIC_ID" => $ID), "cnt_not_approved");
         $res["CNT"] = intVal($res["CNT"]) - intVal($res["CNT_NOT_APPROVED"]);
         $res["CNT"] = $res["CNT"] > 0 ? $res["CNT"] : 0;
         if (intval($res["ABS_FIRST_MESSAGE_ID"]) > 0 && intval($res["ABS_FIRST_MESSAGE_ID"]) != intval($res["FIRST_MESSAGE_ID"])) {
             $GLOBALS["DB"]->Query("UPDATE b_forum_message SET NEW_TOPIC = (CASE WHEN ID=" . intval($res["ABS_FIRST_MESSAGE_ID"]) . " THEN 'Y' ELSE 'N' END) WHERE TOPIC_ID=" . $ID, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
             CForumMessage::Reindex($res["ABS_FIRST_MESSAGE_ID"], $messFirst = array());
             CForumMessage::Reindex($res["FIRST_MESSAGE_ID"], $mess = array());
         }
         $arFields = array("APPROVED" => $res["CNT"] > 0 ? "Y" : "N", "POSTS" => $res["CNT"] > 0 ? $res["CNT"] - 1 : 0, "LAST_POSTER_ID" => false, "LAST_POSTER_NAME" => false, "LAST_POST_DATE" => false, "LAST_MESSAGE_ID" => intVal($res["LAST_MESSAGE_ID"]), "POSTS_UNAPPROVED" => intVal($res["CNT_NOT_APPROVED"]), "ABS_LAST_POSTER_ID" => false, "ABS_LAST_POSTER_NAME" => false, "ABS_LAST_POST_DATE" => false, "ABS_LAST_MESSAGE_ID" => intVal($res["ABS_LAST_MESSAGE_ID"]));
         if ($arFields["ABS_LAST_MESSAGE_ID"] > 0) {
             $res = CForumMessage::GetByID($arFields["ABS_LAST_MESSAGE_ID"], array("FILTER" => "N"));
             $arFields["ABS_LAST_POSTER_ID"] = intVal($res["AUTHOR_ID"]) > 0 ? $res["AUTHOR_ID"] : false;
             $arFields["ABS_LAST_POSTER_NAME"] = $res["AUTHOR_NAME"];
             $arFields["ABS_LAST_POST_DATE"] = $res["POST_DATE"];
             if (intVal($arFields["LAST_MESSAGE_ID"]) > 0) {
                 if ($arFields["LAST_MESSAGE_ID"] < $arFields["ABS_LAST_MESSAGE_ID"]) {
                     $res = CForumMessage::GetByID($arFields["LAST_MESSAGE_ID"], array("FILTER" => "N"));
                 }
                 $arFields["LAST_POSTER_ID"] = intVal($res["AUTHOR_ID"]) > 0 ? $res["AUTHOR_ID"] : false;
                 $arFields["LAST_POSTER_NAME"] = $res["AUTHOR_NAME"];
                 $arFields["LAST_POST_DATE"] = $res["POST_DATE"];
             }
         }
         foreach (array("LAST_POST_DATE" => "START_DATE", "ABS_LAST_POST_DATE" => "START_DATE", "LAST_POSTER_NAME" => "USER_START_NAME", "ABS_LAST_POSTER_NAME" => "USER_START_NAME") as $key => $val) {
             if ($arFields[$key] == false) {
                 $arFields["=" . $key] = $val;
                 unset($arFields[$key]);
             }
         }
     }
     return CForumTopic::Update($ID, $arFields);
 }
开发者ID:Satariall,项目名称:izurit,代码行数:60,代码来源:topic.php

示例3: Update


//.........这里部分代码省略.........
             $GLOBALS["FORUM_CACHE"]["TOPIC"][$ID]["VIEWS"] = intVal($res["VIEWS"]);
             $GLOBALS["FORUM_CACHE"]["TOPIC_FILTER"][$ID]["VIEWS"] = intVal($res["VIEWS"]);
         }
     } else {
         unset($GLOBALS["FORUM_CACHE"]["FORUM"][$arTopic_prev["FORUM_ID"]]);
         unset($GLOBALS["FORUM_CACHE"]["TOPIC"][$ID]);
         unset($GLOBALS["FORUM_CACHE"]["TOPIC_FILTER"][$ID]);
         if (intVal($arFields1["FORUM_ID"]) > 0) {
             unset($GLOBALS["FORUM_CACHE"]["FORUM"][intVal($arFields1["FORUM_ID"])]);
         }
         if (intVal($arFields["FORUM_ID"]) > 0) {
             unset($GLOBALS["FORUM_CACHE"]["FORUM"][intVal($arFields["FORUM_ID"])]);
         }
     }
     if (count($res) == 1 && !empty($res["VIEWS"])) {
         return $ID;
     }
     if (is_set($arFields, "FORUM_ID") && intVal($arFields["FORUM_ID"]) != intVal($arTopic_prev["FORUM_ID"])) {
         $arFiles = array();
         $db_res = CForumFiles::GetList(array(), array("TOPIC_ID" => $ID));
         if ($db_res && ($res = $db_res->Fetch())) {
             do {
                 $arFiles[] = $res["ID"];
             } while ($res = $db_res->Fetch());
         }
         CForumFiles::UpdateByID($arFiles, array("FORUM_ID" => $arFields["FORUM_ID"]));
     }
     /***************** Event onAfterTopicUpdate ************************/
     $events = GetModuleEvents("forum", "onAfterTopicUpdate");
     if ($events->nSelectedCount > 0) {
         $arTopicFields = CForumTopic::GetByID($ID, array("NoFilter" => true));
     }
     while ($arEvent = $events->Fetch()) {
         ExecuteModuleEventEx($arEvent, array($ID, $arTopicFields));
     }
     /***************** /Event ******************************************/
     // recalc statistic if topic removed from another forum
     if (!$skip_counts && is_set($arFields, "FORUM_ID") && intVal($arFields["FORUM_ID"]) != intVal($arTopic_prev["FORUM_ID"])) {
         $DB->StartTransaction();
         $db_res = CForumMessage::GetList(array(), array("TOPIC_ID" => $ID));
         while ($ar_res = $db_res->Fetch()) {
             CForumMessage::Update($ar_res["ID"], array("FORUM_ID" => $arFields["FORUM_ID"]), true);
         }
         $db_res = CForumSubscribe::GetList(array(), array("TOPIC_ID" => $ID));
         while ($ar_res = $db_res->Fetch()) {
             CForumSubscribe::Update($ar_res["ID"], array("FORUM_ID" => $arFields["FORUM_ID"]));
         }
         $DB->Commit();
         CForumNew::SetStat($arFields["FORUM_ID"]);
         CForumNew::SetStat($arTopic_prev["FORUM_ID"]);
     }
     if (IsModuleInstalled("search")) {
         $bNeedDeleteIndex = false;
         if (is_set($arFields, "FORUM_ID") && intVal($arFields["FORUM_ID"]) != intVal($arTopic_prev["FORUM_ID"])) {
             $res = CForumNew::GetByID($arFields["FORUM_ID"]);
             $bNeedDeleteIndex = $res["INDEXATION"] != "Y" ? true : false;
         }
         if ($bNeedDeleteIndex) {
             CModule::IncludeModule("search");
             CSearch::DeleteIndex("forum", false, $arTopic_prev["FORUM_ID"], $ID);
         } elseif (is_set($arFields, "TITLE") || is_set($arFields, "TAGS") || is_set($arFields, "DESCRIPTION")) {
             $arReindex = array();
             $arFields["FORUM_ID"] = is_set($arFields, "FORUM_ID") ? $arFields["FORUM_ID"] : $arTopic_prev["FORUM_ID"];
             if (is_set($arFields, "TITLE") && trim($arTopic_prev["TITLE"]) != trim($arFields["TITLE"])) {
                 $arReindex["TITLE"] = $bNeedFilter ? $arFieldsForFilter["TITLE"] : $arFields["TITLE"];
             }
             if (is_set($arFields, "DESCRIPTION") && trim($arTopic_prev["DESCRIPTION"]) != trim($arFields["DESCRIPTION"])) {
                 $title = is_set($arReindex, "TITLE") ? $arReindex["TITLE"] : ($bNeedFilter ? $arFieldsForFilter["TITLE"] : $arTopic_prev["TITLE"]);
                 $description = $bNeedFilter ? $arFieldsForFilter["DESCRIPTION"] : $arFields["DESCRIPTION"];
                 $arReindex["TITLE_FOR_FIRST_POST"] = $title . (!empty($description) ? ", " . $description : "");
             }
             if (is_set($arFields, "TAGS") && trim($arTopic_prev["TAGS"]) != trim($arFields["TAGS"])) {
                 $arReindex["TAGS"] = $bNeedFilter ? $arFieldsForFilter["TAGS"] : $arFields["TAGS"];
             }
             if (!empty($arReindex)) {
                 CModule::IncludeModule("search");
                 if (is_set($arReindex, "TITLE")) {
                     $db_res = CForumMessage::GetList(array("ID" => "ASC"), array("FORUM_ID" => $arFields["FORUM_ID"], "TOPIC_ID" => $ID, "NEW_TOPIC" => "Y"));
                     if ($db_res) {
                         while ($arMessage = $db_res->Fetch()) {
                             CForumMessage::Reindex($arMessage['ID'], array_merge($arMessage, $arReindex));
                         }
                     }
                 }
                 if (is_set($arReindex, "TITLE_FOR_FIRST_POST") || is_set($arReindex, "TAGS")) {
                     unset($arReindex["TITLE"]);
                     if (is_set($arReindex, "TITLE_FOR_FIRST_POST")) {
                         $arReindex["TITLE"] = $arReindex["TITLE_FOR_FIRST_POST"];
                         unset($arReindex["TITLE_FOR_FIRST_POST"]);
                     }
                     $db_res = CForumMessage::GetList(array("ID" => "ASC"), array("TOPIC_ID" => $ID, "NEW_TOPIC" => "Y"));
                     if ($db_res && ($arMessage = $db_res->Fetch())) {
                         CForumMessage::Reindex($arMessage['ID'], array_merge($arMessage, $arReindex));
                     }
                 }
             }
         }
     }
     return $ID;
 }
开发者ID:k-kalashnikov,项目名称:geekcon_new,代码行数:101,代码来源:topic.php

示例4: Update


//.........这里部分代码省略.........
				$arFields["ATTACH_IMG"] = $arFiles[0];
			}
			else
			{
				$arFields["ATTACH_IMG"] = 0;
			}
			unset($arFields["FILES"]);
		}
/***************** Attach/******************************************/
		if (empty($arFields) && empty($strSql))
			return false;
		$strUpdate = $DB->PrepareUpdate("b_forum_message", $arFields, $strUploadDir);
		$strSql = "UPDATE b_forum_message SET ".$strUpdate.$strSql." WHERE ID = ".$ID;

		$DB->QueryBind($strSql,
			array("POST_MESSAGE" => $arFields["POST_MESSAGE"],
				"POST_MESSAGE_HTML" => $arFields["POST_MESSAGE_HTML"],
				"POST_MESSAGE_FILTER" => $arFields["POST_MESSAGE_FILTER"],
				"EDIT_REASON" => $arFields["EDIT_REASON"],
				"HTML" => $arFields["HTML"]));
/***************** Attach ******************************************/
		if (!empty($arFiles))
		{
			$res = array(
				"FORUM_ID" => (is_set($arFields, "FORUM_ID") ? $arFields["FORUM_ID"] : $arMessage_prev["FORUM_ID"]),
				"TOPIC_ID" => (is_set($arFields, "TOPIC_ID") ? $arFields["TOPIC_ID"] : $arMessage_prev["TOPIC_ID"]),
				"MESSAGE_ID" => $ID);
			CForumFiles::UpdateByID($arFiles, $res);
		}
/***************** Attach/******************************************/
/***************** Quota *******************************************/
		$_SESSION["SESS_RECOUNT_DB"] = "Y";

		$GLOBALS["USER_FIELD_MANAGER"]->Update("FORUM_MESSAGE", $ID, $arFields);
/***************** Event onAfterMessageUpdate **********************/
		$events = GetModuleEvents("forum", "onAfterMessageUpdate");
		while ($arEvent = $events->Fetch())
			ExecuteModuleEventEx($arEvent, array(&$ID, &$arFields));
/***************** /Event ******************************************/
		unset($GLOBALS["FORUM_CACHE"]["MESSAGE"][$ID]);
		unset($GLOBALS["FORUM_CACHE"]["MESSAGE_FILTER"][$ID]);

		if (!$skip_counts || IsModuleInstalled("search"))
		{
			$arMessage = CForumMessage::GetByIDEx($ID, array("GET_TOPIC_INFO" => "Y", "GET_FORUM_INFO" => "Y", "FILTER" => "Y"));
			if (!$skip_counts)
			{
				// author
				if ($arMessage["AUTHOR_ID"] != $arMessage_prev["AUTHOR_ID"]):
					CForumUser::SetStat($arMessage_prev["AUTHOR_ID"], array("MESSAGE" => $arMessage_prev, "ACTION" => "DECREMENT"));
					CForumUser::SetStat($arMessage["AUTHOR_ID"], array("MESSAGE" => $arMessage, "ACTION" => "INCREMENT"));
				endif;

				// Topic
				if ($arMessage["TOPIC_ID"] != $arMessage_prev["TOPIC_ID"]):
					CForumTopic::SetStat($arMessage_prev["TOPIC_ID"]);
					CForumTopic::SetStat($arMessage["TOPIC_ID"]);
				endif;

				// Forum
				if ($arMessage["FORUM_ID"] != $arMessage_prev["FORUM_ID"]):
					CForumNew::SetStat($arMessage_prev["FORUM_ID"], array("MESSAGE" => $arMessage_prev, "ACTION" => "DECREMENT"));
					CForumNew::SetStat($arMessage["FORUM_ID"], array("MESSAGE" => $arMessage, "ACTION" => "INCREMENT"));
				endif;

				if ($arMessage["APPROVED"] != $arMessage_prev["APPROVED"]):
					if ($arMessage["AUTHOR_ID"] == $arMessage_prev["AUTHOR_ID"]):
						CForumUser::SetStat($arMessage["AUTHOR_ID"], array("MESSAGE" => $arMessage, "ACTION" => "UPDATE"));
					endif;
					if ($arMessage["TOPIC_ID"] == $arMessage_prev["TOPIC_ID"]):
						CForumTopic::SetStat($arMessage["TOPIC_ID"]);
					endif;
					if ($arMessage["FORUM_ID"] == $arMessage_prev["FORUM_ID"]):
						CForumNew::SetStat($arMessage["FORUM_ID"], array("MESSAGE" => $arMessage, "ACTION" => "UPDATE"));
					endif;
					$bUpdatedStatistic = true;
				endif;
			}
			$arForum = CForumNew::GetByID($arMessage["FORUM_ID"]);
			if (CModule::IncludeModule("search") && $arForum["INDEXATION"] == "Y")
			{
				// if message was removed from indexing forum to no-indexing forum we must delete index
				if ($arMessage_prev["FORUM_INFO"]["INDEXATION"] == "Y" &&
					$arMessage["FORUM_INFO"]["INDEXATION"] != "Y")
				{
					CSearch::DeleteIndex("forum", $ID);
				}
				elseif ($arMessage["FORUM_INFO"]["INDEXATION"] == "Y" &&
					$arMessage_prev["APPROVED"] != "N" && $arMessage["APPROVED"] == "N")
				{
					CSearch::DeleteIndex("forum", $ID);
				}
				elseif ($arMessage["APPROVED"] == "Y")
				{
					CForumMessage::Reindex($ID, $arMessage);
				}
			}
		}
		return $ID;
	}
开发者ID:ASDAFF,项目名称:bxApiDocs,代码行数:101,代码来源:message.php


注:本文中的CForumMessage::Reindex方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。