List All Editors
Last modified by Vincent Massol on 2021/03/18 11:28
Lists all the users that have edited a document |
Type | Snippet |
Category | |
Developed by | |
Rating | |
License | GNU Lesser General Public License 2.1 |
Table of contents
Description
Simple and efficient query, but requires programming rights.
#set($targetDoc = $xwiki.getDocument("Main.WebHome"))
## Or any other document. Or just use $doc, the current doc.
#set($editors = $xwiki.search(
"select distinct rni.author from XWikiRCSNodeInfo rni where rni.id.docId = $targetDoc.id"))
#foreach($editor in $editors)
* $editor
#end
## Or any other document. Or just use $doc, the current doc.
#set($editors = $xwiki.search(
"select distinct rni.author from XWikiRCSNodeInfo rni where rni.id.docId = $targetDoc.id"))
#foreach($editor in $editors)
* $editor
#end
The same idea, but works without programming rights. A bit slower, as it contains an implicit join with XWikiDocument.
## This works with the current document, $doc, but can be modified as above.
#set($editors = $xwiki.searchDocuments(
", XWikiRCSNodeInfo rni where rni.id.docId = $doc.id and rni.author = doc.fullName"))
#foreach($editor in $editors)
## Write a link and a proper name, not just the document name. Can also be used in snippet 1.
* $xwiki.getUserName($editor)
#end
#set($editors = $xwiki.searchDocuments(
", XWikiRCSNodeInfo rni where rni.id.docId = $doc.id and rni.author = doc.fullName"))
#foreach($editor in $editors)
## Write a link and a proper name, not just the document name. Can also be used in snippet 1.
* $xwiki.getUserName($editor)
#end
The second snippet works in a single (non-virtual) wiki. When there are virtual wikis involved, things are a bit more difficult, as the author's document might be in another database. Still, it correctly selects all the editors with a local account.