2 rcs_id('$Id: upgrade.php,v 1.2 2004-03-12 15:48:07 rurban Exp $');
5 Copyright 2004 $ThePhpWikiProgrammingTeam
7 This file is (not yet) part of PhpWiki.
9 PhpWiki 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; either version 2 of the License, or
12 (at your option) any later version.
14 PhpWiki is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with PhpWiki; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 * Upgrade the WikiDB and config settings after installing a new
28 * Status: experimental, no queries for verification yet, no db update,
30 * Installation on an existing PhpWiki database needs some
31 * additional worksteps. Each step will require multiple pages.
34 * 1. Check for new or changed database schema and update it
35 * according to some predefined upgrade tables. (medium)
36 * 2. Check for new or changed (localized) pgsrc/ pages and ask
37 * for upgrading these. Check timestamps, upgrade silently or
38 * show diffs if existing. Overwrite or merge (easy)
39 * 3. Check for new or changed or deprecated index.php settings
40 * and help in upgrading these. (hard)
41 * 4. Check for changed plugin invocation arguments. (hard)
42 * 5. Check for changed theme variables. (hard)
44 * @author: Reini Urban
46 require_once("lib/loadsave.php");
48 // see loadsave.php for saving new pages.
49 function CheckPgsrcUpdate(&$request) {
50 $dbh = $request->getDbh();
51 $path = FindLocalizedFile(WIKI_PGSRC);
52 $pgsrc = new fileSet($path);
53 // fixme: verification, ...
54 foreach ($pgsrc->getFiles() as $pagename) {
55 $pagename = urldecode($pagename);
56 if (substr($pagename,-1,1) == '~') continue;
57 if ($dbh->isWikiPage($pagename)) {
59 ; //echo "$pagename exists<br />\n";
61 echo "$pagename does not exist<br />\n";
62 LoadAny($request,$path."/".$pagename);
70 * search table definition in appropriate schema and
74 function installTable(&$dbh, $table) {
75 if (!in_array($DBParam['dbtype'],array('SQL','ADODB'))) return;
76 $backend = 'mysql'; // fixme
77 $schema = findFile("schemas/$backend.sql");
92 * currently update only session, user, pref and member
93 * jeffs-hacks database api (around 1.3.2) later
94 * people should export/import their pages if using that old versions.
96 function CheckDatabaseUpdate($request) {
97 global $DBParam, $DBAuthParams;
98 if (!in_array($DBParam['dbtype'],array('SQL','ADODB'))) return;
99 $dbh = &$request->_dbi;
100 $backend = &$dbh->_backend->_dbh;
101 if ($DBParam['dbtype'] == 'SQL') {
102 $tables = $backend->getListOf('tables');
103 } elseif ($DBParam['dbtype'] == 'ADODB') {
104 $tables = $backend->MetaTables();
111 * Upgrade: Base class for multipage worksteps
112 * identify, validate, display options, next step
117 class Upgrade_CheckPgsrc extends Upgrade {
120 class Upgrade_CheckDatabaseUpdate extends Upgrade {
123 // TODO: At which step are we?
124 // validate and do it again or go on with next step.
126 /** entry function from lib/main.php
128 function DoUpgrade($request) {
130 if (!$request->_user->isAdmin()) {
131 $request->_notAuthorized(WIKIAUTH_ADMIN);
133 HTML::div(array('class' => 'disabled-plugin'),
134 fmt("Upgrade disabled: user != isAdmin")));
138 StartLoadDump($request, _("Upgrading this PhpWiki"));
139 CheckDatabaseUpdate($request);
140 CheckPgsrcUpdate($request);
141 EndLoadDump($request);
146 $Log: not supported by cvs2svn $
154 // c-hanging-comment-ender-p: nil
155 // indent-tabs-mode: nil