hasPermission() public method

public hasPermission ( $subject, $permission ) : boolean
$subject
$permission
return boolean
コード例 #1
0
 /**
  * {@inheritdoc}
  */
 public function getNavigationItems(array $options = [])
 {
     $content = new ContentNavigationItem('content-navigation.contents.content');
     $content->setId('tab-content');
     $content->setAction('content');
     $content->setComponent('content/form@sulucontent');
     $seo = new ContentNavigationItem('content-navigation.contents.seo');
     $seo->setId('tab-seo');
     $seo->setAction('seo');
     $seo->setComponent('content/seo@sulucontent');
     $seo->setDisplay(['edit']);
     $excerpt = new ContentNavigationItem('content-navigation.contents.excerpt');
     $excerpt->setId('tab-excerpt');
     $excerpt->setAction('excerpt');
     $excerpt->setComponent('content/excerpt@sulucontent');
     $excerpt->setDisplay(['edit']);
     $settings = new ContentNavigationItem('content-navigation.contents.settings');
     $settings->setId('tab-settings');
     $settings->setAction('settings');
     $settings->setComponent('content/settings@sulucontent');
     $settings->setDisplay(['edit']);
     $navigation = [$content, $seo, $excerpt, $settings];
     $securityContext = 'sulu.webspaces.' . $options['webspace'];
     if ($this->enabledSecurity && $this->securityChecker->hasPermission($securityContext, 'security')) {
         $permissions = new ContentNavigationItem('Permissions');
         $permissions->setAction('permissions');
         $permissions->setDisplay(['edit']);
         $permissions->setComponent('permission-tab@sulusecurity');
         $permissions->setComponentOptions(['display' => 'form', 'type' => SecurityBehavior::class, 'securityContext' => $securityContext]);
         $navigation[] = $permissions;
     }
     return $navigation;
 }
コード例 #2
0
ファイル: MediaAdmin.php プロジェクト: kriswillis/sulu
 public function __construct(SecurityCheckerInterface $securityChecker, $title)
 {
     $this->securityChecker = $securityChecker;
     $rootNavigationItem = new NavigationItem($title);
     $section = new NavigationItem('');
     $media = new NavigationItem('navigation.media');
     $media->setIcon('image');
     if ($this->securityChecker->hasPermission('sulu.media.collections', 'view')) {
         $collections = new DataNavigationItem('navigation.media.collections', '/admin/api/collections?sortBy=title', $media);
         $collections->setId('collections-edit');
         $collections->setAction('media/collections/root');
         $collections->setInstanceName('collections');
         $collections->setDataNameKey('title');
         $collections->setDataResultKey('collections');
         $collections->setShowAddButton(true);
         $collections->setTitleTranslationKey('navigation.media.collections');
         $collections->setNoDataTranslationKey('');
         $collections->setAddButtonTranslationKey('navigation.media.collections.add');
         $collections->setSearchTranslationKey('navigation.media.collections.search');
     }
     if ($media->hasChildren()) {
         $section->addChild($media);
         $rootNavigationItem->addChild($section);
     }
     $this->setNavigation(new Navigation($rootNavigationItem));
 }
コード例 #3
0
ファイル: ContentAdmin.php プロジェクト: Silwereth/sulu
 public function __construct(WebspaceManagerInterface $webspaceManager, SecurityCheckerInterface $securityChecker, SessionManagerInterface $sessionManager, $title)
 {
     $this->webspaceManager = $webspaceManager;
     $this->securityChecker = $securityChecker;
     $this->sessionManager = $sessionManager;
     $rootNavigationItem = new NavigationItem($title);
     $section = new NavigationItem('navigation.webspaces');
     $rootNavigationItem->addChild($section);
     /** @var Webspace $webspace */
     foreach ($this->webspaceManager->getWebspaceCollection() as $webspace) {
         if ($this->securityChecker->hasPermission(self::SECURITY_CONTEXT_PREFIX . $webspace->getKey(), 'view')) {
             $webspaceItem = new NavigationItem($webspace->getName());
             $webspaceItem->setIcon('bullseye');
             $indexUuid = $this->sessionManager->getContentNode($webspace->getKey())->getIdentifier();
             $indexPageItem = new NavigationItem('navigation.webspaces.index-page');
             $indexPageItem->setAction('content/contents/' . $webspace->getKey() . '/edit:' . $indexUuid . '/details');
             $webspaceItem->addChild($indexPageItem);
             $contentItem = new NavigationItem('navigation.webspaces.content');
             $contentItem->setAction('content/contents/' . $webspace->getKey());
             $webspaceItem->addChild($contentItem);
             $section->addChild($webspaceItem);
         }
     }
     $this->setNavigation(new Navigation($rootNavigationItem));
 }
