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

Eemeli Aro eemeli at gmail.com
Mon Jul 12 18:45:41 CDT 2010


On 12 July 2010 21:07, Randy Brown <alongkiss at aprivatespot.com> wrote:
> Thanks, Eemeli.
> That works as you described for passwords set on the page. Unfortunately,
> some of my pages inherit the attributes. I've tried numerous variations of
> your code, but haven't figured out how to do the test for Group and
> Site-inherited attributes. Is that possible? If so, any hints?

Here's a still hacky but possibly more robust & inheriting approach --
assuming that it works, as I haven't tested it:

$FmtPV['$NoReadPasswd'] = "($GLOBALS['NoHTMLCache'] & 2) ? 'false' : 'true'";

That depends on not having a custom $AuthFunction, and no recipe
fiddling with $NoHTMLCache in an odd way, and on RetrieveAuthPage()
getting called at least once before PVs are resolved, all which I'm
almost certain to be true in almost all cases. UserAuth might make
that not work, but then you wouldn't be asking about @nopass since it
handles access differently AFAIK.

eemeli

> Randy
> P.S. This is a pretty important conditional if you want to put
> visibility-dependent things like RSS links or Facebook "Like" buttons
> (http://www.pmwiki.org/wiki/Cookbook/FacebookLikeButton) on a page. I'm
> thinking if I display links and buttons on a page that won't service them
> due to password protection, it will just confuse users.
> On Jul 12, 2010, at 11:45 AM, Eemeli Aro wrote:
>
> Slightly hacky, but should work provided that the @nopass is set
> directly for the page, and not inherited from the GroupAttributes
> page:
>
>



More information about the pmwiki-users mailing list