2002-03-03 22:47:30 +01:00
|
|
|
<?php
|
|
|
|
/**************************************************************************\
|
2004-05-05 14:06:13 +02:00
|
|
|
* eGroupWare - Setup *
|
|
|
|
* http://www.egroupware.org *
|
2002-03-03 22:47:30 +01:00
|
|
|
* -------------------------------------------- *
|
|
|
|
* This file written by Dan Kuykendall<seek3r@phpgroupware.org> *
|
2004-01-07 10:22:07 +01:00
|
|
|
* and Miles Lott<milos@groupwhere.org> *
|
2002-03-03 22:47:30 +01:00
|
|
|
* -------------------------------------------- *
|
|
|
|
* 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. *
|
|
|
|
\**************************************************************************/
|
|
|
|
|
|
|
|
/* $Id$ */
|
|
|
|
|
2004-01-07 10:22:07 +01:00
|
|
|
class setup_detection
|
2002-03-03 22:47:30 +01:00
|
|
|
{
|
|
|
|
function get_versions()
|
|
|
|
{
|
2005-03-04 13:40:28 +01:00
|
|
|
$d = dir(EGW_SERVER_ROOT);
|
2002-03-03 22:47:30 +01:00
|
|
|
while($entry=$d->read())
|
|
|
|
{
|
2005-03-04 13:40:28 +01:00
|
|
|
if($entry != ".." && !ereg('setup',$entry) && is_dir(EGW_SERVER_ROOT . '/' . $entry))
|
2002-03-03 22:47:30 +01:00
|
|
|
{
|
2005-03-04 13:40:28 +01:00
|
|
|
$f = EGW_SERVER_ROOT . '/' . $entry . '/setup/setup.inc.php';
|
2002-03-03 22:47:30 +01:00
|
|
|
if (@file_exists ($f))
|
|
|
|
{
|
|
|
|
include($f);
|
|
|
|
$setup_info[$entry]['filename'] = $f;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$d->close();
|
|
|
|
|
|
|
|
// _debug_array($setup_info);
|
|
|
|
@ksort($setup_info);
|
|
|
|
return $setup_info;
|
|
|
|
}
|
|
|
|
|
|
|
|
function get_db_versions($setup_info='')
|
|
|
|
{
|
2002-04-10 01:48:36 +02:00
|
|
|
$tname = Array();
|
2005-03-04 15:43:14 +01:00
|
|
|
$GLOBALS['egw_setup']->db->Halt_On_Error = 'no';
|
2005-11-02 12:45:52 +01:00
|
|
|
|
|
|
|
$GLOBALS['egw_setup']->set_table_names();
|
2002-03-03 22:47:30 +01:00
|
|
|
|
2005-11-02 12:45:52 +01:00
|
|
|
if($GLOBALS['egw_setup']->applications_table)
|
2002-03-03 22:47:30 +01:00
|
|
|
{
|
|
|
|
/* one of these tables exists. checking for post/pre beta version */
|
2005-11-02 12:45:52 +01:00
|
|
|
if($GLOBALS['egw_setup']->applications_table != 'applications')
|
2002-03-03 22:47:30 +01:00
|
|
|
{
|
2005-11-02 12:45:52 +01:00
|
|
|
$GLOBALS['egw_setup']->db->select($GLOBALS['egw_setup']->applications_table,'*',false,__LINE__,__FILE__);
|
2005-03-04 15:43:14 +01:00
|
|
|
while(@$GLOBALS['egw_setup']->db->next_record())
|
2002-03-03 22:47:30 +01:00
|
|
|
{
|
2005-03-04 15:43:14 +01:00
|
|
|
$setup_info[$GLOBALS['egw_setup']->db->f('app_name')]['currentver'] = $GLOBALS['egw_setup']->db->f('app_version');
|
|
|
|
$setup_info[$GLOBALS['egw_setup']->db->f('app_name')]['enabled'] = $GLOBALS['egw_setup']->db->f('app_enabled');
|
2002-03-03 22:47:30 +01:00
|
|
|
}
|
|
|
|
/* This is to catch old setup installs that did not have phpgwapi listed as an app */
|
2002-04-30 05:35:52 +02:00
|
|
|
$tmp = @$setup_info['phpgwapi']['version']; /* save the file version */
|
2002-03-03 22:47:30 +01:00
|
|
|
if(!@$setup_info['phpgwapi']['currentver'])
|
|
|
|
{
|
|
|
|
$setup_info['phpgwapi']['currentver'] = $setup_info['admin']['currentver'];
|
|
|
|
$setup_info['phpgwapi']['version'] = $setup_info['admin']['currentver'];
|
|
|
|
$setup_info['phpgwapi']['enabled'] = $setup_info['admin']['enabled'];
|
|
|
|
// _debug_array($setup_info['phpgwapi']);exit;
|
2003-08-28 16:31:11 +02:00
|
|
|
// There seems to be a problem here. If ['phpgwapi']['currentver'] is set,
|
|
|
|
// The GLOBALS never gets set.
|
2002-03-03 22:47:30 +01:00
|
|
|
$GLOBALS['setup_info'] = $setup_info;
|
2005-03-04 15:43:14 +01:00
|
|
|
$GLOBALS['egw_setup']->register_app('phpgwapi');
|
2002-03-03 22:47:30 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$GLOBALS['setup_info'] = $setup_info;
|
|
|
|
}
|
|
|
|
$setup_info['phpgwapi']['version'] = $tmp; /* restore the file version */
|
|
|
|
}
|
2005-11-02 12:45:52 +01:00
|
|
|
else
|
2002-03-03 22:47:30 +01:00
|
|
|
{
|
2005-03-04 15:43:14 +01:00
|
|
|
$GLOBALS['egw_setup']->db->query('select * from applications');
|
|
|
|
while(@$GLOBALS['egw_setup']->db->next_record())
|
2002-03-03 22:47:30 +01:00
|
|
|
{
|
2005-03-04 15:43:14 +01:00
|
|
|
if($GLOBALS['egw_setup']->db->f('app_name') == 'admin')
|
2002-03-03 22:47:30 +01:00
|
|
|
{
|
2005-03-04 15:43:14 +01:00
|
|
|
$setup_info['phpgwapi']['currentver'] = $GLOBALS['egw_setup']->db->f('app_version');
|
2002-03-03 22:47:30 +01:00
|
|
|
}
|
2005-03-04 15:43:14 +01:00
|
|
|
$setup_info[$GLOBALS['egw_setup']->db->f('app_name')]['currentver'] = $GLOBALS['egw_setup']->db->f('app_version');
|
2002-03-03 22:47:30 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// _debug_array($setup_info);
|
|
|
|
return $setup_info;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* app status values:
|
|
|
|
U Upgrade required/available
|
|
|
|
R upgrade in pRogress
|
|
|
|
C upgrade Completed successfully
|
|
|
|
D Dependency failure
|
|
|
|
P Post-install dependency failure
|
|
|
|
F upgrade Failed
|
|
|
|
V Version mismatch at end of upgrade (Not used, proposed only)
|
|
|
|
M Missing files at start of upgrade (Not used, proposed only)
|
|
|
|
*/
|
|
|
|
function compare_versions($setup_info)
|
|
|
|
{
|
2003-08-28 16:31:11 +02:00
|
|
|
foreach($setup_info as $key => $value)
|
2002-03-03 22:47:30 +01:00
|
|
|
{
|
2003-08-28 16:31:11 +02:00
|
|
|
//echo '<br>'.$value['name'].'STATUS: '.$value['status'];
|
2002-03-03 22:47:30 +01:00
|
|
|
/* Only set this if it has not already failed to upgrade - Milosch */
|
2003-08-28 16:31:11 +02:00
|
|
|
if(!( (@$value['status'] == 'F') || (@$value['status'] == 'C') ))
|
2002-03-03 22:47:30 +01:00
|
|
|
{
|
|
|
|
//if ($setup_info[$key]['currentver'] > $setup_info[$key]['version'])
|
2005-03-04 15:43:14 +01:00
|
|
|
if($GLOBALS['egw_setup']->amorethanb($value['currentver'],@$value['version']))
|
2002-03-03 22:47:30 +01:00
|
|
|
{
|
|
|
|
$setup_info[$key]['status'] = 'V';
|
|
|
|
}
|
2003-08-28 16:31:11 +02:00
|
|
|
elseif(@$value['currentver'] == @$value['version'])
|
2002-03-03 22:47:30 +01:00
|
|
|
{
|
|
|
|
$setup_info[$key]['status'] = 'C';
|
|
|
|
}
|
2005-03-04 15:43:14 +01:00
|
|
|
elseif($GLOBALS['egw_setup']->alessthanb(@$value['currentver'],@$value['version']))
|
2002-03-03 22:47:30 +01:00
|
|
|
{
|
|
|
|
$setup_info[$key]['status'] = 'U';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$setup_info[$key]['status'] = 'U';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// _debug_array($setup_info);
|
|
|
|
return $setup_info;
|
|
|
|
}
|
|
|
|
|
|
|
|
function check_depends($setup_info)
|
|
|
|
{
|
|
|
|
/* Run the list of apps */
|
2003-08-28 16:31:11 +02:00
|
|
|
foreach($setup_info as $key => $value)
|
2002-03-03 22:47:30 +01:00
|
|
|
{
|
|
|
|
/* Does this app have any depends */
|
|
|
|
if(isset($value['depends']))
|
|
|
|
{
|
2004-01-07 10:22:07 +01:00
|
|
|
/* If so find out which apps it depends on */
|
2003-08-28 16:31:11 +02:00
|
|
|
foreach($value['depends'] as $depkey => $depvalue)
|
2002-03-03 22:47:30 +01:00
|
|
|
{
|
|
|
|
/* I set this to False until we find a compatible version of this app */
|
|
|
|
$setup_info['depends'][$depkey]['status'] = False;
|
|
|
|
/* Now we loop thru the versions looking for a compatible version */
|
2004-01-07 10:22:07 +01:00
|
|
|
|
2003-08-28 16:31:11 +02:00
|
|
|
foreach($depvalue['versions'] as $depskey => $depsvalue)
|
2002-03-03 22:47:30 +01:00
|
|
|
{
|
2003-09-13 20:19:03 +02:00
|
|
|
$currentver = $setup_info[$depvalue['appname']]['currentver'];
|
|
|
|
if ($depvalue['appname'] == 'phpgwapi' && substr($currentver,0,6) == '0.9.99')
|
|
|
|
{
|
|
|
|
$currentver = '0.9.14.508';
|
|
|
|
}
|
2005-03-04 15:43:14 +01:00
|
|
|
$major = $GLOBALS['egw_setup']->get_major($currentver);
|
2002-03-03 22:47:30 +01:00
|
|
|
if ($major == $depsvalue)
|
|
|
|
{
|
|
|
|
$setup_info['depends'][$depkey]['status'] = True;
|
|
|
|
}
|
2003-04-02 19:46:37 +02:00
|
|
|
else // check if majors are equal and minors greater or equal
|
2002-03-03 22:47:30 +01:00
|
|
|
{
|
2005-03-04 15:43:14 +01:00
|
|
|
$major_depsvalue = $GLOBALS['egw_setup']->get_major($depsvalue);
|
2003-04-02 19:46:37 +02:00
|
|
|
list(,,,$minor_depsvalue) = explode('.',$depsvalue);
|
2003-09-13 20:19:03 +02:00
|
|
|
list(,,,$minor) = explode('.',$currentver);
|
2003-04-02 19:46:37 +02:00
|
|
|
if ($major == $major_depsvalue && $minor <= $minor_depsvalue)
|
|
|
|
{
|
|
|
|
$setup_info['depends'][$depkey]['status'] = True;
|
|
|
|
}
|
2002-03-03 22:47:30 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
Finally, we loop through the dependencies again to look for apps that still have a failure status
|
|
|
|
If we find one, we set the apps overall status as a dependency failure.
|
|
|
|
*/
|
2003-08-28 16:31:11 +02:00
|
|
|
foreach($value['depends'] as $depkey => $depvalue)
|
2002-03-03 22:47:30 +01:00
|
|
|
{
|
|
|
|
if ($setup_info['depends'][$depkey]['status'] == False)
|
|
|
|
{
|
|
|
|
/* Only set this if it has not already failed to upgrade - Milosch */
|
|
|
|
if($setup_info[$key]['status'] != 'F')//&& $setup_info[$key]['status'] != 'C')
|
|
|
|
{
|
2005-10-08 16:54:01 +02:00
|
|
|
/* Added check for status U - uninstalled apps carry this flag (upgrade from nothing == install).
|
|
|
|
* This should fix apps showing post-install dep failure when they are not yet installed.
|
|
|
|
*/
|
|
|
|
if($setup_info[$key]['status'] == 'C' || $setup_info[$key]['status'] == 'U')
|
2002-03-03 22:47:30 +01:00
|
|
|
{
|
|
|
|
$setup_info[$key]['status'] = 'D';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$setup_info[$key]['status'] = 'P';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $setup_info;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Called during the mass upgrade routine (Stage 1) to check for apps
|
|
|
|
that wish to be excluded from this process.
|
|
|
|
*/
|
|
|
|
function upgrade_exclude($setup_info)
|
|
|
|
{
|
2003-08-28 16:31:11 +02:00
|
|
|
foreach($setup_info as $key => $value)
|
2002-03-03 22:47:30 +01:00
|
|
|
{
|
|
|
|
if(isset($value['no_mass_update']))
|
|
|
|
{
|
|
|
|
unset($setup_info[$key]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $setup_info;
|
|
|
|
}
|
|
|
|
|
|
|
|
function check_header()
|
|
|
|
{
|
|
|
|
if(!file_exists('../header.inc.php'))
|
|
|
|
{
|
2005-03-04 13:40:28 +01:00
|
|
|
$GLOBALS['egw_info']['setup']['header_msg'] = 'Stage One';
|
2002-03-03 22:47:30 +01:00
|
|
|
return '1';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-03-04 13:40:28 +01:00
|
|
|
if(!@isset($GLOBALS['egw_info']['server']['header_admin_password']))
|
2002-03-03 22:47:30 +01:00
|
|
|
{
|
2005-03-04 13:40:28 +01:00
|
|
|
$GLOBALS['egw_info']['setup']['header_msg'] = 'Stage One (No header admin password set)';
|
2002-03-03 22:47:30 +01:00
|
|
|
return '2';
|
|
|
|
}
|
2005-03-04 13:40:28 +01:00
|
|
|
elseif(!@isset($GLOBALS['egw_domain']))
|
2002-03-03 22:47:30 +01:00
|
|
|
{
|
2005-03-04 13:40:28 +01:00
|
|
|
$GLOBALS['egw_info']['setup']['header_msg'] = 'Stage One (Add domains to your header.inc.php)';
|
2002-03-03 22:47:30 +01:00
|
|
|
return '3';
|
|
|
|
}
|
2005-03-04 13:40:28 +01:00
|
|
|
elseif(@$GLOBALS['egw_info']['server']['versions']['header'] != @$GLOBALS['egw_info']['server']['versions']['current_header'])
|
2002-03-03 22:47:30 +01:00
|
|
|
{
|
2005-03-04 13:40:28 +01:00
|
|
|
$GLOBALS['egw_info']['setup']['header_msg'] = 'Stage One (Upgrade your header.inc.php)';
|
2003-10-22 13:28:17 +02:00
|
|
|
return '4';
|
2002-03-03 22:47:30 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
/* header.inc.php part settled. Moving to authentication */
|
2005-03-04 13:40:28 +01:00
|
|
|
$GLOBALS['egw_info']['setup']['header_msg'] = 'Stage One (Completed)';
|
2002-03-03 22:47:30 +01:00
|
|
|
return '10';
|
|
|
|
}
|
|
|
|
|
2004-01-07 10:19:38 +01:00
|
|
|
function check_db($setup_info='')
|
2002-03-03 22:47:30 +01:00
|
|
|
{
|
2004-01-07 10:19:38 +01:00
|
|
|
$setup_info = $setup_info ? $setup_info : $GLOBALS['setup_info'];
|
2002-03-03 22:47:30 +01:00
|
|
|
|
2005-03-04 15:43:14 +01:00
|
|
|
$GLOBALS['egw_setup']->db->Halt_On_Error = 'no';
|
2002-03-03 22:47:30 +01:00
|
|
|
// _debug_array($setup_info);
|
|
|
|
|
2005-03-04 15:43:14 +01:00
|
|
|
if (!$GLOBALS['egw_setup']->db->Link_ID)
|
2003-08-28 20:14:45 +02:00
|
|
|
{
|
2003-10-14 12:06:07 +02:00
|
|
|
$old = error_reporting();
|
|
|
|
error_reporting($old & ~E_WARNING); // no warnings
|
2005-03-04 15:43:14 +01:00
|
|
|
$GLOBALS['egw_setup']->db->connect();
|
2003-10-14 12:06:07 +02:00
|
|
|
error_reporting($old);
|
2003-08-28 20:14:45 +02:00
|
|
|
}
|
2005-11-02 12:45:52 +01:00
|
|
|
$GLOBALS['egw_setup']->set_table_names();
|
|
|
|
|
2005-03-04 15:43:14 +01:00
|
|
|
if (!$GLOBALS['egw_setup']->db->Link_ID)
|
2003-08-28 20:14:45 +02:00
|
|
|
{
|
2005-03-04 13:40:28 +01:00
|
|
|
$GLOBALS['egw_info']['setup']['header_msg'] = 'Stage 1 (Create Database)';
|
2003-08-28 20:14:45 +02:00
|
|
|
return 1;
|
|
|
|
}
|
2002-03-03 22:47:30 +01:00
|
|
|
if(!isset($setup_info['phpgwapi']['currentver']))
|
|
|
|
{
|
|
|
|
$setup_info = $this->get_db_versions($setup_info);
|
|
|
|
}
|
2005-11-02 12:45:52 +01:00
|
|
|
//_debug_array($setup_info);
|
2002-03-03 22:47:30 +01:00
|
|
|
if (isset($setup_info['phpgwapi']['currentver']))
|
|
|
|
{
|
2003-08-28 16:31:11 +02:00
|
|
|
if(@$setup_info['phpgwapi']['currentver'] == @$setup_info['phpgwapi']['version'])
|
2002-03-03 22:47:30 +01:00
|
|
|
{
|
2005-03-04 13:40:28 +01:00
|
|
|
$GLOBALS['egw_info']['setup']['header_msg'] = 'Stage 1 (Tables Complete)';
|
2002-03-03 22:47:30 +01:00
|
|
|
return 10;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-03-04 13:40:28 +01:00
|
|
|
$GLOBALS['egw_info']['setup']['header_msg'] = 'Stage 1 (Tables need upgrading)';
|
2002-03-03 22:47:30 +01:00
|
|
|
return 4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* no tables, so checking if we can create them */
|
2005-11-02 12:45:52 +01:00
|
|
|
$GLOBALS['egw_setup']->db->query('CREATE TABLE egw_testrights ( testfield varchar(5) NOT NULL )');
|
2005-03-04 15:43:14 +01:00
|
|
|
if(!$GLOBALS['egw_setup']->db->Errno)
|
2002-03-03 22:47:30 +01:00
|
|
|
{
|
2005-11-02 12:45:52 +01:00
|
|
|
$GLOBALS['egw_setup']->db->query('DROP TABLE egw_testrights');
|
2005-03-04 13:40:28 +01:00
|
|
|
$GLOBALS['egw_info']['setup']['header_msg'] = 'Stage 3 (Install Applications)';
|
2002-03-03 22:47:30 +01:00
|
|
|
return 3;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-03-04 13:40:28 +01:00
|
|
|
$GLOBALS['egw_info']['setup']['header_msg'] = 'Stage 1 (Create Database)';
|
2002-03-03 22:47:30 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function check_config()
|
|
|
|
{
|
2005-03-04 15:43:14 +01:00
|
|
|
$GLOBALS['egw_setup']->db->Halt_On_Error = 'no';
|
2005-03-04 13:40:28 +01:00
|
|
|
if(@$GLOBALS['egw_info']['setup']['stage']['db'] != 10)
|
2002-03-03 22:47:30 +01:00
|
|
|
{
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
|
2005-11-02 12:45:52 +01:00
|
|
|
$GLOBALS['egw_setup']->db->select($GLOBALS['egw_setup']->config_table,'config_value',array('config_name'=>'freshinstall'),__LINE__,__FILE__);
|
2005-03-04 15:43:14 +01:00
|
|
|
$configured = $GLOBALS['egw_setup']->db->next_record() ? $GLOBALS['egw_setup']->db->f('config_value') : False;
|
2002-03-03 22:47:30 +01:00
|
|
|
if($configed)
|
|
|
|
{
|
2005-03-04 13:40:28 +01:00
|
|
|
$GLOBALS['egw_info']['setup']['header_msg'] = 'Stage 2 (Needs Configuration)';
|
2002-03-03 22:47:30 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-03-04 13:40:28 +01:00
|
|
|
$GLOBALS['egw_info']['setup']['header_msg'] = 'Stage 2 (Configuration OK)';
|
2002-03-03 22:47:30 +01:00
|
|
|
return 10;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-03-22 02:32:43 +01:00
|
|
|
function check_lang($check = True)
|
2002-03-03 22:47:30 +01:00
|
|
|
{
|
2005-03-04 15:43:14 +01:00
|
|
|
$GLOBALS['egw_setup']->db->Halt_On_Error = 'no';
|
2005-03-04 13:40:28 +01:00
|
|
|
if($check && $GLOBALS['egw_info']['setup']['stage']['db'] != 10)
|
2002-03-03 22:47:30 +01:00
|
|
|
{
|
|
|
|
return '';
|
|
|
|
}
|
2003-03-22 02:32:43 +01:00
|
|
|
if (!$check)
|
|
|
|
{
|
2005-03-04 15:43:14 +01:00
|
|
|
$GLOBALS['setup_info'] = $GLOBALS['egw_setup']->detection->get_db_versions($GLOBALS['setup_info']);
|
2003-03-22 02:32:43 +01:00
|
|
|
}
|
2005-11-02 12:45:52 +01:00
|
|
|
$GLOBALS['egw_setup']->db->query($q = "SELECT DISTINCT lang FROM {$GLOBALS['egw_setup']->lang_table}",__LINE__,__FILE__);
|
2005-03-04 15:43:14 +01:00
|
|
|
if($GLOBALS['egw_setup']->db->num_rows() == 0)
|
2002-03-03 22:47:30 +01:00
|
|
|
{
|
2005-03-04 13:40:28 +01:00
|
|
|
$GLOBALS['egw_info']['setup']['header_msg'] = 'Stage 3 (No languages installed)';
|
2002-03-03 22:47:30 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-03-04 15:43:14 +01:00
|
|
|
while(@$GLOBALS['egw_setup']->db->next_record())
|
2002-03-03 22:47:30 +01:00
|
|
|
{
|
2005-03-04 15:43:14 +01:00
|
|
|
$GLOBALS['egw_info']['setup']['installed_langs'][$GLOBALS['egw_setup']->db->f('lang')] = $GLOBALS['egw_setup']->db->f('lang');
|
2002-03-03 22:47:30 +01:00
|
|
|
}
|
2005-03-04 13:40:28 +01:00
|
|
|
foreach($GLOBALS['egw_info']['setup']['installed_langs'] as $key => $value)
|
2002-03-03 22:47:30 +01:00
|
|
|
{
|
2005-11-02 12:45:52 +01:00
|
|
|
$sql = "SELECT lang_name FROM {$GLOBALS['egw_setup']->languages_table} WHERE lang_id = '".$value."'";
|
2005-03-04 15:43:14 +01:00
|
|
|
$GLOBALS['egw_setup']->db->query($sql);
|
|
|
|
if ($GLOBALS['egw_setup']->db->next_record())
|
2004-07-10 12:59:37 +02:00
|
|
|
{
|
2005-03-04 15:43:14 +01:00
|
|
|
$GLOBALS['egw_info']['setup']['installed_langs'][$value] = $GLOBALS['egw_setup']->db->f('lang_name');
|
2004-07-10 12:59:37 +02:00
|
|
|
}
|
2002-03-03 22:47:30 +01:00
|
|
|
}
|
2005-03-04 13:40:28 +01:00
|
|
|
$GLOBALS['egw_info']['setup']['header_msg'] = 'Stage 3 (Completed)';
|
2002-03-03 22:47:30 +01:00
|
|
|
return 10;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
@function check_app_tables
|
|
|
|
@abstract Verify that all of an app's tables exist in the db
|
|
|
|
@param $appname
|
|
|
|
@param $any optional, set to True to see if any of the apps tables are installed
|
|
|
|
*/
|
|
|
|
function check_app_tables($appname,$any=False)
|
|
|
|
{
|
|
|
|
$none = 0;
|
|
|
|
$setup_info = $GLOBALS['setup_info'];
|
|
|
|
|
|
|
|
if(@$setup_info[$appname]['tables'])
|
|
|
|
{
|
|
|
|
/* Make a copy, else we send some callers into an infinite loop */
|
|
|
|
$copy = $setup_info;
|
2005-03-04 15:43:14 +01:00
|
|
|
$GLOBALS['egw_setup']->db->Halt_On_Error = 'no';
|
|
|
|
$table_names = $GLOBALS['egw_setup']->db->table_names();
|
2002-12-23 02:29:19 +01:00
|
|
|
$tables = Array();
|
2003-08-28 16:31:11 +02:00
|
|
|
foreach($table_names as $key => $val)
|
2002-03-03 22:47:30 +01:00
|
|
|
{
|
|
|
|
$tables[] = $val['table_name'];
|
|
|
|
}
|
2003-08-28 16:31:11 +02:00
|
|
|
foreach($copy[$appname]['tables'] as $key => $val)
|
2002-03-03 22:47:30 +01:00
|
|
|
{
|
|
|
|
if($GLOBALS['DEBUG'])
|
|
|
|
{
|
|
|
|
echo '<br>check_app_tables(): Checking: ' . $appname . ',table: ' . $val;
|
|
|
|
}
|
|
|
|
if(!in_array($val,$tables))
|
|
|
|
{
|
|
|
|
if($GLOBALS['DEBUG'])
|
|
|
|
{
|
|
|
|
echo '<br>check_app_tables(): ' . $val . ' missing!';
|
|
|
|
}
|
|
|
|
if(!$any)
|
|
|
|
{
|
|
|
|
return False;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$none++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if($any)
|
|
|
|
{
|
|
|
|
if($GLOBALS['DEBUG'])
|
|
|
|
{
|
|
|
|
echo '<br>check_app_tables(): Some tables installed';
|
|
|
|
}
|
|
|
|
return True;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if($none && $any)
|
|
|
|
{
|
|
|
|
if($GLOBALS['DEBUG'])
|
|
|
|
{
|
|
|
|
echo '<br>check_app_tables(): No tables installed';
|
|
|
|
}
|
|
|
|
return False;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if($GLOBALS['DEBUG'])
|
|
|
|
{
|
|
|
|
echo '<br>check_app_tables(): All tables installed';
|
|
|
|
}
|
|
|
|
return True;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|