[Pmwiki-users] [:if:] Syntax Question

Patrick R. Michaud pmichaud
Sat Oct 16 16:27:23 CDT 2004


On Sat, Oct 16, 2004 at 11:31:48PM +0200, Knut Alboldt wrote:
> 
> on 12 Oct, Patrick gave some statements to check the user's authorization:
> 
> >if (RetrieveAuthPage($pagename,'edit',false)) {
> >   # user is authorized to edit
> >} else {
> >   # user is not yet authorized to edit
> >}
>
> so this "only" has to be defined within the $Conditions-array (but I don't 
> know how yet, but it should be possible). This was one of the features I 
> had in pmwiki v1 and want to port to pmwiki 2.

In config.php:

   $Conditions['authedit'] = "RetrieveAuthPage(\$pagename,'edit',false)";

In the markup:

   [:if authedit:] You're authorized to edit this page [:ifend:]


There is one minor issue to note here, in that an author first visiting
the site will not see the conditional text until after she has entered
an edit or admin password for the page, and she won't be prompted for
a password until they attempt an operation requiring one (e.g., editing
a page).  So, using this as the only mechanism for displaying "edit page"
links might mean one cannot easily see it.  But I can think of lots of
applications where that's okay.

Another mechanism for hiding the edit and other command links based on
authorization is to use CSS to suppress the display, as in

   if (!RetrieveAuthPage($pagename,'edit',false))
      $HTMLStyles[] = " 
        #wikicmds { display:none; }
        .footnav { display:none; }\n";

Pm



More information about the pmwiki-users mailing list