[Pmwiki-users] Expiring page revisions.

Patrick R. Michaud pmichaud
Wed Oct 1 10:26:21 CDT 2003


On Wed, Oct 01, 2003 at 11:07:41AM +1000, Richard Canning wrote:
> 
>    Sometimes after doing a lot of editing on a page and getting it to the
>    point  I  am happy with I want to expire all of the page revisions and
>    clear the history.
> 
>    Is there any way to add an action that would automatically do this?
>    eg ?action=expirediff

Here's some code to do it (also available in the cookbook at
http://www.pmichaud.com/wiki/Cookbook/ExpireDiff):

  if ($action=='expirediff') {
    Lock(2);
    $page = RetrieveAuthPage($pagename,"edit");
    if (!$page) { Abort("?cannot get $pagename"); }
    $pagefile = FmtPageName("$WikiDir/$PageFileFmt",$pagename);
    @copy($pagefile,"$pagefile,$Now");
    $keys = array_keys($page);
    foreach($keys as $k) 
      if (preg_match("/^diff:(\\d+):/",$k)) unset($page[$k]);
    WritePage($pagename,$page);
    Redirect($pagename);
    exit;
  }

This code removes the page revision history, but also handles
locking and makes a backup copy of the page (same as if page was
deleted) prior to removing the page revisions.  The code requires
the person to have edit permissions on the page in order to remove
the revision history (you could easily change this to require "admin"
permissions instead).

Pm



More information about the pmwiki-users mailing list