Commit 583d5a4e authored by Dries's avatar Dries
Browse files

- Patch #48622 by adrian: remove drupal_goto from _submit functions.

parent 91152ba7
......@@ -1193,7 +1193,7 @@ function drupal_to_js($var) {
}
return '[ '. implode(', ', $output) .' ]';
}
// Fall through
// Fall through
case 'object':
$output = array();
foreach ($var as $k => $v) {
......
......@@ -103,11 +103,24 @@ function drupal_get_form($form_id, &$form, $callback = NULL) {
}
$form = _form_builder($form_id, $form);
$goto = $_GET['q'];
if (!empty($_POST['edit']) && (($_POST['edit']['form_id'] == $form_id) || ($_POST['edit']['form_id'] == $callback))) {
drupal_validate_form($form_id, $form, $callback);
if ($form_submitted && !form_get_errors()) {
drupal_submit_form($form_id, $form, $callback);
$redirect = drupal_submit_form($form_id, $form, $callback);
if (!is_null($redirect)) {
$goto = $redirect;
}
else if ($form['#redirect']) {
$goto = $form['#redirect'];
}
if (is_array($goto)) {
call_user_func_array('drupal_goto', $redirect);
}
else {
drupal_goto(drupal_get_path_alias($goto));
}
}
}
......@@ -136,14 +149,18 @@ function drupal_validate_form($form_id, &$form, $callback = NULL) {
function drupal_submit_form($form_id, $form, $callback = NULL) {
global $form_values;
$goto = null;
unset($GLOBALS['form_values']['submit'], $GLOBALS['form_values']['form_id']);
if (isset($form['#submit'])) {
foreach ($form['#submit'] as $function => $args) {
if (function_exists($function)) {
call_user_func_array($function, $args);
// Since we can only redirect to one page, only the last redirect will work
$redirect = call_user_func_array($function, $args);
$goto = (!is_null($redirect)) ? $redirect : $goto;
}
}
}
return $goto;
}
function _form_validate($elements, $form_id = NULL) {
......
......@@ -998,8 +998,8 @@ function _menu_sort($a, $b) {
elseif ($a['weight'] > $b['weight']) {
return 1;
}
elseif (isset($a['title']) && isset($b['title']) && ($a['title'] < $b['title'])) {
return -1;
elseif (isset($a['title']) && isset($b['title'])) {
return strnatcasecmp($a['title'], $b['title']);
}
else {
return 1;
......
......@@ -291,7 +291,20 @@ tr.odd .form-item, tr.even .form-item {
#forum td.posts, #forum td.topics, #forum td.replies, #forum td.pager {
text-align: center;
}
.forum-topic-navigation {
padding: 1em 0 0 3em;
border-top: 1px solid #888;
border-bottom: 1px solid #888;
text-align: center;
padding: 0.5em;
}
.forum-topic-navigation .topic-previous {
margin-right: 4em;
text-align: right;
}
.forum-topic-navigation .topic-next {
text-align: left;
}
.locale-untranslated {
font-style: normal;
text-decoration: line-through;
......
......@@ -1013,7 +1013,6 @@ function aggregator_page_list_submit($form_id, $form) {
}
}
drupal_set_message(t('The categories have been saved.'));
drupal_goto($_GET['q']);
}
......
......@@ -1013,7 +1013,6 @@ function aggregator_page_list_submit($form_id, $form) {
}
}
drupal_set_message(t('The categories have been saved.'));
drupal_goto($_GET['q']);
}
......
......@@ -406,7 +406,7 @@ 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();
drupal_goto('admin/block');
return 'admin/block';
}
}
......@@ -430,7 +430,7 @@ function block_box_add_submit($form_id, $form_values) {
if (!form_get_errors()) {
if (block_box_save($form_values)) {
drupal_set_message(t('The block has been created.'));
drupal_goto('admin/block');
return 'admin/block';
}
}
}
......@@ -453,7 +453,7 @@ function block_box_delete_confirm_submit($form_id, $form_values) {
db_query('DELETE FROM {boxes} WHERE bid = %d', $form_values['bid']);
drupal_set_message(t('The block %name has been removed.', array('%name' => theme('placeholder', $form_values['info']))));
cache_clear_all();
drupal_goto('admin/block');
return 'admin/block';
};
function block_box_form($edit = array()) {
......
......@@ -406,7 +406,7 @@ 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();
drupal_goto('admin/block');
return 'admin/block';
}
}
......@@ -430,7 +430,7 @@ function block_box_add_submit($form_id, $form_values) {
if (!form_get_errors()) {
if (block_box_save($form_values)) {
drupal_set_message(t('The block has been created.'));
drupal_goto('admin/block');
return 'admin/block';
}
}
}
......@@ -453,7 +453,7 @@ function block_box_delete_confirm_submit($form_id, $form_values) {
db_query('DELETE FROM {boxes} WHERE bid = %d', $form_values['bid']);
drupal_set_message(t('The block %name has been removed.', array('%name' => theme('placeholder', $form_values['info']))));
cache_clear_all();
drupal_goto('admin/block');
return 'admin/block';
};
function block_box_form($edit = array()) {
......
......@@ -1413,7 +1413,7 @@ function _comment_form_submit($form_values) {
function comment_form_submit($form_id, $form_values) {
$form_values = _comment_form_submit($form_values);
if ($cid = comment_save($form_values)) {
drupal_goto('node/'. $form_values['nid'], NULL, "comment-$cid");
return array('node/'. $form_values['nid'], NULL, "comment-$cid");
}
}
......
......@@ -1413,7 +1413,7 @@ function _comment_form_submit($form_values) {
function comment_form_submit($form_id, $form_values) {
$form_values = _comment_form_submit($form_values);
if ($cid = comment_save($form_values)) {
drupal_goto('node/'. $form_values['nid'], NULL, "comment-$cid");
return array('node/'. $form_values['nid'], NULL, "comment-$cid");
}
}
......
......@@ -199,7 +199,7 @@ function contact_mail_user_submit($form_id, $edit) {
drupal_set_message(t('The message has been sent.'));
// Jump to the user's profile page:
drupal_goto("user/$account->uid");
return "user/$account->uid";
}
function contact_admin_edit($cid = NULL) {
......@@ -285,7 +285,7 @@ function contact_admin_edit_submit($form_id, $form_values) {
db_query("UPDATE {contact} SET category = '%s', recipients = '%s', reply = '%s', weight = %d, selected = %d WHERE cid=%d", $form_values['category'], $form_values['recipients'], $form_values['reply'], $form_values['weight'], $form_values['selected'], $form_values['cid']);
}
drupal_set_message(t('Category %category has been updated.', array('%category' => theme('placeholder', $edit['category']))));
drupal_goto('admin/contact');
return 'admin/contact';
}
function contact_admin_delete($cid) {
......@@ -453,5 +453,5 @@ function contact_mail_page_submit($form_id, $edit) {
drupal_set_message(t('Your message has been sent.'));
// Jump to contact page:
drupal_goto('contact');
return 'contact';
}
......@@ -199,7 +199,7 @@ function contact_mail_user_submit($form_id, $edit) {
drupal_set_message(t('The message has been sent.'));
// Jump to the user's profile page:
drupal_goto("user/$account->uid");
return "user/$account->uid";
}
function contact_admin_edit($cid = NULL) {
......@@ -285,7 +285,7 @@ function contact_admin_edit_submit($form_id, $form_values) {
db_query("UPDATE {contact} SET category = '%s', recipients = '%s', reply = '%s', weight = %d, selected = %d WHERE cid=%d", $form_values['category'], $form_values['recipients'], $form_values['reply'], $form_values['weight'], $form_values['selected'], $form_values['cid']);
}
drupal_set_message(t('Category %category has been updated.', array('%category' => theme('placeholder', $edit['category']))));
drupal_goto('admin/contact');
return 'admin/contact';
}
function contact_admin_delete($cid) {
......@@ -453,5 +453,5 @@ function contact_mail_page_submit($form_id, $edit) {
drupal_set_message(t('Your message has been sent.'));
// Jump to contact page:
drupal_goto('contact');
return 'contact';
}
......@@ -1093,7 +1093,7 @@ function node_filter_form_submit() {
return;
}
if ($op != '') {
drupal_goto('admin/node');
return 'admin/node';
}
}
......@@ -1111,7 +1111,7 @@ function node_admin_nodes_submit($form_id, $edit) {
}
}
drupal_set_message(t('The update has been performed.'));
drupal_goto('admin/node');
return 'admin/node';
}
}
......@@ -1227,7 +1227,7 @@ function node_multiple_delete_confirm_submit($form_id, $edit) {
}
drupal_set_message(t('The items have been deleted.'));
}
drupal_goto('admin/node');
return 'admin/node';
}
/**
......@@ -1865,14 +1865,8 @@ function node_form_submit($form_id, $edit) {
drupal_set_message(t('Your %post was created.', array ('%post' => node_get_name($node))));
}
}
if ($node->nid) {
if (node_access('view', $node)) {
drupal_goto('node/'. $node->nid);
}
else {
drupal_goto();
}
if ($node->nid && node_access('view', $node)) {
return 'node/'. $node->nid;
}
}
......@@ -1901,7 +1895,6 @@ function node_delete_confirm() {
function node_delete_confirm_submit($form_id, $form_values) {
if ($form_values['confirm']) {
node_delete($form_values['nid']);
drupal_goto();
}
}
......
......@@ -1093,7 +1093,7 @@ function node_filter_form_submit() {
return;
}
if ($op != '') {
drupal_goto('admin/node');
return 'admin/node';
}
}
......@@ -1111,7 +1111,7 @@ function node_admin_nodes_submit($form_id, $edit) {
}
}
drupal_set_message(t('The update has been performed.'));
drupal_goto('admin/node');
return 'admin/node';
}
}
......@@ -1227,7 +1227,7 @@ function node_multiple_delete_confirm_submit($form_id, $edit) {
}
drupal_set_message(t('The items have been deleted.'));
}
drupal_goto('admin/node');
return 'admin/node';
}
/**
......@@ -1865,14 +1865,8 @@ function node_form_submit($form_id, $edit) {
drupal_set_message(t('Your %post was created.', array ('%post' => node_get_name($node))));
}
}
if ($node->nid) {
if (node_access('view', $node)) {
drupal_goto('node/'. $node->nid);
}
else {
drupal_goto();
}
if ($node->nid && node_access('view', $node)) {
return 'node/'. $node->nid;
}
}
......@@ -1901,7 +1895,6 @@ function node_delete_confirm() {
function node_delete_confirm_submit($form_id, $form_values) {
if ($form_values['confirm']) {
node_delete($form_values['nid']);
drupal_goto();
}
}
......
......@@ -117,7 +117,7 @@ function path_admin_delete_confirm($pid) {
function path_admin_delete_confirm_submit($form_id, $form_values) {
if ($form_values['confirm']) {
path_admin_delete($form_values['pid']);
drupal_goto('admin/path');
return 'admin/path';
}
}
......@@ -342,7 +342,7 @@ function path_form_submit() {
path_set_alias($src, $dst, $pid);
drupal_set_message(t('The alias has been saved.'));
drupal_goto('admin/path');
return 'admin/path';
}
}
......
......@@ -117,7 +117,7 @@ function path_admin_delete_confirm($pid) {
function path_admin_delete_confirm_submit($form_id, $form_values) {
if ($form_values['confirm']) {
path_admin_delete($form_values['pid']);
drupal_goto('admin/path');
return 'admin/path';
}
}
......@@ -342,7 +342,7 @@ function path_form_submit() {
path_set_alias($src, $dst, $pid);
drupal_set_message(t('The alias has been saved.'));
drupal_goto('admin/path');
return 'admin/path';
}
}
......
......@@ -245,7 +245,7 @@ function search_wipe_confirm_submit($form_id, &$form) {
if ($form['confirm']) {
search_wipe();
drupal_set_message(t('The index will be rebuilt.'));
drupal_goto('admin/settings/search');
return 'admin/settings/search';
}
}
......
......@@ -245,7 +245,7 @@ function search_wipe_confirm_submit($form_id, &$form) {
if ($form['confirm']) {
search_wipe();
drupal_set_message(t('The index will be rebuilt.'));
drupal_goto('admin/settings/search');
return 'admin/settings/search';
}
}
......
......@@ -55,7 +55,7 @@ function system_perm() {
*/
function system_elements() {
// Top level form
$type['form'] = array('#method' => 'post', '#action' => request_uri());
$type['form'] = array('#method' => 'post', '#action' => request_uri(), '#redirect' => '');
// Inputs
$type['checkbox'] = array('#input' => TRUE, '#return_value' => 1);
......@@ -787,7 +787,6 @@ function system_settings_form_submit($form_id, $values) {
drupal_set_message(t('The configuration options have been saved.'));
}
menu_rebuild();
drupal_goto($_GET['q']);
}
/**
......@@ -887,7 +886,7 @@ function system_themes_submit($form_id, $values) {
menu_rebuild();
drupal_set_message(t('The configuration options have been saved.'));
drupal_goto('admin/themes');
return 'admin/themes';
}
/**
......@@ -1021,7 +1020,7 @@ function system_modules_submit($form_id, $edit) {
}
drupal_set_message(t('The configuration options have been saved.'));
drupal_goto('admin/modules');
return 'admin/modules';
}
......
......@@ -55,7 +55,7 @@ function system_perm() {
*/
function system_elements() {
// Top level form
$type['form'] = array('#method' => 'post', '#action' => request_uri());
$type['form'] = array('#method' => 'post', '#action' => request_uri(), '#redirect' => '');
// Inputs
$type['checkbox'] = array('#input' => TRUE, '#return_value' => 1);
......@@ -787,7 +787,6 @@ function system_settings_form_submit($form_id, $values) {
drupal_set_message(t('The configuration options have been saved.'));
}
menu_rebuild();
drupal_goto($_GET['q']);
}
/**
......@@ -887,7 +886,7 @@ function system_themes_submit($form_id, $values) {
menu_rebuild();
drupal_set_message(t('The configuration options have been saved.'));
drupal_goto('admin/themes');
return 'admin/themes';
}
/**
......@@ -1021,7 +1020,7 @@ function system_modules_submit($form_id, $edit) {
}
drupal_set_message(t('The configuration options have been saved.'));
drupal_goto('admin/modules');
return 'admin/modules';
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment