Recent Changes - Search:

Cookbook

PmWiki

pmwiki.org

ExpireDiff

Summary: How to remove a page's history
Version:
Prerequisites:
Status:
Maintainer:
Categories: Administration

Question answered by this recipe

How do I remove a page's history?

Answer

The expirediff.phpΔ script adds ?action=expirediff, which removes all of the page revision history information from a wiki page. It requires the user to have edit permissions to the page, and handles locking. It also creates a backup copy of the page with the page revisions intact (same as if someone had requested to delete a page).

In addition, one can add the keepdays=nn parameter, which says to keep any page history within the past nn days. For example, ?action=expirediff&keepdays=7 will remove any page history older than seven days. By default keepdays is zero, which expires the entire page history.

You can also remove the history of all pages or only the history of a specified group. It is possible to specify some options when calling the function ExpireDiffAll from your config.php. The first parameter specifies the group whose files history should be removed. Default is '' which means all files. The second parameter specifies whether backups should be created, 0 means overwrite existing files (defaults to 1). Be careful with this option! The third parameter specifies which histories should be kept, see keepdays above (defaults to 0).

Example:
    
    ExpireDiffAll('Test',0,5);
    

means: Remove the history older than 5 days from all files within the Group Test and overwrite existing files (no backup).

To install this script, simply copy it into your cookbook/ subdirectory, and then add the line

    include_once('cookbook/expirediff.php');

to your local/config.php file.

See Also

Contributors

  • Pm, 2004-12-18
  • Klonk, 2005-04-14, Added function ExpireDiffAll
  • Klonk, 2005-08-10, Updated to add the action with help of $HandleActions
  • Klonk, 2005-08-24, Fixed bug introduced with last change
  • Hagan, Suggestion to fix password protection
  • Dfaure, Suggestion to add ExpireDiff to end of history page
  • Ian MacGregor, Suggestion to style (via CSS) ExpireDiff on history page

Comments

Shouldn't this be also password protectable? Klonk

I made a little modification to add a pwd parameter to pass to the action, you have to encode your password into the expirediff.php file. I use it on my site. Here is the code I added to the original recipe:

<?php

if ($action=='expirediff') {

  # Added code START

  # Change ABC to the password you like
  SDV($MyPwd,'ABC');
  $InputPwd = @$_REQUEST['pwd'];
if (! $MyPwd == $InputPwd ) { Abort("Wrong password!!"); }

  # Added code END

  Lock(2);
.......

SteveAgl

Starting with version 2.0.beta50, you can password-protect the action with

$HandleAuth['expirediff'] = 'edit';

or

$HandleAuth['expirediff'] = 'admin';

to require the edit or admin password respectively.

-Hagan

(:table border=0:)

!

I found out that some changes to expirediff.php are necessary to have password-protection via $HandleAuth['expirediff'] work properly:

  • Change the Line function HandleExpireDiff($pagename) {
    to the following: function HandleExpireDiff($pagename, $auth = 'edit') {
  • Change the Line $page = RetrieveAuthPage($pagename, "edit");
    to the following: $page = RetrieveAuthPage($pagename, $auth);

--floozy

floozy,
That didn't quite work because you could expired the diff without having edit privileges. I made some similar changes that should work. Specifically,
  • Added a line SDV($HandleAuth['expirediff'], 'edit');
  • Changed the Line function HandleExpireDiff($pagename) {
    to the following: function HandleExpireDiff($pagename, $auth) {
  • Changed the Line $page = RetrieveAuthPage($pagename, "edit");
    to the following: $page = RetrieveAuthPage($pagename, $auth);
Thanks! --Hagan

You may also add the following code to your local/config.php in order to add the ExpireDiff feature to the end of the history pages:

...
include_once('cookbook/expirediff.php');
...
if ($action == 'diff') {
  $ExpireDiffFmt = <<<_EOT_
<div id='wikiexpire'>
  <form action='\$PageUrl' method='post'>
    <input type='hidden' name='action' value='expirediff' />
    <input type='hidden' name='n' value='\$FullName' />
    <p>Expire difference(s) older than
      <input type='text' name='keepdays' value='7' /> day(s)</p>
    <input type='submit' />
  </form>
</div>
_EOT_;
  $HandleDiffFmt = array(&$PageStartFmt, &$PageDiffFmt,
                         'function:PrintDiff',
                         &$ExpireDiffFmt, &$PageEndFmt);
}
...

-- Dfaure

  • Thank you Dfaure for this setting, it works great. I'd also like to add that, thanks to Dfaure's inclusion of <div id='wikiexpire'>, you can style this in your history pages by adding this to your skin's .css file:
#wikiexpire {
border: 1px solid #aaaaaa;
background-color: #dddddd;
padding: 2px 2px 2px 2px;
font-weight: bold;
}

You can change the above styling, just like any other css styling, to suit your skin. --Ian MacGregor

error message 20070425

Warning: Cannot modify header information - headers already sent by (output started at /var/www/.org/wiki.*****.org/pmwiki/cookbook/expirediff.php:75) in /var/www/.org/wiki.rijiben.org/pmwiki/pmwiki.php on line 965

ExpireDiffAll('Test',0,5);

Edit - History - Print - Recent Changes - Search
Page last modified on June 06, 2008, at 02:36 PM