You are here

function gallery_assist_uninstall in Gallery Assist 6

Same name and namespace in other branches
  1. 7 gallery_assist.install \gallery_assist_uninstall()

Implementation of hook_uninstall().

File

./gallery_assist.install, line 469
Install, update and uninstall functions and DB tables for the Gallery Assist module.

Code

function gallery_assist_uninstall() {
  module_invoke('gallery_assist', 'delete_directory', variable_get('gallery_assist_directory', file_directory_path() . '/gallery_assist'));

  // Delete all entries in the file table.
  $query = "SELECT fid FROM {gallery_assist_item}";
  $result = db_query($query);
  while ($r = db_fetch_object($result)) {
    db_query('DELETE FROM {files} WHERE fid = %d', $r->fid);
  }

  // Delete all gallery assist nodes form the node and the node_revisions tables.
  $query = "SELECT n.nid FROM {node} n WHERE type = '%s'";
  $result = db_query(db_rewrite_sql($query, 'n', 'nid'), 'gallery_assist');
  while ($r = db_fetch_object($result)) {
    node_delete($r->nid);
  }

  // Delete all gallery assist settings variables.
  db_query("DELETE FROM {variable} WHERE name LIKE 'gallery_assist\\_%'");

  // Delete all database tables.
  drupal_uninstall_schema('gallery_assist');
}