<?php
// $Id$

/**
 * Implementation of hook_install().
 */
function profile_map_install() {
  switch ($GLOBALS['db_type']) {
    case 'mysqli':
    case 'mysql':
      db_query("CREATE TABLE if not exists {profile_map} (
        fid int(11) NOT NULL,
        category varchar(32) NOT NULL,
        field varchar(32) NOT NULL,
        PRIMARY KEY (fid)
      ) TYPE=MyISAM /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
      break;

    case 'pgsql':
      db_query("CREATE TABLE if not exists {profile_map} (
        fid int(11) NOT NULL,
        category varchar(32) NOT NULL,
        field varchar(32) NOT NULL,
        PRIMARY KEY (fid)
      )");
      break;
  }
  drupal_set_message(t('Profile Map table installed. !Configure_Profile_Map', array(
    '!Configure_Profile_Map' => l('Configure Profile Map', 'admin/settings/profile_map')
  )));
}


/**
 * Implementation of hook_uninstall().
 */
function profile_map_uninstall() {
  db_query("DROP TABLE {profile_map}");
  $vars = array(
    'profile_map_name_view',
    'profile_map_name-label_view',
    'profile_map_address_view',
    'profile_map_address-label_view',
    'profile_map_phone_view',
    'profile_map_phone-label_view',
    'profile_map_messaging_view',
    'profile_map_messaging-label_view',
  );
  foreach ($vars as $var) {
    variable_del($var);
  }
  drupal_set_message(t('Profile Map table and variables removed.'));

  cache_clear_all();
}
