print_mail.install 4.72 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_mail module.
6 7
 *
 * @ingroup print
jcnventura's avatar
jcnventura committed
8 9
 */

10 11 12 13
/**
 * Implements hook_enable().
 */
function print_mail_enable() {
jcnventura's avatar
jcnventura committed
14
  $t = get_t();
15 16 17 18 19 20 21 22 23

  // Module weight
  db_update('system')
    ->fields(array(
      'weight' => 1,
    ))
    ->condition('type', 'module')
    ->condition('name', 'print_mail')
    ->execute();
24 25 26 27

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

jcnventura's avatar
jcnventura committed
30
/**
31
 * Implements hook_uninstall().
jcnventura's avatar
jcnventura committed
32 33 34
 */
function print_mail_uninstall() {
  variable_del('print_mail_settings');
35
  variable_del('print_mail_show_link');
36
  variable_del('print_mail_link_pos');
37
  variable_del('print_mail_link_teaser');
38 39 40 41 42 43
  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');
44
  variable_del('print_mail_hourly_threshold');
45 46
  variable_del('print_mail_teaser_default');
  variable_del('print_mail_teaser_choice');
jcnventura's avatar
jcnventura committed
47 48
  variable_del('print_mail_link_text');
  variable_del('print_mail_link_use_alias');
49
  variable_del('print_mail_text_title');
jcnventura's avatar
jcnventura committed
50 51 52
  variable_del('print_mail_text_confirmation');
  variable_del('print_mail_text_message');
  variable_del('print_mail_text_subject');
53
  variable_del('print_mail_text_content');
54
  variable_del('print_mail_job_queue');
55
  variable_del('print_mail_display_sys_urllist');
jcnventura's avatar
jcnventura committed
56
  $settings = db_query("SELECT name FROM {variable} WHERE name LIKE 'print\_mail\_display\_%'");
jcnventura's avatar
jcnventura committed
57
  foreach ($settings as $variable) {
jcnventura's avatar
jcnventura committed
58 59 60
    variable_del($variable->name);
  }
}
61 62

/**
63
 * Implements hook_schema().
64
 */
jcnventura's avatar
jcnventura committed
65 66
function print_mail_schema() {
  $schema['print_mail_node_conf'] = array(
67
    'description' => 'Send by email node-specific configuration settings',
jcnventura's avatar
jcnventura committed
68 69 70 71 72
    'fields' => array(
      'nid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
jcnventura's avatar
jcnventura committed
73
        'description' => 'The {node}.nid of the node.',
jcnventura's avatar
jcnventura committed
74 75 76 77 78
      ),
      'link' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
jcnventura's avatar
jcnventura committed
79
        'default' => 1,
jcnventura's avatar
jcnventura committed
80
        'size' => 'tiny',
jcnventura's avatar
jcnventura committed
81
        'description' => 'Show link',
jcnventura's avatar
jcnventura committed
82 83 84 85 86
      ),
      'comments' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
jcnventura's avatar
jcnventura committed
87
        'default' => 1,
jcnventura's avatar
jcnventura committed
88
        'size' => 'tiny',
jcnventura's avatar
jcnventura committed
89
        'description' => 'Show link in individual comments',
jcnventura's avatar
jcnventura committed
90 91 92 93 94
      ),
      'url_list' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
jcnventura's avatar
jcnventura committed
95
        'default' => 1,
jcnventura's avatar
jcnventura committed
96
        'size' => 'tiny',
jcnventura's avatar
jcnventura committed
97
        'description' => 'Show Printer-friendly URLs list',
jcnventura's avatar
jcnventura committed
98 99 100 101
      ),
    ),
    'primary key' => array('nid'),
  );
102

jcnventura's avatar
jcnventura committed
103
  $schema['print_mail_page_counter'] = array(
104
    'description' => 'Send by email version access counter',
jcnventura's avatar
jcnventura committed
105 106 107 108 109
    'fields' => array(
      'path' => array(
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
jcnventura's avatar
jcnventura committed
110
        'description' => 'Page path',
jcnventura's avatar
jcnventura committed
111 112 113 114 115 116 117
      ),
      'totalcount' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'size' => 'big',
jcnventura's avatar
jcnventura committed
118
        'description' => 'Number of page accesses',
jcnventura's avatar
jcnventura committed
119 120 121 122 123 124
      ),
      'timestamp' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
jcnventura's avatar
jcnventura committed
125
        'description' => 'Last access',
jcnventura's avatar
jcnventura committed
126 127 128 129 130 131 132
      ),
      'sentcount' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'size' => 'big',
jcnventura's avatar
jcnventura committed
133
        'description' => 'Number of sent emails',
jcnventura's avatar
jcnventura committed
134 135 136 137 138 139
      ),
      'sent_timestamp' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
140
        'description' => 'Last email sent',
jcnventura's avatar
jcnventura committed
141 142 143 144 145 146
      ),
    ),
    'primary key' => array('path'),
  );

  return $schema;
147
}
148 149 150 151 152 153 154

/**
 * Remove hardcoded numeric deltas from all blocks
 */
function print_mail_update_7000(&$sandbox) {
  $renamed_deltas = array(
    'print_mail' => array(
jcnventura's avatar
jcnventura committed
155
      '0' => 'print_mail-top',
156 157 158
    ),
  );

jcnventura's avatar
jcnventura committed
159 160
  update_fix_d7_block_deltas($sandbox, $renamed_deltas, array());
}
161 162 163 164 165 166 167 168 169

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

/**
 * Update permissions to new spellings
 */
function print_mail_update_7101(&$sandbox) {
  db_update('role_permission')
    ->fields(array('permission' => 'access send by email'))
    ->condition('permission', 'access send to friend')
    ->execute();
  db_update('role_permission')
    ->fields(array('permission' => 'send unlimited emails'))
    ->condition('permission', 'send unlimited e-mails')
    ->execute();
}