--- civicrm_subscribe.module	Sun Nov 14 00:28:40 2010
+++ civicrm_subscribe.module	Mon Dec 20 13:55:55 2010
@@ -30,36 +30,43 @@
 }
 
 function civicrm_subscribe_admin_settings() {
   if (module_exists('civicrm')) {
     civicrm_initialize();
     require_once('api/v2/Group.php');
     require_once('api/v2/GroupContact.php');
     $options = array();
     $params = array();
     $return_properties = array('id', 'title');
     $groups =& civicrm_group_get($params);
-
+    $subscribed_groups = variable_get('civicrm_subscribe_groups', 0);
+    
     if (!$groups['is_error']) {
       foreach ($groups as $group) {
-        $options[$group["id"]] = $group["title"];
+        $append = '';
+        if( isset($subscribed_groups[$group["id"]]) && $subscribed_groups[$group["id"]] == $group["id"]) {
+          $path = 'user/subscribe/'.$group["id"];
+          $link = '<a href="'.url($path).'">'.$path.'</a>';
+          $append = " [".$link."]";
+        }
+        $options[$group["id"]] = $group["title"].$append;
       }
     }
     asort($options);
 
     $form['civicrm_subscribe_groups'] = array(
-      '#type' => 'select',
+      '#type' => 'checkboxes',
       '#title' => t('Subscription Groups'),
       '#options' => $options,
-      '#multiple' => 1,
-      '#default_value' => variable_get('civicrm_subscribe_groups', 0),
+      //'#multiple' => 1,
+      '#default_value' => $subscribed_groups,
       '#description' => t("Select the CiviCRM groups users can subscribe to.")
     );
   }
  /* $form['civicrm_subscribe_drupal_account'] = array(
     '#type' => 'select',
     '#title' => t('Account Handling'),
     '#options' => array(0 => t('CiviCRM Only'), 1 => t('Drupal and CiviCRM')),
     '#default_value' => variable_get('civicrm_subscribe_drupal_account', 0),
     '#description' => t('On confirmation, should a Drupal user account be created?'),
   );
   $form['subscribe_messages'] = array(
@@ -191,37 +198,35 @@
   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()) {
   // convert non-arrayed request arguments into an array for easier handling below
   if (!is_array($groups)) {
     $groups = array($groups);
   }
 
   // get the list of valid civicrm_subscribe groups (from the settings form)
   $valid_groups = variable_get('civicrm_subscribe_groups', array());
-  if (count($groups) > 0) {
-    // make sure that each specified group is valid, this prevents spoofing
-    // the submit form
-    foreach ($groups as $index => $group_id) {
-      if (is_numeric($group_id)) {
-        if (!in_array($group_id, $valid_groups)) {
-          unset($groups[$index]);
-        }
+  if (count($groups) <= 0) {
+    $groups = $valid_groups;
+  }
+  // make sure that each specified group is valid, this prevents spoofing
+  // the submit form
+  foreach ($groups as $index => $group_id) {
+    if (is_numeric($group_id)) {
+      if (!in_array($group_id, $valid_groups) || $group_id <= 0) {
+        unset($groups[$index]);
       }
     }
   }
-  else {
-    $groups = $valid_groups;
-  }
-
+  
   // let a custom module modify the default groups to subscribe to.  This allows
   // you to modify the subscription groups based on context
   $groups += module_invoke_all('civicrm_subscribe_groups', $groups);
 
   // if a group wasn't specific, then return all valid groups
   return $groups;
 }
 
 function civicrm_subscribe_form_submit($form, &$form_state) {
   civicrm_initialize();
   // create civicrm parameters to save