コード例 #4
0
ファイル: ContentAdmin.php プロジェクト: sulu/sulu
 public function __construct(WebspaceManagerInterface $webspaceManager, SecurityCheckerInterface $securityChecker, SessionManagerInterface $sessionManager, $title)
 {
     $this->webspaceManager = $webspaceManager;
     $this->securityChecker = $securityChecker;
     $this->sessionManager = $sessionManager;
     $rootNavigationItem = new NavigationItem($title);
     $section = new NavigationItem('navigation.webspaces');
     $section->setPosition(10);
     $rootNavigationItem->addChild($section);
     $position = 10;
     /** @var Webspace $webspace */
     foreach ($this->webspaceManager->getWebspaceCollection() as $webspace) {
         if ($this->securityChecker->hasPermission(self::SECURITY_CONTEXT_PREFIX . $webspace->getKey(), PermissionTypes::VIEW)) {
             $webspaceItem = new NavigationItem($webspace->getName());
             $webspaceItem->setPosition($position++);
             $webspaceItem->setIcon('bullseye');
             $indexUuid = $this->sessionManager->getContentNode($webspace->getKey())->getIdentifier();
             $indexPageItem = new NavigationItem('navigation.webspaces.index-page');
             $indexPageItem->setPosition(10);
             $indexPageItem->setAction('content/contents/' . $webspace->getKey() . '/edit:' . $indexUuid . '/content');
             $webspaceItem->addChild($indexPageItem);
             $contentItem = new NavigationItem('navigation.webspaces.content');
             $contentItem->setPosition(20);
             $contentItem->setAction('content/contents/' . $webspace->getKey());
             $webspaceItem->addChild($contentItem);
             $webspaceSettingsItem = new NavigationItem('navigation.webspaces.settings');
             $webspaceSettingsItem->setPosition(30);
             $webspaceSettingsItem->setAction(sprintf('content/webspace/settings:%s/general', $webspace->getKey()));
             $webspaceItem->addChild($webspaceSettingsItem);
             $section->addChild($webspaceItem);
         }
     }
     $this->setNavigation(new Navigation($rootNavigationItem));
 }
コード例 #5
0
ファイル: ContactAdmin.php プロジェクト: sulu/sulu
 public function __construct(SecurityCheckerInterface $securityChecker, $title)
 {
     $this->securityChecker = $securityChecker;
     $rootNavigationItem = new NavigationItem($title);
     $section = new NavigationItem('navigation.modules');
     $section->setPosition(20);
     $contacts = new NavigationItem('navigation.contacts');
     $contacts->setPosition(30);
     $contacts->setIcon('user');
     if ($this->securityChecker->hasPermission('sulu.contact.people', PermissionTypes::VIEW)) {
         $people = new NavigationItem('navigation.contacts.people');
         $people->setPosition(10);
         $people->setIcon('users');
         $people->setAction('contacts/contacts');
         $contacts->addChild($people);
     }
     if ($this->securityChecker->hasPermission('sulu.contact.organizations', PermissionTypes::VIEW)) {
         $companies = new NavigationItem('navigation.contacts.companies');
         $companies->setPosition(20);
         $companies->setIcon('building');
         $companies->setAction('contacts/accounts');
         $contacts->addChild($companies);
     }
     if ($contacts->hasChildren()) {
         $rootNavigationItem->addChild($section);
         $section->addChild($contacts);
     }
     $this->setNavigation(new Navigation($rootNavigationItem));
 }
