You are here

function avatar_selection_uninstall in Avatar Selection 5

Same name and namespace in other branches
  1. 5.2 avatar_selection.install \avatar_selection_uninstall()
  2. 6 avatar_selection.install \avatar_selection_uninstall()
  3. 7 avatar_selection.install \avatar_selection_uninstall()

Implementation of hook_uninstall().

File

./avatar_selection.install, line 34

Code

function avatar_selection_uninstall() {

  // delete the variables we created.
  variable_del('avatar_selection_disable_user_upload');
  variable_del('avatar_selection_force_user_avatar_reg');
  variable_del('avatar_selection_force_user_avatar');
  variable_del('avatar_selection_avatar_per_page');
  variable_del('avatar_selection_set_random_default');

  // delete the images
  $dir = file_create_path('avatar_selection') . '/';
  $listings = file_scan_directory($dir, '.*\\.(gif|GIF|Gif|jpg|JPG|Jpg|jpeg|JPEG|Jpeg|png|PNG|Png)', array(
    '.',
    '..',
    'CVS',
  ), 0, FALSE);
  if ($listings) {
    foreach ($listings as $listing) {
      file_delete($dir . $listing->basename);
    }
  }

  // drop the avatar_selection table
  switch ($GLOBALS['db_type']) {
    case 'mysqli':
    case 'mysql':
      $deleted = db_query("DROP TABLE IF EXISTS {avatar_selection}");
      break;
    case 'pgsql':
      $deleted = db_query("DROP TABLE {avatar_selection}");
      break;
  }

  // clear the cache tables
  cache_clear_all(null, 'cache');
  cache_clear_all(null, 'cache_filter');
  cache_clear_all(null, 'cache_menu');
  cache_clear_all(null, 'cache_page');
  watchdog('Avatar Selection', 'avatar_selection module removed');
}