コード例 #1
0
 /**
  * @param $userId
  * @return bool
  */
 public function canRead($userId)
 {
     if ($this->canRead !== null) {
         return $this->canRead;
     }
     if (!Loader::includeModule('socialnetwork')) {
         return false;
     }
     $cacheTtl = 2592000;
     $cacheId = 'blog_post_socnet_general_' . $this->entityId . '_' . LANGUAGE_ID;
     $timezoneOffset = \CTimeZone::getOffset();
     if ($timezoneOffset != 0) {
         $cacheId .= "_" . $timezoneOffset;
     }
     $cacheDir = '/blog/socnet_post/gen/' . intval($this->entityId / 100) . '/' . $this->entityId;
     $cache = new \CPHPCache();
     if ($cache->initCache($cacheTtl, $cacheId, $cacheDir)) {
         $post = $cache->getVars();
     } else {
         $cache->startDataCache();
         $queryPost = \CBlogPost::getList(array(), array("ID" => $this->entityId), false, false, array("ID", "BLOG_ID", "PUBLISH_STATUS", "TITLE", "AUTHOR_ID", "ENABLE_COMMENTS", "NUM_COMMENTS", "VIEWS", "CODE", "MICRO", "DETAIL_TEXT", "DATE_PUBLISH", "CATEGORY_ID", "HAS_SOCNET_ALL", "HAS_TAGS", "HAS_IMAGES", "HAS_PROPS", "HAS_COMMENT_IMAGES"));
         $post = $queryPost->fetch();
         $cache->endDataCache($post);
     }
     if (!$post) {
         $this->canRead = false;
         return false;
     }
     /** @noinspection PhpDynamicAsStaticMethodCallInspection */
     $this->canRead = \CBlogPost::getSocNetPostPerms($this->entityId, true, $userId, $post["AUTHOR_ID"]) >= BLOG_PERMS_READ;
     return $this->canRead;
 }
コード例 #2
0
ファイル: helper.php プロジェクト: vim84/b-markt
 /**
  * Returns active A/B-test
  *
  * @return array|null
  */
 public static function getActiveTest()
 {
     static $abtest;
     if (!defined('SITE_ID') || !SITE_ID) {
         return null;
     }
     if (empty($abtest)) {
         $cache = new \CPHPCache();
         if ($cache->initCache(30 * 24 * 3600, 'abtest_active_' . SITE_ID, '/abtest')) {
             $abtest = $cache->getVars();
         } else {
             $abtest = ABTestTable::getList(array('order' => array('SORT' => 'ASC'), 'filter' => array('SITE_ID' => SITE_ID, 'ACTIVE' => 'Y', '<=START_DATE' => new \Bitrix\Main\Type\DateTime())))->fetch() ?: null;
             $cache->startDataCache();
             $cache->endDataCache($abtest);
         }
         if (!empty($abtest) && intval($abtest['DURATION']) > 0) {
             $end = clone $abtest['START_DATE'];
             $end->add(intval($abtest['DURATION']) . ' days');
             if (time() > $end->format('U')) {
                 Helper::stopTest($abtest['ID'], true);
                 $abtest = null;
             }
         }
     }
     return $abtest;
 }
