The attached patch adds an action to Workflow NG which makes it possible to subscribe a user to a certain newsletter. You may want to use this functionality for example when your site features a mailinglist and you'd like to automatically subscribe every newly registered user to that mailinglist.

For the newsletter functionality this patch depends on the Simplenews module, but since I don't think everybody would like to use this functionality I decided not to add an extra dependency to Workflow NG. Instead, when the action is used and Simplenews isn't installed, a friendly message is shown to the user indicating that the action cannot be used until Simplenews has been installed.

This patch applies without errors on the 5.x-1.x-dev version as well as on the 5.x-1.0 version of Workflow NG. However, I've only tested it with the 5.x-1.0 version.

Comments

fago’s picture

Project: Workflow-ng » Simplenews

A great idea! However the way it is supposed to work, is that simplenews modules implements that action. For that it doesn't need a dependency on worklfow-ng, just implement hook_action_info with simplenews and add your action to it.
docs about this topic: http://drupal.org/node/156754

That would be great as one could auto-register people to newsletters e.g. by role :)

yngens’s picture

subscribe

rkj’s picture

Allright, thanks for your reply, fago. Maybe I'll post a patch for Simplenews later.

For those who would like to use this patch for workflow-ng anyway: I've discovered a small typo, so attached you'll find an updated version of the patch.

geek-merlin’s picture

subscribe

geek-merlin’s picture

hey there, i wrote a .inc file for the send action at #219544: Actions to do scheduled sending, you might use/extend this.

rkj’s picture

Title: Add subscribe newsletter action » Simplenews integration: adds "subscribe to newsletter" action
Project: Simplenews » Workflow-ng
Version: 5.x-1.x-dev » 5.x-2.0
Component: Code » Wng Module Integration
StatusFileSize
new1011 bytes

Since workflow-ng 5.x-2.0 has a new modules/ directory for workflow-ng integrations with the various modules, I figured this patch should be rewritten as .inc files that can be put in this modules/ directory. Is this correct, fago?

Anyway, attached you'll find a tarball containing two .inc files that make this functionality work in the new 5.x-2.0 version of workflow-ng.

Cheers,
Remco

fago’s picture

Project: Workflow-ng » Simplenews
Version: 5.x-2.0 » 5.x-1.x-dev
Component: Wng Module Integration » Code

no, that's only intended for core modules.

contribs should ship with their own integration, so please create a patch for simplenews instead.

rkj’s picture

Version: 5.x-1.x-dev » 5.x-1.2

Okay, no problem. Here it is.

But why then did you include token integration in workflow-ng's module directory? AFAIK, this isn't a core module...

Anyway, I hope the maintainer of simplenews will include my patch in the next release.

rkj’s picture

StatusFileSize
new2.4 KB

Okay, no problem. Here it is.

But why then did you include token integration in workflow-ng's module directory? AFAIK, this isn't a core module...

Anyway, I hope the maintainer of simplenews will include my patch in the next release.

fago’s picture

Status: Needs review » Needs work

great, to see you working on this. the token.inc is just for worklow-ng's additional token support (workflow-ng token API) and no usual module integration.

* your functions have partly the wrong namespace:
e.g. workflow_ng_action_subscribenewsletter should start with simplenews or better simplenews_workflow_ng or so.

* you shouldn't have the checks for the existance of simplenews - as the code is shipped with simplenews if it's added.

*+ foreach (taxonomy_get_tree($vid) as $n) {
use more readable variable names than $n.

scottrigby’s picture

Hi Fago (hi rkj) - I'll be happpy to test this out once I know what I should test. Thanks guys! -Scott

scottrigby’s picture

any news? :)

sutharsan’s picture

Status: Needs work » Needs review
StatusFileSize
new2.3 KB

I've combined the rkj's code and aexi's code (http://drupal.org/node/182218#comment-818537 and http://drupal.org/node/219544#comment-826871) into one simplenews submodule for workflow_ng integration.
I hardly tested the code but the basis of rkj and aexi looks good enough to give it a try (even for non coders amongst you).

sutharsan’s picture

Title: Simplenews integration: adds "subscribe to newsletter" action » Workflow_ng and actions integration

This title is more appropriate.
The patch only takes care of workflow_ng integrations. If there is interest for actions integration, pls let me know.

socialnicheguru’s picture

This is great thanks!

Chris

fago’s picture

I had a short look at the code without testing it. There are two forgotten var_dumps() in there, apart from that the code looks fine.

scottrigby’s picture

Hi guys, has anyone taken care of the forgotten var_dumps() fago mentioned - and if so can you post the updated code here?

By the way, could this (for example) allow workflow_ng to send email notifications when new users subscribe to the newsletter?

Cheers!
:) Scott

sutharsan’s picture

StatusFileSize
new2.57 KB

var_dump() removed. New zip file attached.
@scottrigby: no, in only includes actions to subscribe a user and to send a newsletter.

lonehorseend’s picture

Status: Needs review » Needs work

I just downloaded and tested this on a new installation of Drupal 5.16. The subscription part works great! The sending part not so well because it seems incomplete. I'm not give a choice of what email to send, so it attempts to send the user's bio (the node has been created and being tested byworkflow-ng) instead of an actual newsletter issue.

I guess it would be fine if I created a newsletter and wanted it sent, but I really want to send a particular newsletter based on the fact that a person just created a their bio. I'm using simplenews because it's the only way I've researched that seems to send attachments.

lonehorseend’s picture

Version: 5.x-1.2 » 5.x-1.5

Forgot to set the version that I'm using.

miro_dietiker’s picture

Status: Needs work » Closed (won't fix)

Closing all feature requests of 5.x.