You are here

function ad_image_uninstall in Advertisement 7

Same name and namespace in other branches
  1. 5.2 image/ad_image.install \ad_image_uninstall()
  2. 5 image/ad_image.install \ad_image_uninstall()
  3. 6.3 image/ad_image.install \ad_image_uninstall()
  4. 6 image/ad_image.install \ad_image_uninstall()
  5. 6.2 image/ad_image.install \ad_image_uninstall()

Implements hook_uninstall().

File

image/ad_image.install, line 128
Ad_image module database schema.

Code

function ad_image_uninstall() {
  $result = db_query('SELECT nid FROM {node} n WHERE n.type = :type', array(
    ':type' => 'distribution',
  ));
  $nids = array();
  foreach ($result as $row) {
    $nids[] = $row->nid;
  }

  // Delete field instances
  $fields = _ad_image_installed_instances();
  foreach ($fields as $field) {
    field_delete_instance($field);
  }

  // Delete field definitions
  $fields = array_keys(_ad_image_installed_fields());
  foreach ($fields as $field) {
    field_delete_field($field);
  }

  // Purge all field infromation
  field_purge_batch(1000);

  // Delete all ad_image content.
  $result = db_query("SELECT aid FROM {ad_image}");
  foreach ($result as $row) {
    node_delete($row->aid);
  }
}