You are here

hook_install() and hook_unistall()

/**
* Implements hook_install().
*/
function example_install() {
  // Set default variables.
  variable_set('example_gmap', 1);
  variable_set('example_default_center_lat', 42.91455);
  variable_set('example_default_center_long', -75.569851);
  variable_set('example_default_gmap_zoom', 8);

  // Get localization function for installation as t() may be unavailable.
  $t = get_t();

  // Give user feedback.
  drupal_set_message($t('example variables created.'));
}

/**
* Implements hook_uninstall().
*/
function example_uninstall() {
  // Delete variables.
  variable_del('example_gmap');
  variable_del('example_default_center_lat');
  variable_del('example_default_center_long');
  variable_del('example_default_gmap_zoom');

  // Inform the user of the removal.
  $t = get_t();
  drupal_set_message($t('example variables removed.'));
}

code type: