| webmaster@1 | 1 <?php | 
| webmaster@1 | 2 // $Id: poll.install,v 1.13 2007/12/18 12:59:21 dries Exp $ | 
| webmaster@1 | 3 | 
| webmaster@1 | 4 /** | 
| webmaster@1 | 5  * Implementation of hook_install(). | 
| webmaster@1 | 6  */ | 
| webmaster@1 | 7 function poll_install() { | 
| webmaster@1 | 8   // Create tables. | 
| webmaster@1 | 9   drupal_install_schema('poll'); | 
| webmaster@1 | 10 } | 
| webmaster@1 | 11 | 
| webmaster@1 | 12 /** | 
| webmaster@1 | 13  * Implementation of hook_uninstall(). | 
| webmaster@1 | 14  */ | 
| webmaster@1 | 15 function poll_uninstall() { | 
| webmaster@1 | 16   // Remove tables. | 
| webmaster@1 | 17   drupal_uninstall_schema('poll'); | 
| webmaster@1 | 18 } | 
| webmaster@1 | 19 | 
| webmaster@1 | 20 /** | 
| webmaster@1 | 21  * Implementation of hook_schema(). | 
| webmaster@1 | 22  */ | 
| webmaster@1 | 23 function poll_schema() { | 
| webmaster@1 | 24   $schema['poll'] = array( | 
| webmaster@1 | 25     'description' => t('Stores poll-specific information for poll nodes.'), | 
| webmaster@1 | 26     'fields' => array( | 
| webmaster@1 | 27       'nid'     => array( | 
| webmaster@1 | 28         'type' => 'int', | 
| webmaster@1 | 29         'unsigned' => TRUE, | 
| webmaster@1 | 30         'not null' => TRUE, | 
| webmaster@1 | 31         'default' => 0, | 
| webmaster@1 | 32         'description' => t("The poll's {node}.nid.") | 
| webmaster@1 | 33         ), | 
| webmaster@1 | 34       'runtime' => array( | 
| webmaster@1 | 35         'type' => 'int', | 
| webmaster@1 | 36         'not null' => TRUE, | 
| webmaster@1 | 37         'default' => 0, | 
| webmaster@1 | 38         'description' => t('The number of seconds past {node}.created during which the poll is open.') | 
| webmaster@1 | 39         ), | 
| webmaster@1 | 40       'active'  => array( | 
| webmaster@1 | 41         'type' => 'int', | 
| webmaster@1 | 42         'unsigned' => TRUE, | 
| webmaster@1 | 43         'not null' => TRUE, | 
| webmaster@1 | 44         'default' => 0, | 
| webmaster@1 | 45         'description' => t('Boolean indicating whether or not the poll is open.'), | 
| webmaster@1 | 46         ), | 
| webmaster@1 | 47       ), | 
| webmaster@1 | 48     'primary key' => array('nid'), | 
| webmaster@1 | 49     ); | 
| webmaster@1 | 50 | 
| webmaster@1 | 51   $schema['poll_choices'] = array( | 
| webmaster@1 | 52     'description' => t('Stores information about all choices for all {poll}s.'), | 
| webmaster@1 | 53     'fields' => array( | 
| webmaster@1 | 54       'chid'    => array( | 
| webmaster@1 | 55         'type' => 'serial', | 
| webmaster@1 | 56         'unsigned' => TRUE, | 
| webmaster@1 | 57         'not null' => TRUE, | 
| webmaster@1 | 58         'description' => t('Unique identifier for a poll choice.'), | 
| webmaster@1 | 59         ), | 
| webmaster@1 | 60       'nid'     => array( | 
| webmaster@1 | 61         'type' => 'int', | 
| webmaster@1 | 62         'unsigned' => TRUE, | 
| webmaster@1 | 63         'not null' => TRUE, | 
| webmaster@1 | 64         'default' => 0, | 
| webmaster@1 | 65         'description' => t('The {node}.nid this choice belongs to.'), | 
| webmaster@1 | 66         ), | 
| webmaster@1 | 67       'chtext'  => array( | 
| webmaster@1 | 68         'type' => 'varchar', | 
| webmaster@1 | 69         'length' => 128, | 
| webmaster@1 | 70         'not null' => TRUE, | 
| webmaster@1 | 71         'default' => '', | 
| webmaster@1 | 72         'description' => t('The text for this choice.'), | 
| webmaster@1 | 73         ), | 
| webmaster@1 | 74       'chvotes' => array( | 
| webmaster@1 | 75         'type' => 'int', | 
| webmaster@1 | 76         'not null' => TRUE, | 
| webmaster@1 | 77         'default' => 0, | 
| webmaster@1 | 78         'description' => t('The total number of votes this choice has received by all users.'), | 
| webmaster@1 | 79         ), | 
| webmaster@1 | 80       'chorder' => array( | 
| webmaster@1 | 81         'type' => 'int', | 
| webmaster@1 | 82         'not null' => TRUE, | 
| webmaster@1 | 83         'default' => 0, | 
| webmaster@1 | 84         'description' => t('The sort order of this choice among all choices for the same node.'), | 
| webmaster@1 | 85         ) | 
| webmaster@1 | 86       ), | 
| webmaster@1 | 87     'indexes' => array( | 
| webmaster@1 | 88       'nid' => array('nid') | 
| webmaster@1 | 89       ), | 
| webmaster@1 | 90     'primary key' => array('chid'), | 
| webmaster@1 | 91     ); | 
| webmaster@1 | 92 | 
| webmaster@1 | 93   $schema['poll_votes'] = array( | 
| webmaster@1 | 94     'description' => t('Stores per-{users} votes for each {poll}.'), | 
| webmaster@1 | 95     'fields' => array( | 
| webmaster@1 | 96       'nid'      => array( | 
| webmaster@1 | 97         'type' => 'int', | 
| webmaster@1 | 98         'unsigned' => TRUE, | 
| webmaster@1 | 99         'not null' => TRUE, | 
| webmaster@1 | 100         'description' => t('The {poll} node this vote is for.'), | 
| webmaster@1 | 101         ), | 
| webmaster@1 | 102       'uid'      => array( | 
| webmaster@1 | 103         'type' => 'int', | 
| webmaster@1 | 104         'unsigned' => TRUE, | 
| webmaster@1 | 105         'not null' => TRUE, | 
| webmaster@1 | 106         'default' => 0, | 
| webmaster@1 | 107         'description' => t('The {users}.uid this vote is from unless the voter was anonymous.'), | 
| webmaster@1 | 108         ), | 
| webmaster@1 | 109       'chorder'  => array( | 
| webmaster@1 | 110         'type' => 'int', | 
| webmaster@1 | 111         'not null' => TRUE, | 
| webmaster@1 | 112         'default' => -1, | 
| webmaster@1 | 113         'description' => t("The {users}'s vote for this poll."), | 
| webmaster@1 | 114         ), | 
| webmaster@1 | 115       'hostname' => array( | 
| webmaster@1 | 116         'type' => 'varchar', | 
| webmaster@1 | 117         'length' => 128, | 
| webmaster@1 | 118         'not null' => TRUE, | 
| webmaster@1 | 119         'default' => '', | 
| webmaster@1 | 120         'description' => t('The IP address this vote is from unless the voter was logged in.'), | 
| webmaster@1 | 121         ), | 
| webmaster@1 | 122       ), | 
| webmaster@1 | 123     'primary key' => array('nid', 'uid', 'hostname'), | 
| webmaster@1 | 124     'indexes' => array( | 
| webmaster@1 | 125       'hostname' => array('hostname'), | 
| webmaster@1 | 126       'uid'      => array('uid'), | 
| webmaster@1 | 127       ), | 
| webmaster@1 | 128     ); | 
| webmaster@1 | 129 | 
| webmaster@1 | 130   return $schema; | 
| webmaster@1 | 131 } | 
| webmaster@1 | 132 |