[pmwiki-users] Checking permissions in the template?
Ryan R. Varick
rvarick at gmail.com
Sat Jul 1 01:48:12 CDT 2006
On 6/30/06, H. Fox <haganfox at users.sourceforge.net> wrote:
> 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
>
Looks like black magic to me, but it's exactly what I needed. Thanks.
Ryan
More information about the pmwiki-users
mailing list