mailhandler.install in Mailhandler 6
Same filename and directory in other branches
Install, uninstall, schema and update functions for Mailhandler module.
Describe the schema in use by this module, and define install, update and uninstall functions.
File
mailhandler.installView source
<?php
/**
* @file
* Install, uninstall, schema and update functions for Mailhandler module.
*
* Describe the schema in use by this module, and define install, update and
* uninstall functions.
*/
/**
* Implementation of hook_install().
*/
function mailhandler_install() {
drupal_install_schema('mailhandler');
}
/**
* Implementation of hook_uninstall().
*/
function mailhandler_uninstall() {
// Remove module variables.
$variables = array(
'mailhandler_default_type',
'mailhandler_max_retrieval',
'mailhandler_default_encoding',
'mailhandler_watchdog_level',
);
foreach ($variables as $varname) {
variable_del($varname);
}
drupal_uninstall_schema('mailhandler');
}
/**
* Implementation of hook_schema().
*/
function mailhandler_schema() {
$schema = array();
$schema['mailhandler'] = array(
'description' => t('Mailhandler table'),
'fields' => array(
'mid' => array(
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
'disp-width' => '10',
),
'mail' => array(
'type' => 'varchar',
'length' => '255',
'not null' => TRUE,
),
'domain' => array(
'type' => 'varchar',
'length' => '255',
'not null' => TRUE,
),
'port' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'disp-width' => '5',
),
'name' => array(
'type' => 'varchar',
'length' => '255',
'not null' => TRUE,
),
'pass' => array(
'type' => 'varchar',
'length' => '255',
'not null' => TRUE,
),
'security' => array(
'type' => 'int',
'unsigned' => TRUE,
'size' => 'tiny',
'not null' => TRUE,
),
'replies' => array(
'type' => 'int',
'unsigned' => TRUE,
'size' => 'tiny',
'not null' => TRUE,
'default' => 1,
),
'fromheader' => array(
'type' => 'varchar',
'length' => '128',
'not null' => FALSE,
),
'commands' => array(
'type' => 'text',
'not null' => FALSE,
),
'sigseparator' => array(
'type' => 'varchar',
'length' => '128',
'not null' => FALSE,
),
'enabled' => array(
'type' => 'int',
'size' => 'tiny',
'not null' => FALSE,
),
'folder' => array(
'type' => 'varchar',
'length' => '255',
'not null' => TRUE,
),
'imap' => array(
'type' => 'int',
'unsigned' => TRUE,
'size' => 'tiny',
'not null' => TRUE,
),
'mime' => array(
'type' => 'varchar',
'length' => '128',
'not null' => FALSE,
),
'mailto' => array(
'type' => 'varchar',
'length' => '255',
'not null' => TRUE,
),
'delete_after_read' => array(
'type' => 'int',
'unsigned' => TRUE,
'size' => 'tiny',
'not null' => TRUE,
'default' => 1,
),
'extraimap' => array(
'type' => 'varchar',
'length' => '255',
'not null' => TRUE,
),
'format' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'authentication' => array(
'type' => 'varchar',
'length' => '255',
'not null' => TRUE,
'default' => 'mailhandler_default',
),
),
'primary key' => array(
'mid',
),
'indexes' => array(
'mail' => array(
'mail',
),
),
);
return $schema;
}
/**
* Update database hooks
*/
/**
* First update for Drupal 6.
*
* This is no longer needed, but it's probably better to leave this function in
* place so the sequence of future updates will not be broken.
*/
function mailhandler_update_1() {
//return _system_update_utf8(array('mailhandler'));
}
/**
* Add authentication method field to module schema.
*
* Update introduced for release 6.1.9, when authentication is set as pluggable
* system in the module.
*
* Issue: http://drupal.org/node/11962 : Virtual Email Passphrase Authentication
* Commit: http://drupal.org/cvs?commit=322700
*/
function mailhandler_update_6001() {
$ret = array();
db_add_field($ret, 'mailhandler', 'authentication', array(
'type' => 'varchar',
'not null' => TRUE,
'length' => '255',
'default' => 'mailhandler_default',
));
return $ret;
}
/**
* Check that the IMAP extension exists for PHP.
*
* @todo: currently the module is unable to work without IMAP extension, but for
* convenience, I'm still allowing the module to be enabled so parts of the main
* functionality can be automatically tested by PIFR. This must be changed when
* the IMAP extension is no longer a dependency for this module to work.
*/
function mailhandler_requirements($phase) {
// Ensure translations don't break at install time
$t = get_t();
$has_imap = function_exists('imap_open');
$requirements['mailhandler'] = array(
'title' => $t('IMAP'),
'description' => $t("Mailhandler requires that PHP's !ext is enabled in order to function properly.", array(
'!ext' => l('IMAP extension', 'http://www.php.net/imap'),
)),
'value' => $has_imap ? $t('Enabled') : $t('Not found'),
'severity' => $has_imap ? REQUIREMENT_OK : REQUIREMENT_ERROR,
);
return $requirements;
}
Functions
Name | Description |
---|---|
mailhandler_install | Implementation of hook_install(). |
mailhandler_requirements | Check that the IMAP extension exists for PHP. |
mailhandler_schema | Implementation of hook_schema(). |
mailhandler_uninstall | Implementation of hook_uninstall(). |
mailhandler_update_1 | First update for Drupal 6. |
mailhandler_update_6001 | Add authentication method field to module schema. |