You are here

function delete_all_bulk_delete_content_submit in Delete all 5

Implementation of hook_submit for bulk_delete_content form

File

./delete_all.module, line 92

Code

function delete_all_bulk_delete_content_submit($form_id, $form_values) {

  //TODO: Display message with deletion statistics

  //Iterate and delete any taxonomy terms if present
  if (isset($form_values['vocabulary'])) {
    $vocabulary = $form_values['vocabulary'];
    foreach ($vocabulary as $v) {
      if ($v > 0) {

        //Get Vocabulary Info for message.
        $vocabulary_info = taxonomy_get_vocabulary($v);

        //Get Array of terms to delete
        $terms = _delete_all_get_terms_by_vid($v);

        //Iterate through terms and delete them
        foreach ($terms as $term) {
          taxonomy_del_term($term);
        }
        drupal_set_message("You have deleted " . count($terms) . ' terms of type ' . $vocabulary_info->name . '.');
      }
    }
  }

  //Iterate and delete nodes by type
  if (isset($form_values['node_types'])) {
    $node_types = $form_values['node_types'];

    //$nodes = array();
    foreach ($node_types as $t) {
      if (gettype($t) == 'string') {
        $nodes = _delete_all_get_nodes_by_type($t);
        foreach ($nodes as $n) {
          node_delete($n);
        }
      }
    }
  }
  return "admin/settings/bulk_delete/complete";
}