[pmwiki-devel] new pages editable only by author?

Patrick R. Michaud pmichaud at pobox.com
Wed Jan 24 15:06:25 CST 2007


On Wed, Jan 24, 2007 at 02:57:09PM -0600, Ben Stallings wrote:
> Has anyone come up with a way to cause all newly created pages to be 
> editable only by their creators, by default?  

    function OnlyCreatorEdits($pagename, &$page, &$new) {
      global $AuthId;
      ## if the page already exists, we're not creating it, so do nothing
      if (PageExists($pagename)) return;
     
      ## we're creating the page, so set the default edit password
      ## if something else hasn't already set one
      if (@$AuthId && !@$new['passwdedit']) 
        $new['passwdedit'] = "id:$AuthId";
    }

    ## add our function into the edit sequence (somewhere before PostPage)
    array_unshift($EditFunctions, 'OnlyCreatorEdits');

> That is, assuming AuthUser 
> is in use, $page['passwdedit'] would be set to 
> "id:".$_SESSION['authid'][0] prior to running the WritePage function. 

I recommend against using $_SESSION['authid'] -- the way that authorization
information is managed may change in future releases.  

> The most practical place to do this would be in the PostPage function, 
> and admins would probably want to enable it on a per-group basis, so 
> there would need to be some sort of configuration array...

The code I gave above can go into any local customization.  

Pm



More information about the pmwiki-devel mailing list