statistics.install 4.1 KB

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