--- civicrm_subscribe.module	Thu Dec 16 17:31:02 2010
+++ civicrm_subscribe.module	Thu Dec 16 16:46:30 2010
@@ -38,20 +38,27 @@
     $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.")
     );
   }
@@ -199,21 +206,18 @@
 
   // 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);
