| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225 | 
							- <?php
 
- /**
 
-  * @file
 
-  * Install, update, and uninstall functions for tracker.module.
 
-  */
 
- /**
 
-  * Implements hook_uninstall().
 
-  */
 
- function tracker_uninstall() {
 
-   variable_del('tracker_index_nid');
 
-   variable_del('tracker_batch_size');
 
- }
 
- /**
 
-  * Implements hook_enable().
 
-  */
 
- function tracker_enable() {
 
-   $max_nid = db_query('SELECT MAX(nid) FROM {node}')->fetchField();
 
-   if ($max_nid != 0) {
 
-     variable_set('tracker_index_nid', $max_nid);
 
-     // To avoid timing out while attempting to do a complete indexing, we
 
-     // simply call our cron job to remove stale records and begin the process.
 
-     tracker_cron();
 
-   }
 
- }
 
- /**
 
-  * Implements hook_schema().
 
-  */
 
- function tracker_schema() {
 
-   $schema['tracker_node'] = array(
 
-     'description' => 'Tracks when nodes were last changed or commented on.',
 
-     'fields' => array(
 
-       'nid' => array(
 
-         'description' => 'The {node}.nid this record tracks.',
 
-         'type' => 'int',
 
-         'unsigned' => TRUE,
 
-         'not null' => TRUE,
 
-         'default' => 0,
 
-       ),
 
-       'published' => array(
 
-         'description' => 'Boolean indicating whether the node is published.',
 
-         'type' => 'int',
 
-         'not null' => FALSE,
 
-         'default' => 0,
 
-         'size' => 'tiny',
 
-       ),
 
-       'changed' => array(
 
-         'description' => 'The Unix timestamp when the node was most recently saved or commented on.',
 
-         'type' => 'int',
 
-         'unsigned' => TRUE,
 
-         'not null' => TRUE,
 
-         'default' => 0,
 
-       ),
 
-     ),
 
-     'indexes' => array(
 
-       'tracker' => array('published', 'changed'),
 
-     ),
 
-     'primary key' => array('nid'),
 
-     'foreign keys' => array(
 
-       'tracked_node' => array(
 
-         'table' => 'node',
 
-         'columns' => array('nid' => 'nid'),
 
-       ),
 
-     ),
 
-   );
 
-   $schema['tracker_user'] = array(
 
-     'description' => 'Tracks when nodes were last changed or commented on, for each user that authored the node or one of its comments.',
 
-     'fields' => array(
 
-       'nid' => array(
 
-         'description' => 'The {node}.nid this record tracks.',
 
-         'type' => 'int',
 
-         'unsigned' => TRUE,
 
-         'not null' => TRUE,
 
-         'default' => 0,
 
-       ),
 
-       'uid' => array(
 
-         'description' => 'The {users}.uid of the node author or commenter.',
 
-         'type' => 'int',
 
-         'not null' => TRUE,
 
-         'default' => 0,
 
-       ),
 
-       'published' => array(
 
-         'description' => 'Boolean indicating whether the node is published.',
 
-         'type' => 'int',
 
-         'not null' => FALSE,
 
-         'default' => 0,
 
-         'size' => 'tiny',
 
-       ),
 
-       'changed' => array(
 
-         'description' => 'The Unix timestamp when the node was most recently saved or commented on.',
 
-         'type' => 'int',
 
-         'unsigned' => TRUE,
 
-         'not null' => TRUE,
 
-         'default' => 0,
 
-       ),
 
-     ),
 
-     'indexes' => array(
 
-       'tracker' => array('uid', 'published', 'changed'),
 
-     ),
 
-     'primary key' => array('nid', 'uid'),
 
-     'foreign keys' => array(
 
-       'tracked_node' => array(
 
-         'table' => 'node',
 
-         'columns' => array('nid' => 'nid'),
 
-       ),
 
-       'tracked_user' => array(
 
-         'table' => 'users',
 
-         'columns' => array('uid' => 'uid'),
 
-       ),
 
-     ),
 
-   );
 
-   return $schema;
 
- }
 
