You are here

mailhandler.install in Mailhandler 5

File

mailhandler.install
View source
<?php

/**
 * Implementation of hook_install().
 */
function mailhandler_install() {
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      db_query("\n        CREATE TABLE {mailhandler} (\n          mid         int(10) unsigned not null auto_increment primary key,\n          mail        varchar(255) not null,\n          domain      varchar(255) not null,\n          port        int(5) unsigned not null,  \n          name        varchar(255) not null,\n          pass        varchar(255) not null,\n          security    tinyint unsigned not null,\n          replies     tinyint unsigned not null default '1',\n          fromheader  varchar(128),\n          commands    text,  \n          sigseparator  varchar(128),\n          enabled     tinyint,\n          folder varchar(255) not null,\n          imap tinyint unsigned not null,\n          mime VARCHAR (128),\n          mailto varchar(255) not null,\n          delete_after_read tinyint unsigned not null default '1',\n          extraimap varchar(255) not null,\n          format int(4) NOT NULL default '0',\n          KEY (mail)\n        ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
      break;
    case 'pgsql':
      db_query("\n        CREATE TABLE {mailhandler} (\n          mid         serial,\n          mail        text not null,\n          domain      text not null,\n          port        integer not null,  \n          name        text not null,\n          pass        text not null,\n          security    integer not null,\n          replies     integer not null default 1,\n          fromheader  text,\n          commands    text,  \n          sigseparator  text,\n          enabled     integer,\n          folder      text not null,\n          imap        integer not null,\n          mime        text,\n          mailto      text not null,\n          delete_after_read integer not null default 1,\n          extraimap text not null,\n          format integer NOT NULL default 0,\n          PRIMARY KEY (mid)\n        ); \n   \n   ");
      break;
  }
}

/**
 * Update database hooks
 */
function mailhandler_update_1() {
  return _system_update_utf8(array(
    'mailhandler',
  ));
}

/**
 * Check that the IMAP extension exists for PHP.
 */
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

Namesort descending Description
mailhandler_install Implementation of hook_install().
mailhandler_requirements Check that the IMAP extension exists for PHP.
mailhandler_update_1 Update database hooks