Hello,

We have a setup where someone can buy a video, and on purchase completion (ACL + Content Access + Ubercart) they get an ACL view access. The video shows up only if they have this specific permission, but they can still access the node itself (with a video placeholder) without that permission.

I would like to create a view for purchased videos. One way to do that would be to pull all the nodes that have specific ACL view permission (as opposed to node access in general).

Is there a way to do this?

Any other ideas on how I can accomplish this?

Thanks,
Andrey.

Comments

mr.andrey’s picture

I ended up using a default argument with PHP code. It checks for all the ACL view permissions for the current user and returns the list of nodes.

Here's how to do it:

Under Arguments, create a new argument: "Node: Nid"

Under "Action to take if argument is not present", select "Provide default argument"

Set the "Default argument type" to "PHP Code", and enter the following:

global $user;
return db_result(db_query("SELECT GROUP_CONCAT(CAST(an.nid AS CHAR) SEPARATOR ',') FROM {acl_user} au INNER JOIN {acl_node} an ON au.acl_id = an.acl_id WHERE an.grant_view = 1 AND au.uid = %d", $user->uid));

Then check "Allow multiple terms per argument", and click "Update".

Best,
Andrey.

salvis’s picture

Thanks for sharing this. I wish we had a good place for keeping such snippets — the issues queue is not really the right place...

mr.andrey’s picture

I use Vim for note keeping. It has folds, so you can keep things very organized for yourself.

Cheers,
Andrey.

mr.andrey’s picture

And just for reference, if you're using Taxonomy Access module, and want to provide and argument for explicit node view permission based on a term and a role that has permission to view it, here's the mysql query for that:

SELECT GROUP_CONCAT(CAST(tn.nid AS CHAR) SEPARATOR ',') FROM term_node tn INNER JOIN term_access ta ON tn.tid = ta.tid WHERE ta.rid IN (SELECT ur.rid FROM users_roles ur WHERE ur.uid = <your user id goes here>)
AND ta.grant_view = 1

Best,
Andrey.

salvis’s picture

I mean here on d.o...

salvis’s picture

Issue summary: View changes
Status: Active » Reviewed & tested by the community

Nothing to commit, just mark this for keeps.

salvis’s picture

Status: Reviewed & tested by the community » Closed (outdated)