/** * @param SMSPage $page * @param mixed $permissionName In this case, permissionName is the appProxyType name! * * @return bool */ public function isAccessProtected(SMSPage $page, $permissionName) { /* * !!! $permissionName is used for visibilityDefinitionType !!! */ $pageId = $page->getId(); // try to return chached protection status if (isset($this->cache[$permissionName][$pageId])) { return $this->cache[$permissionName][$pageId]; } /** @var $umgtUS UmgtUserSessionStore */ $umgtUS = $this->getServiceObject(UmgtUserSessionStore::class, [], APFService::SERVICE_TYPE_SESSION_SINGLETON); // load current user $user = $umgtUS->getUser($this->getContext()); // protect against access if no user is logged in and no anonymous access is granted if ($user === null) { return $this->cache[$permissionName][$pageId] = !$this->anonymousAccess; } /** @var $umgtM UmgtManager */ $umgtM = $this->getDIServiceObject('APF\\modules\\usermanagement\\biz', 'UmgtManager'); // load visibilities from users and groups $groups = $umgtM->loadGroupsWithUser($user); $visibilityType = $umgtM->loadVisibilityDefinitionTypeByName($permissionName); if ($visibilityType === null) { return $this->cache[$permissionName][$pageId] = true; // visibility type is not existent } $visibilities = $umgtM->loadVisibilityDefinitionsByUser($user, $visibilityType); if (count($groups) > 0) { foreach ($groups as $group) { $visibilities = array_merge($visibilities, $umgtM->loadVisibilityDefinitionsByGroup($group, $visibilityType)); } } // search visibility definitions if (count($visibilities) > 0) { foreach ($visibilities as $visibility) { if ($visibility->getAppObjectId() == $pageId && (bool) $visibility->getReadPermission()) { return $this->cache[$permissionName][$pageId] = false; // visibility definition with read permission found, grant access } } } // no permission found, protected against access return $this->cache[$permissionName][$pageId] = true; }
/** * @param SMSPage $page * * @return string|null * @throws SMSWrongParameterException * @version : v0.1 */ public function getParentId(SMSPage $page) { $pageId = $page->getId(); $pageDOMNode = $this->XML_DOMDocument->getElementById($pageId); if ($pageDOMNode === null) { throw new SMSWrongParameterException('[SMSXMLMapper::getParentId()] Could not find node for page id "' . $pageId . '".', E_USER_ERROR); } $parentNode = $pageDOMNode->parentNode; if (!$parentNode instanceof \DOMElement) { return null; // no parent node } $parentNodeName = $parentNode->nodeName; if ($parentNodeName != self::PAGE_NODENAME) { return null; // no parent node, which is a page (e.g. XML documentRoot) } return $parentNode->getAttribute('id'); }
/** * @param SMSPage $page */ public function set404Page(SMSPage $page) { $this->set404PageId($page->getId()); }
/** * @return SMSPage */ public final function getOuterPage() { return $this->SMSPage->getOuterPage(); }