Index: simplenews.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/simplenews/simplenews.module,v
retrieving revision 1.109
diff -u -p -r1.109 simplenews.module
--- simplenews.module	21 Jun 2008 07:28:45 -0000	1.109
+++ simplenews.module	29 Jun 2008 14:09:46 -0000
@@ -810,6 +810,9 @@ function simplenews_subscribe_user($mail
   elseif (!isset($subscription->tids[$tid])) {
     // OR add user to newsletter relationship if not already subscribed.
     db_query("INSERT INTO {simplenews_snid_tid} (snid, tid) VALUES (%d, %d)", $subscription->snid, $tid);
+
+    // Execute simplenews subscribe trigger.
+    simplenews_call_actions('subscribe', $subscription);
   }
   return TRUE;
 }
@@ -856,7 +859,10 @@ function simplenews_unsubscribe_user($ma
     if (!db_result(db_query("SELECT COUNT(*) FROM {simplenews_snid_tid} t WHERE t.snid = %d", $subscription->snid))) {
       db_query('DELETE FROM {simplenews_subscriptions} WHERE snid = %d', $subscription->snid);
     }
-  }
+
+    // Execute simplenews unsubscribe trigger
+    simplenews_call_actions('unsubscribe', $subscription);
+    }
 
   return TRUE;
 }
@@ -1523,6 +1529,27 @@ function simplenews_clear_spool() {
 }
 
 /**
+ * Call simplenews actions
+ *
+ * @see simplenews_hook_info()
+ */
+function simplenews_call_actions($op, $subscription) {
+  // Only call actions when the simplenews_action module is enabled.
+  if (!module_exists('simplenews_action')) {
+    return;
+  }
+  $aids = _trigger_get_hook_aids('simplenews', $op);
+  $context = array(
+    'hook' => 'simplenews',
+    'op' => $op,
+    'account' => $subscription,
+  );
+  foreach ($aids as $aid => $action_info) {
+    actions_do($aid, $subscription, $context);
+  }
+}
+
+/**
  * Build formatted from-name and e-mail for a mail object.
  *
  * Each newsletter (serie; tid) can have a different from address.
Index: simplenews_action/simplenews_action.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/simplenews/simplenews_action/simplenews_action.module,v
retrieving revision 1.1
diff -u -p -r1.1 simplenews_action.module
--- simplenews_action/simplenews_action.module	4 May 2008 13:29:15 -0000	1.1
+++ simplenews_action/simplenews_action.module	29 Jun 2008 14:09:47 -0000
@@ -20,6 +20,7 @@ function simplenews_action_info() {
       'hooks' => array(
         'cron' => array('run'),
         'user' => array('insert'),
+        'simplenews' => array('subscribe'),
       ),
     ),
     'simplenews_cron_action' => array(
@@ -63,11 +64,11 @@ function simplenews_action_info() {
  *   @see simplenews_send_newsletter_action_submit
  */
 function simplenews_send_newsletter_action(&$object, $context = array()) {
-  if ($context['hook'] == 'cron' || $context['hook'] == 'user') {
+  if ($context['hook'] == 'cron' || $context['hook'] == 'user' || $context['hook'] == 'simplenews') {
 
     // Determine newsletter receipients
     $accounts = array();
-    if ($context['hook'] == 'user') {
+    if ($context['hook'] == 'user' || $context['hook'] == 'simplenews') {
       $accounts[] = $context['account'];
     }
 
@@ -293,3 +294,21 @@ function simplenews_unsubscribe_user_act
   );
   return $params;
 }
+
+/**
+ * Implementation of hook_hook_info().
+ */
+function simplenews_hook_info() {
+  return array(
+    'simplenews' => array(
+      'simplenews' => array(
+        'subscribe' => array(
+          'runs when' => t('After a user has been subscribed'),
+        ),
+        'unsubscribe' => array(
+          'runs when' => t('After a user has been unsubscribed'),
+        ),
+      ),
+    ),
+  );
+}
\ No newline at end of file
