/[drupal]/contributions/modules/advpoll/advpoll.install
ViewVC logotype

Contents of /contributions/modules/advpoll/advpoll.install

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


Revision 1.7 - (show annotations) (download) (as text)
Tue Nov 28 06:36:17 2006 UTC (3 years ago) by chriskennedy
Branch: MAIN
CVS Tags: HEAD
Changes since 1.6: +30 -1 lines
File MIME type: text/x-php
#93788 - preliminary (untested) postgresql support, patch by jaydub with slight modifications
1 <?php
2 // $Id: advpoll.install,v 1.6 2006/11/09 18:16:39 chriskennedy Exp $
3
4
5 /**
6 * Implementation of hook_install().
7 */
8 function advpoll_install() {
9 switch ($GLOBALS['db_type']) {
10 case 'mysql':
11 case 'mysqli':
12 db_query("CREATE TABLE {advpoll} (
13 `nid` int(10) NOT NULL,
14 `quorum` int(10) NOT NULL,
15 `mode` varchar(32) NOT NULL,
16 `uselist` tinyint default '0',
17 `active` tinyint default '1',
18 `runtime` int NOT NULL default '0',
19 `maxchoices` int unsigned NOT NULL default '0',
20 `algorithm` VARCHAR(100),
21 `showvotes` tinyint,
22 `startdate` int unsigned,
23 PRIMARY KEY (`nid`)
24 ) ENGINE=MyISAM /*!40100 DEFAULT CHARACTER SET utf8 */");
25
26 db_query("CREATE TABLE {advpoll_electoral_list} (
27 `nid` int(10) NOT NULL,
28 `uid` int(10) NOT NULL,
29 PRIMARY KEY (`nid`,`uid`)
30 ) ENGINE=MyISAM /*!40100 DEFAULT CHARACTER SET utf8 */");
31
32 db_query("CREATE TABLE {advpoll_choices} (
33 `nid` int(10) NOT NULL,
34 `label` text NOT NULL,
35 `vote_offset` int(2) unsigned default NULL,
36 PRIMARY KEY (`nid`, `vote_offset`),
37 KEY `vote_offset` (`vote_offset`)
38 ) ENGINE=MyISAM /*!40100 DEFAULT CHARACTER SET utf8 */");
39
40 break;
41 case 'pgsql':
42 db_query("CREATE TABLE {advpoll} (
43 nid integer NOT NULL,
44 quorum integer NOT NULL,
45 mode varchar(32) NOT NULL,
46 uselist smallint DEFAULT '0',
47 active smallint DEFAULT '1',
48 runtime integer NOT NULL DEFAULT '0',
49 maxchoices integer NOT NULL DEFAULT '0',
50 algorithm varchar(100),
51 showvotes smallint,
52 startdate integer,
53 PRIMARY KEY (nid)
54 )");
55
56 db_query("CREATE TABLE {advpoll_electoral_list} (
57 nid integer NOT NULL,
58 uid integer NOT NULL,
59 PRIMARY KEY (nid, uid)
60 )");
61
62 db_query("CREATE TABLE {advpoll_choices} (
63 nid integer NOT NULL,
64 label text NOT NULL,
65 vote_offset smallint DEFAULT NULL,
66 PRIMARY KEY (nid, vote_offset)
67 )");
68 db_query("CREATE INDEX {advpoll_choices}_vote_offset_idx ON {advpoll_choices} (vote_offset)");
69 break;
70 }
71 }
72
73 /**
74 * Implementation of hook_uninstall().
75 */
76 function advpoll_uninstall() {
77 db_query('DELETE FROM {votingapi_vote} WHERE content_type="advpoll"');
78 $result = db_query('SELECT nid FROM {advpoll}');
79 while ($obj = db_fetch_object($result)) {
80 node_delete($obj->nid);
81 }
82 db_query('DROP TABLE {advpoll}');
83 db_query('DROP TABLE {advpoll_electoral_list}');
84 db_query('DROP TABLE {advpoll_choices}');
85 variable_del('advpoll_default_mode');
86 variable_del('advpoll_default_electoral_list');
87 }

  ViewVC Help
Powered by ViewVC 1.1.2