You are here

function relation_ui_type_delete_confirm in Relation 7

Menu callback; deletes a single relation type.

1 string reference to 'relation_ui_type_delete_confirm'
relation_ui_menu in ./relation_ui.module
Implements hook_menu().

File

./relation_ui.module, line 405
Provide administration interface for relation type bundles.

Code

function relation_ui_type_delete_confirm($form, &$form_state, $relation_type) {
  $form['relation_type'] = array(
    '#type' => 'value',
    '#value' => $relation_type->relation_type,
  );
  $form['label'] = array(
    '#type' => 'value',
    '#value' => $relation_type->label,
  );
  $message = t('Are you sure you want to delete the %label relation type?', array(
    '%label' => $relation_type->label,
  ));
  $caption = '';
  $num_relations = relation_query()
    ->propertyCondition('relation_type', $relation_type->relation_type)
    ->count()
    ->execute();
  if ($num_relations) {
    $caption .= '<p>' . format_plural($num_relations, 'The %label relation type is used by 1 relation on your site. If you remove this relation type, you will not be able to edit  %label relations and they may not display correctly.', 'The %label relation type is used by @count relations on your site. If you remove %label, you will not be able to edit %label relations and they may not display correctly.', array(
      '%label' => $relation_type->label,
      '@count' => $num_relations,
    )) . '</p>';
  }
  $caption .= '<p>' . t('This action cannot be undone.') . '</p>';
  return confirm_form($form, $message, 'admin/structure/relation', $caption, t('Delete'));
}