Restore XWikiAllGroup
Last modified by Sergiu Dumitriu on 2021/03/18 11:28
Fixes the XWikiAllGroup by synchronizing it with real users in the wiki |
Type | Snippet |
Category | |
Developed by | |
Rating | |
License | GNU Lesser General Public License 2.1 |
Table of contents
Description
Recreates the XWiki.XWikiAllGroup page with all existing users added to it. This can be useful for the case when you accidentally delete or overwrite XWikiAllGroup (such as when you do a XAR import and overwrite it by mistake).
Add the following in a document in the XWiki Syntax 2.1:
{{velocity}}
#set ($allGroupDoc = $xwiki.getDocument('XWiki.XWikiAllGroup'))
#foreach ($userDocName in $xwiki.searchDocuments(', BaseObject as obj where obj.className=''XWiki.XWikiUsers'' and obj.name=doc.fullName'))
#if (!$allGroupDoc.getObject('XWiki.XWikiGroups', 'member', $userDocName))
#set ($member = $allGroupDoc.newObject('XWiki.XWikiGroups'))
$!member.set('member', $userDocName)
* Restoring user [[$userDocName]] in XWikiAllGroup
#end
#end
#if ("$!{request.confirm}" == '1')
$allGroupDoc.save()
#else
[[Confirm these changes?>>$doc||queryString="confirm=1"]]
#end
{{/velocity}}
#set ($allGroupDoc = $xwiki.getDocument('XWiki.XWikiAllGroup'))
#foreach ($userDocName in $xwiki.searchDocuments(', BaseObject as obj where obj.className=''XWiki.XWikiUsers'' and obj.name=doc.fullName'))
#if (!$allGroupDoc.getObject('XWiki.XWikiGroups', 'member', $userDocName))
#set ($member = $allGroupDoc.newObject('XWiki.XWikiGroups'))
$!member.set('member', $userDocName)
* Restoring user [[$userDocName]] in XWikiAllGroup
#end
#end
#if ("$!{request.confirm}" == '1')
$allGroupDoc.save()
#else
[[Confirm these changes?>>$doc||queryString="confirm=1"]]
#end
{{/velocity}}