Subscriber API: separate subscribers from newsletter management and allow other modules to define subscribers

joachim - July 31, 2009 - 14:20
Project:Simplenews
Version:6.x-1.x-dev
Component:Code
Category:task
Priority:normal
Assigned:Unassigned
Status:active
Description

Just been discussing this on IRC with sutharsan :)
I'm creating this issue so we've got somewhere to collect use cases and discuss how best to do this.

The main idea I think is to split the part of simplenews that collects and manages subscriptions into a separate module.
An API link between what remains of simplenews core and simplenews_subs would then be open to other modules in some way.

Potential interested parties:
- views: define subscribers from a view
- event registration (not a module yet, just vague plans: see http://groups.drupal.org/node/23834 )
- Ubercart - there's big potential for marketing campaigns based on who bought what

Of course, we could say that any module worth its salt should support views, and so provided that a view can be created of what the module wants, then all simplenews needs to do is support views :)

#1

simonsparks - September 29, 2009 - 09:25

Hello. What's the latest on this issue?
I'm looking for a way to add a "sign up to our newsletter" option to the ubercart checkout process.
This simplenews integration would be the ideal solution for me.

#2

acdtrp - October 13, 2009 - 06:47

I second that. Each new user who creates a new account via the checkout process in ubercart doesn't receive the default "opt-out" setting. It would be great if they had such pane in the checkout.

#3

Sutharsan - November 3, 2009 - 08:48

As a preparation for a subscription API I've scanned simplenews module for subscription related database access and extracted the required functionality.

simplenews_taxonomy() op:delete
// Delete all subscriptions of given tid (delete the whole subscription list).

simplenews_user() op:insert
// Check if a subscriber exist of given email addres.
// alternative: Get subscriber object of given email
// Update UID and Language of given subscriber ID

simplenews_user() op:'update':
// Does a subscriber exist of given UID?
// alternative: Get subscriber object of given uid (alternative: given email)
// Update mail and language of given subscriber ID

// Get subscriber ID with given email addres
// Update mail and language of given subscriber ID

// Activate/de-activate subscriber with given uid

simplenews_user() op:'delete'
// Get subscriber ID of given email addres
// Delete all subscriptions of given subscriber ID
// Delete subscriber of given subscriber ID
// Update UID of subscriber of given UID

simplenews_user() op:'view'
// Get the number of active subscriptions a given UID has)

simplenews_subscribe_user()
// Create subscriber of given email, UID, language, subscriber status. Return the subscriber object
// Create additional subscription of given subscriber ID to newsletter TID using timestamp and subscriptions source.
// Create first subscription of given subscriber ID to newsletter TID using timestamp and subscriptions source.

simplenews_unsubscribe_user()
// Unsubscribe given subscriber ID of netwsletter TID using timestamp and subscription source.

simplenews_user_is_subscribed()
// Check if given email is subscribed to given newsletter TID

simplenews_get_subscription()
// Get subscription object of subscriber with given subscriber ID, email or UID.

simplenews_delete_subscription()
// Get subscriber object using given subscriber ID
// Delete subscriber data of given subscriber ID
// Delete subscription data of given subscriber ID

simplenews_send_node()
// Get email address of all accounts active and subscribed to given newsletter TID.

simplenews_send_status_update()
// Get newsletter object of all newsletter with given sent status.
// Update sent status of given newsletter NID and VID

simplenews_confirm_subscription()
// Get subscriber ID and email of given subscriber ID
// alternative: get subscriber object of given subscriber ID.

simplenews_activate_subscription()
// Activate subscriber of given subscriber ID (multiple)

simplenews_inactivate_subscription()
// De-activate subscriber of given subscriber ID (multiple)

simplenews_count_subscriptions()
// Get number of subscribers who are subscribed to given newsletter TID

simplenews_build_subscription_filter_query()
// Filter query, perhaps too specific.

simplenews_admin_export_after_build()
// Get subscriber mail of given newsletter TID and variable where clause

simplenews_subscription_multiple_delete_confirm()
// Get subscriber mail of given subscriber ID

simplenews_admin_news()
// Get node object, sent status and newsletter TID of variable where clause.
// Count nodes of variable where clause.

simplenews_send_newsletter_action()
// Get newsletter sent status of given nid.
// Set newsletter sent status to 'pending' of given nid.

simplenews_unsubscribe_user_action()
// Check if subscription exists of given email.
// Unsubscribe given subscriber ID and newsletter TID using time stamp and unsubscription source.

This raw data should now be combined, abstracted and converted to API function definitions.

#4

joachim - November 21, 2009 - 12:19

Just to say -- I have a checkout of HEAD on my laptop and a copy of the above comment, just waiting for a long train journey when I've not got other work on!

 
 

Drupal is a registered trademark of Dries Buytaert.