Problem with setting space rights from Velocity

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem with setting space rights from Velocity

grinko
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!
_______________________________________________
users mailing list
[hidden email]
http://lists.xwiki.org/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: Problem with setting space rights from Velocity

Sergiu Dumitriu-2
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/
_______________________________________________
users mailing list
[hidden email]
http://lists.xwiki.org/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: Problem with setting space rights from Velocity

Jean Couteau
In reply to this post by grinko
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

_______________________________________________
users mailing list
[hidden email]
http://lists.xwiki.org/mailman/listinfo/users