Returns an array of permissions which can be configured for the user
@return array
777078
public static function permissions(): array
    {
        $permissions = parent::permissions();

        //  Fetch the blogs, each blog should have its own permission
        $ci =& get_instance();
        $ci->load->model('blog/blog_model');
        $blogs = $ci->blog_model->getAll();

        $out = array();

        if (!empty($blogs)) {
            foreach ($blogs as $blog) {
                $permissions[$blog->id . ':update']  = $blog->label . ': Can update settings';
            }
        }

        return $permissions;
    }
62395
private function getAllPermissions()
    {
        $user = auth()->user();

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

        $permissions = $permissions->sortBy('name')->groupBy('name');

        return json_encode($permissions);
    }
517314
protected function getPermissionsRole()
    {
        $arguments = $this->getArguments();

        if (count($arguments) < 2) {
            $this->errorAndExit($this->text('Invalid command'));
        }

        $role_id = array_shift($arguments);

        if (!is_numeric($role_id)) {
            $this->errorAndExit($this->text('Invalid argument'));
        }

        $role = $this->role->get($role_id);

        if (!isset($role['permissions'])) {
            $this->errorAndExit($this->text('Unexpected result'));
        }

        return array($role_id, $role['permissions'], $arguments);
    }
665575
private function getParentPermissions() : array
    {
        $result = [];
        foreach ($this->table->associations() as $association) {
            if (! $this->isSupportedJoinAssociation($association)) {
                continue;
            }

            if (! $this->isParentModuleAssociation($association)) {
                continue;
            }

            $foreignKey = $association->getForeignKey();
            Assert::string($foreignKey);

            $field = sprintf('%s IN', $foreignKey);
            $result[$field] = $this->getPermissionsByModel($this->getModelByAssociation($association));
        }

        return $result;
    }
267643
public function permissions()
    {
        $permissionModel = config('defender.permission_model');
        $permissionRoleTable = config('defender.permission_role_table');
        $roleKey = config('defender.role_key');
        $permissionKey = config('defender.permission_key');

        return $this->belongsToMany($permissionModel, $permissionRoleTable, $roleKey, $permissionKey)->withPivot('value', 'expires');
    }
1070211
private function getPermissionArray()
    {
        $permissionArray = array(
            'can_add'           => false,
            'subtree_limit'     => $this->Attribute->contentClassAttribute()->attribute( eZTagsType::SUBTREE_LIMIT_FIELD ),
            'allowed_locations' => array(),
            'allowed_locations_tags' => false );

        $userLimitations = eZTagsTemplateFunctions::getSimplifiedUserAccess( 'tags', 'add' );

        if ( $userLimitations['accessWord'] == 'no' )
            return $permissionArray;

        $userLimitations = isset( $userLimitations['simplifiedLimitations']['Tag'] ) ? $userLimitations['simplifiedLimitations']['Tag'] : array();
        $limitTag = eZTagsObject::fetchWithMainTranslation( $permissionArray['subtree_limit'] );

        if ( empty( $userLimitations ) )
        {
            if ( $permissionArray['subtree_limit'] == 0 || $limitTag instanceof eZTagsObject )
            {
                $permissionArray['allowed_locations'] = array( $permissionArray['subtree_limit'] );

                if ( $limitTag instanceof eZTagsObject )
                    $permissionArray['allowed_locations_tags'] = array( $limitTag );
            }
        }
        else if ( $permissionArray['subtree_limit'] == 0 )
        {
            $permissionArray['allowed_locations_tags'] = array();

            /** @var eZTagsObject[] $userLimitations */
            $userLimitations = eZTagsObject::fetchList( array( 'id' => array( $userLimitations ) ), null, null, true );
            if ( is_array( $userLimitations ) && !empty( $userLimitations ) )
            {
                foreach ( $userLimitations as $limitation )
                {
                    $permissionArray['allowed_locations'][] = $limitation->attribute( 'id' );
                    $permissionArray['allowed_locations_tags'][] = $limitation;
                }
            }
        }
        else if ( $limitTag instanceof eZTagsObject )
        {
            /** @var eZTagsObject[] $userLimitations */
            $userLimitations = eZTagsObject::fetchList( array( 'id' => array( $userLimitations ) ), null, null, true );
            if ( is_array( $userLimitations ) && !empty( $userLimitations ) )
            {
                $pathString = $limitTag->attribute( 'path_string' );
                foreach ( $userLimitations as $limitation )
                {
                    if ( strpos( $pathString, '/' . $limitation->attribute( 'id' ) . '/' ) !== false )
                    {
                        $permissionArray['allowed_locations'] = array( $permissionArray['subtree_limit'] );
                        $permissionArray['allowed_locations_tags'] = array( $limitTag );
                        break;
                    }
                }
            }
        }

        if ( !empty( $permissionArray['allowed_locations'] ) )
            $permissionArray['can_add'] = true;

        return $permissionArray;
    }
948352
public function listPermissions()
    {
        if ($this->permissionCache !== false) {
            return $this->permissionCache;
        }

        /*
         * Load module items
         */
        foreach ($this->callbacks as $callback) {
            $callback($this);
        }

        /*
         * Load plugin items
         */
        $plugins = PluginManager::instance()->getPlugins();

        foreach ($plugins as $id => $plugin) {
            $items = $plugin->registerPermissions();
            if (!is_array($items)) {
                continue;
            }

            $this->registerPermissions($id, $items);
        }

        /*
         * Sort permission items
         */
        usort($this->permissions, function ($a, $b) {
            if ($a->order == $b->order) {
                return 0;
            }

            return $a->order > $b->order ? 1 : -1;
        });

        return $this->permissionCache = $this->permissions;
    }
