[pmwiki-devel] check authorization requirements for a given page

Hans design5 at softflow.co.uk
Thu Oct 1 17:32:55 CDT 2009


Thursday, October 1, 2009, 10:54:48 PM, Frank wrote:

> For me and my users, this should do the trick in local/config.php
>    $page = RetrieveAuthPage($pagename, 'read', true);
>    if ($page['passwdedit']) Markup(...);

It may do the trick for you, but mind that checking $page['passwdedit']
may not be enough, as an edit passoword may be set on the
GroupAttributes page, or as a general  default password in config
(the famous attributes cascade).

so to catch any of these, this code may be better:

  if (PageVar($pagename, '$PasswdEdit')) {
   ....special markup settings....
  }


PageVar($pagename, '$PasswdEdit') returns the attribute string,
information as to which users or group of users are authorised, and
if there is a password, shown as ******.
It is empty if nothing is set, on any level.

{$PasswdEdit} can be used in pages to show this info, or in templates
etc.
See also http://www.pmwiki.org/wiki/PmWiki/PageVariables
and http://www.pmwiki.org/wiki/Cookbook/PagelistAuthListShort
(for an example of use in a pagelist template)


Hans




More information about the pmwiki-devel mailing list