Thanks for this amazing module. I'm using it in a project with several domains and it works like a charm. However, I'm having one use-case I can't get to work.

We are using the Relations module to link content within the site. For example; we show related 'activity' nodes in the the sidebar for specific 'news_items'. The clients now requests a way to show related content across domains. So; show a related activity from domain1 on a news items of domain2.

The Relation module allows admins to relate content from all domains. However, this content is not shows in the sidebar as a teaser due to Domain module (which uses hook_node_access_records() and hook_node_grants()). I've tried implementing hook_node_access(), but that only works for full nodes, where I'd like to allow viewing of teasers.

Summarized: is there a way to show teasers of another domain content in specific cases (eg; it is linked to using the Relation module from the current page), and if so; how? Can this be done with hook_node_access_records/hook_node_grants?

Comments

agentrickard’s picture

The short answer is no. You cannot. hook_node_access() actually will work on teasers, but really it only runs once per node, and that may cause the problem.

The node_grants() solution won't work either, because of the limitation of "check access once per node."

To really do this, you'd have to write a custom block that loads your nodes. You can do this in Views by enabling the 'Disable SQL rewrites' option, though this opens potential security risks.

One other way to handle this would be to create a new node type for those "teasers" and assign those nodes to "All affiliates" but have them link to the proper nodes. That would take some doing, but it would be secure.

BarisW’s picture

Thanks for the response. Actually, we've got it working using hook_node_grants. We've added a custom grant and we save the nid of the node from which the teaser is referred from.

When we check for access on the node teaser, we fetch the current node_id and if it differs from the node that is checked, we can assume that it's a teaser display. Then we can check for the grant and allow access if the nid of the current full node matches the node grant entry.

Obviously, we needed to add hooks to insert/delete grants when a relation has been made/deleted.

Sutharsan wrote this code, we might be able to share it as a contrib module.

agentrickard’s picture

That sounds very weird ;-)

hanksterr7’s picture

I'd be interested in the code. Can it be shared?

BarisW’s picture

@hanksterr7: sure, will do, but I want to clean-up the code first and make it less client-specific.