コード例 #6
0
 /**
  * {@inheritdoc}
  */
 public function getNavigationItems(array $options = [])
 {
     if (!$this->securityChecker->hasPermission(CustomUrlAdmin::getCustomUrlSecurityContext($options['webspace']), PermissionTypes::VIEW)) {
         return [];
     }
     $contentNavigationItem = new ContentNavigationItem('content-navigation.webspace.custom-url');
     $contentNavigationItem->setId('tab-custom-urls');
     $contentNavigationItem->setAction('custom-urls');
     $contentNavigationItem->setPosition(40);
     $contentNavigationItem->setComponent('webspace/settings/custom-url@sulucustomurl');
     return [$contentNavigationItem];
 }
コード例 #7
0
 /**
  * {@inheritdoc}
  */
 public function getNavigationItems(array $options = [])
 {
     if (!$this->securityChecker->hasPermission(SnippetAdmin::getDefaultSnippetsSecurityContext($options['webspace']), PermissionTypes::VIEW) || !$this->defaultEnabled) {
         return [];
     }
     $snippets = new ContentNavigationItem('content-navigation.webspace.snippets');
     $snippets->setId('tab-snippets');
     $snippets->setAction('snippets');
     $snippets->setPosition(25);
     $snippets->setComponent('webspace/settings/snippets@sulusnippet');
     return [$snippets];
 }
コード例 #8
0
 public function getNavigationItems(array $options = [])
 {
     $navigation = [];
     if ($this->securityChecker->hasPermission('sulu.security.users', 'view')) {
         $permissions = new ContentNavigationItem('content-navigation.security.permissions');
         $permissions->setAction('permissions');
         $permissions->setComponent('users@sulusecurity');
         $permissions->setDisplay(['edit']);
         $navigation[] = $permissions;
     }
     return $navigation;
 }
コード例 #9
0
 /**
  * {@inheritdoc}
  */
 public function getNavigationItems(array $options = [])
 {
     if (!$this->securityChecker->hasPermission(WebsiteAdmin::getAnalyticsSecurityContext($options['webspace']), PermissionTypes::VIEW)) {
         return [];
     }
     $analytics = new ContentNavigationItem('content-navigation.webspace.analytics');
     $analytics->setId('tab-analytics');
     $analytics->setAction('analytics');
     $analytics->setPosition(20);
     $analytics->setComponent('webspace/settings/analytics@suluwebsite');
     return [$analytics];
 }
コード例 #10
0
 /**
  * @param SecurityCheckerInterface $securityChecker
  * @param string                   $title
  */
 public function __construct(SecurityCheckerInterface $securityChecker, $title)
 {
     $this->securityChecker = $securityChecker;
     $rootNavigationItem = new NavigationItem($title);
     $section = new NavigationItem('');
     if ($this->securityChecker->hasPermission('sulu.event.events', 'view')) {
         $shop = new NavigationItem('sulu.navigation.events');
         $shop->setIcon('calendar');
         $shop->setAction('events');
         $section->addChild($shop);
         $rootNavigationItem->addChild($section);
     }
     $this->setNavigation(new Navigation($rootNavigationItem));
 }
コード例 #11
0
ファイル: MediaAdmin.php プロジェクト: sulu/sulu
 public function __construct(SecurityCheckerInterface $securityChecker, $title)
 {
     $this->securityChecker = $securityChecker;
     $rootNavigationItem = new NavigationItem($title);
     $section = new NavigationItem('navigation.modules');
     $section->setPosition(20);
     if ($this->securityChecker->hasPermission('sulu.media.collections', PermissionTypes::VIEW)) {
         $media = new NavigationItem('navigation.media');
         $media->setPosition(20);
         $media->setIcon('image');
         $media->setAction('media/collections');
         $section->addChild($media);
         $rootNavigationItem->addChild($section);
     }
     $this->setNavigation(new Navigation($rootNavigationItem));
 }
