It should be useful add a policy for let a group of users to view the node even if the node is set as private.
I've tried to modify the module adding on private_nodes_perm():
foreach ($types as $v) {
$permissions[] = 'user can view private node (type: ' . $v . ')';
}
So, in the private_nodes_check_access() we can check this policy too. I've add this:
$node = node_load(array('nid' => $nid));
$type = $node->type;
$nodetypes = private_nodes_get_node_types();
if (user_access('user can view private node (type: ' . $nodetypes[$type] . ')')) {
return true;
}
before the check of the ($is_owner || $is_admin || !isset ($level)).
What do you think?
Comments
Comment #1
ben_scott commentedI think that's a great idea - I'll add it to the module when I get a moment. :)
Thanks very much.
Comment #2
finex commentedHere is the patch for the head version of private nodes.
Comment #3
finex commentedI'm using this patch with the views module, but the views module doesn't work correctly with the "user can view private node of type" permission:
1) i've set a node as private (owner user John)
2) the user Tom have the "user can view private node of type" permission.
3) Tom can access to the node (ok, the permission so work)
4) Tom doesn't view the node from a views that should list the node.
We need to fix the private_nodes_db_rewrite_sql(). I'll try.
Comment #4
finex commentedBefore the:
on the private_nodes_db_rewrite_sql() function, I've added this code:
With this code the views module show the correct records: when an user can view the private nodes, the views show them. But I've found two big problem: the forums and the image gallery stop work! Both show zero records.
I don't know how to execute this code only in the views.
Comment #5
finex commentedSorry, the problem on the image gallery module was an error introduced by a misconfiguration. The problem is only in the forum.
Comment #6
Mantichora commentedI have tried your code, it seems to work for me but I did change the location.
Maybe you should try it too?
Comment #7
finex commentedMoving the code work as before: The image gallery and the forum does't work.
On the forum I've this error:
Where "comunicazione", "movimento" and "resoconto" are the node type which the current user can view with the
permission.
In the same way on the image gallery I've this:
The problem is on the name assigned to the node table: on the views the alias is "node" on the forum or the image gallery, it is "n".
I've tried to change the code:
to:
In this way the forum and the image gallery works correctly, but the views created with the views module stop working because them use the alias "node" for the node table.
We have to use this code for have this function work correctly:
I attach the full patch to the private module, for the current version available:
http://ftp.drupal.org/files/projects/private_nodes-5.x-1.x-dev.tar.gz
If someone can test the patch after we should apply it to the module.
Thanks all!
:-)
Comment #8
finex commentedUpdated patch, the previous one is wrong.
Comment #9
finex commentedThere is an issue to this patch.
Actually the private_nodes_get_node_types() return the NAME of the node type, not the TYPE.
In this way if the NAME contains special char (such spaces) the queries will be broken.
The Simple solution is to modify the rivate_nodes_get_node_types().
From:
To:
I've full tested this and it works flawlessly.