Project:Taxonomy Access Control Lite
Version:6.x-1.3
Component:Code
Category:support request
Priority:normal
Assigned:wims
Status:active

Issue Summary

Hey, I have setup TAC lite to control node access by taxonomy terms. I create a taxonomy for each protocol I need to control access to, then on the user admin page under taxonomy based access I grant view rights as needed. This works perfectly.

Now I would like to produce a listing of users with view rights to each protocol (tax term). I don't completely understand how/where the data is being saved. I also use the devel node_access_user block to check rights, but this produces a table based on node.

It looks like the data field in the user table contains some data, but I do not understand the serialized format. Can someone help me get a listing by tax term of users with view rights??

Thanks to all.

Comments

#1

I too have spent a couple of hours trying to figure this one out.

I need to establish whether a user has access to a taxonomy term programmatically, by querying the database if need be, or better, by using an existing function (though it doesn't seem like the module exposes such a function).

Anyone with an idea on how to crack this?

#2

I need the same information. Can't find the connection between the User and the TAC Scheme.

Please help. Trying to import userid's from one system into drupal and I then need to set the tac lite information.

#3

Drupal's users table has a data field. It contains a serialized array of information about the user. Tac_lite's data is in there.

It makes it difficult to query in the way you guys are describing. But keeping the data there is one of the things that makes tac_lite lite. And it works with Drupal's user_load() and user_save() APIs.

#4

Component:Miscellaneous» Code
Assigned to:Anonymous» wims
Status:active» patch (to be ported)

I wrote this script. Put it in a Page body and set 'input format' to PHP to generate a user list by taxonomy term.

$op is the id of the Taxonomy term to filter my overview.
Yes I know this could be better and in the correct Drupal way but I'm still a starting Drupal user ;-(
Not found a better sollution at this moment.

<?php
  $op
= 291;
 
$items = array();
 
$block = array();
 
$result = db_query('SELECT DISTINCT uid FROM {users} WHERE uid > 1 ORDER BY name');
 
$output .= '<table>';
    while (
$tmp = db_fetch_object($result)) {
     
$x = user_load($tmp->uid);
      if (
is_array($x->tac_lite)) {
        if (
$x->tac_lite[6][$op] == $op) {

     
$output .= '<tr><td>';
      if (!
$x->picture == NULL ) {
         
$output .= '<div class="picture">';
         
$output .= '<a href="../user/'.$x->uid.'" title="Gebruikersprofiel tonen.">';
         
$output .= '<img src="../system/files/pictures/picture-'.$x->uid.'.jpg">';
         
$output .= '</a></div>';
      }   
         
$output .= '</td>'
     
$output .= '<td><a href= ../user/'.$x->uid.'>'.$x->name.'</a></td></tr>';
        }
      }
    }
 
$output .= '</table>'
  print
$output;
?>

#5

Status:patch (to be ported)» active

On a site with a lot of users, that code will run into problems.

Check out devel_node_access, part of the devel package. It's not exactly what you guys are looking for, but it may provide some ideas.

#6

I am in a similar situation as the OP. I needed to make a menu that would show ALL menu items all the time (regardless of access), but only actually link the menu items the user has access to.

I used this to grab user's taclite permissions:

global $user;
$grants = tac_lite_node_grants($user, view);

Then I used this to check if the user has access to the TID (taxonomy id):

if (in_array($tid, $grants['tac_lite'])) {
//do something
}

Worked fantastic for me. You will still have to deal with users who have absolutely no TAC_LITE limitations (their TAC_LITE grants array is equal to 0 or 1)... this probably means anonymous users, authenticated users and the super administrator (you). I just made cases for each type and dealt with them.

This filters out anonymous (not logged in) users:

if (user_is_logged_in()) {
//do something
}

This filters out the super administrator (you, user 1):

if ($user->uid == 1) {
//do something
}

Best of luck!

nobody click here