[pmwiki-users] How to use if ($page['=auth']['edit'])

Patrick R. Michaud pmichaud at pobox.com
Sat Sep 9 20:52:30 CDT 2006


On Sat, Sep 09, 2006 at 10:27:02PM +0200, Tom Lederer wrote:
> Hi all,
> after reading http://www.pmwiki.org/wiki/Cookbook/ 
> ConditionalMarkupSamples
> i assumed that i could use if ($page['=auth']['edit']) in a file:
> 
> What i try to do is
> 
> Markup("taghead",       "directives", '/\\(:markupname:\\)/ 
> ei',        'Keep(MarkupFunction())');
> 
> this should display different things to a editor than to a reader. So  
> i did:
> 
> function MarkupFunction() {
>      global $pagename,$ScriptUrl;
>      $page = RetrieveAuthPage($pagename, 'read', false,  
> READPAGE_CURRENT);
>      if ($page['=auth']['edit']) {
> 	return "You have edit rights.";	
>      }
>      else {
> 	return "Read only.";
>      }
> }

Since the page is already loaded into the cache by the time the 
markup is processed, it's a bit faster to do:

    global $PCache, $pagename;
    if ($PCache[$pagename]['=auth']['edit']) {
      return 'You have edit rights.';
    } else {
      return 'Read only.';
    }

> Does anyone spot an error, or can tell me how to accomplish this?

I don't immediately see an error with what you're doing, however,
so I'm not exactly sure what's going on.

Are you running your site with $EnableIMS set?  If so, you
might be seeing the effects of the browser cache.  

Pm




More information about the pmwiki-users mailing list