List All Editors

Last modified by Vincent Massol on 2021/03/18 11:28

cogLists all the users that have edited a document
TypeSnippet
Category
Developed by

Sergiu Dumitriu

Rating
0 Votes
LicenseGNU Lesser General Public License 2.1

Table of contents

Description

This works with XWiki Platform >= 1.2

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

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

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.

Tags: users
     

Get Connected