Fixed \XF\AddOn\AbstractSetup :: applyGlobalPermissionInt doesn't allow for copying existing int permission value

DragonByte Tech

Well-known member
Affected version
2.0.7
Based off of the functionality of the applyGlobalPermission function, I expected that applyGlobalPermissionInt would copy the current int permission value of a given $dependGroupId and $dependPermissionId.

However, that is not what's happening. Instead, it inserts the $applyValue only if the user group has "allow" for a given Flag permission (based off $dependGroupId and $dependPermissionId).

I would fix this issue by changing the relevant query to this:
SQL:
                REPLACE INTO xf_permission_entry
                    (user_group_id, user_id, permission_group_id, permission_id, permission_value, permission_value_int)
                SELECT user_group_id, user_id, ?, ?, 'use_int', IF(permission_value = 'use_int', permission_value_int, ?)
                FROM xf_permission_entry
                WHERE permission_group_id = ?
                    AND permission_id = ?
                    AND permission_value IN('allow', 'use_int')
What this will do is copy the existing int permission if the given depend permission is an int permission, or use $applyValue if it is not. This maintains existing behaviour (apply the value to user groups with the given permission) while also allowing for the use of int permission copy.


Fillip
 
Top Bottom