Use node_save() for saving audience changes
| Project: | OG Audience |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Jump to:
I like this module and think it elegantly solves a thorny problem. Thus, I am dropping some similar functionality from OG and referring people to this module. See http://drupal.org/node/164070. Be prepared for some more users!
I have a few notes after reading the code:
- og_audience_build_form_submit() should really do a node_load(), change the groups, and then node_save(). that way, actions and other modules will learn about the group change. if there is a problem doing this, lets discuss.
- i think that og_audience_form_alter() wil not be needed in OG 5.x.4 since i will not allow editing of audience by non admins.
- og_audience_build_form() copies some code from OG. if possible, submit a refactoring patch to OG so you don't have to do that.

#1
Thanks for the advices, Moshe! I'll try to implement them soon. You also have commit access to the module, in case you need to change anything.
#2
@Moshe: Your last two recommendations are now fixed for sure. But for the first one I'd need to investigate further. At the moment, OG Audience does the following to save group assignments:
og_save_ancestry($node);node_access_acquire_grants($node);
cache_clear_all();
#3
Two items fixed in 6.x, to be clear.
#4
#5
Alternatively, perhaps we could invoke hook_nodeapi() directly from OG Audience, with $op = 'update'.
#6
Invoking hook_nodeapi() looks like a good solution to me. That would allow the trigger module to trigger actions when the audience gets updated.