- major overhaul of installation

- support for update script
- running sql script after configuration
This commit is contained in:
steinm 2011-12-06 16:39:41 +00:00
parent 1221996207
commit deebe92707
4 changed files with 150 additions and 41 deletions

View File

@ -88,6 +88,7 @@ function printCheckError($resCheck) { /* {{{ */
* Load default settings + set
*/
define("LETODMS_INSTALL", "on");
define("LETODMS_VERSION", "3.3.0");
require_once('../inc/inc.ClassSettings.php');
@ -142,7 +143,7 @@ include("../inc/inc.ClassUI.php");
UI::htmlStartPage("INSTALL");
UI::contentHeading("letoDMS Installation...");
UI::contentHeading("letoDMS Installation for version ".LETODMS_VERSION);
UI::contentContainerStart();
@ -158,9 +159,9 @@ if (isset($_GET['phpinfo'])) {
}
/**
* Show phpinfo
* check if ENABLE_INSTALL_TOOL shall be removed
*/
if (isset($_GET['disableinstall'])) {
if (isset($_GET['disableinstall'])) { /* {{{ */
if(file_exists($configDir."/ENABLE_INSTALL_TOOL")) {
if(unlink($configDir."/ENABLE_INSTALL_TOOL")) {
echo getMLText("settings_install_disabled");
@ -179,12 +180,12 @@ if (isset($_GET['disableinstall'])) {
UI::contentContainerEnd();
UI::htmlEndPage();
exit();
}
} /* }}} */
/**
* Check System
*/
if (printCheckError( $settings->checkSystem())) {
if (printCheckError( $settings->checkSystem())) { /* {{{ */
if (function_exists("apache_get_version")) {
echo "<br/>Apache version: " . apache_get_version();
}
@ -200,7 +201,7 @@ if (printCheckError( $settings->checkSystem())) {
echo '<a href="' . $httpRoot . 'install/install.php?phpinfo">' . getMLText("version_info") . '</a>';
exit;
}
} /* }}} */
if (isset($_POST["action"])) $action=$_POST["action"];
@ -230,7 +231,7 @@ if ($action=="setSettings") {
/**
* Check Parameters, require version 3.3.x
*/
$hasError = printCheckError( $settings->check('33'));
$hasError = printCheckError( $settings->check(substr(str_replace('.', '', LETODMS_VERSION), 0,2)));
if (!$hasError)
{
@ -240,7 +241,7 @@ if ($action=="setSettings") {
$createOK = false;
$errorMsg = "";
include $settings->_ADOdbPath."adodb/adodb.inc.php";
require_once($settings->_ADOdbPath."adodb/adodb.inc.php");
$connTmp = ADONewConnection($settings->_dbDriver);
if ($connTmp) {
$connTmp->Connect($settings->_dbHostname, $settings->_dbUser, $settings->_dbPass, $settings->_dbDatabase);
@ -286,18 +287,60 @@ if ($action=="setSettings") {
if (!$hasError) {
// Save settings
$settings->save();
$needsupdate = false;
require_once($settings->_ADOdbPath."adodb/adodb.inc.php");
$connTmp = ADONewConnection($settings->_dbDriver);
if ($connTmp) {
$connTmp->Connect($settings->_dbHostname, $settings->_dbUser, $settings->_dbPass, $settings->_dbDatabase);
if ($connTmp->IsConnected()) {
$res = $connTmp->Execute('select * from tblVersion');
if($rec = $res->FetchRow()) {
$updatedirs = array();
$d = dir(".");
while (false !== ($entry = $d->read())) {
if(preg_match('/update-([0-9.]*)/', $entry, $matches)) {
$updatedirs[] = $matches[1];
}
}
$d->close();
echo "Your current database schema has version ".$rec['major'].'.'.$rec['minor'].'.'.$rec['subminor']."<br /><br />";
if($updatedirs) {
foreach($updatedirs as $updatedir) {
if($updatedir >= $rec['major'].'.'.$rec['minor'].'.'.$rec['subminor']) {
$needsupdate = true;
print "<h3>Database update to version ".$updatedir." needed</h3>";
if(file_exists('update-'.$updatedir.'/update.txt')) {
print "<p>Please read the comments on updating this version. <a href=\"update-".$updatedir."/update.txt\">Read now</a></p>";
}
if(file_exists('update-'.$updatedir.'/update.php')) {
print "<p>Afterwards run the <a href=\"update.php?version=".$updatedir."\">update script</a>.</p>";
}
}
}
} else {
print "<p>Your current database is up to date.</p>";
}
}
}
}
// Show Web page
echo getMLText("settings_install_success");
echo "<br/><br/>";
echo getMLText("settings_delete_install_folder");
echo "<br/><br/>";
echo '<a href="install.php?disableinstall=1">' . getMLText("settings_disable_install") . '</a>';
echo "<br/><br/>";
echo '<a href="' . $httpRoot . '/out/out.Settings.php">' . getMLText("settings_more_settings") .'</a>';
if(!$needsupdate) {
echo getMLText("settings_install_success");
echo "<br/><br/>";
echo getMLText("settings_delete_install_folder");
echo "<br/><br/>";
echo '<a href="install.php?disableinstall=1">' . getMLText("settings_disable_install") . '</a>';
echo "<br/><br/>";
echo '<a href="' . $httpRoot . '/out/out.Settings.php">' . getMLText("settings_more_settings") .'</a>';
}
}
}
// Save settings
$settings->save();
// Back link
echo '<br/>';

View File

@ -18,19 +18,8 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
include("../inc/inc.Version.php");
include("../inc/inc.Settings.php");
include("../inc/inc.DBInit.php");
include("../inc/inc.Language.php");
include("../inc/inc.ClassUI.php");
include("../inc/inc.Authentication.php");
if (!$user->isAdmin()) {
print "<b>ERROR: You must be administrator to execute the update</b>";
die;
}
function check($doupdate=0) {
function check($doupdate=0) { /* {{{ */
global $db, $settings;
$arr = array();
@ -90,12 +79,7 @@ function check($doupdate=0) {
echo "<b>Summary of all updates</b><br />\n";
echo "<pre>".implode("<br />", $allupdates)."</pre>";
return true;
}
UI::htmlStartPage('Database update');
UI::globalNavigation();
UI::pageNavigation('Database update');
UI::contentContainerStart();
} /* }}} */
if(isset($_GET['doupdate']) && $_GET['doupdate'] == 1)
$doupdate = 1;
@ -103,14 +87,11 @@ else
$doupdate = 0;
if (!check($doupdate)) {
die;
print "<p>Update failed</p>";
}
if(!$doupdate) {
print "<p>If the above update statements look ok, either execute them in your prefered mysql client or click on the link below.</p>";
print "<a href=\"?doupdate=1\">Execute update</a><br />\n";
}
UI::contentContainerEnd();
UI::htmlEndPage();
?>

View File

@ -9,7 +9,7 @@ Folder search
-------------
The new folder search has introduced a new database field which has to
be initially filled. Without that field searching for subfolders in a
folder will not work.
folder will not work. See below.
Data conversion
---------------
@ -48,4 +48,8 @@ document directories into it. If you have already a document with id 1, you
must choose a different name for your new sub directory and rename to 1 after
all document directories have been moved.
After finishing update
----------------------
Once you are done with the update, log in as administrator and make an
object check in the admin tools. This will fill the new database field
needed for the folder search.

81
install/update.php Normal file
View File

@ -0,0 +1,81 @@
<?php
// MyDMS. Document Management System
// Copyright (C) 2002-2005 Markus Westphal
// Copyright (C) 2006-2008 Malcolm Cowe
// Copyright (C) 2010 Matteo Lucarelli
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
require_once("../inc/inc.Utils.php");
require_once('../inc/inc.ClassSettings.php');
$configDir = Settings::getConfigDir();
$settings = new Settings();
$settings->load($configDir."/settings.xml");
/**
* Check if ENABLE_INSTALL_TOOL exists in config dir
*/
if (!file_exists($configDir."/ENABLE_INSTALL_TOOL")) {
echo "For installation of LetoDMS, you must create the file conf/ENABLE_INSTALL_TOOL";
exit;
}
require_once("../inc/inc.Language.php");
require_once("../inc/inc.ClassUI.php");
UI::htmlStartPage('Database update');
UI::contentHeading("letoDMS Installation for version ".$_GET['version']);
UI::contentContainerStart();
require_once($settings->_ADOdbPath."adodb/adodb.inc.php");
$db = ADONewConnection($settings->_dbDriver);
if ($db) {
$db->Connect($settings->_dbHostname, $settings->_dbUser, $settings->_dbPass, $settings->_dbDatabase);
if (!$db->IsConnected()) {
die;
}
}
$queries = file_get_contents('update-'.$_GET['version'].'/update.sql');
$queries = explode(";", $queries);
// execute queries
$errorMsg = '';
if($queries) {
echo "<h3>Running sql statements</h3>";
foreach($queries as $query) {
$query = trim($query);
if (!empty($query)) {
echo $query."<br />";
$db->Execute($query);
if ($db->ErrorNo()<>0) {
$errorMsg .= $db->ErrorMsg() . "<br/>";
}
}
}
}
if(!$errorMsg) {
echo "<h3>Running update script</h3>";
include('update-'.$_GET['version'].'/update.php');
} else {
echo $errorMsg;
}
UI::contentContainerEnd();
UI::htmlEndPage();
?>