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]);
             }
 $cache_path = $cache_path_main . "forums";
 if ($arParams["CACHE_TIME"] > 0 && $cache->InitCache($arParams["CACHE_TIME"], $cache_id, $cache_path)) {
     $res = $cache->GetVars();
     $arForums = CForumCacheManager::Expand($res["arForums"]);
 }
 $arForums = is_array($arForums) ? $arForums : array();
 if (empty($arForums)) {
     $db_res = CForumNew::GetListEx(array("FORUM_GROUP_SORT" => "ASC", "FORUM_GROUP_ID" => "ASC", "SORT" => "ASC", "NAME" => "ASC"), $arFilter);
     if ($db_res && ($res = $db_res->GetNext())) {
         do {
             $arForums[$res["ID"]] = $res;
         } while ($res = $db_res->GetNext());
     }
     if ($arParams["CACHE_TIME"] > 0) {
         $cache->StartDataCache($arParams["CACHE_TIME"], $cache_id, $cache_path);
         $cache->EndDataCache(array("arForums" => CForumCacheManager::Compress($arForums)));
     }
 }
 $arResult["FORUMS"] = $arForums;
 $arGroupsForums = array();
 $arGroups = array();
 foreach ($arResult["FORUMS"] as $key => $res) {
     $arGroupsForums[$res["FORUM_GROUP_ID"]][$key] = $res;
 }
 foreach ($arGroupsForums as $PARENT_ID => $res) {
     $bResult = true;
     $res = array("FORUMS" => $res);
     while ($PARENT_ID > 0) {
         if (!array_key_exists($PARENT_ID, $arResult["GROUPS"])) {
             $bResult = false;
             $PARENT_ID = false;
Example #3
0
                $res["user_start_id_profile"] = $res["URL"]["AUTHOR"];
                // For custom
                $res["read"] = $res["URL"]["READ"];
                // For custom
                $arTopics[] = $res;
            }
        }
    }
    $arResult['TOPICS'] = CForumCacheManager::Compress($arTopics);
    $arResult['FORUMS'] = CForumCacheManager::Compress($arForums);
    $this->EndResultCache();
    $arResult['TOPICS'] = $arTopics;
    $arResult['FORUMS'] = $arForums;
} else {
    $arResult['TOPICS'] = CForumCacheManager::Expand($arResult['TOPICS']);
    $arResult['FORUMS'] = CForumCacheManager::Expand($arResult['FORUMS']);
}
$arResult["TOPIC"] = $arResult["TOPICS"];
// For custom
$arResult["FORUM"] = $arResult["FORUMS"];
// For custom
$this->IncludeComponentTemplate();
/********************************************************************
			Data
********************************************************************/
if ($arParams["SET_NAVIGATION"] != "N") {
    $APPLICATION->AddChainItem(GetMessage("FTP_INDEX"), CComponentEngine::MakePathFromTemplate($arParams["URL_TEMPLATES_INDEX"], array()));
}
if ($arParams["SET_TITLE"] != "N") {
    $APPLICATION->SetTitle(GetMessage("FTP_TITLE"));
}
Example #4
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 #5
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 #6
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 #7
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;
 }
