Hello,
Indeed, #stop throws an exception on XWiki 3.0.
You should create an issue on Jira about the #stop problem. I don't really
know if this is caused by XWiki, or is strictly related to Velocity. This is
a regression from my point of view and it should be fixed.
Another solution for you would be to override contentview.vm and replace the
line:
$renderedContent
with:
#if(!$xwiki.getUser().isUserInGroup("XWiki.XWikiEditorsGroup"))
{{warning}}You don't have permission to view this document{{/warning}}
#else
$renderedContent
#end
More info about how to override a template can be found here:
http://platform.xwiki.org/xwiki/bin/view/DevGuide/Skins#HD.OverridingtheSkiā¦.
Raluca.
On Tue, Apr 5, 2011 at 5:38 PM, China Sunrise <china.sunrise(a)gmail.com>wrote;wrote:
Hi,
I'm relatively new to xwiki. I have a few pages where dynamic tables had to
be shown, and I'm using PHP quite heavily there. In a couple of pages, the
content is supposed to be shown only if the user is in a specific group
called 'XWikiEditorsGroup'. I didn't want to rely on xwiki's native
single-page permissions as they looked a little cumbersome for what I
needed, and preferred to control access via the page code itself. Up to
xwiki 2.7, the following velocity section, which was the first section in
the page, did the trick:
{{velocity}}
#set($user=$xwiki.getUser())
#if(!$user.isUserInGroup("XWiki.XWikiEditorsGroup"))
{{warning}}You don't have permission to view this document{{/warning}}
#stop
#end
{{/velocity}}
However, after upgrading to xwiki 3.0, this code no longer works. From what
I see, the issue appears to be related to velocity 1.7 and its different
syntax for the #stop directive. I can't seem to find the right syntax
though. As an alternative approach, I've also tried to relocate this access
control logic into the PHP code that follows the above velocity section. To
do that, I need to find a way to get the true/false value of
"$user.isUserInGroup("XWiki.XWikiEditorsGroup")" in PHP, but so far
haven't
found a way to do that either and not sure how to pass the $user object and
its isUserInGroup() method to the PHP part. I've even looked into doing
this
in groovy but no luck there either.
Any advice will be appreciated...
Thanks
_______________________________________________
users mailing list
users(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/users