12TA Your tip "ACLs of the current page in the page footer (template modification)"
did not match the text of the default template main.php.
Interestingly, this code example, despite it's date, is still working, today! Just note, that in main.php there are two languages present next to each other: HTML and PHP. So, everything within PHP tags <?php ... ?>
is PHP syntax. And outside those tags is HTML syntax, so take care of where you paste this code.
Generally speaking, this tweak consists of two components, first the definition of the new function tpl_aclinfo()
, and independently another codeblock, where this function is actually called and the result is rendered.
First code block (function definition):
<?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) {
array_unshift($namespaces,$ns . ':*');
$ns = getNS($ns);
}
array_unshift($namespaces,'*'); // root
$namespaces[] = $ID;
// check matches
foreach ($namespaces as $level) {
$matches = preg_grep('/^'.preg_quote($level,'/').'\s+\S+\s+\d+\s*$/',$AUTH_ACL);
$this_acls = array();
foreach($matches as $match){
$match = preg_replace('/#.*$/','',$match); //ignore comments
$acl = preg_split('/\s+/',$match);
$this_acls[urldecode($acl[1])] = $acl[2];
if ($acl[1] == "@ALL") // overwrites stuff from upper level
$page_acls = array();
}
$page_acls = array_merge($page_acls,$this_acls);
}
// check if visible to everyone:
if (($page_acls['@ALL'] !== false) && $page_acls['@ALL'] > 0)
return; // page is visible to everyone
$list = array();
foreach ($page_acls as $user => $right) {
if ($right > 0 && $user != "@admin" ) // admins can see everything
array_push($list,$user);
}
if (count($list)) {
sort($list);
print "(page visible to: ";
print join(', ',$list);
print ")";
}
// Uncomment this, if you want to display users/groups who cannot access this page, too:
$list = array();
foreach ($page_acls as $user => $right) {
if ($right == 0)
array_push($list,$user);
}
if (count($list)) {
sort($list);
print "(page hidden to: ";
print join(', ',$list);
print ")";
}
}
?>
The first code block has it's own PHP tags, thus, it can go just about anywhere, but should stay clear of other existing PHP tags, to avoid chaos and, thus, dysfunctional code.
Second code block (function call):
<?php tpl_aclinfo(); ?>
The second code block creates the output, and must be pasted in your main.php at the right location in order to have the output in the right place on your page. In the default template, this would be here.
After line 65 (into the empty line 66) insert the following line of code:
<div class="ACLinfo"> <?php tpl_aclinfo(); ?> </div>
If you use another template, let me know. I can look for you, to find a good spot for the code. I should mention, this is not update safe and further styling might be necessary for a sound end result.
Cheers!