示例#1
0
 /**
  * Calculates the grant result for a group on a content
  * @param Usergroup $group The evaluated group
  * @param Usergroup $contentGroup The group of the content
  * @param BackendContentRights $contentRights The rights of the content
  * @param BackendAction $action The action that shall be taken for the content
  * @return GrantResult Returns the calculated result
  */
 private function GrantGroupOnContent(Usergroup $group, Usergroup $contentGroup, BackendContentRights $contentRights, BackendAction $action)
 {
     if (!$group->Equals($contentGroup)) {
         return GrantResult::NoAccess();
     }
     $allowed = false;
     switch ($action) {
         case BackendAction::Create():
             $allowed = $contentRights->GetCreateIn();
             break;
         case BackendAction::Edit():
             $allowed = $contentRights->GetEdit();
             break;
         case BackendAction::Move():
             $allowed = $contentRights->GetMove();
             break;
         case BackendAction::Delete():
             $allowed = $contentRights->GetRemove();
             break;
         case BackendAction::Read():
             $allowed = $this->HasAnyContentRight($contentRights);
             break;
     }
     return $allowed ? GrantResult::Allowed() : GrantResult::NoAccess();
 }