Index: modules/block.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/block.module,v
retrieving revision 1.184
diff -u -F^f -r1.184 block.module
--- modules/block.module	22 Oct 2005 15:14:46 -0000	1.184
+++ modules/block.module	28 Oct 2005 06:07:10 -0000
@@ -303,106 +303,62 @@ function block_box_get($bid) {
  * Menu callback; displays the block configuration form.
  */
 function block_admin_configure($module = NULL, $delta = 0) {
-  $edit = $_POST['edit'];
-  $op = $_POST['op'];
 
-  switch ($op) {
-    case t('Save block'):
-      db_query("UPDATE {blocks} SET visibility = %d, pages = '%s', custom = %d WHERE module = '%s' AND delta = '%s'", $edit['visibility'], $edit['pages'], $edit['custom'], $module, $delta);
-      module_invoke($module, 'block', 'save', $delta, $edit);
-      drupal_set_message(t('The block configuration has been saved.'));
-      cache_clear_all();
-      drupal_goto('admin/block');
-
-    default:
-      // Always evaluates to TRUE, but a validation step may be added later.
-      if (!$edit) {
-        $edit = db_fetch_array(db_query("SELECT pages, visibility, custom FROM {blocks} WHERE module = '%s' AND delta = '%s'", $module, $delta));
-      }
+  $form['module'] = array('#type' => 'value', '#value' => $module);
+  $form['delta'] = array('#type' => 'value', '#value' => $delta);
+  
+  $edit = db_fetch_array(db_query("SELECT pages, visibility, custom FROM {blocks} WHERE module = '%s' AND delta = '%s'", $module, $delta));
 
-      // Module-specific block configurations.
-      if ($settings = module_invoke($module, 'block', 'configure', $delta)) {
-          $form['block_settings'] = array('#type' => 'fieldset',
-            '#title' => t('Block specific settings'),
-            '#collapsible' => true,
-            '#collapsed' => false,
-            '#weight' => 0);
+  // Module-specific block configurations.
+  if ($settings = module_invoke($module, 'block', 'configure', $delta)) {
+      $form['block_settings'] = array('#type' => 'fieldset', '#title' => t('Block specific settings'), '#collapsible' => true, '#collapsed' => false, '#weight' => 0);
 
-          foreach ($settings as $k => $v) {
-            $form['block_settings'][$k] = $v;
-          }
+      foreach ($settings as $k => $v) {
+        $form['block_settings'][$k] = $v;
       }
+  }
 
-      // Get the block subject for the page title.
-      $info = module_invoke($module, 'block', 'list');
-      drupal_set_title(t("'%name' block", array('%name' => $info[$delta]['info'])));
-
-      // Standard block configurations.
-
-      $form['user_vis_settings'] = array('#type' => 'fieldset',
-        '#title' => t('User specific visibility settings'),
-        '#collapsible' => true,
-        '#collapsed' => false,
-        '#weight' => 0);
-
-      $form['user_vis_settings']['custom'] = array(
-        '#type' => 'radios',
-        '#title' => t('Custom visibility settings'),
-        '#default_value' => $edit['custom'],
-        '#options' => array(t('Users cannot control whether or not they see this block.'), t('Show this block by default, but let individual users hide it.'), t('Hide this block by default but let individual users show it.')), t('Allow individual users to customize the visibility of this block in their account settings.'),
-        '#default_value' => $edit['custom']);
-
-
-      $form['page_vis_settings'] = array('#type' => 'fieldset',
-        '#title' => t('Page specific visibility settings'),
-        '#collapsible' => true,
-        '#collapsed' => false,
-        '#weight' => 0);
-
-
-      $form['page_vis_settings']['visibility'] = array(
-        '#type' => 'radios',
-        '#title' => t('Show block on specific pages'),
-        '#default_value' => $edit['visibility'],
-        '#options' => array(t('Show on every page except the listed pages.'), t('Show on only the listed pages.'), t('Show if the following PHP code returns <code>TRUE</code> (PHP-mode, experts only).')),
-        '#default_value' => $edit['visibility']);
-
-      $form['page_vis_settings']['pages'] = array(
-        '#type' => 'textarea',
-        '#title' => t('Pages'),
-        '#default_value' => $edit['pages'],
-        '#cols' => 60,
-        '#rows' => 5,
-        '#description' => t("Enter one page per line as Drupal paths. The '*' character is a wildcard. Example paths are '%blog' for the blog page and %blog1 for every personal blog. %front is the front page. If the PHP-mode is chosen, enter PHP code between %php.  Note that executing incorrect PHP-code can break your Drupal site.", array('%blog' => theme('placeholder', 'blog'), '%blog1' =>  theme('placeholder', 'blog/*'), '%front' => theme('placeholder', '<front>'), '%php' => theme('placeholder', '<?php ?>'))));
+  // Get the block subject for the page title.
+  $info = module_invoke($module, 'block', 'list');
+  drupal_set_title(t("'%name' block", array('%name' => $info[$delta]['info'])));
 
-      $form['submit'] = array('#type' => 'submit', '#value' => t('Save block'));
+  // Standard block configurations.
 
-      return drupal_get_form('block_config', $form);
-  }
+  $form['user_vis_settings'] = array('#type' => 'fieldset', '#title' => t('User specific visibility settings'), '#collapsible' => true, '#collapsed' => false, '#weight' => 0);
+  $form['user_vis_settings']['custom'] = array('#type' => 'radios', '#title' => t('Custom visibility settings'), '#options' => array(t('Users cannot control whether or not they see this block.'), t('Show this block by default, but let individual users hide it.'), t('Hide this block by default but let individual users show it.'), t('Allow individual users to customize the visibility of this block in their account settings.')), '#default_value' => $edit['custom']);
+  $form['page_vis_settings'] = array('#type' => 'fieldset', '#title' => t('Page specific visibility settings'), '#collapsible' => true, '#collapsed' => false, '#weight' => 0);
+  $form['page_vis_settings']['visibility'] = array('#type' => 'radios', '#title' => t('Show block on specific pages'), '#options' => array(t('Show on every page except the listed pages.'), t('Show on only the listed pages.'), t('Show if the following PHP code returns <code>TRUE</code> (PHP-mode, experts only).')), '#default_value' => $edit['visibility']);
+  $form['page_vis_settings']['pages'] = array('#type' => 'textarea', '#title' => t('Pages'), '#default_value' => $edit['pages'], '#cols' => 60, '#rows' => 5, '#description' => t("Enter one page per line as Drupal paths. The '*' character is a wildcard. Example paths are '%blog' for the blog page and %blog1 for every personal blog. %front is the front page. If the PHP-mode is chosen, enter PHP code between %php.  Note that executing incorrect PHP-code can break your Drupal site.", array('%blog' => theme('placeholder', 'blog'), '%blog1' =>  theme('placeholder', 'blog/*'), '%front' => theme('placeholder', '<front>'), '%php' => theme('placeholder', '<?php ?>'))));
+  $form['submit'] = array('#type' => 'submit', '#value' => t('Save block'));
+
+  return drupal_get_form('block_admin_configure', $form);
+}
+
+function block_admin_configure_execute($form_id, $values) {
+  db_query("UPDATE {blocks} SET visibility = %d, pages = '%s', custom = %d WHERE module = '%s' AND delta = '%s'", $values['visibility'], $values['pages'], $values['custom'], $values['module'], $values['delta']);
+  module_invoke($values['module'], 'block', 'save', $values['delta'], $values);
+  drupal_set_message(t('The block configuration has been saved.'));
+  cache_clear_all();
+  drupal_goto('admin/block');
 }
 
 /**
  * Menu callback; displays the block creation form.
  */
 function block_box_add() {
-  $edit = $_POST['edit'];
-  $op = $_POST['op'];
-
-  switch ($op) {
-    case t('Save block'):
-      if (block_box_save($edit)) {
-        drupal_set_message(t('The block has been created.'));
-        drupal_goto('admin/block');
-      }
-      // deliberate no break
-    default:
-      $form = block_box_form($edit);
-      $form['submit'] = array('#type' => 'submit', '#value' => t('Save block'));
-  }
+  $form = block_box_form();
+  $form['submit'] = array('#type' => 'submit', '#value' => t('Save block'));
 
   return drupal_get_form('block_box_add', $form);
 }
 
+function block_box_add_execute($form_id, $values) {
+  if (block_box_save($values)) {
+    drupal_set_message(t('The block has been created.'));
+  }
+  drupal_goto('admin/block');
+}
+
 /**
  * Menu callback; confirm deletion of custom blocks.
  */
