1 node.pages.inc node_preview_banner_form_node_submit(array $form, array &$form_state)

Submit handler for the node preview banner form.

@since 1.11.0

See also

node_preview_banner_form()

File

core/modules/node/node.pages.inc, line 731
Callbacks for adding, editing, and deleting content and managing revisions.

Code

function node_preview_banner_form_node_submit(array $form, array &$form_state) {
  form_load_include($form_state, 'inc', 'node', 'node.pages');
  $node = $form_state['values']['node'];
  node_object_prepare($node);
  $type = $node->type;
  $build = array();
  $build['node'] = $node;
  $build['values']['status'] = $node->old_status;
  $build['values']['scheduled'] = $node->scheduled;
  $build['values']['op'] = t('Save');
  backdrop_form_submit($type . '_node_form', $build, $node);
  $errors = form_get_errors();
  if (!empty($errors)) {
    foreach ($errors as $field_name => $message) {
      watchdog('node', '%field: %message', array('%message' => $message, '%field' => $field_name));
    }
  }
  else {
    // Determine whether to redirect user to full page display.
    $destination = '<front>';
    if (node_access('view', $node)) {
      $destination = 'node/' . $node->nid;
      // If node type set to prevent direct viewing of full page URL
      // stay on edit page if user is not permitted.
      $type = node_type_get_type($node);
      $bypass_hidden_path = user_access('view hidden paths');
      if ($type->settings['hidden_path'] && !$bypass_hidden_path) {
        $destination = 'node/' . $node->nid . '/edit';
      }
    }
    backdrop_goto($destination);
  }
}