You are here

function community_tags_delete_all_form in Community Tags 6.2

Same name and namespace in other branches
  1. 6 community_tags.admin.inc \community_tags_delete_all_form()
  2. 7 community_tags.admin.inc \community_tags_delete_all_form()

Confirmation form for tag purge. Assumes defaults.

1 string reference to 'community_tags_delete_all_form'
community_tags_menu in ./community_tags.module
Implementation of hook_menu().

File

./community_tags.admin.inc, line 383
community_tags.admin.inc

Code

function community_tags_delete_all_form(&$form_state, $vocabulary, $content_type) {
  $form = array();
  $type_obj = node_get_types('type', $content_type);

  // get the number of tags that will be deleted
  $counts = _community_tags_get_tag_counts_by_type_and_vocabulary();
  if (empty($counts[$vocabulary->vid][$content_type])) {
    drupal_set_message(t('There are no community tags to delete.'));
  }
  else {
    $counts = $counts[$vocabulary->vid][$content_type];
  }

  // get settings if valid
  $settings = _community_tags_get_settings($vocabulary->vid, $content_type, TRUE);
  $form['#delete_ops'] = array();
  $form['#ct_settings'] = $settings;
  $form['#vocabulary'] = $vocabulary;
  $form['#content_type_obj'] = $type_obj;
  $form['#counts'] = $counts;
  $question = t('Delete %count community tags from the %vocabulary vocabulary on nodes of type %type?.', array(
    '%count' => $counts->tag_count,
    '%vocabulary' => $vocabulary->name,
    '%type' => $type_obj->name,
  ));

  // @todo 2.x get the number of node terms that will be deleted
  // @todo 2.x get the number of orphaned terms that will be deleted
  $description = '';
  if ($settings) {
    $form['#delete_ops']['delete_tags'] = TRUE;
    $description .= '<p>' . t('WARNING: Community tagging is currently enabled for this combination of content type and vocabulary. ') . '</p>';
    $description = '<p>' . t('Community tags will be deleted from the community tags database table.') . '</p>';
    if ($settings['opmode'] & COMMUNITY_TAGS_OPMODE_DELETE_ORPHAN_TERMS) {
      $form['delete_policy'] = array(
        '#type' => 'checkbox',
        '#title' => t('Delete redundant terms'),
        '#weight' => 1,
        '#default_value' => COMMUNITY_TAGS_OPMODE_DELETE_ORPHAN_TERMS,
        '#description' => t('"Delete redundant term" mode is set. All redundant terms will be deleted i.e. all terms matching deleted tags that are no longer used. If you do not want to delete redundant terms as part of this purge operation, un-check this below.'),
      );
    }
  }
  else {
    $form['#delete_ops']['#quick_delete'] = TRUE;
    $description = '<p>' . t('Community tagging is currently disabled for this combination of content type and vocabulary. ') . '</p>';
    $description = '<p>' . t('Community tags will be deleted from the community tags database table and nothing else. ') . '</p>';
  }
  $path = 'admin/settings/community-tags';
  $confirm_form = confirm_form($form, $question, $path, $description);
  $confirm_form['actions']['#weight'] = 5;
  return $confirm_form;
}