Needs work
Project:
Simplenews
Version:
6.x-2.x-dev
Component:
Usability
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
11 Dec 2008 at 05:14 UTC
Updated:
29 May 2013 at 12:05 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
sutharsan commentedWhat is there at Simplenews triggers is a very basic implementation. I can't remember to what extend it has been tested.
What you describe is very usefull functionality and is exactly where actions and triggers are for. It probably needs some code to get it working. Patches are welcome.
Comment #2
callison commentedI'm working on a patch for this, but I'm having just a little bit of trouble.
I've got a new action defined and I added a case in the simplenews_mail() function to handle mailing to the recipient admin. My trouble, though, is figuring out how I get the tid of the newsletter that was just subscribed/unsubscribed to/from.
I know that the account data is passed into the action function I created, and there is an array $context['account']->tids, but the index of that array is the tid itself, which I don't know. So, how do I get the tid to reference the $context['account']->tids in the first place?
Here is the action function I wrote:
And here is the case in simplenews_mail():
I fee like there is an easy way to do this, but I sure can't figure it out. Any help would be appreciated. Many thanks.
Comment #3
sutharsan commentedThe tid sould come in into the action via the context or object, depending on which trigger you use. I guess the object if you use the subscription trigger.
Note: If you are planning to make a patch, make sure you follow drupal coding standards.
Comment #4
callison commentedActually, I don't think the tid of the newsletter being subscribed to (or unsubscribed from) is passed in through either of those variables. If a user is already subscribed to any newsletter at the time of the subscription, an array of all the tids the user is subscribed to is passed in through $object but not the current one. Does that make sense?
I'm wondering if we could add a variable to the $context array in the simplenews_call_actions function. The current function looks like this:
Could we change it like this to include the $tid
Comment #5
sutharsan commentedIt has been some time since I worked on simplenews_actions module. Feel free to write the required code and post a patch here.
Comment #6
callison commentedI have attached two patches, one for simplenews.module and one for simplenews_action.module.
Here are the changes I made to simplenews.module:
Here are the changes I made to simplenews.module:
Comment #7
callison commentedI updated simplenews_action.module so that you can choose which newsletters you want to be notified about.
Comment #8
thepanz commentedI edited your simplenews.module patch adding some t() calls and some text adjustments. For latest 6.x-1.x-dev.
How can we merge our edits?
Regards
Comment #9
callison commentedThanks for your review. How about you just upload your revised patch or send me the changes and I'll do it.
Comment #10
thepanz commentedI'm behind a Firewall now, I attach my simplenews module. you can view my edits using a diff SW.
Regards
Comment #11
callison commentedThanks. I have made the changes and posted the updated patch.
Comment #12
thepanz commentedMaybe you should also add a t() call in
Comment #13
thepanz commentedI re-rolled to 6.x-1.x-dev CVS version and edited (again) your patches:
- Changed Action name (more clear)
- Added t() to "Anonymous User"
All the edits are working fine and notify eMails are sent Ok.
Regards
Comment #14
callison commentedLooks good. Thanks for your changes.
I added a feature to allow entering a username as a recipient (with autocomplete).
I also fixed the logic for determing if this is a subscription or UNsubscription. The original if statement used simplenews_user_subscribed() which failed if the user used the "Subscribe/Unsubscribe" button on the simplenews block. I changed it to look at the $_POST['op'] variable which, I believe, is very consistent.
Lastly, I made the multiple newsletter select (in the action configuration form) a required field.
Thanks for your help!
Comment #15
sutharsan commentedThanks for the code so far!
The content of the email should be more flexible. Themable at least, or perhaps better like 'Send e-mail' trigger does it with a webform. The latter should than have a way of inserting the newsletter name, tid, etc. into it.
Can the (un)subscribe action be modified so 'Send e-mail' and other actions can use it?
The patch contains code style errors. Please use Coder Module to check.
Comment #16
callison commentedThis is fun! I've never submitted code to Drupal before.
I updated the action configuration to include a Message Settings fieldset where there is a subject, message, and checkbox (to include link for user's account page).
I allowed for a %status ('Subscribe' or 'Unsubscribe') variable within the subject and/or body fields. This allows people to use the same subject and message for both subscriptions and unsubscriptions. For example, the subject could be
[%newsletter] %status Notificationwhich makes the subject[Newsletter Name] Subcribe Notification. Also, the message could containSomeone has %statusdwhich becomesSomeone has Subscribed. After playing around (making separate subscribe/unsubscribe message settings, etc.) this seemed to be the best way to proceed. Any thoughts would be appreciated.These changes checked out fine in the Coder Module. I did, however, notice some style errors (and even a potential SQL security issue) in simplenews.module not related to these changes.
Sutharsan, I wasn't sure what you meant by modifying the action so 'Send e-mail' can use it? Would you please describe how that could be done and what the purpose would be. Thanks.
Comment #17
thepanz commentedHi Callison, well done! You know.. OpenSource projects can be fun if you contribute (.. and if the community is responsive) ;)
I'm wondering if a multiple-receivers feature should be implemented.. and if receivers can/must be registered user (selection with auto-complete field?)
Another question is: is the sent message translatable? I can't find any Drupal suggestion about user-input translation..
Regards
Comment #18
callison commentedThanks!
As far as multiple receivers go, this should probably not be a feature of this patch because users can add as many actions as they want defining who to send notifications to. However, that said, it could be really useful to be able to, for example, notify all moderators when someone subscribes (and enable that with one action). I'm up for suggestions on if and how this could be implemented. I already have the auto-complete functionality for a single recipient. I would have to think about how to best implement that with multiple recipients. Again...suggestions.
I don't know about translatability (is that a word?). Doesn't drupal_mail() automatically translate the message into the recipient's default language?
I appreciate your help and suggestions. Thanks.
Comment #19
sutharsan commentedI suggested to investigate the possibility of using the 'send email' because I'd rather see smart use of existing tools than introducing new ones. Currently the 'send email' action can not be triggered by (un)subscription because this trigger is defined to only trigger 'simplenews' actions. Either the trigger definition must be altered or the action definition must be extended (if possible). Next step would be to get the (un)subscription and newsletter status/tid/name into the email.
Code style errors: spaces after/before opening/closing parenthesis and escaped quotes in t-string.
The body of the email should at least be themable or better editable by the action admin as the drupal core action 'send email' does.
I would discourage the option to send the email to multiple recipients. This notification email is usefull if you have a small or medium size list. A large list has zillions of (un)subscriptions; individual notifications would drive me mad. This notification is i.m.o. only an intermediate solution to a better subscription management system with proper listings of (un)subscribers on date, name, address, source, etc.
Comment #20
callison commented@sutharsan: Isn't the only way to edit a trigger definition in system.module itself (i.e. add
'simplenews' => array('subscribe', 'unsubscribe'),to the trigger definition) or is there a way to extend that in simplenews_action.module? I'm kind of new to this, so I don't understand what you mean by extending the action definition in a way that will be triggered by a system trigger ('send e-mail'). If you get a chance, please expound on this a little more.In the meantime, I re-rolled the patch fixing the code style errors you mentioned. If I'm understanding you correctly, the body of the email already is editable by the action admin (including the all of the token variables I mentioned above - plus an additional %to_from token in this re-rolled patch). Thanks.
Comment #21
sutharsan commentedThe (un)subscribe trigger definition (simplenews_hook_info) defines what kind of actions can be triggered. Currently only 'simplenews' actions can be triggered. Perhaps this can be extended with 'user' actions.
The body of the email is currently only editable by using the localization. This is not sufficient. All drupal output must be themable. Also consider editable output as the 'send email' action uses.
Comment #22
George_Smith commentedI tried to apply this patch to the latest release (1.0-rc4), and I get this text after the "Hunk #5 succeeded" line:
patching file simplenews_action.module
patch unexpectedly ends in middle of line
Hunk #2 succeeded at 304 with fuzz 1.
Does that mean that the patch applied successfully, or not? Sorry, this is my first time applying a patch, and I would have trouble believing that "unexpectedly ends" means that it was a success.
Thanks for the help. I'd really like to get the Notify Admin feature working!
Comment #23
quinti commentedHow i can port these patches to drupal 5x, or, well
waht's more simple?, update dru 5x to 6, or port this patch to 5?
thank's
Comment #24
donquixote commentedWith the title changed, people will have a hard time finding the valuable discussions in this thread.
I therefore restore the old title.
Comment #25
CMatters commentedsubscribe
Comment #26
callison commentedI am posting a patch to system.module that will allow the send e-mail action to be used for Simplenews triggers. Following is a quick step-by-step guide to creating your actions and triggers for alerting admins on (un)subscriptions:
Naturally, this assumes you already have simplenews and simplenews_actions modules installed and working and that you have applied this patch to system.module
Hopefully this makes sense. This is good because it's so simple, but I think it could be better if you could choose the newsletter that you want to be notified of, include more variables specific to simplenews in the message, etc. I'll work on it some more - any ideas, comments, and suggestions are very welcome.
Comment #27
callison commentedI should have known better than to hack the system module. There's a hook for altering the action. So...I have now used that and applied it to simplenews_action.module. Much better! The above guidelines still work, just don't apply that patch, use THIS ONE.
This could still be better by adding tokens, etc. so I'm looking into it and will post more later.
Comment #28
Jackinloadup commentedsubscribe
Comment #29
edsko commentedsubscribe
Comment #30
Anonymous (not verified) commentedI actually achieved this using the Trigger Unlock module - http://drupal.org/project/triggerunlock
You can then set up an action (i.e. Send email...) and the Trigger Unlock module allows you to assign any Action to any Trigger. So on Home » Administer » Site building » Triggers, instead of "No available actions for this trigger." you will be able to assign any action to the 'Subscribe' or 'Unsubscribe' Trigger.
Comment #31
portulacaThank you for the tip, I also tried Triggerunlock and it works.
I used Tokenized email option, of all I tested only Global tokens work (FYI).
Comment #32
aschiwi commentedWell with triggerunlock you can assign any action to any trigger but there are only two actions - "A user has been subscribed" and "A user has been unsubscribed". Almost sufficient if you only have one newsletter. Also there are no tokens for the email address that signed up (anonymous user), so I don't know who subscribed or unsubscribed and I don't know what he or she subscribed to.
I would really prefer the patch, which by the way I could not get to work. What I tried was to patch simplenews.module with the patch in http://drupal.org/node/345579#comment-1164859. I patched both 6.x-1.x-dev and 6.x-1.0, both with pretty much the same result:
Was I supposed to do something else?
Comment #33
callison commented@aschiwi: The patch is offset by a bit (12 lines apparently). You can manually make the changes yourself - you'd have to go in and find the line number and then offset 12 lines and add the code, but I wouldn't recommend it because it is really a much better way to use the actions method. I'm working now on getting tokenization integrated into my previous patch to allow tokens for describing who subscribed or unsubscribed and what he or she subscribed to. Please bear with me (or give me advice on integrated tokens). I'll try to have a new patch in here soon.
Comment #34
sutharsan commentedCallison, Simplenews 2.x-dev and HEAD are integrated with Token. So feel free to use this code as example and tokenize the patch. I'll be happy to review and add it to Simplenews.
What happened to the #20 patch, is it replaced by #27? I'm confused.
Comment #35
callison commented@Sutharsan: I wasn't exactly sure what you meant in #21 so I kind of changed direction. I then thought why replicate existing functionality so I tried to use the existing 'Send Email' action and just incorporate that into Simplenews. So, that's what the patch in #27 does. Now I'm almost done adding some tokens.
Comment #36
callison commentedOK, here's an updated patch from #27.
This patch allows the send_email action to be used as a Simplenews trigger. On the send_email configuration page (after creating the advanced send_email action), there is now token replacement for the simplenews variables defined in simplenews_token_list. I have tested this some, but more testing would be appreciated.
Note: In order to include the newsletter's name as a token variable, I had to make a patch for simplenews.module also - make sure to apply both patches.
Comment #37
aschiwi commented@callison: Thank you for your quick work on those patches. Are they for Simplenews 2.x-dev?
Comment #38
callison commented@aschiwi: They're for HEAD - I'm not sure the version number.
Comment #39
krabbe commentedI tried the patches, but the simplenews_send_email-patch didn't work.
This is what terminal said:
The newsletter-action-patch seemed to work, but I can't test it because of the failure of the other patch.
Comment #40
donquixote commentedchanging back the title
(it seems the issue title field is easily mistaken for a comment title field - I did the same thing when my account was younger..)
Comment #41
callison commented@krabbe: Are you using the HEAD version of simplenews?
Comment #42
krabbe commented@callison: Yes, I do...
@donquixote: Sorry 4 that. Indeed I thought it's a comment-title.
Comment #43
callison commented@krabbe - I just patched a clean version of HEAD with no problems. Can anyone else confirm the problem that krabbe is having?
Comment #44
krabbe commentedOK, I started from the beginning again, got the HEAD-version, applied the patches without error and can see the simplenews-tokens now...
Don't know why, must have had the wrong HEAD version.
Thanks a lot.
Comment #45
krabbe commentedBut now the newsletter-variables don't expand in the confirmation-Mail to the subscriber.
This is what I got in the mail:
I'm not sure if I should use the patch from http://drupal.org/node/365507#comment-2021982 ??
Comment #46
krabbe commentedI changed to Simplenews 6.x-2.x-dev (2009-Dez-10) and I've got the newsletter-variables back working.
And I can create a new action "Send tokenized email" with simplenews-token like [simplenews-receiver-mail].
But when I go to built > trigger > simplenews they do not show up.
Should I open a new issue for that?
Comment #47
sutharsan commentedIf tokens in 2.x are not expanded, you should create a new issue. But make sure you can reproduce this error on a unpatched 2.x version.
Comment #48
sutharsan commentedI don't like the way the newsletter name is fed into the $subscription object in the simplenews.module patch. I'd rather see this moved to simplenews_action_mail_alter() or a fundamental approach by adding the newsletter name to the $subscription object which is returned by simplenews_get_subscription().
Patches do apply to HEAD without errors.
Comment #49
krabbe commented@Sutharsan - I created a new issue here, but you found it allready. The version I use is still unpatched...
Comment #50
krabbe commentedI patched the 2.x-dev and the simplenews-actions work only for user, not for guests.
And the simplenews-tokens show up in the action "Send tokenized email", but the action to choose on triggers > simplenews is only the "Send email".
Comment #51
callison commented@sutharsan - I agree completely but I couldn't find a way to do it. Since I used the send email action, the simplenews info is not passed in via context or anything else. I looked at every variable I was being passed and couldn't find a way at all to get the name. Please let me know (in a little more detail if possible) how I could go about getting the name in the send email context. Thanks.
In the meantime, I'll work on getting the fundamental approach working via simplenews_get_subscription().
Comment #52
linksync commentedsubscribing
Comment #53
mkmk commentedI am very interested in seeing this feature becoming part of simplenews.
Comment #54
eloiguell commentedI have customized simplenews.module to blocking forever unsubscribed emails for legal reasons. New topic: http://drupal.org/node/695734
Comment #55
sutharsan commentedEloiguell, please stay on topic.
Comment #56
eloiguell commentedSorry Sutharsan. I had move it to a new topic.
Comment #57
eric_a commentedI just arrived here and will spend some more time with this issue.
For my own needs I'm going to try an unsubscribe approach different from the patch. It is a simple way, meeting points made in #48 by Satharsan (http://drupal.org/node/345579#comment-2362580) and it does not need any API change at all.
If the action would fetch the current subscription object (which is not being cached) by doing something like simplenews_get_subscription($object) it could compare the two subscription objects and figure out which newsletter is involved in the unsubscribe trigger.
Of course this does not help actions dealing with subscribing...
I'll report back.
EDIT: Hmm, the only reason this idea could work for unsubscribe and not for subscribe is because in the former case the initial subscription object is passed to actions and in the second case the updated subscription object. Inconsistency? Bug?
Comment #58
aschiwi commentedI have a working rules integration. I can't post a patch yet but am willing to give everyone the module who wants it. Feel free to contact me.
Comment #59
eric_a commented@callison and Sutharsan: what happened to the idea of passing $tid as extra context? It was there in the patch from #20 and then it was gone.
Passing this data in $context is a much better idea than stuffing it in the object which contains all subscriptions.
Passing the newsletter is essential for notifying about somebody subscribing/unsubscribing. Making existing actions from system (or any other module) available to the simplenews trigger is another isue. I think it would be good to focus some more in this issue. Perhaps split it up in two.
Comment #60
muschpusch commentedsubscribe
Comment #61
mkmk commentedsubscribe
I don't know if me saying "subscribe" will actually subscribe me to this thread... there's no indication of this anywhere.
Comment #62
j0nathan commentedsubscribing
Comment #63
marcvangend[off-topic] @mkmk: all those people saying 'subscribe' do so because any comment will make the issue appear on their personal tracker page. Yours is at http://drupal.org/user/359099/track. See? Now I'm subscribed too :-)
Comment #64
kruser commentedsubscribe:
The patch in #36 works, but the only token that doesn't render in the email is Email address of the newsletter receiver - [simplenews-receiver-mail]
Comment #65
modctek commented[simplenews-subscriptions-url] also does not render. I've not tested any of the other Simplenews-specific tokens yet aside from this one and the one mentioned above.
Comment #66
sfyn commentedsub
Comment #67
wwwoliondorcom commentedHi,
Is it now possible to get these notifications ?
Thanks a lot.
Comment #68
MakeOnlineShop commentedHello
Can i know why this function has not yet been added to Simplenews after years ?
I wonder if few people are interested by this ?
Cheers.
Comment #69
callison commentedComment #70
modctek commentedI imagine on a high-traffic site, this could flood an inbox without some form of digest mode.
Comment #71
simonp-1 commentedJust wondering where work is at on this and if it is going to be possible to make use of this functionality without having to patch modules in the near future?
As far as I understand from reading and trying out the current version of modules, integrating changes to Simplenews subscriber lists with any contact data held externally is extremely cumbersome. It seems like it currently works if the subscriber is logged in, but for an organization of any size (with maybe multiple newsletters) this scenario seems unlikely.
Please could anybody correct me if I've got this wrong, and thanks for any update on the status of this issue...
Comment #72
simon georges commented@simonp, there is no work directly into this, but :
- there currently is an issue about Rules Integration (#620498: Integration with Rules module)
- maybe it's possible to use Simplenews Actions to achieve that in the meantine
- since a few commits, a hook is fired when user subscribes / unsubscribes (#1069570: Define hooks on subscribe/unsubscribe user), so it should be possible to use it, at least in 6.x-2.x.
Comment #73
klim_ commentedsubscribe #64:
token [simplenews-receiver-mail] dont render in email, is it because there is confirmation mail to accept subscription?
Comment #74
simon georges commentedRegarding the missing token: #720444: Send tokenized e-mail - token fields not populated.
Comment #75
calbasiI'm changing version to the last d7 version...
Comment #76
berdirThis should easily be possible in 7.x using the provides rules integration module. Maybe someone can provide default rules for this or write a documentation page about how to do it?
Setting back to 6.x-2.x as that's where the technical limitations are, 7.x-1.x is just configuration thing.
Comment #77
reptilex commentedOk I figured it out. Will share it here so that the next guy doesn't need to do trial and error, at least not in D7.
For this to work you have to have:
After that for my case I added a new role for the people I wanted to be notified, but you can just choose the administrator role.
New Subscription from <?php echo $mail; ?> for simplenews category <?php echo $tid; ?>A new subscriber with the email <?php echo $mail; ?> for the simplenews category <?php echo $tid; ?> has been added for your site <?php echo $site; ?>. Be happy.Next time someone subscribes you will get an email. Now go and do the same for unsubscribe. Remember to use the event "A user has been unsubscribed" and use the proper wording in the email fields. This should do the trick.
Comment #78
B Leg commentedreptilex: What version of simplenews are you using? I don't have simplenews rules and the admin/config/workflow/rules path doesn't exist either. Are you running D7?
Comment #79
alexander.nachev commentedSolution in comment #77 by reptilex works perfect for D7. Thanks for it.
Comment #80
reptilex commentedYeah B Leg. I'm running D7. And you are welcome alexander.nache. ;)
Comment #81
berdir@reptilex: Would be great if you could add a How-To to the documentation so that others can find it more easily. Go to the project page, click on view documentation and then add a child page.
You could also provide a patch with a disabled default rule.
Comment #82
rmcom commentedsubscribe #64:
token [simplenews-receiver-mail] does not render in notification email
Comment #83
reptilex commented@Berdir good idea, I added the howto (at http://drupal.org/node/1835500) feel free to review it, right now I don't have the time to write the code, but I would be glad to test it and correct it if someone else does.
Comment #84
Marko B commentedWhy use "send mail for all users in a role" why not just send an simple email to someone and that is it?