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