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


PHP CForumUser::GetListUserForumLastVisit方法代码示例

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


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

示例1: ForumInitParams

function ForumInitParams()
{
    //	unset($_SESSION["FORUM"]);
    $UserLogin = "GUEST";
    $LastVisit = time() + CTimeZone::GetOffset();
    if ($GLOBALS["USER"]->IsAuthorized()) {
        if (!is_array($_SESSION["FORUM"]["USER"]) || $_SESSION["FORUM"]["USER"]["USER_ID"] != $GLOBALS["USER"]->GetID()) {
            $_SESSION["FORUM"]["USER"] = CForumUser::GetByUSER_ID($GLOBALS["USER"]->GetID());
            if ($_SESSION["FORUM"]["USER"]) {
                $_SESSION["FORUM"]["USER"]["LAST_VISIT_TIMESTAMP"] = MakeTimeStamp($_SESSION["FORUM"]["USER"]["LAST_VISIT"]);
            } else {
                $_SESSION["FORUM"]["USER"] = array();
                $_SESSION["FORUM"]["USER"]["LAST_VISIT_TIMESTAMP"] = CForumNew::GetNowTime("timestamp");
            }
        } elseif (empty($_SESSION["FORUM"]["USER"]["LAST_VISIT_TIMESTAMP"])) {
            $_SESSION["FORUM"]["USER"]["LAST_VISIT_TIMESTAMP"] = CForumNew::GetNowTime("timestamp");
        }
        $arUser = $_SESSION["FORUM"]["USER"];
        $UserLogin = $GLOBALS["USER"]->GetLogin();
        $LastVisit = $_SESSION["FORUM"]["USER"]["LAST_VISIT_TIMESTAMP"];
        // if info for this user is not exist that info gets from DB
        if (!is_array($_SESSION["FORUM"][$UserLogin]) || intVal($_SESSION["FORUM"][$UserLogin][0]) <= 0) {
            $_SESSION["FORUM"][$UserLogin] = array();
            $db_res = CForumUser::GetListUserForumLastVisit(array(), array("USER_ID" => $GLOBALS["USER"]->GetID()));
            if ($db_res && ($res = $db_res->Fetch())) {
                do {
                    $_SESSION["FORUM"][$UserLogin][intVal($res["FORUM_ID"])] = MakeTimeStamp($res["LAST_VISIT"]);
                } while ($res = $db_res->Fetch());
            }
            if (intVal($_SESSION["FORUM"][$UserLogin][0]) <= 0) {
                $_SESSION["FORUM"][$UserLogin] = array();
                CForumUser::SetUserForumLastVisit($GLOBALS["USER"]->GetID(), 0, false);
                $db_res = CForumUser::GetListUserForumLastVisit(array(), array("USER_ID" => $GLOBALS["USER"]->GetID(), "FORUM_ID" => 0));
                if ($db_res && ($res = $db_res->Fetch())) {
                    $_SESSION["FORUM"][$UserLogin][0] = MakeTimeStamp($res["LAST_VISIT"]);
                } else {
                    $_SESSION["FORUM"][$UserLogin][0] = $LastVisit;
                }
            }
        }
        // synhronize guest session with authorized user session
        if (is_array($_SESSION["FORUM"]["GUEST_TID"]) && !empty($_SESSION["FORUM"]["GUEST_TID"])) {
            foreach ($_SESSION["FORUM"]["GUEST_TID"] as $key => $val) {
                CForumTopic::SetReadLabelsNew($key, false, $val, array("UPDATE_TOPIC_VIEWS" => "N"));
            }
        }
        //		if (is_array($_SESSION["FORUM"]["GUEST"]) && (!empty($_SESSION["FORUM"]["GUEST"])))
        //		{
        //			foreach ($_SESSION["FORUM"]["GUEST"] as $key => $val)
        //			{
        //				if (intVal($val) > intVal($_SESSION["FORUM"][$UserLogin][intVal($key)]))
        //					$_SESSION["FORUM"][$UserLogin][intVal($key)] = intVal($val);
        //			}
        //		}
        unset($_SESSION["FORUM"]["GUEST_TID"]);
        unset($_SESSION["FORUM"]["GUEST"]);
    } else {
        if (!isset($_SESSION["FORUM"]["GUEST"]) || !is_array($_SESSION["FORUM"]["GUEST"])) {
            $forum_cookie = COption::GetOptionString("main", "cookie_name", "BITRIX_SM") . "_FORUM_GUEST";
            if (isset($_COOKIE[$forum_cookie]) && strlen($_COOKIE[$forum_cookie]) > 0) {
                $arForum = explode("/", $_COOKIE[$forum_cookie]);
                if (is_array($arForum) && count($arForum) > 0) {
                    foreach ($arForum as $forumInfo) {
                        list($f, $lv) = explode("-", $forumInfo);
                        $_SESSION["FORUM"]["GUEST"][intVal($f)] = intVal($lv);
                    }
                }
            }
        }
        if (!isset($_SESSION["FORUM"]["GUEST"]) || !is_array($_SESSION["FORUM"]["GUEST"]) || intVal($_SESSION["FORUM"]["GUEST"][0]) < 0) {
            $_SESSION["FORUM"]["GUEST"] = array();
            $_SESSION["FORUM"]["GUEST"][0] = CForumNew::GetNowTime();
        }
        // All geting info put in cookies
        if (COption::GetOptionString("forum", "USE_COOKIE", "N") == "Y") {
            $arCookie = array();
            foreach ($_SESSION["FORUM"]["GUEST"] as $key => $val) {
                $arCookie[] = $key . "-" . $val;
            }
            $GLOBALS["APPLICATION"]->set_cookie("FORUM_GUEST", implode("/", $arCookie), false, "/", false, false, "Y", false);
        }
        //		It need to save info about visited topics for GUEST in cookies
        if (!isset($_SESSION["FORUM"]["GUEST_TID"]) || !is_array($_SESSION["FORUM"]["GUEST_TID"])) {
            $_SESSION["FORUM"]["GUEST_TID"] = array();
            $topic_cookie = COption::GetOptionString("main", "cookie_name", "BITRIX_SM") . "_FORUM_GUEST_TID";
            if (isset($_COOKIE[$topic_cookie]) && strlen($_COOKIE[$topic_cookie]) > 0) {
                $arTopic = explode("/", $_COOKIE[$topic_cookie]);
                if (is_array($arTopic) && count($arTopic) > 0) {
                    foreach ($arTopic as $topicInfo) {
                        list($f, $lv) = explode("-", $topicInfo);
                        $_SESSION["FORUM"]["GUEST_TID"][intVal($f)] = intVal($lv);
                    }
                }
            }
        }
    }
    // cleaning session date.
    if (is_array($_SESSION["FORUM"])) {
        foreach ($_SESSION["FORUM"] as $key => $val) {
            if (substr($key, 0, strLen("LAST_VISIT_FORUM_")) == "LAST_VISIT_FORUM_") {
//.........这里部分代码省略.........
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:101,代码来源:include.php


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