コード例 #1
0
ファイル: UserGuard.php プロジェクト: agentmedia/phine-core
 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();
 }
コード例 #2
0
ファイル: MemberGuard.php プロジェクト: agentmedia/phine-core
 /**
  * Checks access to an item by its properties and assigned groups
  * @param boolean $guestsOnly True if guests only see the item
  * @param boolean $publish True if item is generally published
  * @param Date $from The start date of publishing
  * @param Date $to The end date of publishing
  * @param Membergroup[] $groups Groups assigned to the item
  * @return GrantResult
  */
 private function GrantByProperties($guestsOnly, $publish, Date $from = null, Date $to = null, array $groups = array())
 {
     if (!PublishDateUtil::IsPublishedNow($publish, $from, $to)) {
         return GrantResult::NoAccess();
     }
     if ($this->GetMember() && $guestsOnly) {
         return GrantResult::NoAccess();
     }
     if (count($groups) == 0) {
         return GrantResult::Allowed();
     }
     if (!$this->GetMember()) {
         return GrantResult::LoginRequired();
     }
     $groupIDs = Membergroup::GetKeyList($groups);
     $memberGroupIDs = Membergroup::GetKeyList($this->Groups());
     return count(array_intersect($groupIDs, $memberGroupIDs)) ? GrantResult::Allowed() : GrantResult::NoAccess();
 }