source: extensions/community/maintain.inc.php @ 9484

Last change on this file since 9484 was 9441, checked in by plg, 13 years ago

bug fixed : include/constants.php was removed, no need to include it

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