1 | <?php |
---|
2 | |
---|
3 | if (!defined("COMMUNITY_PATH")) |
---|
4 | { |
---|
5 | define('COMMUNITY_PATH', PHPWG_PLUGINS_PATH.basename(dirname(__FILE__))); |
---|
6 | } |
---|
7 | |
---|
8 | function plugin_install() |
---|
9 | { |
---|
10 | global $conf, $prefixeTable; |
---|
11 | |
---|
12 | if ('mysql' == $conf['dblayer']) |
---|
13 | { |
---|
14 | $query = ' |
---|
15 | CREATE TABLE '.$prefixeTable.'community_permissions ( |
---|
16 | id int(11) NOT NULL AUTO_INCREMENT, |
---|
17 | type varchar(255) NOT NULL, |
---|
18 | group_id smallint(5) unsigned DEFAULT NULL, |
---|
19 | user_id smallint(5) DEFAULT NULL, |
---|
20 | category_id smallint(5) unsigned DEFAULT NULL, |
---|
21 | recursive enum(\'true\',\'false\') NOT NULL DEFAULT \'true\', |
---|
22 | create_subcategories enum(\'true\',\'false\') NOT NULL DEFAULT \'false\', |
---|
23 | moderated enum(\'true\',\'false\') NOT NULL DEFAULT \'true\', |
---|
24 | PRIMARY KEY (id) |
---|
25 | ) ENGINE=MyISAM DEFAULT CHARACTER SET utf8 |
---|
26 | ;'; |
---|
27 | pwg_query($query); |
---|
28 | |
---|
29 | $query = ' |
---|
30 | CREATE TABLE '.$prefixeTable.'community_pendings ( |
---|
31 | image_id mediumint(8) unsigned NOT NULL, |
---|
32 | state varchar(255) NOT NULL, |
---|
33 | added_on datetime NOT NULL, |
---|
34 | validated_by smallint(5) DEFAULT NULL |
---|
35 | ) ENGINE=MyISAM DEFAULT CHARACTER SET utf8 |
---|
36 | ;'; |
---|
37 | pwg_query($query); |
---|
38 | } |
---|
39 | elseif ('pgsql' == $conf['dblayer']) |
---|
40 | { |
---|
41 | $query = ' |
---|
42 | CREATE TABLE "'.$prefixeTable.'community_permissions" ( |
---|
43 | "id" serial NOT NULL, |
---|
44 | "type" VARCHAR(255) NOT NULL, |
---|
45 | "group_id" INTEGER, |
---|
46 | "user_id" INTEGER, |
---|
47 | "category_id" INTEGER, |
---|
48 | "recursive" BOOLEAN default true, |
---|
49 | "create_subcategories" BOOLEAN default false, |
---|
50 | "moderated" BOOLEAN default true, |
---|
51 | PRIMARY KEY ("id") |
---|
52 | ) |
---|
53 | ;'; |
---|
54 | pwg_query($query); |
---|
55 | |
---|
56 | $query = ' |
---|
57 | CREATE TABLE "'.$prefixeTable.'community_pendings" ( |
---|
58 | image_id INTEGER NOT NULL, |
---|
59 | state VARCHAR(255) NOT NULL, |
---|
60 | added_on TIMESTAMP NOT NULL, |
---|
61 | validated_by INTEGER |
---|
62 | ) |
---|
63 | ;'; |
---|
64 | pwg_query($query); |
---|
65 | } |
---|
66 | else |
---|
67 | { |
---|
68 | $query = ' |
---|
69 | CREATE TABLE "'.$prefixeTable.'community_permissions" ( |
---|
70 | "id" INTEGER NOT NULL, |
---|
71 | "type" VARCHAR(255) NOT NULL, |
---|
72 | "group_id" INTEGER, |
---|
73 | "user_id" INTEGER, |
---|
74 | "category_id" INTEGER, |
---|
75 | "recursive" BOOLEAN default true, |
---|
76 | "create_subcategories" BOOLEAN default false, |
---|
77 | "moderated" BOOLEAN default true, |
---|
78 | PRIMARY KEY ("id") |
---|
79 | ) |
---|
80 | ;'; |
---|
81 | pwg_query($query); |
---|
82 | |
---|
83 | $query = ' |
---|
84 | CREATE TABLE "'.$prefixeTable.'community_pendings" ( |
---|
85 | image_id INTEGER NOT NULL, |
---|
86 | state VARCHAR(255) NOT NULL, |
---|
87 | added_on TIMESTAMP NOT NULL, |
---|
88 | validated_by INTEGER |
---|
89 | ) |
---|
90 | ;'; |
---|
91 | pwg_query($query); |
---|
92 | } |
---|
93 | } |
---|
94 | |
---|
95 | function plugin_uninstall() |
---|
96 | { |
---|
97 | global $prefixeTable; |
---|
98 | |
---|
99 | $query = 'DROP TABLE '.$prefixeTable.'community_permissions;'; |
---|
100 | pwg_query($query); |
---|
101 | |
---|
102 | $query = 'DROP TABLE '.$prefixeTable.'community_pendings;'; |
---|
103 | pwg_query($query); |
---|
104 | } |
---|
105 | ?> |
---|