Check Rights For A User On A Page

Last modified by Andreea Popescu on 2021/03/18 11:28

cogSee the rights configured for a given user on a given page
TypeSnippet
Category
Developed by

Guillaume Delhumeau

Rating
0 Votes
LicenseGNU Lesser General Public License 2.1

Table of contents

Description

Copy & paste this code:

= Check rights =
{{velocity}}

{{html}}
<form class="xform" method="get" action="$doc.getURL('view')">
<dl>
  <dt><label for="user">User:</label></dt>
  <dd><input type="text" name="user" id="user" value="$escapetool.xml("$!request.user")" /></dd>
  <dt><label for="page">Page:</label></dt>
  <dd><input type="text" name="page" id="page" value="$escapetool.xml("$!request.page")" /></dd>
  <p><span class="buttonwrapper"><input class="button" type="submit" value="Check"/></span></p>
</dl>
</form>
{{/html}}

#if($request.page && $request.user)
  = Results =
 #set($d = $xwiki.getDocument($request.page))
 #set($user = $request.user)
  |=User|=Document|=View|=Edit|=Comment|=Delete|=Admin|=Programming
  |[[$user>>$user]]|[[$d>>$d]]|$d.hasAccessLevel('view', $user)|$d.hasAccessLevel('edit', $user)|$d.hasAccessLevel('comment', $user)|$d.hasAccessLevel('delete', $user)|$d.hasAccessLevel('admin', $user)|$d.hasAccessLevel('programming', $user)
#end
{{/velocity}}

You will obtain:

screenshot.png

Get Connected