<?php

/**
 * @file
 * Handles installing, uninstalling, and updating Authorize.net settings.
 */

/**
 * Implements hook_requirements().
 */
function uc_authorizenet_requirements($phase) {
  $t = get_t();

  $has_curl = function_exists('curl_init');

  $requirements['uc_authorizenet_curl'] = array(
    'title' => $t('cURL'),
    'value' => $has_curl ? $t('Enabled') : $t('Not found'),
  );
  if (!$has_curl) {
    $requirements['uc_authorizenet_curl']['severity'] = REQUIREMENT_ERROR;
    $requirements['uc_authorizenet_curl']['description'] = $t("Authorize.net requires the PHP <a href='!curl_url'>cURL</a> library.", array('!curl_url' => 'http://php.net/manual/en/curl.setup.php'));
  }

  return $requirements;
}

function uc_authorizenet_uninstall() {
  // Delete related variables all at once.
  db_query("DELETE FROM {variable} WHERE name LIKE 'uc_authnet_%%'");
}

/**
 * Implements hook_update_last_removed().
 */
function uc_authorizenet_update_last_removed() {
  return 3;
}