272210
public function getPermissionsIdList() {

		$permissions		= $this->permissionMappingList;
		$permissionsList	= [];

		foreach ( $permissions as $permission ) {

			array_push( $permissionsList, $permission->permissionId );
		}

		return $permissionsList;
	}
282073
public function providePermissions()
    {
        $permissions = array();
        $config = Config::inst()->get('PublishProvider', 'classes');

        foreach ($config as $class) {
            $subClasses = array_keys(ClassInfo::subclassesFor($class));
            
            foreach ($subClasses as $subClass) {
                foreach (array(
                        'publish',
                        'unpublish',
                        'archive',
                        'view',
                        'edit',
                        'delete',
                        'create') as $name) {
                    $permissions[$subClass . '_' . $name] = singleton($subClass)->singular_name(). ' ' . $name;
                }
            }
        }
        
        return $permissions;
    }
15389
public function getPermissions($user_id = null)
    {
        static $permissions = array();

        if (!isset($user_id)) {
            $user_id = $this->uid;
        }

        if (isset($permissions[$user_id])) {
            return $permissions[$user_id];
        }

        $user = $this->get($user_id);

        if (empty($user['role_id'])) {
            return $permissions[$user_id] = array();
        }

        $role = array();
        if (isset($user['role_permissions'])) {
            $role['permissions'] = $user['role_permissions'];
        } else {
            $role = $this->role->get($user['role_id']);
        }

        if (empty($role['permissions'])) {
            return $permissions[$user_id] = array();
        }

        return $permissions[$user_id] = (array) $role['permissions'];
    }
854623
public function getPermissionsInherited()
    {
        $rights = [];
        $permissions = $this->permissions;

        // ntfs permissions
        // determine if ntfs is enabled
        // then more permissive wins
        $tmp = [];
        $letNtfs = function ($alias, $slug) use (&$tmp) {
            if ( config('acl.most_permissive_wins', false) ) {
                $ntfs[$alias] = array_diff($slug, [false]);
                if ( sizeof($ntfs) > 0 ) {
                    $tmp = array_replace_recursive($tmp, $ntfs);
                }
            }
        };

        foreach ($permissions as $row) {

            // permissions without inherit ids
            if ( is_null($row->inherit_id) || ! $row->inherit_id ) {

                // ntfs determination
                $letNtfs($row->name, $row->slug);

                // merge permissions
                $rights = array_replace_recursive($rights, [$row->name => $row->slug], $tmp);
                continue;
            }

            // process inherit_id recursively
            $inherited = $this->getRecursiveInherit($row->inherit_id, $row->slug);
            $merge = $permissions->where('name', $row->name);
            $merge = method_exists($merge, 'pluck') ? $merge->pluck('slug', 'name') : $merge->lists('slug', 'name');

                // fix for l5.1 and backward compatibility.
            // lists() method should return as an array.
            $merge = $this->collectionAsArray($merge);

            // replace and merge permissions
            $rights = array_replace_recursive($rights, $inherited, $merge);

            // make sure we don't unset if
            // inherited & slave permission
            // have same names
            if ( key($inherited) != $row->name )
                unset($rights[$row->name]);

        }

        return $rights;
    }
898947
private function getAllMappedPermissions(): array
    {
        $mappedPermissions = [];
        foreach (Craft::$app->userPermissions->getAllPermissions() as $permissions) {
            $mappedPermissions = array_merge($mappedPermissions, $this->getMappedPermissions($permissions));
        }

        return $mappedPermissions;
    }
1296636
private function getMapConfigPermissions()
    {
        $id = '_config';

        if (!\array_key_exists($id, $this->cache)) {
            $this->cache[$id] = [];
            $this->buildSystemPermissions($id);
        }

        return $this->cache[$id];
    }
682984
public function providePermissions()
    {
        $permissions = [];
        foreach (MenuSet::get() as $menuset) {
            $key = $menuset->PermissionKey();
            $permissions[$key] = [
                'name' => _t(
                    __CLASS__ . '.EDITMENUSET',
                    "Manage links with in '{name}'",
                    [
                        'name' => $menuset->obj('Title')
                    ]
                ),
                'category' => _t(__CLASS__ . '.MENUSETS', 'Menu sets')
            ];
        }
        return $permissions;
    }
770478
private function getPermissionActions()
    {
        $actions = [];

        /**
         * @var $route \Symfony\Component\Routing\Route
         */
        foreach ($this->get('router')->getRouteCollection()->all() as $name => $route) {
            if ($route->hasOption('require_admin_permission')) {
                list(, $action) = explode('.', $route->getOption('require_admin_permission'));
                $actions[$action] = [
                    'id'   => $action,
                    'name' => $action
                ];
            }
        }

        ksort($actions);

        return array_values($actions);
    }
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
        );
    }
106773
protected function getPermissions()
    {
        try {
            return $this->cache->rememberForever('permissions.policies', function () {
                return Permission::with('roles')->get();
            });
        } catch (\Exception $exception) {
            $this->cache->forget('permissions.policies');

            return new Collection;
        }
    }