print_mail.install in Printer, email and PDF versions 5.4
Same filename and directory in other branches
Install file of the print_mail module
File
print_mail/print_mail.installView source
<?php
/**
* @file
* Install file of the print_mail module
*
* @ingroup print
*/
/**
* Implementation of hook_install().
*/
function print_mail_install() {
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
db_query("CREATE TABLE {print_mail_node_conf} (\n nid int(10) unsigned NOT NULL,\n link tinyint(3) unsigned NOT NULL default '1',\n comments tinyint(3) unsigned NOT NULL default '1',\n url_list tinyint(3) unsigned NOT NULL default '1',\n PRIMARY KEY (nid)\n ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
db_query("CREATE TABLE {print_mail_page_counter} (\n path varchar(128) NOT NULL,\n totalcount bigint(20) unsigned NOT NULL default '0',\n timestamp int(10) unsigned NOT NULL default '0',\n sentcount bigint(20) unsigned NOT NULL default '0',\n sent_timestamp int(10) unsigned NOT NULL default '0',\n PRIMARY KEY (path)\n ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
break;
case 'pgsql':
db_query("CREATE TABLE {print_mail_node_conf} (\n nid int_unsigned NOT NULL,\n link smallint NOT NULL default '1',\n comments smallint_unsigned NOT NULL default '1',\n url_list smallint_unsigned NOT NULL default '1',\n PRIMARY KEY (nid)\n )");
db_query("CREATE TABLE {print_mail_page_counter} (\n path varchar(128) NOT NULL,\n totalcount bigint NOT NULL default '0',\n timestamp int_unsigned NOT NULL default '0',\n sentcount bigint NOT NULL default '0',\n sent_timestamp int_unsigned NOT NULL default '0',\n PRIMARY KEY (path)\n )");
break;
}
// Module weight
db_query("UPDATE {system} SET weight = 1 WHERE name = 'print_mail'");
}
/**
* Implementation of hook_uninstall().
*/
function print_mail_uninstall() {
db_query('DROP TABLE {print_mail_node_conf}');
db_query('DROP TABLE {print_mail_page_counter}');
variable_del('print_mail_settings');
variable_del('print_mail_show_link');
variable_del('print_mail_link_pos');
variable_del('print_mail_link_teaser');
variable_del('print_mail_node_link_visibility');
variable_del('print_mail_node_link_pages');
variable_del('print_mail_link_class');
variable_del('print_mail_sys_link_visibility');
variable_del('print_mail_sys_link_pages');
variable_del('print_mail_book_link');
variable_del('print_mail_hourly_threshold');
variable_del('print_mail_teaser_default');
variable_del('print_mail_teaser_choice');
variable_del('print_mail_link_text');
variable_del('print_mail_link_use_alias');
variable_del('print_mail_text_confirmation');
variable_del('print_mail_text_message');
variable_del('print_mail_text_subject');
variable_del('print_mail_text_content');
variable_del('print_mail_job_queue');
$settings = db_query("SELECT name FROM {variable} WHERE name LIKE 'print\\_mail\\_display\\_%'");
while ($variable = db_fetch_object($settings)) {
variable_del($variable->name);
}
}
/**
* Update to version 5.x-4.0
*/
function print_mail_update_6000() {
global $conf;
$ret = array();
if (isset($conf['print_mail_settings'])) {
$print_mail_settings = variable_get('print_mail_settings', '');
variable_set('print_mail_link_pos', array(
'link' => $print_html_settings['show_link'] ? 'link' : 0,
));
variable_set('print_mail_show_link', max(1, $print_mail_settings['show_link']));
variable_set('print_mail_node_link_visibility', $print_mail_settings['node_link_visibility']);
variable_set('print_mail_node_link_pages', $print_mail_settings['node_link_pages']);
variable_set('print_mail_link_class', $print_mail_settings['link_class']);
variable_set('print_mail_sys_link_visibility', $print_mail_settings['sys_link_visibility']);
variable_set('print_mail_sys_link_pages', $print_mail_settings['sys_link_pages']);
variable_set('print_mail_book_link', $print_mail_settings['book_link']);
variable_set('print_mail_teaser_default', $print_mail_settings['teaser_default']);
variable_set('print_mail_teaser_choice', $print_mail_settings['teaser_choice']);
variable_del('print_mail_settings');
}
return $ret;
}
/**
* Update to version 5.x-4.1
*/
function print_mail_update_6001() {
$ret = array();
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
db_query("CREATE TABLE {print_mail_node_conf} (\n nid int(10) unsigned NOT NULL,\n link tinyint(3) unsigned NOT NULL default '1',\n comments tinyint(3) unsigned NOT NULL default '1',\n url_list tinyint(3) unsigned NOT NULL default '1',\n PRIMARY KEY (nid)\n ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
db_query("CREATE TABLE {print_mail_page_counter} (\n path varchar(128) NOT NULL,\n totalcount bigint(20) unsigned NOT NULL default '0',\n timestamp int(10) unsigned NOT NULL default '0',\n sentcount bigint(20) unsigned NOT NULL default '0',\n sent_timestamp int(10) unsigned NOT NULL default '0',\n PRIMARY KEY (path)\n ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
break;
case 'pgsql':
db_query("CREATE TABLE {print_mail_node_conf} (\n nid int_unsigned NOT NULL,\n link smallint NOT NULL default '1',\n comments smallint_unsigned NOT NULL default '1',\n url_list smallint_unsigned NOT NULL default '1',\n PRIMARY KEY (nid)\n )");
db_query("CREATE TABLE {print_mail_page_counter} (\n path varchar(128) NOT NULL,\n totalcount bigint NOT NULL default '0',\n timestamp int_unsigned NOT NULL default '0',\n sentcount bigint NOT NULL default '0',\n sent_timestamp int_unsigned NOT NULL default '0',\n PRIMARY KEY (path)\n )");
break;
}
return $ret;
}
/**
* Update to version 5.x-4.2
*/
function print_mail_update_6003() {
// Delete custom text strings set to the default
$ret = array();
$vars = array(
'print_mail_link_text' => 'Send to friend',
'print_mail_text_subject' => '!user has sent you a message from !site',
'print_mail_text_message' => 'Message from sender',
'print_mail_text_content' => '',
'print_mail_text_confirmation' => 'Thank you for spreading the word about !site.',
);
$t = get_t();
foreach ($vars as $name => $default) {
if (variable_get($name, '') == $t($default)) {
variable_del($name);
}
}
menu_rebuild();
return $ret;
}
/**
* Update to version 5.x-4.8
*/
function print_mail_update_6004() {
// add new 'access send to friend' permission to any role which has 'access print'
$ret = array();
$dbret = db_query('SELECT * FROM {permission}');
while ($role = db_fetch_object($dbret)) {
if (strpos($role->perm, 'access print') !== FALSE) {
$role->perm = db_escape_string('access send to friend, ' . $role->perm);
$ret[] = update_sql("UPDATE {permission} SET perm = '{$role->perm}' WHERE rid = {$role->rid}");
}
}
return $ret;
}
/**
* Update to version 5.x-4.10
*/
function print_mail_update_6006() {
$ret = array();
// Module weight
$ret[] = update_sql("UPDATE {system} SET weight = 1 WHERE name = 'print_mail'");
return $ret;
}
/**
* Update to version 5.x-4.10
*/
function print_mail_update_6007() {
$ret = array();
foreach (node_get_types() as $key => $value) {
$print_mail_display = variable_get('print_mail_display_' . $value->type, 1);
$print_mail_display_comment = variable_get('print_mail_display_comment_' . $value->type, 0);
$print_mail_display_urllist = variable_get('print_mail_display_urllist_' . $value->type, 1);
if (!$print_mail_display || $print_mail_display_comment || !$print_mail_display_urllist) {
$result = db_query("SELECT n.nid, link, comments, url_list from {node} AS n LEFT JOIN {print_mail_node_conf} AS pnc ON n.nid = pnc.nid WHERE type = '%s'", $value->type);
while ($conf = db_fetch_object($result)) {
if ($conf->link != NULL && $conf->comments != NULL && $conf->url_list != NULL) {
$conf->link = !$print_mail_display ? 0 : $conf->link;
$conf->comments = $print_mail_display_comment ? 1 : $conf->comments;
$conf->url_list = !$print_mail_display_urllist ? 0 : $conf->url_list;
$ret[] = update_sql("UPDATE {print_mail_node_conf} SET link = {$conf->link}, comments = {$conf->comments}, url_list = {$conf->url_list} WHERE nid = {$conf->nid}");
}
else {
$ret[] = update_sql("INSERT INTO {print_mail_node_conf} (nid, link, comments, url_list) VALUES ({$conf->nid}, {$print_mail_display}, {$print_mail_display_comment}, {$print_mail_display_urllist})");
}
}
}
}
return $ret;
}
Functions
Name | Description |
---|---|
print_mail_install | Implementation of hook_install(). |
print_mail_uninstall | Implementation of hook_uninstall(). |
print_mail_update_6000 | Update to version 5.x-4.0 |
print_mail_update_6001 | Update to version 5.x-4.1 |
print_mail_update_6003 | Update to version 5.x-4.2 |
print_mail_update_6004 | Update to version 5.x-4.8 |
print_mail_update_6006 | Update to version 5.x-4.10 |
print_mail_update_6007 | Update to version 5.x-4.10 |