Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
My use case is: I need to do stuff when content is affiliated to a new domain.
I couldn't do that with rules. Tried using node data comparison condition with the node saving event, but since domain affiliation is not a field, I could not compare the data.
Also, domain access has a bunch of hooks, but no hook for such situation. But that's another issue, on another module. :-)
I think it would be great to have the following events:
- Node is added to a domain
- Node is removed from a domain
- User is added to a domain
- User is removed from a domain
Thanks
Comments
Comment #1
shushu CreditAttribution: shushu commentedHi,
I understand your needs, but looking into the domain module code it seems those hooks are really missing, and that I won't be able to easily implement those events without them.
_domain_store_grants() seems to be the place needs to be patched and to add the hooks.
It also need to properly show the old domains of a node, new domains of a node, and the "diff" between them.
When this data will exist, I will be happy to implement the Rules events for it.
@tomyinhauser, sorry.
Comment #2
agentrickardInteresting. Problem is, I don't use Rules.
I would prefer this be supported in Domain Rules (which is where Rules integration should go).
What you would need to do is read hook_node_presave(), I suspect, and fire a Rules hook there. Really, what you're checking for is if a value of the field has changed on the node (or the user).
Comment #3
shushu CreditAttribution: shushu commented@agentrickard, thanks.
Trying to grab the info from hook_node_presave() might be problematic and depend on the order of the things.
May I provide a patch that wil call a hook in _domain_store_grants() /
Do you think it will be the right place to put it ?
Thanks,
Shushu
Comment #4
agentrickardThat might be the safest place, because by that point, we've determined what grants to store.
I'd prefer to put a hook in there that Domain Rules can respond to. I really don't want to maintain Rules integration code.
Comment #5
shushu CreditAttribution: shushu commentedSure, I never thought you will maintain the rules integration. I just need the hook in the right spot.
I will keep you updated.
Thanks,
Shushu