コード例 #3
0
ファイル: class.php プロジェクト: mrdeadmouse/u136006
 /**
  * Set mutable attributes
  * @param bool   $bFromCache
  * @param string $strUserIds
  */
 protected function workWithNonCacheAttr($bFromCache = false, $strUserIds = '')
 {
     //if list of users in cache - get last activity
     if ($bFromCache && $strUserIds) {
         $dbRes = CUser::getList($by = 'id', $order = 'asc', array('ID' => $strUserIds, 'LAST_ACTIVITY' => static::LAST_ACTIVITY), array('FIELDS' => array('ID')));
         while ($arRes = $dbRes->fetch()) {
             if ($this->arResult['USERS'][$arRes['ID']]) {
                 $this->arResult['USERS'][$arRes['ID']]['IS_ONLINE'] = true;
             }
         }
         unset($dbRes, $arRes);
     }
     $buildResizedPhoto = false;
     $displayPhoto = $this->displayPersonalPhoto();
     foreach ($this->arResult['USERS'] as &$arUser) {
         if ($this->bExcel && $displayPhoto) {
             //if export in excel, then method $this->resizePersonalPhoto() not run. And not modify PERSONAL_PHOTO
             if (!$arUser['PERSONAL_PHOTO']) {
                 $arUser['PERSONAL_PHOTO'] = $this->getDefaultPictureSonet($arUser['PERSONAL_GENDER']);
             }
             $arUser['PERSONAL_PHOTO_SOURCE'] = $arUser['PERSONAL_PHOTO'];
             $arUser['PERSONAL_PHOTO'] = CFile::GetPath($arUser['PERSONAL_PHOTO']);
         } elseif ($bFromCache && $displayPhoto) {
             $buildResizedPhoto = $this->resizePersonalPhoto($arUser) || $buildResizedPhoto;
         }
         $arUser['IS_BIRTHDAY'] = CIntranetUtils::IsToday($arUser['PERSONAL_BIRTHDAY']);
         $arUser['IS_ABSENT'] = CIntranetUtils::IsUserAbsent($arUser['ID']);
     }
     //rewrite cache if we build new resized photo
     if ($buildResizedPhoto) {
         $this->obCache->clean($this->cacheId, $this->cacheDir);
         $this->obCache->startDataCache();
         $this->obCache->endDataCache(array('USERS' => $this->arResult['USERS'], 'STR_USER_ID' => $strUserIds, 'DEPARTMENTS' => $this->arResult['DEPARTMENTS'], 'DEPARTMENT_HEAD' => $this->arResult['DEPARTMENT_HEAD'], 'USERS_NAV' => $this->arResult['USERS_NAV']));
     }
 }
コード例 #4
0
ファイル: webdavserver.php プロジェクト: DarneoStudio/bitrix
 protected function parsePath($requestUri)
 {
     static $storages;
     if (empty($storages)) {
         $cache = new \CPHPCache();
         if ($cache->initCache(30 * 24 * 3600, 'webdav_disk_common_storage', '/webdav/storage')) {
             $storages = $cache->getVars();
         } else {
             $storages = \Bitrix\Disk\Storage::getModelList(array('filter' => array('=ENTITY_TYPE' => \Bitrix\Disk\ProxyType\Common::className())));
             foreach ($storages as $key => $storage) {
                 $storages[$key] = array('id' => $storage->getEntityId(), 'path' => $storage->getProxyType()->getStorageBaseUrl());
             }
             $cache->startDataCache();
             if (defined('BX_COMP_MANAGED_CACHE')) {
                 $taggedCache = \Bitrix\Main\Application::getInstance()->getTaggedCache();
                 $taggedCache->startTagCache('/webdav/storage');
                 $taggedCache->registerTag('disk_common_storage');
                 $taggedCache->endTagCache();
             }
             $cache->endDataCache($storages);
         }
     }
     $patterns = array(array('user', '/(?:company|contacts)/personal/user/(\\d+)/files/lib(.*)$'), array('user', '/(?:company|contacts)/personal/user/(\\d+)/disk/path(.*)$'), array('group', '/workgroups/group/(\\d+)/files(.*)$'), array('group', '/workgroups/group/(\\d+)/disk/path(.*)$'));
     foreach ($storages as $storage) {
         $storagePath = trim($storage['path'], '/');
         $patterns[] = array('docs', sprintf('^/%s/path(.*)$', $storagePath), $storage['id']);
         $patterns[] = array('docs', sprintf('^/%s(.*)$', $storagePath), $storage['id']);
     }
     // @TODO: aggregator
     $patterns[] = array('docs', '^/docs/path(.*)$', 'shared_files_s1');
     $patterns[] = array('docs', '^/docs(.*)$', 'shared_files_s1');
     $type = null;
     $id = null;
     $path = null;
     foreach ($patterns as $pattern) {
         $matches = array();
         if (preg_match('#' . $pattern[1] . '#i', $requestUri, $matches)) {
             $type = $pattern[0];
             list($id, $path) = $type == 'docs' ? array($pattern[2], $matches[1]) : array($matches[1], $matches[2]);
             break;
         }
     }
     /** @var Storage $storage */
     $storage = null;
     if ($type == 'user') {
         $storage = Driver::getInstance()->getStorageByUserId((int) $id);
     } elseif ($type == 'group') {
         $storage = Driver::getInstance()->getStorageByGroupId((int) $id);
     } elseif ($type == 'docs') {
         $storage = Driver::getInstance()->getStorageByCommonId($id);
     } else {
         return array(null, null);
     }
     $path = static::UrlDecode($path);
     return array($storage, $path);
 }
