Projet

Général

Profil

Paste
Télécharger (5,62 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / print / print_mail / print_mail.install @ a2baadd1

1
<?php
2

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

    
10
/**
11
 * Implements hook_enable().
12
 */
13
function print_mail_enable() {
14
  $t = get_t();
15

    
16
  // Module weight
17
  db_update('system')
18
    ->fields(array(
19
      'weight' => 1,
20
    ))
21
    ->condition('type', 'module')
22
    ->condition('name', 'print_mail')
23
    ->execute();
24

    
25
  if (module_exists('mailsystem')) {
26
    mailsystem_set(array('print_mail' => 'DefaultMailSystem'));
27
  }
28
}
29

    
30
/**
31
 * Implements hook_disable().
32
 */
33
function print_mail_disable() {
34
  if (module_exists('mailsystem')) {
35
    mailsystem_clear(array('print_mail' => ''));
36
  }
37
}
38

    
39
/**
40
 * Implements hook_uninstall().
41
 */
42
function print_mail_uninstall() {
43
  variable_del('print_mail_settings');
44
  variable_del('print_mail_show_link');
45
  variable_del('print_mail_link_pos');
46
  variable_del('print_mail_link_teaser');
47
  variable_del('print_mail_node_link_visibility');
48
  variable_del('print_mail_node_link_pages');
49
  variable_del('print_mail_link_class');
50
  variable_del('print_mail_sys_link_visibility');
51
  variable_del('print_mail_sys_link_pages');
52
  variable_del('print_mail_book_link');
53
  variable_del('print_mail_hourly_threshold');
54
  variable_del('print_mail_use_reply_to');
55
  variable_del('print_mail_teaser_default');
56
  variable_del('print_mail_teaser_choice');
57
  variable_del('print_mail_link_text');
58
  variable_del('print_mail_link_use_alias');
59
  variable_del('print_mail_text_title');
60
  variable_del('print_mail_text_confirmation');
61
  variable_del('print_mail_text_message');
62
  variable_del('print_mail_text_subject');
63
  variable_del('print_mail_text_content');
64
  variable_del('print_mail_job_queue');
65
  variable_del('print_mail_display_sys_urllist');
66
  $settings = db_query("SELECT name FROM {variable} WHERE name LIKE 'print\_mail\_display\_%'");
67
  foreach ($settings as $variable) {
68
    variable_del($variable->name);
69
  }
70
}
71

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

    
113
  $schema['print_mail_page_counter'] = array(
114
    'description' => 'Send by email version access counter',
115
    'fields' => array(
116
      'path' => array(
117
        'type' => 'varchar',
118
        'length' => 255,
119
        'not null' => TRUE,
120
        'description' => 'Page path',
121
      ),
122
      'totalcount' => array(
123
        'type' => 'int',
124
        'unsigned' => TRUE,
125
        'not null' => TRUE,
126
        'default' => 0,
127
        'size' => 'big',
128
        'description' => 'Number of page accesses',
129
      ),
130
      'timestamp' => array(
131
        'type' => 'int',
132
        'unsigned' => TRUE,
133
        'not null' => TRUE,
134
        'default' => 0,
135
        'description' => 'Last access',
136
      ),
137
      'sentcount' => array(
138
        'type' => 'int',
139
        'unsigned' => TRUE,
140
        'not null' => TRUE,
141
        'default' => 0,
142
        'size' => 'big',
143
        'description' => 'Number of sent emails',
144
      ),
145
      'sent_timestamp' => array(
146
        'type' => 'int',
147
        'unsigned' => TRUE,
148
        'not null' => TRUE,
149
        'default' => 0,
150
        'description' => 'Last email sent',
151
      ),
152
    ),
153
    'primary key' => array('path'),
154
  );
155

    
156
  return $schema;
157
}
158

    
159
/**
160
 * Remove hardcoded numeric deltas from all blocks
161
 */
162
function print_mail_update_7000(&$sandbox) {
163
  $renamed_deltas = array(
164
    'print_mail' => array(
165
      '0' => 'print_mail-top',
166
    ),
167
  );
168

    
169
  update_fix_d7_block_deltas($sandbox, $renamed_deltas, array());
170
}
171

    
172
/**
173
 * Disable MimeMailSystem for now
174
 */
175
function print_mail_update_7100(&$sandbox) {
176
  if (module_exists('mailsystem')) {
177
    mailsystem_set(array('print_mail' => 'DefaultMailSystem'));
178
  }
179
}
180

    
181
/**
182
 * Update permissions to new spellings
183
 */
184
function print_mail_update_7101(&$sandbox) {
185
  db_update('role_permission')
186
    ->fields(array('permission' => 'access send by email'))
187
    ->condition('permission', 'access send to friend')
188
    ->execute();
189
  db_update('role_permission')
190
    ->fields(array('permission' => 'send unlimited emails'))
191
    ->condition('permission', 'send unlimited e-mails')
192
    ->execute();
193
}
194

    
195
/**
196
 * Enable block and help area links
197
 */
198
function print_mail_update_7102(&$sandbox) {
199
  $link_pos = variable_get('print_mail_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_mail_link_pos', $link_pos);
203
}
204

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