source: extensions/community/include/install.inc.php @ 23085

Last change on this file since 23085 was 23085, checked in by plg, 8 years ago

New feature: user album. Only for registered users, no recursivity. Piwigo
will automatically create an upload album for each user with appropriate
community permissions, at first connection.

Bug fixed: on activation, do not create a new "Community" album if it already
exists.

Bug fixed: remove debug for quota

Bug fixed: round corners for number of pending pictures in admin menu.

File size: 4.2 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | Piwigo - a PHP based photo gallery                                    |
4// +-----------------------------------------------------------------------+
5// | Copyright(C) 2008-2013 Piwigo Team                  http://piwigo.org |
6// | Copyright(C) 2003-2008 PhpWebGallery Team    http://phpwebgallery.net |
7// | Copyright(C) 2002-2003 Pierrick LE GALL   http://le-gall.net/pierrick |
8// +-----------------------------------------------------------------------+
9// | This program is free software; you can redistribute it and/or modify  |
10// | it under the terms of the GNU General Public License as published by  |
11// | the Free Software Foundation                                          |
12// |                                                                       |
13// | This program is distributed in the hope that it will be useful, but   |
14// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
15// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
16// | General Public License for more details.                              |
17// |                                                                       |
18// | You should have received a copy of the GNU General Public License     |
19// | along with this program; if not, write to the Free Software           |
20// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
21// | USA.                                                                  |
22// +-----------------------------------------------------------------------+
23
24function community_install()
25{
26  global $conf, $prefixeTable;
27   
28  $query = '
29CREATE TABLE IF NOT EXISTS '.$prefixeTable.'community_permissions (
30  id int(11) NOT NULL AUTO_INCREMENT,
31  type varchar(255) NOT NULL,
32  group_id smallint(5) unsigned DEFAULT NULL,
33  user_id smallint(5) DEFAULT NULL,
34  category_id smallint(5) unsigned DEFAULT NULL,
35  user_album enum(\'true\',\'false\') NOT NULL DEFAULT \'false\',
36  recursive enum(\'true\',\'false\') NOT NULL DEFAULT \'true\',
37  create_subcategories enum(\'true\',\'false\') NOT NULL DEFAULT \'false\',
38  moderated enum(\'true\',\'false\') NOT NULL DEFAULT \'true\',
39  nb_photos int DEFAULT NULL,
40  storage int DEFAULT NULL,
41  PRIMARY KEY (id)
42) ENGINE=MyISAM DEFAULT CHARSET=utf8
43;';
44  pwg_query($query);
45
46  $query = '
47CREATE TABLE IF NOT EXISTS '.$prefixeTable.'community_pendings (
48  image_id mediumint(8) unsigned NOT NULL,
49  state varchar(255) NOT NULL,
50  added_on datetime NOT NULL,
51  validated_by smallint(5) DEFAULT NULL
52) ENGINE=MyISAM DEFAULT CHARSET=utf8
53;';
54  pwg_query($query);
55
56  // column community_permissions.nb_photos added for version 2.5.d
57  $result = pwg_query('SHOW COLUMNS FROM `'.$prefixeTable.'community_permissions` LIKE "nb_photos";');
58  if (!pwg_db_num_rows($result))
59  {     
60    pwg_query('ALTER TABLE `'.$prefixeTable .'community_permissions` ADD `nb_photos` INT DEFAULT NULL;');
61  }
62 
63  // column community_permissions.storage added for version 2.5.d
64  $result = pwg_query('SHOW COLUMNS FROM `'.$prefixeTable.'community_permissions` LIKE "storage";');
65  if (!pwg_db_num_rows($result))
66  {     
67    pwg_query('ALTER TABLE `'.$prefixeTable .'community_permissions` ADD `storage` INT DEFAULT NULL;');
68  }
69
70  // column community_permissions.user_album added for version 2.5.d
71  $result = pwg_query('SHOW COLUMNS FROM `'.$prefixeTable.'community_permissions` LIKE "user_album";');
72  if (!pwg_db_num_rows($result))
73  {     
74    pwg_query('ALTER TABLE `'.$prefixeTable .'community_permissions` ADD `user_album` enum(\'true\',\'false\') NOT NULL DEFAULT \'false\' after `category_id`;');
75  }
76
77  // column categories.community_user added for version 2.5.d
78  $result = pwg_query('SHOW COLUMNS FROM `'.$prefixeTable.'categories` LIKE "community_user";');
79  if (!pwg_db_num_rows($result))
80  {     
81    pwg_query('ALTER TABLE `'.$prefixeTable .'categories` ADD `community_user`  smallint(5) DEFAULT NULL;');
82  }
83
84  if (!isset($conf['community']))
85  {
86    $community_default_config = serialize(
87      array(
88        'user_albums' => false,
89        )
90      );
91   
92    conf_update_param('community', $community_default_config);
93    $conf['community'] = $community_default_config;
94  }
95}
96?>
Note: See TracBrowser for help on using the repository browser.