[xwiki-users] Newbie XWiki programming questions

Marco Fabbri mrfabbri at gmail.com
Fri Jan 4 01:08:05 CET 2008


On Thu, 2008-01-03 at 21:15 +0100, Robert Hercz wrote:
> Hi,
> 
>  
> 
> Still trying to understand the possibilities of XWiki, can someone pls
> point me in the direction of (or suggest) code I can embed in XWiki
> standard editable pages, which allows me to check the current user’s
> group membership, and if OK, display the few next lines of text?
> 

direction: taking a look at the API (1.1.2):
<http://platform.xwiki.org/xwiki/bin/download/DevGuide/API/xwiki%2Dcore%
2D1.1.2%2Djavadoc.zip/index.html> and in particular xwiki, context and
user objects.

>  
> 
> Pseudocode:
> 
>  
> 
> IF (IsMemberOf Group1 OR IsMemberOf Group2)
> 
>    Display this text
> 
>    Display that text
> 
> END
> 
>  

#set( $user = $xwiki.getUser() )
#if( $user.isUserInGroup("XWiki.XWikiAdminGroup") || $user.isUserInGroup("XWiki.XWikiGroupTemplate"))
this text will be displayed only if the current user is a member of the admin or template group 
#end

$xwiki.getUser() resolves to 
<http://platform.xwiki.org/xwiki/bin/download/DevGuide/API/xwiki%2Dcore%
2D1.1.2%2Djavadoc.zip/com/xpn/xwiki/api/XWiki.html#getUser()>

$user.isUserInGroup("XWiki.XWikiAdminGroup") resolves to
<http://platform.xwiki.org/xwiki/bin/download/DevGuide/API/xwiki%2Dcore%
2D1.1.2%
2Djavadoc.zip/com/xpn/xwiki/api/User.html#isUserInGroup(java.lang.String)>

for Java code methods resolution in Velocity see
<http://velocity.apache.org/engine/releases/velocity-1.5/user-guide.html#methods>

> 
> Also, I’d like to find out if it’s possible to log somewhere, which
> pages are accessed (viewed) by whom, when, and from which IP
> addresses.
> 

XWiki uses Commons Logging and the logging level is pretty customizable.
For logging configuration take a look at
<http://platform.xwiki.org/xwiki/bin/view/AdminGuide/Logging>.

There is also a Statistics Application:
<http://platform.xwiki.org/xwiki/bin/view/Features/IntegratedStatistics>.

Best Regards,

-- 
Marco

=====
"We know nothing
 — that is the first point.
Therefore we should be very modest
 — that is the second.
That we should not claim to know when we do not know
 — that is the third."

 Karl R. Popper



More information about the users mailing list