--- subscriptions:subscriptions.module	2005-12-12 03:47:31.%N 1.32+++ subscriptions:subscriptions.module	2006-01-10 15:01:15.%N -0500@@ -1,5 +1,6 @@ <?php // $Id: subscriptions.module,v 1.32 2005/12/12 03:47:31 weitzman Exp $+// 4.7 Forms API Patch 2006/01/10 -q0rban   /**  * Implementation of hook_help().@@ -39,7 +40,15 @@   $mailevent .= "Alternativly, if you have the mailqueue module installed, you can send the messages ";   $mailevent .= "to that module for handling.";   if ( module_exist( 'mailqueue' ) ) {-    $output = form_radios( t( "Mailer Event" ), "subscriptions_event", variable_get( "subscriptions_event", "insert" ), array( "insert" => t( "On Comment Insert/Update" ), "queue" => t( "Send to mail queue" ) ) , t( $mailevent ) );+    $form_options = array( 'insert' => t( 'On Comment Insert/Update' ));+    $form['subscription_settings']['subscriptions_event'] = array(+      '#type'          => 'radios',+      '#title'         => t('Mailer event'),+      '#default_value' => variable_get( 'subscriptions_event', 'insert' ),+      '#options'       => $form_options,+      '#description'   => t( $mailevent )+    );+    $output = $form;   }   else {     $output = "Subscription notifications will be sent upon insert/update.  This should be ";@@ -57,8 +66,20 @@   switch ($type) {     case 'form':       if (user_access('maintain subscriptions') && $category == 'account') {-        return array(array('title' => t('Subscription settings'), 'data' => form_checkbox(t('Automatically subscribe to threads in which you post.'), 'subscriptions_auto', 1, isset($edit->subscriptions_auto) ? $edit->subscriptions_auto : $user->subscriptions_auto, t('Checking this box allows you to be automatically subscribe to any thread you create or post a comment to.'))));-      }+        $form['subscriptions'] = array(+          '#type'        => 'fieldset', +          '#title'       => t('Subscription settings'), +          '#weight'      => 5, +          '#collapsible' => TRUE+        );+        $form['subscriptions']['subscriptions_auto'] = array(+          '#type'          => 'checkbox',+          '#title'         => t('Autosubscribe'),+          '#default_value' => isset($edit['subscriptions_auto']) ? $edit['subscriptions_auto'] : $user->subscriptions_auto,+          '#description'   => t('Checking this box allows you to be automatically subscribe to any thread you create or post a comment to.')+        );+      return $form;+    }   } } @@ -71,8 +92,15 @@   foreach ($vocabularies as $vocabulary) {     $select[$vocabulary->vid] = $vocabulary->name;   }-  $output = form_select(t('Omitted vocabularies'), 'subscriptions_omitted_taxa', variable_get('subscriptions_omitted_taxa', array()), $select, t('Select vocabularies which should be <strong>omitted</strong> from subscription listings.'), '', 1);-  return $output;+  $form['sub_settings']['subscriptions_omitted_taxa'] = array(+    '#type'          => 'select',+    '#title'         => t('Omitted vocabularies'),+    '#default_value' => variable_get('subscriptions_omitted_taxa', array()),+    '#options'       => $select,+    '#description'   => t('Select vocabularies which should be <strong>omitted</strong> from subscription listings.'),+    '#multiple'      => TRUE+  );+  return $form; }  /**@@ -308,13 +336,32 @@         user_save($user, array('subscriptions_subscribe' => $node->subscriptions_subscribe));       }       break;-    case 'form post':-      if (!$user->subscriptions_auto) {-        $allsubs = subscriptions_get_user();-        $val = isset($node->subscriptions_subscribe) ? $node->subscriptions_subscribe : $allsubs['node'][$node->nid] ? 1 : $user->subscriptions_subscribe;-        return form_item(t('Subscribe'), form_checkbox(t('Receive notification of replies to this %name.', array('%name' => node_invoke($node, 'node_name'))), 'subscriptions_subscribe', 1, $val));-      }-      break;+  }+}++/**+ * Implementation of hook_form_alter().+ */+function subscriptions_form_alter($form_id, &$form) {+  $allsubs = subscriptions_get_user();+  $val = isset($node->subscriptions_subscribe) ? $node->subscriptions_subscribe : $allsubs['node'][$node->nid] ? 1 : $user->subscriptions_subscribe;+ +  if (isset($form['type']) && $form['type']['#value'] .'_node_form' == $form_id) {+    $node = $form['#node'];+    $form['subscriptions'] = array(+      '#type'        => 'fieldset',+      '#title'       => t('Subscriptions'),+      '#collapsible' => TRUE,+      '#weight'      => 0,+      '#tree'        => TRUE,+    );+    $form['subscriptions']['subscriptions_subscribe'] = array(+      '#type'          => 'checkbox', +      '#title'         => t('Receive notification of replies.'),+      '#return_value'  => 1,+      '#default_value' => $val, +      '#collapsible'   => FALSE+    );   } } @@ -464,7 +511,12 @@       // omit undesired vocabularies from listing       $vocabularies = taxonomy_get_vocabularies();       $omits = variable_get('subscriptions_omitted_taxa', array());-      foreach ($omits as $omit) {+      if (is_array ($omits)) {+        foreach ($omits as $omit) {+          unset($vocabularies[$omit]);+        } +      }+      else {         unset($vocabularies[$omit]);       }       foreach ($vocabularies as $vocab) {@@ -504,8 +556,13 @@       // omit undesired vocabularies from listing       $vocabularies = taxonomy_get_vocabularies();       $omits = variable_get('subscriptions_omitted_taxa', array());-      foreach ($omits as $omit) {-        unset($vocabularies[$omit]);+      if (is_array ($omits)) {+        foreach ($omits as $omit) {+          unset($vocabularies[$omit]);+        } +      }+      else {+        unset($vocabularies[$omits]);       }       foreach ($vocabularies as $vocab) {         $tree = taxonomy_get_tree($vocab->vid);