Example #1
0
     $res["MODERATE"] = array("TOPICS" => 0, "POSTS" => intVal($res["POSTS_UNAPPROVED"]));
     $res["mCnt"] = $res["MODERATE"]["POSTS"];
     $res["TITLE"] = $parser->wrap_long_words($res["TITLE"]);
     $res["LAST_POSTER_NAME"] = $parser->wrap_long_words($res["LAST_POSTER_NAME"]);
     $res["LAST_POST_DATE"] = intval($res["LAST_MESSAGE_ID"]) > 0 ? CForumFormat::DateFormat($arParams["DATE_TIME_FORMAT"], MakeTimeStamp($res["LAST_POST_DATE"], CSite::GetDateFormat())) : "";
     $res["URL"] = array("MODERATE_MESSAGE" => CComponentEngine::MakePathFromTemplate($arParams["URL_TEMPLATES_MESSAGE_APPR"], array("FID" => $res["ID"], "TID" => "s")), "TOPICS" => CComponentEngine::MakePathFromTemplate($arParams["URL_TEMPLATES_LIST"], array("FID" => $res["ID"])), "MESSAGE" => CComponentEngine::MakePathFromTemplate($arParams["URL_TEMPLATES_MESSAGE"], array("FID" => $res["ID"], "TID" => $res["TID"], "TITLE_SEO" => $res["TITLE_SEO"], "MID" => $res["LAST_MESSAGE_ID"])) . "#message" . $res["LAST_MESSAGE_ID"], "AUTHOR" => CComponentEngine::MakePathFromTemplate($arParams["URL_TEMPLATES_PROFILE_VIEW"], array("UID" => $res["LAST_POSTER_ID"])));
     /************** For custom template ********************************/
     $res["topic_list"] = $res["URL"]["TOPICS"];
     $res["message_appr"] = $res["URL"]["MODERATE_MESSAGE"];
     $res["message_list"] = $res["URL"]["MESSAGE"];
     $res["profile_view"] = $res["URL"]["AUTHOR"];
     /*******************************************************************/
     $res["FORUM_GROUP_ID"] = intVal($res["FORUM_GROUP_ID"]);
     $arGroupForum[$res["FORUM_GROUP_ID"]]["FORUM"][] = $res;
     $arResult["FORUMS_LIST"][$res["ID"]] = $res["ID"];
     CForumCacheManager::SetTag($this->GetCachePath(), "forum_msg_count" . $res["ID"]);
 }
 $arGroups = array();
 if (!function_exists("__array_merge")) {
     function __array_merge($arr1, $arr2)
     {
         $arResult = $arr1;
         foreach ($arr2 as $key2 => $val2) {
             if (!array_key_exists($key2, $arResult)) {
                 $arResult[$key2] = $val2;
                 continue;
             } elseif ($val2 == $arResult[$key2]) {
                 continue;
             } elseif (!is_array($arResult[$key2])) {
                 $arResult[$key2] = array($arResult[$key2]);
             }
Example #2
0
        $db_res1 = CForumTopic::GetListEx(array("SORT" => "ASC"), array("@ID" => $topicLinks));
        $topicLinks1 = array();
        while ($res = $db_res1->GetNext()) {
            $key = array_search($res["ID"], $topicLinks);
            if (array_key_exists($key, $arResult["Topics"])) {
                $arResult["Topics"][$key]["URL"] = array_merge($arResult["Topics"][$key]["URL"], array("TOPIC" => CComponentEngine::MakePathFromTemplate($arParams["URL_TEMPLATES_READ"], array("FID" => $res["FORUM_ID"], "TID" => $res["ID"], "TITLE_SEO" => $res["TITLE_SEO"], "MID" => "s")), "~TOPIC" => CComponentEngine::MakePathFromTemplate($arParams["~URL_TEMPLATES_READ"], array("FID" => $res["FORUM_ID"], "TID" => $res["ID"], "TITLE_SEO" => $res["TITLE_SEO"], "MID" => "s")), "LAST_MESSAGE" => CComponentEngine::MakePathFromTemplate($arParams["URL_TEMPLATES_MESSAGE"], array("FID" => $res["FORUM_ID"], "TID" => $res["ID"], "TITLE_SEO" => $res["TITLE_SEO"], "MID" => intVal($res["LAST_MESSAGE_ID"]))), "~LAST_MESSAGE" => CComponentEngine::MakePathFromTemplate($arParams["~URL_TEMPLATES_MESSAGE"], array("FID" => $res["FORUM_ID"], "TID" => $res["ID"], "TITLE_SEO" => $res["TITLE_SEO"], "MID" => intVal($res["LAST_MESSAGE_ID"]))), "MESSAGE_UNREAD" => CComponentEngine::MakePathFromTemplate($arParams["URL_TEMPLATES_MESSAGE"], array("FID" => $res["FORUM_ID"], "TID" => $res["ID"], "TITLE_SEO" => $res["TITLE_SEO"], "MID" => "unread_mid")), "~MESSAGE_UNREAD" => CComponentEngine::MakePathFromTemplate($arParams["~URL_TEMPLATES_MESSAGE"], array("FID" => $res["FORUM_ID"], "TID" => $res["ID"], "TITLE_SEO" => $res["TITLE_SEO"], "MID" => "unread_mid"))));
            }
        }
    }
    /*******************************************************************
    				CACHE
    *******************************************************************/
    if ($PAGEN == null && $arParams["CACHE_TIME"] > 0 && defined("BX_COMP_MANAGED_CACHE")) {
        $cache->StartDataCache($arParams["CACHE_TIME"], $cache_id, $cache_path);
        CForumCacheManager::SetTag($cache_path, "forum_msg_count" . $arParams['FID']);
        CForumCacheManager::SetTag($cache_path, "forum_" . $arParams['FID']);
        $cache->EndDataCache(array("Topics" => $arResult["Topics"], "NAV_STRING" => $arResult['NAV_STRING'], "NAV_PAGE" => $arResult['NAV_PAGE']));
    }
    /*******************************************************************
    				/ CACHE
    *******************************************************************/
}
$topicCount = sizeof($arResult['Topics']);
for ($topicID = 0; $topicID < $topicCount; $topicID++) {
    $tres =& $arResult['Topics'][$topicID];
    if ($tres["TopicStatus"] == "OLD" && NewMessageTopic($tres["FORUM_ID"], $tres["ID"], $arResult["PERMISSION"] < "Q" ? $tres["LAST_POST_DATE"] : $tres["ABS_LAST_POST_DATE"], $tres["LAST_VISIT"])) {
        $tres["TopicStatus"] = "NEW";
    }
}
$arResult["TOPICS"] = $arResult["Topics"];
/************** Navigation *****************************************/
Example #3
0
                    $res["FOR_JS"]["AUTHOR_NAME"] = CUtil::JSEscape($res["AUTHOR_NAME"]);
                    $res["FOR_JS"]["POST_MESSAGE_TEXT"] = CUtil::JSEscape(htmlspecialcharsbx($res["POST_MESSAGE_TEXT"]));
                    $res["NEW"] = $arResult["UNREAD_MID"] > 0 && $res["ID"] >= $arResult["UNREAD_MID"] ? "Y" : "N";
                    $arMessages[$res["ID"]] = $res;
                }
            }
            $arResult["MESSAGES"] = $arMessages;
            unset($arMessages);
            foreach (GetModuleEvents('forum', 'OnPrepareComments', true) as $arEvent) {
                $result = ExecuteModuleEventEx($arEvent);
            }
            $parser->arFiles = $arResult["FILES"];
            foreach ($arResult["MESSAGES"] as $iID => $res) {
                $parser->arUserfields = $arResult["MESSAGES"][$iID]["PROPS"] = array_key_exists($res["ID"], $arResult["UFS"]) ? $arResult["UFS"][$res["ID"]] : array();
                $arResult["MESSAGES"][$iID]["POST_MESSAGE_TEXT"] = $parser->convert($res["~POST_MESSAGE_TEXT"], $res["ALLOW"]);
                $arResult["MESSAGES"][$iID]["FILES_PARSED"] = $parser->arFilesIDParsed;
            }
            if (defined("BX_COMP_MANAGED_CACHE")) {
                CForumCacheManager::SetTag($this->GetCachePath(), "forum_topic_" . $arResult['FORUM_TOPIC_ID']);
            }
        } else {
            $GLOBALS["NavNum"]++;
        }
    }
    $this->IncludeComponentTemplate();
}
$output = ob_get_clean();
foreach (GetModuleEvents('forum', 'OnCommentsDisplayTemplate', true) as $arEvent) {
    ExecuteModuleEventEx($arEvent, array(&$output, $arParams, $arResult));
}
echo $output;
Example #4
0
				while ($db_props && ($res = $db_props->Fetch()))
				{
					$arMessages[$res["ID"]]["PROPS"] = array_intersect_key($res, array_flip($arParams["USER_FIELDS"]));
				}
			}
			/************** Message info ***************************************/
			$parser->arFiles = $arResult["FILES"];
			foreach ($arMessages as $iID => $res)
				$arMessages[$iID]["POST_MESSAGE_TEXT"] = $parser->convert($res["~POST_MESSAGE_TEXT"], array_merge($res["ALLOW"], array("USERFIELDS" => $res["PROPS"])));
		}

