You are here

function ds_remove_view_mode in Display Suite 7

Same name and namespace in other branches
  1. 7.2 modules/ds_ui/includes/ds.view_modes.inc \ds_remove_view_mode()

Remove a view mode from the database.

Parameters

$action: Whether we delete or remove the view mode.

2 calls to ds_remove_view_mode()
ds_delete_view_mode_confirm_submit in ./ds.view_modes.inc
Confirmed view mode delete submit callback.
ds_revert_view_mode_confirm_submit in ./ds.view_modes.inc
Confirmed view mode revert submit callback.

File

./ds.view_modes.inc, line 253
Administrative functions for managing view modes for every entity.

Code

function ds_remove_view_mode($form, &$form_state, $action = 'deleted') {
  $view_mode = $form['#view_mode'];

  // Remove view mode from database.
  db_delete('ds_view_modes')
    ->condition('view_mode', $view_mode->view_mode)
    ->execute();

  // Remove layout and field settings for this view mode.
  db_delete('ds_field_settings')
    ->condition('view_mode', $view_mode->view_mode)
    ->execute();
  db_delete('ds_layout_settings')
    ->condition('view_mode', $view_mode->view_mode)
    ->execute();

  // Clear entity info cache and trigger menu build on next request.
  cache_clear_all('entity_info', 'cache', TRUE);
  variable_set('menu_rebuild_needed', TRUE);

  // Redirect.
  $form_state['redirect'] = 'admin/structure/ds/view_modes';
  drupal_set_message(t('The view mode %view_mode has been ' . $action . '.', array(
    '%view_mode' => $view_mode->label,
  )));
}