コード例 #5
0
ファイル: comp_findtools.php プロジェクト: spas-viktor/books
 public static function resolveComponentEngine(CComponentEngine $engine, $pageCandidates, &$arVariables)
 {
     /** @global CMain $APPLICATION */
     global $APPLICATION, $CACHE_MANAGER;
     $component = $engine->GetComponent();
     if ($component) {
         $iblock_id = intval($component->arParams["IBLOCK_ID"]);
     } else {
         $iblock_id = 0;
     }
     $requestURL = $APPLICATION->GetCurPage(true);
     $cacheId = $requestURL . implode("|", array_keys($pageCandidates));
     $cache = new CPHPCache();
     if ($cache->startDataCache(3600, $cacheId, "iblock_find")) {
         if (defined("BX_COMP_MANAGED_CACHE")) {
             $CACHE_MANAGER->StartTagCache("iblock_find");
             CIBlock::registerWithTagCache($iblock_id);
         }
         foreach ($pageCandidates as $pageID => $arVariablesTmp) {
             if ($arVariablesTmp["SECTION_CODE_PATH"] != "" && (isset($arVariablesTmp["ELEMENT_ID"]) || isset($arVariablesTmp["ELEMENT_CODE"]))) {
                 if (CIBlockFindTools::checkElement($iblock_id, $arVariablesTmp)) {
                     $arVariables = $arVariablesTmp;
                     if (defined("BX_COMP_MANAGED_CACHE")) {
                         $CACHE_MANAGER->EndTagCache();
                     }
                     $cache->endDataCache(array($pageID, $arVariablesTmp));
                     return $pageID;
                 }
             }
         }
         foreach ($pageCandidates as $pageID => $arVariablesTmp) {
             if ($arVariablesTmp["SECTION_CODE_PATH"] != "" && (!isset($arVariablesTmp["ELEMENT_ID"]) && !isset($arVariablesTmp["ELEMENT_CODE"]))) {
                 if (CIBlockFindTools::checkSection($iblock_id, $arVariablesTmp)) {
                     $arVariables = $arVariablesTmp;
                     if (defined("BX_COMP_MANAGED_CACHE")) {
                         $CACHE_MANAGER->EndTagCache();
                     }
                     $cache->endDataCache(array($pageID, $arVariablesTmp));
                     return $pageID;
                 }
             }
         }
         if (defined("BX_COMP_MANAGED_CACHE")) {
             $CACHE_MANAGER->AbortTagCache();
         }
         $cache->abortDataCache();
     } else {
         $vars = $cache->getVars();
         $pageID = $vars[0];
         $arVariables = $vars[1];
         return $pageID;
     }
     list($pageID, $arVariables) = each($pageCandidates);
     return $pageID;
 }
