source: trunk/install/db/94-database.php @ 16313

Last change on this file since 16313 was 12922, checked in by mistic100, 13 years ago

update Piwigo headers to 2012, last change before the expected (or not) apocalypse

File size: 3.6 KB
RevLine 
[8651]1<?php
2// +-----------------------------------------------------------------------+
[8728]3// | Piwigo - a PHP based photo gallery                                    |
[8651]4// +-----------------------------------------------------------------------+
[12922]5// | Copyright(C) 2008-2012 Piwigo Team                  http://piwigo.org |
[8651]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
24if (!defined('PHPWG_ROOT_PATH'))
25{
26  die('Hacking attempt!');
27}
28
29$upgrade_description = 'remove user upload as core feature and save config for Community plugin';
30
31$user_upload_conf = array();
32
33// upload_user_access
34$conf_orig = $conf;
35load_conf_from_db();
36$user_upload_conf['upload_user_access'] = $conf['upload_user_access'];
37$conf = $conf_orig;
38
39// unvalidated photos submitted by users
40$query = '
41SELECT *
42  FROM '.PREFIX_TABLE.'waiting
43;';
44$result = pwg_query($query);
45$user_upload_conf['waiting_rows'] = array();
46while ($row = pwg_db_fetch_assoc($result)) {
47  array_push($user_upload_conf['waiting_rows'], $row);
48}
49
50// uploadable categories
51$query = '
52SELECT id
53  FROM '.CATEGORIES_TABLE.'
54  WHERE uploadable = \'true\'
55;';
56$result = pwg_query($query);
57$user_upload_conf['uploadable_categories'] = array();
58while ($row = pwg_db_fetch_assoc($result)) {
59  array_push($user_upload_conf['uploadable_categories'], $row['id']);
60}
61
62// save configuration for a future use by the Community plugin
[12802]63$backup_filepath = PHPWG_ROOT_PATH.$conf['data_location'].'plugins/core_user_upload_to_community.php';
[11509]64$save_conf = true;
65if (is_dir(dirname($backup_filepath)))
66{
67  if (!is_writable(dirname($backup_filepath)))
68  {
69    $save_conf = false;
70  }
71}
[12802]72elseif (!is_writable( PHPWG_ROOT_PATH.$conf['data_location'] ))
[11509]73{
74  $save_conf = false;
75}
[8651]76
[11509]77if ($save_conf)
78{
79  mkgetdir(dirname($backup_filepath));
[8651]80
[11509]81  file_put_contents(
82    $backup_filepath,
83    '<?php $user_upload_conf = \''.serialize($user_upload_conf).'\'; ?>'
84    );
85}
86
[8651]87//
88// remove all what is related to user upload in the database
89//
90
91// categories.uploadable
92pwg_query('ALTER TABLE '.CATEGORIES_TABLE.' DROP COLUMN uploadable;');
93
94// waiting
95pwg_query('DROP TABLE '.PREFIX_TABLE.'waiting;');
96
97// config parameter settings : upload_user_access, upload_link_everytime
98$query = '
99DELETE FROM '.PREFIX_TABLE.'config
100  WHERE param IN (\'upload_user_access\', \'upload_link_everytime\', \'email_admin_on_picture_uploaded\')
101;';
102pwg_query($query);
103
104echo
105"\n"
106. $upgrade_description
107."\n"
108;
109?>
Note: See TracBrowser for help on using the repository browser.