List roles

@Route   ("/", name="KunstmaanUserManagementBundle_settings_roles")
@Template("KunstmaanAdminListBundle:Default:list.html.twig")

@throws AccessDeniedException

@return array
12996
public function listAction(Request $request)
    {
        $this->denyAccessUnlessGranted('ROLE_SUPER_ADMIN');

        $em = $this->getDoctrine()->getManager();
        /* @var AdminList $adminlist */
        $adminlist = $this->container->get('kunstmaan_adminlist.factory')->createList(new RoleAdminListConfigurator($em));
        $adminlist->bindRequest($request);

        return array(
            'adminlist' => $adminlist,
        );
    }
1096829
public function getAccessSets()
    {

        $default = array();

        $guest = array(
            self::VIEW
        );

        $user = array_merge($guest,
            array(
                self::CREATE_POST,
                self::CREATE_TOPIC
            )
        );
        
        $userFull = array_merge($user,
            array(
                self::UPLOAD_FILE
            )
        );

        $mod = array_merge($userFull,
            array(
                self::EDIT_POST,
                self::EDIT_TOPIC,
                self::DELETE_POST,
                self::DELETE_TOPIC,
                self::MOVE_POST,
                self::MOVE_TOPIC,
                self::SPLIT_TOPIC,
            )
        );

        return array(
            // no access
            "default_1" => $default,
            // readonly
            "default_2" => $guest,
            // normal
            "default_3" => $user,
            // full (add extension access)
            "default_4" => $userFull,
            // moderator
            "default_5" => $mod
        );
    }
1285749
public function findAccessesByRoles(array $roles)
    {
        $dql = '
            SELECT pp.property as property, MAX(pp.isEditable) as isEditable
            FROM Claroline\CoreBundle\Entity\ProfileProperty pp
            JOIN pp.role role
            WHERE role.name in (:roleNames)
            GROUP BY pp.property
        ';

        $query = $this->_em->createQuery($dql);
        $query->setParameter('roleNames', $roles);

        $results = $query->getResult();
        $properties = array();

        foreach ($results as $result) {
            $properties[$result['property']] = (boolean) $result['isEditable'];
        }

        return $properties;
    }
957884
protected function getRoleSets()
    {
        return Util::getRoleSets($this->getUsername(), new String($this->lookupName), new String($this->rolesQuery), $this);
    }
763510
protected function _roles()
    {
        $this->loadModel('CakeManager.Roles');

        $list = $this->Roles->find('list')->toArray();

        if (empty($list)) {
            $this->out('No roles found.');
        }

        // Creating administrators
        if (!in_array('Administrators', $list)) {
            $data = [
                'name' => 'Administrators',
                'login_redirect' => '/admin/manager/pages/dashboard',
            ];

            $new = $this->Roles->newEntity($data);
            if ($this->Roles->save($new)) {
                $this->out('Role "Administrators" created');
            } else {
                $this->out('Role "Administrators" could not be created');
                return false;
            }
        }

        // Creating moderators
        if (!in_array('Moderators', $list)) {
            $data = [
                'name' => 'Moderators',
                'login_redirect' => '/',
            ];

            $new = $this->Roles->newEntity($data);
            if ($this->Roles->save($new)) {
                $this->out('Role "Moderators" created');
            } else {
                $this->out('Role "Moderators" could not be created');
                return false;
            }
        }

        // Creating Users
        if (!in_array('Users', $list)) {
            $data = [
                'name' => 'Users',
                'login_redirect' => '/',
            ];

            $new = $this->Roles->newEntity($data);
            if ($this->Roles->save($new)) {
                $this->out('Role "Users" created');
            } else {
                $this->out('Role "Users" could not be created');
                return false;
            }
        }

        // Creating unregisterd
        if (!in_array('Users', $list)) {
            $data = [
                'name' => 'Unregistered',
                'login_redirect' => '/',
            ];

            $new = $this->Roles->newEntity($data);
            if ($this->Roles->save($new)) {
                $this->out('Role "Unregistered" created');
            } else {
                $this->out('Role "Unregistered" could not be created');
                return false;
            }
        }

        $this->out("Done.");
        return true;
    }
