當前位置: 首頁>>代碼示例>>PHP>>正文


PHP CForumTopic::CheckFields方法代碼示例

本文整理匯總了PHP中CForumTopic::CheckFields方法的典型用法代碼示例。如果您正苦於以下問題:PHP CForumTopic::CheckFields方法的具體用法?PHP CForumTopic::CheckFields怎麽用?PHP CForumTopic::CheckFields使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在CForumTopic的用法示例。


在下文中一共展示了CForumTopic::CheckFields方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: Update

 function Update($ID, $arFields, $skip_counts = False)
 {
     global $DB;
     $ID = intVal($ID);
     $arFields1 = array();
     $arFieldsForFilter = array();
     $bNeedFilter = false;
     if ($ID <= 0 || !CForumTopic::CheckFields("UPDATE", $arFields)) {
         return false;
     }
     /***************** Event onBeforeTopicUpdate **************************/
     $events = GetModuleEvents("forum", "onBeforeTopicUpdate");
     while ($arEvent = $events->Fetch()) {
         if (ExecuteModuleEventEx($arEvent, array(&$ID, &$arFields)) === false) {
             return false;
         }
     }
     /***************** /Event ******************************************/
     if (empty($arFields)) {
         return false;
     }
     foreach ($arFields as $key => $value) {
         if (substr($key, 0, 1) == "=") {
             $arFields1[substr($key, 1)] = $value;
             unset($arFields[$key]);
         }
     }
     if (!$skip_counts && is_set($arFields, "FORUM_ID") || COption::GetOptionString("forum", "FILTER", "Y") == "Y" || (is_set($arFields, "TITLE") || is_set($arFields, "TAGS")) && IsModuleInstalled("search")) {
         $arTopic_prev = CForumTopic::GetByID($ID, array("NoFilter" => true));
     }
     // Fields "HTML".
     if (COption::GetOptionString("forum", "FILTER", "Y") == "Y") {
         $arFieldsForFilter = array("TITLE" => is_set($arFields, "TITLE") ? $arFields["TITLE"] : $arTopic_prev["TITLE"], "TAGS" => is_set($arFields, "TAGS") ? $arFields["TAGS"] : $arTopic_prev["TAGS"], "DESCRIPTION" => is_set($arFields, "DESCRIPTION") ? $arFields["DESCRIPTION"] : $arTopic_prev["DESCRIPTION"], "LAST_POSTER_NAME" => is_set($arFields, "LAST_POSTER_NAME") ? $arFields["LAST_POSTER_NAME"] : $arTopic_prev["LAST_POSTER_NAME"], "ABS_LAST_POSTER_NAME" => is_set($arFields, "ABS_LAST_POSTER_NAME") ? $arFields["ABS_LAST_POSTER_NAME"] : $arTopic_prev["ABS_LAST_POSTER_NAME"], "USER_START_NAME" => is_set($arFields, "USER_START_NAME") ? $arFields["USER_START_NAME"] : $arTopic_prev["USER_START_NAME"]);
         $bNeedFilter = false;
         foreach ($arFieldsForFilter as $key => $val) {
             if (is_set($arFields, $key)) {
                 $bNeedFilter = true;
                 break;
             }
         }
         if ($bNeedFilter) {
             foreach ($arFieldsForFilter as $key => $val) {
                 $res = CFilterUnquotableWords::Filter($val);
                 if (empty($res) && !empty($val)) {
                     $res = "*";
                 }
                 $arFieldsForFilter[$key] = $res;
             }
             $arFields["HTML"] = serialize($arFieldsForFilter);
         }
     }
     $strUpdate = $DB->PrepareUpdate("b_forum_topic", $arFields);
     foreach ($arFields1 as $key => $value) {
         if (strLen($strUpdate) > 0) {
             $strUpdate .= ", ";
         }
         $strUpdate .= $key . "=" . $value . " ";
     }
     if (!empty($strUpdate)) {
         $strSql = "UPDATE b_forum_topic SET " . $strUpdate . " WHERE ID = " . $ID;
         $DB->QueryBind($strSql, array("HTML" => $arFields["HTML"]), false, "FILE: " . __FILE__ . "<br> LINE: " . __LINE__);
     }
     $res = array_merge($arFields1, $arFields);
     if (count($res) == 1 && !empty($res["VIEWS"])) {
         if (intVal($res["VIEWS"]) <= 0) {
             $GLOBALS["FORUM_CACHE"]["TOPIC"][$ID]["VIEWS"]++;
             $GLOBALS["FORUM_CACHE"]["TOPIC_FILTER"][$ID]["VIEWS"]++;
         } else {
             $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));
     }
//.........這裏部分代碼省略.........
開發者ID:k-kalashnikov,項目名稱:geekcon_new,代碼行數:101,代碼來源:topic.php


注:本文中的CForumTopic::CheckFields方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。