Ignore:
Timestamp:
Feb 25, 2011, 12:22:52 AM (13 years ago)
Author:
plg
Message:

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:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/community/maintain.inc.php

    r3673 r9372  
    1010function plugin_install()
    1111{
    12   $query = "
    13 CREATE TABLE IF NOT EXISTS ".COMMUNITY_TABLE." (
    14   user_id smallint(5) NOT NULL default '0',
    15   permission_level tinyint NOT NULL default 1,
    16   PRIMARY KEY  (user_id)
     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")
    1752)
    18 ;";
    19   pwg_query($query);
     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  }
    2092}
    2193
    2294function plugin_uninstall()
    2395{
    24   $query = 'DROP TABLE '.COMMUNITY_TABLE.';';
     96  global $prefixeTable;
     97 
     98  $query = 'DROP TABLE '.$prefixeTable.'community_permissions;';
     99  pwg_query($query);
     100
     101  $query = 'DROP TABLE '.$prefixeTable.'community_pendings;';
    25102  pwg_query($query);
    26103}
Note: See TracChangeset for help on using the changeset viewer.