Project

General

Profile

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

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

1
<?php
2

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

    
10
/**
11
 * Implements hook_enable().
12
 */
13
function print_epub_enable() {
14
  // Module weight.
15
  db_update('system')
16
    ->fields(array(
17
      'weight' => 4,
18
    ))
19
    ->condition('type', 'module')
20
    ->condition('name', 'print_epub')
21
    ->execute();
22
}
23

    
24
/**
25
 * Implements hook_uninstall().
26
 */
27
function print_epub_uninstall() {
28
  variable_del('print_epub_display_sys_urllist');
29
  variable_del('print_epub_filename');
30
  variable_del('print_epub_images_via_file');
31
  variable_del('print_epub_link_text');
32
  variable_del('print_epub_link_text_enabled');
33
  variable_del('print_epub_epub_tool');
34

    
35
  variable_del('print_epub_book_link');
36
  variable_del('print_epub_link_class');
37
  variable_del('print_epub_link_pos');
38
  variable_del('print_epub_link_teaser');
39
  variable_del('print_epub_link_use_alias');
40
  variable_del('print_epub_show_link');
41
  variable_del('print_epub_sys_link_pages');
42
  variable_del('print_epub_sys_link_visibility');
43

    
44
  $settings = db_query("SELECT name FROM {variable} WHERE name LIKE 'print\_epub\_display\_%'");
45
  foreach ($settings as $variable) {
46
    variable_del($variable->name);
47
  }
48
}
49

    
50
/**
51
 * Implements hook_schema().
52
 */
53
function print_epub_schema() {
54
  $schema['print_epub_node_conf'] = array(
55
    'description' => 'EPUB version node-specific configuration settings',
56
    'fields' => array(
57
      'nid' => array(
58
        'type' => 'int',
59
        'unsigned' => TRUE,
60
        'not null' => TRUE,
61
        'description' => 'The {node}.nid of the node.',
62
      ),
63
      'link' => array(
64
        'type' => 'int',
65
        'unsigned' => TRUE,
66
        'not null' => TRUE,
67
        'default' => 1,
68
        'size' => 'tiny',
69
        'description' => 'Show link',
70
      ),
71
      'comments' => array(
72
        'type' => 'int',
73
        'unsigned' => TRUE,
74
        'not null' => TRUE,
75
        'default' => 1,
76
        'size' => 'tiny',
77
        'description' => 'Show link in individual comments',
78
      ),
79
      'url_list' => array(
80
        'type' => 'int',
81
        'unsigned' => TRUE,
82
        'not null' => TRUE,
83
        'default' => 1,
84
        'size' => 'tiny',
85
        'description' => 'Show Printer-friendly URLs list',
86
      ),
87
    ),
88
    'primary key' => array('nid'),
89
  );
90

    
91
  $schema['print_epub_page_counter'] = array(
92
    'description' => 'EPUB version access counter',
93
    'fields' => array(
94
      'path' => array(
95
        'type' => 'varchar',
96
        'length' => 255,
97
        'not null' => TRUE,
98
        'description' => 'Page path',
99
      ),
100
      'totalcount' => array(
101
        'type' => 'int',
102
        'unsigned' => TRUE,
103
        'not null' => TRUE,
104
        'default' => 0,
105
        'size' => 'big',
106
        'description' => 'Number of page accesses',
107
      ),
108
      'timestamp' => array(
109
        'type' => 'int',
110
        'unsigned' => TRUE,
111
        'not null' => TRUE,
112
        'default' => 0,
113
        'description' => 'Last access',
114
      ),
115
    ),
116
    'primary key' => array('path'),
117
  );
118

    
119
  return $schema;
120
}
121

    
122
/**
123
 * Remove hardcoded numeric deltas from all blocks.
124
 */
125
function print_epub_update_7000(&$sandbox) {
126
  $renamed_deltas = array(
127
    'print_epub' => array(
128
      '0' => 'print_epub-top',
129
    ),
130
  );
131

    
132
  update_fix_d7_block_deltas($sandbox, $renamed_deltas, array());
133

    
134
  if (variable_get('print_epub_filename', '') == '[site-name] - [title] - [mod-yyyy]-[mod-mm]-[mod-dd]') {
135
    variable_set('print_epub_filename', '[site:name] - [node:title] - [node:changed:custom:Y-m-d]');
136
  }
137
}
138

    
139
/**
140
 * Enable block and help area links.
141
 */
142
function print_epub_update_7202(&$sandbox) {
143
  $link_pos = variable_get('print_epub_link_pos', drupal_json_decode('{ "link": "link", "block": "block", "help": "help" }'));
144
  $link_pos['block'] = 'block';
145
  $link_pos['help'] = 'help';
146
  variable_set('print_epub_link_pos', $link_pos);
147
}
148

    
149
/**
150
 * Increase size of the path field in the print_epub_page_counter table.
151
 */
152
function print_epub_update_7203(&$sandbox) {
153
  db_drop_primary_key('print_epub_page_counter');
154
  db_change_field('print_epub_page_counter', 'path', 'path',
155
    array(
156
      'type' => 'varchar',
157
      'length' => 255,
158
      'not null' => TRUE,
159
      'description' => 'Page path',
160
    ),
161
    array('primary key' => array('path')));
162
}