You are here

function views_edit_view_submit in Views (for Drupal 7) 5

Handle submit buttons on a view form.

File

./views_ui.module, line 1830

Code

function views_edit_view_submit($form_id, $form) {
  $view = (object) $form;

  // Transform any data that requires it here.
  $view->access = array_keys(array_filter($view->access));

  // ensure for MYSQL 5 irritation reasons.
  $view->nodes_per_page = intval($view->nodes_per_page);
  $view->nodes_per_block = intval($view->nodes_per_block);
  $view->menu_tab_weight = intval($view->menu_tab_weight);

  // re-order things as they were ordered on the form.
  foreach (array(
    'field',
    'argument',
    'filter',
    'sort',
    'exposed_filter',
  ) as $section) {
    views_ui_reorder($view->{$section});
  }
  $view_is_new = !$view->vid;
  $vid = _views_save_view($view);
  views_invalidate_cache();
  menu_rebuild();
  if ($form['vid']) {
    drupal_set_message(t('View successfully saved.'));
  }
  else {
    drupal_set_message(t('View successfully added.'));
  }
  if ($form['op'] == t('Save')) {
    $args = explode('/', $_GET['q']);
    if ($args[0] == 'admin' && $args[1] == 'build' && $args[2] == 'views') {
      return 'admin/build/views';
    }
    array_pop($args);
    return implode('/', $args);
  }
  if ($form['op'] == t('Save and edit') && $view_is_new) {
    return "admin/build/views/{$vid}/edit";
  }
}