You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

108 lines
3.0 KiB

<?php
/*
Copyright Intermesh 2003
Author: Merijn Schering <mschering@intermesh.nl>
Version: 1.0 Release date: 28 Februari 2005
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.
*/
require_once('../Group-Office.php');
$CONFIG_FILE = $GO_CONFIG->get_config_file();
require_once('install.inc');
if(!isset($_REQUEST['config_created']))
{
save_config($GO_CONFIG);
header('Location: '.$_SERVER['PHP_SELF'].'?config_created=true');
exit();
}
$db = new db();
$db->Halt_On_Error = 'no';
$old_version = intval(str_replace('.', '', $GO_CONFIG->get_setting('version')));
$new_version = intval(str_replace('.', '', $GO_CONFIG->version));
require_once($GO_CONFIG->root_path.'lib/updates.inc');
if (!isset($updates[$old_version]))
{
//invalid version, abort upgrade
echo 'The version number '.$old_version.' is invalid<br />';
exit();
}else
{
for ($cur_ver=$old_version;$cur_ver<$new_version;$cur_ver++)
{
if (isset($updates[$cur_ver]))
{
while($query = array_shift($updates[$cur_ver]))
{
@$db->query($query);
}
}
if (file_exists($GO_CONFIG->root_path.'lib/scripts/'.$cur_ver.'.inc'))
{
echo 'Running update script for version '.$cur_ver.'...<br />';
require_once($GO_CONFIG->root_path.'lib/scripts/'.$cur_ver.'.inc');
}
}
$db_version = $GO_CONFIG->version;
$_SESSION['completed']['database_structure'] = true;
//store the version number for future upgrades
$GO_CONFIG->save_setting('version', $GO_CONFIG->version);
//Upgrade modules
$GO_MODULES->get_modules();
while($GO_MODULES->next_record())
{
$module_info = $GO_MODULES->get_module_info($GO_MODULES->f('id'));
if($module_info)
{
$installed_version = intval(str_replace('.', '', $GO_MODULES->f('version')));
$new_version = intval(str_replace('.', '',$module_info['version']));
if($installed_version < $new_version)
{
$update_file = $GO_CONFIG->root_path.'modules/'.$GO_MODULES->f('id').'/sql/'.$GO_MODULES->f('id').'.updates.inc';
if(file_exists($update_file))
{
require_once($update_file);
for ($cur_ver=$installed_version;$cur_ver<$new_version;$cur_ver++)
{
if (isset($updates[$cur_ver]))
{
while($query = array_shift($updates[$cur_ver]))
{
@$db->query($query);
}
}
}
}
for ($cur_ver=$installed_version;$cur_ver<$new_version;$cur_ver++)
{
if (file_exists($GO_CONFIG->root_path.'modules/'.$GO_MODULES->f('id').'/sql/'.$cur_ver.'.inc'))
{
echo 'Running update script for module \''.$GO_MODULES->f('id').'\' version '.$cur_ver.'...<br />';
require_once($GO_CONFIG->root_path.'modules/'.$GO_MODULES->f('id').'/sql/'.$cur_ver.'.inc');
}
}
}
$sql = "UPDATE modules SET version='".$module_info['version']."' WHERE id='".$GO_MODULES->f('id')."'";
$db->query($sql);
}
}
install_required_modules();
echo 'Database updated<br />';
}
?>