You are here

function taxonomy_manager_terms_confirm_delete in Taxonomy Manager 5

Additional confirmation form for deletion

1 string reference to 'taxonomy_manager_terms_confirm_delete'
taxonomy_manager_voc in ./taxonomy_manager.module
returns either form for deletion confirm or the taxonomy manager form

File

./taxonomy_manager.module, line 833
Taxonomy Manager

Code

function taxonomy_manager_terms_confirm_delete($vid, $edit) {
  $selected = array();
  if (is_array($edit['taxonomy']['manager']['tree'])) {
    $selected = _taxonomy_manager_tree_get_selected_terms($edit['taxonomy']['manager']['tree']);
  }
  else {
    if (is_array($edit['selected_terms'])) {
      $selected = $edit['selected_terms'];
    }
  }
  $form['selected_terms'] = array(
    '#prefix' => '<ul>',
    '#suffix' => '</ul>',
    '#tree' => TRUE,
  );
  foreach ($selected as $tid) {
    $term = taxonomy_get_term($tid);
    $form['selected_terms'][$tid] = array(
      '#type' => 'hidden',
      '#value' => $tid,
      '#prefix' => '<li>',
      '#suffix' => check_plain($term->name) . "</li>\n",
    );
  }
  if (!count($selected)) {
    return array(
      'info' => array(
        '#value' => t('No terms selected.') . '<br />' . l(t('Back'), 'admin/content/taxonomy_manager/' . $vid),
      ),
    );
  }
  if (isset($edit['delete']['options']['delete_orphans']) || isset($edit['options']['delete_orphans'])) {
    $form['options'] = array(
      '#tree' => TRUE,
    );
    $form['options']['delete_orphans'] = array(
      '#type' => 'hidden',
      '#value' => TRUE,
    );
  }
  $form['vid'] = array(
    '#type' => 'hidden',
    '#value' => $vid,
  );
  $msg = isset($form['options']['delete_orphans']) ? t('Deleting a term will delete all its children if there are any. ') : '';
  $msg .= t('This action cannot be undone.');
  return confirm_form($form, t('Are you sure you want to delete the following terms: '), 'admin/content/taxonomy_manager/' . $vid, $msg, t('Delete terms'), t('Cancel'));
}