コード例 #6
0
ファイル: helper.php プロジェクト: webgksupport/alpina
 /**
  * Returns active A/B-test
  *
  * @return array|null
  */
 public static function getActiveTest()
 {
     static $abtest;
     static $defined;
     if (!defined('SITE_ID') || !SITE_ID) {
         return null;
     }
     if (empty($defined)) {
         $cache = new \CPHPCache();
         if ($cache->initCache(30 * 24 * 3600, 'abtest_active_' . SITE_ID, '/abtest')) {
             $abtest = $cache->getVars();
         } else {
             $abtest = ABTestTable::getList(array('order' => array('SORT' => 'ASC'), 'filter' => array('SITE_ID' => SITE_ID, 'ACTIVE' => 'Y', '<=START_DATE' => new Type\DateTime())))->fetch() ?: null;
             $cache->startDataCache();
             $cache->endDataCache($abtest);
         }
         $defined = true;
         if (!empty($abtest)) {
             if (!$abtest['MIN_AMOUNT']) {
                 $capacity = AdminHelper::getSiteCapacity($abtest['SITE_ID']);
                 if ($capacity['min'] > 0) {
                     $result = ABTestTable::update($abtest['ID'], array('MIN_AMOUNT' => $capacity['min']));
                     if ($result->isSuccess()) {
                         $cache->clean('abtest_active_' . SITE_ID, '/abtest');
                         $abtest['MIN_AMOUNT'] = $capacity['min'];
                     }
                 }
             }
             if (intval($abtest['DURATION']) == -1) {
                 if (intval($abtest['MIN_AMOUNT']) > 0) {
                     $capacity = AdminHelper::getTestCapacity($abtest['ID']);
                     if ($capacity['A'] >= $abtest['MIN_AMOUNT'] && $capacity['B'] >= $abtest['MIN_AMOUNT']) {
                         Helper::stopTest($abtest['ID'], true);
                         $abtest = null;
                     }
                 }
             } else {
                 if (intval($abtest['DURATION']) > 0) {
                     $end = clone $abtest['START_DATE'];
                     $end->add(intval($abtest['DURATION']) . ' days');
                     if (time() > $end->format('U')) {
                         Helper::stopTest($abtest['ID'], true);
                         $abtest = null;
                     }
                 }
             }
         }
     }
     return $abtest;
 }
コード例 #7
0
ファイル: comp_findtools.php プロジェクト: Satariall/izurit
 public static function resolveComponentEngine(CComponentEngine $engine, $pageCandidates, &$arVariables)
 {
     /** @global CMain $APPLICATION */
     global $APPLICATION, $CACHE_MANAGER;
     static $aSearch = array("&lt;", "&gt;", "&quot;", "&#039;");
     static $aReplace = array("<", ">", "\"", "'");
     $component = $engine->GetComponent();
     if ($component) {
         $iblock_id = intval($component->arParams["IBLOCK_ID"]);
     } else {
         $iblock_id = 0;
     }
     //To fix GetPagePath security hack for SMART_FILTER_PATH
     foreach ($pageCandidates as $pageID => $arVariablesTmp) {
         foreach ($arVariablesTmp as $variableName => $variableValue) {
             if ($variableName === "SMART_FILTER_PATH") {
                 $pageCandidates[$pageID][$variableName] = str_replace($aSearch, $aReplace, $variableValue);
             }
         }
     }
     $requestURL = $APPLICATION->GetCurPage(true);
     $cacheId = $requestURL . implode("|", array_keys($pageCandidates)) . "|" . SITE_ID;
     $cache = new CPHPCache();
     if ($cache->startDataCache(3600, $cacheId, "iblock_find")) {
         if (defined("BX_COMP_MANAGED_CACHE")) {
             $CACHE_MANAGER->StartTagCache("iblock_find");
             CIBlock::registerWithTagCache($iblock_id);
         }
         foreach ($pageCandidates as $pageID => $arVariablesTmp) {
             if ($arVariablesTmp["SECTION_CODE_PATH"] != "" && (isset($arVariablesTmp["ELEMENT_ID"]) || isset($arVariablesTmp["ELEMENT_CODE"]))) {
                 if (CIBlockFindTools::checkElement($iblock_id, $arVariablesTmp)) {
                     $arVariables = $arVariablesTmp;
                     if (defined("BX_COMP_MANAGED_CACHE")) {
                         $CACHE_MANAGER->EndTagCache();
                     }
                     $cache->endDataCache(array($pageID, $arVariablesTmp));
                     return $pageID;
                 }
             }
         }
         foreach ($pageCandidates as $pageID => $arVariablesTmp) {
             if ($arVariablesTmp["SECTION_CODE_PATH"] != "" && (!isset($arVariablesTmp["ELEMENT_ID"]) && !isset($arVariablesTmp["ELEMENT_CODE"]))) {
                 if (CIBlockFindTools::checkSection($iblock_id, $arVariablesTmp)) {
                     $arVariables = $arVariablesTmp;
                     if (defined("BX_COMP_MANAGED_CACHE")) {
                         $CACHE_MANAGER->EndTagCache();
                     }
                     $cache->endDataCache(array($pageID, $arVariablesTmp));
                     return $pageID;
                 }
             }
         }
         if (defined("BX_COMP_MANAGED_CACHE")) {
             $CACHE_MANAGER->AbortTagCache();
         }
         $cache->abortDataCache();
     } else {
         $vars = $cache->getVars();
         $pageID = $vars[0];
         $arVariables = $vars[1];
         return $pageID;
     }
     reset($pageCandidates);
     list($pageID, $arVariables) = each($pageCandidates);
     return $pageID;
 }
