| 1 |
<?php
|
| 2 |
// $Id: fivestar_comment.install,v 1.2 2009/05/11 03:12:55 quicksketch Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* @file
|
| 6 |
* Installation file for Fivestar Comment module.
|
| 7 |
*/
|
| 8 |
|
| 9 |
function fivestar_comment_schema() {
|
| 10 |
$schema['fivestar_comment'] = array(
|
| 11 |
'fields' => array(
|
| 12 |
'cid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE),
|
| 13 |
'vote_id' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
|
| 14 |
'value' => array('type' => 'int', 'size' => 'tiny', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
|
| 15 |
'tag' => array('type' => 'varchar', 'length' => 64, 'not null' => TRUE, 'default' => 'vote'),
|
| 16 |
),
|
| 17 |
'primary key' => array('cid'),
|
| 18 |
'indexes' => array(
|
| 19 |
'vote_id' => array('vote_id'),
|
| 20 |
),
|
| 21 |
);
|
| 22 |
return $schema;
|
| 23 |
}
|
| 24 |
|
| 25 |
function fivestar_comment_install() {
|
| 26 |
drupal_install_schema('fivestar_comment');
|
| 27 |
}
|
| 28 |
|
| 29 |
function fivestar_comment_uninstall() {
|
| 30 |
drupal_uninstall_schema('fivestar_comment');
|
| 31 |
db_query("DELETE FROM {variable} WHERE name LIKE 'fivestar_comment_%'");
|
| 32 |
}
|
| 33 |
|
| 34 |
/**
|
| 35 |
* Add vote_id column to the fivestar_comment table. This update will only
|
| 36 |
* be run when upgrading to fivestar schema 6103.
|
| 37 |
*/
|
| 38 |
function fivestar_comment_update_6100() {
|
| 39 |
$ret = array();
|
| 40 |
|
| 41 |
// This update will already be run as fivestar_comment_update_5100 on Drupal 5.
|
| 42 |
if (FIVESTAR_VERSION >= 6100) {
|
| 43 |
db_add_field($ret, 'fivestar_comment', 'vote_id', array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0));
|
| 44 |
db_add_index($ret, 'fivestar_comment', 'vote_id', array('vote_id'));
|
| 45 |
|
| 46 |
$comments = db_query('SELECT fc.cid, fc.value, v.vote_id FROM {fivestar_comment} fc INNER JOIN {comments} c ON fc.cid = c.cid INNER JOIN {votingapi_vote} v ON fc.value = v.value AND c.nid = v.content_id AND c.uid = v.uid WHERE v.tag = "vote" AND v.value_type = "percent" AND v.content_type = "node"');
|
| 47 |
while ($comment = db_fetch_object($comments)) {
|
| 48 |
db_query('UPDATE {fivestar_comment} SET vote_id = %d WHERE cid = %d', $comment->vote_id, $comment->cid);
|
| 49 |
}
|
| 50 |
}
|
| 51 |
|
| 52 |
return $ret;
|
| 53 |
}
|
| 54 |
|
| 55 |
/**
|
| 56 |
* Add tag column to the fivestar_comment table.
|
| 57 |
*/
|
| 58 |
function fivestar_comment_update_6200() {
|
| 59 |
$ret = array();
|
| 60 |
|
| 61 |
db_add_field($ret, 'fivestar_comment', 'tag', array('type' => 'varchar', 'length' => 64, 'not null' => TRUE, 'default' => 'vote'));
|
| 62 |
|
| 63 |
return $ret;
|
| 64 |
}
|