[xwiki-users] Problem with setting space rights from Velocity
Hello folks, I have some troubles setting space rights from Velocity and can't find any examples for it. This code should generate new XWikiGlobalRights objects for each user. However, adding them to the Space.WebHome page doesn't work, and adding them to the Space.WebPreferences page (like the Set Rights page does) fails (the objects are not generated). Can someone give me a hint whats wrong here? #foreach($newuser in $projectuserlist) #set ($myspace = $xwiki.getDocument("${projectname}.WebPreferences")) #set ($rightsObject = $myspace.newObject("XWiki.XWikiGlobalRights")) #set ($result = $rightsObject.set("levels", "view,edit")) #set ($result = $rightsObject.set("users", $newuser)) ##set ($result = $rightsObject.set("allow", 1)) $mydoc.save() #end Thanks for any help in advance!
grinko wrote:
Hello folks,
I have some troubles setting space rights from Velocity and can't find any examples for it.
This code should generate new XWikiGlobalRights objects for each user. However, adding them to the Space.WebHome page doesn't work, and adding them to the Space.WebPreferences page (like the Set Rights page does) fails (the objects are not generated).
Can someone give me a hint whats wrong here?
#foreach($newuser in $projectuserlist) #set ($myspace = $xwiki.getDocument("${projectname}.WebPreferences")) #set ($rightsObject = $myspace.newObject("XWiki.XWikiGlobalRights")) #set ($result = $rightsObject.set("levels", "view,edit")) #set ($result = $rightsObject.set("users", $newuser)) ##set ($result = $rightsObject.set("allow", 1)) $mydoc.save()
Who is $mydoc? :) Try $myspace.save(), and it should work just fine.
#end
-- Sergiu Dumitriu http://purl.org/net/sergiu/
Hi,
#foreach($newuser in $projectuserlist) #set ($myspace = $xwiki.getDocument("${projectname}.WebPreferences")) #set ($rightsObject = $myspace.newObject("XWiki.XWikiGlobalRights"))
I would use #set ($rightsObject = $myspace.createNewObject("XWiki.XWikiGlobalRights"))
#set ($result = $rightsObject.set("levels", "view,edit")) #set ($result = $rightsObject.set("users", $newuser)) ##set ($result = $rightsObject.set("allow", 1)) $mydoc.save() #end
Hope this helps Jean -- ---- Jean Couteau Code Lutin - http://www.codelutin.com 44 Bd des Pas Enchantés - 44230 St-Sébastien/Loire Tél : 02 40 50 29 28 - Fax : 09 59 92 29 28
participants (3)
-
grinko -
Jean Couteau -
Sergiu Dumitriu