? feed.patch
Index: plugins/types/feed.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/mysite/plugins/types/feed.inc,v
retrieving revision 1.20
diff -u -p -r1.20 feed.inc
--- plugins/types/feed.inc	19 Aug 2007 20:02:57 -0000	1.20
+++ plugins/types/feed.inc	10 Sep 2007 16:45:31 -0000
@@ -403,72 +403,69 @@ function mysite_type_feed_form($owner) {
  * @ingroup forms
  */
 function mysite_type_feed_custom_form($owner) {
-    $feeds = variable_get('mysite_feed_categories', NULL);
-    $refresh = variable_get('mysite_feed_update', 3600);
-     $form['new_feed'] = array(
-      '#type' => 'fieldset',
-      '#title' => t('Add New Web Feed'),
-      '#weight' => 5,
-      '#collapsible' => TRUE,
-      '#collapsed' => FALSE,
-    );
-    $form['new_feed']['title'] = array('#type' => 'textfield',
-      '#title' => t('Feed title'),
-      '#default_value' => $edit['title'],
-      '#maxlength' => 64,
-      '#size' => 40, 
-      '#description' => t('The name of the feed; typically the name of the web site you syndicate content from.'),
-      '#required' => FALSE,
-      '#autocomplete_path' => 'autocomplete/mysite/feed'
-    );
-    $form['new_feed']['url'] = array('#type' => 'textfield',
-      '#title' => t('URL'),
-      '#default_value' => $edit['url'],
-      '#maxlength' => 255,
-      '#size' => 40,  
-      '#description' => t('The fully-qualified URL of the feed.'),
-      '#required' => FALSE,
-    );
-    $form['new_feed']['refresh'] = array(
-        '#type' => 'hidden', '#value' => $refresh
-    );
-    $form['new_feed']['uid'] = array(
-        '#type' => 'hidden', '#value' => $owner->uid
-    );
-    // categories
-    if ($_POST) {
-      $edit = $_POST['edit'];
+  $feeds = variable_get('mysite_feed_categories', NULL);
+  $refresh = variable_get('mysite_feed_update', 3600);
+  $form['new_feed'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Add New Web Feed'),
+    '#weight' => 5,
+    '#collapsible' => TRUE,
+    '#collapsed' => FALSE,
+  );
+  $form['new_feed']['title'] = array('#type' => 'textfield',
+    '#title' => t('Feed title'),
+    '#default_value' => $edit['title'],
+    '#maxlength' => 64,
+    '#size' => 40, 
+    '#description' => t('The name of the feed; typically the name of the web site you syndicate content from.'),
+    '#required' => FALSE,
+    '#autocomplete_path' => 'autocomplete/mysite/feed'
+  );
+  $form['new_feed']['url'] = array('#type' => 'textfield',
+    '#title' => t('URL'),
+    '#default_value' => $edit['url'],
+    '#maxlength' => 255,
+    '#size' => 40,  
+    '#description' => t('The fully-qualified URL of the feed.'),
+    '#required' => FALSE,
+  );
+  $form['new_feed']['refresh'] = array(
+      '#type' => 'hidden', '#value' => $refresh
+  );
+  $form['new_feed']['uid'] = array(
+      '#type' => 'hidden', '#value' => $owner->uid
+  );
+  // categories
+  if (empty($edit['category'])) {
+    $edit['category'] = variable_get('mysite_feed_default', array());
+  }
+  if (!empty($edit['category'])) {
+    $implode = "(". implode(", ", $feeds) .")";
+    $sql = "SELECT cid, title, description FROM {aggregator_category} WHERE cid IN %s";
+    $result = db_query($sql, $implode);
+    $options = array();
+    while ($category = db_fetch_object($result)) {
+      $options[$category->cid] = check_plain($category->title);
+    }
+    if (empty($options)) {
+     $form['new_feed']['no_feeds'] = array(
+       '#value' => t('<p>There are no categories configured.  Please go to <a href="@url">aggregator categories</a> to add one. <br /><b>User Feeds</b> is a good choice.</p>', array('@url' => url('admin/content/aggregator/add/category'))) ,
+      ); 
+    }
+    else if (count($options) > 1) {
+      $form['new_feed']['category'] = array(
+        '#type' => 'radios', '#title' => t('Feed Categories'), '#default_value' => $edit['category'],
+        '#options' =>  $options,
+        '#description' => t('Select a category for this feed')
+      );
     }
     else {
-      $edit['category'] = variable_get('mysite_feed_default', array());
+      $form['new_feed']['category'] = array(
+        '#type' => 'hidden', '#value' => $edit['category']
+      );
     }
-    if (!empty($edit['category'])) {
-      $implode = "(". implode(", ", $feeds) .")";
-      $sql = "SELECT cid, title, description FROM {aggregator_category} WHERE cid IN %s";
-      $result = db_query($sql, $implode);
-      $options = array();
-      while ($category = db_fetch_object($result)) {
-        $options[$category->cid] = check_plain($category->title);
-      }
-      if (empty($options)) {
-       $form['new_feed']['no_feeds'] = array(
-         '#value' => t('<p>There are no categories configured.  Please go to <a href="@url">aggregator categories</a> to add one. <br /><b>User Feeds</b> is a good choice.</p>', array('@url' => url('admin/content/aggregator/add/category'))) ,
-        ); 
-      }
-      else if (count($options) > 1) {
-        $form['new_feed']['category'] = array(
-          '#type' => 'radios', '#title' => t('Feed Categories'), '#default_value' => $edit['category'],
-          '#options' =>  $options,
-          '#description' => t('Select a category for this feed')
-        );
-      }
-      else {
-        $form['new_feed']['category'] = array(
-          '#type' => 'hidden', '#title' => t('Feed Categories'), '#default_value' => $edit['category']
-        );
-      }
-    }  
-    $form['new_feed']['submit'] = array('#type' => 'submit', '#value' => t('Submit New Feed'));
+  }  
+  $form['new_feed']['submit'] = array('#type' => 'submit', '#value' => t('Submit New Feed'));
   return $form;
 }
 
@@ -480,7 +477,7 @@ function mysite_type_feed_custom_form($o
  * @ingroup forms
  */
 function mysite_type_feed_custom_form_submit($form_id, $form_values) {
-  if ($_POST['op'] == t('Submit New Feed')) {
+  if ($form_values['op'] == t('Submit New Feed')) {
     // Check for duplicate titles and see what we need to save
     if (isset($form_values['fid'])) {
       $result = db_query("SELECT fid, title, url, description FROM {aggregator_feed} WHERE (title = '%s' OR url='%s') AND fid != %d", $form_values['title'], $form_values['url'], $form_values['fid']);
