Show last authors
author | version | line-number | content |
---|---|---|---|
1 | {{groovy}} | ||
2 | def mainGroupDoc = xwiki.getDocument("XWiki.XWikiAllGroup") | ||
3 | def groupClassRef = "XWiki.XWikiGroups" | ||
4 | |||
5 | def allUsers = xwiki.searchDocuments("where doc.fullName like 'XWiki.%' and doc.fullName != 'XWiki.XWikiAllGroup'") | ||
6 | def added = [] | ||
7 | |||
8 | allUsers.each { userDocName -> | ||
9 | def userDoc = xwiki.getDocument(userDocName) | ||
10 | def existing = mainGroupDoc.getXObjects(groupClassRef) | ||
11 | def alreadyMember = existing?.any { it?.getStringValue("member") == userDocName } | ||
12 | |||
13 | if (!alreadyMember) { | ||
14 | def newObj = mainGroupDoc.newXObject(groupClassRef) | ||
15 | newObj.setStringValue("member", userDocName) | ||
16 | added << userDocName | ||
17 | } | ||
18 | } | ||
19 | |||
20 | if (added) { | ||
21 | xwiki.saveDocument(mainGroupDoc, "Added missing users to XWikiAllGroup: ${added.join(', ')}") | ||
22 | println "✅ Added users to main wiki: ${added.join(', ')}" | ||
23 | } else { | ||
24 | println "✅ All users are already members of the main wiki." | ||
25 | } | ||
26 | {{/groovy}} |