| 1 |
<?php
|
| 2 |
|
| 3 |
// $Id: tracker2.install,v 1.8 2008/04/01 15:56:29 straussd Exp $
|
| 4 |
|
| 5 |
/**
|
| 6 |
* @file
|
| 7 |
* The (un)install and update code for the tracker2 module.
|
| 8 |
*
|
| 9 |
* @ingroup tracker2
|
| 10 |
*/
|
| 11 |
|
| 12 |
function tracker2_install() {
|
| 13 |
drupal_install_schema('tracker2');
|
| 14 |
tracker2_update_6001();
|
| 15 |
}
|
| 16 |
|
| 17 |
function tracker2_uninstall() {
|
| 18 |
drupal_uninstall_schema('tracker2');
|
| 19 |
variable_del('tracker2_index_nid');
|
| 20 |
variable_del('tracker2_batch_size');
|
| 21 |
variable_del('tracker2_pager');
|
| 22 |
db_drop_index($ret, 'comments', 'tracker_changed');
|
| 23 |
db_drop_index($ret, 'comments', 'tracker_subscription');
|
| 24 |
}
|
| 25 |
|
| 26 |
function tracker2_enable() {
|
| 27 |
$max_nid = db_result(db_query('SELECT MAX(nid) FROM {node}'));
|
| 28 |
variable_set('tracker2_index_nid', $max_nid);
|
| 29 |
if ($max_nid) {
|
| 30 |
drupal_set_message(t('Tracker will index from node %nid downward.', array('%nid' => $max_nid)));
|
| 31 |
}
|
| 32 |
}
|
| 33 |
|
| 34 |
function tracker2_update_6001() {
|
| 35 |
$ret = array();
|
| 36 |
db_add_index($ret, 'comments', 'tracker_changed', array('nid', 'status', 'timestamp'));
|
| 37 |
db_add_index($ret, 'comments', 'tracker_subscription', array('uid', 'nid', 'status'));
|
| 38 |
return $ret;
|
| 39 |
}
|
| 40 |
|
| 41 |
function tracker2_schema() {
|
| 42 |
$schema['tracker2_node'] = array(
|
| 43 |
'description' => 'Track changes to content',
|
| 44 |
'fields' => array(
|
| 45 |
'nid' => array(
|
| 46 |
'type' => 'int',
|
| 47 |
'unsigned' => TRUE,
|
| 48 |
'not null' => TRUE,
|
| 49 |
'description' => "{node}.nid",
|
| 50 |
),
|
| 51 |
'published' => array(
|
| 52 |
'type' => 'int',
|
| 53 |
'size' => 'tiny',
|
| 54 |
'not null' => TRUE,
|
| 55 |
'description' => "True if {node}.status == 1",
|
| 56 |
),
|
| 57 |
'changed' => array(
|
| 58 |
'type' => 'int',
|
| 59 |
'unsigned' => TRUE,
|
| 60 |
'not null' => TRUE,
|
| 61 |
'description' => "{node}.changed",
|
| 62 |
),
|
| 63 |
),
|
| 64 |
'primary key' => array('nid'),
|
| 65 |
'indexes' => array(
|
| 66 |
'tracker' => array('published', 'changed'),
|
| 67 |
),
|
| 68 |
);
|
| 69 |
$schema['tracker2_user'] = array(
|
| 70 |
'fields' => array(
|
| 71 |
'nid' => array(
|
| 72 |
'type' => 'int',
|
| 73 |
'unsigned' => TRUE,
|
| 74 |
'not null' => TRUE,
|
| 75 |
'description' => "{node}.nid"
|
| 76 |
),
|
| 77 |
'uid' => array(
|
| 78 |
'type' => 'int',
|
| 79 |
'unsigned' => TRUE,
|
| 80 |
'not null' => TRUE,
|
| 81 |
'description' => "{user}.uid",
|
| 82 |
),
|
| 83 |
'published' => array(
|
| 84 |
'type' => 'int',
|
| 85 |
'size' => 'tiny',
|
| 86 |
'not null' => TRUE,
|
| 87 |
'description' => "True if {node}.status == 1",
|
| 88 |
),
|
| 89 |
'changed' => array(
|
| 90 |
'type' => 'int',
|
| 91 |
'unsigned' => TRUE,
|
| 92 |
'not null' => TRUE,
|
| 93 |
'description' => "{node}.changed",
|
| 94 |
),
|
| 95 |
),
|
| 96 |
'primary key' => array('nid', 'uid'),
|
| 97 |
'indexes' => array(
|
| 98 |
'tracker' => array('uid', 'published', 'changed'),
|
| 99 |
),
|
| 100 |
);
|
| 101 |
return $schema;
|
| 102 |
}
|