[pmwiki-users] How to detect if a page has @nopass for the read password

Eemeli Aro eemeli at gmail.com
Tue Jul 13 03:04:55 CDT 2010


On 13 July 2010 05:11, Randy Brown <alongkiss at aprivatespot.com> wrote:
> Thanks for the suggestion, Eemeli.  Unfortunately, that just gave me a blank page.

Blargle.

Trying and failing is dangerous, it sucks you in and makes you fix
things. This should work for the general case, but tell me if it
doesn't.

$Conditions['nopasswd'] = 'NoCache(CondNoPasswd($pagename, $condparm))';
function CondNoPasswd($pagename, $condparm) {
  global $HandleAuth;
  @list($level, $pn) = explode(' ', $condparm, 2);
  $pn = ($pn > '') ? MakePageName($pagename, $pn) : $pagename;
  if (@$HandleAuth[$level]>'') $level = $HandleAuth[$level];
  $page = RetrieveAuthPage($pn, $level, false, READPAGE_CURRENT);
  if (!$page || empty($page['=passwd'])) return FALSE;
  $ra = $page['=passwd']['read'];
  return (empty($ra) || ((count($ra) == 1) && (reset($ra) == '@nopass')));
}

To use:

(:if nopasswd read:)1(:else:)0(:ifend:)

or eg.

(:if nopasswd edit Main.HomePage:)1(:else:)0(:ifend:)

eemeli



More information about the pmwiki-users mailing list