... |
... |
@@ -1,20 +1,18 @@ |
1 |
1 |
{{groovy}} |
2 |
|
-import org.xwiki.model.reference.DocumentReference |
|
2 |
+def groupDocRef = "XWiki.XWikiAllGroup" |
|
3 |
+def groupClassName = "XWiki.XWikiGroups" |
3 |
3 |
|
4 |
|
-def groupDocRef = new DocumentReference("xwiki", "XWiki", "XWikiAllGroup") |
5 |
|
-def groupClassRef = new DocumentReference("xwiki", "XWiki", "XWikiGroups") |
6 |
6 |
def mainGroupDoc = xwiki.getDocument(groupDocRef).getDocument() |
7 |
|
- |
8 |
8 |
def allUsers = xwiki.searchDocuments("where doc.fullName like 'XWiki.%' and doc.fullName != 'XWiki.XWikiAllGroup'") |
9 |
9 |
def added = [] |
10 |
10 |
|
11 |
11 |
allUsers.each { userDocName -> |
12 |
|
- def alreadyMember = mainGroupDoc.getXObjects(groupClassRef)?.any { |
|
10 |
+ def alreadyMember = mainGroupDoc.getXObjects(groupClassName)?.any { |
13 |
13 |
it?.getStringValue("member") == userDocName |
14 |
14 |
} |
15 |
15 |
|
16 |
16 |
if (!alreadyMember) { |
17 |
|
- def newObj = mainGroupDoc.newXObject(groupClassRef) |
|
15 |
+ def newObj = mainGroupDoc.newXObject(groupClassName) |
18 |
18 |
newObj.setStringValue("member", userDocName) |
19 |
19 |
added << userDocName |
20 |
20 |
} |
... |
... |
@@ -21,8 +21,8 @@ |
21 |
21 |
} |
22 |
22 |
|
23 |
23 |
if (added) { |
24 |
|
- def mainGroupWrapped = xwiki.getDocument(mainGroupDoc.documentReference) |
25 |
|
- xwiki.saveDocument(mainGroupWrapped, "Added missing users to XWikiAllGroup: ${added.join(', ')}") |
|
22 |
+ def wrappedDoc = xwiki.getDocument(mainGroupDoc.documentReference) |
|
23 |
+ xwiki.saveDocument(wrappedDoc, "✅ Added users to XWikiAllGroup: ${added.join(', ')}") |
26 |
26 |
println "✅ Added users to main wiki: ${added.join(', ')}" |
27 |
27 |
} else { |
28 |
28 |
println "✅ All users are already members of the main wiki." |