<?php

/**
 * @file
 * Install file for Mail reroute module.
 */

/*
 * Implementation of hook_install().
 *
function advanced_mail_reroute_install() {
  
}
*/

/**
 * Implementation of hook_uninstall().
 */
function advanced_mail_reroute_uninstall() {  
  $vars = array(
    'advanced_mail_reroute_default_rule',
    'advanced_mail_reroute_primary_email',
    'advanced_mail_reroute_override',
    'advanced_mail_reroute_enable_logging'
  );
  foreach ($vars as $var) {
    variable_del($var);
  }
}

/**
 * Implementation of hook_schema()
 */
function advanced_mail_reroute_schema() {
  $schema = array();
	
  $schema['advanced_mail_reroute_rules'] = array(
    'description' => 'Stores reroute rules for advanced_mail_reroute module.',
    'fields' => array(
      'mailkey' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE
      ),
      'reroute_rule' => array(
        'type' =>  'int',
        'size' => 'tiny',
        'not null' => TRUE
      ),
      'email' => array(
        'type' => 'text',
        'not null' => TRUE
      )
    ),
    'primary key' => array('mailkey'),
    'indexes' => array(
      'mailkey' => array('mailkey')
    )
  );
  $schema['advanced_mail_reroute_log'] = array(
    'description' => 'Stores logs of activity recorded by advanced_mail_reroute module.',
    'fields' => array(
      'id' => array(
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE
      ),
      'timestamp' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE
      ),
      'mailkey' => array(
        'type' => 'text',
        'not null' => TRUE
      ),
      'from_email' => array(
        'type' => 'text',
        'not null' => TRUE
      ),
      'to_email' => array(
        'type' => 'text',
        'not null' => TRUE
      ),
      'reroute_rule' => array(
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE
      ),
      'reroute_email' => array(
        'type' => 'text',
        'not null' => TRUE
      )
    ),
    'primary key' => array('id')
  );
  
  return $schema;
}
