function community_tags_delete_all_form in Community Tags 6
Same name and namespace in other branches
- 6.2 community_tags.admin.inc \community_tags_delete_all_form()
- 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 602 - 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>';
if ($settings['opmode'] & COMMUNITY_TAGS_OPMODE_SYNC || $settings['opmode'] & COMMUNITY_TAGS_OPMODE_DELETE_ORPHAN_TERMS) {
// offer option to bring ct's into line with nt or vice versa
$form['delete_policy'] = array(
'#type' => 'checkboxes',
'#title' => t('Purge options'),
'#options' => array(),
'#multiple' => TRUE,
'#weight' => 1,
'#default_value' => array(),
);
if ($settings['opmode'] & COMMUNITY_TAGS_OPMODE_SYNC) {
$description .= '<p>' . t('Community tags are synchronised with node terms: all corresponding node terms will be removed. ') . '</p>';
$description .= '<p>' . t('If you do not want to delete corresponding node terms as part of this purge operation, un-check the option below. ') . '</p>';
$form['delete_policy']['#options'][COMMUNITY_TAGS_OPMODE_SYNC] = t('<em>Delete node terms</em>');
$form['delete_policy']['#default_value'][] = COMMUNITY_TAGS_OPMODE_SYNC;
}
else {
$description = '<p>' . t('Community tags will be deleted from the community tags database table.') . '</p>';
}
if ($settings['opmode'] & COMMUNITY_TAGS_OPMODE_DELETE_ORPHAN_TERMS) {
$description .= '<p>' . t('"Delete orphaned term" mode is set. All orphaned terms will be deleted i.e. all terms matching deleted tags that are no longer used. ') . '</p>';
$description .= '<p>' . t('If you do not want to delete redundant terms as part of this purge operation, un-check the option below. ') . '</p>';
$form['delete_policy']['#options'][COMMUNITY_TAGS_OPMODE_DELETE_ORPHAN_TERMS] = t('<em>Delete redundant terms</em>');
$form['delete_policy']['#default_value'][] = COMMUNITY_TAGS_OPMODE_DELETE_ORPHAN_TERMS;
}
}
}
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'] = 2;
return $confirm_form;
}