コード例 #8
0
ファイル: component.php プロジェクト: DarneoStudio/bitrix
 /**
  * Function starts the caching block of the component execution.
  *
  * @param int|bool $cacheTime
  * @param mixed $additionalCacheID
  * @param string|bool $cachePath
  * @return string
  *
  */
 public final function startResultCache($cacheTime = false, $additionalCacheID = false, $cachePath = false)
 {
     /** @global CMain $APPLICATION */
     global $APPLICATION, $CACHE_MANAGER;
     if (!$this->__bInited) {
         return null;
     }
     if ($this->arParams["CACHE_TYPE"] == "N" || $this->arParams["CACHE_TYPE"] == "A" && COption::getOptionString("main", "component_cache_on", "Y") == "N") {
         return true;
     }
     if ($cacheTime === false) {
         $cacheTime = intval($this->arParams["CACHE_TIME"]);
     }
     $this->__cacheID = $this->getCacheID($additionalCacheID);
     $this->__cachePath = $cachePath;
     if ($this->__cachePath === false) {
         $this->__cachePath = $CACHE_MANAGER->getCompCachePath($this->__relativePath);
     }
     $this->__cache = \Bitrix\Main\Data\Cache::createInstance();
     if ($this->__cache->startDataCache($cacheTime, $this->__cacheID, $this->__cachePath)) {
         $this->__NavNum = $GLOBALS["NavNum"];
         if (defined("BX_COMP_MANAGED_CACHE") && $this->__cache->isStarted()) {
             $CACHE_MANAGER->startTagCache($this->__cachePath);
         }
         return true;
     } else {
         $arCache = $this->__cache->GetVars();
         $this->arResult = $arCache["arResult"];
         if (array_key_exists("templateCachedData", $arCache)) {
             $templateCachedData =& $arCache["templateCachedData"];
             if ($templateCachedData && is_array($templateCachedData)) {
                 if (array_key_exists("additionalCSS", $templateCachedData) && strlen($templateCachedData["additionalCSS"]) > 0) {
                     $APPLICATION->SetAdditionalCSS($templateCachedData["additionalCSS"]);
                     if ($this->__parent) {
                         $this->__parent->addChildCSS($templateCachedData["additionalCSS"]);
                     }
                 }
                 if (array_key_exists("additionalJS", $templateCachedData) && strlen($templateCachedData["additionalJS"]) > 0) {
                     $APPLICATION->AddHeadScript($templateCachedData["additionalJS"]);
                     if ($this->__parent) {
                         $this->__parent->addChildJS($templateCachedData["additionalJS"]);
                     }
                 }
                 if (array_key_exists("frames", $templateCachedData) && is_array($templateCachedData["frames"])) {
                     foreach ($templateCachedData["frames"] as $frameState) {
                         \Bitrix\Main\Page\FrameHelper::applyCachedData($frameState);
                     }
                 }
                 if (array_key_exists("frameMode", $templateCachedData) && $templateCachedData["frameMode"] === false) {
                     $context = isset($templateCachedData["frameModeCtx"]) ? "(from component cache) " . $templateCachedData["frameModeCtx"] : $this->__name . " - a cached template set frameMode=false";
                     \Bitrix\Main\Data\StaticHtmlCache::applyComponentFrameMode($context);
                 }
                 if (isset($templateCachedData["externalCss"])) {
                     foreach ($templateCachedData["externalCss"] as $cssPath) {
                         $APPLICATION->SetAdditionalCSS($cssPath);
                         //Check if parent component exists and plug css it to it's "collection"
                         if ($this->__parent) {
                             $this->__parent->addChildCSS($cssPath);
                         }
                     }
                 }
                 if (isset($templateCachedData["externalJs"])) {
                     foreach ($templateCachedData["externalJs"] as $jsPath) {
                         $APPLICATION->AddHeadScript($jsPath);
                         //Check if parent component exists and plug js it to it's "collection"
                         if ($this->__parent) {
                             $this->__parent->addChildJS($jsPath);
                         }
                     }
                 }
             }
             if ($templateCachedData["__editButtons"]) {
                 foreach ($templateCachedData["__editButtons"] as $button) {
                     if ($button[0] == 'AddEditAction') {
                         $this->addEditAction($button[1], $button[2], $button[3], $button[4]);
                     } else {
                         $this->addDeleteAction($button[1], $button[2], $button[3], $button[4]);
                     }
                 }
             }
             if ($templateCachedData["__view"]) {
                 foreach ($templateCachedData["__view"] as $view_id => $target) {
                     foreach ($target as $view_content) {
                         $APPLICATION->addViewContent($view_id, $view_content[0], $view_content[1]);
                     }
                 }
             }
             if (array_key_exists("__NavNum", $templateCachedData)) {
                 $GLOBALS["NavNum"] += $templateCachedData["__NavNum"];
             }
             if (array_key_exists("__children_css", $templateCachedData)) {
                 foreach ($templateCachedData["__children_css"] as $css_url) {
                     $APPLICATION->setAdditionalCSS($css_url);
                 }
             }
             if (array_key_exists("__children_js", $templateCachedData)) {
                 foreach ($templateCachedData["__children_js"] as $js_url) {
                     $APPLICATION->addHeadScript($js_url);
                 }
             }
             if (array_key_exists("__children_epilogs", $templateCachedData)) {
                 foreach ($templateCachedData["__children_epilogs"] as $component_epilog) {
                     $this->includeComponentEpilog($component_epilog);
                 }
             }
             if (array_key_exists("component_epilog", $templateCachedData)) {
                 $this->includeComponentEpilog($templateCachedData["component_epilog"]);
             }
         }
         return false;
     }
 }
