Index: misc/tabledrag.js
===================================================================
RCS file: /cvs/drupal/drupal/misc/tabledrag.js,v
retrieving revision 1.32
diff -u -p -r1.32 tabledrag.js
--- misc/tabledrag.js	3 Nov 2009 05:34:37 -0000	1.32
+++ misc/tabledrag.js	7 Dec 2009 22:51:07 -0000
@@ -56,8 +56,8 @@ Drupal.tableDrag = function (table, tabl
   // this table. For efficiency, large sections of code can be skipped if we
   // don't need to track horizontal movement and indentations.
   this.indentEnabled = false;
-  for (group in tableSettings) {
-    for (n in tableSettings[group]) {
+  for (var group in tableSettings) {
+    for (var n in tableSettings[group]) {
       if (tableSettings[group][n].relationship == 'parent') {
         this.indentEnabled = true;
       }
@@ -147,7 +147,7 @@ Drupal.tableDrag.prototype.hideColumns =
  */
 Drupal.tableDrag.prototype.rowSettings = function (group, row) {
   var field = $('.' + group, row);
-  for (delta in this.tableSettings[group]) {
+  for (var delta in this.tableSettings[group]) {
     var targetClass = this.tableSettings[group][delta].target;
     if (field.is('.' + targetClass)) {
       // Return a copy of the row settings.
@@ -442,7 +442,7 @@ Drupal.tableDrag.prototype.dropRow = fun
       for (var group in self.tableSettings) {
         var rowSettings = self.rowSettings(group, droppedRow);
         if (rowSettings.relationship == 'group') {
-          for (n in self.rowObject.children) {
+          for (var n in self.rowObject.children) {
             self.updateField(self.rowObject.children[n], group);
           }
         }
@@ -535,7 +535,7 @@ Drupal.tableDrag.prototype.findDropTarge
     if ((y > (rowY - rowHeight)) && (y < (rowY + rowHeight))) {
       if (this.indentEnabled) {
         // Check that this row is not a child of the row being dragged.
-        for (n in this.rowObject.group) {
+        for (var n in this.rowObject.group) {
           if (this.rowObject.group[n] == row) {
             return null;
           }
@@ -761,12 +761,10 @@ Drupal.tableDrag.prototype.restripeTable
   // :even and :odd are reversed because jQuery counts from 0 and
   // we count from 1, so we're out of sync.
   // Match immediate children of the parent element to allow nesting.
-  $('> tbody > tr.draggable, > tr.draggable', this.table)
-    .filter(':odd').filter('.odd')
-      .removeClass('odd').addClass('even')
-    .end().end()
-    .filter(':even').filter('.even')
-      .removeClass('even').addClass('odd');
+  $('> tbody > tr.draggable:visible, > tr.draggable:visible', this.table)
+    .removeClass('odd even')
+    .filter(':odd').addClass('even').end()
+    .filter(':even').addClass('odd');
 };
 
 /**
@@ -1037,7 +1035,7 @@ Drupal.tableDrag.prototype.row.prototype
  * Remove indentation helper classes from the current row group.
  */
 Drupal.tableDrag.prototype.row.prototype.removeIndentClasses = function () {
-  for (n in this.children) {
+  for (var n in this.children) {
     $('.indentation', this.children[n])
       .removeClass('tree-child')
       .removeClass('tree-child-first')
Index: modules/filter/filter.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/filter/filter.admin.inc,v
retrieving revision 1.52
diff -u -p -r1.52 filter.admin.inc
--- modules/filter/filter.admin.inc	3 Dec 2009 15:33:42 -0000	1.52
+++ modules/filter/filter.admin.inc	7 Dec 2009 23:07:57 -0000
@@ -109,6 +109,9 @@ function filter_admin_format_form($form,
     $help = t('All roles for this text format must be enabled and cannot be changed.');
   }
 
+  $form['#format'] = $format;
+  $form['#tree'] = TRUE;
+
   $form['name'] = array(
     '#type' => 'textfield',
     '#title' => t('Name'),
@@ -117,42 +120,46 @@ function filter_admin_format_form($form,
     '#required' => TRUE,
   );
 
-  // Add a row of checkboxes for form group.
-  $form['roles'] = array('#type' => 'fieldset',
+  // Add user role access selection.
+  $form['roles'] = array(
+    '#type' => 'checkboxes',
     '#title' => t('Roles'),
     '#description' => $is_fallback ? $help : t('Choose which roles may use this text format. Note that roles with the "administer filters" permission can always use all text formats.'),
-    '#tree' => TRUE,
+    '#options' => user_roles(),
+    '#default_value' => array_keys(filter_get_roles_by_format($format)),
+    '#disabled' => $is_fallback,
   );
-  $checked = filter_get_roles_by_format($format);
-  foreach (user_roles() as $rid => $name) {
-    $form['roles'][$rid] = array('#type' => 'checkbox',
-      '#title' => $name,
-      '#default_value' => ($is_fallback || isset($checked[$rid])),
-    );
-    if ($is_fallback) {
-      $form['roles'][$rid]['#disabled'] = TRUE;
-    }
-  }
+
   // Table with filters
   $filter_info = filter_get_filters();
   // Load all configured filters for existing text formats.
   $filters = !empty($format->format) ? filter_list_format($format->format) : array();
 
-  $form['filters'] = array('#type' => 'fieldset',
+  $form['filters'] = array(
+    '#type' => 'fieldset',
     '#title' => t('Filters'),
     '#description' => t('Choose the filters that will be used in this text format.'),
-    '#tree' => TRUE,
   );
+
   foreach ($filter_info as $name => $filter) {
+    // Create an empty filter object for new/unconfigured filters.
+    if (!isset($filters[$name])) {
+      $filters[$name] = new stdClass;
+      $filters[$name]->status = 0;
+      $filters[$name]->weight = 0;
+      $filters[$name]->settings = array();
+    }
+    $form['filters'][$name]['#filter'] = $filters[$name];
     $form['filters'][$name]['status'] = array(
       '#type' => 'checkbox',
       '#title' => $filter['title'],
-      '#default_value' => !empty($filters[$name]->status),
+      '#default_value' => $filters[$name]->status,
       '#description' => $filter['description'],
     );
   }
+
   if (!empty($format->format)) {
-    $form['format'] = array('#type' => 'hidden', '#value' => $format->format);
+    $form['format'] = array('#type' => 'value', '#value' => $format->format);
 
     // Composition tips (guidelines)
     $tips = _filter_tips($format->format, FALSE);
@@ -178,6 +185,7 @@ function filter_admin_format_form($form,
 function filter_admin_format_form_validate($form, &$form_state) {
   if (!isset($form_state['values']['format'])) {
     $format_name = trim($form_state['values']['name']);
+    form_set_value($form['name'], $format_name, $form_state);
     $result = db_query("SELECT format FROM {filter_format} WHERE name = :name", array(':name' => $format_name))->fetchField();
     if ($result) {
       form_set_error('name', t('Text format names must be unique. A format named %name already exists.', array('%name' => $format_name)));
@@ -189,10 +197,17 @@ function filter_admin_format_form_valida
  * Process text format form submissions.
  */
 function filter_admin_format_form_submit($form, &$form_state) {
+  // Remove unnecessary values.
+  form_state_values_clean($form_state);
+
+  // Save text format.
   $format = (object) $form_state['values'];
-  $format->format = isset($form_state['values']['format']) ? $form_state['values']['format'] : NULL;
+  if (!isset($form_state['values']['format'])) {
+    $format->format = NULL;
+  }
   $status = filter_format_save($format);
 
+  // Save user permissions.
   if ($permission = filter_permission_name($format)) {
     foreach ($format->roles as $rid => $enabled) {
       user_role_change_permissions($rid, array($permission => $enabled));
@@ -262,10 +277,11 @@ function filter_admin_configure($form, &
   $form['#format'] = $format;
   foreach ($filters as $name => $filter) {
     if ($filter->status && isset($filter_info[$name]['settings callback']) && function_exists($filter_info[$name]['settings callback'])) {
+      $function = $filter['settings callback'];
       // Pass along stored filter settings and default settings, but also the
       // format object and all filters to allow for complex implementations.
       $defaults = (isset($filter_info[$name]['default settings']) ? $filter_info[$name]['default settings'] : array());
-      $settings_form = $filter_info[$name]['settings callback']($form, $form_state, $filters[$name], $defaults, $format, $filters);
+      $settings_form = $function($form, $form_state, $filters[$name], $format, $defaults, $filters);
       if (!empty($settings_form)) {
         $form['settings'][$name] = array(
           '#type' => 'fieldset',
Index: modules/filter/filter.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/filter/filter.module,v
retrieving revision 1.307
diff -u -p -r1.307 filter.module
--- modules/filter/filter.module	7 Dec 2009 03:46:36 -0000	1.307
+++ modules/filter/filter.module	7 Dec 2009 22:47:31 -0000
@@ -935,7 +935,7 @@ function filter_filter_info() {
 /**
  * Settings callback for the HTML filter.
  */
-function _filter_html_settings($form, &$form_state, $filter, $defaults) {
+function _filter_html_settings($form, &$form_state, $filter, $format, $defaults) {
   $settings['allowed_html'] = array(
     '#type' => 'textfield',
     '#title' => t('Allowed HTML tags'),
@@ -1081,7 +1081,7 @@ function _filter_html_tips($filter, $for
 /**
  * Settings callback for URL filter.
  */
-function _filter_url_settings($form, &$form_state, $filter, $defaults) {
+function _filter_url_settings($form, &$form_state, $filter, $format, $defaults) {
   $settings['filter_url_length'] = array(
     '#type' => 'textfield',
     '#title' => t('Maximum link text length'),
Index: modules/filter/filter.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/filter/filter.test,v
retrieving revision 1.51
diff -u -p -r1.51 filter.test
--- modules/filter/filter.test	3 Dec 2009 15:33:42 -0000	1.51
+++ modules/filter/filter.test	7 Dec 2009 22:48:01 -0000
@@ -265,7 +265,7 @@ class FilterAdminTestCase extends Drupal
     }
     $this->assertTrue(($filters[0]->name == $second_filter && $filters[1]->name == $first_filter), t('Order confirmed.'));
 
-    // Add filter.
+    // Add format.
     $edit = array();
     $edit['name'] = $this->randomName();
     $edit['roles[2]'] = 1;
