You are here

function boxes_admin_ui_type_delete_confirm in Boxes 7.2

Menu callback; delete a single content type.

1 string reference to 'boxes_admin_ui_type_delete_confirm'
boxes_admin_ui_menu in boxes_admin_ui/boxes_admin_ui.module
Implements hook_menu().

File

boxes_admin_ui/boxes_admin_ui.admin.inc, line 175
Boxes Admin Page

Code

function boxes_admin_ui_type_delete_confirm($form, &$form_state, $type) {
  $form['type'] = array(
    '#type' => 'value',
    '#value' => $type,
  );
  $form['name'] = array(
    '#type' => 'value',
    '#value' => $type
      ->getLabel(),
  );
  $caption = '';
  if (!method_exists($type, 'getExportStatus') || $type
    ->getExportStatus() == 'Normal') {
    $message = t('Are you sure you want to delete the block type %type?', array(
      '%type' => $type
        ->getLabel(),
    ));
    $num_boxes = db_query("SELECT COUNT(*) FROM {box} WHERE type = :type", array(
      ':type' => $type->type,
    ))
      ->fetchField();
    if ($num_boxes) {
      $caption .= '<p>' . format_plural($num_boxes, '%type is used by 1 block on your site. If you remove this block type, you will not be able to edit the %type blocks and it may not display correctly.', '%type is used by @count pieces of content on your site. If you remove %type, you will not be able to edit the %type content and it may not display correctly.', array(
        '%type' => $type
          ->getLabel(),
      )) . '</p>';
    }
    $action = t('Delete');
  }
  else {
    $message = t('Are you sure you want to revert the block type %type?', array(
      '%type' => $type
        ->getLabel(),
    ));
    $action = t('Revert');
  }
  $caption .= '<p>' . t('This action cannot be undone.') . '</p>';
  return confirm_form($form, $message, 'admin/structure/block-types', $caption, $action);
}