コード例 #12
0
ファイル: CategoryAdmin.php プロジェクト: kriswillis/sulu
 public function __construct(SecurityCheckerInterface $securityChecker, $title)
 {
     $this->securityChecker = $securityChecker;
     $rootNavigationItem = new NavigationItem($title);
     $section = new NavigationItem('');
     $settings = new NavigationItem('navigation.settings');
     $settings->setIcon('cog');
     if ($this->securityChecker->hasPermission('sulu.settings.categories', 'view')) {
         $categories = new NavigationItem('navigation.settings.categories', $settings);
         $categories->setAction('settings/categories');
     }
     if ($settings->hasChildren()) {
         $section->addChild($settings);
         $rootNavigationItem->addChild($section);
     }
     $this->setNavigation(new Navigation($rootNavigationItem));
 }
コード例 #13
0
ファイル: SnippetAdmin.php プロジェクト: sulu/sulu
 public function __construct(SecurityCheckerInterface $securityChecker, WebspaceManagerInterface $webspaceManager, $defaultEnabled, $title)
 {
     $this->securityChecker = $securityChecker;
     $this->webspaceManager = $webspaceManager;
     $this->defaultEnabled = $defaultEnabled;
     $rootNavigationItem = new NavigationItem($title);
     $section = new NavigationItem('navigation.modules');
     $section->setPosition(20);
     if ($this->securityChecker->hasPermission('sulu.global.snippets', 'view')) {
         $snippet = new NavigationItem('navigation.snippets');
         $snippet->setPosition(10);
         $snippet->setIcon('sticky-note-o');
         $snippet->setAction('snippet/snippets');
         $section->addChild($snippet);
         $rootNavigationItem->addChild($section);
     }
     $this->setNavigation(new Navigation($rootNavigationItem));
 }
コード例 #14
0
 /**
  * {@inheritdoc}
  */
 public function getNavigationItems(array $options = [])
 {
     $content = new ContentNavigationItem('content-navigation.contents.content');
     $content->setId('tab-content');
     $content->setPosition(10);
     $content->setAction('content');
     $content->setComponent('content/form@sulucontent');
     $content->setDisplayConditions([new DisplayCondition('linked', DisplayCondition::OPERATOR_EQUAL, null), new DisplayCondition('shadowOn', DisplayCondition::OPERATOR_EQUAL, false)]);
     $seo = new ContentNavigationItem('content-navigation.contents.seo');
     $seo->setId('tab-seo');
     $seo->setPosition(20);
     $seo->setAction('seo');
     $seo->setComponent('content/seo@sulucontent');
     $seo->setDisplay(['edit']);
     $seo->setDisplayConditions([new DisplayCondition('url', DisplayCondition::OPERATOR_NOT_EQUAL, ''), new DisplayCondition('linked', DisplayCondition::OPERATOR_EQUAL, null), new DisplayCondition('shadowOn', DisplayCondition::OPERATOR_EQUAL, false)]);
     $excerpt = new ContentNavigationItem('content-navigation.contents.excerpt');
     $excerpt->setId('tab-excerpt');
     $excerpt->setPosition(30);
     $excerpt->setAction('excerpt');
     $excerpt->setComponent('content/excerpt@sulucontent');
     $excerpt->setDisplay(['edit']);
     $excerpt->setDisplayConditions([new DisplayCondition('url', DisplayCondition::OPERATOR_NOT_EQUAL, ''), new DisplayCondition('linked', DisplayCondition::OPERATOR_NOT_EQUAL, 'internal'), new DisplayCondition('shadowOn', DisplayCondition::OPERATOR_EQUAL, false)]);
     $settings = new ContentNavigationItem('content-navigation.contents.settings');
     $settings->setId('tab-settings');
     $settings->setPosition(40);
     $settings->setAction('settings');
     $settings->setComponent('content/settings@sulucontent');
     $settings->setDisplay(['edit']);
     $settings->setDisplayConditions([new DisplayCondition('url', DisplayCondition::OPERATOR_NOT_EQUAL, '')]);
     $navigation = [$content, $seo, $excerpt, $settings];
     $securityContext = 'sulu.webspaces.' . $options['webspace'];
     if ($this->enabledSecurity && $this->securityChecker->hasPermission($securityContext, PermissionTypes::SECURITY)) {
         $permissions = new ContentNavigationItem('content-navigation.contents.permissions');
         $permissions->setId('tab-permissions');
         $permissions->setAction('permissions');
         $permissions->setPosition(50);
         $permissions->setDisplay(['edit']);
         $permissions->setComponent('permission-tab@sulusecurity');
         $permissions->setComponentOptions(['display' => 'form', 'type' => SecurityBehavior::class, 'securityContext' => $securityContext]);
         $permissions->setDisplayConditions([new DisplayCondition('url', DisplayCondition::OPERATOR_NOT_EQUAL, '')]);
         $navigation[] = $permissions;
     }
     return $navigation;
 }
