You are here

function avatar_selection_uninstall in Avatar Selection 7

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

Implements hook_uninstall().

Remove all the variables, files and sql tables used by the module.

File

./avatar_selection.install, line 133
The Avatar Selection module install file.

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');
  variable_del('avatar_selection_distinctive_avatars');
  variable_del('avatar_selection_imagecache_preset');

  // Delete the images.
  $query = db_select('avatar_selection', 'avs')
    ->fields('avs', array(
    'avatar',
    'fid',
    'name',
    'weight',
  ))
    ->distinct();
  $alias = $query
    ->join('file_managed', 'f', 'f.fid = avs.fid');
  $query
    ->addField('f', 'uri');
  $query
    ->addField('f', 'filename');
  $query
    ->addField('f', 'filemime');
  $query
    ->addField('f', 'filesize');
  $query
    ->addField('f', 'status');
  $query
    ->addField('f', 'timestamp');
  $result = $query
    ->execute();
  foreach ($result as $avatar) {
    file_delete($avatar);
  }

  // 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');
}