Hello,

Nice module.

I've a content type 'product' and I wish that some nodes of them are not available for the role 'personal' and always available for the role 'professional'.

I've installed the module and setting it in 'Default permission settings'.

I've done a view to find my product by taxonomy term (exposed form). When I try to access to a page with a restricted access it well works, but I want that nodes with restricted access don't appear in the view results.

I've tried to add a filter 'node access'. When I doing this my view has no result.

How should I do to have only the node which are not restricted in my view?

Thanks in advance.

Comments

emptyvoid’s picture

There currently is no views integration for this module. If the community would like to provide a patch or discuss strategies for the a design to accomplish this I am all ears.

nsputnik’s picture

Yes, what can we do to have views access respect node_access?

Snehal-1’s picture

Hi frnd.. How to start Drupal? Whare is the correct documentation.. send that link na plzzz

nsputnik’s picture

Does a "Permission Prioritizer" or "Permission Hierarchy"module make sense to address the issue of conflicting permission issues?

maestrojed’s picture

I too wanted to use views in conjunction with node_access. I am using node_access to restrict by specific users. This is different then your issue in filtering by role. However, taking it a little further I imagine this could be adjusted to work for you too.

Here is my solution:

Installed a views modules called viewsphpfilter
http://drupal.org/project/viewsphpfilter

Apply this filter "Node: Node ID PHP handler."

You can now write some simple php, return an array of node ids and your view will work. Here is the code I used only show nodes that the authenticated user was granted permission to view via node_access:

// Get the authenticated user's information
global $user;
$userId = $user->uid;
//Start an array to hold the nids the user is allowed to access.
$output = array();
//If we found a user
if($user->uid>0){
//Query what nids this uid has access to
$sql = "SELECT nid FROM {node_access_user} WHERE uid=$userId ";
$results = db_query($sql);
while ( $data = db_fetch_object($results) ) {
//add this nid to the output array
$output[] = $data->nid;
//A Flag to know access is allow to at least 1 nid
$accessAllowed = true;
}
//if the user did not have access to any nodes
if($accessAllowed!=true){
//Set the output to zero
$output[] = 0;
}
}
//No UID, Not logged in. Return zero
else{
$output[] = 0;
}
return $output;

If there is still a need for a similar filter but by role let me know and I will try to help.

Michsk’s picture

Or take a look at the nodeaccess module withouth _-sign.

emptyvoid’s picture

Category: support » feature
selinav’s picture

Thanks for your replies, #5 is a good alternative until this functionality will be added.

kevinwo’s picture

A heads up to anyone using the above solution in #5, due to a recent change in Views PHP Filter 6.x-1.0 (see http://drupal.org/node/1088102#comment-4273008), make sure the two instances of the line:

output[] = 0;

read as:

output[] = '';

and all will be well.