コード例 #15
0
 public function __construct(SecurityCheckerInterface $securityChecker, $title)
 {
     $this->securityChecker = $securityChecker;
     $rootNavigationItem = new NavigationItem($title);
     $section = new NavigationItem('');
     $sales = new NavigationItem('navigation.sales');
     $sales->setPosition(20);
     $sales->setIcon('shopping-cart');
     if ($this->securityChecker->hasPermission('sulu.sales_order.orders', 'view')) {
         $order = new NavigationItem('navigation.sales.order', $sales);
         $order->setAction('sales/orders');
         $order->setPosition(10);
     }
     if ($sales->hasChildren()) {
         $section->addChild($sales);
         $rootNavigationItem->addChild($section);
     }
     $this->setNavigation(new Navigation($rootNavigationItem));
 }
コード例 #16
0
ファイル: SnippetAdmin.php プロジェクト: kriswillis/sulu
 public function __construct(SecurityCheckerInterface $securityChecker, $title)
 {
     $this->securityChecker = $securityChecker;
     $rootNavigationItem = new NavigationItem($title);
     $section = new NavigationItem('navigation.webspaces');
     $global = new NavigationItem('navigation.global-content');
     $global->setIcon('globe');
     $section->addChild($global);
     if ($this->securityChecker->hasPermission('sulu.global.snippets', 'view')) {
         $snippet = new NavigationItem('navigation.snippets');
         $snippet->setIcon('bullseye');
         $snippet->setAction('snippet/snippets');
         $global->addChild($snippet);
     }
     if ($global->hasChildren()) {
         $rootNavigationItem->addChild($section);
     }
     $this->setNavigation(new Navigation($rootNavigationItem));
 }
コード例 #17
0
ファイル: WebsiteAdmin.php プロジェクト: sulu/sulu
 /**
  * Check the permissions for all webspaces.
  * Returns true if the user has live permission in all webspaces.
  *
  * @return bool
  */
 private function checkLivePermissionForAllWebspaces()
 {
     foreach ($this->webspaceManager->getWebspaceCollection() as $webspace) {
         $context = ContentAdmin::SECURITY_CONTEXT_PREFIX . $webspace->getKey();
         if (!$this->securityChecker->hasPermission($context, PermissionTypes::LIVE)) {
             return false;
         }
     }
     return true;
 }
コード例 #18
0
ファイル: SecurityAdmin.php プロジェクト: sulu/sulu
 public function __construct(SecurityCheckerInterface $securityChecker, $title)
 {
     $this->securityChecker = $securityChecker;
     $rootNavigationItem = new NavigationItem($title);
     $section = new NavigationItem('navigation.modules');
     $section->setPosition(20);
     $settings = new NavigationItem('navigation.settings');
     $settings->setPosition(40);
     $settings->setIcon('gear');
     if ($this->securityChecker->hasPermission('sulu.security.roles', PermissionTypes::VIEW)) {
         $roles = new NavigationItem('security.roles.title', $settings);
         $roles->setPosition(10);
         $roles->setAction('settings/roles');
         $roles->setIcon('gear');
     }
     if ($settings->hasChildren()) {
         $section->addChild($settings);
         $rootNavigationItem->addChild($section);
     }
     $this->setNavigation(new Navigation($rootNavigationItem));
 }
