Example #1
0
         $cache_path = "/blog/socnet_post/" . intval($arPost["ID"] / 100) . "/" . $arPost["ID"] . "/";
         $cache_id = "blog_socnet_post_read_" . $GLOBALS["USER"]->GetID();
         if ($cache->InitCache($arParams["CACHE_TIME"], $cache_id, $cache_path)) {
             $arResult["Post"]["IMPORTANT"] = $cache->GetVars();
         } else {
             $cache->StartDataCache($arParams["CACHE_TIME"], $cache_id, $cache_path);
             if (defined("BX_COMP_MANAGED_CACHE")) {
                 $GLOBALS["CACHE_MANAGER"]->StartTagCache($cache_path);
                 $GLOBALS["CACHE_MANAGER"]->RegisterTag("BLOG_POST_IMPRTNT" . $arPost["ID"]);
             }
             $db_user = CUser::GetById($GLOBALS["USER"]->GetId());
             $arResult["Post"]["IMPORTANT"]["USER"] = $db_user->Fetch();
             $db_res = CBlogUserOptions::GetList(array("ID" => "ASC"), array("POST_ID" => $arResult["Post"]["ID"], "NAME" => "BLOG_POST_IMPRTNT", "VALUE" => "Y", "USER_ACTIVE" => "Y"), array("bCount" => true));
             if ($db_res && ($res = $db_res->Fetch()) && $res["CNT"] > 0) {
                 $arResult["Post"]["IMPORTANT"]["COUNT"] = $res["CNT"];
                 $arResult["Post"]["IMPORTANT"]["IS_READ"] = CBlogUserOptions::GetOption($arPost["ID"], "BLOG_POST_IMPRTNT", "N", $GLOBALS["USER"]->GetId());
             }
             if (defined("BX_COMP_MANAGED_CACHE")) {
                 $GLOBALS["CACHE_MANAGER"]->EndTagCache();
             }
             $cache->EndDataCache($arResult["Post"]["IMPORTANT"]);
         }
     }
 }
 if (isset($arResult["GRATITUDE"]) && isset($arResult["GRATITUDE"]["USERS"]) && is_array($arResult["GRATITUDE"]["USERS"]) && !empty($arResult["GRATITUDE"]["USERS"]) && isset($arUserIdVisible) && is_array($arUserIdVisible)) {
     foreach ($arResult["GRATITUDE"]["USERS"] as $key => $userIdTmp) {
         if (!in_array($userIdTmp, $arUserIdVisible)) {
             unset($arResult["GRATITUDE"]["USERS"][$key]);
         }
     }
     foreach ($arResult["GRATITUDE"]["USERS_FULL"] as $key => $arUserTmp) {
Example #2
0
 public static function getBlogPostUsersImprtnt($arFields)
 {
     if (!is_array($arFields)) {
         throw new Exception('Incorrect input data');
     }
     $arParams["postId"] = intval($arFields['POST_ID']);
     if ($arParams["postId"] <= 0) {
         throw new Exception('Wrong post ID');
     }
     $arParams["nTopCount"] = 500;
     $arParams["paramName"] = 'BLOG_POST_IMPRTNT';
     $arParams["paramValue"] = 'Y';
     $arResult = array();
     $cache = new CPHPCache();
     $cache_id = "blog_post_param_" . serialize(array($arParams["postId"], $arParams["nTopCount"], $arParams["paramName"], $arParams["paramValue"]));
     $cache_path = $GLOBALS["CACHE_MANAGER"]->GetCompCachePath(CComponentEngine::MakeComponentPath("socialnetwork.blog.blog")) . "/" . $arParams["postId"];
     $cache_time = defined("BX_COMP_MANAGED_CACHE") ? 3600 * 24 * 365 : 600;
     if ($cache->InitCache($cache_time, $cache_id, $cache_path)) {
         $arResult = $cache->GetVars();
     } else {
         $cache->StartDataCache($cache_time, $cache_id, $cache_path);
         if (CModule::IncludeModule("blog")) {
             if (defined("BX_COMP_MANAGED_CACHE")) {
                 $GLOBALS["CACHE_MANAGER"]->StartTagCache($cache_path);
                 $GLOBALS["CACHE_MANAGER"]->RegisterTag($arParams["paramName"] . $arParams["postId"]);
             }
             if ($arBlogPost = CBlogPost::GetByID($arParams["postId"])) {
                 $postPerms = CBlogPost::GetSocNetPostPerms($arParams["postId"], true, $GLOBALS["USER"]->GetID(), $arBlogPost["AUTHOR_ID"]);
                 if ($postPerms >= BLOG_PERMS_READ) {
                     $db_res = CBlogUserOptions::GetList(array(), array('POST_ID' => $arParams["postId"], 'NAME' => $arParams["paramName"], 'VALUE' => $arParams["paramValue"], 'USER_ACTIVE' => 'Y'), array("nTopCount" => $arParams["nTopCount"], "SELECT" => array("USER_ID")));
                     if ($db_res) {
                         while ($res = $db_res->Fetch()) {
                             $arResult[] = $res["USER_ID"];
                         }
                     }
                 }
             }
             if (defined("BX_COMP_MANAGED_CACHE")) {
                 $GLOBALS["CACHE_MANAGER"]->EndTagCache();
             }
             $cache->EndDataCache($arResult);
         }
     }
     return $arResult;
 }
Example #3
0
}
$arResult["NAV_RESULT"] = "";
$arResult["NAV_STRING"] = "";
$arResult["POST"] = array();
$arResult["IDS"] = array();
$arResult["userCache"] = array();
$arParams["FILTER"] = array_merge($arParams["FILTER"], $arFilter);
$PAGEN = $GLOBALS["PAGEN_" . ($GLOBALS["NavNum"] + 1)] || $arParams["PAGE_SETTINGS"]["iNumPage"];
$arCacheID = array("filter" => array_merge($arParams["FILTER"], $dfc === true ? array("<=DATE_PUBLISH" => "") : array()), $arParams["SORT"], array_intersect_key($arParams["PAGE_SETTINGS"], array("bDescPageNumbering" => false, "nPageSize" => 10)), CTimeZone::GetOffset(), $USER->GetID());
$cache_id = "blog_blog_" . md5(serialize($arCacheID));
/********************************************************************
				Actions
********************************************************************/
if (is_array($_REQUEST["options"]) && !empty($_REQUEST["options"]) && check_bitrix_sessid() && $USER->IsAuthorized() && CModule::IncludeModule("blog")) {
    foreach ($_REQUEST["options"] as $val) {
        CBlogUserOptions::SetOption($val["post_id"], $val["name"], $val["value"], $USER->GetID());
    }
    if (defined("BX_COMP_MANAGED_CACHE")) {
        $CACHE_MANAGER->ClearByTag($val["name"] . $val["post_id"]);
        $CACHE_MANAGER->ClearByTag($val["name"] . $val["post_id"] . "_" . $USER->GetID());
        $CACHE_MANAGER->ClearByTag($val["name"] . "_USER_" . $USER->GetID());
    } else {
        $obCache = new CPHPCache();
        $obCache->Clean($cache_id, $cache_path);
    }
    $db_events = GetModuleEvents("socialnetwork", "OnAfterCBlogUserOptionsSet");
    while ($arEvent = $db_events->Fetch()) {
        ExecuteModuleEventEx($arEvent, array($_REQUEST["options"], $cache_id, $cache_path));
    }
}
/********************************************************************
Example #4
0
 protected static function _clear_cache($user_id = 0)
 {
     global $CACHE_MANAGER;
     self::$__USER_OPTIONS_CACHE = array();
     if ($user_id > 0) {
         $CACHE_MANAGER->cleanDir("blog_post_param");
     } else {
         $CACHE_MANAGER->clean("user_option:{$user_id}", "blog_post_param");
     }
 }
Example #5
0
$arList = array("post_id" => $_REQUEST["post_id"], "items" => array(), "StatusPage" => "done", "RecordCount" => 0);
$arResult["nPageSize"] = 20;
$_REQUEST["post_id"] = intval($_REQUEST["post_id"]);
$_REQUEST["name"] = trim($_REQUEST["name"]);
$_REQUEST["value"] = trim($_REQUEST["value"]);
$_REQUEST["PATH_TO_USER"] = !empty($_REQUEST["PATH_TO_UER"]) ? $_REQUEST["PATH_TO_UER"] : (!empty($_REQUEST["PATH_TO_USER"]) ? $_REQUEST["PATH_TO_USER"] : '******');
$_REQUEST["NAME_TEMPLATE"] = !empty($_REQUEST["NAME_TEMPLATE"]) ? $_REQUEST["NAME_TEMPLATE"] : CSite::GetNameFormat(false);
if ($_REQUEST["post_id"] > 0 && !empty($_REQUEST["name"]) && !empty($_REQUEST["value"]) && check_bitrix_sessid()) {
    $arParams["CACHE_TIME"] = $_REQUEST["iNumPage"] >= 2 ? 0 : 600;
    global $CACHE_MANAGER;
    $cache = new CPHPCache();
    $cache_id = "blog_post_param_" . serialize(array($arResult["nPageSize"], $_REQUEST["post_id"], $_REQUEST["name"], $_REQUEST["iNumPage"], $_REQUEST["value"], $_REQUEST["NAME_TEMPLATE"], $_REQUEST["PATH_TO_USER"]));
    $cache_path = $CACHE_MANAGER->GetCompCachePath(CComponentEngine::MakeComponentPath("socialnetwork.blog.blog")) . "/" . $_REQUEST["post_id"];
    $arList = $arParams["CACHE_TIME"] > 0 && $cache->InitCache($arParams["CACHE_TIME"], $cache_id, $cache_path) ? $cache->GetVars() : array();
    if ((!is_array($arList) || empty($arList)) && CModule::IncludeModule("blog")) {
        $db_res = CBlogUserOptions::GetList(array("RANK" => "DESC", "OWNER_ID" => $GLOBALS["USER"]->GetID()), array("POST_ID" => $_REQUEST["post_id"], "NAME" => $_REQUEST["name"], "VALUE" => $_REQUEST["value"], "USER_ACTIVE" => "Y"), array("iNumPage" => $_REQUEST["iNumPage"] > 0 ? $_REQUEST["iNumPage"] : 0, "bDescPageNumbering" => false, "nPageSize" => $arResult["nPageSize"], "bShowAll" => false, "SELECT" => array("USER_ID", "USER_NAME", "USER_LAST_NAME", "USER_SECOND_NAME", "USER_LOGIN", "USER_PERSONAL_PHOTO")));
        if ($db_res && ($res = $db_res->Fetch())) {
            $arList["StatusPage"] = $db_res->NavPageNomer >= $db_res->NavPageCount || $arResult["nPageSize"] > $db_res->NavRecordCount ? "done" : "continue";
            $arList["RecordCount"] = $db_res->NavRecordCount;
            if ($_REQUEST["iNumPage"] <= $db_res->NavPageCount) {
                do {
                    $arUser = array("ID" => $res["USER_ID"], "PHOTO" => "", "FULL_NAME" => CUser::FormatName($_REQUEST["NAME_TEMPLATE"], array("NAME" => $res["USER_NAME"], "LAST_NAME" => $res["USER_LAST_NAME"], "SECOND_NAME" => $res["USER_SECOND_NAME"], "LOGIN" => $res["USER_LOGIN"])), "URL" => CUtil::JSEscape(CComponentEngine::MakePathFromTemplate($_REQUEST["PATH_TO_USER"], array("UID" => $res["USER_ID"], "user_id" => $res["USER_ID"], "USER_ID" => $res["USER_ID"]))));
                    if (array_key_exists("USER_PERSONAL_PHOTO", $res)) {
                        $arFileTmp = CFile::ResizeImageGet($res["USER_PERSONAL_PHOTO"], array("width" => 21, "height" => 21), BX_RESIZE_IMAGE_EXACT, false);
                        $arUser["PHOTO"] = CFile::ShowImage($arFileTmp["src"], 21, 21, "border=0");
                    }
                    $arList["items"][] = $arUser;
                } while ($res = $db_res->Fetch());
            }
        }
        if ($arParams["CACHE_TIME"] > 0 && !empty($arList["items"])) {
Example #6
0
$PAGEN=($GLOBALS["PAGEN_".($GLOBALS["NavNum"]+1)] || $arParams["PAGE_SETTINGS"]["iNumPage"]);
$arCacheID = array(
	"filter" => array_merge($arParams["FILTER"], ($dfc === true ? array("<=DATE_PUBLISH" => "") : array())),
	$arParams["SORT"],
	array_intersect_key($arParams["PAGE_SETTINGS"], array("bDescPageNumbering" => false, "nPageSize" => 10)),
	CTimeZone::GetOffset()
);
$cache_id = "blog_blog_".md5(serialize($arCacheID));
/********************************************************************
				Actions
********************************************************************/
if(is_array($_REQUEST["options"]) && !empty($_REQUEST["options"]) &&
	check_bitrix_sessid() && $USER->IsAuthorized() && CModule::IncludeModule("blog"))
{
	foreach($_REQUEST["options"] as $val) {
		CBlogUserOptions::SetOption($val["post_id"], $val["name"], $val["value"]);
	}
	$db_events = GetModuleEvents("socialnetwork", "OnAfterCBlogUserOptionsSet");
	while ($arEvent = $db_events->Fetch())
		ExecuteModuleEventEx($arEvent, Array($_REQUEST["options"], $cache_id, $cache_path));
}
/********************************************************************
				/Actions
********************************************************************/

if ($PAGEN == null && $arParams["CACHE_TIME"] > 0) // cache only the first page
{
	if ($cache->InitCache($arParams["CACHE_TIME"], $cache_id, $cache_path))
	{
		$arRes = $cache->GetVars();
		$arResult["POST"] = $arRes["POST"];