tips:display_acls
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | |||
wiki:tips:display_acls [2007-10-15 15:49] – made mail address clickable 131.220.9.183 | wiki:tips:display_acls [2007-11-20 13:29] (current) – Small bugfix 131.220.9.168 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Display ACLs in page footer ====== | ||
+ | Sometimes, it is interesting to know, who is allowed to view the current page. Checking this in the ACL plugin is difficult and only possible for admins. By patching your favorite [[: | ||
+ | |||
+ | ===== Instructions ===== | ||
+ | |||
+ | Somewhere in your template' | ||
+ | |||
+ | <code php> | ||
+ | <div class=" | ||
+ | <div class=" | ||
+ | <?php tpl_userinfo()?> | ||
+ | </ | ||
+ | <div class=" | ||
+ | <?php tpl_pageinfo()?> | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | Replace these lines with the following code: | ||
+ | |||
+ | <code php> | ||
+ | <? | ||
+ | function tpl_aclinfo() { | ||
+ | global $ID, $AUTH_ACL; | ||
+ | |||
+ | if (auth_quickaclcheck($ID) == 0) | ||
+ | return; // no rights to view, no rights to get this info | ||
+ | |||
+ | $page_acls = array(); | ||
+ | $namespaces = array(); | ||
+ | | ||
+ | $ns = getNS($ID); | ||
+ | while ($ns) { | ||
+ | | ||
+ | $ns = getNS($ns); | ||
+ | } | ||
+ | array_unshift($namespaces,' | ||
+ | |||
+ | $namespaces[] = $ID; | ||
+ | |||
+ | // check matches | ||
+ | foreach ($namespaces as $level) { | ||
+ | $matches = preg_grep('/ | ||
+ | $this_acls = array(); | ||
+ | foreach($matches as $match){ | ||
+ | $match = preg_replace('/# | ||
+ | $acl = preg_split('/ | ||
+ | $this_acls[urldecode($acl[1])] = $acl[2]; | ||
+ | if ($acl[1] == " | ||
+ | $page_acls = array(); | ||
+ | } | ||
+ | $page_acls = array_merge($page_acls, | ||
+ | } | ||
+ | | ||
+ | // check if visible to everyone: | ||
+ | if (($page_acls[' | ||
+ | return; // page is visible to everyone | ||
+ | | ||
+ | $list = array(); | ||
+ | foreach ($page_acls as $user => $right) { | ||
+ | if ($right > 0 && $user != " | ||
+ | array_push($list, | ||
+ | } | ||
+ | if (count($list)) { | ||
+ | sort($list); | ||
+ | print "(page visible to: "; | ||
+ | print join(', | ||
+ | print " | ||
+ | } | ||
+ | |||
+ | // Uncomment this, if you want to display users/ | ||
+ | /* $list = array(); | ||
+ | foreach ($page_acls as $user => $right) { | ||
+ | if ($right == 0) | ||
+ | array_push($list, | ||
+ | } | ||
+ | if (count($list)) { | ||
+ | sort($list); | ||
+ | print "(page hidden to: "; | ||
+ | print join(', | ||
+ | print " | ||
+ | } | ||
+ | */ | ||
+ | |||
+ | } | ||
+ | ?> | ||
+ | |||
+ | <div class=" | ||
+ | <div class=" | ||
+ | <?php tpl_userinfo()?> | ||
+ | <?php tpl_aclinfo()?> | ||
+ | </ | ||
+ | <div class=" | ||
+ | <?php tpl_pageinfo()?> | ||
+ | </ | ||
+ | </ | ||
+ | </ |
tips/display_acls.txt · Last modified: 2007-11-20 13:29 by 131.220.9.168