RE: [xwiki-users] List member login ID and real name by group?
Robin, Thanks for the solution - it is exactly what I need - I was struggling with the object <-> property relationship. I'd like to encourage one of the XWiki gurus to spent a bit of time on some Javadoc, and object and data models. I'm sure it would make XWiki a lot more attractive to current and prospective users. Thanks, John -----Original Message----- From: Robin Fernandes [mailto:rewbs.soal@gmail.com] Sent: Thursday, 16 March 2006 11:46 AM To: xwiki-users@objectweb.org Subject: Re: [xwiki-users] List member login ID and real name by group? Hi, Try this: {table} group|wikiname|real name #set($sql = "select obj.name,prop.value from BaseObject obj, StringProperty prop where obj.className='XWiki.XWikiGroups' and obj.name!='XWiki.XWikiGroupTemplate' and prop.name='member' and obj.id=prop.id.id order by obj.name") #foreach ($row in $xwiki.search($sql)) #foreach ($item in $row) ##does anyone know a better way of extracting multiple fields from an sql result? #if ($velocityCount==1) #set($group=$item) #elseif ($velocityCount==2) #set($member=$item) #end #end #set($memberDoc=$xwiki.getDocument($member)) #if ($member != "") ##ignore blank fields $group | $member | $!memberDoc.get("first_name") $!memberDoc.get("last_name") #end #end {table} Should create a table sorted by group with the columns: group / wiki ID / first_name last_name I'm sure there are many other (better, less verbose) ways of doing it, but with this method: . The sql query gets the name of all XWiki.XWikiGroups objects and the value of their 'member' property (note: each XWikiGroups object in fact represents just one member) (also note: the name of the group object corresponds to the name of the document in which that object lives) . The value of the member property corresponds to the user's wiki name, which also happens to be the user's document name. . The user's document contains the user's object. We can therefore use a call to 'get' on the document to get the user's object properties (e.g. first_name and last_name). The API is quite useful (though it needs some more documentation): http://build.xpertnet.biz/doc/api/com/xpn/xwiki/api/Api.html And studying the classes in the XWiki class editor to discover the properties is very helpful too; make sure you use the real property names and not the "pretty names" though. Hope this helps, Robin. On 15/03/06, Turner, John <John.Turner3@team.telstra.com> wrote:
Jérémi,
Thanks for your suggestion.
## This code shows a list of Users. #set($sql = ", BaseObject as obj where obj.name=doc.fullName and obj.className='XWiki.XWikiUsers'") #foreach ($item in $xwiki.searchDocuments($sql)) #set($itemdoc = $xwiki.getDocument($item)) #set($obj = $itemdoc.getObject("XWiki.XWikiUsers")) * $obj.name: $obj.first_name $obj.last_name #end
The above code gives me a list of Users. How do I get a list that shows Groups, and for each Group the Members that belong to the Group? I don't understand the XWiki object or data model. Once I've got a Group, as per the following code, how do I get a list of Members that belong to the Group?
## This code shows a list of Groups. #set($sql2 = ", BaseObject as obj where obj.name=doc.fullName and obj.className='XWiki.XWikiGroups'") #foreach ($item in $xwiki.searchDocuments($sql2)) #set($itemdoc = $xwiki.getDocument($item)) * $itemdoc.name #end
Thanks, John
-----Original Message----- From: jeremi joslin [mailto:jeremi23@gmail.com] Sent: Thursday, 16 March 2006 9:26 AM To: xwiki-users@objectweb.org Subject: Re: [xwiki-users] List member login ID and real name by group?
On 3/16/06, Turner, John <John.Turner3@team.telstra.com> wrote:
Dear All,
We use login IDs that are not very meaningful. I'd like to create a page that lists the login ID and real name of each member by group to help with administration. I can see how to get the groups, for example:
#set($sqlGrp = ", BaseObject as obj where obj.name=doc.fullName and obj.className='XWiki.XWikiGroups'") #foreach ($item in $xwiki.searchDocuments($sqlGrp)) #set($itemdoc = $xwiki.getDocument($item)) Group: $itemdoc.name <br/> #end
How do I access the members for a given group?
Thanks, John
Hi, maybe something like this is what you want :
#set($sqlGrp = ", BaseObject as obj where obj.name=doc.fullName and obj.className='XWiki.XWikiUsers'") #foreach ($item in $xwiki.searchDocuments($sqlGrp)) #set($itemdoc = $xwiki.getDocument($item)) #set($obj = $itemdoc.getObject("XWiki.XWikiUsers")) user: $obj.fullName $obj.name<br/> #end
Jérémi
-- Blog: http://www.jeremi.info LinkedIn: https://www.linkedin.com/profile?viewProfile=&key=1437724 Project Manager XWiki: http://www.xwiki.org skype: jeremi23 -- msn et gtalk : jeremi23@gmail.com
-- You receive this message as a subscriber of the xwiki-users@objectweb.org mailing list. To unsubscribe: mailto:xwiki-users-unsubscribe@objectweb.org For general help: mailto:sympa@objectweb.org?subject=help ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
participants (1)
-
Turner, John