source: trunk/install/upgrade_1.3.0.php @ 1932

Last change on this file since 1932 was 1932, checked in by rub, 17 years ago

o add missing $lang
o use of l10n_dec
o normalize file header

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 3.5 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-2007 PhpWebGallery Team - http://phpwebgallery.net |
6// +-----------------------------------------------------------------------+
7// | file          : $Id: upgrade_1.3.0.php 1932 2007-03-29 19:04:54Z rub $
8// | last update   : $Date: 2007-03-29 19:04:54 +0000 (Thu, 29 Mar 2007) $
9// | last modifier : $Author: rub $
10// | revision      : $Revision: 1932 $
11// +-----------------------------------------------------------------------+
12// | This program is free software; you can redistribute it and/or modify  |
13// | it under the terms of the GNU General Public License as published by  |
14// | the Free Software Foundation                                          |
15// |                                                                       |
16// | This program is distributed in the hope that it will be useful, but   |
17// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
18// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
19// | General Public License for more details.                              |
20// |                                                                       |
21// | You should have received a copy of the GNU General Public License     |
22// | along with this program; if not, write to the Free Software           |
23// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
24// | USA.                                                                  |
25// +-----------------------------------------------------------------------+
26
27
28/**
29 * Upgrade from 1.3.0 to 1.3.1
30 */
31
32if (!defined('PHPWG_ROOT_PATH'))
33{
34  die ('This page cannot be loaded directly, load upgrade.php');
35}
36else
37{
38  if (!defined('PHPWG_IN_UPGRADE') or !PHPWG_IN_UPGRADE)
39  {
40    die ('Hacking attempt!');
41  }
42}
43
44$queries = array(
45  "
46ALTER TABLE phpwebgallery_categories
47  ADD COLUMN uppercats varchar(255) NOT NULL default ''
48;",
49
50  "
51CREATE TABLE phpwebgallery_user_category (
52  user_id smallint(5) unsigned NOT NULL default '0'
53)
54;",
55
56  "
57ALTER TABLE phpwebgallery_categories
58  ADD INDEX id (id)
59;",
60
61  "
62ALTER TABLE phpwebgallery_categories
63  ADD INDEX id_uppercat (id_uppercat)
64;",
65
66  "
67ALTER TABLE phpwebgallery_image_category
68  ADD INDEX category_id (category_id)
69;",
70
71  "
72ALTER TABLE phpwebgallery_image_category
73  ADD INDEX image_id (image_id)
74;",
75  );
76
77foreach ($queries as $query)
78{
79  $query = str_replace('phpwebgallery_', PREFIX_TABLE, $query);
80  pwg_query($query);
81}
82// filling the new column categories.uppercats
83$id_uppercats = array();
84
85$query = '
86SELECT id, id_uppercat
87  FROM '.CATEGORIES_TABLE.'
88;';
89$result = pwg_query($query);
90while ($row = mysql_fetch_array($result))
91{
92  if (!isset($row['id_uppercat']) or $row['id_uppercat'] == '')
93  {
94    $row['id_uppercat'] = 'NULL';
95  }
96  $id_uppercats[$row['id']] = $row['id_uppercat'];
97}
98
99$datas = array();
100
101foreach (array_keys($id_uppercats) as $id)
102{
103  $data = array();
104  $data['id'] = $id;
105  $uppercats = array();
106 
107  array_push($uppercats, $id);
108  while (isset($id_uppercats[$id]) and $id_uppercats[$id] != 'NULL')
109  {
110    array_push($uppercats, $id_uppercats[$id]);
111    $id = $id_uppercats[$id];
112  }
113  $data['uppercats'] = implode(',', array_reverse($uppercats));
114
115  array_push($datas, $data);
116}
117
118mass_updates(
119  CATEGORIES_TABLE,
120  array(
121    'primary' => array('id'),
122    'update' => array('uppercats')
123    ),
124  $datas
125  );
126
127// now we upgrade from 1.3.1 to 1.6.0
128include_once(PHPWG_ROOT_PATH.'install/upgrade_1.3.1.php');
129?>
Note: See TracBrowser for help on using the repository browser.