NEW: KEY_MODULE-filed rights now group with their target module and sort next to it - #39736
Open
hregis wants to merge 3 commits into
Open
NEW: KEY_MODULE-filed rights now group with their target module and sort next to it#39736hregis wants to merge 3 commits into
hregis wants to merge 3 commits into
Conversation
…ort next to it Rights declared by a module but filed into another module's section of the permission grid (DolibarrModules::KEY_MODULE) previously kept the declaring module's own family/module_position, opening a second, misplaced section instead of merging with the target module's native rights. User::loadRights() and UserGroup::loadRights() also indexed such rights under the display module column instead of module_origin, so hasRight() could never resolve them under the module that actually declared and controls them. - insert_permissions() now resolves family/module_position from the target module (getModuleInfoByRightsClass(), cached) when KEY_MODULE differs from the declaring module. - loadRights() (User and UserGroup) indexes $user->rights by module_origin when set, so hasRight() checks against the declaring module regardless of where the right is displayed. - New rights_def.sort_order column + DolibarrModules::KEY_SORT_ORDER let such a right sort right next to a specific native right of the target module (set to that right's id) instead of always trailing the whole section. module_position can't carry this: it's a per-module value that user/perms.php actively normalizes back to the module's own position on every page load. - user/perms.php, user/group/perms.php, admin/perms.php: sort by sort_order (falling back to id, unchanged for every existing right), tooltip and a small badge now show the actual declaring module for such rights.
getModulePosition() can return int|string, but the method's declared return
type is array{family:string,position:int}. Cast position to int at both
places the result array is built so the runtime type matches the declaration.
Add a 4th example permission to modMyModule.class.php showing how to file a right into another module's section of the permission grid and sort it next to a specific native right of that module.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rights declared by a module but filed into another module's section of the permission grid (DolibarrModules::KEY_MODULE) previously kept the declaring module's own family/module_position, opening a second, misplaced section instead of merging with the target module's native rights. User::loadRights() and UserGroup::loadRights() also indexed such rights under the display module column instead of module_origin, so hasRight() could never resolve them under the module that actually declared and controls them.