[pmwiki-users] setting page attibute acording a publish/drafts ptv

Hans design5 at softflow.co.uk
Thu Nov 27 08:07:14 CST 2008


Thursday, November 27, 2008, 1:25:30 PM, noskule wrote:

> ok I try that, is there an example somwhere how to change attributes of pages
> in php?

I have no time to create a function, but here
http://www.pmwiki.org/wiki/Cookbook/FoxPageManagement
under "Creating a Profile page and Preferences page"
you find a filter script which sets an edit password.

$new['passwdread'] = crypt(read_password');

might do the trick.

perhaps:

# set read password "read_password" on target pages
$FoxFilterFunctions['FoxSetReadPW'] = 'FoxSetReadPW';
function FoxSetReadPW($pn, $fields) {
   global $FoxAuth, $AuthId, $Author;
   if(isset($fields['target']))
       $targets = preg_split("/[\s,|]+/", $fields['target'], -1, PREG_SPLIT_NO_EMPTY);
   else return;
   foreach ($targets as $tgt) { 
       if(isset($fields['foxgroup'])) 
            $pn = MakePageName($pn, $fields['foxgroup'].".".$tgt);
       else $pn = MakePageName($pn, $tgt);

       $page = RetrieveAuthPage($pn, $FoxAuth, true);
       if (!$page) echo "?cannot edit $pagename";
       $new = $page;
       if ($new['text'] =="") $new['text'] = " ";
        if ($AuthId) $new['passwdread'] = crypt('read_password');
       UpdatePage($pn, $page, $new);
   }
   return $fields;
}




  ~Hans




More information about the pmwiki-users mailing list