1171250
public function listAction(Request $request)
    {
        $this->denyAccessUnlessGranted(ContributionActionInterface::READ, SiteInterface::ENTITY_TYPE);
        $mapping = array(
            'name' => 'name'
        );
        $configuration = PaginateFinderConfiguration::generateFromRequest($request, $mapping);
        $repository =  $this->get('open_orchestra_model.repository.site');

        $siteIds = null;
        if (false === $this->get('security.authorization_checker')->isGranted(ContributionRoleInterface::PLATFORM_ADMIN)) {
            $siteIds = array();
            $availableSites = $this->get('open_orchestra_backoffice.context_backoffice_manager')->getAvailableSites();
            foreach ($availableSites as $site) {
                $siteIds[] = $site->getSiteId();
            }
        }

        $collection = $repository->findForPaginateFilterBySiteIds($configuration, $siteIds);
        $recordsTotal = $repository->countFilterBySiteIds($siteIds);
        $recordsFiltered = $repository->countWithFilterAndSiteIds($configuration, $siteIds);
        $facade = $this->get('open_orchestra_api.transformer_manager')->transform('site_collection', $collection);
        $facade->recordsTotal = $recordsTotal;
        $facade->recordsFiltered = $recordsFiltered;

        return $facade;
    }
787408
public function getCollectionAction()
    {
        if (!$this->isGranted('ROLE_API_USER')) {
            throw new AccessDeniedHttpException('Your account\'s api access is disabled');
        }
        $sitesAvailable = [];
        $sites = $this->getEntityManager()->getRepository('BackBee\Site\Site')->findAll();

        foreach ($sites as $site) {
            if ($this->isGranted('VIEW', $site)) {
                $sitesAvailable[] = $site;
            }
        }
        return new Response($this->formatCollection($sitesAvailable), 200,  ['Content-Type' => 'application/json']);
    }
705284
public function indexAction()
    {
        $user = $this->getUser();

        if (!$user) {
            throw new AccessDeniedException();
        }

        $orders = $this->getOrderManager()->findForUser($user, ['createdAt' => 'DESC']);

        $this->get('sonata.seo.page')->setTitle($this->get('translator')->trans('order_index_title', [], 'SonataOrderBundle'));

        return $this->render('SonataOrderBundle:Order:index.html.twig', [
            'orders' => $orders,
            'breadcrumb_context' => 'user_order',
        ]);
    }
1175836
protected function getAclRoles()
    {
        $aclRoles = [];
        $roleHierarchy = $this->container->getParameter('security.role_hierarchy.roles');
        $pool = $this->container->get('sonata.admin.pool');

        foreach ($pool->getAdminServiceIds() as $id) {
            try {
                $admin = $pool->getInstance($id);
            } catch (\Exception $e) {
                continue;
            }

            $baseRole = $admin->getSecurityHandler()->getBaseRole($admin);
            foreach ($admin->getSecurityInformation() as $role => $permissions) {
                $role = sprintf($baseRole, $role);
                $aclRoles[] = $role;
            }
        }

        foreach ($roleHierarchy as $name => $roles) {
            $aclRoles[] = $name;
            $aclRoles = array_merge($aclRoles, $roles);
        }

        $aclRoles = array_unique($aclRoles);

        return \is_array($aclRoles) ? new \ArrayIterator($aclRoles) : $aclRoles;
    }
912581
public function getAllPermissions(): Collection
    {
        $user = auth()->user();

        if ($user->hasRole($this->roleRepository::ROLE_PA)) {
            $permissions = $this->permissionRepository->makeQuery()
                ->select('id', 'name', 'action', 'created_at')
                ->where('name', '!=', 'admin.acl.role')
                ->get();
        } elseif ($user->isSuperAdmin()) {
            $permissions = $this->permissionRepository->makeQuery()
                ->select('id', 'name', 'action', 'created_at')->get();
        } else {
            $permissions = collect([]);
        }

        return $permissions->sortBy('name')->groupBy('name');
    }
