/** * Finds the parent rights * @return BackendContentRights */ private function FindParentRights() { $parentRights = null; $parentContent = $this->Content()->Exists() ? ContentTreeUtil::ParentOf($this->Content()) : null; if ($parentContent) { $parentRights = RightsFinder::FindContentRights($parentContent); } if (!$parentRights) { switch ($this->Location()) { case Enums\ContentLocation::Page(): $pageRights = RightsFinder::FindPageRights($this->Page()); $parentRights = $pageRights ? $pageRights->GetContentRights() : null; break; case Enums\ContentLocation::Layout(): $layoutRights = $this->Area()->GetLayout()->GetUserGroupRights(); $parentRights = $layoutRights ? $layoutRights->GetContentRights() : null; break; case Enums\ContentLocation::Container(): $containerRights = $this->Container()->GetUserGroupRights(); $parentRights = $containerRights ? $containerRights->GetContentRights() : null; break; } } return $parentRights; }
/** * Calculates the grant result for a content * @param Content $content The content * @param BackendAction $action The action that shall be taken on the content * @return GrantResult Returns the calculated grant result */ private function GrantOnContent(Content $content, BackendAction $action) { if ($this->GetUser()->Equals($content->GetUser())) { return GrantResult::Allowed(); } $contentRights = RightsFinder::FindContentRights($content); $contentGroup = GroupFinder::FindContentGroup($content); if (!$contentRights || !$contentGroup) { return GrantResult::NoAccess(); } $groups = $this->GetGroups(); foreach ($groups as $group) { $result = $this->GrantGroupOnContent($group, $contentGroup, $contentRights, $action); if ($result->Equals(GrantResult::Allowed())) { return $result; } } return GrantResult::NoAccess(); }