コード例 #9
0
ファイル: adminhelper.php プロジェクト: webgksupport/alpina
 /**
  * Returns A/B-test traffic amounts
  *
  * @param int $id A/B-test ID.
  * @return array
  */
 public static function getTestCapacity($id)
 {
     $cache = new \CPHPCache();
     if ($cache->initCache(time() - strtotime('today'), 'abtest_capacity_' . intval($id), '/abtest')) {
         $capacity = $cache->getVars();
     } else {
         if (Loader::includeModule('conversion')) {
             if ($conversionRates = Conversion\RateManager::getTypes(array('ACTIVE' => true))) {
                 if ($abtest = ABTestTable::getById($id)->fetch()) {
                     $lid = $abtest['SITE_ID'];
                     $baseRate = array_slice($conversionRates, 0, 1, true);
                     $reportContext = new Conversion\ReportContext();
                     $reportContext->setAttribute('conversion_site', $lid);
                     $reportContext->setAttribute('abtest', $id);
                     $reportContext->setAttribute('abtest_section', 'A');
                     $groupAData = reset($reportContext->getRatesDeprecated($baseRate, array(), null));
                     $reportContext->unsetAttribute('abtest_section', 'A');
                     $reportContext->setAttribute('abtest_section', 'B');
                     $groupBData = reset($reportContext->getRatesDeprecated($baseRate, array(), null));
                     $capacity = array('A' => $groupAData['DENOMINATOR'], 'B' => $groupBData['DENOMINATOR']);
                     $cache->startDataCache(strtotime('tomorrow') - time());
                     $cache->endDataCache($capacity);
                 }
             }
         }
     }
     return !empty($capacity) ? $capacity : array('A' => 0, 'B' => 0);
 }
