Hello,
I need to automatically set rights for a page with Velocity
I have some ideas on the way to do this : get the list of rights already set
for the page, check/modify them and eventually add more rights entries if
necessary.
The code will be something like :
#set($rightindex=0)
#set($rightsobjectslist=$doc.getObjects("XWiki.XWikiRights"))
#foreach($rightsobject in $rightsobjectslist)
current rights n°$rightindex are : groups=$rightsobject.groups
,users=$rightsobject.users , levels=$rightsobject.levels ,
allow=$rightsobject.allow;
##check if rights_0 exists and modify it
#if ($rightindex==0)
#set($userobject=$xwiki.getDocument("XWiki.aXWikiUser").getObject("XWiki.XWi
kiUsers",0))
#set($rightsobject.users=$userobject.name)
modified users for rights_0 = $rightsobject.users
(...)
#end
##check if rights_1 exists and modify it
#if ($rightindex==1)
(...)
#end
#set($rightindex=$rightindex+1)
#end
#if($rightsobjectslist.size==1)
## create missing rights
#end
$doc.saveDocument()
My problem with this code is that the value of $rightsobject.users doesn't
change ! It is "XWiki.XWikiGuest" before the #set($rightsobject.users=...)
and it still is "XWiki.XWikiGuest" after ( instead of
"XWiki.aXWikiUser" )
If somebody can help, it would be nice
Thanks
Yan
Show replies by date