| 1 |
<?php
|
| 2 |
/**
|
| 3 |
* Implementation of hook_install().
|
| 4 |
*/
|
| 5 |
function nodevote_install() {
|
| 6 |
drupal_install_schema('nodevote');
|
| 7 |
}
|
| 8 |
|
| 9 |
/**
|
| 10 |
* Implementation of hook_schema().
|
| 11 |
*/
|
| 12 |
function nodevote_schema() {
|
| 13 |
$schema = array();
|
| 14 |
$schema['nodevote'] = array(
|
| 15 |
'description' => t('Stores the users\' votes about a node'),
|
| 16 |
'fields' => array(
|
| 17 |
'uid' => array(
|
| 18 |
'description' => t('User ID'),
|
| 19 |
'type' => 'int',
|
| 20 |
'unsigned' => TRUE,
|
| 21 |
'not null' => TRUE,
|
| 22 |
),
|
| 23 |
'nid' => array(
|
| 24 |
'description' => t('Node ID'),
|
| 25 |
'type' => 'int',
|
| 26 |
'unsigned' => TRUE,
|
| 27 |
'not null' => TRUE,
|
| 28 |
),
|
| 29 |
'vote' => array(
|
| 30 |
'description' => t('Amount'),
|
| 31 |
'type' => 'int',
|
| 32 |
'unsigned' => TRUE,
|
| 33 |
'not null' => TRUE,
|
| 34 |
),
|
| 35 |
'timestamp' => array(
|
| 36 |
'description' => t('Timestamp'),
|
| 37 |
'type' => 'int',
|
| 38 |
'length' => 2,
|
| 39 |
'unsigned' => TRUE,
|
| 40 |
'not null' => TRUE,
|
| 41 |
),
|
| 42 |
),
|
| 43 |
'primary key' => array('uid', 'nid'),
|
| 44 |
'indexes' => array('node_nid' => array('nid'), 'user_id' => array('uid')),
|
| 45 |
);
|
| 46 |
return $schema;
|
| 47 |
}
|
| 48 |
|
| 49 |
function nodevote_update_1() {
|
| 50 |
return _system_update_utf8(array('nodevote'));
|
| 51 |
}
|
| 52 |
|
| 53 |
function nodevote_update_2() {
|
| 54 |
$ret = array();
|
| 55 |
$ret[] = update_sql("ALTER TABLE {nodevote} ADD COLUMN timestamp int(11) NOT NULL default '0'");
|
| 56 |
|
| 57 |
return $ret;
|
| 58 |
}
|
| 59 |
|
| 60 |
/**
|
| 61 |
* Implementation of hook_uninstall().
|
| 62 |
*/
|
| 63 |
function nodevote_uninstall() {
|
| 64 |
drupal_uninstall_schema('nodevote');
|
| 65 |
}
|
| 66 |
|