summaryrefslogtreecommitdiff
path: root/modules/tracker
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2009-08-31 08:55:12 +0000
committerDries Buytaert <dries@buytaert.net>2009-08-31 08:55:12 +0000
commit56555f65f33156730a88c77ad60e5cb0ddaab4aa (patch)
tree8e9a965dbb246fe7b67896892628aa46e3ff2828 /modules/tracker
parentc239131ccae4acddce67c75dc0123566a0475636 (diff)
downloadbrdo-56555f65f33156730a88c77ad60e5cb0ddaab4aa.tar.gz
brdo-56555f65f33156730a88c77ad60e5cb0ddaab4aa.tar.bz2
- Forgot tracker.install.
Diffstat (limited to 'modules/tracker')
-rw-r--r--modules/tracker/tracker.install215
1 files changed, 215 insertions, 0 deletions
diff --git a/modules/tracker/tracker.install b/modules/tracker/tracker.install
new file mode 100644
index 000000000..1ceff152a
--- /dev/null
+++ b/modules/tracker/tracker.install
@@ -0,0 +1,215 @@
+<?php
+// $Id$
+
+/**
+ * Implement hook_install().
+ */
+function tracker_install() {
+ drupal_install_schema('tracker');
+}
+
+/**
+ * Implement hook_uninstall().
+ */
+function tracker_uninstall() {
+ drupal_uninstall_schema('tracker');
+
+ variable_del('tracker_index_nid');
+ variable_del('tracker_batch_size');
+}
+
+/**
+ * Implement 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();
+ }
+}
+
+/**
+ * Implement 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(
+ 'node' => '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(
+ 'node' => 'nid',
+ 'users' => 'uid',
+ ),
+ );
+
+ return $schema;
+}
+
+/**
+ * @defgroup updates-6.x-to-7.x Tracker updates from 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(
+ 'node' => '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(
+ 'node' => 'nid',
+ 'users' => 'uid',
+ ),
+ );
+
+ $ret = array();
+ foreach ($schema as $name => $table) {
+ db_create_table($ret, $name, $table);
+ }
+
+ $max_nid = db_query('SELECT MAX(nid) FROM {node}')->fetchField();
+ if ($max_nid != 0) {
+ variable_set('tracker_index_nid', $max_nid);
+ }
+ return $ret;
+}
+
+/**
+ * @} End of "defgroup updates-6.x-to-7.x"
+ * The next series of updates should start at 8000.
+ */