コード例 #19
0
ファイル: ContentAdmin.php プロジェクト: kriswillis/sulu
 public function __construct(WebspaceManagerInterface $webspaceManager, SecurityCheckerInterface $securityChecker, $title)
 {
     $this->webspaceManager = $webspaceManager;
     $this->securityChecker = $securityChecker;
     $rootNavigationItem = new NavigationItem($title);
     $section = new NavigationItem('navigation.webspaces');
     $rootNavigationItem->addChild($section);
     /** @var Webspace $webspace */
     foreach ($this->webspaceManager->getWebspaceCollection() as $webspace) {
         if ($this->securityChecker->hasPermission($this->securityContextPrefix . $webspace->getKey(), 'view')) {
             $webspaceItem = new NavigationItem($webspace->getName());
             $webspaceItem->setIcon('bullseye');
             $indexPageItem = new NavigationItem('navigation.webspaces.index-page');
             $indexPageItem->setAction('content/contents/' . $webspace->getKey() . '/edit:index/details');
             $webspaceItem->addChild($indexPageItem);
             $contentItem = new NavigationItem('navigation.webspaces.content');
             $contentItem->setAction('content/contents/' . $webspace->getKey());
             $webspaceItem->addChild($contentItem);
             $section->addChild($webspaceItem);
         }
     }
     $this->setNavigation(new Navigation($rootNavigationItem));
 }
コード例 #20
0
ファイル: SearchController.php プロジェクト: ollietb/sulu
 /**
  * @return array
  */
 private function getAllowedIndexes()
 {
     $allowedIndexNames = [];
     $indexNames = $this->searchManager->getIndexNames();
     foreach ($indexNames as $indexName) {
         $indexConfiguration = $this->indexConfigurationProvider->getIndexConfiguration($indexName);
         if (!$indexConfiguration) {
             $allowedIndexNames[] = $indexName;
             continue;
         }
         if ($this->securityChecker->hasPermission($indexConfiguration->getSecurityContext(), 'view')) {
             $allowedIndexNames[] = $indexName;
         }
     }
     return $allowedIndexNames;
 }
コード例 #21
0
ファイル: SearchController.php プロジェクト: sulu/sulu
 /**
  * @return array
  */
 private function getAllowedIndexes()
 {
     $allowedIndexNames = [];
     $indexNames = $this->searchManager->getIndexNames();
     foreach ($indexNames as $indexName) {
         $indexConfiguration = $this->indexConfigurationProvider->getIndexConfiguration($indexName);
         if (!$indexConfiguration) {
             $allowedIndexNames[] = $indexName;
             continue;
         }
         $contexts = $indexConfiguration->getContexts();
         if ($this->securityChecker->hasPermission($indexConfiguration->getSecurityContext(), PermissionTypes::VIEW) && (empty($contexts) || array_search('admin', $contexts) !== false)) {
             $allowedIndexNames[] = $indexName;
         }
     }
     return $allowedIndexNames;
 }
コード例 #22
0
ファイル: SuluAdmin.php プロジェクト: symcloud/symcloud
 /**
  * @param SecurityCheckerInterface $securityChecker
  * @param TokenStorageInterface $tokenStorage
  * @param RepositoryInterface $repository
  * @param Router $router
  * @param string $title
  */
 public function __construct(SecurityCheckerInterface $securityChecker, TokenStorageInterface $tokenStorage, RepositoryInterface $repository, Router $router, $title)
 {
     $rootNavigationItem = new NavigationItem($title);
     $section = new NavigationItem('');
     $files = new NavigationItem('symcloud.file');
     $files->setIcon('folder-open');
     if ($securityChecker->hasPermission('symcloud.files', 'view') && $tokenStorage->getToken() !== null) {
         $session = $repository->loginByHash($tokenStorage->getToken()->getUser(), 'HEAD');
         $references = $session->getReferences();
         foreach ($references as $reference) {
             $referenceItem = new DataNavigationItem($reference->getName(), $router->generate('get_directory', array('reference' => $reference->getHash(), 'name-as-key' => 'true', 'only-directories' => 'true')));
             $referenceItem->setDataResultKey('children');
             $referenceItem->setAction('symcloud/path:' . $reference->getHash());
             $referenceItem->setShowAddButton(false);
             $files->addChild($referenceItem);
         }
     }
     if ($files->hasChildren()) {
         $rootNavigationItem->addChild($section);
         $section->addChild($files);
     }
     $this->setNavigation(new Navigation($rootNavigationItem));
 }