You are here

multiple_email.install in Multiple E-mail Addresses 6

Install file for multiple_email module

File

multiple_email.install
View source
<?php

/**
 * @file
 * Install file for multiple_email module
 */

/**
 * Implementation of hook_install().
 */
function multiple_email_install() {
  drupal_install_schema('multiple_email');

  // Now import current users' emails.
  db_query("\n    INSERT INTO {multiple_email}\n      (uid, email, time_registered, confirmed)\n    SELECT\n      uid,\n      mail,\n      created,\n      1\n    FROM {users}\n    WHERE uid != 0\n    AND mail != ''\n    GROUP BY mail\n  ");
}

/**
 * Implementation of hook_uninstall().
 */
function multiple_email_uninstall() {
  drupal_uninstall_schema('multiple_email');
  $variables = array(
    'multiple_email_hide_field',
    'multiple_email_edit_emails',
    'multiple_email_confirm_deadline',
    'multiple_email_confirm_attempts',
    'multiple_email_confirmation_subject',
    'multiple_email_confirmation_body',
    'multiple_email_expire_subject',
    'multiple_email_expire_body',
  );
  foreach ($variables as $key) {
    variable_del($key);
  }
}

/**
 * Implementation of hook_enable().
 */
function multiple_email_enable() {
  drupal_set_message(t("Multiple E-mail settings are available under !link", array(
    '!link' => l('Administer > Site configuration > Multiple E-mail Settings ', 'admin/settings/multiple-email'),
  )));
}
function multiple_email_schema() {
  $schema['multiple_email'] = array(
    'description' => 'The base table for multiple email.',
    'fields' => array(
      'eid' => array(
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'uid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'email' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
      ),
      'time_registered' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'confirmed' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'confirm_code' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
      ),
      'time_code_generated' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'attempts' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
    'indexes' => array(
      'uid' => array(
        'uid',
      ),
    ),
    'unique keys' => array(
      'email' => array(
        'email',
      ),
    ),
    'primary key' => array(
      'eid',
    ),
  );
  return $schema;
}

Functions