- Модуль: forum
- Путь к файлу: ~/bitrix/modules/forum/classes/general/forum_new.php
- Класс: CAllForumNew
- Вызов: CAllForumNew::InitReadLabels
static function InitReadLabels($ID, $arUserGroups) // out-of-date function
{
$ID = intval($ID);
if ($ID <= 0)
return false;
$arForumCookie = array();
$iCurFirstReadForum = 0;
$read_forum_cookie = COption::GetOptionString("main", "cookie_name", "BITRIX_SM")."_FORUM_0";
if (isset($_COOKIE[$read_forum_cookie]) && $_COOKIE[$read_forum_cookie] <> '')
{
$arForumCookie = explode("/", $_COOKIE[$read_forum_cookie]);
$i = 0;
while ($i < count($arForumCookie))
{
if (intval($arForumCookie[$i]) == $ID)
{
$iCurFirstReadForum = intval($arForumCookie[$i+1]);
break;
}
$i += 2;
}
}
$read_forum_cookie1 = COption::GetOptionString("main", "cookie_name", "BITRIX_SM")."_FORUM_".$ID;
if (isset($_COOKIE[$read_forum_cookie1]) && intval($_COOKIE[$read_forum_cookie1]) > 0)
{
if ($iCurFirstReadForum < intval($_COOKIE[$read_forum_cookie1]))
{
$iCurFirstReadForum = intval($_COOKIE[$read_forum_cookie1]);
}
}
if ($_SESSION["first_read_forum_".$ID] == '' || intval($_SESSION["first_read_forum_".$ID])<0)
{
$_SESSION["first_read_forum_".$ID] = $iCurFirstReadForum;
}
if (is_null($_SESSION["read_forum_".$ID]) || $_SESSION["read_forum_".$ID] == '')
{
$_SESSION["read_forum_".$ID] = "0";
}
$iLastPostID = 0;
$strPerms = CForumNew::GetUserPermission($ID, $arUserGroups);
if ($strPerms > "Q"):
$db_res = CForumMessage::GetList(array("ID"=>"DESC"), array("FORUM_ID" => $ID, "APPROVED" => "N"), false, 1);
if ($db_res && $res = $db_res->Fetch()):
$iLastPostID = intval($res["ID"]);
endif;
endif;
if ($iLastPostID <= 0):
$res = CForumNew::GetByID($ID);
$iLastPostID = intval($res["LAST_MESSAGE_ID"]);
endif;
if ($iLastPostID > 0)
{
$i = 0;
$arCookieVal = array();
while ($i < count($arForumCookie))
{
if (intval($arForumCookie[$i]) != $ID)
{
$arCookieVal[] = intval($arForumCookie[$i])."/".intval($arForumCookie[$i + 1]);
}
$i += 2;
}
$arCookieVal[] = $ID."/".$iLastPostID;
//$GLOBALS["APPLICATION"]->set_cookie($read_forum_cookie, $strCookieVal, false, "/", false, false, "Y", "");
$GLOBALS["APPLICATION"]->set_cookie("FORUM_0", implode("/", $arCookieVal), false, "/", false, false, "Y", false);
}
return true;
}