The DeleteRevisionsAddOn allows users to delete revisions for a topic.

This is what happens:

  1. Given correct rights set in CurrentWeb.WebPreferences and Main.TWikiPreferences (See Installation instructions), the user is presented with the "Delete Topic Revisions..." link in "More Topic Actions"
    • Since the /bin/oops script can't read the $ENV{HTTP_ADFS_GROUP} , only topic and web settings are checked before displaying the "Delete Topic Revisions..."-link. The user is first checked when the script, /bin/delrefs is run, and is presented with a warning if it the action isn't authorized.
    • The DeleteRevisionsAddOn.pm will only search in the current web's WebPreferences topic for allowed users and topics, and only in Main.TWikiPreferences for allowed webs.
    • The user has to have CHANGE rights to the topic.
  2. The topic's .txt,v file (the file that keeps track of the revisions) then gets manually moved using "rename" to the Trash web.
    • If TrashWeb._DELREFS_CurrentWebCurrentTopic already exists, a number is appended to the trashed topic becomes TrashWeb._DELREFS_CurrentWebCurrentTopic_1
  3. After this, the topic is saved in the AddOn using the TWiki functions, in order to generate a new .txt,v file for the Topic.


  • It is not a nice thing to directly edit the template files. A better solution should be created.

Installation instructions

  • Unpack the tar in /your/twiki
File Description
lib/TWiki/Plugins/DeleteRevisionsPlugin.pm A simple plugin that checks if a) the user is in 'oopsmore.tmpl' ("More topic actions") and b) if the topic and web is authorized for the deletion of revisions. If so, a flag is set so that the revision delete link in oopsmore.tmpl is visible. This plugins also check's where you're coming from. Which the link in oopsmore.tmpl uses to tell 'delrefs' where it should redirect the user after it's done.
lib/TWiki/Contrib/DeleteRevisionsAddOn.pm Where it all happens. Includes a method for checking whether a user is allowed to delete revisions, used by DeleteRevisionPlugin.pm
lib/TWiki/Contrib/DeleteRevisionsAddOn/Config.spec Config file used for registering the bin script and the plugin.
bin/delrefs/ The bin script, nothing fancy happening here
  • Edit templates/oopsmore.tmpl and add the following definition at the top of the file among the other definitions:
<div style="display: %IF{"'%CAN_DELETE_REVISIONS%'='YES!'" then="block" else="none"}%">
---++ %MAKETEXT{"Delete topic revisions"}%
    $(function() {
        $('#deleterefs').click(function(e) {
            if (confirm("Are you sure you want to delete -ALL- previous revisions for this topic? Please note:\n\t1) This action -CAN NOT- be undone without talking to a TWiki administrator.\n\t2) The topic will be moved to the Trash Web where it may be subject to -PERMANENT DELETION- after some time.\n\nUse with care.")) {
                window.location = $(this).attr('href');
   * <strong><a href="%SCRIPTURL%/delrefs/%WEB%/%TOPIC%%IF{"defined 'DELREF_REDIRECT_TO'" then="?redirectTo=%DELREF_REDIRECT_TO%"}%" rel='nofollow' id="deleterefs">%MAKETEXT{"Delete topic revisions..."}%</a></strong>
     %MAKETEXT{"The topic will be cloned to !TrashWeb.[_1] before revisions are deleted in this web ([_2])." args="<nop>%TOPIC%,%WEB%"}%

  • Include the definition at the bottom of templates/oopsmore.tmpl with:

  • In the WebPreferences topic of the webs you want people to be able to delete revisions in, add the following section:
---++ Topic Revision Deletion

In this web (%WEB%), which users should be allowed to delete topic revision history?

   * Set DELREF_VALID_USERS = Main.User1, User2, e-group1, e-group2

On which topics should this be allowed? (DELREF_VALID_TOPICS = "ALLTOPICS" will allow _ALL_ topics for having its revision history deleted)

   * Set DELREF_VALID_TOPICS = Topic1, Topic2, Topic3

Please note that a user has to have CHANGE rights to the topic he/she is trying to delete revisions from.

  • In the Main.TWikiPreferences, set the following:

---++ Topic Revision Deletion

On which webs should this be allowed?

   * Set DELREF_VALID_WEBS = Web1, Web2

  • Even though the DeleteRevisionsAddOn only will search for DELREF_VALID_USERS/TOPICS/WEB in CurrentWeb.WebPreferences and MainWeb.TWikiPreferences, its still recommended to FINALize these preferences.

  • Re-save the TWiki configuration (/bin/configure) in order for the /lib/TWiki/Contrib/DeleteRevisionsAddOn/Config.spec contents to be added to /lib/LocalSite.cfg (registering the "delrefs" handler and enabling the plugin).

  • That's it smile Whenever a user visits "More Topic Actions" he will see the "Delete Topic Revisions..." link, allowing him/her to delete the revisions, given that he/she has sufficient rights of course.
Topic attachments
I Attachment History Action Size Date Who Comment
Compressed Zip archivetar DeleteRevisionsAddOn.tar r7 r6 r5 r4 r3 manage 70.0 K 2013-05-27 - 10:55 TerjeAndersen Various changed caused by the fact that the oops script ("more topic actions") cannot read egroups (at least not before implementation of ldap)
Edit | Attach | Watch | Print version | History: r10 < r9 < r8 < r7 < r6 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r10 - 2014-03-24 - TerjeAndersen
    • Cern Search Icon Cern Search
    • TWiki Search Icon TWiki Search
    • Google Search Icon Google Search

    TWiki21Nov All webs login

This site is powered by the TWiki collaboration platform Powered by PerlCopyright & 2008-2022 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
or Ideas, requests, problems regarding TWiki? use Discourse or Send feedback