Index: trackback.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/trackback/trackback.module,v
retrieving revision 1.56
diff -u -F^f -r1.56 trackback.module
--- trackback.module	29 Nov 2005 23:25:48 -0000	1.56
+++ trackback.module	14 Dec 2005 01:06:26 -0000
@@ -1,5 +1,5 @@
 <?php
-// $Id: trackback.module,v 1.56 2005-11-29 23:25:48 robinmonks Exp $
+// $Id: trackback.module,v 1.56 2005/11/29 23:25:48 robinmonks Exp $
 
 /**
  * Implementation of hook_help().
@@ -143,11 +143,85 @@ function trackback_received_delete() {
   }
 }
 
+function trackback_form_alter($form_id, &$form) {
+  if (isset($form['type']) && $form['type']['#value'] .'_node_settings' == $form_id) {
+    $type = $form['type']['#value'];
+    $default = ($type == 'story' || $type == 'blog' || $type == 'forum') ? 1 : 0;
+    $form['workflow']['trackback_'. $type] = array(
+      '#type' => 'radios',
+      '#title' => 'Trackbacks',
+      '#options' => array(1 => t('Enabled'), 0 => t('Disabled')),
+      '#return_value' => 1,
+      '#default_value' => variable_get('trackback_'. $type, $default),
+      '#description' => t('Enable trackbacks for this node type.')
+    );
+  }
+  else if (isset($form['type']) && $form['type']['#value'] .'_node_form' == $form_id) {
+    $node = $form['#node'];
+    if (_trackback_valid_for_node_type($node)) {
+      $form['trackback'] = array(
+        '#type' => 'fieldset',
+        '#title' => t('Trackbacks'),
+        '#collapsible' =>  TRUE,
+        //'#collapsed' => TRUE
+      );
+      $form['trackback']['can_receive'] = array(
+        '#type' => 'checkbox',
+        '#title' => t('Allow Trackbacks'),
+        '#return_value' => 1,
+        '#default_value' => (isset($node->can_receive) ? $node->can_receive : TRUE),
+        '#description' => t('Allow other posts to send trackbacks to this content.')
+      );
+      $form['trackback']['trackback_urls'] = array(
+        '#type' => 'textarea',
+        '#title' => t('Send Trackbacks'),
+        '#default_value' => $node->trackback_urls,
+        '#cols' => 80,
+        '#rows' => 4,
+        '#description' => t('Enter one URL per line for each trackback you wish to send.')
+      );
+
+      // if there are any past successful trackbacks from this posting, add them to the node editing page.
+      // if there are any past unsuccessful trackbacks from this posting, add checkmarks to enable resending them
+      $past_successes_listing = array();
+      $options = array();
+      $result = db_query('SELECT url, successful FROM {trackback_sent} WHERE nid = %d', $node->nid);
+      while ($url = db_fetch_object($result)) {
+        if ($url->successful) {
+          $past_successes_listing[] = $url->url;
+        }
+        else {
+          $options[$url->url] = $url->url;
+        }
+      }
+
+      // add listing of successfully trackbacked URLs
+      if (count($past_successes_listing)) {
+        $form['trackback'][] = array(
+          '#type' => 'markup',
+          '#value' => theme('item_list', $past_successes_listing, t('Successful URLs'))
+        );
+        //t('These URLs have been successfuly pinged by this post.')
+      }
+
+      // add listing of unsuccessfully trackbacked URLs
+      if (count($options)) {
+        $form['trackback']['trackback_urls_to_retry'] = array(
+          '#type' => 'checkboxes',
+          '#title' => t('Unsuccessful URLs'),
+          '#default_value' => array(),
+          '#options' => $options,
+          '#description' => t('Attempts to ping these URLs with this post have failed. Mark a check next to the trackback URLs you wish to retry for this post.')
+        );
+      }
+    }
+  }
+}
 
 function trackback_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) {
   global $trackback_node;
   
-  if ($op == 'settings' || $op == 'load' || _trackback_valid_for_node_type($node)) {
+  if ($op == 'load' || _trackback_valid_for_node_type($node)) {
     switch ($op) {
       case 'load':
         $result = db_query('SELECT * FROM {trackback_received} WHERE nid = %d AND status = 1 ORDER BY created DESC', $node->nid);
@@ -167,17 +241,6 @@ function trackback_nodeapi(&$node, $op, 
         }
         return $values_array;
 
-      case 'settings':
-        $default = ($node->type == 'story' || $node->type == 'blog' || $node->type == 'forum') ? 1 : 0;
-        $form['workflow']['trackback_'. $node->type] = array(
-            '#type' => 'checkbox',
-            '#title' => 'Enable trackbacks',
-            '#return_value' => 1,
-            '#default_value' => variable_get('trackback_'. $node->type, $default),
-            '#description' => t('Enable trackbacks for this node type.')
-            );
-        return $form;
-
       case 'view':
         if ($node->can_receive) {
           $url = url('node/'. $node->nid, NULL, NULL, TRUE);
@@ -207,67 +270,6 @@ function trackback_nodeapi(&$node, $op, 
         }
         break;
 
-      case 'form':
-        $form = array();
-        $form['trackback'] = array(
-            '#type' => 'fieldset',
-            '#title' => t('Trackbacks'),
-            '#collapsible' =>  TRUE,
-            //'#collapsed' => TRUE
-            );
-
-        $form['trackback']['can_receive'] = array(
-            '#type' => 'checkbox',
-            '#title' => t('Allow Trackbacks'),
-            '#return_value' => 1,
-            '#default_value' => (isset($node->can_receive) ? $node->can_receive : TRUE),
-            '#description' => t('Allow other posts to send trackbacks to this content.')
-            );
-        $form['trackback']['trackback_urls'] = array(
-            '#type' => 'textarea',
-            '#title' => t('Send Trackbacks'),
-            '#default_value' => $node->trackback_urls,
-            '#cols' => 80,
-            '#rows' => 4,
-            '#description' => t('Enter one URL per line for each trackback you wish to send.')
-            );
-
-        // if there are any past successful trackbacks from this posting, add them to the node editing page.
-        // if there are any past unsuccessful trackbacks from this posting, add checkmarks to enable resending them
-        $past_successes_listing = array();
-        $options = array();
-        $result = db_query('SELECT url, successful FROM {trackback_sent} WHERE nid = %d', $node->nid);
-        while ($url = db_fetch_object($result)) {
-          if ($url->successful) {
-            $past_successes_listing[] = $url->url;
-          }
-          else {
-            $options[$url->url] = $url->url;
-          }
-        }
-
-        // add listing of successfully trackbacked URLs
-        if (count($past_successes_listing)) {
-          $form['trackback'][] = array(
-              '#type' => 'markup',
-              '#value' => theme('item_list', $past_successes_listing, t('Successful URLs'))
-              );
-          //t('These URLs have been successfuly pinged by this post.')
-        }
-
-        // add listing of unsuccessfully trackbacked URLs
-        if (count($options)) {
-          $form['trackback']['trackback_urls_to_retry'] = array(
-              '#type' => 'checkboxes',
-              '#title' => t('Unsuccessful URLs'),
-              '#default_value' => array(),
-              '#options' => $options,
-              '#description' => t('Attempts to ping these URLs with this post have failed. Mark a check next to the trackback URLs you wish to retry for this post.')
-              );
-        }
-
-        return $form;
-
       case 'validate':
         $node->trackback_urls_array = explode("\n", $node->trackback_urls);
         foreach ($node->trackback_urls_array as $id => $url) {
