[1070] | 1 | <?php |
---|
| 2 | // +-----------------------------------------------------------------------+ |
---|
[2297] | 3 | // | Piwigo - a PHP based picture gallery | |
---|
| 4 | // +-----------------------------------------------------------------------+ |
---|
[5196] | 5 | // | Copyright(C) 2008-2010 Piwigo Team http://piwigo.org | |
---|
[2297] | 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 | // +-----------------------------------------------------------------------+ |
---|
[1070] | 23 | |
---|
| 24 | if (!defined('PHPWG_ROOT_PATH')) |
---|
| 25 | { |
---|
| 26 | die('Hacking attempt!'); |
---|
| 27 | } |
---|
| 28 | |
---|
| 29 | $upgrade_description = 'Field "Status" Table #user_infos changed'; |
---|
| 30 | |
---|
| 31 | include_once(PHPWG_ROOT_PATH.'include/constants.php'); |
---|
| 32 | include(PHPWG_ROOT_PATH . 'include/config_default.inc.php'); |
---|
[5215] | 33 | @include(PHPWG_ROOT_PATH. 'local/config/config.inc.php'); |
---|
[1070] | 34 | |
---|
| 35 | // +-----------------------------------------------------------------------+ |
---|
| 36 | // | Upgrade content | |
---|
| 37 | // +-----------------------------------------------------------------------+ |
---|
| 38 | |
---|
| 39 | echo "Alter table ".USER_INFOS_TABLE; |
---|
| 40 | $query = " |
---|
| 41 | alter table ".USER_INFOS_TABLE." |
---|
| 42 | modify column `status` enum('webmaster', 'admin', 'normal', 'generic', 'guest') NOT NULL default 'guest' |
---|
| 43 | ;"; |
---|
| 44 | pwg_query($query); |
---|
| 45 | |
---|
| 46 | echo "Define webmaster"; |
---|
| 47 | $query = ' |
---|
| 48 | update |
---|
| 49 | '.USER_INFOS_TABLE.' |
---|
| 50 | set status = \'webmaster\' |
---|
| 51 | where |
---|
| 52 | user_id = '.$conf['webmaster_id'].' and status = \'admin\' |
---|
| 53 | ;'; |
---|
| 54 | $result = pwg_query($query); |
---|
| 55 | |
---|
| 56 | echo "Define normal"; |
---|
| 57 | $query = ' |
---|
| 58 | select |
---|
| 59 | user_id |
---|
| 60 | from |
---|
| 61 | '.USER_INFOS_TABLE.' |
---|
| 62 | where |
---|
| 63 | user_id != '.$conf['guest_id'].' and status = \'guest\' |
---|
| 64 | ;'; |
---|
| 65 | $result = pwg_query($query); |
---|
| 66 | |
---|
| 67 | $datas = array(); |
---|
| 68 | |
---|
[4325] | 69 | while ($row = pwg_db_fetch_assoc($result)) |
---|
[1070] | 70 | { |
---|
| 71 | array_push( |
---|
| 72 | $datas, |
---|
| 73 | array( |
---|
| 74 | 'user_id' => $row['user_id'], |
---|
| 75 | 'status' => 'normal' |
---|
| 76 | ) |
---|
| 77 | ); |
---|
| 78 | } |
---|
| 79 | |
---|
| 80 | mass_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 | |
---|
| 93 | echo |
---|
| 94 | "\n" |
---|
| 95 | .'Column '.USER_INFOS_TABLE.'.status changed' |
---|
| 96 | ."\n" |
---|
| 97 | ; |
---|
| 98 | |
---|
| 99 | ?> |
---|