You are here

commerce_billy_mail.install in Commerce Billy Mail 7

Installation functions for commerce_billy_mail

File

commerce_billy_mail.install
View source
<?php

/**
 * @file
 * Installation functions for commerce_billy_mail
 */

/**
 * Implements hook_install().
 */
function commerce_billy_mail_install() {

  // Set general settings.
  variable_set('commerce_billy_mail_attach_pdf_invoice', module_exists('commerce_billy_pdf invoice'));
  variable_set('commerce_billy_mail_from', NULL);
  variable_set('commerce_billy_mail_cc', '');
  variable_set('commerce_billy_mail_bcc', '');
  variable_set('commerce_billy_mail_subject', t('Your invoice.'));
  variable_set('commerce_billy_mail_body', t('Find your invoice attached.'));
  variable_set('commerce_billy_mail_plaintext', 'FALSE');
}

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

  // Remove the general settings.
  $result = db_query("SELECT name FROM {variable} WHERE name LIKE 'commerce_billy_mail_%'");

  // Exclude variables here!!
  $exclude = array();
  while ($var_name = $result
    ->fetchAssoc()) {
    if (!in_array($var_name['name'], $exclude)) {
      variable_del($var_name['name']);
    }
  }
}

/**
 * Implements hook_requirements().
 */
function commerce_billy_mail_requirements($phase) {
  $requirements = array();
  $t = get_t();
  if ($phase == 'install') {
    if (!module_exists('mimemail') && !module_exists('smtp')) {
      $requirements['c_b_m_mailsystem'] = array(
        'title' => 'Commerce Billy Mail',
        'description' => $t('To send invoices as e-mail attachments, the installation of <a href="https://drupal.org/project/mimemail">Mime Mail</a> or <a href="https://drupal.org/project/smtp">smtp</a> is required.'),
        'value' => VERSION,
        'severity' => REQUIREMENT_WARNING,
      );
    }
  }
  return $requirements;
}