1194706
public function browserAction()
    {
        $this->checkIfMediaBundleIsLoaded();
        if (false === $this->admin->checkAccess('list')) {
            throw new AccessDeniedException();
        }

        $datagrid = $this->admin->getDatagrid();
        $datagrid->setValue('context', null, $this->getRequest()->get('context'));
        $datagrid->setValue('providerName', null, $this->getRequest()->get('provider'));

        $formats = [];

        foreach ($datagrid->getResults() as $media) {
            $formats[$media->getId()] = $this->get('sonata.media.pool')->getFormatNamesByContext($media->getContext());
        }

        $formView = $datagrid->getForm()->createView();

        $this->get('twig')->getRuntime(FormRenderer::class)->setTheme($formView, $this->admin->getFilterTheme());

        $tags = $this->getDoctrine()
            ->getRepository(Tag::class)
            ->createQueryBuilder('t')
            ->select('t', 'c')
            ->leftJoin('t.children', 'c') // preload
            ->orderBy('t.path', 'ASC')
            ->getQuery()->getResult();

        $tagAdmin = $this->get('networking_init_cms.admin.tag');

        return $this->render(
            $this->getTemplate('browser'),
            [
                'tags' => $tags,
                'tagAdmin' => $tagAdmin,
                'lastItem' => 0,
                'action' => 'browser',
                'form' => $formView,
                'datagrid' => $datagrid,
                'formats' => $formats,
            ]
        );
    }
548044
public function getLayoutsAction($uid)
    {
        if (!$this->isGranted("ROLE_API_USER")) {
            throw new AccessDeniedHttpException("Your account's api access is disabled");
        }

        $site = $this->getEntityManager()->getRepository('BackBee\Site\Site')->find($uid);

        if (!$site) {
            return $this->create404Response(sprintf('Site not found: %s', $uid));
        }

        if (!$this->isGranted('VIEW', $site)) {
            throw new AccessDeniedHttpException(sprintf('You are not authorized to view site %s', $site->getLabel()));
        }

        $layouts = array();

        foreach ($site->getLayouts() as $layout) {
            if ($this->isGranted('VIEW', $layout)) {
                $layouts[] = [
                    'uid' => $layout->getUid(),
                    'site' => [
                        'uid' => $layout->getSite()->getUid(),
                    ],
                    'label' => $layout->getLabel(),
                    'path' => $layout->getPath(),
                    'data' => json_decode($layout->getData(), true),
                    'picpath' => $layout->getPicpath(),
                ];
            }
        }

        return new Response($this->formatCollection($layouts), 200, ['Content-Type' => 'application/json']);
    }
57467
public function getRoles()
    {
        if (is_array($this->_roles)) {
            return $this->_roles;
        }
        if (!$this->id) {
            return $this->_roles = [];
        }
        return $this->_roles = \Cms\Orm\CmsAuthRoleQuery::joinedRoleByAuthId($this->id)
            ->orderAsc('name', 'cms_role')
            ->findPairs('cms_role_id', 'cms_role.name');
    }
296961
public function getRoles()
    {
        $roles = array();
        foreach ($this->groups as $group) {
            $roles[] = $group->getAsRole();
        }
        $roles[] = 'ROLE_USER';
        return $roles;
    }
1374370
public function getRoles()
    {
        $user       = $this;
        $comparator = function ($level) use ($user) {
            return $user->hasAccessLevel($level);
        };

        // Fallback for PHP < 5.6 which do not support ARRAY_FILTER_USE_KEY.
        if (version_compare(PHP_VERSION, '5.6', '<')) {
            $filtered = array_flip(array_filter(array_keys(self::$roleMap), $comparator));
            return array_values(array_intersect_key(self::$roleMap, $filtered));
        }

        return array_values(array_filter(self::$roleMap, $comparator, ARRAY_FILTER_USE_KEY));
    }
1159308
public static function optionsAccessLevels(): array
    {
        return [
            Auth::PRIV_PRIVATE => I18N::translate('Show to visitors'),
            Auth::PRIV_USER    => I18N::translate('Show to members'),
            Auth::PRIV_NONE    => I18N::translate('Show to managers'),
            Auth::PRIV_HIDE    => I18N::translate('Hide from everyone'),
        ];
    }
661137
public function getRoles($reset = false, $authenticated = false, $anonymous = false)
    {
        if ($reset || !$this->roles) {
            $roles = $this->entityTypeManager->getStorage('user_role')->loadMultiple();
            if (!$authenticated) {
                unset($roles['authenticated']);
            }
            if (!$anonymous) {
                unset($roles['anonymous']);
            }
            foreach ($roles as $role) {
                $this->roles[$role->id()] = $role->label();
            }
        }

        return $this->roles;
    }