print.install 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. <?php
  2. /**
  3. * @file
  4. * Install, update and uninstall functions for the print module.
  5. *
  6. * @ingroup print
  7. */
  8. /**
  9. * Implements hook_install().
  10. */
  11. function print_install() {
  12. $t = get_t();
  13. drupal_set_message($t('Printer-friendly Page settings are available under !link',
  14. array('!link' => l($t('Administration > Configuration > User interface > Printer, email and PDF versions'), 'admin/config/user-interface/print'))
  15. ));
  16. }
  17. /**
  18. * Implements hook_enable().
  19. */
  20. function print_enable() {
  21. // Module weight
  22. db_update('system')
  23. ->fields(array(
  24. 'weight' => 0,
  25. ))
  26. ->condition('type', 'module')
  27. ->condition('name', 'print')
  28. ->execute();
  29. }
  30. /**
  31. * Implements hook_uninstall().
  32. */
  33. function print_uninstall() {
  34. variable_del('print_settings');
  35. variable_del('print_sourceurl_settings');
  36. variable_del('print_html_settings');
  37. variable_del('print_robot_settings');
  38. variable_del('print_logo_url');
  39. variable_del('print_logo_options');
  40. variable_del('print_css');
  41. variable_del('print_keep_theme_css');
  42. variable_del('print_urls');
  43. variable_del('print_urls_anchors');
  44. variable_del('print_comments');
  45. variable_del('print_newwindow');
  46. variable_del('print_sourceurl_enabled');
  47. variable_del('print_sourceurl_date');
  48. variable_del('print_sourceurl_forcenode');
  49. variable_del('print_html_show_link');
  50. variable_del('print_html_link_pos');
  51. variable_del('print_html_link_teaser');
  52. variable_del('print_html_node_link_visibility');
  53. variable_del('print_html_node_link_pages');
  54. variable_del('print_html_link_class');
  55. variable_del('print_html_sys_link_visibility');
  56. variable_del('print_html_sys_link_pages');
  57. variable_del('print_html_book_link');
  58. variable_del('print_html_new_window');
  59. variable_del('print_html_sendtoprinter');
  60. variable_del('print_html_windowclose');
  61. variable_del('print_display_sys_urllist');
  62. variable_del('print_robots_noindex');
  63. variable_del('print_robots_nofollow');
  64. variable_del('print_robots_noarchive');
  65. variable_del('print_footer_options');
  66. variable_del('print_footer_user');
  67. variable_del('print_html_link_text');
  68. variable_del('print_html_link_use_alias');
  69. variable_del('print_text_links');
  70. variable_del('print_text_published');
  71. variable_del('print_text_retrieved');
  72. variable_del('print_text_source_url');
  73. $settings = db_query("SELECT name FROM {variable} WHERE name LIKE 'print\_display\_%'");
  74. foreach ($settings as $variable) {
  75. variable_del($variable->name);
  76. }
  77. }
  78. /**
  79. * Implements hook_schema().
  80. */
  81. function print_schema() {
  82. $schema['print_node_conf'] = array(
  83. 'description' => 'Printer-friendly version node-specific configuration settings',
  84. 'fields' => array(
  85. 'nid' => array(
  86. 'type' => 'int',
  87. 'unsigned' => TRUE,
  88. 'not null' => TRUE,
  89. 'description' => 'The {node}.nid of the node.',
  90. ),
  91. 'link' => array(
  92. 'type' => 'int',
  93. 'unsigned' => TRUE,
  94. 'not null' => TRUE,
  95. 'default' => 1,
  96. 'size' => 'tiny',
  97. 'description' => 'Show link',
  98. ),
  99. 'comments' => array(
  100. 'type' => 'int',
  101. 'unsigned' => TRUE,
  102. 'not null' => TRUE,
  103. 'default' => 1,
  104. 'size' => 'tiny',
  105. 'description' => 'Show link in individual comments',
  106. ),
  107. 'url_list' => array(
  108. 'type' => 'int',
  109. 'unsigned' => TRUE,
  110. 'not null' => TRUE,
  111. 'default' => 1,
  112. 'size' => 'tiny',
  113. 'description' => 'Show Printer-friendly URLs list',
  114. ),
  115. ),
  116. 'primary key' => array('nid'),
  117. );
  118. $schema['print_page_counter'] = array(
  119. 'description' => 'Printer-friendly version access counter',
  120. 'fields' => array(
  121. 'path' => array(
  122. 'type' => 'varchar',
  123. 'length' => 128,
  124. 'not null' => TRUE,
  125. 'description' => 'Page path',
  126. ),
  127. 'totalcount' => array(
  128. 'type' => 'int',
  129. 'unsigned' => TRUE,
  130. 'not null' => TRUE,
  131. 'default' => 0,
  132. 'size' => 'big',
  133. 'description' => 'Number of page accesses',
  134. ),
  135. 'timestamp' => array(
  136. 'type' => 'int',
  137. 'unsigned' => TRUE,
  138. 'not null' => TRUE,
  139. 'default' => 0,
  140. 'description' => 'Last access',
  141. ),
  142. ),
  143. 'primary key' => array('path'),
  144. );
  145. return $schema;
  146. }
  147. /**
  148. * Remove hardcoded numeric deltas from all blocks
  149. */
  150. function print_update_7000(&$sandbox) {
  151. $renamed_deltas = array(
  152. 'print' => array(
  153. '0' => 'print-links',
  154. '1' => 'print-top',
  155. ),
  156. );
  157. update_fix_d7_block_deltas($sandbox, $renamed_deltas, array());
  158. }
  159. /**
  160. * Enable block and help area links
  161. */
  162. function print_update_7101(&$sandbox) {
  163. $link_pos = variable_get('print_html_link_pos', drupal_json_decode('{ "link": "link", "block": "block", "help": "help" }'));
  164. $link_pos['block'] = 'block';
  165. $link_pos['help'] = 'help';
  166. variable_set('print_html_link_pos', $link_pos);
  167. }