Example #8
0
function ForumDeleteTopic($topic, &$strErrorMessage, &$strOKMessage, $arAddParams = array())
{
    global $USER;
    $arError = array();
    $arOk = array();
    $arAddParams = !is_array($arAddParams) ? array($arAddParams) : $arAddParams;
    $arAddParams["PERMISSION"] = !empty($arAddParams["PERMISSION"]) ? $arAddParams["PERMISSION"] : false;
    $topic = ForumDataToArray($topic);
    if (empty($topic)) {
        $arError[] = GetMessage("DELTOP_NO_TOPIC");
    } else {
        if (!CForumUser::IsAdmin() && !$arAddParams["PERMISSION"]) {
            $db_res = CForumTopic::GetListEx(array(), array("@ID" => implode(",", $topic), "PERMISSION_STRONG" => true));
        } else {
            $db_res = CForumTopic::GetListEx(array(), array("@ID" => implode(",", $topic)));
        }
        if ($db_res && ($res = $db_res->Fetch())) {
            do {
                if (CForumTopic::CanUserDeleteTopic($res["ID"], $USER->GetUserGroupArray(), $USER->GetID(), $arAddParams["PERMISSION"])) {
                    if (CForumTopic::Delete($res["ID"])) {
                        $arOk[] = GetMessage("DELTOP_OK") . " (TID=" . intVal($res["ID"]) . ")";
                        CForumCacheManager::ClearTag("F", $res['FORUM_ID']);
                        CForumCacheManager::ClearTag("T", $res["ID"]);
                        CForumEventLog::Log("topic", "delete", $res["ID"], serialize($res));
                    } else {
                        $arError[] = GetMessage("DELTOP_NO") . " (TID=" . intVal($res["ID"]) . ")";
                    }
                } else {
                    $arError[] = GetMessage("DELTOP_NO_PERMS") . " (TID=" . intVal($res["ID"]) . ")";
                }
            } while ($res = $db_res->Fetch());
        } else {
            $arError[] = GetMessage("FMT_NO_PERMS_EDIT");
        }
    }
    if (count($arError) > 0) {
        $strErrorMessage .= implode(".\n", $arError) . ".\n";
    }
    if (count($arOk) > 0) {
        $strOKMessage .= implode(".\n", $arOk) . ".\n";
    }
    if (count($arError) > 0) {
        return false;
    } else {
        return true;
    }
}
 private static function getDataToCheck($messageId)
 {
     $return = false;
     if ($messageId > 0 && Loader::includeModule("forum")) {
         if (!array_key_exists($messageId, self::$messages)) {
             $cacheTtl = 2592000;
             $cacheId = 'forum_message_' . $messageId;
             $cachePath = \CComponentEngine::makeComponentPath("forum.topic.read");
             $cache = new \CPHPCache();
             $messages = $topics = array();
             if ($cache->initCache($cacheTtl, $cacheId, $cachePath)) {
                 list($messages, $topics) = $cache->getVars();
             } else {
                 $dbRes = \CForumMessage::getListEx(array("ID" => "ASC"), array("TOPIC" => "Y", "TOPIC_MESSAGE_ID" => $messageId, ">=ID" => $messageId), false, 10);
                 while ($res = $dbRes->fetch()) {
                     $messages["M" . $res["ID"]] = array_intersect_key($res, array("ID" => "", "TOPIC_ID" => "", "FORUM_ID" => "", "USER_ID" => "", "NEW_TOPIC" => "", "PARAM1" => "", "PARAM2" => ""));
                     if (!array_key_exists("T" . $res["TOPIC_ID"], $topics)) {
                         $topics["T" . $res["TOPIC_ID"]] = array("TITLE" => $res["TITLE"], "USER_ID" => $res["USER_START_ID"], "XML_ID" => $res["TOPIC_XML_ID"], "SOCNET_GROUP_ID" => $res["TOPIC_SOCNET_GROUP_ID"], "OWNER_ID" => $res["TOPIC_OWNER_ID"]);
                     }
                 }
                 if (!empty($messages)) {
                     $cache->startDataCache();
                     $res = reset($topics);
                     /** @noinspection PhpDynamicAsStaticMethodCallInspection */
                     \CForumCacheManager::setTag($cachePath, "forum_topic_" . $res['ID']);
                     $cache->endDataCache(array($messages, $topics));
                 }
             }
             self::$messages += $messages;
             self::$topics += $topics;
         }
         if (array_key_exists("M" . $messageId, self::$messages)) {
             $return = array(self::$messages["M" . $messageId], self::$topics["T" . self::$messages["M" . $messageId]["TOPIC_ID"]], \CForumNew::getByIDEx(self::$messages["M" . $messageId]["FORUM_ID"], SITE_ID));
         }
     }
     return $return;
 }