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

Last change on this file since 8651 was 8651, checked in by plg, 14 years ago

feature 2108 added: user upload removed from core. It will come back as a
"new generation" user upload in the Community plugin.

File size: 3.3 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | Piwigo - a PHP based picture gallery                                  |
4// +-----------------------------------------------------------------------+
5// | Copyright(C) 2008-2010 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
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
63$backup_filepath = $conf['local_data_dir'].'/plugins/core_user_upload_to_community.php';
64mkgetdir(dirname($backup_filepath));
65
66file_put_contents(
67  $backup_filepath,
68  '<?php $user_upload_conf = \''.serialize($user_upload_conf).'\'; ?>'
69  );
70
71//
72// remove all what is related to user upload in the database
73//
74
75// categories.uploadable
76pwg_query('ALTER TABLE '.CATEGORIES_TABLE.' DROP COLUMN uploadable;');
77
78// waiting
79pwg_query('DROP TABLE '.PREFIX_TABLE.'waiting;');
80
81// config parameter settings : upload_user_access, upload_link_everytime
82$query = '
83DELETE FROM '.PREFIX_TABLE.'config
84  WHERE param IN (\'upload_user_access\', \'upload_link_everytime\', \'email_admin_on_picture_uploaded\')
85;';
86pwg_query($query);
87
88echo
89"\n"
90. $upgrade_description
91."\n"
92;
93?>
Note: See TracBrowser for help on using the repository browser.