You are here

function biblio_admin_types_delete_form in Bibliography Module 7

Same name and namespace in other branches
  1. 6.2 includes/biblio.admin.inc \biblio_admin_types_delete_form()
  2. 6 biblio.admin.inc \biblio_admin_types_delete_form()
  3. 7.2 includes/biblio.admin.inc \biblio_admin_types_delete_form()

_state

Parameters

$form:

$tid:

Return value

unknown

1 string reference to 'biblio_admin_types_delete_form'
biblio_menu in ./biblio.module
Implements hook_menu().

File

includes/biblio.admin.inc, line 1690
biblio.admin.inc

Code

function biblio_admin_types_delete_form($form, &$form_state, $tid) {
  $existing_msg = '';
  if (isset($tid) && is_numeric($tid)) {
    $row = db_query('SELECT t.* FROM {biblio_types} as t WHERE t.tid = :tid ', array(
      ':tid' => $tid,
    ))
      ->fetchObject();
    $num_rows = db_query('SELECT COUNT(*) FROM {biblio} as b WHERE b.biblio_type = :btype', array(
      ':btype' => $row->tid,
    ))
      ->fetchField();
    if ($num_rows) {
      $existing_msg = t('There are @count biblio entries of this type, you should change the type of these entries before proceeding otherwise they will be deleted', array(
        '@count' => $num_rows,
      ));
    }
    $form['tid'] = array(
      '#type' => 'value',
      '#value' => $row->tid,
    );
    $output = confirm_form($form, t('Are you sure you want to delete the custom biblio type:  %title ?', array(
      '%title' => $row->name,
    )) . $existing_msg, isset($_GET['destination']) ? $_GET['destination'] : 'admin/config/content/biblio/pubtype', t('This action cannot be undone.'), t('Delete'), t('Cancel'));
    return $output;
  }
  else {
    drupal_goto('admin/config/content/biblio/pubtype');
  }
}