<?php if (!defined('PmWiki')) exit();

# set edit password to $AuthId
$FoxFilterFunctions['FoxSetPW'] = 'FoxSetPW';
function FoxSetPW($pn, $fields) {
  //echo "FOXSETPW>"; //DEBUG//
   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['passwdedit'] = "id:$AuthId";  
       UpdatePage($pn, $page, $new);
   }
   return $fields;
}