refactor: translation bar access check respect user settings for tran… - #2423
Open
sawyerb-ksu wants to merge 2 commits into
Open
sawyerb-ksu wants to merge 2 commits into
sawyerb-ksu wants to merge 2 commits into
Conversation
…slations and add functional tests
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.
Fix: translation banner shows for admins without explicit translate access
Summary
The "Translate user interface" footer banner was visible to any user whose ACL check passed via a blanket "all privileges" grant (e.g., administrators with the default all-access grant), even when they had never been explicitly granted the
translatepermission. This made the banner appear for users whose language settings do not actually authorize interface translation.This change introduces a dedicated access check that requires an explicit
translatepermission and respects the permission's language conditional, so the banner is only shown to users who have been intentionally granted translate access.Problem
_footer.phprendered the sfTranslatePlugin banner whenever:QubitAcl::check()also matches blanketacl_permissionrows withNULL action("all privileges"), so administrators with the standard admin grant saw the banner even without an explicit translate grant.Changes
lib/QubitTranslateBarAccess.class.php(new)New static helper class with:
hasExplicitTranslateAccess(?myUser $user = null): bool— returnstrueonly if the current user has an explicittranslatepermission (action = 'translate') granted to them directly, to one of their groups (including group ancestors), with aNULL object_id(system-wide),grantDeny = 1, and the permission's language conditional (if any) evaluates true for the user's current UI culture.getExplicitTranslatePermissions(myUser $user): array— protected helper that fetches the matching explicit permission rows, mirroring the role hierarchy built inQubitAcl::buildUserRoleList(authenticated role, user id, user groups, and group ancestors).apps/qubit/templates/_footer.phpBanner render condition changed from:
to:
test/functional/qubit/translationBarCheck.php(new)Functional test script (runnable inside the test container via
php -d xdebug.mode=off test/functional/qubit/translationBarCheck.php, exits 0/1) that drives an in-processsfBrowserand asserts on the#l10n-clientfooter bar for four scenarios:translategrant (en), cultureenfr(en-only grant)The script creates and cleans up its own test user, group membership, and permission rows. Note: because this fork authenticates via CAS, the test signs the user in by seeding the browser's session file with the same data
myUser::signIn()produces, rather than POSTing to/user/login.Verification
en-only grant does not show the bar under anfrUI culture).Risk / Backwards compatibility
translategrant (the normal "can translate" checkbox on a user record) see the banner exactly as before.translatepermission explicitly.QubitTranslateBarAccessclass.