Clean Activity Stream

Last modified by Vincent Massol on 2016/01/21 10:29

cogA form to remove events from the Activity Stream
TypeXAR
CategoryApplication
Developed by

Pascal Bastien

Rating
Rate!
0 Votes
LicenseGNU Lesser General Public License 2.1
Installable with the Extension Manager

Description

By default the Activity Stream is displayed on the front page of XWiki and sometimes there's a need to remove some entries from it (someone modifying a page with some rude language comment, creating/deleting a page that we don't want to show in the stream, etc).

This application allows removing some specific events from the Activity Stream.

Form to delete selected events

CleanASBefore.png

Result

CleanASAfter.png

ASBeforeAfter.png

Notes

  • The form is installed in Sandbox by default but it is an admin tool, once installed you can move page in a space of your choice
  • The form shows only last 500 events by default
  • After event deletion you must refresh the page to update the list displayed by the form (deleted event still show up in the list prior to refresh)
  • Old Activity Stream events can be removed using the cleanup parameters that exists in the xwiki.cfg configuration file:
    #-# Number of days the events should be kept (0 or any negative value: infinite duration)
    #-# Note: if this value is greater than 0 a scheduler job will be created, this job will then be fired every week to
    #-# delete events older than the configured value.
    #-# Default: 0
    # xwiki.plugin.activitystream.daystokeepevents=0

Tested on

This extension has been tested with the following configurations.

Extension VersionXWiki FlavorNotes
0.9XWiki Enterprise 7.0.1
 

Prerequisites & Installation Instructions

We recommend using the Extension Manager to install this extension (Make sure that the text "Installable with the Extension Manager" is displayed at the top right location on this page to know if this extension can be installed with the Extension Manager). Note that installing Extensions when being offline is currently not supported and you'd need to use some complex manual method.

You can also use the following manual method, which is useful if this extension cannot be installed with the Extension Manager or if you're using an old version of XWiki that doesn't have the Extension Manager:

  1. Log in the wiki with a user having Administration rights
  2. Go to the Administration page and select the Import category
  3. Follow the on-screen instructions to upload the downloaded XAR
  4. Click on the uploaded XAR and follow the instructions
  5. You'll also need to install all dependent Extensions that are not already installed in your wiki

Download/install Sandbox.CleanActivityStream-v0.9.xar xar extension and move page in a space of your choice OR

  • Copy/paste this code below in a page:
    {{velocity}}
    =Form to delete manually some events entries from Activity Stream =

    Select events below (last 500) and click on button to delete them

    #if ($xwiki.hasAdminRights())
     {{html}}
     <form method="get" id="DelActivityStream" onsubmit="return confirm('Delete selected events: are you sure?')">
     <div class="container">
        ## List 500 last events
        #foreach ($MyEvent in $xwiki.activitystream.getEvents(false, 500, 0 ))
          #set($MycheckBox="<input type='checkbox' name='IdEntry' value='")
          #set($MycheckBox=$MycheckBox + "$MyEvent.getEventId()")
          #set($MycheckBox=$MycheckBox + "'
    />" + "$MyEvent.getDisplayDate() - $MyEvent.getPage() - $MyEvent.getType() - - $MyEvent.getUser() " + "<br />")
          $MycheckBox
        #end
       </div>
       <span class="buttonwrapper"><input type="submit" value="Delete selected entries from Activity stream" class="button"/></span>
     </form>
    {{/html}}
     #else
    {{warning}}
      You must login with an administrator account.
    {{/warning}}
    #end

    ## Get selected events ids
    ## formatting to use data in next hql query: act.eventId in ( 'xxx-yyyyy', 'another-ide', 'etc' )
    #set($ListIn = $stringtool.join($request.getParameterValues('IdEntry'), "', '"))
    #set($ListIn = "'" + $ListIn + "'")

    ## Get selected events object
    #set($results= $xwiki.activitystream.searchEvents("act.eventId in ($ListIn)", false, 0, 0))

    ## loop on theses events and delete them
    #foreach ($MyEventToDelete in $results)
      $xwiki.activitystream.deleteActivityEvent($MyEventToDelete)
      * $MyEventToDelete.getDisplayDate() - $MyEventToDelete.getPage() - $MyEventToDelete.getType() - - $MyEventToDelete.getUser() ~*~*  //**deleted**//  ~*~*
    #end

    {{/velocity}}
  • Add this XWiki.StyleSheetExtension object on the page:
    .container {
     border:2px;
     solid #ccc;
     width:800px;
     height: 300px;
     overflow-y: scroll;
     margin-left: unset;
    }

Release Notes

v0.9

  • v0.9: initial version
Created by Pascal Bastien on 2016/01/21 08:52
    

Get Connected