/************** Message List/***************************************/
		if ($arParams["CACHE_TIME"] > 0)
		{
			$cache->StartDataCache();
			CForumCacheManager::SetTag($cache_path, "forum_topic_".$arResult["FORUM_TOPIC_ID"]);
			$cache->EndDataCache(array(
				"arMessages" => $arMessages,
				"Nav" => array(
					"NAV_RESULT" => $arResult["NAV_RESULT"],
					"NAV_STYLE"  => $arResult["NAV_STYLE"],
					"NAV_STRING" => $arResult["NAV_STRING"])));
		}
	}
	else
	{
		$GLOBALS["NavNum"]++;
		if ($arAllow["VIDEO"] == "Y")
		{
			foreach ($arMessages as $key => $res):
				$arAllow["SMILES"] = ($res["USE_SMILES"] == "Y" ? $arResult["FORUM"]["ALLOW_SMILES"] : "N");
Example #5
0
 function GetMessageCount($forumID, $topicID, $approved = null)
 {
     global $CACHE_MANAGER;
     static $arCacheCount = array();
     static $obCache = null;
     static $cacheLabel = 'forum_msg_count';
     static $notCached = 0;
     static $TTL = 3600000;
     if ($approved === true) {
         $approved = "Y";
     }
     if ($approved === false) {
         $approved = "N";
     }
     if ($approved === null) {
         $approved = "A";
     }
     if ($approved !== "Y" && $approved !== "N" && $approved !== "A") {
         return false;
     }
     if (isset($arCacheCount[$forumID][$topicID][$approved])) {
         return $arCacheCount[$forumID][$topicID][$approved];
     }
     if ($obCache === null) {
         $obCache = new CPHPCache();
     }
     $cacheID = md5($cacheLabel . $forumID);
     $cachePath = str_replace(array(":", "//"), "/", "/" . SITE_ID . "/" . $cacheLabel . "/");
     if ($obCache->InitCache($TTL, $cacheID, $cachePath)) {
         $resCache = $obCache->GetVars();
         if (is_array($resCache['messages'])) {
             $arCacheCount[$forumID] = $resCache['messages'];
         }
     }
     if (isset($arCacheCount[$forumID][$topicID][$approved])) {
         return $arCacheCount[$forumID][$topicID][$approved];
     } else {
         $bCount = true;
         if ($approved === "N" || $approved === "Y") {
             $bCount = "cnt_not_approved";
         }
         if (intval($topicID) > 0 || $topicID === 0) {
             $arFilter = array("TOPIC_ID" => $topicID);
         } else {
             $arRes = CForumTopic::GetByID($topicID);
             if ($arRes) {
                 $arFilter = array("TOPIC_ID" => $arRes['ID']);
             } else {
                 return false;
             }
         }
         $count = CForumMessage::GetList(null, $arFilter, $bCount);
         $result = 0;
         if ($approved === "N") {
             $result = intval($count['CNT_NOT_APPROVED']);
         } elseif ($approved === "Y") {
             $result = $count['CNT'] - $count['CNT_NOT_APPROVED'];
         } else {
             $result = intval($count);
         }
         $notCached++;
     }
     $arCacheCount[$forumID][$topicID][$approved] = $result;
     if ($notCached > 2) {
         $obCache->StartDataCache($TTL, $cacheID, $cachePath);
         CForumCacheManager::SetTag($cachePath, $cacheLabel . $forumID);
         $obCache->EndDataCache(array("messages" => $arCacheCount[$forumID]));
         $notCached = 0;
     }
     return $result;
 }