Remove All Anonymous Comments
Last modified by Vincent Massol on 2021/03/18 11:29
Remove all anonymous comments from all pages in the current wiki |
Type | Snippet |
Category | |
Developed by | |
Rating | |
License | GNU Lesser General Public License 2.1 |
Table of contents
Description
{{velocity}}
#set($confirm = ("$!request.confirm" == '1'))
#foreach($item in $xwiki.searchDocuments(", BaseObject obj where doc.fullName = obj.name and obj.className='XWiki.XWikiComments'"))
#set($commentedDoc = $xwiki.getDocument($item))
#set($dirty = false)
#foreach($comment in $commentedDoc.getObjects('XWiki.XWikiComments'))
#if(!$comment.get('author').startsWith('XWiki.'))
* $item - $comment.getNumber() - $comment.get('author')
#if($confirm)
#set($discard = $commentedDoc.removeObject($comment))
#set($dirty = true)
#end
#end
#end
#if($dirty)
* Saving $commentedDoc
#set($discard = $commentedDoc.save('Removed spam comments'))
#end
#end
{{/velocity}}
#set($confirm = ("$!request.confirm" == '1'))
#foreach($item in $xwiki.searchDocuments(", BaseObject obj where doc.fullName = obj.name and obj.className='XWiki.XWikiComments'"))
#set($commentedDoc = $xwiki.getDocument($item))
#set($dirty = false)
#foreach($comment in $commentedDoc.getObjects('XWiki.XWikiComments'))
#if(!$comment.get('author').startsWith('XWiki.'))
* $item - $comment.getNumber() - $comment.get('author')
#if($confirm)
#set($discard = $commentedDoc.removeObject($comment))
#set($dirty = true)
#end
#end
#end
#if($dirty)
* Saving $commentedDoc
#set($discard = $commentedDoc.save('Removed spam comments'))
#end
#end
{{/velocity}}