<?php

/**
 * Implementaton of hook_install
 */
function better_messages_install() {
  drupal_set_message(t("Better Messages is installed successfully.<br />Click here to visit the <a href=@href>settings page</a>!", array('@href' => base_path() . 'admin/config/user-interface/better-messages')));
}

/**
 * Implementaton of hook_uninstall
 */
function better_messages_uninstall() {
  db_query("DELETE FROM {variable} WHERE name LIKE 'better_messages_%'");
  db_query("DELETE FROM {variable} WHERE name = 'better_messages'");
  db_query("DELETE FROM {system} WHERE name = 'better_messages'");
}

function better_messages_update_6000() {  
  // Rename poorly named variables.
  $settings_new = array(
    'position' => variable_get('better_messages_pos', 'center'), 'vertical' => variable_get('better_messages_vertical', 0),
    'horizontal' => variable_get('better_messages_horizontal', 10), 'fixed'  => variable_get('better_messages_fixed', 1),
    'width' => variable_get('better_messages_width', '400px'), 'autoclose' => variable_get('better_messages_autoclose', 0),
    'opendelay' => variable_get('better_messages_open_delay', 0.3), 'disable_autoclose' => variable_get('better_messages_disable_autoclose', 0),
    'popin' => array('effect' => variable_get('better_messages_popin_effect', 'fadeIn'), 'duration' => variable_get('better_messages_popin_duration', 'slow')),
    'popout' => array('effect' => variable_get('better_messages_popout_effect', 'fadeOut'), 'duration' => variable_get('better_messages_popout_duration', 'slow')),
    'extra' => array(
      'pages' => variable_get('better_messages_pages', ''),
      'visibility' => variable_get('better_messages_visibility', 0),
    )
  );
  db_query("DELETE FROM {variable} WHERE name LIKE 'better_messages_%'");
  variable_set('better_messages', $settings_new);
  return array();
}
