<?php
// $Id: whois.install,v 1.6 2010/01/19 15:02:59 helmo Exp $

/**
 * @file
 * Install, update and uninstall functions for the Whois module.
 */


/**
 * Implementation of hook_requirements().
 */
function whois_requirements($phase) {
  $requirements = array();
  $t = get_t();
  switch ($phase) {
    case 'install':
    case 'runtime':
      $path = drupal_get_path('module', 'whois') . '/phpwhois/whois.main.php';
      if (!file_exists($path)) {
        $requirements['whois'] = array(
          'title' => $t('Whois lookup'),
          'description' => $t("Whois module requires !phpwhois to do whois queries. !download and put it's contents in <em>modules/whois</em> directory (so that it looks something like this: <em>modules/whois/phpwhois/example.php</em>).", array('!phpwhois' => l('phpWhois library', 'http://phpwhois.sf.net/'), '!download' => l('Download phpWhois', 'http://sourceforge.net/project/showfiles.php?group_id=31207&package_id=23260'))),
          'severity' => $phase == 'install' ? REQUIREMENT_WARNING : REQUIREMENT_ERROR,
          'value' => $t('!phpwhois library missing', array('!phpwhois' => l('phpWhois', 'http://phpwhois.sf.net/'))),
        );
      }
  }
  return $requirements;
}

/**
 * Implementation of hook_uninstall().
 */
function whois_uninstall() {
  variable_del('whois_output_method');
  variable_del('whois_enable_ajax');
  variable_del('whois_hourly_threshold');
  variable_del('whois_log_watchdog');
}
