Hi!
Joris Dirks wrote:
I intend to make more use of groups and updating the
members on
changes relevant to them by sending them e-mail.
There is a proposal that seek exactly that!
http://dev.xwiki.org/xwiki/bin/view/GoogleSummerOfCode/SendMailtoWikiUsers
I've not followed these projects during 2009 and 2010, so, I don't know
what is its state. The "Using Scheduler issues (groovy questions)"
actually active could also apply to what you are looking for.
Watchlists look too technical/difficult and forcing
group members to
use them is too cumbersome, so I'd like to start simple: exporting the
mail addresses and mailing them the old-fashioned way.
Please, Joris, why to do you find technical/difficult the use of Watch?
Perhaps I'm misunderstanding you, but all what a user has to do is to
check the Watch "star" for a given document, space, or even the whole
wiki. Of course this way users must do the action: they must check the
stars! But also any administrator can modify Watch lists in the
WatchListClass object of any users. And they also could be modified
programmatically (well, don't ask me how, please! :-)
Now for the coding: I started with
http://code.xwiki.org/xwiki/bin/view/Snippets/CsvExportOfUsersSnippet
yet group membership is only enclosed in the objects of the respective
group pages. Any suggestions how to either export only members of a
set group, or include subscribed groups as a column?
As for how to export members of a given group. I've modified slightly
the CsvExportOfUsersSnippet snippet. Just change XWiki.XWikiAdminGroup
with the document name of the group you want to export:
{{velocity}}
#if("$!{request.confirm}" == '1')
#set($ok = $response.setContentType("text/csv"))
#set($ok = $response.setHeader("Content-disposition", "attachment;
filename=export-users.csv"))
login;firstname;lasname;email;phone
#set ($sql = ", BaseObject as obj where obj.name = doc.fullName and
obj.className = 'XWiki.XWikiUsers' and obj.name <>
'XWiki.XWikiUserTemplate' order by doc.name asc")
#set($groupDoc = $xwiki.getDocument("XWiki.XWikiAdminGroup"))
#foreach($user in $xwiki.searchDocuments($sql))
#if($groupDoc.getObject('XWiki.XWikiGroups', 'member',
"$user"))
#set($userDoc = $xwiki.getDocument($user))
"$userDoc.name";"$userDoc.get('first_name')";"$userDoc.get('last_name')";"$userDoc.get('email')";"$userDoc.get('office_phone')"
#end
#end
#else
* [[Download CSV list of users of group
XWikiAdminGroup>>?confirm=1&xpage=plain&outputSyntax=plain]]
#end
{{/velocity}}
As for groups membership, check this:
{{velocity filter="none"}}
{{html clean="false" wiki="true"}}
#set($user = $xwiki.getUser())
#set($query = ", BaseObject as obj, StringProperty as prop where
doc.fullName = obj.name and obj.className='XWiki.XWikiGroups' and
doc.fullName <> 'XWiki.XWikiGroupTemplate' order by doc.fullName asc")
#set($results=$xwiki.searchDocuments($query))
#foreach($item in $results)
#if($user.isUserInGroup($item))
[[$item>>$item]]<p/>
#end
#end
{{/html}}
{{/velocity}}
Now, it will be needed to combine both scripts. I think it will be great
to have a selection list to choose the group we/you want to export and,
concerning groups membership, I don't know how to store the result in a
Velocity variable, then include it as column in the output. This must
not be difficult, but I've not tried yet!
Any idea about a more elegant way of doing this will be welcome!
HTH,
Ricardo
--
Ricardo RodrÃguez
CTO
eBioTIC.
Life Sciences, Data Modeling and Information Management Systems