public function checkPermission(array &$aData) { //inicjalizacja keszu $key = md5(serialize(array_keys($aData))); if (self::$_oConfig->uodo->enable) { $idUser = parent::$_oPermission->getUserId(); } else { $aUser = Zend_Auth::getInstance()->getIdentity(); $idUser = $aUser['user_id']; } //tworzenie keszu $oCache = new Common_Cache_Cache(); $oTag = new Common_Cache_Tag(); $oTag->setTags(array('permission')); //@todo to powinna być stała $oCache->setLifetime(86400); //@todo ustawić to jakoś w konfigu na np. 99999999 $oCache->setSerialize(true); $sId = $oCache->getId(get_class($this), 'perm-response-form', array($key, $idUser)); //pobieranie/tworzenie danych $aResult = $oCache->load($sId); if ($aResult == false) { $aResult = $this->_schema($aData); $oCache->save($aResult, $sId, $oTag->getTags()); } $aData = $this->_setValue($aData, $aResult); }
protected function _checkPermission($aKeys) { if (self::$_oConfig->uodo->enabled) { //sprawdza z podanych kluczy do których użytkownik nie ma dostępu? $key = md5(serialize($aKeys)); $idUser = self::$_oPermission->getUserId(); //tworzenie keszu $oCache = new Common_Cache_Cache(); $oTag = new Common_Cache_Tag(); $oTag->setTags(array('permission')); //@todo to powinna być stała $oCache->setLifetime(86400); //@todo ustawić to jakoś w konfigu na np. 99999999 $oCache->setSerialize(true); $sId = $oCache->getId(get_class($this), 'perm-response-abst', array($key, $idUser)); //pobieranie/tworzenie danych $aResult = $oCache->load($sId); if ($aResult == false) { $aResult = array(); foreach ($aKeys as $sField) { if (!self::$_oPermission->checkPermission($sField, Acl_Model_Table_ZasobTyp::FIELD_READ)) { $aResult[] = $sField; } } $oCache->save($aResult, $sId, $oTag->getTags()); } } else { $aResult = array(); } return $aResult; }
public function checkPermission($aParams) { $aKeys = $this->_getKeys($aParams); $key = md5(serialize($aKeys)); //$idUser = Zend_Auth::getInstance()->getIdentity()->user_id; $idUser = self::$_oPermission->getUserId(); //tworzenie keszu $oCache = new Common_Cache_Cache(); $oTag = new Common_Cache_Tag(); $oTag->setTags(array('permission')); //@todo to powinna być stała $oCache->setLifetime(86400); //@todo ustawić to jakoś w konfigu na np. 99999999 $oCache->setSerialize(true); $sId = $oCache->getId(get_class($this), 'perm-request', array($key, $idUser)); //pobieranie/tworzenie danych $aAllowKeys = $oCache->load($sId); if ($aAllowKeys == false) { $aAllowKeys = $this->_getAllowedKeys($aParams); $oCache->save($aAllowKeys, $sId, $oTag->getTags()); } return $this->_cp($aAllowKeys, $aParams); }
protected function _getCachedFileContent() { $oCache = new Common_Cache_Cache(); $oTag = new Common_Cache_Tag(); $oTag->setTags(array('javascript')); //@todo to powinna być stała $oCache->setLifetime(1); //@todo ustawić to jakoś w konfigu na np. 99999999 $oCache->setSerialize(false); $sId = $oCache->getId(get_class($this), 'js-load', array()); $sResult = $oCache->load($sId); if ($sResult != false) { if ($oCache->getSerialize()) { $sResult = unserialize($sResult); } } else { $sResult = $this->_getFileContent(); $sNewResult = $oCache->getSerialize() ? serialize($sResult) : $sResult; $oCache->save($sNewResult, $sId, $oTag->getTags()); } return $sResult; }
/** * Save some string datas into a cache record * * Note : $data is always "string" (serialization is done by the * core not by the backend) * * @param string $data Datas to cache * @param string $id Cache id * @param array $tags Array of strings, the cache record will be tagged by each string entry * @param int $specificLifetime If != false, set a specific lifetime for this cache record (null => infinite lifetime) * @return boolean True if no problem */ public function save($data, $id, $tags = array(), $specificLifetime = false, $memcacheTag = false) { if ($this->_memcacheEnable && $memcacheTag != true) { $cache = new Common_Cache_Cache(); $aCacheTags = unserialize($cache->load(Common_Cache_Tag::MEMCACHE_TAGS)); foreach ($tags as $sTag) { if (isset($aCacheTags[$sTag])) { $aTagId = $aCacheTags[$sTag]; } $aTagId[$id] = $id; $aCacheTags[$sTag] = $aTagId; } $tags = array(); $cache->save(serialize($aCacheTags), Common_Cache_Tag::MEMCACHE_TAGS, $tags, $specificLifetime, true); } return $this->setCache()->_oCache->save($data, $id, $tags, $specificLifetime); }