Project

General

Profile

Paste
Download (5.72 KB) Statistics
| Branch: | Revision:

root / drupal7 / sites / all / modules / print / print.install @ 76bdcd04

1
<?php
2

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

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

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

    
34
/**
35
 * Implements hook_uninstall().
36
 */
37
function print_uninstall() {
38
  variable_del('print_comments');
39
  variable_del('print_css');
40
  variable_del('print_footer_options');
41
  variable_del('print_footer_user');
42
  variable_del('print_html_display_sys_urllist');
43
  variable_del('print_html_link_text');
44
  variable_del('print_html_link_text_enabled');
45
  variable_del('print_html_new_window');
46
  variable_del('print_html_sendtoprinter');
47
  variable_del('print_html_windowclose');
48
  variable_del('print_keep_theme_css');
49
  variable_del('print_logo_options');
50
  variable_del('print_logo_url');
51
  variable_del('print_newwindow');
52
  variable_del('print_robots_noarchive');
53
  variable_del('print_robots_nofollow');
54
  variable_del('print_robots_noindex');
55
  variable_del('print_sourceurl_date');
56
  variable_del('print_sourceurl_enabled');
57
  variable_del('print_sourceurl_forcenode');
58
  variable_del('print_urls');
59
  variable_del('print_urls_anchors');
60

    
61
  variable_del('print_html_book_link');
62
  variable_del('print_html_link_class');
63
  variable_del('print_html_link_pos');
64
  variable_del('print_html_link_teaser');
65
  variable_del('print_html_link_use_alias');
66
  variable_del('print_html_show_link');
67
  variable_del('print_html_sys_link_pages');
68
  variable_del('print_html_sys_link_visibility');
69

    
70
  $settings = db_query("SELECT name FROM {variable} WHERE name LIKE 'print\_html\_display\_%'");
71
  foreach ($settings as $variable) {
72
    variable_del($variable->name);
73
  }
74
}
75

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

    
117
  $schema['print_page_counter'] = array(
118
    'description' => 'Printer-friendly version access counter',
119
    'fields' => array(
120
      'path' => array(
121
        'type' => 'varchar',
122
        'length' => 255,
123
        'not null' => TRUE,
124
        'description' => 'Page path',
125
      ),
126
      'totalcount' => array(
127
        'type' => 'int',
128
        'unsigned' => TRUE,
129
        'not null' => TRUE,
130
        'default' => 0,
131
        'size' => 'big',
132
        'description' => 'Number of page accesses',
133
      ),
134
      'timestamp' => array(
135
        'type' => 'int',
136
        'unsigned' => TRUE,
137
        'not null' => TRUE,
138
        'default' => 0,
139
        'description' => 'Last access',
140
      ),
141
    ),
142
    'primary key' => array('path'),
143
  );
144

    
145
  return $schema;
146
}
147

    
148
/**
149
 * Remove hardcoded numeric deltas from all blocks.
150
 */
151
function print_update_7000(&$sandbox) {
152
  $renamed_deltas = array(
153
    'print' => array(
154
      '0' => 'print-links',
155
      '1' => 'print-top',
156
    ),
157
  );
158

    
159
  update_fix_d7_block_deltas($sandbox, $renamed_deltas, array());
160
}
161

    
162
/**
163
 * Enable the print UI module.
164
 */
165
function print_update_7199(&$sandbox) {
166
  module_enable(array('print_ui'), FALSE);
167
}
168

    
169
/**
170
 * Delete old variables.
171
 */
172
function print_update_7200(&$sandbox) {
173
  variable_del('print_settings');
174
  variable_del('print_sourceurl_settings');
175
  variable_del('print_html_settings');
176
  variable_del('print_robot_settings');
177

    
178
  variable_del('print_html_node_link_pages');
179
  variable_del('print_html_node_link_visibility');
180

    
181
  variable_del('print_text_links');
182
  variable_del('print_text_published');
183
  variable_del('print_text_retrieved');
184
  variable_del('print_text_source_url');
185

    
186
  $settings = db_query("SELECT name FROM {variable} WHERE name LIKE 'print\_display\_%'");
187
  foreach ($settings as $variable) {
188
    $name = $variable->name;
189

    
190
    variable_set(str_replace('print_', 'print_html_', $name), variable_get($name));
191
    variable_del($name);
192
  }
193
}
194

    
195
/**
196
 * Enable block and help area links.
197
 */
198
function print_update_7202(&$sandbox) {
199
  $link_pos = variable_get('print_html_link_pos', drupal_json_decode('{ "link": "link", "block": "block", "help": "help" }'));
200
  $link_pos['block'] = 'block';
201
  $link_pos['help'] = 'help';
202
  variable_set('print_html_link_pos', $link_pos);
203
}
204

    
205
/**
206
 * Increase size of the path field in the print_page_counter table.
207
 */
208
function print_update_7203(&$sandbox) {
209
  db_drop_primary_key('print_page_counter');
210
  db_change_field('print_page_counter', 'path', 'path',
211
    array(
212
      'type' => 'varchar',
213
      'length' => 255,
214
      'not null' => TRUE,
215
      'description' => 'Page path',
216
    ),
217
    array('primary key' => array('path')));
218
}