rbac/DbManager.php
protected function getInheritedPermissionsByUser($userGuid)
    {
        $query = (new Query)->select('item_name')
            ->from($this->assignmentTable)
            ->where(['user_guid' => (string) $userGuid]);

        $childrenList = $this->getChildrenList();
        $result = [];
        foreach ($query->column($this->db) as $roleName) {
            $this->getChildrenRecursive($roleName, $childrenList, $result);
        }

        if (empty($result)) {
            return [];
        }

        $query = (new Query)->from($this->itemTable)->where([
            'type' => Item::TYPE_PERMISSION,
            'name' => array_keys($result),
        ]);
        $permissions = [];
        foreach ($query->all($this->db) as $row) {
            $permissions[$row['name']] = $this->populateItem($row);
        }
        return $permissions;
    }
protected function getInheritedPermissionsByUser($userGuid)
    {
        $query = (new Query)->select('item_name')
            ->from($this->assignmentTable)
            ->where(['user_guid' => (string) $userGuid]);

        $childrenList = $this->getChildrenList();
        $result = [];
        foreach ($query->column($this->db) as $roleName) {
            $this->getChildrenRecursive($roleName, $childrenList, $result);
        }

        if (empty($result)) {
            return [];
        }

        $query = (new Query)->from($this->itemTable)->where([
            'type' => Item::TYPE_PERMISSION,
            'name' => array_keys($result),
        ]);
        $permissions = [];
        foreach ($query->all($this->db) as $row) {
            $permissions[$row['name']] = $this->populateItem($row);
        }
        return $permissions;
    }
protected function getInheritedPermissionsByUser ( $ userGuid ) { $ query = ( new Query ) -> select ( 'item_name' ) -> from ( $ this -> assignmentTable ) -> where ( [ 'user_guid' => ( string ) $ userGuid ] ) ; $ childrenList = $ this -> getChildrenList ( ) ; $ result = [ ] ; foreach ( $ query -> column ( $ this -> db ) as $ roleName ) { $ this -> getChildrenRecursive ( $ roleName , $ childrenList , $ result ) ; } if ( empty ( $ result ) ) { return [ ] ; } $ query = ( new Query ) -> from ( $ this -> itemTable ) -> where ( [ 'type' => Item :: TYPE_PERMISSION , 'name' => array_keys ( $ result ) , ] ) ; $ permissions = [ ] ; foreach ( $ query -> all ( $ this -> db ) as $ row ) { $ permissions [ $ row [ 'name' ] ] = $ this -> populateItem ( $ row ) ; } return $ permissions ; }
Returns all permissions that the user inherits from the roles assigned to him.
@param string|User $userGuid the user GUID (see [[\rhosocial\user\User::guid]])
@return Permission[] all inherited permissions that the user has. The array is indexed by the permission names.
Returns all permissions that the user inherits from the roles assigned to him .