/** * Finds the parent group * @return Usergroup */ private function FindParentGroup() { $parentGroup = null; $parentContent = $this->Content()->Exists() ? ContentTreeUtil::ParentOf($this->Content()) : null; if ($parentContent) { $parentGroup = GroupFinder::FindContentGroup($parentContent); } if (!$parentGroup) { switch ($this->Location()) { case Enums\ContentLocation::Page(): $parentGroup = GroupFinder::FindPageGroup($this->Page()); break; case Enums\ContentLocation::Layout(): $parentGroup = $this->Area()->GetLayout()->GetUserGroup(); break; case Enums\ContentLocation::Container(): $parentGroup = $this->Container()->GetUserGroup(); break; } } return $parentGroup; }
/** * 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(); }