mass_contact.install in Mass Contact 5.2
File
mass_contact.install
View source
<?php
function mass_contact_install() {
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
db_query("CREATE TABLE {mass_contact} (\n cid int unsigned NOT NULL auto_increment,\n category varchar(255) NOT NULL default '',\n recipients longtext NOT NULL,\n reply longtext NOT NULL,\n weight tinyint NOT NULL default '0',\n selected tinyint NOT NULL default '0',\n PRIMARY KEY (cid),\n UNIQUE KEY category (category)\n ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
break;
case 'pgsql':
db_query("CREATE TABLE {mass_contact} (\n cid serial CHECK (cid >= 0),\n category varchar(255) NOT NULL default '',\n recipients text NOT NULL default '',\n reply text NOT NULL default '',\n weight smallint NOT NULL default '0',\n selected smallint NOT NULL default '0',\n PRIMARY KEY (cid),\n UNIQUE (category)\n )");
break;
}
drupal_set_message(t('All tables and entries required by the Mass Contact module have been created.'));
}
function mass_contact_uninstall() {
db_query('DROP TABLE {mass_contact}');
db_query("DELETE FROM {variable} WHERE name LIKE 'mass_contact_%'");
}
function mass_contact_update_5200() {
$ret = array();
$ret[] = update_sql("UPDATE {variable} SET name = 'mass_contact_html_d' WHERE name = 'mass_contact_HTML_d'");
return $ret;
}
function mass_contact_update_5201() {
$ret = array();
$result = db_query('SELECT * FROM {permission}');
while ($permission = db_fetch_object($result)) {
if (strstr($permission->perm, 'access mass contact form')) {
$new_permission = str_replace('access mass contact form', 'send mass contact e-mails', $permission->perm);
$ret[] = update_sql('UPDATE {permission} SET perm = "' . $new_permission . '" WHERE rid = ' . $permission->rid . ' AND tid = ' . $permission->tid);
}
}
return $ret;
}