statistics.install 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. <?php
  2. /**
  3. * @file
  4. * Install, update, and uninstall functions for the Statistics module.
  5. */
  6. /**
  7. * Implements hook_uninstall().
  8. */
  9. function statistics_uninstall() {
  10. // Remove variables.
  11. variable_del('statistics_count_content_views');
  12. variable_del('statistics_count_content_views_ajax');
  13. variable_del('statistics_enable_access_log');
  14. variable_del('statistics_flush_accesslog_timer');
  15. variable_del('statistics_day_timestamp');
  16. variable_del('statistics_block_top_day_num');
  17. variable_del('statistics_block_top_all_num');
  18. variable_del('statistics_block_top_last_num');
  19. }
  20. /**
  21. * Implements hook_schema().
  22. */
  23. function statistics_schema() {
  24. $schema['accesslog'] = array(
  25. 'description' => 'Stores site access information for statistics.',
  26. 'fields' => array(
  27. 'aid' => array(
  28. 'type' => 'serial',
  29. 'not null' => TRUE,
  30. 'description' => 'Primary Key: Unique accesslog ID.',
  31. ),
  32. 'sid' => array(
  33. 'type' => 'varchar',
  34. 'length' => 128,
  35. 'not null' => TRUE,
  36. 'default' => '',
  37. 'description' => 'Browser session ID of user that visited page.',
  38. ),
  39. 'title' => array(
  40. 'type' => 'varchar',
  41. 'length' => 255,
  42. 'not null' => FALSE,
  43. 'description' => 'Title of page visited.',
  44. ),
  45. 'path' => array(
  46. 'type' => 'varchar',
  47. 'length' => 255,
  48. 'not null' => FALSE,
  49. 'description' => 'Internal path to page visited (relative to Drupal root.)',
  50. ),
  51. 'url' => array(
  52. 'type' => 'text',
  53. 'not null' => FALSE,
  54. 'description' => 'Referrer URI.',
  55. ),
  56. 'hostname' => array(
  57. 'type' => 'varchar',
  58. 'length' => 128,
  59. 'not null' => FALSE,
  60. 'description' => 'Hostname of user that visited the page.',
  61. ),
  62. 'uid' => array(
  63. 'type' => 'int',
  64. 'unsigned' => TRUE,
  65. 'not null' => FALSE,
  66. 'default' => 0,
  67. 'description' => 'User {users}.uid that visited the page.',
  68. ),
  69. 'timer' => array(
  70. 'type' => 'int',
  71. 'unsigned' => TRUE,
  72. 'not null' => TRUE,
  73. 'default' => 0,
  74. 'description' => 'Time in milliseconds that the page took to load.',
  75. ),
  76. 'timestamp' => array(
  77. 'type' => 'int',
  78. 'unsigned' => TRUE,
  79. 'not null' => TRUE,
  80. 'default' => 0,
  81. 'description' => 'Timestamp of when the page was visited.',
  82. ),
  83. ),
  84. 'indexes' => array(
  85. 'accesslog_timestamp' => array('timestamp'),
  86. 'uid' => array('uid'),
  87. ),
  88. 'primary key' => array('aid'),
  89. 'foreign keys' => array(
  90. 'visitor' => array(
  91. 'table' => 'users',
  92. 'columns' => array('uid' => 'uid'),
  93. ),
  94. ),
  95. );
  96. $schema['node_counter'] = array(
  97. 'description' => 'Access statistics for {node}s.',
  98. 'fields' => array(
  99. 'nid' => array(
  100. 'description' => 'The {node}.nid for these statistics.',
  101. 'type' => 'int',
  102. 'not null' => TRUE,
  103. 'default' => 0,
  104. ),
  105. 'totalcount' => array(
  106. 'description' => 'The total number of times the {node} has been viewed.',
  107. 'type' => 'int',
  108. 'unsigned' => TRUE,
  109. 'not null' => TRUE,
  110. 'default' => 0,
  111. 'size' => 'big',
  112. ),
  113. 'daycount' => array(
  114. 'description' => 'The total number of times the {node} has been viewed today.',
  115. 'type' => 'int',
  116. 'unsigned' => TRUE,
  117. 'not null' => TRUE,
  118. 'default' => 0,
  119. 'size' => 'medium',
  120. ),
  121. 'timestamp' => array(
  122. 'description' => 'The most recent time the {node} has been viewed.',
  123. 'type' => 'int',
  124. 'unsigned' => TRUE,
  125. 'not null' => TRUE,
  126. 'default' => 0,
  127. ),
  128. ),
  129. 'primary key' => array('nid'),
  130. );
  131. return $schema;
  132. }
  133. /**
  134. * @addtogroup updates-6.x-to-7.x
  135. * @{
  136. */
  137. /**
  138. * Update the {accesslog}.sid column to match the length of {sessions}.sid
  139. */
  140. function statistics_update_7000() {
  141. db_change_field('accesslog', 'sid', 'sid', array(
  142. 'type' => 'varchar',
  143. 'length' => 128,
  144. 'not null' => TRUE,
  145. 'default' => '',
  146. 'description' => 'Browser session ID of user that visited page.',
  147. ));
  148. }
  149. /**
  150. * @} End of "addtogroup updates-6.x-to-7.x".
  151. */