source: trunk/admin/include/functions_upgrade.php @ 2819

Last change on this file since 2819 was 2819, checked in by patdenice, 15 years ago
  • Add roma theme to upgrade page.
  • Upgrade translation.
  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 5.0 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
24function check_upgrade()
25{
26  // Is Piwigo already installed ?
27  if (!defined('PHPWG_IN_UPGRADE') or !PHPWG_IN_UPGRADE)
28  {
29    $message = 'Piwigo is not in upgrade mode. In include/mysql.inc.php,
30insert line
31<pre style="background-color:lightgray">
32define(\'PHPWG_IN_UPGRADE\', true);
33</pre>
34if you want to upgrade';
35    die($message);
36  }
37}
38
39// concerning upgrade, we use the default tables
40function prepare_conf_upgrade()
41{
42  global $prefixeTable;
43
44  // $conf is not used for users tables
45  // define cannot be re-defined
46  define('CATEGORIES_TABLE', $prefixeTable.'categories');
47  define('COMMENTS_TABLE', $prefixeTable.'comments');
48  define('CONFIG_TABLE', $prefixeTable.'config');
49  define('FAVORITES_TABLE', $prefixeTable.'favorites');
50  define('GROUP_ACCESS_TABLE', $prefixeTable.'group_access');
51  define('GROUPS_TABLE', $prefixeTable.'groups');
52  define('HISTORY_TABLE', $prefixeTable.'history');
53  define('HISTORY_SUMMARY_TABLE', $prefixeTable.'history_summary');
54  define('IMAGE_CATEGORY_TABLE', $prefixeTable.'image_category');
55  define('IMAGES_TABLE', $prefixeTable.'images');
56  define('SESSIONS_TABLE', $prefixeTable.'sessions');
57  define('SITES_TABLE', $prefixeTable.'sites');
58  define('USER_ACCESS_TABLE', $prefixeTable.'user_access');
59  define('USER_GROUP_TABLE', $prefixeTable.'user_group');
60  define('USERS_TABLE', $prefixeTable.'users');
61  define('USER_INFOS_TABLE', $prefixeTable.'user_infos');
62  define('USER_FEED_TABLE', $prefixeTable.'user_feed');
63  define('WAITING_TABLE', $prefixeTable.'waiting');
64  define('RATE_TABLE', $prefixeTable.'rate');
65  define('USER_CACHE_TABLE', $prefixeTable.'user_cache');
66  define('USER_CACHE_CATEGORIES_TABLE', $prefixeTable.'user_cache_categories');
67  define('CADDIE_TABLE', $prefixeTable.'caddie');
68  define('UPGRADE_TABLE', $prefixeTable.'upgrade');
69  define('SEARCH_TABLE', $prefixeTable.'search');
70  define('USER_MAIL_NOTIFICATION_TABLE', $prefixeTable.'user_mail_notification');
71  define('TAGS_TABLE', $prefixeTable.'tags');
72  define('IMAGE_TAG_TABLE', $prefixeTable.'image_tag');
73  define('PLUGINS_TABLE', $prefixeTable.'plugins');
74  define('OLD_PERMALINKS_TABLE', $prefixeTable.'old_permalinks');
75}
76
77// Create empty local files to avoid log errors
78function create_empty_local_files()
79{
80   $files =
81      array (
82         PHPWG_ROOT_PATH . 'template-common/local-layout.css',
83         PHPWG_ROOT_PATH . 'template/yoga/local-layout.css'
84         );
85
86   foreach ($files as $path)
87   {
88      if (!file_exists ($path))
89      {
90         $file = @fopen($path, "w");
91         @fwrite($file , '/* You can modify this file */');
92         @fclose($file);
93      }
94   }
95}
96
97// Deactivate all non-standard plugins
98function deactivate_non_standard_plugins()
99{
100  global $page;
101
102  $standard_plugins = array(
103    'add_index',
104    'admin_advices',
105    'admin_multi_view',
106    'c13y_upgrade',
107    'event_tracer',
108    'language_switch',
109    'LocalFilesEditor'
110    );
111
112  $query = '
113SELECT id
114FROM '.PREFIX_TABLE.'plugins
115WHERE state = "active"
116AND id NOT IN ("' . implode('","', $standard_plugins) . '")
117;';
118
119  $result = pwg_query($query);
120  $plugins = array();
121  while ($row = mysql_fetch_assoc($result))
122  {
123    array_push($plugins, $row['id']);
124  }
125
126  if (!empty($plugins))
127  {
128    $query = '
129UPDATE '.PREFIX_TABLE.'plugins
130SET state="inactive"
131WHERE id IN ("' . implode('","', $plugins) . '")
132;';
133    mysql_query($query);
134
135    array_push($page['infos'],
136      l10n('deactivated plugins') . '<pre>' . implode(', ', $plugins) . '</pre>');
137  }
138}
139
140?>
Note: See TracBrowser for help on using the repository browser.