Hi,
I have a question... and it's a little hard to work the answer out by reading the code.
1) If a blog's status is 0 by default, and then it's set to "1" later by a person or through Drupal's interface (therefore doing a node_save), is the module going to send the notifications *then*?
2)
In Free Software Magazine, blog entries are published by default. Then, I have a custom module that hooks to nodeapi and "unpublishes" them on the fly if they are from our columnists, which means they need to be edited. The nodeapi hook is called before Subscriptions' (the module starts with a "b"!). Apart from the fact that this is a little fragile, will it work OK with "subscriptions"? (I do a DB update and then set $node->status=0 when I sneakily set the entry to unpublished). The "theory" is that "subscriptions" won't even notice that $node->status was ever "1". Do you think my theory "holds"?
(I think it does. However, there is some seriously involved testing in this, and I will only do it if you *think* it will work)
Thanks!
Merc.
Comments
Comment #1
salvisYes, if you publish by saving the node, then this is how it works. Notifications are not sent when you do bulk publishing through Administer|Content though.
Yes, that should work. Actually, it's a bit more stable than you think, because subscriptions_content.module ensures that it's heavier than taxonomy.module (which has a weight of 0). So, unless you weigh down your custom module for some reason, it will definitely run before subscriptions_content.
Comment #2
mercmobily commentedHi,
Thank you for your response!
Two quick ones, and then I promise I will close this issue and disappear :D
----------------------------------------
Yes, that should work. Actually, it's a bit more stable than you think, because subscriptions_content.module ensures that it's heavier than taxonomy.module (which has a weight of 0). So, unless you weigh down your custom module for some reason, it will definitely run before subscriptions_content.
----------------------------------------
This is semi-unrelated, but I'd love to know as a developer... how did you weight the module?
Also, if I do mass-publishing, is there a way for me to instigate "subscriptions" to send out notifications? (I am talking about custom code, obviously. I don't need something 100% functional, just a hint will do!)
Thank you,
Merc.
Comment #3
salvisThe weight is set in subscriptions_content.install.
I intend to look into mass-publishing, hopefully today. The idea is to alter the form so that my function is called first, where I can do the queueing, and then I'll call the original function.
Comment #4
mercmobily commentedHi,
I was more thinking about if I used my own mass-publishing function.
For example, I use a custom-module to keep track of issues. When an issue gets published, the custom module goes through every article in the issue and sets it to "published".
Is there a hook or a function I could get node_issue.module to call in order to "wake subscriptions up" and get it to send notifications?
Thanks!
Merc.
Comment #5
salvisYou can assemble an event object as it's done in subscriptions_content_nodeapi() and call subscriptions_queue() with it, assuming you're dealing with simple nodes.
If you have special requirements for your content type, you can either implement a special GUI for them (subscriptions_blog_ui.module is an example) and keep using subscriptions_content.module, or your own Subscriptions add-in module (see the separate subscriptions_og project).
Comment #6
mercmobily commentedHi,
This is precisely what I needed - thank you.
Last question. Please allow me to be lazy... I am rarely so. How does the subscription module keep track of notification already sent out? That is, if for any reason a node is unpublished, then published, and then unpublished, and then published again, do you keep a tab of all the sent subscriptions?
Merc.
Comment #7
salvisIt doesn't keep track of sent notifications. Those that are sent are removed from {subscriptions_queue}, that's all.
If you unpublish and republish (without unchecking Send subscriptions notifications under Publishing options), new notifications are sent.
Comment #8
mercmobily commentedHi,
Ouch... OK.
I think that might become a patch of mine once the module is stable... I have the feeling this behaviour might become problematic for most sites.
Thank you for your answer and for your fantastic work!
(Feel free to close this issue, and thanks again)
Merc.
Comment #9
gustav commentedMerc, I too would be interested in a patch that made the subscriptions module keep track of the notifications it has already sent out. Do you want to open a new issue for that? I would need such functionality for example for the intelligent "send notification" link that I am planning, see http://drupal.org/node/214495.
Comment #10
mercmobily commentedHi,
Gutav: only if salvis, the maintainer, wouldn't mind me doing so. Maybe it's already planned, or maybe it would go against the current module architecture...?
(JUst being very careful here)
Consider that I am just taking 2 weeks off starting from Monday. Plus, I am maintaining 4 modules (one of them is huge: drigg, a full digg clone). But, I would need this patch for Free Software Magazine. So, I might end up doing it.
Merc.
Comment #11
salvis@mercmobily:
Why do you think that "most sites" will keep turning the published state on and off continuously?
I believe that turning it off (after it has been on and notifications have been sent) and then turning it back on would be a very rare exception that is covered by the checkbox in the publication options. Am I missing something?
At this point I see little benefit in introducing a table that keeps on growing indefinitely, so no, there are no plans for such a feature. Maybe you can convince me otherwise, but so far I don't think this is core functionality, and it would be best to put this into an add-on module.
I will certainly help if you want to work on it.
Comment #12
mercmobily commentedHi,
I think you are right. I must have been on crack -- who knows.
I will definitely write it as an extra module should I notice that it becomes a problem with Free Software Magazine. However, I doubt it.
Thank you!
Merc.
Comment #13
salvisComment #14
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.