protected function BeforeInit()
 {
     if (!self::Guard()->Allow(BackendAction::Read(), $this)) {
         //TODO: message
         Response::Redirect(BackendRouter::ModuleUrl(new Overview()));
         return false;
     }
     return parent::BeforeInit();
 }
 /**
  * Gets and checks the requested user
  * @return boolean False if processing can continue
  */
 protected function BeforeInit()
 {
     $this->user = User::Schema()->ByID(Request::GetData('user'));
     if (!$this->user || !self::Guard()->Allow(BackendAction::AssignGroups(), $this->user)) {
         //TODO: Error message
         Response::Redirect(BackendRouter::ModuleUrl(new UserList()));
     }
     return parent::BeforeInit();
 }
Exemple #3
0
 private function AddModulesField()
 {
     $name = 'Module';
     $select = new Select($name, '');
     $select->AddOption('', Trans('Core.PleaseSelect'));
     $this->AddField($select);
     $this->SetRequired($name);
     foreach (PathUtil::Bundles() as $bundle) {
         $modules = PathUtil::FrontendModules($bundle);
         foreach ($modules as $moduleName) {
             $type = ClassFinder::CalcModuleType($bundle, $moduleName);
             $module = ClassFinder::CreateFrontendModule($type);
             if ($module instanceof FrontendModule && self::Guard()->Allow(BackendAction::UseIt(), $module->ContentForm())) {
                 $this->AddModuleTypeOption($select, $type);
             }
             //$select->AddOption($type, Trans($type));
         }
     }
 }
 /**
  * True if contents can be added to root element
  * @return boolean
  */
 protected function CanCreateIn()
 {
     return self::Guard()->GrantAddContentToContainer($this->container)->ToBool() && self::Guard()->Allow(BackendAction::UseIt(), new ModuleForm());
 }
Exemple #5
0
 /**
  * True if user can delete the member
  * @param Member $member
  * @return bool
  */
 protected function CanDelete(Member $member)
 {
     return self::Guard()->Allow(BackendAction::Delete(), $member);
 }
Exemple #6
0
 protected function CanChangeIsAdmin()
 {
     return self::Guard()->Allow(BackendAction::ChangeIsAdmin(), $this->user);
 }
Exemple #7
0
 /**
  * True if the area is locked
  * @param Area $area
  * @return bool
  */
 protected function IsLocked(Area $area)
 {
     return !BackendModule::Guard()->Allow(BackendAction::Read(), $area);
 }
 /**
  * True if user can delete the member group
  * @param Membergroup $group
  * @return bool
  */
 protected function CanDelete(Membergroup $group)
 {
     return self::Guard()->Allow(BackendAction::Delete(), $group);
 }
Exemple #9
0
 /**
  * True if layout can be deleted
  * @param Layout $layout The layout
  * @return boo
  */
 protected function CanDelete(Layout $layout)
 {
     return self::Guard()->Allow(BackendAction::Delete(), $layout) && self::Guard()->Allow(BackendAction::UseIt(), new LayoutForm());
 }
Exemple #10
0
 protected function CanCreateIn()
 {
     return self::Guard()->GrantAddPageToSite($this->site)->ToBool() && self::Guard()->Allow(BackendAction::UseIt(), new PageForm());
 }
Exemple #11
0
 /**
  * Grant evaluation for adding content on top of a container
  * @param Container $container The container
  * @return GrantResult Returns the grant result telling if creation is allowed
  */
 function GrantAddContentToContainer(Container $container)
 {
     //dummy content for evaluation
     $content = new Content();
     $content->SetUserGroup($container->GetUserGroup());
     $containerRights = $container->GetUserGroupRights();
     if ($containerRights) {
         $content->SetUserGroupRights($containerRights->GetContentRights());
     }
     return $this->Grant(BackendAction::Create(), $content);
 }
 /**
  * True if there can be content created after
  * @return boolean
  */
 protected final function CanCreateAfter()
 {
     $parentItem = $this->tree->ParentOf($this->item);
     if ($parentItem) {
         $parent = $this->tree->ContentByItem($parentItem);
         return BackendModule::Guard()->Allow(BackendAction::Create(), $parent);
     }
     return $this->GrantCreateInRoot()->ToBool();
 }
 /**
  * 
  * True if user can lock modules
  * @return bool Returns true if current user can lock (backend) modules for a group
  */
 protected function CanLockModules(Usergroup $group)
 {
     return self::Guard()->Allow(BackendAction::ChangeIsAdmin(), $group);
 }
 /**
  * True if the container can be removed
  * @param Container $container
  * @return boolean
  */
 protected function CanDelete(Container $container)
 {
     return self::Guard()->Allow(BackendAction::Delete(), $container);
 }
Exemple #15
0
 /**
  * True if user group can be assigned
  * @return bool
  */
 protected function CanAssignGroup()
 {
     return self::Guard()->Allow(BackendAction::AssignGroups(), $this->site);
 }
Exemple #16
0
 /**
  * True if user can delete the site
  * @param Site $site
  * @return bool
  */
 protected function CanDelete(Site $site)
 {
     return self::Guard()->Allow(BackendAction::Delete(), $site);
 }
Exemple #17
0
 protected function CanDelete(Area $area)
 {
     return self::Guard()->Allow(BackendAction::Delete(), $area);
 }
Exemple #18
0
 private function CanAssignGroup()
 {
     return self::Guard()->Allow(BackendAction::AssignGroups(), $this->Content());
 }
Exemple #19
0
 /**
  * The modules for the backend navigation
  * @return Returns an array with bundle names as keys and backend modules as list
  */
 static function BackendNavModules()
 {
     $result = array();
     $allBundles = PathUtil::Bundles();
     //force Core to appear first
     $coreKey = array_search('Core', $allBundles);
     unset($allBundles[$coreKey]);
     array_unshift($allBundles, 'Core');
     $bundles = array_values($allBundles);
     foreach ($bundles as $bundle) {
         $modules = PathUtil::BackendModules($bundle);
         foreach ($modules as $module) {
             $type = self::CalcModuleType($bundle, $module);
             $instance = self::CreateBackendModule($type);
             if (!$instance instanceof BackendModule) {
                 continue;
             }
             if ($instance->SideNavIndex() >= 0 && BackendModule::Guard()->Allow(BackendAction::Read(), $instance)) {
                 self::AddBackendNavModule($result, $instance);
             }
         }
     }
     return self::SortByNavIndex($result);
 }
 /**
  * True if contents can be added to root element
  * @return boolean
  */
 protected function CanCreateIn()
 {
     return self::Guard()->GrantAddContentToPageArea($this->page, $this->area)->ToBool() && self::Guard()->Allow(BackendAction::UseIt(), new ModuleForm());
 }