Needs work
Project:
View access per node
Version:
8.x-1.1
Component:
Miscellaneous
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
3 Jun 2019 at 01:22 UTC
Updated:
1 Dec 2022 at 13:44 UTC
Jump to comment: Most recent
Comments
Comment #2
rafuel92 commentedHello, thanks for the issue, this module uses standard hook_node_access (See here) so it should work, anyway i'll check this issue as soon as i can and let you know.
Comment #3
ash2303 commentedViews does not follow view option of `hook_node_access`. Use `Nodeaccess` module if you want to control nodes listing in views as well. You can also use something as below for quick fix with VAPN:
It will automatically apply access to the views containing VAPN nodes. If you want to show all nodes in a view irrespective of VAPN permissions, just use `Disable Sql Rewrite` in Query settings.
Comment #4
rafuel92 commentedwe may provide a configuration option into the vapn configuration to integrate the logic implemented in the pre render hook provided by @ash2303
Comment #5
HerrSerker commented#3 did it for me
Comment #6
greggmarshallActually hook_node_access() is skipped by Views, and other lists, by design Node access rights
Comment #7
dajka commentedUpdate: This is still an issue. Also I tried to implement #3 and it gives an unexpected error by now.
Update#2: Found the issue! you have to include the following line before the code for #3 to work.
use \Drupal\views\ViewExecutable;(Hopefully this saves some time for people like me :) )
Comment #8
tostinni commentedThe solution proposed in #3 is fine but it has a problem regarding the fact that it arrives after the query has been run and thus can lead to incomplete pages of your view.
Let's supposed you have a 10 items pager, if vapn needs to exclude 2 of them you will have 8 items in your page and 2 empty spots that would be visible if you have a grid display.
So here is a solution altering the view query by adding a relationship with the vapn table and checking if the node vapn configuration match the current user or if it's null.
Comment #9
jjmackow commented*3 is causing 500 errors with PHP 8.1 and 8.2. It had been working fine in PHP 7.4. What seems to be at issue is the if clause ...
and in particular, the first part ...
This issue comes when a user has 2 or more roles.
When the HTTP ERROR 500 occurs, this is written to the error log:
that particular line within the file is:
if (($context["row"] != twig_last($this->env, ($context["rows"] ?? null)))) {