Extending the permissions

RisteD

Active member
I would suggest extending the permissions for groups too. Currently XenForo by it's standards does not support permissions based on group, i would suggest to implement something like:

PHP:
\XF::group()->hasPermission($group,$permission) // return true or false;
    the group() will be instance of User Groups, and function hasPermission will be instance of
    Permission entry table which relations  user_group_id , group.user_group_id.

Sometimes in your code you don't need a user permission, you'll need group permission.

This is currently possible if we make custom entity which will check in permission entry table and then make relations with UserGroup entity after that make hasPermission($group, $permission).
 
Upvote 0

Brogan

XenForo moderator
Staff member
Sometimes in your code you don't need a user permission, you'll need group permission.
And if that member has never set for the permission and the user group permission is yes?

Permissions are always evaluated down to the member for the fact that they are cumulative and can be set at the user group, node, and member level.
 

RisteD

Active member
Sometimes in your addons want to use priority on user groups and in fact you can always use && AND condition.
you can always experiment and you can also make priority xD but wanna see that function implemented in Core system.

I had implemented code already for user group permissions, had to extend UserGroup permission and PermissionsEntry and to use my function in Finder.
So i make custom class and function to obtain a permission based on user group ID, single permission ofc.
PHP:
class PermissionEntry extends Finder{
    public function hasPermission($group,$permission){
        $response =  $this->with('UserGroup')
                    ->where('permission_group_id',$group)
                    ->where('permission_id',$permission)
                    ->fetchOne();
        if(is_null($response)){
            return false;
        } else {
            return true;
        }
    }
}
 
Top