| 1 |
<?php
|
| 2 |
// $Id: comment_cck.install,v 1.2 2008/07/14 20:30:44 killes Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* Implementation of hook_install().
|
| 6 |
*/
|
| 7 |
function comment_cck_install() {
|
| 8 |
drupal_install_schema('comment_cck');
|
| 9 |
}
|
| 10 |
|
| 11 |
/**
|
| 12 |
* Implementation of hook_uninstall().
|
| 13 |
*/
|
| 14 |
function comment_cck_uninstall() {
|
| 15 |
drupal_uninstall_schema('comment_cck');
|
| 16 |
variable_del('comment_cck_block_author_fields');
|
| 17 |
variable_del('comment_cck_fields_');
|
| 18 |
foreach (node_get_types('names') as $type_name) {
|
| 19 |
variable_del('comment_cck_node_'. $type_name);
|
| 20 |
variable_del('comment_cck_fields_'. $type_name);
|
| 21 |
}
|
| 22 |
}
|
| 23 |
|
| 24 |
/**
|
| 25 |
* Implementation of hook_schema().
|
| 26 |
*/
|
| 27 |
function comment_cck_schema() {
|
| 28 |
$schema = array();
|
| 29 |
|
| 30 |
$schema['comment_cck_revisions'] = array(
|
| 31 |
'description' => t('This table keeps track of which comments are responsible for which node revisions.'),
|
| 32 |
'fields' => array(
|
| 33 |
'cid' => array(
|
| 34 |
'description' => t('The cid of the comment that corresponds to the revision specified by vid.'),
|
| 35 |
'type' => 'int',
|
| 36 |
'unsigned' => TRUE,
|
| 37 |
'not null' => TRUE,
|
| 38 |
'default' => 0,
|
| 39 |
),
|
| 40 |
'vid' => array(
|
| 41 |
'description' => t('The vid of the revision that corresponds to the comment specified by cid.'),
|
| 42 |
'type' => 'int',
|
| 43 |
'unsigned' => TRUE,
|
| 44 |
'not null' => TRUE,
|
| 45 |
'default' => 0,
|
| 46 |
),
|
| 47 |
'previous_vid' => array(
|
| 48 |
'description' => t('The vid of the revision that corresponds to the comment specified by cid.'),
|
| 49 |
'type' => 'int',
|
| 50 |
'unsigned' => TRUE,
|
| 51 |
'not null' => TRUE,
|
| 52 |
'default' => 0,
|
| 53 |
),
|
| 54 |
),
|
| 55 |
'unique keys' => array(
|
| 56 |
'vid' => array('vid'),
|
| 57 |
),
|
| 58 |
'primary key' => array('cid'),
|
| 59 |
);
|
| 60 |
|
| 61 |
return $schema;
|
| 62 |
}
|
| 63 |
|
| 64 |
/**
|
| 65 |
* Change the primary key from vid to cid, since we always select by cid.
|
| 66 |
*/
|
| 67 |
function comment_cck_update_6000() {
|
| 68 |
$ret = array();
|
| 69 |
db_drop_primary_key($ret, 'comment_cck_revisions');
|
| 70 |
db_add_primary_key($ret, 'comment_cck_revisions', array('cid'));
|
| 71 |
db_add_unique_key($ret, 'comment_cck_revisions', 'vid', array('vid'));
|
| 72 |
return $ret;
|
| 73 |
}
|
| 74 |
|
| 75 |
/**
|
| 76 |
* The nid field is unnecessary.
|
| 77 |
*/
|
| 78 |
function comment_cck_update_6001() {
|
| 79 |
$ret = array();
|
| 80 |
db_drop_field($ret, 'comment_cck_revisions', 'nid');
|
| 81 |
return $ret;
|
| 82 |
}
|
| 83 |
|
| 84 |
/**
|
| 85 |
* Cleanup the database of old variables.
|
| 86 |
*/
|
| 87 |
function comment_cck_update_6002() {
|
| 88 |
$ret = array();
|
| 89 |
// Remove old per-node-type variables.
|
| 90 |
foreach (node_get_types('names') as $type_name) {
|
| 91 |
variable_del('comment_cck_node_'. $type_name);
|
| 92 |
}
|
| 93 |
// Remove phantom variable.
|
| 94 |
variable_del('comment_cck_fields_');
|
| 95 |
return $ret;
|
| 96 |
}
|