print.install 4.56 KB
Newer Older
jcnventura's avatar
jcnventura committed
1 2
<?php

jcnventura's avatar
jcnventura committed
3 4
/**
 * @file
jcnventura's avatar
jcnventura committed
5
 * Install, update and uninstall functions for the print module.
6 7
 *
 * @ingroup print
jcnventura's avatar
jcnventura committed
8 9
 */

jcnventura's avatar
jcnventura committed
10
/**
11
 * Implements hook_install().
jcnventura's avatar
jcnventura committed
12 13
 */
function print_install() {
14 15
  $t = get_t();
  drupal_set_message($t('Printer-friendly Page settings are available under !link',
jcnventura's avatar
jcnventura committed
16
    array('!link' => l($t('Administration > Configuration > User interface > Printer, email and PDF versions'), 'admin/config/user-interface/print'))
jcnventura's avatar
jcnventura committed
17 18 19
  ));
}

20 21 22 23 24 25 26 27 28 29 30 31 32 33
/**
 * Implements hook_enable().
 */
function print_enable() {
  // Module weight
  db_update('system')
    ->fields(array(
      'weight' => 0,
    ))
    ->condition('type', 'module')
    ->condition('name', 'print')
    ->execute();
}

jcnventura's avatar
jcnventura committed
34
/**
35
 * Implements hook_uninstall().
jcnventura's avatar
jcnventura committed
36 37 38 39 40 41
 */
function print_uninstall() {
  variable_del('print_settings');
  variable_del('print_sourceurl_settings');
  variable_del('print_html_settings');
  variable_del('print_robot_settings');
42
  variable_del('print_logo_url');
43
  variable_del('print_logo_options');
44
  variable_del('print_css');
45
  variable_del('print_keep_theme_css');
46
  variable_del('print_urls');
47
  variable_del('print_urls_anchors');
48 49 50 51 52 53
  variable_del('print_comments');
  variable_del('print_newwindow');
  variable_del('print_sourceurl_enabled');
  variable_del('print_sourceurl_date');
  variable_del('print_sourceurl_forcenode');
  variable_del('print_html_show_link');
54
  variable_del('print_html_link_pos');
55
  variable_del('print_html_link_teaser');
56 57 58 59 60 61 62 63
  variable_del('print_html_node_link_visibility');
  variable_del('print_html_node_link_pages');
  variable_del('print_html_link_class');
  variable_del('print_html_sys_link_visibility');
  variable_del('print_html_sys_link_pages');
  variable_del('print_html_book_link');
  variable_del('print_html_new_window');
  variable_del('print_html_sendtoprinter');
64
  variable_del('print_html_windowclose');
65
  variable_del('print_display_sys_urllist');
66 67 68
  variable_del('print_robots_noindex');
  variable_del('print_robots_nofollow');
  variable_del('print_robots_noarchive');
69 70 71 72 73 74 75 76
  variable_del('print_footer_options');
  variable_del('print_footer_user');
  variable_del('print_html_link_text');
  variable_del('print_html_link_use_alias');
  variable_del('print_text_links');
  variable_del('print_text_published');
  variable_del('print_text_retrieved');
  variable_del('print_text_source_url');
jcnventura's avatar
jcnventura committed
77
  $settings = db_query("SELECT name FROM {variable} WHERE name LIKE 'print\_display\_%'");
78
  foreach ($settings as $variable) {
jcnventura's avatar
jcnventura committed
79 80 81
    variable_del($variable->name);
  }
}
82 83

/**
84
 * Implements hook_schema().
85
 */
86 87
function print_schema() {
  $schema['print_node_conf'] = array(
jcnventura's avatar
jcnventura committed
88
    'description' => 'Printer-friendly version node-specific configuration settings',
89 90 91 92 93
    'fields' => array(
      'nid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
jcnventura's avatar
jcnventura committed
94
        'description' => 'The {node}.nid of the node.',
95 96 97 98 99
      ),
      'link' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
jcnventura's avatar
jcnventura committed
100
        'default' => 1,
101
        'size' => 'tiny',
jcnventura's avatar
jcnventura committed
102
        'description' => 'Show link',
103 104 105 106 107
      ),
      'comments' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
jcnventura's avatar
jcnventura committed
108
        'default' => 1,
109
        'size' => 'tiny',
jcnventura's avatar
jcnventura committed
110
        'description' => 'Show link in individual comments',
111 112 113 114 115
      ),
      'url_list' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
jcnventura's avatar
jcnventura committed
116
        'default' => 1,
117
        'size' => 'tiny',
jcnventura's avatar
jcnventura committed
118
        'description' => 'Show Printer-friendly URLs list',
119 120 121 122
      ),
    ),
    'primary key' => array('nid'),
  );
123

124
  $schema['print_page_counter'] = array(
jcnventura's avatar
jcnventura committed
125
    'description' => 'Printer-friendly version access counter',
126 127 128 129 130
    'fields' => array(
      'path' => array(
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
jcnventura's avatar
jcnventura committed
131
        'description' => 'Page path',
132 133 134 135 136 137 138
      ),
      'totalcount' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'size' => 'big',
jcnventura's avatar
jcnventura committed
139
        'description' => 'Number of page accesses',
140 141 142 143 144 145
      ),
      'timestamp' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
jcnventura's avatar
jcnventura committed
146
        'description' => 'Last access',
147 148 149 150
      ),
    ),
    'primary key' => array('path'),
  );
151

152
  return $schema;
153
}
154 155 156 157 158 159 160

/**
 * Remove hardcoded numeric deltas from all blocks
 */
function print_update_7000(&$sandbox) {
  $renamed_deltas = array(
    'print' => array(
jcnventura's avatar
jcnventura committed
161 162
      '0' => 'print-links',
      '1' => 'print-top',
163 164 165 166 167
    ),
  );

  update_fix_d7_block_deltas($sandbox, $renamed_deltas, array());
}
168 169

/**
170
 * Empty update
171 172 173
 */
function print_update_7100(&$sandbox) {
}