[pmwiki-users] Password protect page with editors' password action

Alex Eftimiades alexeftimiades at gmail.com
Sat Jul 14 17:53:28 CDT 2012


I have been trying to make a button that password protects a page with  
the editors' password, or un-protects it if it is already protected.

I tried putting this at the bottom of config.php, but it just seemed  
to mess up my pages:
$HandleActions['switchauth'] = 'switchauth';  # if url contains  
action=myaction call HandleMyAction timely
$HandleAuth['switchauth'] = ' ';              # authorization level  
$auth for HandleMyAction

function switchauth($pagename, $auth) {     # parameters (signature)  
of handler function required by PMWiki
#  Lock(2);
   $pagestuff = RetrieveAuthPage($pagename, 'attr', false);
   $old=$pagestuff;
   if($pagestuff['protected']==true){
     $pagestuff['passwdread'] = 'test';
     $pagestuff['protected']=false;
   }
   else{
     $pagestuff['passwdread'] = 'test';
     $pagestuff['protected']=true;
   }
   UpdatePage($pagename, $old, $pagestuff);
   Redirect($pagename);
#  Lock(0);
}

Can someone please help me?
Alex



More information about the pmwiki-users mailing list