[pmwiki-devel] testing auth level in a recipe

0 views
Skip to first unread message

Simon

unread,
Mar 17, 2022, 5:36:24 AM3/17/22
to PmWiki Devel Mailing List
I want to test the auth level of the page a recipe is on to restrict some output if it is not operating at admin or edit level

I've seen CondAuth, but wonder if there is another way

ngā mihi

Simon

Dominique Faure

unread,
Mar 17, 2022, 7:59:15 PM3/17/22
to Simon, PmWiki Devel Mailing List
Hi,

The following code defines a markup variable that you may use in a
test to render content accordingly:

=====8<- - - - -
function PmWikiAuthLevel($pagename) {
global $AuthLevels;
SDV($AuthLevels, array('admin', 'edit', 'read'));
foreach($AuthLevels as $level)
if(RetrieveAuthPage($pagename, $level, false, READPAGE_CURRENT))
return $level;
return '(none)';
}
$FmtPV['$AuthLevel'] = 'PmWikiAuthLevel($pn)';
=====8<- - - - -

Regards,

> _______________________________________________
> pmwiki-devel mailing list
> pmwiki...@pmichaud.com
> http://www.pmichaud.com/mailman/listinfo/pmwiki-devel

_______________________________________________
pmwiki-devel mailing list
pmwiki...@pmichaud.com
http://www.pmichaud.com/mailman/listinfo/pmwiki-devel

Simon

unread,
Mar 18, 2022, 3:09:12 AM3/18/22
to Dominique Faure, PmWiki Devel Mailing List
Thanks very much.

I should have said "within" the recipe, but this does function does exactly what I need,
and the page variable is a bonus

cheers

Simon




Reply all
Reply to author
Forward
0 new messages