You are here

function ds_remove_view_mode_confirm in Display Suite 7.2

Same name and namespace in other branches
  1. 7 ds.view_modes.inc \ds_remove_view_mode_confirm()

Confirmation revert or remove form.

2 calls to ds_remove_view_mode_confirm()
ds_delete_view_mode_confirm in modules/ds_ui/includes/ds.view_modes.inc
Menu callback: Confirmation view mode delete form.
ds_revert_view_mode_confirm in modules/ds_ui/includes/ds.view_modes.inc
Menu callback: Confirmation view mode revert form.

File

modules/ds_ui/includes/ds.view_modes.inc, line 200
Administrative functions for managing view modes for every entity.

Code

function ds_remove_view_mode_confirm($form, &$form_state, $view_mode = '', $action = 'delete') {
  ctools_include('export');
  $view_modes = ctools_export_crud_load_all('ds_view_modes');
  if (isset($view_modes[$view_mode])) {
    $view_mode = $view_modes[$view_mode];
  }
  $confirm = FALSE;
  if (isset($view_mode->export_type)) {
    if ($action == 'delete' && $view_mode->export_type != 2) {
      $confirm = TRUE;
    }
    elseif ($action == 'revert' && $view_mode->export_type == 3) {
      $confirm = TRUE;
    }
  }
  if ($confirm) {
    $form['#view_mode'] = $view_mode;
    return confirm_form($form, t('Are you sure you want to ' . $action . ' %view_mode?', array(
      '%view_mode' => $view_mode->label,
    )), 'admin/structure/ds/view_modes', t('This action cannot be undone.'), t(drupal_ucfirst($action)), t('Cancel'));
  }
  else {
    drupal_set_message(t('This operation is not possible.'));
    drupal_goto('admin/structure/ds/view_modes');
  }
}