source: trunk/install/upgrade_1.4.0.php @ 1028

Last change on this file since 1028 was 911, checked in by plg, 19 years ago
  • bug 181 fixed: "Parameters not created in phpwebgallery_config during upgrade". gallery_title and gallery_description had not been added to config table. (use|show)_(exif|iptc) and authorize_remembering have also been removed...
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.4 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | PhpWebGallery - a PHP based picture gallery                           |
4// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
5// | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net |
6// +-----------------------------------------------------------------------+
7// | branch        : BSF (Best So Far)
8// | file          : $RCSfile$
9// | last update   : $Date: 2005-10-23 21:02:21 +0000 (Sun, 23 Oct 2005) $
10// | last modifier : $Author: plg $
11// | revision      : $Revision: 911 $
12// +-----------------------------------------------------------------------+
13// | This program is free software; you can redistribute it and/or modify  |
14// | it under the terms of the GNU General Public License as published by  |
15// | the Free Software Foundation                                          |
16// |                                                                       |
17// | This program is distributed in the hope that it will be useful, but   |
18// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
19// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
20// | General Public License for more details.                              |
21// |                                                                       |
22// | You should have received a copy of the GNU General Public License     |
23// | along with this program; if not, write to the Free Software           |
24// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
25// | USA.                                                                  |
26// +-----------------------------------------------------------------------+
27
28if (!defined('PHPWG_ROOT_PATH'))
29{
30  die ('This page cannot be loaded directly, load upgrade.php');
31}
32else
33{
34  if (!defined('PHPWG_IN_UPGRADE') or !PHPWG_IN_UPGRADE)
35  {
36    die ('Hacking attempt!');
37  }
38}
39
40$last_time = get_moment();
41
42// will the user have to edit include/config_local.inc.php for
43// prefix_thumbnail configuration parameter
44$query = '
45SELECT value
46  FROM '.CONFIG_TABLE.'
47  WHERE param = \'prefix_thumbnail\'
48;';
49list($prefix_thumbnail) = mysql_fetch_array(pwg_query($query));
50
51// delete obsolete configuration
52$query = '
53DELETE
54  FROM '.PREFIX_TABLE.'config
55  WHERE param IN (
56   \'prefix_thumbnail\',
57   \'mail_webmaster\',
58   \'upload_maxfilesize\',
59   \'upload_maxwidth\',
60   \'upload_maxheight\',
61   \'upload_maxwidth_thumbnail\',
62   \'upload_maxheight_thumbnail\',
63   \'mail_notification\',
64   \'use_iptc\',
65   \'use_exif\',
66   \'show_iptc\',
67   \'show_exif\',
68   \'authorize_remembering\'
69   )
70;';
71mysql_query($query);
72
73$queries = array(
74
75  "
76ALTER TABLE phpwebgallery_categories
77  CHANGE COLUMN date_last date_last datetime default NULL
78;",
79
80  "
81ALTER TABLE phpwebgallery_comments
82  ADD COLUMN validation_date datetime default NULL
83;",
84
85  "
86UPDATE phpwebgallery_comments
87  SET validation_date = date
88",
89
90  "
91ALTER TABLE phpwebgallery_comments
92  ADD INDEX comments_i1 (image_id)
93;",
94
95  "
96ALTER TABLE phpwebgallery_comments
97  ADD INDEX comments_i2 (validation_date)
98;",
99
100  "
101ALTER TABLE phpwebgallery_favorites
102  CHANGE COLUMN user_id user_id smallint(5) NOT NULL default '0'
103;",
104
105  "
106ALTER TABLE phpwebgallery_images
107  CHANGE COLUMN date_available
108    date_available datetime NOT NULL default '0000-00-00 00:00:00'
109;",
110
111  "
112ALTER TABLE phpwebgallery_rate
113  CHANGE COLUMN user_id user_id smallint(5) NOT NULL default '0'
114;",
115
116  "
117ALTER TABLE phpwebgallery_sessions
118  CHANGE COLUMN user_id user_id smallint(5) NOT NULL default '0'
119;",
120
121  "
122ALTER TABLE phpwebgallery_user_access
123  CHANGE COLUMN user_id user_id smallint(5) NOT NULL default '0'
124;",
125
126  "
127DROP TABLE phpwebgallery_user_forbidden
128;",
129
130  "
131ALTER TABLE phpwebgallery_user_group
132 CHANGE COLUMN user_id user_id smallint(5) NOT NULL default '0'
133;",
134
135  "
136ALTER TABLE phpwebgallery_users
137  CHANGE COLUMN id id smallint(5) NOT NULL auto_increment
138;",
139
140  "
141CREATE TABLE phpwebgallery_caddie (
142  user_id smallint(5) NOT NULL default '0',
143  element_id mediumint(8) NOT NULL default '0',
144  PRIMARY KEY  (user_id,element_id)
145) TYPE=MyISAM
146;",
147
148  "
149CREATE TABLE phpwebgallery_user_cache (
150  user_id smallint(5) NOT NULL default '0',
151  need_update enum('true','false') NOT NULL default 'true',
152  forbidden_categories text,
153  PRIMARY KEY  (user_id)
154) TYPE=MyISAM
155;",
156
157  "
158CREATE TABLE phpwebgallery_user_feed (
159  id varchar(50) binary NOT NULL default '',
160  user_id smallint(5) NOT NULL default '0',
161  last_check datetime default NULL,
162  PRIMARY KEY  (id)
163) TYPE=MyISAM
164;",
165
166  "
167CREATE TABLE phpwebgallery_user_infos (
168  user_id smallint(5) NOT NULL default '0',
169  nb_image_line tinyint(1) unsigned NOT NULL default '5',
170  nb_line_page tinyint(3) unsigned NOT NULL default '3',
171  status enum('admin','guest') NOT NULL default 'guest',
172  language varchar(50) NOT NULL default 'english',
173  maxwidth smallint(6) default NULL,
174  maxheight smallint(6) default NULL,
175  expand enum('true','false') NOT NULL default 'false',
176  show_nb_comments enum('true','false') NOT NULL default 'false',
177  recent_period tinyint(3) unsigned NOT NULL default '7',
178  template varchar(255) NOT NULL default 'yoga',
179  registration_date datetime NOT NULL default '0000-00-00 00:00:00',
180  UNIQUE KEY user_infos_ui1 (user_id)
181) TYPE=MyISAM
182;"
183  );
184
185foreach ($queries as $query)
186{
187  $query = str_replace('phpwebgallery_', PREFIX_TABLE, $query);
188  pwg_query($query);
189}
190
191$new_time = get_moment();
192echo '<pre>['.get_elapsed_time($last_time, $new_time).']';
193echo ' Basic database structure upgrade done</pre>';
194flush();
195$last_time = $new_time;
196
197// user datas migration from phpwebgallery_users to phpwebgallery_user_infos
198$query = '
199SELECT *
200  FROM '.USERS_TABLE.'
201;';
202
203$datas = array();
204list($dbnow) = mysql_fetch_row(pwg_query('SELECT NOW();'));
205
206$result = pwg_query($query);
207while ($row = mysql_fetch_array($result))
208{
209  $row['user_id'] = $row['id'];
210  $row['registration_date'] = $dbnow;
211  array_push($datas, $row);
212}
213
214include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
215mass_inserts(
216  USER_INFOS_TABLE,
217  array(
218    'user_id',
219    'nb_image_line',
220    'nb_line_page',
221    'status',
222    'language',
223    'maxwidth',
224    'maxheight',
225    'expand',
226    'show_nb_comments',
227    'recent_period',
228    'template',
229    'registration_date'
230    ),
231  $datas
232  );
233
234$queries = array(
235
236  "
237UPDATE ".USER_INFOS_TABLE."
238  SET template = 'yoga'
239;",
240
241  "
242UPDATE ".USER_INFOS_TABLE."
243  SET language = 'en_UK.iso-8859-1'
244  WHERE language NOT IN ('en_UK.iso-8859-1', 'fr_FR.iso-8859-1')
245;",
246
247  "
248UPDATE ".CONFIG_TABLE."
249  SET value = 'en_UK.iso-8859-1'
250  WHERE param = 'default_language'
251    AND value NOT IN ('en_UK.iso-8859-1', 'fr_FR.iso-8859-1')
252;",
253
254  "
255UPDATE ".CONFIG_TABLE."
256  SET value = 'yoga'
257  WHERE param = 'default_template'
258;",
259
260  "
261INSERT INTO ".CONFIG_TABLE."
262  (param,value,comment)
263  VALUES
264  (
265    'gallery_title',
266    'PhpWebGallery demonstration site',
267    'Title at top of each page and for RSS feed'
268  )
269;",
270
271  "
272INSERT INTO ".CONFIG_TABLE."
273  (param,value,comment)
274  VALUES
275  (
276    'gallery_description',
277    'My photos web site',
278    'Short description displayed with gallery title'
279  )
280;"
281
282  );
283
284foreach ($queries as $query)
285{
286  $query = str_replace('phpwebgallery_', PREFIX_TABLE, $query);
287  pwg_query($query);
288}
289
290$infos = array();
291
292if ($prefix_thumbnail != 'TN-')
293{
294  array_push(
295    $infos,
296    'the thumbnail prefix configuration parameter was moved to configuration
297file, copy config_local.inc.php from "tools" directory to "include" directory
298and edit $conf[\'prefix_thumbnail\'] = '.$prefix_thumbnail
299    );
300}
301
302?>
Note: See TracBrowser for help on using the repository browser.