Skip to content
ms_fac.install 6.58 KiB
Newer Older

/**
 * @file
 */

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

  $has_curl = function_exists('curl_init');

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

  return $requirements;
}

/**
 * Implements hook_install().
 */
function ms_fac_install() {
  // Create random encryption key
  variable_set('ms_fac_encryption_key', drupal_get_private_key());
}

/**
 * Implements hook_uninstall().
 */
function ms_fac_uninstall() {

  // Delete related variables all at once.
  db_delete('variable')
    ->condition('name', 'ms_fac_%%', 'LIKE')
    ->execute();
}

/**
 * Implements hook_schema().
 ().
 */
function ms_fac_schema() {
  $schema['ms_fac_payment_profiles'] = array(
    'description' => 'Used to hold Customer Payment Profiles',
    'fields' => array(
      'id' => array(
        'description' => 'The unique ID.',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'uid' => array(
        'description' => 'The user ID',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'status' => array(
        'description' => 'The status',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'billToFirstName' => array(
        'description' => 'Billing First Name',
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
        'default' => '',
      ),
      'billToLastName' => array(
        'description' => 'Billing Last Name',
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
        'default' => '',
      ),
      'billToAddress' => array(
        'description' => 'Billing Address',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'billToCity' => array(
        'description' => 'Billing City',
        'type' => 'varchar',
        'length' => 64,
        'not null' => TRUE,
        'default' => '',
      ),
      'billToState' => array(
        'description' => 'Billing State ISO2',
        'type' => 'varchar',
        'length' => 16,
        'not null' => TRUE,
        'default' => '',
      ),
      'billToZip' => array(
        'description' => 'Billing Zip',
        'type' => 'varchar',
        'length' => 16,
        'not null' => TRUE,
        'default' => '',
      ),
      'billToCountry' => array(
        'description' => 'Billing Country ISO2',
        'type' => 'varchar',
        'length' => 16,
        'not null' => TRUE,
        'default' => '',
      ),
      'billToPhoneNumber' => array(
        'description' => 'Billing Phone',
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
        'default' => '',
      ),
      'billToFaxNumber' => array(
        'description' => 'Billing Fax',
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
        'default' => '',
      ),
      'cardNumber' => array(
        'description' => 'Credit Card Number',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'expirationMonth' => array(
        'description' => 'Expiration Month of the Card',
        'type' => 'varchar',
        'length' => 16,
        'not null' => TRUE,
        'default' => '',
      ),
      'expirationYear' => array(
        'description' => 'Expiration Year of the Card',
        'type' => 'varchar',
        'length' => 16,
        'not null' => TRUE,
        'default' => '',
      ),
    ),
    'indexes' => array(
      'uid' => array('uid'),
    ),
    'primary key' => array('id'),
  );

  $schema['ms_fac_shipping_profiles'] = array(
    'description' => 'Used to hold Customer Shipping Profiles',
    'fields' => array(
      'id' => array(
        'description' => 'The unique ID.',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'uid' => array(
        'description' => 'The user ID',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'status' => array(
        'description' => 'The status',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'shipToFirstName' => array(
        'description' => 'Shipping First Name',
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
        'default' => '',
      ),
      'shipToLastName' => array(
        'description' => 'Shipping Last Name',
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
        'default' => '',
      ),
      'shipToAddress' => array(
        'description' => 'Shipping Address',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'shipToCity' => array(
        'description' => 'Shipping City',
        'type' => 'varchar',
        'length' => 64,
        'not null' => TRUE,
        'default' => '',
      ),
      'shipToState' => array(
        'description' => 'Shipping State ISO2',
        'type' => 'varchar',
        'length' => 16,
        'not null' => TRUE,
        'default' => '',
      ),
      'shipToZip' => array(
        'description' => 'Shipping Zip',
        'type' => 'varchar',
        'length' => 16,
        'not null' => TRUE,
        'default' => '',
      ),
      'shipToCountry' => array(
        'description' => 'Shipping Country ISO2',
        'type' => 'varchar',
        'length' => 16,
        'not null' => TRUE,
        'default' => '',
      ),
      'shipToPhoneNumber' => array(
        'description' => 'Shipping Phone',
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
        'default' => '',
      ),
      'shipToFaxNumber' => array(
        'description' => 'Shipping Fax',
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
        'default' => '',
      ),
    ),
    'indexes' => array(
      'uid' => array('uid'),
    ),
    'primary key' => array('id'),
  );

  return $schema;
}

// ======================================
// Updates:
// ======================================