- /**
 
-  * @addtogroup updates-6.x-to-7.x
 
-  * @{
 
-  */
 
- /**
 
-  * Create new tracker_node and tracker_user tables.
 
-  */
 
- function tracker_update_7000() {
 
-   $schema['tracker_node'] = array(
 
-     'description' => 'Tracks when nodes were last changed or commented on',
 
-     'fields' => array(
 
-       'nid' => array(
 
-         'description' => 'The {node}.nid this record tracks.',
 
-         'type' => 'int',
 
-         'unsigned' => TRUE,
 
-         'not null' => TRUE,
 
-         'default' => 0,
 
-       ),
 
-       'published' => array(
 
-         'description' => 'Boolean indicating whether the node is published.',
 
-         'type' => 'int',
 
-         'not null' => FALSE,
 
-         'default' => 0,
 
-         'size' => 'tiny',
 
-       ),
 
-       'changed' => array(
 
-         'description' => 'The Unix timestamp when the node was most recently saved or commented on.',
 
-         'type' => 'int',
 
-         'unsigned' => TRUE,
 
-         'not null' => TRUE,
 
-         'default' => 0,
 
-       ),
 
-     ),
 
-     'indexes' => array(
 
-       'tracker' => array('published', 'changed'),
 
-     ),
 
-     'primary key' => array('nid'),
 
-     'foreign keys' => array(
 
-       'tracked_node' => array(
 
-         'table' => 'node',
 
-         'columns' => array('nid' => 'nid'),
 
-       ),
 
-     ),
 
-   );
 
-   $schema['tracker_user'] = array(
 
-     'description' => 'Tracks when nodes were last changed or commented on, for each user that authored the node or one of its comments.',
 
-     'fields' => array(
 
-       'nid' => array(
 
-         'description' => 'The {node}.nid this record tracks.',
 
-         'type' => 'int',
 
-         'unsigned' => TRUE,
 
-         'not null' => TRUE,
 
-         'default' => 0,
 
-       ),
 
-       'uid' => array(
 
-         'description' => 'The {users}.uid of the node author or commenter.',
 
-         'type' => 'int',
 
-         'not null' => TRUE,
 
-         'default' => 0,
 
-       ),
 
-       'published' => array(
 
-         'description' => 'Boolean indicating whether the node is published.',
 
-         'type' => 'int',
 
-         'not null' => FALSE,
 
-         'default' => 0,
 
-         'size' => 'tiny',
 
-       ),
 
-       'changed' => array(
 
-         'description' => 'The Unix timestamp when the node was most recently saved or commented on.',
 
-         'type' => 'int',
 
-         'unsigned' => TRUE,
 
-         'not null' => TRUE,
 
-         'default' => 0,
 
-       ),
 
-     ),
 
-     'indexes' => array(
 
-       'tracker' => array('uid', 'published', 'changed'),
 
-     ),
 
-     'primary key' => array('nid', 'uid'),
 
-     'foreign keys' => array(
 
-       'tracked_node' => array(
 
-         'table' => 'node',
 
-         'columns' => array('nid' => 'nid'),
 
-       ),
 
-       'tracked_user' => array(
 
-         'table' => 'users',
 
-         'columns' => array('uid' => 'uid'),
 
-       ),
 
-     ),
 
-   );
 
-   foreach ($schema as $name => $table) {
 
-     db_create_table($name, $table);
 
-   }
 
-   $max_nid = db_query('SELECT MAX(nid) FROM {node}')->fetchField();
 
-   if ($max_nid != 0) {
 
-     variable_set('tracker_index_nid', $max_nid);
 
-   }
 
- }
 
- /**
 
-  * @} End of "addtogroup updates-6.x-to-7.x".
 
-  */
 
 
  |