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