? sites/test.angrylittletree.com
Index: includes/form.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/form.inc,v
retrieving revision 1.148
diff -u -F^f -r1.148 form.inc
--- includes/form.inc	31 Aug 2006 14:59:28 -0000	1.148
+++ includes/form.inc	31 Aug 2006 15:29:13 -0000
@@ -113,7 +113,6 @@ function drupal_get_form($form_id) {
   return drupal_render_form($args[0], $form);
 }
 
-
 /**
  * Retrieves a form using a form_id, populates it with $form_values,
  * processes it, and returns any validation errors encountered. This
@@ -200,16 +199,15 @@ function drupal_retrieve_form($form_id) 
  *   The path to redirect the user to upon completion.
  */
 function drupal_process_form($form_id, &$form) {
-  global $form_values, $form_submitted, $user, $form_button_counter;
+  global $form_values, $submit_callback, $user;
   static $saved_globals = array();
   // In some scenerios, this function can be called recursively. Pushing any pre-existing
   // $form_values and form submission data lets us start fresh without clobbering work done
   // in earlier recursive calls.
-  array_push($saved_globals, array($form_values, $form_submitted, $form_button_counter));
+  array_push($saved_globals, array($form_values, $submit_callback));
 
   $form_values = array();
-  $form_submitted = FALSE;
-  $form_button_counter = array(0, 0);
+  $submit_callback = array();
 
   drupal_prepare_form($form_id, $form);
   if (($form['#programmed']) || (!empty($_POST) && (($_POST['form_id'] == $form_id) || ($_POST['form_id'] == $form['#base'])))) {
@@ -217,8 +215,8 @@ function drupal_process_form($form_id, &
     // IE does not send a button value when there is only one submit button (and no non-submit buttons)
     // and you submit by pressing enter.
     // In that case we accept a submission without button values.
-    if ((($form['#programmed']) || $form_submitted || (!$form_button_counter[0] && $form_button_counter[1])) && !form_get_errors()) {
-      $redirect = drupal_submit_form($form_id, $form);
+    if ((($form['#programmed']) || $submit_callback) && !form_get_errors()) {
+      $redirect = drupal_submit_form($form_id, $form, $submit_callback);
       if (!$form['#programmed']) {
         drupal_redirect_form($form, $redirect);
       }
@@ -227,7 +225,7 @@ function drupal_process_form($form_id, &
 
   // We've finished calling functions that alter the global values, so we can
   // restore the ones that were there before this function was called.
-  list($form_values, $form_submitted, $form_button_counter) = array_pop($saved_globals);
+  list($form_values, $submit_callback) = array_pop($saved_globals);
   return $redirect;
 }
 
@@ -306,17 +304,6 @@ function drupal_prepare_form($form_id, &
     }
   }
 
-  if (!isset($form['#submit'])) {
-    if (function_exists($form_id .'_submit')) {
-      // we set submit here so that it can be altered but use reference for
-      // $form_values because it will change later
-      $form['#submit'] = array($form_id .'_submit' => array());
-    }
-    elseif (function_exists($base .'_submit')) {
-      $form['#submit'] = array($base .'_submit' => array());
-    }
-  }
-
   foreach (module_implements('form_alter') as $module) {
     $function = $module .'_form_alter';
     $function($form_id, $form);
@@ -367,24 +354,37 @@ function drupal_validate_form($form_id, 
  *   theming, and hook_form_alter functions.
  * @param $form
  *   An associative array containing the structure of the form.
+ * @param $submit_callback
+ *   An array of callback functions. The name can contain %base which will be
+ *   changed to $form_id / #base accordingly.
  * @return
  *   A string containing the path of the page to display when processing
  *   is complete.
  *
  */
-function drupal_submit_form($form_id, $form) {
+function drupal_submit_form($form_id, $form, $submit_callback) {
   global $form_values;
   $default_args = array($form_id, &$form_values);
 
-  if (isset($form['#submit'])) {
-    foreach ($form['#submit'] as $function => $args) {
-      if (function_exists($function)) {
-        $args = array_merge($default_args, (array) $args);
-        // Since we can only redirect to one page, only the last redirect will work
-        $redirect = call_user_func_array($function, $args);
-        if (isset($redirect)) {
-          $goto = $redirect;
-        }
+  // Loop through the callbacks for a given submit operation, and execute
+  // each one if it exists. If we encounter a %base, we replace that with
+  // $form_id / #base
+  foreach ($submit_callback as $function => $args) {
+    if (strpos($function, '%base') !== FALSE) {
+      if (function_exists(str_replace('%base', $form_id, $function))) {
+        $function = str_replace('%base', $form_id, $function);
+      }
+      elseif (function_exists(str_replace('%base', $form['#base'], $function))) {
+        $function = str_replace('%base', $form['#base'], $function);
+      }
+    }
+
+    if (function_exists($function)) {
+      $args = array_merge($default_args, (array) $args);
+      // Since we can only redirect to one page, only the last redirect will work
+      $redirect = call_user_func_array($function, $args);
+      if (isset($redirect)) {
+        $goto = $redirect;
       }
     }
   }
@@ -581,7 +581,7 @@ function form_error(&$element, $message 
  *   An associative array containing the structure of the form.
  */
 function form_builder($form_id, $form) {
-  global $form_values, $form_submitted, $form_button_counter;
+  global $form_values, $submit_callback;
 
   // Initialize as unprocessed.
   $form['#processed'] = FALSE;
@@ -670,13 +670,13 @@ function form_builder($form_id, $form) {
         }
       }
     }
-    if (isset($form['#executes_submit_callback'])) {
-      // Count submit and non-submit buttons
-      $form_button_counter[$form['#executes_submit_callback']]++;
-      // See if a submit button was pressed
+    if (isset($form['#button_type'])) {
+      // This is an element capable of initiating a form submit. See if it was clicked.
       if (isset($form['#post'][$form['#name']]) && $form['#post'][$form['#name']] == $form['#value']) {
         $form_submitted = $form_submitted || $form['#executes_submit_callback'];
-
+        if (isset($form['#callback'])) {
+          $submit_callback = $form['#callback'];
+        }
         // In most cases, we want to use form_set_value() to manipulate the global variables.
         // In this special case, we want to make sure that the value of this element is listed
         // in $form_variables under 'op'.
@@ -698,8 +698,10 @@ function form_builder($form_id, $form) {
 
   // Set the $form_values key that gets passed to validate and submit.
   // We call this after #process gets called so that #process has a
-  // chance to update #value if desired.
-  if (isset($form['#input']) && $form['#input']) {
+  // chance to update #value if desired. Button type input fields should
+  // only show up if they're used to submit the form, so we will ignore
+  // them here.
+  if (isset($form['#input']) && $form['#input'] && !isset($form['#button_type'])) {
     form_set_value($form, $form['#value']);
   }
 
Index: modules/book/book.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/book/book.module,v
retrieving revision 1.387
diff -u -F^f -r1.387 book.module
--- modules/book/book.module	29 Aug 2006 18:43:25 -0000	1.387
+++ modules/book/book.module	31 Aug 2006 15:29:13 -0000
@@ -187,12 +187,6 @@ function book_load($node) {
   return db_fetch_object(db_query('SELECT * FROM {book} WHERE vid = %d', $node->vid));
 }
 
-function book_form_alter($form_id, &$form) {
-  if ($form_id == 'node_delete_confirm') {
-    $form['#submit']['book_node_delete_confirm_submit'] = array();
-  }
-}
-
 function book_node_submit($form_id, $node) {
   $node = (object)$node;
   if ($node->is_new || $node->revision) {
Index: modules/comment/comment.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/comment/comment.module,v
retrieving revision 1.482
diff -u -F^f -r1.482 comment.module
--- modules/comment/comment.module	31 Aug 2006 08:55:45 -0000	1.482
+++ modules/comment/comment.module	31 Aug 2006 15:29:13 -0000
@@ -280,7 +280,7 @@ function comment_form_alter($form_id, &$
   }
   elseif (isset($form['type'])) {
     if ($form['type']['#value'] .'_node_form' == $form_id) {
-      $form['#submit']['comment_node_submit'] = array();
+      $form['actions']['submit']['#callback']['comment_node_delete_confirm_submit'] = array();
       $node = $form['#node'];
       $form['comment_settings'] = array(
         '#type' => 'fieldset',
Index: modules/forum/forum.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/forum/forum.module,v
retrieving revision 1.356
diff -u -F^f -r1.356 forum.module
--- modules/forum/forum.module	29 Aug 2006 18:43:25 -0000	1.356
+++ modules/forum/forum.module	31 Aug 2006 15:29:13 -0000
@@ -233,10 +233,6 @@ function forum_form_alter($form_id, &$fo
       unset($form['nodes']['forum']);
     }
   }
-
-  if ($form_id == 'node_delete_confirm'  && $form['node']['#value']->type == 'forum') {
-    $form['#submit']['forum_node_delete_confirm_submit'] = array();
-  }
 }
 
 /**
Index: modules/menu/menu.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/menu/menu.module,v
retrieving revision 1.85
diff -u -F^f -r1.85 menu.module
--- modules/menu/menu.module	30 Aug 2006 15:17:49 -0000	1.85
+++ modules/menu/menu.module	31 Aug 2006 15:29:13 -0000
@@ -189,7 +189,7 @@ function menu_form_alter($form_id, &$for
       }
     }
 
-    $form['#submit']['menu_node_submit'] = array();
+    $form['submit']['#callback']['menu_node_submit'] = array();
 
     $form['menu'] = array('#type' => 'fieldset',
       '#title' => t('Menu settings'),
@@ -253,7 +253,7 @@ function menu_form_alter($form_id, &$for
   }
 
   if ($form_id == 'node_delete_confirm') {
-    $form['#submit']['menu_node_delete_confirm_submit'] = array();
+    $form['actions']['submit']['#callback']['menu_node_delete_confirm_submit'] = array();
   }
 }
 
Index: modules/node/node.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/node.module,v
retrieving revision 1.692
diff -u -F^f -r1.692 node.module
--- modules/node/node.module	31 Aug 2006 14:59:28 -0000	1.692
+++ modules/node/node.module	31 Aug 2006 15:29:13 -0000
@@ -1855,7 +1855,17 @@ function node_form($node, $form_values =
 
   // Add the buttons.
   $form['preview'] = array('#type' => 'button', '#value' => t('Preview'), '#weight' => 40);
-  $form['submit'] = array('#type' => 'submit', '#value' => t('Submit'), '#weight' => 45);
+  $form['submit'] = array(
+    '#type' => 'submit',
+    '#value' => t('Submit'),
+    '#weight' => 45,
+    '#callback' => array(
+      $node->type .'_node_submit_early' => array(),
+      'node_form_submit' => array(),
+      $node->type .'_node_submit' => array(),
+    ),
+  );
+
   if ($node->nid && node_access('delete', $node)) {
     $form['delete'] = array('#type' => 'button', '#value' => t('Delete'), '#weight' => 50);
   }
@@ -1864,11 +1874,6 @@ function node_form($node, $form_values =
     'node_form_validate' => array(),
     $node->type .'_node_validate' => array(),
   );
-  $form['#submit'] = array(
-    $node->type .'_node_submit_early' => array(),
-    'node_form_submit' => array(),
-    $node->type .'_node_submit' => array(),
-  );
   $form['#base'] = 'node_form';
   return $form;
 }
@@ -1877,7 +1882,7 @@ function node_form_add_preview($form) {
   global $form_values;
 
   $op = isset($form_values['op']) ? $form_values['op'] : '';
-  if ($op == $form_values['preview']) {
+  if ($op == t('Preview')) {
     drupal_validate_form($form['form_id']['#value'], $form);
     if (!form_get_errors()) {
       // We pass the global $form_values here to preserve changes made during form validation
@@ -2074,12 +2079,12 @@ function node_form_submit($form_id, &$no
 function node_delete_confirm($node) {
   if (node_access('delete', $node)) {
     $form['node'] = array('#type' => 'value', '#value' => $node);
-    $output = confirm_form($form,
+    $form = confirm_form($form,
                    t('Are you sure you want to delete %title?', array('%title' => $node->title)),
                    $_GET['destination'] ? $_GET['destination'] : 'node/'. $node->nid, t('This action cannot be undone.'),
                    t('Delete'), t('Cancel')  );
+    $form['actions']['submit']['#callback'][$node->type .'_node_delete_confirm_submit'] = array();
   }
-
   return $output;
 }
 
Index: modules/path/path.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/path/path.module,v
retrieving revision 1.92
diff -u -F^f -r1.92 path.module
--- modules/path/path.module	29 Aug 2006 18:43:25 -0000	1.92
+++ modules/path/path.module	31 Aug 2006 15:29:13 -0000
@@ -259,7 +259,7 @@ function path_form_alter($form_id, &$for
 
     if (user_access('create url aliases')) {
       $form['#validate']['path_node_validate'] = array();
-      $form['#submit']['path_node_submit'] = array();
+      $form['submit']['#callback']['path_node_submit'] = array();
     }
 
     $path = $form['#node']->path;
@@ -288,7 +288,7 @@ function path_form_alter($form_id, &$for
   }
 
   if ($form_id == 'node_delete_confirm') {
-    $form['#submit']['path_node_delete_confirm_submit'] = array();
+    $form['actions']['submit']['#callback']['path_node_delete_confirm_submit'] = array();
   }
 }
 
Index: modules/poll/poll.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/poll/poll.module,v
retrieving revision 1.214
diff -u -F^f -r1.214 poll.module
--- modules/poll/poll.module	30 Aug 2006 18:50:35 -0000	1.214
+++ modules/poll/poll.module	31 Aug 2006 15:29:13 -0000
@@ -114,12 +114,6 @@ function poll_node_validate($form_id, $n
   }
 }
 
-function poll_form_alter($form_id, &$form) {
-  if ($form_id == 'node_delete_confirm' && $form['node']['#value']->type == 'poll') {
-    $form['#submit']['poll_node_delete_confirm_submit'] = array();
-  }
-}
-
 /**
  * Implementation of hook_form().
  */
Index: modules/statistics/statistics.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/statistics/statistics.module,v
retrieving revision 1.239
diff -u -F^f -r1.239 statistics.module
--- modules/statistics/statistics.module	29 Aug 2006 18:43:25 -0000	1.239
+++ modules/statistics/statistics.module	31 Aug 2006 15:29:13 -0000
@@ -539,7 +539,7 @@ function statistics_node_delete_confirm_
 
 function statistics_form_alter($form_id, &$form) {
   if ($form_id == 'node_delete_confirm') {
-    $form['#submit']['statistics_node_delete_confirm_submit'] = array();
+    $form['actions']['submit']['#callback']['statistics_node_delete_confirm_submit'] = array();
   }
 }
 
Index: modules/system/system.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.module,v
retrieving revision 1.355
diff -u -F^f -r1.355 system.module
--- modules/system/system.module	29 Aug 2006 20:19:41 -0000	1.355
+++ modules/system/system.module	31 Aug 2006 15:29:14 -0000
@@ -64,8 +64,8 @@ function system_elements() {
 
   // Inputs
   $type['checkbox'] = array('#input' => TRUE, '#return_value' => 1);
-  $type['submit'] = array('#input' => TRUE, '#name' => 'op', '#button_type' => 'submit', '#executes_submit_callback' => TRUE);
-  $type['button'] = array('#input' => TRUE, '#name' => 'op', '#button_type' => 'submit', '#executes_submit_callback' => FALSE);
+  $type['submit'] = array('#input' => TRUE, '#name' => 'op', '#button_type' => 'submit', '#callback' => array('%base_submit' => array()));
+  $type['button'] = array('#input' => TRUE, '#name' => 'op', '#button_type' => 'submit');
   $type['textfield'] = array('#input' => TRUE, '#size' => 60, '#maxlength' => 128, '#autocomplete_path' => FALSE);
   $type['password'] = array('#input' => TRUE, '#size' => 30);
   $type['password_confirm'] = array('#input' => TRUE, '#process' => array('expand_password_confirm' => array()));
@@ -380,12 +380,13 @@ function system_admin_theme_settings() {
     '#default_value' => variable_get('admin_theme', 'bluemarine'),
   );
 
+  $form = system_settings_form($form);
   // In order to give it our own submit, we have to give it the default submit
-  // too because the presence of a #submit will prevent the default #submit
+  // too because the presence of a #callback will prevent the default submit
   // from being used. Also we want ours first.
-  $form['#submit']['system_admin_theme_submit'] = array();
-  $form['#submit']['system_settings_form_submit'] = array();
-  return system_settings_form($form);
+  $form['buttons']['submit']['#callback']['system_admin_theme_submit'] = array();
+  $form['buttons']['submit']['#callback']['system_settings_form_submit'] = array();
+  return $form;
 }
 
 
Index: modules/taxonomy/taxonomy.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.module,v
retrieving revision 1.310
diff -u -F^f -r1.310 taxonomy.module
--- modules/taxonomy/taxonomy.module	29 Aug 2006 18:43:26 -0000	1.310
+++ modules/taxonomy/taxonomy.module	31 Aug 2006 15:29:14 -0000
@@ -608,7 +608,7 @@ function taxonomy_form_alter($form_id, &
   if (isset($form['type']) && $form['type']['#value'] .'_node_form' == $form_id) {
     // inject custom validate and submit handlers
     $form['#validate']['taxonomy_node_validate'] = array();
-    $form['#submit']['taxonomy_node_submit'] = array();
+    $form['submit']['#callback']['taxonomy_node_submit'] = array();
 
     $node = $form['#node'];
 
@@ -678,7 +678,7 @@ function taxonomy_form_alter($form_id, &
   }
 
   if ($form_id == 'node_delete_confirm') {
-    $form['#submit']['taxonomy_node_delete_confirm_submit'] = array();
+    $form['actions']['submit']['#callback']['taxonomy_node_delete_confirm_submit'] = array();
   }
 }
 
Index: modules/upload/upload.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/upload/upload.module,v
retrieving revision 1.126
diff -u -F^f -r1.126 upload.module
--- modules/upload/upload.module	30 Aug 2006 18:56:31 -0000	1.126
+++ modules/upload/upload.module	31 Aug 2006 15:29:14 -0000
@@ -367,7 +367,7 @@ function upload_form_alter($form_id, &$f
     if ($form['type']['#value'] .'_node_form' == $form_id && variable_get("upload_$node->type", TRUE)) {
       if (user_access('upload files')) {
         $form['#validate']['upload_node_validate'] = array();
-        $form['#submit']['upload_node_submit'] = array();
+        $form['submit']['#callback']['upload_node_submit'] = array();
       }
 
       drupal_add_js('misc/progress.js');
@@ -397,7 +397,7 @@ function upload_form_alter($form_id, &$f
   }
 
   if ($form_id == 'node_delete_confirm') {
-    $form['#submit']['upload_node_delete_confirm_submit'] = array();
+    $form['actions']['submit']['#callback']['upload_node_delete_confirm_submit'] = array();
   }
 }
 
