Index: civicrm_subscribe.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/civicrm_subscribe/civicrm_subscribe.install,v
retrieving revision 1.1.4.3
diff -u -p -r1.1.4.3 civicrm_subscribe.install
--- civicrm_subscribe.install	24 Dec 2007 01:13:04 -0000	1.1.4.3
+++ civicrm_subscribe.install	13 Nov 2010 17:23:39 -0000
@@ -1,16 +1,45 @@
 <?php
-// $Id: civicrm_subscribe.install,v 1.1.4.3 2007/12/24 01:13:04 douggreen Exp $
+// $Id$
 
 function civicrm_subscribe_schema() {
   $schema = array();
   $schema['civicrm_subscribe'] = array(
+    'description' => t('CiviCRM contact id tracking'),
     'fields' => array(
-      'ccid' => array('type' => 'int', 'size' => 'normal', 'unsigned' => TRUE, 'not null' => TRUE),
-      'hash' => array('type' => 'varchar', 'length' => 8, 'default' => 'NULL'),
+      'ccid' => array(
+        'description' => t('CiviCRM contact id'),
+        'type' => 'int', 
+        'size' => 'normal', 
+        'unsigned' => TRUE, 
+        'not null' => TRUE
+      ),
+      'hash' => array(
+        'type' => 'varchar', 
+        'length' => 8, 
+        'default' => 'NULL'
+      ),
     ),
     'primary key' => array('ccid'),
     'indexes' => array('hash' => array('hash')),
   );
+  $schema['civicrm_subscribe_form'] = array(
+    'description' => t('Group to use in a CiviCRM subscribe block form'),
+    'fields' => array(
+      'group_id' => array(
+        'description' => t('CiviCRM group id'),
+        'type' => 'int',
+        'unsigned' => TRUE,
+        'not null' => TRUE,
+      ),
+      'email_only' => array(
+        'description' => t('Whether this is an email-only form'),
+        'type' => 'int',
+        'not null' => FALSE,
+        'default' => 0,
+      ),
+    ),
+  'primary key' => array('group_id'),
+  );
   return $schema;
 }
 
@@ -21,3 +50,58 @@ function civicrm_subscribe_install() {
 function civicrm_subscribe_uninstall() {
   drupal_uninstall_schema('civicrm_subscribe');
 }
+
+function civicrm_subscribe_update_6101() {
+  /* update function for earlier versions of CiviCRM Subscribe:
+     these versions may be missing required tables */
+  $schema = array();
+  $schema['civicrm_subscribe'] = array(
+    'description' => t('CiviCRM contact id tracking'),
+    'fields' => array(
+      'ccid' => array(
+        'description' => t('CiviCRM contact id'),
+        'type' => 'int', 
+        'size' => 'normal', 
+        'unsigned' => TRUE, 
+        'not null' => TRUE
+      ),
+      'hash' => array(
+        'type' => 'varchar', 
+        'length' => 8, 
+        'default' => 'NULL'
+      ),
+    ),
+    'primary key' => array('ccid'),
+    'indexes' => array('hash' => array('hash')),
+  );
+  $schema['civicrm_subscribe_form'] = array(
+    'description' => t('Group to use in a CiviCRM subscribe block form'),
+    'fields' => array(
+      'group_id' => array(
+        'description' => t('CiviCRM group id'),
+        'type' => 'int',
+        'unsigned' => TRUE,
+        'not null' => TRUE,
+      ),
+      'email_only' => array(
+        'description' => t('Whether this is an email-only form'),
+        'type' => 'int',
+        'not null' => FALSE,
+        'default' => 0,
+      ),
+    ),
+  'primary key' => array('group_id'),
+  );
+  
+  $ret = array();
+  
+  if (!db_table_exists('civicrm_subscribe')) {
+    db_create_table($ret, 'civicrm_subscribe', $schema['civicrm_subscribe']);
+  }
+  
+  if (!db_table_exists('civicrm_subscribe_form')) {
+    db_create_table($ret, 'civicrm_subscribe_form', $schema['civicrm_subscribe_form']);
+  }
+  
+  return $ret;
+}
Index: civicrm_subscribe.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/civicrm_subscribe/civicrm_subscribe.module,v
retrieving revision 1.2.2.5
diff -u -p -r1.2.2.5 civicrm_subscribe.module
--- civicrm_subscribe.module	25 Sep 2010 18:06:14 -0000	1.2.2.5
+++ civicrm_subscribe.module	13 Nov 2010 17:23:39 -0000
@@ -121,12 +121,18 @@ function civicrm_subscribe_admin_setting
   return system_settings_form($form);
 }
 
-function civicrm_subscribe_form() {
-  // look for a group_id in the path (user/subscribe/$group_id)
-  $groups = (arg(0) == 'user' && arg(1) == 'subscribe' && is_numeric($group_id = arg(2))) ? array($group_id) : array();
-
+function civicrm_subscribe_form(&$form_state, $group_id = -1, $email_only = TRUE) {
+  if(isset($group_id) && $group_id != -1) {
+    $groups = array($group_id);
+  }
+  else {
+    // look for a group_id in the path (user/subscribe/$group_id)
+    $groups = (arg(0) == 'user' && arg(1) == 'subscribe' && is_numeric($group_id = arg(2))) ? array($group_id) : array();
+  }
+  
   // make sure that the path is a valid group that allows subscriptions
   $groups = _civicrm_subscribe_get_groups($groups);
+  
   if (count($groups)) {
     $group_name = 'this group';
     if (module_exists('civicrm')) {
@@ -142,7 +148,7 @@ function civicrm_subscribe_form() {
       $group_name = implode(', ', $group_names);
     }
     $help = t('Enter your email address to subscribe to %group_name.', array('%group_name' => $group_name));
-
+    
     return array(
       '#action' => url('user/subscribe', array('query' => 'destination='. $_GET['q'])),
       '#submit' => array('civicrm_subscribe_form_submit'),
@@ -182,7 +188,7 @@ function civicrm_subscribe_form() {
 }
 
 function _civicrm_subscribe_invalid_group() {
-  return t('You can not signup for this group, contact your system administrator, edit the <a href="@url">settings</a> page, or try another group', array('@url' => url('admin/settings/civicrm_subscribe')));
+  return t('You cannot sign up for this group, contact your system administrator, edit the <a href="@url">settings</a> page, or try another group.', array('@url' => url('admin/settings/civicrm_subscribe')));
 }
 
 function _civicrm_subscribe_get_groups($groups = array()) {
@@ -218,7 +224,7 @@ function _civicrm_subscribe_get_groups($
 
 function civicrm_subscribe_form_submit($form, &$form_state) {
   civicrm_initialize();
-  // create civicrm paramaters to save
+  // create civicrm parameters to save
   /*$params = array(
     'first_name' => $form_state['values']['first_name'],
     'last_name' => $form_state['values']['last_name'],
@@ -230,7 +236,7 @@ function civicrm_subscribe_form_submit($
   //  longer on the original referring node, the groups are different if
   //  hook_civicrm_subscribe_groups altered the list.  So, get the original
   //  $_POST values.  This seems insecure, but FAPI validates that the form
-  //  being processed is the one that was submitted, so, is it inseucre?
+  //  being processed is the one that was submitted, so, is it insecure?
   if (isset($_POST['groups'])) {
     $groups = explode(',', $_POST['groups']);
   }
