View source
<?php
function mail_logger_install() {
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
db_query("CREATE TABLE {mail_logger} (\n mlid int(10) unsigned NOT NULL auto_increment,\n mailkey varchar(255) NOT NULL,\n `to` varchar(255) NOT NULL,\n `subject` varchar(255) NOT NULL,\n body text NOT NULL,\n `from` varchar(255) NOT NULL,\n headers text NOT NULL,\n date_sent int(10) unsigned NOT NULL,\n PRIMARY KEY (mlid),\n KEY `to` (`to`),\n KEY `from` (`from`),\n KEY `subject` (`subject`(20)),\n KEY date_sent (date_sent)\n ) /*!40100 DEFAULT CHARACTER SET utf8 */");
$max_weight = db_result(db_query("SELECT weight FROM {system} WHERE name LIKE 'mail_logger'"));
db_query("UPDATE {system} SET weight = %d WHERE name LIKE 'mail_logger' LIMIT 1", $max_weight + 999);
break;
case 'pgsql':
db_query("CREATE TABLE {mail_logger} (\n mlid int(10) unsigned NOT NULL auto_increment,\n mailkey varchar(255) NOT NULL,\n `to` varchar(255) NOT NULL,\n `subject` varchar(255) NOT NULL,\n body text NOT NULL,\n `from` varchar(255) NOT NULL,\n headers text NOT NULL,\n date_sent int(10) unsigned NOT NULL,\n PRIMARY KEY (mlid),\n KEY `to` (`to`),\n KEY `from` (`from`),\n KEY `subject` (`subject`(20)),\n KEY date_sent (date_sent)\n )");
$max_weight = db_result(db_query("SELECT weight FROM {system} WHERE name LIKE 'mail_logger'"));
db_query("UPDATE {system} SET weight = %d WHERE name LIKE 'mail_logger' LIMIT 1", $max_weight + 999);
break;
}
}
function mail_logger_enable() {
$max_weight = db_result(db_query("SELECT weight FROM {system} WHERE name LIKE 'mail_logger'"));
db_query("UPDATE {system} SET weight = %d WHERE name LIKE 'mail_logger' LIMIT 1", $max_weight + 999);
}
function mail_logger_uninstall() {
db_query("DROP TABLE {mail_logger}");
}