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

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

Rewritten version of Community plugin :

  • user upload (web form on gallery side)
  • precise permission manage (who, where, with moderation or not, ability to create sub-albums)
  • email notification to administrators when photos are uploaded

Requires Piwigo 2.2.0RC3

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