print_mail.install 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. <?php
  2. /**
  3. * @file
  4. * Install, update and uninstall functions for the print_mail module.
  5. *
  6. * @ingroup print
  7. */
  8. /**
  9. * Implements hook_enable().
  10. */
  11. function print_mail_enable() {
  12. $t = get_t();
  13. // Module weight
  14. db_update('system')
  15. ->fields(array(
  16. 'weight' => 1,
  17. ))
  18. ->condition('type', 'module')
  19. ->condition('name', 'print_mail')
  20. ->execute();
  21. if (module_exists('mailsystem')) {
  22. mailsystem_set(array('print_mail' => 'DefaultMailSystem'));
  23. }
  24. }
  25. /**
  26. * Implements hook_disable().
  27. */
  28. function print_mail_disable() {
  29. if (module_exists('mailsystem')) {
  30. mailsystem_clear(array('print_mail' => ''));
  31. }
  32. }
  33. /**
  34. * Implements hook_uninstall().
  35. */
  36. function print_mail_uninstall() {
  37. variable_del('print_mail_display_sys_urllist');
  38. variable_del('print_mail_hourly_threshold');
  39. variable_del('print_mail_job_queue');
  40. variable_del('print_mail_link_text');
  41. variable_del('print_mail_link_text_enabled');
  42. variable_del('print_mail_send_option_default');
  43. variable_del('print_mail_teaser_choice');
  44. variable_del('print_mail_teaser_default');
  45. variable_del('print_mail_use_reply_to');
  46. variable_del('print_mail_user_recipients');
  47. variable_del('print_mail_book_link');
  48. variable_del('print_mail_link_class');
  49. variable_del('print_mail_link_pos');
  50. variable_del('print_mail_link_teaser');
  51. variable_del('print_mail_link_use_alias');
  52. variable_del('print_mail_show_link');
  53. variable_del('print_mail_sys_link_pages');
  54. variable_del('print_mail_sys_link_visibility');
  55. $settings = db_query("SELECT name FROM {variable} WHERE name LIKE 'print\_mail\_display\_%'");
  56. foreach ($settings as $variable) {
  57. variable_del($variable->name);
  58. }
  59. }
  60. /**
  61. * Implements hook_schema().
  62. */
  63. function print_mail_schema() {
  64. $schema['print_mail_node_conf'] = array(
  65. 'description' => 'Send by email node-specific configuration settings',
  66. 'fields' => array(
  67. 'nid' => array(
  68. 'type' => 'int',
  69. 'unsigned' => TRUE,
  70. 'not null' => TRUE,
  71. 'description' => 'The {node}.nid of the node.',
  72. ),
  73. 'link' => array(
  74. 'type' => 'int',
  75. 'unsigned' => TRUE,
  76. 'not null' => TRUE,
  77. 'default' => 1,
  78. 'size' => 'tiny',
  79. 'description' => 'Show link',
  80. ),
  81. 'comments' => array(
  82. 'type' => 'int',
  83. 'unsigned' => TRUE,
  84. 'not null' => TRUE,
  85. 'default' => 1,
  86. 'size' => 'tiny',
  87. 'description' => 'Show link in individual comments',
  88. ),
  89. 'url_list' => array(
  90. 'type' => 'int',
  91. 'unsigned' => TRUE,
  92. 'not null' => TRUE,
  93. 'default' => 1,
  94. 'size' => 'tiny',
  95. 'description' => 'Show Printer-friendly URLs list',
  96. ),
  97. ),
  98. 'primary key' => array('nid'),
  99. );
  100. $schema['print_mail_page_counter'] = array(
  101. 'description' => 'Send by email version access counter',
  102. 'fields' => array(
  103. 'path' => array(
  104. 'type' => 'varchar',
  105. 'length' => 255,
  106. 'not null' => TRUE,
  107. 'description' => 'Page path',
  108. ),
  109. 'totalcount' => array(
  110. 'type' => 'int',
  111. 'unsigned' => TRUE,
  112. 'not null' => TRUE,
  113. 'default' => 0,
  114. 'size' => 'big',
  115. 'description' => 'Number of page accesses',
  116. ),
  117. 'timestamp' => array(
  118. 'type' => 'int',
  119. 'unsigned' => TRUE,
  120. 'not null' => TRUE,
  121. 'default' => 0,
  122. 'description' => 'Last access',
  123. ),
  124. 'sentcount' => array(
  125. 'type' => 'int',
  126. 'unsigned' => TRUE,
  127. 'not null' => TRUE,
  128. 'default' => 0,
  129. 'size' => 'big',
  130. 'description' => 'Number of sent emails',
  131. ),
  132. 'sent_timestamp' => array(
  133. 'type' => 'int',
  134. 'unsigned' => TRUE,
  135. 'not null' => TRUE,
  136. 'default' => 0,
  137. 'description' => 'Last email sent',
  138. ),
  139. ),
  140. 'primary key' => array('path'),
  141. );
  142. return $schema;
  143. }
  144. /**
  145. * Remove hardcoded numeric deltas from all blocks
  146. */
  147. function print_mail_update_7000(&$sandbox) {
  148. $renamed_deltas = array(
  149. 'print_mail' => array(
  150. '0' => 'print_mail-top',
  151. ),
  152. );
  153. update_fix_d7_block_deltas($sandbox, $renamed_deltas, array());
  154. }
  155. /**
  156. * Disable MimeMailSystem for now
  157. */
  158. function print_mail_update_7100(&$sandbox) {
  159. if (module_exists('mailsystem')) {
  160. mailsystem_set(array('print_mail' => 'DefaultMailSystem'));
  161. }
  162. }
  163. /**
  164. * Update permissions to new spellings
  165. */
  166. function print_mail_update_7101(&$sandbox) {
  167. db_update('role_permission')
  168. ->fields(array('permission' => 'access send by email'))
  169. ->condition('permission', 'access send to friend')
  170. ->execute();
  171. db_update('role_permission')
  172. ->fields(array('permission' => 'send unlimited emails'))
  173. ->condition('permission', 'send unlimited e-mails')
  174. ->execute();
  175. }
  176. /**
  177. * Delete old variables
  178. */
  179. function print_mail_update_7200(&$sandbox) {
  180. variable_del('print_mail_settings');
  181. variable_del('print_mail_node_link_pages');
  182. variable_del('print_mail_node_link_visibility');
  183. variable_del('print_mail_text_title');
  184. variable_del('print_mail_text_confirmation');
  185. variable_del('print_mail_text_message');
  186. variable_del('print_mail_text_subject');
  187. variable_del('print_mail_text_content');
  188. }
  189. /**
  190. * Enable block and help area links
  191. */
  192. function print_mail_update_7202(&$sandbox) {
  193. $link_pos = variable_get('print_mail_link_pos', drupal_json_decode('{ "link": "link", "block": "block", "help": "help" }'));
  194. $link_pos['block'] = 'block';
  195. $link_pos['help'] = 'help';
  196. variable_set('print_mail_link_pos', $link_pos);
  197. }
  198. /**
  199. * Increase size of the path field in the print_mail_page_counter table
  200. */
  201. function print_mail_update_7203(&$sandbox) {
  202. db_drop_primary_key('print_mail_page_counter');
  203. db_change_field('print_mail_page_counter', 'path', 'path',
  204. array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'description' => 'Page path'),
  205. array('primary key' => array('path')));
  206. }