/** * Validate all the restrictions using the accessControlScope * * @return bool */ public function isValid() { if (!$this->scope instanceof accessControlScope) { throw new Exception("Scope was not set"); } // if we have ks if ($this->scope->getKs() && $this->scope->getKs() instanceof ks) { // not need to validate if we have an admin ks if ($this->scope->getKs()->isAdmin()) { return true; } } $restrictions = $this->getRestrictions(); foreach ($restrictions as $restriction) { if ($restriction->isValid() === false) { // if one is not valid, all access control considered not valid return false; } } return true; }
private function applyAccessControlOnContextData(accessControlScope $accessControlScope) { if ($this->isAdmin) { return; } $accessControl = $this->entry->getAccessControl(); /* @var $accessControl accessControl */ if ($accessControl && $accessControl->hasRules()) { $this->isSecured = true; if (kConf::hasMap("optimized_playback")) { $partnerId = $accessControl->getPartnerId(); $optimizedPlayback = kConf::getMap("optimized_playback"); if (array_key_exists($partnerId, $optimizedPlayback)) { $params = $optimizedPlayback[$partnerId]; if (array_key_exists('cache_kdp_access_control', $params) && $params['cache_kdp_access_control'] && (strpos(strtolower(kCurrentContext::$client_lang), "kdp") !== false || strpos(strtolower(kCurrentContext::$client_lang), "html") !== false)) { return; } } } $accessControlScope->setEntryId($this->entry->getId()); $this->isAdmin = $accessControlScope->getKs() && $accessControlScope->getKs()->isAdmin(); $this->disableCache = $accessControl->applyContext($this->contextDataResult); } }