Exemplo n.º 1
0
 /**
  * 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']));
     }
 }
Exemplo n.º 2
0
 public function getObject($id, $code, $sectionCode = false, $iblock = false, $clear_cache = "N")
 {
     $id = (int) $id;
     $cache = new CPHPCache();
     if ($id) {
         $arFilter = array("ID" => $id);
         $cacheId = "object_" . $id . $sectionCode;
         $cachePath = "/" . SITE_ID . "/object/" . substr($id, 0, 3);
     } else {
         $arFilter = array("=CODE" => $code);
         $cacheId = "object_" . $code . $sectionCode;
         $cachePath = "/" . SITE_ID . "/object/" . substr($code, 0, 3);
     }
     if ($sectionCode) {
         $arFilter["SECTION_CODE"] = $sectionCode;
         $arFilter["!SECTION_ID"] = false;
     }
     if ($iblock) {
         $arFilter["IBLOCK_ID"] = $iblock;
     }
     // чистим кеш?
     if ('Y' == $clear_cache) {
         CPHPCache::clean($cacheId, $cachePath);
     }
     $cacheTime = CACHE_OBJECT;
     if ($cache->InitCache($cacheTime, $cacheId, $cachePath)) {
         $vars = $cache->GetVars();
         $obj = $vars["OBJECT"];
         return $obj;
     } else {
         $res = CIBlockElement::GetList(array(), $arFilter);
         if ($elem = $res->GetNextElement()) {
             $obj = $elem->GetFields();
             $props = $elem->GetProperties();
             $obj["PROPS"] = $props;
             if ($cache->StartDataCache()) {
                 $cache->EndDataCache(array("OBJECT" => $obj));
             }
             return $obj;
         }
     }
     return null;
 }
Exemplo n.º 3
0
	/**
	* Function deletes the cache created before.
	*
	* <p>Note: parameters must exactly match to startResultCache call.</p>
	* @param mixed $additionalCacheID
	* @param string $cachePath
	* @return void
	*
	*/
	final public function clearResultCache($additionalCacheID = false, $cachePath = false)
	{
		global $APPLICATION, $CACHE_MANAGER;

		if (!$this->__bInited)
			return null;

		$this->__cacheID = $this->getCacheID($additionalCacheID);

		$this->__cachePath = $cachePath;
		if ($this->__cachePath === false)
			$this->__cachePath = $CACHE_MANAGER->getCompCachePath($this->__relativePath);

		CPHPCache::clean($this->__cacheID, $this->__cachePath);
	}
Exemplo n.º 4
0
 /**
  * Function deletes the cache created before.
  *
  * <p>Note: parameters must exactly match to startResultCache call.</p>
  * @param mixed $additionalCacheID
  * @param string|bool $cachePath
  * @return void
  *
  */
 public final function clearResultCache($additionalCacheID = false, $cachePath = false)
 {
     global $CACHE_MANAGER;
     if (!$this->__bInited) {
         return null;
     }
     $this->__cacheID = $this->getCacheID($additionalCacheID);
     $this->__cachePath = $cachePath;
     if ($this->__cachePath === false) {
         $this->__cachePath = $CACHE_MANAGER->getCompCachePath($this->__relativePath);
     }
     $cache = new CPHPCache();
     $cache->clean($this->__cacheID, $this->__cachePath);
 }
Exemplo n.º 5
0
 /**
  * Cleans active A/B-test cache
  *
  * @param int $siteId Site ID.
  * @return void
  */
 public static function clearCache($siteId)
 {
     $cache = new \CPHPCache();
     $cache->clean('abtest_active_' . $siteId, '/abtest');
 }