source: tags/build-Butterfly02/install/db/12-database.php @ 22644

Last change on this file since 22644 was 2299, checked in by plg, 16 years ago

Bug fixed: as rvelices notified me by email, my header replacement script was
bugged (r2297 was repeating new and old header).

By the way, I've also removed the replacement keywords. We were using them
because it was a common usage with CVS but it is advised not to use them with
Subversion. Personnaly, it is a problem when I search differences between 2
Piwigo installations outside Subversion.

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 3.3 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | Piwigo - a PHP based picture gallery                                  |
4// +-----------------------------------------------------------------------+
5// | Copyright(C) 2008      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 = 'Field "Status" Table #user_infos changed';
30
31include_once(PHPWG_ROOT_PATH.'include/constants.php');
32include(PHPWG_ROOT_PATH . 'include/config_default.inc.php');
33@include(PHPWG_ROOT_PATH. 'include/config_local.inc.php');
34
35// +-----------------------------------------------------------------------+
36// |                            Upgrade content                            |
37// +-----------------------------------------------------------------------+
38
39echo "Alter table ".USER_INFOS_TABLE;
40$query = "
41alter table ".USER_INFOS_TABLE."
42  modify column `status` enum('webmaster', 'admin', 'normal', 'generic', 'guest') NOT NULL default 'guest'
43;";
44pwg_query($query);
45
46echo "Define webmaster";
47$query = '
48update
49  '.USER_INFOS_TABLE.'
50set status = \'webmaster\'
51where
52  user_id = '.$conf['webmaster_id'].' and status = \'admin\'
53;';
54$result = pwg_query($query);
55
56echo "Define normal";
57$query = '
58select
59  user_id
60from
61  '.USER_INFOS_TABLE.'
62where
63  user_id != '.$conf['guest_id'].' and status = \'guest\'
64;';
65$result = pwg_query($query);
66
67$datas = array();
68
69while ($row = mysql_fetch_array($result))
70{
71  array_push(
72    $datas,
73    array(
74      'user_id'    => $row['user_id'],
75      'status' => 'normal'
76      )
77    );
78}
79
80mass_updates(
81  USER_INFOS_TABLE,
82  array(
83    'primary' => array('user_id'),
84    'update'  => array('status')
85    ),
86  $datas
87  );
88
89// +-----------------------------------------------------------------------+
90// |                           End notification                            |
91// +-----------------------------------------------------------------------+
92
93echo
94"\n"
95.'Column '.USER_INFOS_TABLE.'.status changed'
96."\n"
97;
98
99?>
Note: See TracBrowser for help on using the repository browser.