Hello All,

A project I've got requires my module to receive a "ping" each time audio_attach adds and removes children. So, I modified audio_attach's add/remove child functions to ping audio_invoke_audioapi().

I feel this patch has quite a broad range of uses and since it adds such little overhead (add/remove child are only called by specific user action, infrequently).

My particular use-case involved tracking how many playlist items each user creates and, in a userpoints-ish system.

What do you think?

James.

Comments

James Andres’s picture

StatusFileSize
new1.3 KB

Had a bug in my original patch, please use this one.

zirafa’s picture

Sounds interesting. What are some potential use cases for this?

James Andres’s picture

Hi zirafa,

I'm really just scratching my own itch, but I thought the patch might be useful to a few other people. Also, I'm getting tired of writing proprietary code and keeping all the useful bits locked away (even though most clients don't mind us releasing bits of code GPL :-). But enough ranting..

The use-case I'm working with is userpoints-esq, as I mentioned above. I can't go into further detail, unfortunately, due to NDA constraints.

This patch is a useful addition purely on the basis that it fits squarely within the Drupal hook philosophy and hardly impacts performance (the attach/remove child/parent functions are only called when users save playlists ... which happens very infrequently, compared to page views).

I should probably also mention there is a much better way to implement this patch. However it's a bit invasive :-D, what I think would be better in the long run is to restructure the audio_attach module to be based on the insert/update hooks. For instance, when the audio_playlist module want's to add a new track to a playlist it should modify the $node->audio_attach array and call node_save(). Then the audio_attach module should catch the save $op and re-save the modified list. In my opinion this would be a better long-term approach. Also, if audio_attach were structured in this way my patch wouldn't be needed, since I could just catch the update and insert ops, along with every other module that wished to do so.

Cheers,

James.