Index: sites/all/modules/default_filter/default_filter.module
===================================================================
RCS file: /cvs/drupal/contributions/modules/default_filter/default_filter.module,v
retrieving revision 1.6
diff -u -r1.6 default_filter.module
--- sites/all/modules/default_filter/default_filter.module	24 Aug 2007 18:54:53 -0000	1.6
+++ sites/all/modules/default_filter/default_filter.module	26 Aug 2007 00:49:22 -0000
@@ -199,6 +199,10 @@
   */
 function default_filter_form_alter($form_id, &$form){
 	if($form['#id'] == 'node-form' && array_key_exists('body_filter', $form)){
+	  $form['default_filter_passed_form'] = array(
+	    '#type' => 'value',
+	    '#value' => 1,
+	  );
 		$type = $form['type']['#value'];
 		$format = default_filter_retrieve($type);
 
@@ -214,7 +218,7 @@
 			$format_key = 'format';
 		}
 
-		if(array_key_exists($format_key, $form['body_filter'])){
+		if(array_key_exists($format_key, $form['body_filter']) && $format && !isset($form['nid']['#value'])){
 			//Unset any pre-selected filter. If multiples are checked, Gecko
 			//browsers seem to take the last selected but IE takes the first selected.
 			foreach($form['body_filter'][$format_key] as $key => $val){
@@ -228,8 +232,8 @@
 			    }
 			}
 
-			if($format > 0 && isset($form['body_filter'][$format_key][$format])){
-				$form['body_filter'][$format_key][$format]['#value'] = $format;
+			if(isset($form['body_filter'][$format_key][$format])){
+				$form['body_filter'][$format_key][$format]['#default_value'] = $format;
 			}
 		}
 	}
@@ -245,8 +249,8 @@
 function default_filter_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL){
 	if($op == 'insert'){
 		$format = default_filter_retrieve($node->type);
-		if($format > 0){
-			$node->format = $format;
+		if($format && !isset($node->default_filter_passed_form)){
+      db_query('UPDATE {node_revisions} SET format = %d WHERE nid = %d', $format, $node->nid);
 		}
 	}
 }
@@ -274,14 +278,10 @@
 		}
 	}
 
-	$format = 0;	
-	//Only return a format if the user belongs to some role (so this may not work for the admin user).
-	if(sizeof($roles) > 0){
-		//Note the CONCAT function. This assures that we don't let users who 
-		//belong to some role access filters that belong to some other role.
-		//$format = db_result(db_query('SELECT format_id FROM {default_filters} WHERE CONCAT(format_id, ".", role_id) IN ("' . join('","', $eligible) . '") AND role_id IN ("' . join('","', $roles) . '") AND node_type = "%s" ORDER BY weight ASC LIMIT 1', $type));
-		$format = db_result(db_query('SELECT format_id FROM {default_filters} WHERE CONCAT(format_id, ".", role_id) IN ("' . join('","', $eligible) . '") AND node_type = "%s" ORDER BY weight ASC LIMIT 1', $type));
-	}
+	//Note the CONCAT function. This assures that we don't let users who 
+	//belong to some role access filters that belong to some other role.
+	//$format = db_result(db_query('SELECT format_id FROM {default_filters} WHERE CONCAT(format_id, ".", role_id) IN ("' . join('","', $eligible) . '") AND role_id IN ("' . join('","', $roles) . '") AND node_type = "%s" ORDER BY weight ASC LIMIT 1', $type));
+	$format = db_result(db_query('SELECT format_id FROM {default_filters} WHERE CONCAT(format_id, ".", role_id) IN ("' . join('","', $eligible) . '") AND node_type = "%s" ORDER BY weight ASC LIMIT 1', $type));
 	return $format;
 }
 
