PAC tree module snippet: Who gets to see this node?

This goes into your page.tpl.php or flexinode-x.tpl.php as necessary - I'm sure it could be converted to a block as well.

I use it for sensitive flexinodes that shouldn't be seen by everyone to make sure I don't accidentally give too wide permissions. One should note that this ONLY works with the PAC tree module, although it could doubtless be harassed into working with any permissions scheme with a few changes to the sql.

Screenshot of working snippet.

While not necessary, you might want also to throw this CSS into your themes/ styles.css to make things appear cleaner.

#folder_viewer { border:2px solid #CCCCCC; padding:10px; background-color:#FFFFFF;}
#checkbox { float:left;background-color:#C7FFC6; padding:3px; margin:2px;}
#checkbox_fail {float:left; background-color:#FFCECE; padding:3px; margin:2px;}

<?php
   
print '<div id="folder_viewer"><TABLE><TR><TD colspan=4>These roles have access to this node.<BR></TD></TR>';
//Check who has write access.
$result = pager_query(db_rewrite_sql('SELECT na.gid, r.name, na.grant_view, na.grant_update, na.grant_delete FROM `node_access` na INNER JOIN `role` r ON na.gid = r.rid WHERE nid = "' . $nid  . '" AND na.grant_view = "1"', n), 20);
while (
$node = db_fetch_object($result)) {
    print
'<TR><TD><B>' . $node->name . '</B> (' . $node->gid . ')</TD>';

        if (
$node->grant_view == 1) {
            print
'<TD><div id="checkbox"> &radic; Can see files:</div></TD>';
        }

        if (
$node->grant_update == 1) {
            print
'<TD><div id="checkbox"> &radic; Can add files</div></TD>';
        }
        else {print
'<TD><div id="checkbox_fail"> &times; Cannot add files</div></TD>';}

        if (
$node->grant_delete == 1) {
            print
'<TD><div id="checkbox"> &radic Can delete files</div></TD>';
        }               
        else {print
'<TD><div id="checkbox_fail"> &times; Cannot delete files</div></TD>';}
       
    print
'</TD></TR>';
    }
print
'</TABLE></div>';
   
?>

 
 

Drupal is a registered trademark of Dries Buytaert.