/[drupal]/contributions/modules/fivestar/fivestar_comment.install
ViewVC logotype

Contents of /contributions/modules/fivestar/fivestar_comment.install

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.3 - (show annotations) (download) (as text)
Mon May 11 04:05:39 2009 UTC (6 months, 2 weeks ago) by quicksketch
Branch: MAIN
CVS Tags: DRUPAL-6--1-16, HEAD
Changes since 1.2: +13 -1 lines
File MIME type: text/x-php
#317317: by sped2773 and davidc: Rate on multiple axis with admin UI.
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 }

  ViewVC Help
Powered by ViewVC 1.1.2