2006-07-13 13:14:25 +00:00
|
|
|
<?php
|
2006-07-14 01:05:10 +00:00
|
|
|
// $Id$
|
2006-07-13 13:14:25 +00:00
|
|
|
|
2006-09-01 07:40:08 +00:00
|
|
|
/**
|
|
|
|
* Implementation of hook_install().
|
|
|
|
*/
|
2006-07-13 13:14:25 +00:00
|
|
|
function poll_install() {
|
2007-05-25 12:46:46 +00:00
|
|
|
// Create tables.
|
|
|
|
drupal_install_schema('poll');
|
2006-07-13 13:14:25 +00:00
|
|
|
}
|
2006-09-01 07:40:08 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Implementation of hook_uninstall().
|
|
|
|
*/
|
|
|
|
function poll_uninstall() {
|
2007-05-25 12:46:46 +00:00
|
|
|
// Remove tables.
|
|
|
|
drupal_uninstall_schema('poll');
|
2006-09-01 07:40:08 +00:00
|
|
|
}
|
2007-10-05 14:43:26 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Implementation of hook_schema().
|
|
|
|
*/
|
|
|
|
function poll_schema() {
|
|
|
|
$schema['poll'] = array(
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'Stores poll-specific information for poll nodes.',
|
2007-10-05 14:43:26 +00:00
|
|
|
'fields' => array(
|
2008-03-15 12:31:29 +00:00
|
|
|
'nid' => array(
|
2007-10-10 11:39:35 +00:00
|
|
|
'type' => 'int',
|
|
|
|
'unsigned' => TRUE,
|
|
|
|
'not null' => TRUE,
|
|
|
|
'default' => 0,
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => "The poll's {node}.nid.",
|
2008-03-15 12:31:29 +00:00
|
|
|
),
|
2007-10-10 11:39:35 +00:00
|
|
|
'runtime' => array(
|
|
|
|
'type' => 'int',
|
|
|
|
'not null' => TRUE,
|
|
|
|
'default' => 0,
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'The number of seconds past {node}.created during which the poll is open.',
|
2008-03-15 12:31:29 +00:00
|
|
|
),
|
|
|
|
'active' => array(
|
2007-10-10 11:39:35 +00:00
|
|
|
'type' => 'int',
|
|
|
|
'unsigned' => TRUE,
|
|
|
|
'not null' => TRUE,
|
|
|
|
'default' => 0,
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'Boolean indicating whether or not the poll is open.',
|
2007-10-10 11:39:35 +00:00
|
|
|
),
|
2008-03-15 12:31:29 +00:00
|
|
|
),
|
2007-10-05 14:43:26 +00:00
|
|
|
'primary key' => array('nid'),
|
2008-03-15 12:31:29 +00:00
|
|
|
);
|
2007-10-05 14:43:26 +00:00
|
|
|
|
2008-12-05 12:50:28 +00:00
|
|
|
$schema['poll_choice'] = array(
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'Stores information about all choices for all {poll}s.',
|
2007-10-05 14:43:26 +00:00
|
|
|
'fields' => array(
|
2008-03-15 12:31:29 +00:00
|
|
|
'chid' => array(
|
2007-10-10 11:39:35 +00:00
|
|
|
'type' => 'serial',
|
|
|
|
'unsigned' => TRUE,
|
|
|
|
'not null' => TRUE,
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'Unique identifier for a poll choice.',
|
2008-03-15 12:31:29 +00:00
|
|
|
),
|
|
|
|
'nid' => array(
|
2007-10-10 11:39:35 +00:00
|
|
|
'type' => 'int',
|
|
|
|
'unsigned' => TRUE,
|
|
|
|
'not null' => TRUE,
|
|
|
|
'default' => 0,
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'The {node}.nid this choice belongs to.',
|
2008-03-15 12:31:29 +00:00
|
|
|
),
|
|
|
|
'chtext' => array(
|
2007-10-10 11:39:35 +00:00
|
|
|
'type' => 'varchar',
|
|
|
|
'length' => 128,
|
|
|
|
'not null' => TRUE,
|
|
|
|
'default' => '',
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'The text for this choice.',
|
2008-03-15 12:31:29 +00:00
|
|
|
),
|
2007-10-10 11:39:35 +00:00
|
|
|
'chvotes' => array(
|
|
|
|
'type' => 'int',
|
|
|
|
'not null' => TRUE,
|
|
|
|
'default' => 0,
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'The total number of votes this choice has received by all users.',
|
2008-03-15 12:31:29 +00:00
|
|
|
),
|
2008-05-15 20:56:48 +00:00
|
|
|
'weight' => array(
|
2007-10-10 11:39:35 +00:00
|
|
|
'type' => 'int',
|
2008-05-15 20:56:48 +00:00
|
|
|
'size' => 'tiny',
|
2007-10-10 11:39:35 +00:00
|
|
|
'not null' => TRUE,
|
|
|
|
'default' => 0,
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'The sort order of this choice among all choices for the same node.',
|
2007-10-10 11:39:35 +00:00
|
|
|
),
|
2008-03-15 12:31:29 +00:00
|
|
|
),
|
2007-10-10 11:39:35 +00:00
|
|
|
'indexes' => array(
|
2008-03-15 12:31:29 +00:00
|
|
|
'nid' => array('nid'),
|
|
|
|
),
|
2007-10-05 14:43:26 +00:00
|
|
|
'primary key' => array('chid'),
|
2008-03-15 12:31:29 +00:00
|
|
|
);
|
2007-10-12 14:10:18 +00:00
|
|
|
|
2008-12-05 12:50:28 +00:00
|
|
|
$schema['poll_vote'] = array(
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'Stores per-{users} votes for each {poll}.',
|
2007-10-05 14:43:26 +00:00
|
|
|
'fields' => array(
|
2008-05-15 20:56:48 +00:00
|
|
|
'chid' => array(
|
|
|
|
'type' => 'int',
|
|
|
|
'unsigned' => TRUE,
|
|
|
|
'not null' => TRUE,
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => "The {users}'s vote for this poll.",
|
2008-05-15 20:56:48 +00:00
|
|
|
),
|
2008-03-15 12:31:29 +00:00
|
|
|
'nid' => array(
|
2007-10-10 11:39:35 +00:00
|
|
|
'type' => 'int',
|
|
|
|
'unsigned' => TRUE,
|
|
|
|
'not null' => TRUE,
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'The {poll} node this vote is for.',
|
2008-03-15 12:31:29 +00:00
|
|
|
),
|
|
|
|
'uid' => array(
|
2007-10-10 11:39:35 +00:00
|
|
|
'type' => 'int',
|
|
|
|
'unsigned' => TRUE,
|
|
|
|
'not null' => TRUE,
|
|
|
|
'default' => 0,
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'The {users}.uid this vote is from unless the voter was anonymous.',
|
2008-03-15 12:31:29 +00:00
|
|
|
),
|
2007-10-10 11:39:35 +00:00
|
|
|
'hostname' => array(
|
|
|
|
'type' => 'varchar',
|
|
|
|
'length' => 128,
|
|
|
|
'not null' => TRUE,
|
|
|
|
'default' => '',
|
2008-11-15 13:01:11 +00:00
|
|
|
'description' => 'The IP address this vote is from unless the voter was logged in.',
|
2007-10-10 11:39:35 +00:00
|
|
|
),
|
2008-03-15 12:31:29 +00:00
|
|
|
),
|
2007-12-18 12:59:22 +00:00
|
|
|
'primary key' => array('nid', 'uid', 'hostname'),
|
2007-10-05 14:43:26 +00:00
|
|
|
'indexes' => array(
|
2008-05-15 20:56:48 +00:00
|
|
|
'chid' => array('chid'),
|
2007-10-05 14:43:26 +00:00
|
|
|
'hostname' => array('hostname'),
|
2008-03-15 12:31:29 +00:00
|
|
|
'uid' => array('uid'),
|
|
|
|
),
|
|
|
|
);
|
2007-10-05 14:43:26 +00:00
|
|
|
|
|
|
|
return $schema;
|
|
|
|
}
|
2008-12-05 12:50:28 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Rename {poll_choices} table to {poll_choice} and {poll_votes} to {poll_vote}.
|
|
|
|
*/
|
|
|
|
function poll_update_7001() {
|
|
|
|
$ret = array();
|
|
|
|
db_rename_table($ret, 'poll_choices', 'poll_choice');
|
|
|
|
db_rename_table($ret, 'poll_votes', 'poll_vote');
|
|
|
|
return $ret;
|
|
|
|
}
|