Hi Dmitry,
The getDocumentAsAuthor() call should work as expected.
Make sure to use saveDocumentAsAuthor() when saving as well.
Thanks,
Caleb
On 01/04/2013 11:00 AM, Haru wrote:
> Hi!
>
> I'm trying to develop a simple script for followng scenario:
> - Registered User receives an "access code" to the restricted Space
> - User fills in "access code" and access is granted to him.
>
> Following test code is used for tests now (no codes involved yet):
>
> {{velocity}}
>
> #set ($mydoc = $xwiki.getDocumentAsAuthor("Week1.WebPreferences"))
> #set ($rightsObject = $mydoc.newObject("XWiki.XWikiGlobalRights"))
>
> ## Set the values of the fields
> #set ($result1 = $rightsObject.set("groups", "XWiki.XWikiAdminGroup"))
> #set ($result2 = $rightsObject.set("levels", "view,comment,edit"))
> #set ($result3 = $rightsObject.set("users", "$xcontext.getUser()"))
> #set ($result4 = $rightsObject.set("allow", 1))
>
> $mydoc.save()
>
> {{velocity}}
>
> The problem is: it works only if user alredy has access rights to the
> Week1.WebPreferences, if not (as desired by scenario)
>
> #set ($mydoc = $xwiki.getDocumentAsAuthor("Week1.WebPreferences"))
>
> gives Access denied error. The page with this velocity scripting is saved
> with programming rights user.
>
> What is wrong?
>
> I'd highly appreciate if anyone point the direction :-)
>
>
> Kind regards,
>
> Dmitry
> _______________________________________________
> users mailing list
> [email protected]
> http://lists.xwiki.org/mailman/listinfo/users
>
_______________________________________________
users mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/users