How do I prevent anonymous users from using page history? | Confluence | Atlassian Documentation
In the help article above, a code is presented for hiding page history from anonymous users. I want to edit the code in such a way that it will hide the page history from users with only read-rights on a page, but shows it for users with modify rights.
In our organization we use grouprights that either end with _M or with _R to specify if the group has Modify or Read. Would it be possible to use wildcards in the code so that it just picks up on the last part of a group name?
#if ($action.remoteUser != $null)
would become something like:
#if ($action.remoteUser != *_R)
Just to confirm, do you mean the user must be a member of a specific group to be able to see the page history, or that his username must end with '_M'?
According to https://developer.atlassian.com/server/confluence/confluence-objects-accessible-from-velocity there is userAccessor which could resolve group membership.
If it's usernames, then you could try
#if ($action.authenticatedUser.getName().contains("_M"))
or
#if ($action.authenticatedUser.getName().endsWith("_M"))
AuthenticatedUser resolves to ConfluenceUser (https://docs.atlassian.com/ConfluenceServer/javadoc/7.20.0/com/atlassian/confluence/user/ConfluenceUser.html) and apache velocity should have both contains and endsWith methods for String objects, once you get the username.
If it's about group membership then the UserAccessor has this method in it - https://docs.atlassian.com/ConfluenceServer/javadoc/7.20.0/bucket/user/UserAccessor.html#hasMembership-java.lang.String-java.lang.String- which would conveniently return a boolean.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.