[pmwiki-users] Checking permissions in the template?

H. Fox haganfox at users.sourceforge.net
Fri Jun 30 16:08:39 CDT 2006


On 6/30/06, Ryan R. Varick <rvarick at gmail.com> wrote:
> Perhaps this is a simple question, but I haven't found a solution yet.
>  Essentially what I want to do is a (:if auth edit:)... at the
> *template* level.  Specifically, I only want the edit link to be
> visible if the user has permission to edit the page.
>
> I see that PmWiki kind of does this by including PageActions.  I tried
> this approach first, but PmWiki wraps the link in <p> tags, which
> breaks the container I need to put this link in.
>
> So now I am at the template level.  I could use ReadPage on the
> current page and the GroupAttributes page, but that seems overkill.
> Is there a way to get at the current permissions for a page?  I need
> some way of saying:
>
> if(USER_CAN_EDIT) $MyEditFmt="{$Name}?action=edit"
> else $MyEditFmt = '';
>
> Surely there's an easier way than what I'm doing...

Try this:

$page = RetrieveAuthPage($pagename, 'read', false, READPAGE_CURRENT);
if (@$page['=auth']['edit']) $MyEditFmt="{$Name}?action=edit"
else $MyEditFmt = '';

Hagan




More information about the pmwiki-users mailing list