Exemplo n.º 1
0
 public function Grant(Action $action, $onObject)
 {
     if (!$this->GetUser()) {
         return GrantResult::LoginRequired();
     }
     if ($onObject instanceof User) {
         return $this->GrantOnUser($action, $onObject);
     }
     if ($this->IsAdministrator()) {
         return GrantResult::Allowed();
     }
     if ($onObject instanceof Site) {
         if (!$onObject->Exists() && (string) $action == (string) Action::Create()) {
             return $this->GrantCreateSite();
         }
         return $this->GrantOnSite($onObject, $action);
     } else {
         if ($onObject instanceof Page) {
             return $this->GrantOnPage($onObject, $action);
         } else {
             if ($onObject instanceof Container) {
                 if (!$onObject->Exists() && (string) $action == (string) Action::Create()) {
                     return $this->GrantCreateContainer();
                 }
                 return $this->GrantOnContainer($onObject, $action);
             } else {
                 if ($onObject instanceof Area) {
                     return $this->GrantOnArea($onObject, $action);
                 } else {
                     if ($onObject instanceof Layout) {
                         if (!$onObject->Exists() && (string) $action == (string) Action::Create()) {
                             return $this->GrantCreateLayout();
                         }
                         return $this->GrantOnLayout($onObject, $action);
                     } else {
                         if ($onObject instanceof Content) {
                             return $this->GrantOnContent($onObject, $action);
                         } else {
                             if ($onObject instanceof ModuleBase) {
                                 return $this->GrantOnModule($onObject);
                             }
                         }
                     }
                 }
             }
         }
     }
     return GrantResult::NoAccess();
 }