コード例 #10
0
ファイル: component.php プロジェクト: ASDAFF/bitrix-5
 /**
  * Function starts the caching block of the component execution.
  *
  * @param int|bool $cacheTime
  * @param mixed $additionalCacheID
  * @param string|bool $cachePath
  * @return string
  *
  */
 public final function startResultCache($cacheTime = false, $additionalCacheID = false, $cachePath = false)
 {
     /** @global CMain $APPLICATION */
     global $APPLICATION, $CACHE_MANAGER;
     if (!$this->__bInited) {
         return null;
     }
     if ($this->arParams["CACHE_TYPE"] == "N" || $this->arParams["CACHE_TYPE"] == "A" && COption::getOptionString("main", "component_cache_on", "Y") == "N") {
         return true;
     }
     if ($cacheTime === false) {
         $cacheTime = intval($this->arParams["CACHE_TIME"]);
     }
     $this->__cacheID = $this->getCacheID($additionalCacheID);
     $this->__cachePath = $cachePath;
     if ($this->__cachePath === false) {
         $this->__cachePath = $CACHE_MANAGER->getCompCachePath($this->__relativePath);
     }
     $this->__cache = new CPHPCache();
     if ($this->__cache->startDataCache($cacheTime, $this->__cacheID, $this->__cachePath)) {
         $this->__NavNum = $GLOBALS["NavNum"];
         if (defined("BX_COMP_MANAGED_CACHE")) {
             $CACHE_MANAGER->startTagCache($this->__cachePath);
         }
         return true;
     } else {
         $arCache = $this->__cache->GetVars();
         $this->arResult = $arCache["arResult"];
         if (array_key_exists("templateCachedData", $arCache)) {
             $templateCachedData =& $arCache["templateCachedData"];
             CBitrixComponentTemplate::applyCachedData($templateCachedData);
             if ($templateCachedData["__editButtons"]) {
                 foreach ($templateCachedData["__editButtons"] as $button) {
                     if ($button[0] == 'AddEditAction') {
                         $this->addEditAction($button[1], $button[2], $button[3], $button[4]);
                     } else {
                         $this->addDeleteAction($button[1], $button[2], $button[3], $button[4]);
                     }
                 }
             }
             if ($templateCachedData["__view"]) {
                 foreach ($templateCachedData["__view"] as $view_id => $target) {
                     foreach ($target as $view_content) {
                         $APPLICATION->addViewContent($view_id, $view_content[0], $view_content[1]);
                     }
                 }
             }
             if (array_key_exists("__NavNum", $templateCachedData)) {
                 $GLOBALS["NavNum"] += $templateCachedData["__NavNum"];
             }
             if (array_key_exists("__children_css", $templateCachedData)) {
                 foreach ($templateCachedData["__children_css"] as $css_url) {
                     $APPLICATION->setAdditionalCSS($css_url);
                 }
             }
             if (array_key_exists("__children_js", $templateCachedData)) {
                 foreach ($templateCachedData["__children_js"] as $js_url) {
                     $APPLICATION->addHeadScript($js_url);
                 }
             }
             if (array_key_exists("__children_epilogs", $templateCachedData)) {
                 foreach ($templateCachedData["__children_epilogs"] as $component_epilog) {
                     $this->includeComponentEpilog($component_epilog);
                 }
             }
             if (array_key_exists("component_epilog", $templateCachedData)) {
                 $this->includeComponentEpilog($templateCachedData["component_epilog"]);
             }
         }
         return false;
     }
 }
コード例 #11
0
 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;
 }