Commit ac65ff90 authored by Dries's avatar Dries

- Patch #138706 by eaton, chx, webchick, yched et al: form api 3 ... yay. :)

parent ed768b53
......@@ -188,6 +188,7 @@ function _batch_process() {
}
}
// TODO : if the last set was a 'form_submit', there is no 'operations', 'total', 'progress message' in $current_set => warnings
if ($batch['progressive']) {
$remaining = count($current_set['operations']);
$total = $current_set['total'];
......@@ -222,28 +223,18 @@ function &_batch_current_set() {
/**
* Move execution to the next batch set if any, executing the stored
* form _submit callbacks along the way (possibly inserting additional batch sets)
* form _submit handlers along the way (thus possibly inserting
* additional batch sets)
*/
function _batch_next_set() {
$batch =& batch_get();
if (isset($batch['sets'][$batch['current_set']+1])) {
if (isset($batch['sets'][$batch['current_set'] + 1])) {
$batch['current_set']++;
$current_set =& _batch_current_set();
if (isset($current_set['form submit']) && (list($function, $args) = $current_set['form submit']) && function_exists($function)) {
// We have to keep our own copy of $form_values, to account
// for possible alteration by the submit callback.
if (isset($batch['form_values'])) {
$args[1] = $batch['form_values'];
}
$redirect = call_user_func_array($function, $args);
// Store the form_values only if needed, to limit the
// amount of data we store in the batch.
if (isset($batch['sets'][$batch['current_set']+1])) {
$batch['form_values'] = $args[1];
}
if (isset($redirect)) {
$batch['redirect'] = $redirect;
}
if (isset($current_set['form_submit']) && ($function = $current_set['form_submit']) && function_exists($function)) {
// We use our stored copies of $form and $form_state, to account for
// possible alteration by the submit handlers.
$function($batch['form_state']['values'], $batch['form'], $batch['form_state']);
}
return TRUE;
}
......@@ -274,15 +265,27 @@ function _batch_finished() {
if (isset($_batch['destination'])) {
$_REQUEST['destination'] = $_batch['destination'];
}
$redirect = isset($_batch['redirect']) ? $_batch['redirect'] : $_batch['source_page'];
$form_redirect = isset($_batch['form_redirect']) ? $_batch['form_redirect'] : NULL;
// Let drupal_redirect_form handle redirection logic, using a bare pseudo form
// to limit the amount of data we store in the batch.
drupal_redirect_form(array('#redirect' => $form_redirect), $redirect);
// If we get here, $form['redirect']['#redirect'] was FALSE, and we are most
// probably dealing with a multistep form - not supported at the moment.
// Redirect to the originating page - first step of the form.
// Use $_batch['form_state']['redirect'], or $_batch['redirect'], or $_batch['source_page'].
if (isset($_batch['form_state']['redirect'])) {
$redirect = $_batch['form_state']['redirect'];
}
elseif (isset($_batch['redirect'])) {
$redirect = $_batch['redirect'];
}
else {
$redirect = $_batch['source_page'];
}
// Let drupal_redirect_form handle redirection logic.
$form = isset($batch['form']) ? $batch['form'] : array();
if (empty($_batch['form_state']['rebuild']) && empty($_batch['form_state']['storage'])) {
drupal_redirect_form($form, $redirect);
}
// We get here if $form['#redirect'] was FALSE, or if
// Save the final $form_state value, Redirect to the originating page.
$_SESSION['batch_form_state'] = $_batch['form_state'];
drupal_goto($_batch['source_page']);
}
}
......
<?php
// $Id$
/**
* A stub cache implementation to be used during the installation
* process when database access is not yet available. Because Drupal's
* caching system never requires that cached data be present, these
* stub functions can short-circuit the process and sidestep the
* need for any persistent storage. Obviously, using this cache
* implementation during normal operations would have a negative impact
* on performance.
*/
function cache_get($key, $table = 'cache') {
return FALSE;
}
function cache_set($cid, $data, $table = 'cache', $expire = CACHE_PERMANENT, $headers = NULL) {
return;
}
function cache_clear_all($cid = NULL, $table = NULL, $wildcard = FALSE) {
return;
}
This diff is collapsed.
......@@ -69,7 +69,7 @@ function theme_locale_languages_overview_form($form) {
/**
* Process language overview form submissions, updating existing languages.
*/
function locale_languages_overview_form_submit($form_id, $form_values) {
function locale_languages_overview_form_submit($form_values, $form, &$form_state) {
$languages = language_list();
$enabled_count = 0;
foreach ($languages as $langcode => $language) {
......@@ -95,7 +95,8 @@ function locale_languages_overview_form_submit($form_id, $form_values) {
// Changing the language settings impacts the interface.
cache_clear_all('*', 'cache_page', TRUE);
return 'admin/settings/language';
$form_state['redirect'] = 'admin/settings/language';
return;
}
/**
* @} End of "locale-language-overview"
......@@ -151,8 +152,8 @@ function locale_languages_custom_form() {
'#value' => t('Add custom language')
);
// Reuse the validation and submit functions of the predefined language setup form.
$form['#submit']['locale_languages_predefined_form_submit'] = array();
$form['#validate']['locale_languages_predefined_form_validate'] = array();
$form['#submit'][] = 'locale_languages_predefined_form_submit';
$form['#validate'][] = 'locale_languages_predefined_form_validate';
return $form;
}
......@@ -170,8 +171,8 @@ function locale_languages_edit_form($langcode) {
'#type' => 'submit',
'#value' => t('Save language')
);
$form['#submit']['locale_languages_edit_form_submit'] = array();
$form['#validate']['locale_languages_edit_form_validate'] = array();
$form['#submit'][] = 'locale_languages_edit_form_submit';
$form['#validate'][] = 'locale_languages_edit_form_validate';
return $form;
}
else {
......@@ -252,7 +253,7 @@ function _locale_languages_common_controls(&$form, $language = NULL) {
/**
* Validate the language addition form.
*/
function locale_languages_predefined_form_validate($form_id, $form_values) {
function locale_languages_predefined_form_validate($form_values, $form, &$form_state) {
$langcode = $form_values['langcode'];
if ($duplicate = db_num_rows(db_query("SELECT language FROM {languages} WHERE language = '%s'", $langcode)) != 0) {
......@@ -268,14 +269,14 @@ function locale_languages_predefined_form_validate($form_id, $form_values) {
}
else {
// Reuse the editing form validation routine if we add a custom language.
locale_languages_edit_form_validate($form_id, $form_values);
locale_languages_edit_form_validate($form_values, $form, $form_state);
}
}
/**
* Process the language addition form submission.
*/
function locale_languages_predefined_form_submit($form_id, $form_values) {
function locale_languages_predefined_form_submit($form_values, $form, &$form_state) {
$langcode = $form_values['langcode'];
if (isset($form_values['name'])) {
// Custom language form.
......@@ -288,13 +289,14 @@ function locale_languages_predefined_form_submit($form_id, $form_values) {
locale_add_language($langcode, $lang[0], isset($lang[1]) ? $lang[1] : $lang[0], isset($lang[2]) ? $lang[2] : 0, '', $langcode);
}
return 'admin/settings/language';
$form_state['redirect'] = 'admin/settings/language';
return;
}
/**
* Validate the language editing form. Reused for custom language addition too.
*/
function locale_languages_edit_form_validate($form_id, $form_values) {
function locale_languages_edit_form_validate($form_values, $form, &$form_state) {
if (!empty($form_values['domain']) && !empty($form_values['prefix'])) {
form_set_error('prefix', t('Domain and path prefix values should not be set at the same time.'));
}
......@@ -313,7 +315,7 @@ function locale_languages_edit_form_validate($form_id, $form_values) {
/**
* Process the language editing form submission.
*/
function locale_languages_edit_form_submit($form_id, $form_values) {
function locale_languages_edit_form_submit($form_values, $form, &$form_state) {
db_query("UPDATE {languages} SET name = '%s', native = '%s', domain = '%s', prefix = '%s', direction = %d WHERE language = '%s'", $form_values['name'], $form_values['native'], $form_values['domain'], $form_values['prefix'], $form_values['direction'], $form_values['langcode']);
$default = language_default();
if ($default->language == $form_values['langcode']) {
......@@ -323,7 +325,8 @@ function locale_languages_edit_form_submit($form_id, $form_values) {
}
variable_set('language_default', $default);
}
return 'admin/settings/language';
$form_state['redirect'] = 'admin/settings/language';
return;
}
/**
* @} End of "locale-language-add-edit"
......@@ -366,7 +369,7 @@ function locale_languages_delete_form($langcode) {
/**
* Process language deletion submissions.
*/
function locale_languages_delete_form_submit($form_id, $form_values) {
function locale_languages_delete_form_submit($form_values, $form, &$form_state) {
$languages = language_list();
if (isset($languages[$form_values['langcode']])) {
db_query("DELETE FROM {languages} WHERE language = '%s'", $form_values['langcode']);
......@@ -380,7 +383,8 @@ function locale_languages_delete_form_submit($form_id, $form_values) {
// Changing the language settings impacts the interface:
cache_clear_all('*', 'cache_page', TRUE);
return 'admin/settings/language';
$form_state['redirect'] = 'admin/settings/language';
return;
}
/**
* @} End of "locale-language-add-edit"
......@@ -416,10 +420,11 @@ function locale_languages_configure_form() {
/**
* Submit function for language negotiation settings.
*/
function locale_languages_configure_form_submit($form_id, $form_values) {
function locale_languages_configure_form_submit($form_values, $form, &$form_state) {
variable_set('language_negotiation', $form_values['language_negotiation']);
drupal_set_message(t('Language negotiation configuration saved.'));
return 'admin/settings/language';
$form_state['redirect'] = 'admin/settings/language';
return;
}
/**
* @} End of "locale-languages-negotiation"
......@@ -588,7 +593,7 @@ function locale_translate_import_form() {
/**
* Process the locale import form submission.
*/
function locale_translate_import_form_submit($form_id, $form_values) {
function locale_translate_import_form_submit($form_values, $form, &$form_state) {
// Ensure we have the file uploaded
if ($file = file_check_upload('file')) {
......@@ -613,7 +618,8 @@ function locale_translate_import_form_submit($form_id, $form_values) {
return 'admin/build/translate/import';
}
return 'admin/build/translate';
$form_state['redirect'] = 'admin/build/translate';
return;
}
/**
* @} End of "locale-translate-import"
......@@ -682,15 +688,15 @@ function locale_translate_export_pot_form() {
);
$form['export']['submit'] = array('#type' => 'submit', '#value' => t('Export'));
// Reuse PO export submission callback.
$form['#submit']['locale_translate_export_po_form_submit'] = array();
$form['#validate']['locale_translate_export_po_form_validate'] = array();
$form['#submit'][] = 'locale_translate_export_po_form_submit';
$form['#validate'][] = 'locale_translate_export_po_form_validate';
return $form;
}
/**
* Process a translation (or template) export form submission.
*/
function locale_translate_export_po_form_submit($form_id, $form_values) {
function locale_translate_export_po_form_submit($form_values, $form, &$form_state) {
// If template is required, language code is not given.
_locale_export_po(isset($form_values['langcode']) ? $form_values['langcode'] : NULL, $form_values['group']);
}
......@@ -759,7 +765,7 @@ function locale_translate_edit_form($lid) {
* Process string editing form submissions.
* Saves all translations of one string submitted from a form.
*/
function locale_translate_edit_form_submit($form_id, $form_values) {
function locale_translate_edit_form_submit($form_values, $form, &$form_state) {
$lid = $form_values['lid'];
foreach ($form_values['translations'] as $key => $value) {
$trans = db_fetch_object(db_query("SELECT translation FROM {locales_target} WHERE lid = %d AND language = '%s'", $lid, $key));
......@@ -777,7 +783,8 @@ function locale_translate_edit_form_submit($form_id, $form_values) {
// Rebuild the menu, strings may have changed.
menu_rebuild();
return 'admin/build/translate/search';
$form_state['redirect'] = 'admin/build/translate/search';
return;
}
/**
* @} End of "locale-translate-edit"
......
......@@ -15,9 +15,17 @@
* The installation phase we should proceed to.
*/
function install_main() {
global $profile, $install_locale;
global $profile, $install_locale, $conf;
require_once './includes/cache-install.inc';
require_once './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_CONFIGURATION);
// Because no persistent storage is available yet, functions
// that check for cached data will fail. During the installation
// process, we temporarily replace the normal cache system with
// a stubbed-out version that short-circuits the actual caching
// process and avoids any errors.
$conf['cache_inc'] = './includes/cache-install.inc';
require_once './modules/system/system.install';
require_once './includes/file.inc';
......@@ -135,7 +143,8 @@ function install_verify_settings() {
$db_path = ltrim(urldecode($url['path']), '/');
$settings_file = './'. conf_path() .'/settings.php';
_install_settings_form_validate($db_prefix, $db_type, $db_user, $db_pass, $db_host, $db_port, $db_path, $settings_file);
$form_state = array();
_install_settings_form_validate($db_prefix, $db_type, $db_user, $db_pass, $db_host, $db_port, $db_path, $settings_file, $form_state);
if (!form_get_errors()) {
return TRUE;
}
......@@ -318,22 +327,23 @@ function install_settings_form($profile, $install_locale, $settings_file, $db_ur
$form['settings_file'] = array('#type' => 'value', '#value' => $settings_file);
$form['_db_url'] = array('#type' => 'value');
$form['#action'] = "install.php?profile=$profile" . ($install_locale ? "&locale=$install_locale" : '');
$form['#redirect'] = NULL;
$form['#redirect'] = FALSE;
}
return $form;
}
/**
* Form API validate for install_settings form.
*/
function install_settings_form_validate($form_id, $form_values, $form) {
function install_settings_form_validate($form_values, $form, &$form_state) {
global $db_url;
_install_settings_form_validate($form_values['db_prefix'], $form_values['db_type'], $form_values['db_user'], $form_values['db_pass'], $form_values['db_host'], $form_values['db_port'], $form_values['db_path'], $form_values['settings_file'], $form);
_install_settings_form_validate($form_values['db_prefix'], $form_values['db_type'], $form_values['db_user'], $form_values['db_pass'], $form_values['db_host'], $form_values['db_port'], $form_values['db_path'], $form_values['settings_file'], $form_state, $form);
}
/**
* Helper function for install_settings_validate.
*/
function _install_settings_form_validate($db_prefix, $db_type, $db_user, $db_pass, $db_host, $db_port, $db_path, $settings_file, $form = NULL) {
function _install_settings_form_validate($db_prefix, $db_type, $db_user, $db_pass, $db_host, $db_port, $db_path, $settings_file, &$form_state, $form = NULL) {
global $db_url;
// Verify the table prefix
......@@ -358,7 +368,7 @@ function _install_settings_form_validate($db_prefix, $db_type, $db_user, $db_pas
// Verify
$db_url = $db_type .'://'. urlencode($db_user) . ($db_pass ? ':'. urlencode($db_pass) : '') .'@'. ($db_host ? urlencode($db_host) : 'localhost') . ($db_port ? ":$db_port" : '') .'/'. urlencode($db_path);
if (isset($form)) {
form_set_value($form['_db_url'], $db_url);
form_set_value($form['_db_url'], $db_url, $form_state);
}
$success = array();
......@@ -377,7 +387,7 @@ function _install_settings_form_validate($db_prefix, $db_type, $db_user, $db_pas
/**
* Form API submit for install_settings form.
*/
function install_settings_form_submit($form_id, $form_values) {
function install_settings_form_submit($form_values) {
global $profile, $install_locale;
// Update global settings array and save
......@@ -589,17 +599,27 @@ function install_tasks($profile, $task) {
// We break the form up so we can tell when it's been successfully
// submitted.
$form_state = array('storage' => NULL, 'submitted' => FALSE);
$form = drupal_retrieve_form('install_configure_form');
$form_build_id = md5(mt_rand());
$form['#build_id'] = $form_build_id;
drupal_prepare_form('install_configure_form', $form, $form_state);
// In order to find out if the form was successfully submitted or not,
// we do a little song and dance to set the form to 'programmed' and check
// to make sure this is really the form being submitted. It'd better be.
if ($_POST && $_POST['form_id'] == 'install_configure_form') {
if (!empty($_POST) && $_POST['form_id'] == 'install_configure_form') {
$form['#programmed'] = TRUE;
$form['#post'] = $_POST;
}
else {
$form['#post'] = array();
}
if (!drupal_process_form('install_configure_form', $form)) {
drupal_process_form('install_configure_form', $form, $form_state);
if (empty($form_state['redirect'])) {
$output = drupal_render_form('install_configure_form', $form);
install_task_list('configure');
}
......@@ -832,7 +852,7 @@ function install_configure_form() {
return $form;
}
function install_configure_form_validate($form_id, $form_values, $form) {
function install_configure_form_validate($form_values, $form, &$form_state) {
if ($error = user_validate_name($form_values['account']['name'])) {
form_error($form['admin_account']['account']['name'], $error);
}
......@@ -844,13 +864,13 @@ function install_configure_form_validate($form_id, $form_values, $form) {
}
}
function install_configure_form_submit($form_id, $form_values) {
function install_configure_form_submit($form_values, $form, &$form_state) {
variable_set('site_name', $form_values['site_name']);
variable_set('site_mail', $form_values['site_mail']);
variable_set('date_default_timezone', $form_values['date_default_timezone']);
// Turn this off temporarily so that we can pass a password through.
variable_set('user_email_verification', FALSE);
user_register_submit('user_register', $form_values['account']);
user_register_submit($form_values['account'], $form, $form_state);
variable_set('user_email_verification', TRUE);
if (isset($form_values['clean_url'])) {
variable_set('clean_url', $form_values['clean_url']);
......
......@@ -357,7 +357,7 @@ function aggregator_form_category($edit = array('title' => '', 'description' =>
/**
* Validate aggregator_form_feed form submissions.
*/
function aggregator_form_category_validate($form_id, $form_values) {
function aggregator_form_category_validate($form_values, $form, &$form_state) {
if ($form_values['op'] == t('Submit')) {
// Check for duplicate titles
if (isset($form_values['cid'])) {
......@@ -376,7 +376,7 @@ function aggregator_form_category_validate($form_id, $form_values) {
* Process aggregator_form_category form submissions.
* @todo Add delete confirmation dialog.
*/
function aggregator_form_category_submit($form_id, $form_values) {
function aggregator_form_category_submit($form_values, $form, &$form_state) {
if ($form_values['op'] == t('Delete')) {
$title = $form_values['title'];
// Unset the title:
......@@ -388,20 +388,24 @@ function aggregator_form_category_submit($form_id, $form_values) {
if (isset($form_values['title'])) {
drupal_set_message(t('The category %category has been updated.', array('%category' => $form_values['title'])));
if (arg(0) == 'admin') {
return 'admin/content/aggregator/';
$form_state['redirect'] = 'admin/content/aggregator/';
return;
}
else {
return 'aggregator/categories/'. $form_values['cid'];
$form_state['redirect'] = 'aggregator/categories/'. $form_values['cid'];
return;
}
}
else {
watchdog('aggregator', 'Category %category deleted.', array('%category' => $title));
drupal_set_message(t('The category %category has been deleted.', array('%category' => $title)));
if (arg(0) == 'admin') {
return 'admin/content/aggregator/';
$form_state['redirect'] = 'admin/content/aggregator/';
return;
}
else {
return 'aggregator/categories/';
$form_state['redirect'] = 'aggregator/categories/';
return;
}
}
}
......@@ -488,7 +492,7 @@ function aggregator_form_feed($edit = array('refresh' => 900, 'title' => '', 'ur
/**
* Validate aggregator_form_feed form submissions.
*/
function aggregator_form_feed_validate($form_id, $form_values) {
function aggregator_form_feed_validate($form_values, $form, &$form_state) {
if ($form_values['op'] == t('Submit')) {
// Check for duplicate titles
if (isset($form_values['fid'])) {
......@@ -512,7 +516,7 @@ function aggregator_form_feed_validate($form_id, $form_values) {
* Process aggregator_form_feed form submissions.
* @todo Add delete confirmation dialog.
*/
function aggregator_form_feed_submit($form_id, $form_values) {
function aggregator_form_feed_submit($form_values, $form, &$form_state) {
if ($form_values['op'] == t('Delete')) {
$title = $form_values['title'];
// Unset the title:
......@@ -524,20 +528,24 @@ function aggregator_form_feed_submit($form_id, $form_values) {
if (isset($form_values['title'])) {
drupal_set_message(t('The feed %feed has been updated.', array('%feed' => $form_values['title'])));
if (arg(0) == 'admin') {
return 'admin/content/aggregator/';
$form_state['redirect'] = 'admin/content/aggregator/';
return;
}
else {
return 'aggregator/sources/'. $form_values['fid'];
$form_state['redirect'] = 'aggregator/sources/'. $form_values['fid'];
return;
}
}
else {
watchdog('aggregator', 'Feed %feed deleted.', array('%feed' => $title));
drupal_set_message(t('The feed %feed has been deleted.', array('%feed' => $title)));
if (arg(0) == 'admin') {
return 'admin/content/aggregator/';
$form_state['redirect'] = 'admin/content/aggregator/';
return;
}
else {
return 'aggregator/sources/';
$form_state['redirect'] = 'aggregator/sources/';
return;
}
}
}
......@@ -1076,8 +1084,8 @@ function aggregator_page_category() {
}
function aggregator_page_list($sql, $header, $categorize) {
$form['#submit']['aggregator_page_list_submit'] = array();
$form['#validate']['aggregator_page_list_validate'] = array();
$form['#submit'][] = 'aggregator_page_list_submit';
$form['#validate'][] = 'aggregator_page_list_validate';
$form['#theme'] = 'aggregator_page_list';
$form['header'] = array('#value' => $header);
$result = pager_query($sql, 20);
......@@ -1162,7 +1170,7 @@ function aggregator_page_list_validate($form_id, &$form) {
}
}
function aggregator_page_list_submit($form_id, $form_values) {
function aggregator_page_list_submit($form_values, $form, &$form_state) {
foreach ($form_values['categories'] as $iid => $selection) {
db_query('DELETE FROM {aggregator_category_item} WHERE iid = %d', $iid);
foreach ($selection as $cid) {
......
......@@ -292,7 +292,7 @@ function _block_compare($a, $b) {
/**
* Process main block administration form submission.
*/
function block_admin_display_submit($form_id, $form_values) {
function block_admin_display_submit($form_values, $form, &$form_state) {
foreach ($form_values as $block) {
$block['status'] = $block['region'] != BLOCK_REGION_NONE;
$block['region'] = $block['status'] ? $block['region'] : '';
......@@ -498,7 +498,7 @@ function block_admin_configure($module = NULL, $delta = 0) {
return $form;
}
function block_admin_configure_validate($form_id, $form_values) {
function block_admin_configure_validate($form_values, $form, &$form_state) {
if ($form_values['module'] == 'block') {
if (empty($form_values['info']) || db_num_rows(db_query("SELECT bid FROM {boxes} WHERE bid != %d AND info = '%s'", $form_values['delta'], $form_values['info']))) {
form_set_error('info', t('Please ensure that each block description is unique.'));
......@@ -506,7 +506,7 @@ function block_admin_configure_validate($form_id, $form_values) {
}
}
function block_admin_configure_submit($form_id, $form_values) {
function block_admin_configure_submit($form_values, $form, &$form_state) {
if (!form_get_errors()) {
db_query("UPDATE {blocks} SET visibility = %d, pages = '%s', custom = %d, title = '%s' WHERE module = '%s' AND delta = '%s'", $form_values['visibility'], trim($form_values['pages']), $form_values['custom'], $form_values['title'], $form_values['module'], $form_values['delta']);
db_query("DELETE FROM {blocks_roles} WHERE module = '%s' AND delta = '%s'", $form_values['module'], $form_values['delta']);
......@@ -516,7 +516,8 @@ function block_admin_configure_submit($form_id, $form_values) {
module_invoke($form_values['module'], 'block', 'save', $form_values['delta'], $form_values);
drupal_set_message(t('The block configuration has been saved.'));
cache_clear_all();
return 'admin/build/block';
$form_state['redirect'] = 'admin/build/block';
return;
}
}
......@@ -527,7 +528,7 @@ function block_add_block_form() {
return block_admin_configure('block', NULL);
}
function block_add_block_form_validate($form_id, $form_values) {
function block_add_block_form_validate($form_values, $form, &$form_state) {
if (empty($form_values['info']) || db_num_rows(db_query("SELECT info FROM {boxes} WHERE info = '%s'", $form_values['info']))) {
form_set_error('info', t('Please ensure that each block description is unique.'));
}
......@@ -536,7 +537,7 @@ function block_add_block_form_validate($form_id, $form_values) {
/**
* Save the new custom block.
*/
function block_add_block_form_submit($form_id, $form_values) {
function block_add_block_form_submit($form_values, $form, &$form_state) {
$delta = db_next_id('{boxes}_bid');
foreach (list_themes() as $key => $theme) {
......@@ -554,7 +555,8 @@ function block_add_block_form_submit($form_id, $form_values) {
drupal_set_message(t('The block has been created.'));
cache_clear_all();
return 'admin/build/block';
$form_state['redirect'] = 'admin/build/block';
return;
}
/**
......@@ -571,12 +573,13 @@ function block_box_delete($bid = 0) {
/**
* Deletion of custom blocks.
*/
function block_box_delete_submit($form_id, $form_values) {
function block_box_delete_submit($form_values, $form, &$form_state) {
db_query('DELETE FROM {boxes} WHERE bid = %d', $form_values['bid']);
db_query("DELETE FROM {blocks} WHERE module = 'block' AND delta = %d", $form_values['bid']);
drupal_set_message(t('The block %name has been removed.', array('%name' => $form_values['info'])));
cache_clear_all();
return 'admin/build/block';
$form_state['redirect'] = 'admin/build/block';
return;
};
/**
......
......@@ -199,12 +199,12 @@ function book_insert($node) {
/**
* Implementation of hook_submit().
*/
function book_submit(&$node) {
function book_submit(&$form_values) {
global $user;
// Set default values for non-administrators.
if (!user_access('administer nodes')) {
$node->revision = 1;
$node->uid = $user->uid;
$form_values['revision'] = 1;
$form_values['uid'] = $user->uid;
}
}
......@@ -298,7 +298,7 @@ function book_outline($node) {
/**
* Handles book outline form submissions.
*/
function book_outline_submit($form_id, $form_values) {
function book_outline_submit($form_values, $form, &$form_state) {
$op = $form_values['op'];
$node = node_load($form_values['nid']);