Пример #1
0
 /**
  * Get disabled consent from database
  *
  * @return bool True on success and false on error
  */
 private function _loadDisableConsent()
 {
     $eid = $this->_entity->getEid();
     $revisionId = $this->_entity->getRevisionid();
     $cacheProvider = sspmod_janus_DiContainer::getInstance()->getCacheProvider();
     // Try to get result from cache
     $cacheKey = 'entity-disableconsent-' . $eid . '-' . $revisionId;
     $cachedResult = $cacheProvider->fetch($cacheKey);
     if ($cachedResult !== false) {
         $this->_disableConsent = $cachedResult;
         return true;
     }
     $st = $this->execute('SELECT DC.*,
                 CONNECTION.name AS remoteentityid
         FROM ' . $this->getTablePrefix() . 'disableConsent AS DC
         INNER JOIN  ' . $this->getTablePrefix() . 'connection AS CONNECTION
             ON CONNECTION.id = DC.remoteeid
         WHERE DC.`connectionRevisionId` = ?;', array($this->_entity->getId()));
     if ($st === false) {
         return false;
     }
     $row = $st->fetchAll(PDO::FETCH_ASSOC);
     $this->_disableConsent = array();
     foreach ($row as $data) {
         $this->_disableConsent[$data['remoteentityid']] = $data;
     }
     // Store disable consent in cache, note that this does not have to be flushed since a new revision
     // will trigger a new version of the cache anyway
     $cacheProvider->save($cacheKey, $this->_disableConsent);
     return true;
 }
 /**
  * Save disable consent to database
  *
  * @param int $revision The current revision number
  *
  * @return bool True on success and false on error
  */
 private function _saveDisableConsent($revision)
 {
     if ($this->_modified) {
         foreach ($this->_disableConsent as $disable) {
             $st = $this->execute('INSERT INTO ' . self::$prefix . 'disableConsent (
                 `eid`, `revisionid`, `remoteentityid`, `created`, `ip`)
                 VALUES (?, ?, ?, ?, ?);', array($this->_entity->getEid(), $revision, $disable['remoteentityid'], date('c'), $_SERVER['REMOTE_ADDR']));
             if ($st === false) {
                 return false;
             }
         }
     }
     return true;
 }