Index: vr_list/vr_list.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/vr/vr_list/vr_list.module,v
retrieving revision 1.1.2.15
diff -u -p -r1.1.2.15 vr_list.module
--- vr_list/vr_list.module	20 Jul 2010 14:29:36 -0000	1.1.2.15
+++ vr_list/vr_list.module	29 Oct 2010 20:35:21 -0000
@@ -653,4 +653,88 @@ function _vr_list_create_file($members) 
     $csv .= '"' . implode('","', $member) . "\"\n";
   }
   return $csv;
+}
+
+
+/**
+ * Provide actions.
+ */
+function vr_list_action_info() {
+  return array(
+    'vr_list_user_action_subscribe' => array(
+      'description' => t('Select recipient(s)'),
+      'type' => 'user',
+      'configurable' => TRUE,
+      ),
+    );
+}
+
+/**
+ * Configure subscribe/unsubscribe form.
+ */
+function vr_list_user_subscribe_form($context) {
+  $form['list_id'] = array(
+    '#title' => t('VerticalResponse Mailing List'),
+    '#type' => 'select',
+    '#options' => vr_get_lists(),
+    '#required' => TRUE,
+    );
+  $form['list_action'] = array(
+    '#title' => t('Subscription action'),
+    '#type' => 'select',
+    '#options' => array(
+      'addListMember' => t('Subscribe'),
+      'deleteListMember' => t('Unsubscribe'),
+      ),
+    );
+  return $form;
+}
+
+/**
+ * Submit function for actions
+ */
+function vr_list_user_subscribe_form_submit($form, &$form_state) {
+  return $form_state['values'];
+}
+
+/**
+ * List in database.
+ */
+function vr_list_user_subscribe(&$user, $context = array()) {
+  vr_list_member_init();
+  switch ($context['list_action']) {
+    case 'addListMember':
+      $param['list_member'] = array(
+        'list_id' => $context['list_id'],
+        'member_data' => array(
+          array(
+            'name' => 'email_address',
+            'value' => $user->mail,
+            ),
+          ),
+        ); 
+      $member = vr_api('addListMember', $param);
+      $vr_member = new vr_list_member($context['list'], $member);
+      $vr_member->map_fields();
+      break;
+    case 'deleteListMember':
+      $search['field_name'] = 'email_address';
+      $search['field_value'] = $account->mail;
+      $search['list_id'] = $context['list_id'];
+      $member = vr_api('searchListMembers', $search);
+      $vr_member = new vr_list_member($context['list'], $member);
+      $hash = $vr_member->member_array['hash'];
+      // Determine if this user is a list member.
+      $remove['list_member'] = array(
+        'list_id' => $context['list_id'],
+        'member_data' => array(
+          array(
+            'name' => 'hash',
+            'value' => $hash,
+            ),
+          ),
+        );
+      vr_api('deleteListMember', $remove);
+      break;
+  }
 }
\ No newline at end of file
