print.install 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  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_comments');
  35. variable_del('print_css');
  36. variable_del('print_footer_options');
  37. variable_del('print_footer_user');
  38. variable_del('print_html_display_sys_urllist');
  39. variable_del('print_html_link_text');
  40. variable_del('print_html_link_text_enabled');
  41. variable_del('print_html_new_window');
  42. variable_del('print_html_sendtoprinter');
  43. variable_del('print_html_windowclose');
  44. variable_del('print_keep_theme_css');
  45. variable_del('print_logo_options');
  46. variable_del('print_logo_url');
  47. variable_del('print_newwindow');
  48. variable_del('print_robots_noarchive');
  49. variable_del('print_robots_nofollow');
  50. variable_del('print_robots_noindex');
  51. variable_del('print_sourceurl_date');
  52. variable_del('print_sourceurl_enabled');
  53. variable_del('print_sourceurl_forcenode');
  54. variable_del('print_urls');
  55. variable_del('print_urls_anchors');
  56. variable_del('print_html_book_link');
  57. variable_del('print_html_link_class');
  58. variable_del('print_html_link_pos');
  59. variable_del('print_html_link_teaser');
  60. variable_del('print_html_link_use_alias');
  61. variable_del('print_html_show_link');
  62. variable_del('print_html_sys_link_pages');
  63. variable_del('print_html_sys_link_visibility');
  64. $settings = db_query("SELECT name FROM {variable} WHERE name LIKE 'print\_html\_display\_%'");
  65. foreach ($settings as $variable) {
  66. variable_del($variable->name);
  67. }
  68. }
  69. /**
  70. * Implements hook_schema().
  71. */
  72. function print_schema() {
  73. $schema['print_node_conf'] = array(
  74. 'description' => 'Printer-friendly version node-specific configuration settings',
  75. 'fields' => array(
  76. 'nid' => array(
  77. 'type' => 'int',
  78. 'unsigned' => TRUE,
  79. 'not null' => TRUE,
  80. 'description' => 'The {node}.nid of the node.',
  81. ),
  82. 'link' => array(
  83. 'type' => 'int',
  84. 'unsigned' => TRUE,
  85. 'not null' => TRUE,
  86. 'default' => 1,
  87. 'size' => 'tiny',
  88. 'description' => 'Show link',
  89. ),
  90. 'comments' => array(
  91. 'type' => 'int',
  92. 'unsigned' => TRUE,
  93. 'not null' => TRUE,
  94. 'default' => 1,
  95. 'size' => 'tiny',
  96. 'description' => 'Show link in individual comments',
  97. ),
  98. 'url_list' => array(
  99. 'type' => 'int',
  100. 'unsigned' => TRUE,
  101. 'not null' => TRUE,
  102. 'default' => 1,
  103. 'size' => 'tiny',
  104. 'description' => 'Show Printer-friendly URLs list',
  105. ),
  106. ),
  107. 'primary key' => array('nid'),
  108. );
  109. $schema['print_page_counter'] = array(
  110. 'description' => 'Printer-friendly version access counter',
  111. 'fields' => array(
  112. 'path' => array(
  113. 'type' => 'varchar',
  114. 'length' => 255,
  115. 'not null' => TRUE,
  116. 'description' => 'Page path',
  117. ),
  118. 'totalcount' => array(
  119. 'type' => 'int',
  120. 'unsigned' => TRUE,
  121. 'not null' => TRUE,
  122. 'default' => 0,
  123. 'size' => 'big',
  124. 'description' => 'Number of page accesses',
  125. ),
  126. 'timestamp' => array(
  127. 'type' => 'int',
  128. 'unsigned' => TRUE,
  129. 'not null' => TRUE,
  130. 'default' => 0,
  131. 'description' => 'Last access',
  132. ),
  133. ),
  134. 'primary key' => array('path'),
  135. );
  136. return $schema;
  137. }
  138. /**
  139. * Remove hardcoded numeric deltas from all blocks
  140. */
  141. function print_update_7000(&$sandbox) {
  142. $renamed_deltas = array(
  143. 'print' => array(
  144. '0' => 'print-links',
  145. '1' => 'print-top',
  146. ),
  147. );
  148. update_fix_d7_block_deltas($sandbox, $renamed_deltas, array());
  149. }
  150. /**
  151. * Enable the print UI module
  152. */
  153. function print_update_7199(&$sandbox) {
  154. module_enable(array('print_ui'), FALSE);
  155. }
  156. /**
  157. * Delete old variables
  158. */
  159. function print_update_7200(&$sandbox) {
  160. variable_del('print_settings');
  161. variable_del('print_sourceurl_settings');
  162. variable_del('print_html_settings');
  163. variable_del('print_robot_settings');
  164. variable_del('print_html_node_link_pages');
  165. variable_del('print_html_node_link_visibility');
  166. variable_del('print_text_links');
  167. variable_del('print_text_published');
  168. variable_del('print_text_retrieved');
  169. variable_del('print_text_source_url');
  170. $settings = db_query("SELECT name FROM {variable} WHERE name LIKE 'print\_display\_%'");
  171. foreach ($settings as $variable) {
  172. $name = $variable->name;
  173. variable_set(str_replace('print_', 'print_html_', $name), variable_get($name));
  174. variable_del($name);
  175. }
  176. }
  177. /**
  178. * Enable block and help area links
  179. */
  180. function print_update_7202(&$sandbox) {
  181. $link_pos = variable_get('print_html_link_pos', drupal_json_decode('{ "link": "link", "block": "block", "help": "help" }'));
  182. $link_pos['block'] = 'block';
  183. $link_pos['help'] = 'help';
  184. variable_set('print_html_link_pos', $link_pos);
  185. }
  186. /**
  187. * Increase size of the path field in the print_page_counter table
  188. */
  189. function print_update_7203(&$sandbox) {
  190. db_drop_primary_key('print_page_counter');
  191. db_change_field('print_page_counter', 'path', 'path',
  192. array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'description' => 'Page path'),
  193. array('primary key' => array('path')));
  194. }