Setting Rights Snippet

Show how to set up rights programmatically using Velocity

Warning: Make sure to explicitely set the 'allow' field below as otherwise it won't work. This seems to be some bug since by default the allow field is set to 1.

Code

#set ($mydoc = $xwiki.getDocument("Space.Page"))

## Create a rights object and attach it to the Space.Page page
#set ($rightsObject = $mydoc.getObject("XWiki.XWikiRights", true))

## Set the values of the fields
#set ($result = $rightsObject.set("groups", "XWiki.XWikiAdminGroup"))
#set ($result = $rightsObject.set("levels", "edit"))
#set ($result = $rightsObject.set("users", ""))
#set ($result = $rightsObject.set("allow", 1))

## Save the modifications
$mydoc.save()

The Space.Page page can now only be edited by members of the XWikiAdminGroup group.

Version 2.2 last modified by Sergiu on 07/01/2008 at 23:29

Comments 0

No comments for this document

Attachments 0

No attachments for this document

Creator: VincentMassol on 2007/11/21 11:32
This wiki is licensed under a Creative Commons license
1.4.1.10194