mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-07 08:34:42 +01:00
Moved setup and schema_proc classes to api; reorganize how the setup class
is created
This commit is contained in:
parent
88ca7694a6
commit
01faba0c4d
@ -31,7 +31,7 @@
|
||||
set_time_limit(0);
|
||||
|
||||
// Check header and authentication
|
||||
if (!$phpgw_setup->auth('Config'))
|
||||
if (!$GLOBALS['phpgw_setup']->auth('Config'))
|
||||
{
|
||||
Header('Location: index.php');
|
||||
exit;
|
||||
@ -40,7 +40,7 @@
|
||||
|
||||
$ConfigDomain = $HTTP_COOKIE_VARS['ConfigDomain'] ? $HTTP_COOKIE_VARS['ConfigDomain'] : $HTTP_POST_VARS['ConfigDomain'];
|
||||
|
||||
$tpl_root = $phpgw_setup->setup_tpl_dir('setup');
|
||||
$tpl_root = $GLOBALS['phpgw_setup']->html->setup_tpl_dir('setup');
|
||||
$setup_tpl = CreateObject('phpgwapi.Template',$tpl_root);
|
||||
$setup_tpl->set_file(array(
|
||||
'T_head' => 'head.tpl',
|
||||
@ -96,16 +96,16 @@
|
||||
}
|
||||
}
|
||||
|
||||
$phpgw_setup->loaddb();
|
||||
$GLOBALS['phpgw_info']['setup']['stage']['db'] = $phpgw_setup->check_db();
|
||||
$GLOBALS['phpgw_setup']->loaddb();
|
||||
$GLOBALS['phpgw_info']['setup']['stage']['db'] = $GLOBALS['phpgw_setup']->detection->check_db();
|
||||
|
||||
$setup_info = $phpgw_setup->get_versions();
|
||||
$setup_info = $GLOBALS['phpgw_setup']->detection->get_versions();
|
||||
//var_dump($setup_info);exit;
|
||||
$setup_info = $phpgw_setup->get_db_versions($setup_info);
|
||||
$setup_info = $GLOBALS['phpgw_setup']->detection->get_db_versions($setup_info);
|
||||
//var_dump($setup_info);exit;
|
||||
$setup_info = $phpgw_setup->compare_versions($setup_info);
|
||||
$setup_info = $GLOBALS['phpgw_setup']->detection->compare_versions($setup_info);
|
||||
//var_dump($setup_info);exit;
|
||||
$setup_info = $phpgw_setup->check_depends($setup_info);
|
||||
$setup_info = $GLOBALS['phpgw_setup']->detection->check_depends($setup_info);
|
||||
//var_dump($setup_info);exit;
|
||||
@ksort($setup_info);
|
||||
|
||||
@ -117,7 +117,7 @@
|
||||
|
||||
if(@$HTTP_POST_VARS['submit'])
|
||||
{
|
||||
$phpgw_setup->show_header(lang('Application Management'),False,'config',$ConfigDomain . '(' . $phpgw_domain[$ConfigDomain]['db_type'] . ')');
|
||||
$GLOBALS['phpgw_setup']->html->show_header(lang('Application Management'),False,'config',$ConfigDomain . '(' . $phpgw_domain[$ConfigDomain]['db_type'] . ')');
|
||||
$setup_tpl->set_var('description',lang('App install/remove/upgrade') . ':');
|
||||
$setup_tpl->pparse('out','header');
|
||||
|
||||
@ -133,20 +133,20 @@
|
||||
|
||||
if ($setup_info[$appname]['tables'])
|
||||
{
|
||||
$phpgw_setup->process_droptables($terror,$DEBUG);
|
||||
$GLOBALS['phpgw_setup']->process->droptables($terror,$DEBUG);
|
||||
echo '<br>' . $setup_info[$appname]['title'] . ' ' . lang('tables dropped') . '.';
|
||||
}
|
||||
|
||||
$phpgw_setup->deregister_app($setup_info[$appname]['name']);
|
||||
$GLOBALS['phpgw_setup']->deregister_app($setup_info[$appname]['name']);
|
||||
echo '<br>' . $setup_info[$appname]['title'] . ' ' . lang('deregistered') . '.';
|
||||
|
||||
if ($setup_info[$appname]['hooks'])
|
||||
{
|
||||
$phpgw_setup->deregister_hooks($setup_info[$appname]['name']);
|
||||
$GLOBALS['phpgw_setup']->deregister_hooks($setup_info[$appname]['name']);
|
||||
echo '<br>' . $setup_info[$appname]['title'] . ' ' . lang('hooks deregistered') . '.';
|
||||
}
|
||||
|
||||
$terror = $phpgw_setup->process_drop_langs($terror,$DEBUG);
|
||||
$terror = $GLOBALS['phpgw_setup']->process->drop_langs($terror,$DEBUG);
|
||||
echo '<br>' . $setup_info[$appname]['title'] . ' ' . lang('Translations removed') . '.';
|
||||
}
|
||||
|
||||
@ -157,26 +157,26 @@
|
||||
|
||||
if ($setup_info[$appname]['tables'])
|
||||
{
|
||||
$terror = $phpgw_setup->process_current($terror,$DEBUG);
|
||||
$terror = $phpgw_setup->process_default_records($terror,$DEBUG);
|
||||
$terror = $GLOBALS['phpgw_setup']->process->current($terror,$DEBUG);
|
||||
$terror = $GLOBALS['phpgw_setup']->process->default_records($terror,$DEBUG);
|
||||
echo '<br>' . $setup_info[$appname]['title'] . ' '
|
||||
. lang('tables installed, unless there are errors printed above') . '.';
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($phpgw_setup->app_registered($setup_info[$appname]['name']))
|
||||
if ($GLOBALS['phpgw_setup']->app_registered($setup_info[$appname]['name']))
|
||||
{
|
||||
$phpgw_setup->update_app($setup_info[$appname]['name']);
|
||||
$GLOBALS['phpgw_setup']->update_app($setup_info[$appname]['name']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$phpgw_setup->register_app($setup_info[$appname]['name']);
|
||||
$GLOBALS['phpgw_setup']->register_app($setup_info[$appname]['name']);
|
||||
}
|
||||
echo '<br>' . $setup_info[$appname]['title'] . ' ' . lang('registered') . '.';
|
||||
|
||||
if ($setup_info[$appname]['hooks'])
|
||||
{
|
||||
$phpgw_setup->register_hooks($setup_info[$appname]['name']);
|
||||
$GLOBALS['phpgw_setup']->register_hooks($setup_info[$appname]['name']);
|
||||
echo '<br>' . $setup_info[$appname]['title'] . ' ' . lang('hooks registered') . '.';
|
||||
}
|
||||
}
|
||||
@ -185,7 +185,7 @@
|
||||
{
|
||||
$force_en = True;
|
||||
}
|
||||
$terror = $phpgw_setup->process_add_langs($terror,$DEBUG,$force_en);
|
||||
$terror = $GLOBALS['phpgw_setup']->process->add_langs($terror,$DEBUG,$force_en);
|
||||
echo '<br>' . $setup_info[$appname]['title'] . ' ' . lang('Translations added') . '.';
|
||||
}
|
||||
|
||||
@ -194,7 +194,7 @@
|
||||
$terror = array();
|
||||
$terror[] = $setup_info[$appname];
|
||||
|
||||
$phpgw_setup->process_upgrade($terror,$DEBUG);
|
||||
$GLOBALS['phpgw_setup']->process->upgrade($terror,$DEBUG);
|
||||
if ($setup_info[$appname]['tables'])
|
||||
{
|
||||
echo '<br>' . $setup_info[$appname]['title'] . ' ' . lang('tables upgraded') . '.';
|
||||
@ -205,7 +205,7 @@
|
||||
echo '<br>' . $setup_info[$appname]['title'] . ' ' . lang('upgraded') . '.';
|
||||
}
|
||||
|
||||
$terror = $phpgw_setup->process_upgrade_langs($terror,$DEBUG);
|
||||
$terror = $GLOBALS['phpgw_setup']->process->upgrade_langs($terror,$DEBUG);
|
||||
echo '<br>' . $setup_info[$appname]['title'] . ' ' . lang('Translations upgraded') . '.';
|
||||
}
|
||||
|
||||
@ -217,7 +217,7 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
$phpgw_setup->show_header(lang('Application Management'),False,'config',$ConfigDomain . '(' . $phpgw_domain[$ConfigDomain]['db_type'] . ')');
|
||||
$GLOBALS['phpgw_setup']->html->show_header(lang('Application Management'),False,'config',$ConfigDomain . '(' . $phpgw_domain[$ConfigDomain]['db_type'] . ')');
|
||||
}
|
||||
|
||||
if(@$HTTP_GET_VARS['detail'])
|
||||
@ -389,7 +389,7 @@
|
||||
case 'C':
|
||||
$setup_tpl->set_var('remove','<input type="checkbox" name="remove[' . $value['name'] . ']">');
|
||||
$setup_tpl->set_var('upgrade',' ');
|
||||
if (!$phpgw_setup->check_app_tables($value['name']))
|
||||
if (!$GLOBALS['phpgw_setup']->detection->check_app_tables($value['name']))
|
||||
{
|
||||
// App installed and enabled, but some tables are missing
|
||||
$setup_tpl->set_var('instimg','table.gif');
|
||||
@ -427,7 +427,7 @@
|
||||
$setup_tpl->set_var('instalt',lang('Not Completed'));
|
||||
if (!@$value['currentver'])
|
||||
{
|
||||
if ($value['tables'] && $phpgw_setup->check_app_tables($value['name'],True))
|
||||
if ($value['tables'] && $GLOBALS['phpgw_setup']->detection->check_app_tables($value['name'],True))
|
||||
{
|
||||
// Some tables missing
|
||||
$setup_tpl->set_var('remove','<input type="checkbox" name="remove[' . $value['name'] . ']">');
|
||||
@ -516,6 +516,6 @@
|
||||
$setup_tpl->set_var('cancel',lang('Cancel'));
|
||||
$setup_tpl->pparse('out','app_footer');
|
||||
$setup_tpl->pparse('out','footer');
|
||||
$phpgw_setup->show_footer();
|
||||
$GLOBALS['phpgw_setup']->html->show_footer();
|
||||
}
|
||||
?>
|
||||
|
@ -19,17 +19,17 @@
|
||||
'noapi' => True
|
||||
);
|
||||
include('./inc/functions.inc.php');
|
||||
include('./inc/xml_functions.inc.php');
|
||||
include(PHPGW_SERVER_ROOT . 'phpgwapi/inc/xml_functions.inc.php');
|
||||
|
||||
/* Check header and authentication */
|
||||
if (!$phpgw_setup->auth('Config'))
|
||||
if (!$GLOBALS['phpgw_setup']->auth('Config'))
|
||||
{
|
||||
Header('Location: index.php');
|
||||
exit;
|
||||
}
|
||||
// Does not return unless user is authorized
|
||||
|
||||
$tpl_root = $phpgw_setup->setup_tpl_dir('setup');
|
||||
$tpl_root = $GLOBALS['phpgw_setup']->html->setup_tpl_dir('setup');
|
||||
$setup_tpl = CreateObject('phpgwapi.Template',$tpl_root);
|
||||
$setup_tpl->set_file(array(
|
||||
'T_head' => 'head.tpl',
|
||||
@ -40,7 +40,7 @@
|
||||
$host = 'us3.phpgroupware.org';
|
||||
$path = '/cvsdemo/xmlrpc.php';
|
||||
|
||||
$phpgw_setup->show_header(lang('Application List'),True);
|
||||
$GLOBALS['phpgw_setup']->html->show_header(lang('Application List'),True);
|
||||
|
||||
/* Login as demo */
|
||||
$login = CreateObject(
|
||||
@ -98,5 +98,5 @@
|
||||
$r = $c->send($logout);
|
||||
$v = $r->value();
|
||||
|
||||
$phpgw_setup->show_footer();
|
||||
$GLOBALS['phpgw_setup']->html->show_footer();
|
||||
?>
|
||||
|
@ -24,13 +24,13 @@
|
||||
Authorize the user to use setup app and load the database
|
||||
Does not return unless user is authorized
|
||||
*/
|
||||
if (!$phpgw_setup->auth('Config'))
|
||||
if(!$GLOBALS['phpgw_setup']->auth('Config'))
|
||||
{
|
||||
Header('Location: index.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
$tpl_root = $phpgw_setup->setup_tpl_dir('setup');
|
||||
$tpl_root = $GLOBALS['phpgw_setup']->html->setup_tpl_dir('setup');
|
||||
$setup_tpl = CreateObject('phpgwapi.Template',$tpl_root);
|
||||
$setup_tpl->set_file(array(
|
||||
'T_head' => 'head.tpl',
|
||||
@ -43,12 +43,12 @@
|
||||
/* Following to ensure windows file paths are saved correctly */
|
||||
set_magic_quotes_runtime(0);
|
||||
|
||||
$phpgw_setup->loaddb();
|
||||
$GLOBALS['phpgw_setup']->loaddb();
|
||||
|
||||
/* Guessing default values. */
|
||||
$GLOBALS['current_config']['hostname'] = $HTTP_HOST;
|
||||
$GLOBALS['current_config']['files_dir'] = ereg_replace('/setup','/files',dirname($SCRIPT_FILENAME));
|
||||
if (@is_dir('/tmp'))
|
||||
if(@is_dir('/tmp'))
|
||||
{
|
||||
$GLOBALS['current_config']['temp_dir'] = '/tmp';
|
||||
}
|
||||
@ -57,15 +57,15 @@
|
||||
$GLOBALS['current_config']['temp_dir'] = '/path/to/temp/dir';
|
||||
}
|
||||
|
||||
if ($HTTP_POST_VARS['cancel'])
|
||||
if($HTTP_POST_VARS['cancel'])
|
||||
{
|
||||
Header('Location: index.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
/* Check api version, use correct table */
|
||||
$setup_info = $phpgw_setup->get_db_versions();
|
||||
if($phpgw_setup->alessthanb($setup_info['phpgwapi']['currentver'], '0.9.10pre7'))
|
||||
$setup_info = $GLOBALS['phpgw_setup']->detection->get_db_versions();
|
||||
if($GLOBALS['phpgw_setup']->alessthanb($setup_info['phpgwapi']['currentver'], '0.9.10pre7'))
|
||||
{
|
||||
$configtbl = 'config';
|
||||
}
|
||||
@ -74,46 +74,46 @@
|
||||
$configtbl = 'phpgw_config';
|
||||
}
|
||||
|
||||
if ($HTTP_POST_VARS['submit'] && $HTTP_POST_VARS['newsettings'])
|
||||
if($HTTP_POST_VARS['submit'] && $HTTP_POST_VARS['newsettings'])
|
||||
{
|
||||
$phpgw_setup->db->transaction_begin();
|
||||
$GLOBALS['phpgw_setup']->db->transaction_begin();
|
||||
/* This is only temp: */
|
||||
$phpgw_setup->db->query("DELETE FROM $configtbl WHERE config_name='useframes'");
|
||||
$phpgw_setup->db->query("INSERT INTO $configtbl (config_app,config_name, config_value) values ('phpgwapi','useframes','never')");
|
||||
$GLOBALS['phpgw_setup']->db->query("DELETE FROM $configtbl WHERE config_name='useframes'");
|
||||
$GLOBALS['phpgw_setup']->db->query("INSERT INTO $configtbl (config_app,config_name, config_value) values ('phpgwapi','useframes','never')");
|
||||
|
||||
$newsettings = $HTTP_POST_VARS['newsettings'];
|
||||
|
||||
while (list($setting,$value) = @each($newsettings))
|
||||
while(list($setting,$value) = @each($newsettings))
|
||||
{
|
||||
/* echo '<br>Updating: ' . $setting . '=' . $value; */
|
||||
/* Don't erase passwords, since we also do not print them below */
|
||||
if(!ereg('passwd',$setting) && !ereg('password',$setting) && !ereg('root_pw',$setting))
|
||||
{
|
||||
@$phpgw_setup->db->query("DELETE FROM $configtbl WHERE config_name='" . $setting . "'");
|
||||
@$GLOBALS['phpgw_setup']->db->query("DELETE FROM $configtbl WHERE config_name='" . $setting . "'");
|
||||
}
|
||||
if($value)
|
||||
{
|
||||
$phpgw_setup->db->query("INSERT INTO $configtbl (config_app,config_name, config_value) VALUES ('phpgwapi','" . $phpgw_setup->db->db_addslashes($setting)
|
||||
. "','" . $phpgw_setup->db->db_addslashes($value) . "')");
|
||||
$GLOBALS['phpgw_setup']->db->query("INSERT INTO $configtbl (config_app,config_name, config_value) VALUES ('phpgwapi','" . $GLOBALS['phpgw_setup']->db->db_addslashes($setting)
|
||||
. "','" . $GLOBALS['phpgw_setup']->db->db_addslashes($value) . "')");
|
||||
}
|
||||
}
|
||||
$phpgw_setup->db->transaction_commit();
|
||||
$GLOBALS['phpgw_setup']->db->transaction_commit();
|
||||
|
||||
/* Add cleaning of app_sessions per skeeter, but with a check for the table being there, just in case */
|
||||
$tablenames = $phpgw_setup->db->table_names();
|
||||
$tablenames = $GLOBALS['phpgw_setup']->db->table_names();
|
||||
while(list($key,$val) = @each($tablenames))
|
||||
{
|
||||
$tables[] = $val['table_name'];
|
||||
}
|
||||
if ($phpgw_setup->isinarray('phpgw_app_sessions',$tables))
|
||||
if(in_array('phpgw_app_sessions',$tables))
|
||||
{
|
||||
$phpgw_setup->db->lock(array('phpgw_app_sessions'));
|
||||
@$phpgw_setup->db->query("DELETE FROM phpgw_app_sessions WHERE sessionid = '0' and loginid = '0' and app = 'phpgwapi' and location = 'config'",__LINE__,__FILE__);
|
||||
@$phpgw_setup->db->query("DELETE FROM phpgw_app_sessions WHERE app = 'phpgwapi' and location = 'phpgw_info_cache'",__LINE__,__FILE__);
|
||||
$phpgw_setup->db->unlock();
|
||||
$GLOBALS['phpgw_setup']->db->lock(array('phpgw_app_sessions'));
|
||||
@$GLOBALS['phpgw_setup']->db->query("DELETE FROM phpgw_app_sessions WHERE sessionid = '0' and loginid = '0' and app = 'phpgwapi' and location = 'config'",__LINE__,__FILE__);
|
||||
@$GLOBALS['phpgw_setup']->db->query("DELETE FROM phpgw_app_sessions WHERE app = 'phpgwapi' and location = 'phpgw_info_cache'",__LINE__,__FILE__);
|
||||
$GLOBALS['phpgw_setup']->db->unlock();
|
||||
}
|
||||
|
||||
if ($newsettings['auth_type'] == 'ldap')
|
||||
if($newsettings['auth_type'] == 'ldap')
|
||||
{
|
||||
Header('Location: '.$newsettings['webserver_url'].'/setup/ldap.php');
|
||||
exit;
|
||||
@ -125,26 +125,26 @@
|
||||
}
|
||||
}
|
||||
|
||||
if ($newsettings['auth_type'] != 'ldap')
|
||||
if($newsettings['auth_type'] != 'ldap')
|
||||
{
|
||||
$phpgw_setup->show_header(lang('Configuration'),False,'config',$ConfigDomain . '(' . $phpgw_domain[$ConfigDomain]["db_type"] . ')');
|
||||
$GLOBALS['phpgw_setup']->html->show_header(lang('Configuration'),False,'config',$ConfigDomain . '(' . $phpgw_domain[$ConfigDomain]["db_type"] . ')');
|
||||
}
|
||||
|
||||
@$phpgw_setup->db->query("SELECT * FROM $configtbl");
|
||||
while (@$phpgw_setup->db->next_record())
|
||||
@$GLOBALS['phpgw_setup']->db->query("SELECT * FROM $configtbl");
|
||||
while(@$GLOBALS['phpgw_setup']->db->next_record())
|
||||
{
|
||||
$GLOBALS['current_config'][$phpgw_setup->db->f('config_name')] = $phpgw_setup->db->f('config_value');
|
||||
$GLOBALS['current_config'][$GLOBALS['phpgw_setup']->db->f('config_name')] = $GLOBALS['phpgw_setup']->db->f('config_value');
|
||||
}
|
||||
|
||||
if ($GLOBALS['current_config']['files_dir'] == '/path/to/dir/phpgroupware/files')
|
||||
if($GLOBALS['current_config']['files_dir'] == '/path/to/dir/phpgroupware/files')
|
||||
{
|
||||
$GLOBALS['current_config']['files_dir'] = $GLOBALS['phpgw_info']['server']['server_root'] . '/files';
|
||||
}
|
||||
|
||||
if ($error == 'badldapconnection')
|
||||
if($error == 'badldapconnection')
|
||||
{
|
||||
/* Please check the number and dial again :) */
|
||||
$phpgw_setup->show_alert_msg('Error',
|
||||
$GLOBALS['phpgw_setup']->html->show_alert_msg('Error',
|
||||
lang('There was a problem trying to connect to your LDAP server. <br>'
|
||||
.'please check your LDAP server configuration') . '.');
|
||||
}
|
||||
@ -161,7 +161,7 @@
|
||||
}
|
||||
$GLOBALS['phpgw'] = new phpgw;
|
||||
$GLOBALS['phpgw']->common = CreateObject('phpgwapi.common');
|
||||
$GLOBALS['phpgw']->db = $phpgw_setup->db;
|
||||
$GLOBALS['phpgw']->db = $GLOBALS['phpgw_setup']->db;
|
||||
|
||||
$cfg_apps = array('phpgwapi','admin','preferences');
|
||||
while(list(,$cfg_app) = each($cfg_apps))
|
||||
@ -177,9 +177,9 @@
|
||||
$t->set_var('row_off', 'EEEEEE');
|
||||
|
||||
$vars = $t->get_undefined('body');
|
||||
$phpgw_setup->hook('config',$cfg_app);
|
||||
$GLOBALS['phpgw_setup']->hook('config',$cfg_app);
|
||||
|
||||
while (list($null,$value) = each($vars))
|
||||
while(list($null,$value) = each($vars))
|
||||
{
|
||||
$valarray = explode('_',$value);
|
||||
$type = $valarray[0];
|
||||
@ -213,13 +213,13 @@
|
||||
$config = '';
|
||||
$newvals = explode(' ',$newval);
|
||||
$setting = end($newvals);
|
||||
for ($i=0;$i<(count($newvals) - 1); $i++)
|
||||
for($i=0;$i<(count($newvals) - 1); $i++)
|
||||
{
|
||||
$configs[] = $newvals[$i];
|
||||
}
|
||||
$config = implode('_',$configs);
|
||||
/* echo $config . '=' . $current_config[$config]; */
|
||||
if ($current_config[$config] == $setting)
|
||||
if($current_config[$config] == $setting)
|
||||
{
|
||||
$t->set_var($value,' selected');
|
||||
}
|
||||
@ -247,5 +247,6 @@
|
||||
$setup_tpl->set_var('lang_submit',lang('submit'));
|
||||
$setup_tpl->set_var('lang_cancel',lang('cancel'));
|
||||
$setup_tpl->pparse('out','T_config_post_script');
|
||||
$phpgw_setup->show_footer();
|
||||
|
||||
$GLOBALS['phpgw_setup']->html->show_footer();
|
||||
?>
|
||||
|
@ -1,16 +1,16 @@
|
||||
phpGroupWare setup May 2001
|
||||
phpGroupWare setup March 2002 revised (5-2001)
|
||||
|
||||
Class logical (?) organization map:
|
||||
|
||||
class.setup.inc.php Global setup functions app/hook/login
|
||||
|
|
||||
class.setup_detection.inc.php Detection of header, file and db versions
|
||||
class.detection.inc.php Detection of header, file and db versions
|
||||
|
|
||||
class.setup_lang.inc.php Multi-lang functions for display
|
||||
class.translation.inc.php Multi-lang functions for display
|
||||
|
|
||||
class.setup_html.inc.php HTML/template output functions
|
||||
class.html.inc.php HTML/template output functions
|
||||
|
|
||||
class.setup_process.inc.php db processing functions/upgrade/install
|
||||
class.process.inc.php db processing functions/upgrade/install
|
||||
|
|
||||
class.schema_proc.inc.php DB array <--> SQL and abstraction class
|
||||
|
|
||||
|
@ -1,469 +0,0 @@
|
||||
<?php
|
||||
/**************************************************************************\
|
||||
* phpGroupWare - Setup *
|
||||
* http://www.phpgroupware.org *
|
||||
* -------------------------------------------- *
|
||||
* This file written by Michael Dean<mdean@users.sourceforge.net> *
|
||||
* and Miles Lott<milosch@phpgroupware.org> *
|
||||
* -------------------------------------------- *
|
||||
* 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$ */
|
||||
|
||||
class schema_proc
|
||||
{
|
||||
var $m_oTranslator;
|
||||
var $m_oDeltaProc;
|
||||
var $m_odb;
|
||||
var $m_aTables;
|
||||
var $m_bDeltaOnly;
|
||||
|
||||
function schema_proc($dbms)
|
||||
{
|
||||
if(@is_object($GLOBALS['phpgw']))
|
||||
{
|
||||
/* this allows usage from within phpgw */
|
||||
$basedir = PHPGW_SERVER_ROOT . '/setup/';
|
||||
}
|
||||
else
|
||||
{
|
||||
$basedir = './';
|
||||
}
|
||||
|
||||
include($basedir . 'inc/class.schema_proc_' . $dbms . '.inc.php');
|
||||
eval("\$this->m_oTranslator = new schema_proc_$dbms;");
|
||||
|
||||
include($basedir . 'inc/class.schema_proc_array.inc.php');
|
||||
|
||||
$this->m_oDeltaProc = new schema_proc_array;
|
||||
$this->m_aTables = array();
|
||||
$this->m_bDeltaOnly = False; // Default to false here in case it's just a CreateTable script
|
||||
}
|
||||
|
||||
function GenerateScripts($aTables, $bOutputHTML = false)
|
||||
{
|
||||
if (!is_array($aTables))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->m_aTables = $aTables;
|
||||
|
||||
reset($this->m_aTables);
|
||||
$sAllTableSQL = '';
|
||||
while (list($sTableName, $aTableDef) = each($this->m_aTables))
|
||||
{
|
||||
$sSequenceSQL = '';
|
||||
if ($this->_GetTableSQL($sTableName, $aTableDef, $sTableSQL, $sSequenceSQL))
|
||||
{
|
||||
$sTableSQL = "CREATE TABLE $sTableName (\n$sTableSQL\n)"
|
||||
. $this->m_oTranslator->m_sStatementTerminator;
|
||||
if ($sSequenceSQL != "")
|
||||
{
|
||||
$sAllTableSQL .= $sSequenceSQL . "\n";
|
||||
}
|
||||
$sAllTableSQL .= $sTableSQL . "\n\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($bOutputHTML)
|
||||
{
|
||||
print('<br>Failed generating script for <b>' . $sTableName . '</b><br>');
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if ($bOutputHTML)
|
||||
{
|
||||
print('<pre>' . $sAllTableSQL . '</pre><br><br>');
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function ExecuteScripts($aTables, $bOutputHTML = false)
|
||||
{
|
||||
if (!is_array($aTables) || !IsSet($this->m_odb))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
reset($aTables);
|
||||
$this->m_aTables = $aTables;
|
||||
|
||||
while (list($sTableName, $aTableDef) = each($aTables))
|
||||
{
|
||||
if ($this->CreateTable($sTableName, $aTableDef))
|
||||
{
|
||||
if ($bOutputHTML)
|
||||
{
|
||||
echo '<br>Create Table <b>' . $sTableName . '</b>';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($bOutputHTML)
|
||||
{
|
||||
echo '<br>Create Table Failed For <b>' . $sTableName . '</b>';
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function DropAllTables($aTables, $bOutputHTML = false)
|
||||
{
|
||||
if (!is_array($aTables) || !IsSet($this->m_odb))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->m_aTables = $aTables;
|
||||
|
||||
reset($this->m_aTables);
|
||||
while (list($sTableName, $aTableDef) = each($this->m_aTables))
|
||||
{
|
||||
if ($this->DropTable($sTableName))
|
||||
{
|
||||
if ($bOutputHTML)
|
||||
{
|
||||
echo '<br>Drop Table <b>' . $sTableSQL . '</b>';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function DropTable($sTableName)
|
||||
{
|
||||
$retVal = $this->m_oDeltaProc->DropTable($this, $this->m_aTables, $sTableName);
|
||||
if ($this->m_bDeltaOnly)
|
||||
{
|
||||
return $retVal;
|
||||
}
|
||||
|
||||
return $retVal && $this->m_oTranslator->DropTable($this, $this->m_aTables, $sTableName);
|
||||
}
|
||||
|
||||
function DropColumn($sTableName, $aTableDef, $sColumnName, $bCopyData = true)
|
||||
{
|
||||
$retVal = $this->m_oDeltaProc->DropColumn($this, $this->m_aTables, $sTableName, $aTableDef, $sColumnName, $bCopyData);
|
||||
if ($this->m_bDeltaOnly)
|
||||
{
|
||||
return $retVal;
|
||||
}
|
||||
|
||||
return $retVal && $this->m_oTranslator->DropColumn($this, $this->m_aTables, $sTableName, $aTableDef, $sColumnName, $bCopyData);
|
||||
}
|
||||
|
||||
function RenameTable($sOldTableName, $sNewTableName)
|
||||
{
|
||||
$retVal = $this->m_oDeltaProc->RenameTable($this, $this->m_aTables, $sOldTableName, $sNewTableName);
|
||||
if ($this->m_bDeltaOnly)
|
||||
{
|
||||
return $retVal;
|
||||
}
|
||||
|
||||
return $retVal && $this->m_oTranslator->RenameTable($this, $this->m_aTables, $sOldTableName, $sNewTableName);
|
||||
}
|
||||
|
||||
function RenameColumn($sTableName, $sOldColumnName, $sNewColumnName, $bCopyData = true)
|
||||
{
|
||||
$retVal = $this->m_oDeltaProc->RenameColumn($this, $this->m_aTables, $sTableName, $sOldColumnName, $sNewColumnName, $bCopyData);
|
||||
if ($this->m_bDeltaOnly)
|
||||
{
|
||||
return $retVal;
|
||||
}
|
||||
|
||||
return $retVal && $this->m_oTranslator->RenameColumn($this, $this->m_aTables, $sTableName, $sOldColumnName, $sNewColumnName, $bCopyData);
|
||||
}
|
||||
|
||||
function AlterColumn($sTableName, $sColumnName, $aColumnDef, $bCopyData = true)
|
||||
{
|
||||
$retVal = $this->m_oDeltaProc->AlterColumn($this, $this->m_aTables, $sTableName, $sColumnName, $aColumnDef, $bCopyData);
|
||||
if ($this->m_bDeltaOnly)
|
||||
{
|
||||
return $retVal;
|
||||
}
|
||||
|
||||
return $retVal && $this->m_oTranslator->AlterColumn($this, $this->m_aTables, $sTableName, $sColumnName, $aColumnDef, $bCopyData);
|
||||
}
|
||||
|
||||
function AddColumn($sTableName, $sColumnName, $aColumnDef)
|
||||
{
|
||||
$retVal = $this->m_oDeltaProc->AddColumn($this, $this->m_aTables, $sTableName, $sColumnName, $aColumnDef);
|
||||
if ($this->m_bDeltaOnly)
|
||||
{
|
||||
return $retVal;
|
||||
}
|
||||
|
||||
return $retVal && $this->m_oTranslator->AddColumn($this, $this->m_aTables, $sTableName, $sColumnName, $aColumnDef);
|
||||
}
|
||||
|
||||
function CreateTable($sTableName, $aTableDef)
|
||||
{
|
||||
$retVal = $this->m_oDeltaProc->CreateTable($this, $this->m_aTables, $sTableName, $aTableDef);
|
||||
if ($this->m_bDeltaOnly)
|
||||
{
|
||||
return $retVal;
|
||||
}
|
||||
|
||||
return $retVal && $this->m_oTranslator->CreateTable($this, $this->m_aTables, $sTableName, $aTableDef);
|
||||
}
|
||||
|
||||
function f($value)
|
||||
{
|
||||
if ($this->m_bDeltaOnly)
|
||||
{
|
||||
// Don't care, since we are processing deltas only
|
||||
return False;
|
||||
}
|
||||
|
||||
return $this->m_odb->f($value);
|
||||
}
|
||||
|
||||
function num_rows()
|
||||
{
|
||||
if ($this->m_bDeltaOnly)
|
||||
{
|
||||
// If not False, we will cause while loops calling us to hang
|
||||
return False;
|
||||
}
|
||||
|
||||
return $this->m_odb->num_rows();
|
||||
}
|
||||
|
||||
function next_record()
|
||||
{
|
||||
if ($this->m_bDeltaOnly)
|
||||
{
|
||||
// If not False, we will cause while loops calling us to hang
|
||||
return False;
|
||||
}
|
||||
|
||||
return $this->m_odb->next_record();
|
||||
}
|
||||
|
||||
function query($sQuery, $line = '', $file = '')
|
||||
{
|
||||
if ($this->m_bDeltaOnly)
|
||||
{
|
||||
// Don't run this query, since we are processing deltas only
|
||||
return True;
|
||||
}
|
||||
|
||||
return $this->m_odb->query($sQuery, $line, $file);
|
||||
}
|
||||
|
||||
function _GetTableSQL($sTableName, $aTableDef, &$sTableSQL, &$sSequenceSQL)
|
||||
{
|
||||
global $DEBUG;
|
||||
|
||||
if (!is_array($aTableDef))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$sTableSQL = '';
|
||||
reset($aTableDef['fd']);
|
||||
while (list($sFieldName, $aFieldAttr) = each($aTableDef['fd']))
|
||||
{
|
||||
$sFieldSQL = '';
|
||||
if ($this->_GetFieldSQL($aFieldAttr, $sFieldSQL))
|
||||
{
|
||||
if ($sTableSQL != '')
|
||||
{
|
||||
$sTableSQL .= ",\n";
|
||||
}
|
||||
|
||||
$sTableSQL .= "$sFieldName $sFieldSQL";
|
||||
|
||||
if ($aFieldAttr['type'] == 'auto')
|
||||
{
|
||||
$this->m_oTranslator->GetSequenceSQL($sTableName, $sSequenceSQL);
|
||||
if ($sSequenceSQL != '')
|
||||
{
|
||||
$sTableSQL .= sprintf(" DEFAULT nextval('seq_%s')", $sTableName);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($DEBUG) { echo 'GetFieldSQL failed for ' . $sFieldName; }
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$sUCSQL = '';
|
||||
$sPKSQL = '';
|
||||
|
||||
if (count($aTableDef['pk']) > 0)
|
||||
{
|
||||
if (!$this->_GetPK($aTableDef['pk'], $sPKSQL))
|
||||
{
|
||||
if ($bOutputHTML)
|
||||
{
|
||||
print('<br>Failed getting primary key<br>');
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (count($aTableDef['uc']) > 0)
|
||||
{
|
||||
if (!$this->_GetUC($aTableDef['uc'], $sUCSQL))
|
||||
{
|
||||
if ($bOutputHTML)
|
||||
{
|
||||
print('<br>Failed getting unique constraint<br>');
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if ($sPKSQL != '')
|
||||
{
|
||||
$sTableSQL .= ",\n" . $sPKSQL;
|
||||
}
|
||||
|
||||
if ($sUCSQL != '')
|
||||
{
|
||||
$sTableSQL .= ",\n" . $sUCSQL;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Get field DDL
|
||||
function _GetFieldSQL($aField, &$sFieldSQL)
|
||||
{
|
||||
global $DEBUG;
|
||||
if ($DEBUG) { echo'<br>_GetFieldSQL(): Incoming ARRAY: '; var_dump($aField); }
|
||||
if (!is_array($aField))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$sType = '';
|
||||
$iPrecision = 0;
|
||||
$iScale = 0;
|
||||
$sDefault = '';
|
||||
$bNullable = true;
|
||||
|
||||
reset($aField);
|
||||
while (list($sAttr, $vAttrVal) = each($aField))
|
||||
{
|
||||
switch ($sAttr)
|
||||
{
|
||||
case 'type':
|
||||
$sType = $vAttrVal;
|
||||
break;
|
||||
case 'precision':
|
||||
$iPrecision = (int)$vAttrVal;
|
||||
break;
|
||||
case 'scale':
|
||||
$iScale = (int)$vAttrVal;
|
||||
break;
|
||||
case 'default':
|
||||
$sDefault = $vAttrVal;
|
||||
if ($DEBUG) { echo'<br>_GetFieldSQL(): Default="' . $sDefault . '"'; }
|
||||
break;
|
||||
case 'nullable':
|
||||
$bNullable = $vAttrVal;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Translate the type for the DBMS
|
||||
if ($this->m_oTranslator->TranslateType($sType, $iPrecision, $iScale, $sFieldSQL))
|
||||
{
|
||||
if ($bNullable == false)
|
||||
{
|
||||
$sFieldSQL .= ' NOT NULL';
|
||||
}
|
||||
|
||||
if ($sDefault != '')
|
||||
{
|
||||
if ($DEBUG) { echo'<br>_GetFieldSQL(): Calling TranslateDefault for "' . $sDefault . '"'; }
|
||||
// Get default DDL - useful for differences in date defaults (eg, now() vs. getdate())
|
||||
$sTranslatedDefault = $this->m_oTranslator->TranslateDefault($sDefault);
|
||||
$sFieldSQL .= " DEFAULT '$sTranslatedDefault'";
|
||||
}
|
||||
elseif($sDefault == '0')
|
||||
{
|
||||
$sFieldSQL .= " DEFAULT '0'";
|
||||
}
|
||||
if ($DEBUG) { echo'<br>_GetFieldSQL(): Outgoing SQL: ' . $sFieldSQL; }
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($DEBUG) { echo '<br>Failed to translate field: type[' . $sType . '] precision[' . $iPrecision . '] scale[' . $iScale . ']<br>'; }
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function _GetPK($aFields, &$sPKSQL)
|
||||
{
|
||||
$sPKSQL = '';
|
||||
if (count($aFields) < 1)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
$sFields = '';
|
||||
reset($aFields);
|
||||
while (list($key, $sField) = each($aFields))
|
||||
{
|
||||
if ($sFields != '')
|
||||
{
|
||||
$sFields .= ',';
|
||||
}
|
||||
$sFields .= $sField;
|
||||
}
|
||||
|
||||
$sPKSQL = $this->m_oTranslator->GetPKSQL($sFields);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function _GetUC($aFields, &$sUCSQL)
|
||||
{
|
||||
$sUCSQL = '';
|
||||
if (count($aFields) < 1)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
$sFields = '';
|
||||
reset($aFields);
|
||||
while (list($key, $sField) = each($aFields))
|
||||
{
|
||||
if ($sFields != '')
|
||||
{
|
||||
$sFields .= ',';
|
||||
}
|
||||
$sFields .= $sField;
|
||||
}
|
||||
|
||||
$sUCSQL = $this->m_oTranslator->GetUCSQL($sFields);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,184 +0,0 @@
|
||||
<?php
|
||||
/**************************************************************************\
|
||||
* phpGroupWare - Setup *
|
||||
* http://www.phpgroupware.org *
|
||||
* -------------------------------------------- *
|
||||
* This file written by Michael Dean<mdean@users.sourceforge.net> *
|
||||
* and Miles Lott<milosch@phpgroupware.org> *
|
||||
* -------------------------------------------- *
|
||||
* 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$ */
|
||||
|
||||
class schema_proc_array
|
||||
{
|
||||
var $m_sStatementTerminator;
|
||||
|
||||
function schema_proc_array()
|
||||
{
|
||||
$this->m_sStatementTerminator = ";";
|
||||
}
|
||||
|
||||
/* Return a type suitable for DDL abstracted array */
|
||||
function TranslateType($sType, $iPrecision = 0, $iScale = 0, &$sTranslated)
|
||||
{
|
||||
$sTranslated = $sType;
|
||||
return (strlen($sTranslated) > 0);
|
||||
}
|
||||
|
||||
function TranslateDefault($sDefault)
|
||||
{
|
||||
return $sDefault;
|
||||
}
|
||||
|
||||
function GetPKSQL($sFields)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
function GetUCSQL($sFields)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
function _GetColumns($oProc, &$aTables, $sTableName, &$sColumns, $sDropColumn = "")
|
||||
{
|
||||
$sColumns = "";
|
||||
while (list($sName, $aJunk) = each($aTables[$sTableName]["fd"]))
|
||||
{
|
||||
if ($sColumns != "")
|
||||
{
|
||||
$sColumns .= ",";
|
||||
}
|
||||
$sColumns .= $sName;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function DropTable($oProc, &$aTables, $sTableName)
|
||||
{
|
||||
if (IsSet($aTables[$sTableName]))
|
||||
{
|
||||
UnSet($aTables[$sTableName]);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function DropColumn($oProc, &$aTables, $sTableName, $aNewTableDef, $sColumnName, $bCopyData = true)
|
||||
{
|
||||
if (IsSet($aTables[$sTableName]))
|
||||
{
|
||||
if (IsSet($aTables[$sTableName]["fd"][$sColumnName]))
|
||||
{
|
||||
UnSet($aTables[$sTableName]["fd"][$sColumnName]);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function RenameTable($oProc, &$aTables, $sOldTableName, $sNewTableName)
|
||||
{
|
||||
$aNewTables = array();
|
||||
while (list($sTableName, $aTableDef) = each($aTables))
|
||||
{
|
||||
if ($sTableName == $sOldTableName)
|
||||
{
|
||||
$aNewTables[$sNewTableName] = $aTableDef;
|
||||
}
|
||||
else
|
||||
{
|
||||
$aNewTables[$sTableName] = $aTableDef;
|
||||
}
|
||||
}
|
||||
|
||||
$aTables = $aNewTables;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function RenameColumn($oProc, &$aTables, $sTableName, $sOldColumnName, $sNewColumnName, $bCopyData = true)
|
||||
{
|
||||
if (IsSet($aTables[$sTableName]))
|
||||
{
|
||||
$aNewTableDef = array();
|
||||
reset($aTables[$sTableName]["fd"]);
|
||||
while (list($sColumnName, $aColumnDef) = each($aTables[$sTableName]["fd"]))
|
||||
{
|
||||
if ($sColumnName == $sOldColumnName)
|
||||
{
|
||||
$aNewTableDef[$sNewColumnName] = $aColumnDef;
|
||||
}
|
||||
else
|
||||
{
|
||||
$aNewTableDef[$sColumnName] = $aColumnDef;
|
||||
}
|
||||
}
|
||||
|
||||
$aTables[$sTableName]["fd"] = $aNewTableDef;
|
||||
|
||||
reset($aTables[$sTableName]["pk"]);
|
||||
while (list($key, $sColumnName) = each($aTables[$sTableName]["pk"]))
|
||||
{
|
||||
if ($sColumnName == $sOldColumnName)
|
||||
{
|
||||
$aTables[$sTableName]["pk"][$key] = $sNewColumnName;
|
||||
}
|
||||
}
|
||||
|
||||
reset($aTables[$sTableName]["uc"]);
|
||||
while (list($key, $sColumnName) = each($aTables[$sTableName]["uc"]))
|
||||
{
|
||||
if ($sColumnName == $sOldColumnName)
|
||||
{
|
||||
$aTables[$sTableName]["uc"][$key] = $sNewColumnName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function AlterColumn($oProc, &$aTables, $sTableName, $sColumnName, &$aColumnDef, $bCopyData = true)
|
||||
{
|
||||
if (IsSet($aTables[$sTableName]))
|
||||
{
|
||||
if (IsSet($aTables[$sTableName]["fd"][$sColumnName]))
|
||||
{
|
||||
$aTables[$sTableName]["fd"][$sColumnName] = $aColumnDef;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function AddColumn($oProc, &$aTables, $sTableName, $sColumnName, &$aColumnDef)
|
||||
{
|
||||
if (IsSet($aTables[$sTableName]))
|
||||
{
|
||||
if (!IsSet($aTables[$sTableName]["fd"][$sColumnName]))
|
||||
{
|
||||
$aTables[$sTableName]["fd"][$sColumnName] = $aColumnDef;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function CreateTable($oProc, &$aTables, $sTableName, $aTableDef)
|
||||
{
|
||||
if (!IsSet($aTables[$sTableName]))
|
||||
{
|
||||
$aTables[$sTableName] = $aTableDef;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,343 +0,0 @@
|
||||
<?php
|
||||
/**************************************************************************\
|
||||
* phpGroupWare - Setup *
|
||||
* http://www.phpgroupware.org *
|
||||
* -------------------------------------------- *
|
||||
* This file written by Michael Dean<mdean@users.sourceforge.net> *
|
||||
* and Miles Lott<milosch@phpgroupware.org> *
|
||||
* -------------------------------------------- *
|
||||
* 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$ */
|
||||
|
||||
class schema_proc_mssql
|
||||
{
|
||||
var $m_sStatementTerminator;
|
||||
/* Following added to convert sql to array */
|
||||
var $sCol = array();
|
||||
var $pk = array();
|
||||
var $fk = array();
|
||||
var $ix = array();
|
||||
var $uc = array();
|
||||
|
||||
function schema_proc_mssql()
|
||||
{
|
||||
$this->m_sStatementTerminator = ';';
|
||||
}
|
||||
|
||||
/* Return a type suitable for DDL */
|
||||
function TranslateType($sType, $iPrecision = 0, $iScale = 0, &$sTranslated)
|
||||
{
|
||||
$sTranslated = '';
|
||||
switch($sType)
|
||||
{
|
||||
case 'auto':
|
||||
$sTranslated = 'int identity(1,1)';
|
||||
break;
|
||||
case 'blob':
|
||||
$sTranslated = 'image'; /* wonder how well PHP will support this??? */
|
||||
break;
|
||||
case 'char':
|
||||
if ($iPrecision > 0 && $iPrecision < 256)
|
||||
{
|
||||
$sTranslated = sprintf("char(%d)", $iPrecision);
|
||||
}
|
||||
if ($iPrecision > 255)
|
||||
{
|
||||
$sTranslated = 'text';
|
||||
}
|
||||
break;
|
||||
case 'date':
|
||||
$sTranslated = 'smalldatetime';
|
||||
break;
|
||||
case 'decimal':
|
||||
$sTranslated = sprintf("decimal(%d,%d)", $iPrecision, $iScale);
|
||||
break;
|
||||
case 'float':
|
||||
switch ($iPrecision)
|
||||
{
|
||||
case 4:
|
||||
$sTranslated = 'float';
|
||||
break;
|
||||
case 8:
|
||||
$sTranslated = 'real';
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'int':
|
||||
switch ($iPrecision)
|
||||
{
|
||||
case 2:
|
||||
$sTranslated = 'smallint';
|
||||
break;
|
||||
case 4:
|
||||
case 8:
|
||||
$sTranslated = 'int';
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'longtext':
|
||||
case 'text':
|
||||
$sTranslated = 'text';
|
||||
break;
|
||||
case 'timestamp':
|
||||
$sTranslated = 'datetime';
|
||||
break;
|
||||
case 'varchar':
|
||||
if ($iPrecision > 0 && $iPrecision < 256)
|
||||
{
|
||||
$sTranslated = sprintf("varchar(%d)", $iPrecision);
|
||||
}
|
||||
if ($iPrecision > 255)
|
||||
{
|
||||
$sTranslated = 'text';
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return (strlen($sTranslated) > 0);
|
||||
}
|
||||
|
||||
function TranslateDefault($sDefault)
|
||||
{
|
||||
switch ($sDefault)
|
||||
{
|
||||
case 'current_date':
|
||||
case 'current_timestamp':
|
||||
return 'GetDate()';
|
||||
}
|
||||
|
||||
return $sDefault;
|
||||
}
|
||||
|
||||
// Inverse of above, convert sql column types to array info
|
||||
function rTranslateType($sType, $iPrecision = 0, $iScale = 0, &$sTranslated)
|
||||
{
|
||||
$sTranslated = '';
|
||||
if ($sType == 'int' || $sType == 'tinyint' || $sType == 'smallint')
|
||||
{
|
||||
if ($iPrecision > 8)
|
||||
{
|
||||
$iPrecision = 8;
|
||||
}
|
||||
elseif($iPrecision > 4)
|
||||
{
|
||||
$iPrecision = 4;
|
||||
}
|
||||
else
|
||||
{
|
||||
$iPrecision = 2;
|
||||
}
|
||||
}
|
||||
switch($sType)
|
||||
{
|
||||
case 'tinyint':
|
||||
case 'smallint':
|
||||
$sTranslated = "'type' => 'int', 'precision' => 2";
|
||||
break;
|
||||
case 'int':
|
||||
$sTranslated = "'type' => 'int', 'precision' => 4";
|
||||
break;
|
||||
case 'char':
|
||||
if ($iPrecision > 0 && $iPrecision < 256)
|
||||
{
|
||||
$sTranslated = "'type' => 'char', 'precision' => $iPrecision";
|
||||
}
|
||||
if ($iPrecision > 255)
|
||||
{
|
||||
$sTranslated = "'type' => 'text'";
|
||||
}
|
||||
break;
|
||||
case 'decimal':
|
||||
$sTranslated = "'type' => 'decimal', 'precision' => $iPrecision, 'scale' => $iScale";
|
||||
break;
|
||||
case 'float':
|
||||
case 'double':
|
||||
$sTranslated = "'type' => 'float', 'precision' => $iPrecision";
|
||||
break;
|
||||
case 'smalldatetime':
|
||||
$sTranslated = "'type' => 'date'";
|
||||
break;
|
||||
case 'datetime':
|
||||
$sTranslated = "'type' => 'timestamp'";
|
||||
break;
|
||||
case 'varchar':
|
||||
if ($iPrecision > 0 && $iPrecision < 256)
|
||||
{
|
||||
$sTranslated = "'type' => 'varchar', 'precision' => $iPrecision";
|
||||
}
|
||||
if ($iPrecision > 255)
|
||||
{
|
||||
$sTranslated = "'type' => 'text'";
|
||||
}
|
||||
break;
|
||||
case 'image':
|
||||
$sTranslated = "'type' => 'blob'";
|
||||
break;
|
||||
case 'text':
|
||||
$sTranslated = "'type' => '$sType'";
|
||||
break;
|
||||
}
|
||||
|
||||
return (strlen($sTranslated) > 0);
|
||||
}
|
||||
|
||||
function GetPKSQL($sFields)
|
||||
{
|
||||
return "PRIMARY KEY($sFields)";
|
||||
}
|
||||
|
||||
function GetUCSQL($sFields)
|
||||
{
|
||||
return "UNIQUE($sFields)";
|
||||
}
|
||||
|
||||
function _GetColumns($oProc, $sTableName, &$sColumns, $sDropColumn = '')
|
||||
{
|
||||
$sColumns = '';
|
||||
$this->pk = array();
|
||||
$this->fk = array();
|
||||
$this->ix = array();
|
||||
$this->uc = array();
|
||||
|
||||
// Field, Type, Null, Key, Default, Extra
|
||||
$oProc->m_odb->query("exec sp_columns '$sTableName'");
|
||||
while ($oProc->m_odb->next_record())
|
||||
{
|
||||
$type = $default = $null = $nullcomma = $prec = $scale = $ret = $colinfo = $scales = '';
|
||||
if ($sColumns != '')
|
||||
{
|
||||
$sColumns .= ',';
|
||||
}
|
||||
$sColumns .= $oProc->m_odb->f(0);
|
||||
|
||||
// The rest of this is used only for SQL->array
|
||||
$colinfo = explode('(',$oProc->m_odb->f(1));
|
||||
$prec = ereg_replace(')','',$colinfo[1]);
|
||||
$scales = explode(',',$prec);
|
||||
if ($scales[1])
|
||||
{
|
||||
$prec = $scales[0];
|
||||
$scale = $scales[1];
|
||||
}
|
||||
$this->rTranslateType($colinfo[0], $prec, $scale, &$type);
|
||||
|
||||
if ($oProc->m_odb->f(2) == 'YES')
|
||||
{
|
||||
$null = "'nullable' => True";
|
||||
}
|
||||
else
|
||||
{
|
||||
$null = "'nullable' => False";
|
||||
}
|
||||
if ($oProc->m_odb->f(4))
|
||||
{
|
||||
$default = "'default' => '".$oProc->m_odb->f(4)."'";
|
||||
$nullcomma = ',';
|
||||
}
|
||||
else
|
||||
{
|
||||
$default = '';
|
||||
$nullcomma = '';
|
||||
}
|
||||
if ($oProc->m_odb->f(5))
|
||||
{
|
||||
$type = "'type' => 'auto'";
|
||||
}
|
||||
$this->sCol[] = "\t\t\t\t'" . $oProc->m_odb->f(0)."' => array(" . $type . ',' . $null . $nullcomma . $default . '),' . "\n";
|
||||
if ($oProc->m_odb->f(3) == 'PRI')
|
||||
{
|
||||
$this->pk[] = $oProc->m_odb->f(0);
|
||||
}
|
||||
if ($oProc->m_odb->f(3) == 'UNI')
|
||||
{
|
||||
$this->uc[] = $oProc->m_odb->f(0);
|
||||
}
|
||||
/* Hmmm, MUL could also mean unique, or not... */
|
||||
if ($oProc->m_odb->f(3) == 'MUL')
|
||||
{
|
||||
$this->ix[] = $oProc->m_odb->f(0);
|
||||
}
|
||||
}
|
||||
/* ugly as heck, but is here to chop the trailing comma on the last element (for php3) */
|
||||
$this->sCol[count($this->sCol) - 1] = substr($this->sCol[count($this->sCol) - 1],0,-2) . "\n";
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function DropTable($oProc, &$aTables, $sTableName)
|
||||
{
|
||||
return !!($oProc->m_odb->query("DROP TABLE " . $sTableName));
|
||||
}
|
||||
|
||||
function DropColumn($oProc, &$aTables, $sTableName, $aNewTableDef, $sColumnName, $bCopyData = true)
|
||||
{
|
||||
return !!($oProc->m_odb->query("ALTER TABLE $sTableName DROP COLUMN $sColumnName"));
|
||||
}
|
||||
|
||||
function RenameTable($oProc, &$aTables, $sOldTableName, $sNewTableName)
|
||||
{
|
||||
return !!($oProc->m_odb->query("EXEC sp_rename '$sOldTableName', '$sNewTableName'"));
|
||||
}
|
||||
|
||||
function RenameColumn($oProc, &$aTables, $sTableName, $sOldColumnName, $sNewColumnName, $bCopyData = true)
|
||||
{
|
||||
// This really needs testing - it can affect primary keys, and other table-related objects
|
||||
// like sequences and such
|
||||
global $DEBUG;
|
||||
if ($DEBUG) { echo '<br>RenameColumn: calling _GetFieldSQL for ' . $sNewColumnName; }
|
||||
if ($oProc->_GetFieldSQL($aTables[$sTableName]["fd"][$sNewColumnName], $sNewColumnSQL))
|
||||
{
|
||||
return !!($oProc->m_odb->query("EXEC sp_rename '$sTableName.$sOldColumnName', '$sNewColumnName'"));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function AlterColumn($oProc, &$aTables, $sTableName, $sColumnName, &$aColumnDef, $bCopyData = true)
|
||||
{
|
||||
global $DEBUG;
|
||||
if ($DEBUG) { echo '<br>AlterColumn: calling _GetFieldSQL for ' . $sNewColumnName; }
|
||||
if ($oProc->_GetFieldSQL($aTables[$sTableName]["fd"][$sColumnName], $sNewColumnSQL))
|
||||
{
|
||||
return !!($oProc->m_odb->query("ALTER TABLE $sTableName ALTER COLUMN $sColumnName " . $sNewColumnSQL));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function AddColumn($oProc, &$aTables, $sTableName, $sColumnName, &$aColumnDef)
|
||||
{
|
||||
$oProc->_GetFieldSQL($aColumnDef, $sFieldSQL);
|
||||
$query = "ALTER TABLE $sTableName ADD $sColumnName $sFieldSQL";
|
||||
|
||||
return !!($oProc->m_odb->query($query));
|
||||
}
|
||||
|
||||
function GetSequenceSQL($sTableName, &$sSequenceSQL)
|
||||
{
|
||||
$sSequenceSQL = '';
|
||||
return true;
|
||||
}
|
||||
|
||||
function CreateTable($oProc, &$aTables, $sTableName, $aTableDef)
|
||||
{
|
||||
if ($oProc->_GetTableSQL($sTableName, $aTableDef, $sTableSQL, $sSequenceSQL))
|
||||
{
|
||||
// create sequence first since it will be needed for default
|
||||
if ($sSequenceSQL != '')
|
||||
{
|
||||
$oProc->m_odb->query($sSequenceSQL);
|
||||
}
|
||||
|
||||
$query = "CREATE TABLE $sTableName ($sTableSQL)";
|
||||
return !!($oProc->m_odb->query($query));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,367 +0,0 @@
|
||||
<?php
|
||||
/**************************************************************************\
|
||||
* phpGroupWare - Setup *
|
||||
* http://www.phpgroupware.org *
|
||||
* -------------------------------------------- *
|
||||
* This file written by Michael Dean<mdean@users.sourceforge.net> *
|
||||
* and Miles Lott<milosch@phpgroupware.org> *
|
||||
* -------------------------------------------- *
|
||||
* 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$ */
|
||||
|
||||
class schema_proc_mysql
|
||||
{
|
||||
var $m_sStatementTerminator;
|
||||
/* Following added to convert sql to array */
|
||||
var $sCol = array();
|
||||
var $pk = array();
|
||||
var $fk = array();
|
||||
var $ix = array();
|
||||
var $uc = array();
|
||||
|
||||
function schema_proc_mysql()
|
||||
{
|
||||
$this->m_sStatementTerminator = ';';
|
||||
}
|
||||
|
||||
/* Return a type suitable for DDL */
|
||||
function TranslateType($sType, $iPrecision = 0, $iScale = 0, &$sTranslated)
|
||||
{
|
||||
$sTranslated = '';
|
||||
switch($sType)
|
||||
{
|
||||
case 'auto':
|
||||
$sTranslated = 'int(11) auto_increment';
|
||||
break;
|
||||
case 'blob':
|
||||
$sTranslated = 'blob';
|
||||
break;
|
||||
case 'char':
|
||||
if ($iPrecision > 0 && $iPrecision < 256)
|
||||
{
|
||||
$sTranslated = sprintf("char(%d)", $iPrecision);
|
||||
}
|
||||
if ($iPrecision > 255)
|
||||
{
|
||||
$sTranslated = 'text';
|
||||
}
|
||||
break;
|
||||
case 'date':
|
||||
$sTranslated = 'date';
|
||||
break;
|
||||
case 'decimal':
|
||||
$sTranslated = sprintf("decimal(%d,%d)", $iPrecision, $iScale);
|
||||
break;
|
||||
case 'float':
|
||||
switch ($iPrecision)
|
||||
{
|
||||
case 4:
|
||||
$sTranslated = 'float';
|
||||
break;
|
||||
case 8:
|
||||
$sTranslated = 'double';
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'int':
|
||||
switch ($iPrecision)
|
||||
{
|
||||
case 2:
|
||||
$sTranslated = 'smallint';
|
||||
break;
|
||||
case 4:
|
||||
$sTranslated = 'int';
|
||||
break;
|
||||
case 8:
|
||||
$sTranslated = 'bigint';
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'longtext':
|
||||
$sTranslated = 'longtext';
|
||||
break;
|
||||
case 'text':
|
||||
$sTranslated = 'text';
|
||||
break;
|
||||
case 'timestamp':
|
||||
$sTranslated = 'datetime';
|
||||
break;
|
||||
case 'varchar':
|
||||
if ($iPrecision > 0 && $iPrecision < 256)
|
||||
{
|
||||
$sTranslated = sprintf("varchar(%d)", $iPrecision);
|
||||
}
|
||||
if ($iPrecision > 255)
|
||||
{
|
||||
$sTranslated = 'text';
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return (strlen($sTranslated) > 0);
|
||||
}
|
||||
|
||||
function TranslateDefault($sDefault)
|
||||
{
|
||||
switch ($sDefault)
|
||||
{
|
||||
case 'current_date':
|
||||
case 'current_timestamp':
|
||||
return 'now';
|
||||
}
|
||||
|
||||
return $sDefault;
|
||||
}
|
||||
|
||||
/* Inverse of above, convert sql column types to array info */
|
||||
function rTranslateType($sType, $iPrecision = 0, $iScale = 0, &$sTranslated)
|
||||
{
|
||||
$sTranslated = '';
|
||||
if ($sType == 'int' || $sType == 'tinyint' || $sType == 'smallint' || $sType == 'bigint')
|
||||
{
|
||||
if ($iPrecision > 8)
|
||||
{
|
||||
$iPrecision = 8;
|
||||
}
|
||||
elseif($iPrecision > 4)
|
||||
{
|
||||
$iPrecision = 4;
|
||||
}
|
||||
else
|
||||
{
|
||||
$iPrecision = 2;
|
||||
}
|
||||
}
|
||||
switch($sType)
|
||||
{
|
||||
case 'tinyint':
|
||||
case 'smallint':
|
||||
$sTranslated = "'type' => 'int', 'precision' => 2";
|
||||
break;
|
||||
case 'int':
|
||||
$sTranslated = "'type' => 'int', 'precision' => 4";
|
||||
break;
|
||||
case 'bigint':
|
||||
$sTranslated = "'type' => 'int', 'precision' => 8";
|
||||
case 'char':
|
||||
if ($iPrecision > 0 && $iPrecision < 256)
|
||||
{
|
||||
$sTranslated = "'type' => 'char', 'precision' => $iPrecision";
|
||||
}
|
||||
if ($iPrecision > 255)
|
||||
{
|
||||
$sTranslated = "'type' => 'text'";
|
||||
}
|
||||
break;
|
||||
case 'decimal':
|
||||
$sTranslated = "'type' => 'decimal', 'precision' => $iPrecision, 'scale' => $iScale";
|
||||
break;
|
||||
case 'float':
|
||||
case 'double':
|
||||
$sTranslated = "'type' => 'float', 'precision' => $iPrecision";
|
||||
break;
|
||||
case 'datetime':
|
||||
$sTranslated = "'type' => 'timestamp'";
|
||||
break;
|
||||
case 'enum':
|
||||
/* Here comes a nasty assumption */
|
||||
/* $sTranslated = "'type' => 'varchar', 'precision' => 255"; */
|
||||
$sTranslated = "'type' => 'varchar', 'precision' => $iPrecision";
|
||||
break;
|
||||
case 'varchar':
|
||||
if ($iPrecision > 0 && $iPrecision < 256)
|
||||
{
|
||||
$sTranslated = "'type' => 'varchar', 'precision' => $iPrecision";
|
||||
}
|
||||
if ($iPrecision > 255)
|
||||
{
|
||||
$sTranslated = "'type' => 'text'";
|
||||
}
|
||||
break;
|
||||
case 'longtext':
|
||||
case 'text':
|
||||
case 'blob':
|
||||
case 'date':
|
||||
$sTranslated = "'type' => '$sType'";
|
||||
break;
|
||||
}
|
||||
|
||||
return (strlen($sTranslated) > 0);
|
||||
}
|
||||
|
||||
function GetPKSQL($sFields)
|
||||
{
|
||||
return "PRIMARY KEY($sFields)";
|
||||
}
|
||||
|
||||
function GetUCSQL($sFields)
|
||||
{
|
||||
return "UNIQUE($sFields)";
|
||||
}
|
||||
|
||||
function _GetColumns($oProc, $sTableName, &$sColumns, $sDropColumn = '')
|
||||
{
|
||||
$sColumns = '';
|
||||
$this->pk = array();
|
||||
$this->fk = array();
|
||||
$this->ix = array();
|
||||
$this->uc = array();
|
||||
|
||||
/* Field, Type, Null, Key, Default, Extra */
|
||||
$oProc->m_odb->query("describe $sTableName");
|
||||
while ($oProc->m_odb->next_record())
|
||||
{
|
||||
$type = $default = $null = $nullcomma = $prec = $scale = $ret = $colinfo = $scales = '';
|
||||
if ($sColumns != '')
|
||||
{
|
||||
$sColumns .= ',';
|
||||
}
|
||||
$sColumns .= $oProc->m_odb->f(0);
|
||||
|
||||
/* The rest of this is used only for SQL->array */
|
||||
$colinfo = explode('(',$oProc->m_odb->f(1));
|
||||
$prec = ereg_replace(')','',$colinfo[1]);
|
||||
$scales = explode(',',$prec);
|
||||
|
||||
if($colinfo[0] == 'enum')
|
||||
{
|
||||
/* set prec to length of longest enum-value */
|
||||
for($prec=0; list($nul,$name) = @each($scales);)
|
||||
{
|
||||
if($prec < (strlen($name) - 2))
|
||||
{
|
||||
/* -2 as name is like "'name'" */
|
||||
$prec = (strlen($name) - 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif ($scales[1])
|
||||
{
|
||||
$prec = $scales[0];
|
||||
$scale = $scales[1];
|
||||
}
|
||||
$this->rTranslateType($colinfo[0], $prec, $scale, &$type);
|
||||
|
||||
if ($oProc->m_odb->f(2) == 'YES')
|
||||
{
|
||||
$null = "'nullable' => True";
|
||||
}
|
||||
else
|
||||
{
|
||||
$null = "'nullable' => False";
|
||||
}
|
||||
if ($oProc->m_odb->f(4))
|
||||
{
|
||||
$default = "'default' => '".$oProc->m_odb->f(4)."'";
|
||||
$nullcomma = ',';
|
||||
}
|
||||
else
|
||||
{
|
||||
$default = '';
|
||||
$nullcomma = '';
|
||||
}
|
||||
if ($oProc->m_odb->f(5))
|
||||
{
|
||||
$type = "'type' => 'auto'";
|
||||
}
|
||||
$this->sCol[] = "\t\t\t\t'" . $oProc->m_odb->f(0)."' => array(" . $type . ',' . $null . $nullcomma . $default . '),' . "\n";
|
||||
if ($oProc->m_odb->f(3) == 'PRI')
|
||||
{
|
||||
$this->pk[] = $oProc->m_odb->f(0);
|
||||
}
|
||||
if ($oProc->m_odb->f(3) == 'UNI')
|
||||
{
|
||||
$this->uc[] = $oProc->m_odb->f(0);
|
||||
}
|
||||
/* Hmmm, MUL could also mean unique, or not... */
|
||||
if ($oProc->m_odb->f(3) == 'MUL')
|
||||
{
|
||||
$this->ix[] = $oProc->m_odb->f(0);
|
||||
}
|
||||
}
|
||||
/* ugly as heck, but is here to chop the trailing comma on the last element (for php3) */
|
||||
$this->sCol[count($this->sCol) - 1] = substr($this->sCol[count($this->sCol) - 1],0,-2) . "\n";
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function DropTable($oProc, &$aTables, $sTableName)
|
||||
{
|
||||
return !!($oProc->m_odb->query("DROP TABLE " . $sTableName));
|
||||
}
|
||||
|
||||
function DropColumn($oProc, &$aTables, $sTableName, $aNewTableDef, $sColumnName, $bCopyData = true)
|
||||
{
|
||||
return !!($oProc->m_odb->query("ALTER TABLE $sTableName DROP COLUMN $sColumnName"));
|
||||
}
|
||||
|
||||
function RenameTable($oProc, &$aTables, $sOldTableName, $sNewTableName)
|
||||
{
|
||||
return !!($oProc->m_odb->query("ALTER TABLE $sOldTableName RENAME $sNewTableName"));
|
||||
}
|
||||
|
||||
function RenameColumn($oProc, &$aTables, $sTableName, $sOldColumnName, $sNewColumnName, $bCopyData = true)
|
||||
{
|
||||
/*
|
||||
TODO: This really needs testing - it can affect primary keys, and other table-related objects
|
||||
like sequences and such
|
||||
*/
|
||||
global $DEBUG;
|
||||
if ($DEBUG) { echo '<br>RenameColumn: calling _GetFieldSQL for ' . $sNewColumnName; }
|
||||
if ($oProc->_GetFieldSQL($aTables[$sTableName]["fd"][$sNewColumnName], $sNewColumnSQL))
|
||||
{
|
||||
return !!($oProc->m_odb->query("ALTER TABLE $sTableName CHANGE $sOldColumnName $sNewColumnName " . $sNewColumnSQL));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function AlterColumn($oProc, &$aTables, $sTableName, $sColumnName, &$aColumnDef, $bCopyData = true)
|
||||
{
|
||||
global $DEBUG;
|
||||
if ($DEBUG) { echo '<br>AlterColumn: calling _GetFieldSQL for ' . $sNewColumnName; }
|
||||
if ($oProc->_GetFieldSQL($aTables[$sTableName]["fd"][$sColumnName], $sNewColumnSQL))
|
||||
{
|
||||
return !!($oProc->m_odb->query("ALTER TABLE $sTableName MODIFY $sColumnName " . $sNewColumnSQL));
|
||||
/* return !!($oProc->m_odb->query("ALTER TABLE $sTableName CHANGE $sColumnName $sColumnName " . $sNewColumnSQL)); */
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function AddColumn($oProc, &$aTables, $sTableName, $sColumnName, &$aColumnDef)
|
||||
{
|
||||
$oProc->_GetFieldSQL($aColumnDef, $sFieldSQL);
|
||||
$query = "ALTER TABLE $sTableName ADD COLUMN $sColumnName $sFieldSQL";
|
||||
|
||||
return !!($oProc->m_odb->query($query));
|
||||
}
|
||||
|
||||
function GetSequenceSQL($sTableName, &$sSequenceSQL)
|
||||
{
|
||||
$sSequenceSQL = '';
|
||||
return true;
|
||||
}
|
||||
|
||||
function CreateTable($oProc, &$aTables, $sTableName, $aTableDef)
|
||||
{
|
||||
if ($oProc->_GetTableSQL($sTableName, $aTableDef, $sTableSQL, $sSequenceSQL))
|
||||
{
|
||||
/* create sequence first since it will be needed for default */
|
||||
if ($sSequenceSQL != '')
|
||||
{
|
||||
$oProc->m_odb->query($sSequenceSQL);
|
||||
}
|
||||
|
||||
$query = "CREATE TABLE $sTableName ($sTableSQL)";
|
||||
return !!($oProc->m_odb->query($query));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,619 +0,0 @@
|
||||
<?php
|
||||
/**************************************************************************\
|
||||
* phpGroupWare - Setup *
|
||||
* http://www.phpgroupware.org *
|
||||
* SQL for table properties taken from phpPgAdmin Version 2.2.1 *
|
||||
* http://www.greatbridge.org/project/phppgadmin *
|
||||
* Copyright (C) 1999-2000 Dan Wilson <phpPgAdmin@acucore.com> *
|
||||
* Copyright (C) 1998-1999 Tobias Ratschiller <tobias@dnet.it> *
|
||||
* -------------------------------------------- *
|
||||
* This file written by Michael Dean<mdean@users.sourceforge.net> *
|
||||
* and Miles Lott<milosch@phpgroupware.org> *
|
||||
* -------------------------------------------- *
|
||||
* 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$ */
|
||||
|
||||
class schema_proc_pgsql
|
||||
{
|
||||
var $m_sStatementTerminator;
|
||||
/* Following added to convert sql to array */
|
||||
var $sCol = array();
|
||||
var $pk = array();
|
||||
var $fk = array();
|
||||
var $ix = array();
|
||||
var $uc = array();
|
||||
|
||||
function schema_proc_pgsql()
|
||||
{
|
||||
$this->m_sStatementTerminator = ';';
|
||||
}
|
||||
|
||||
/* Return a type suitable for DDL */
|
||||
function TranslateType($sType, $iPrecision = 0, $iScale = 0, &$sTranslated)
|
||||
{
|
||||
switch($sType)
|
||||
{
|
||||
case 'auto':
|
||||
$sTranslated = 'int4';
|
||||
break;
|
||||
case 'blob':
|
||||
$sTranslated = 'text';
|
||||
break;
|
||||
case 'char':
|
||||
if ($iPrecision > 0 && $iPrecision < 256)
|
||||
{
|
||||
$sTranslated = sprintf("char(%d)", $iPrecision);
|
||||
}
|
||||
if ($iPrecision > 255)
|
||||
{
|
||||
$sTranslated = 'text';
|
||||
}
|
||||
break;
|
||||
case 'date':
|
||||
$sTranslated = 'date';
|
||||
break;
|
||||
case 'decimal':
|
||||
$sTranslated = sprintf("decimal(%d,%d)", $iPrecision, $iScale);
|
||||
break;
|
||||
case 'float':
|
||||
if ($iPrecision == 4 || $iPrecision == 8)
|
||||
{
|
||||
$sTranslated = sprintf("float%d", $iPrecision);
|
||||
}
|
||||
break;
|
||||
case 'int':
|
||||
if ($iPrecision == 2 || $iPrecision == 4 || $iPrecision == 8)
|
||||
{
|
||||
$sTranslated = sprintf("int%d", $iPrecision);
|
||||
}
|
||||
break;
|
||||
case 'longtext':
|
||||
$sTranslated = 'text';
|
||||
break;
|
||||
case 'text':
|
||||
$sTranslated = 'text';
|
||||
break;
|
||||
case 'timestamp':
|
||||
$sTranslated = 'timestamp';
|
||||
break;
|
||||
case 'varchar':
|
||||
if ($iPrecision > 0 && $iPrecision < 256)
|
||||
{
|
||||
$sTranslated = sprintf("varchar(%d)", $iPrecision);
|
||||
}
|
||||
if ($iPrecision > 255)
|
||||
{
|
||||
$sTranslated = 'text';
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return (strlen($sTranslated) > 0);
|
||||
}
|
||||
|
||||
function TranslateDefault($sDefault)
|
||||
{
|
||||
switch ($sDefault)
|
||||
{
|
||||
case 'current_date':
|
||||
case 'current_timestamp':
|
||||
return 'now';
|
||||
}
|
||||
|
||||
return $sDefault;
|
||||
}
|
||||
|
||||
/* Inverse of above, convert sql column types to array info */
|
||||
function rTranslateType($sType, $iPrecision = 0, $iScale = 0, &$sTranslated)
|
||||
{
|
||||
$sTranslated = '';
|
||||
switch($sType)
|
||||
{
|
||||
case 'serial':
|
||||
$sTranslated = "'type' => 'auto'";
|
||||
break;
|
||||
case 'int2':
|
||||
$sTranslated = "'type' => 'int', 'precision' => 2";
|
||||
break;
|
||||
case 'int4':
|
||||
$sTranslated = "'type' => 'int', 'precision' => 4";
|
||||
break;
|
||||
case 'int8':
|
||||
$sTranslated = "'type' => 'int', 'precision' => 8";
|
||||
break;
|
||||
case 'bpchar':
|
||||
case 'char':
|
||||
if ($iPrecision > 0 && $iPrecision < 256)
|
||||
{
|
||||
$sTranslated = "'type' => 'char', 'precision' => $iPrecision";
|
||||
}
|
||||
if ($iPrecision > 255)
|
||||
{
|
||||
$sTranslated = "'type' => 'text'";
|
||||
}
|
||||
break;
|
||||
case 'numeric':
|
||||
/* Borrowed from phpPgAdmin */
|
||||
$iPrecision = ($iScale >> 16) & 0xffff;
|
||||
$iScale = ($iScale - 4) & 0xffff;
|
||||
$sTranslated = "'type' => 'decimal', 'precision' => $iPrecision, 'scale' => $iScale";
|
||||
break;
|
||||
case 'float':
|
||||
case 'float4':
|
||||
case 'float8':
|
||||
case 'double':
|
||||
$sTranslated = "'type' => 'float', 'precision' => $iPrecision";
|
||||
break;
|
||||
case 'datetime':
|
||||
case 'timestamp':
|
||||
$sTranslated = "'type' => 'timestamp'";
|
||||
break;
|
||||
case 'varchar':
|
||||
if ($iPrecision > 0 && $iPrecision < 256)
|
||||
{
|
||||
$sTranslated = "'type' => 'varchar', 'precision' => $iPrecision";
|
||||
}
|
||||
if ($iPrecision > 255)
|
||||
{
|
||||
$sTranslated = "'type' => 'text'";
|
||||
}
|
||||
break;
|
||||
case 'text':
|
||||
case 'blob':
|
||||
case 'date':
|
||||
$sTranslated = "'type' => '$sType'";
|
||||
break;
|
||||
}
|
||||
|
||||
return (strlen($sTranslated) > 0);
|
||||
}
|
||||
|
||||
function GetPKSQL($sFields)
|
||||
{
|
||||
return "PRIMARY KEY($sFields)";
|
||||
}
|
||||
|
||||
function GetUCSQL($sFields)
|
||||
{
|
||||
return "UNIQUE($sFields)";
|
||||
}
|
||||
|
||||
function _GetColumns($oProc, $sTableName, &$sColumns, $sDropColumn = '', $sAlteredColumn = '', $sAlteredColumnType = '')
|
||||
{
|
||||
$sdb = $oProc->m_odb;
|
||||
$sdc = $oProc->m_odb;
|
||||
|
||||
$sColumns = '';
|
||||
$this->pk = array();
|
||||
$this->fk = array();
|
||||
$this->ix = array();
|
||||
$this->uc = array();
|
||||
|
||||
$query = "SELECT a.attname,a.attnum FROM pg_attribute a,pg_class b WHERE ";
|
||||
$query .= "b.oid=a.attrelid AND a.attnum>0 and b.relname='$sTableName'";
|
||||
if ($sDropColumn != '')
|
||||
{
|
||||
$query .= " AND a.attname != '$sDropColumn'";
|
||||
}
|
||||
$query .= ' ORDER BY a.attnum';
|
||||
|
||||
$oProc->m_odb->query($query);
|
||||
while ($oProc->m_odb->next_record())
|
||||
{
|
||||
if ($sColumns != '')
|
||||
{
|
||||
$sColumns .= ',';
|
||||
}
|
||||
|
||||
$sFieldName = $oProc->m_odb->f(0);
|
||||
$sColumns .= $sFieldName;
|
||||
if ($sAlteredColumn == $sFieldName && $sAlteredColumnType != '')
|
||||
{
|
||||
$sColumns .= '::' . $sAlteredColumnType;
|
||||
}
|
||||
}
|
||||
//$qdefault = "SELECT substring(d.adsrc for 128) FROM pg_attrdef d, pg_class c "
|
||||
// . "WHERE c.relname = $sTableName AND c.oid = d.adrelid AND d.adnum =" . $oProc->m_odb->f(1);
|
||||
$sql_get_fields = "
|
||||
SELECT
|
||||
a.attnum,
|
||||
a.attname AS field,
|
||||
t.typname AS type,
|
||||
a.attlen AS length,
|
||||
a.atttypmod AS lengthvar,
|
||||
a.attnotnull AS notnull
|
||||
FROM
|
||||
pg_class c,
|
||||
pg_attribute a,
|
||||
pg_type t
|
||||
WHERE
|
||||
c.relname = '$sTableName'
|
||||
and a.attnum > 0
|
||||
and a.attrelid = c.oid
|
||||
and a.atttypid = t.oid
|
||||
ORDER BY a.attnum";
|
||||
/* attnum field type length lengthvar notnull(Yes/No) */
|
||||
$sdb->query($sql_get_fields);
|
||||
while ($sdb->next_record())
|
||||
{
|
||||
$colnum = $sdb->f(0);
|
||||
$colname = $sdb->f(1);
|
||||
|
||||
if ($sdb->f(5) == 'Yes')
|
||||
{
|
||||
$null = "'nullable' => True";
|
||||
}
|
||||
else
|
||||
{
|
||||
$null = "'nullable' => False";
|
||||
}
|
||||
|
||||
if ($sdb->f(2) == 'numeric')
|
||||
{
|
||||
$prec = $sdb->f(3);
|
||||
$scale = $sdb->f(4);
|
||||
}
|
||||
elseif ($sdb->f(3) > 0)
|
||||
{
|
||||
$prec = $sdb->f(3);
|
||||
$scale = 0;
|
||||
}
|
||||
elseif ($sdb->f(4) > 0)
|
||||
{
|
||||
$prec = $sdb->f(4) - 4;
|
||||
$scale = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
$prec = 0;
|
||||
$scale = 0;
|
||||
}
|
||||
|
||||
$this->rTranslateType($sdb->f(2),$prec,$scale,$type);
|
||||
|
||||
$sql_get_default = "
|
||||
SELECT d.adsrc AS rowdefault
|
||||
FROM pg_attrdef d, pg_class c
|
||||
WHERE
|
||||
c.relname = '$sTableName' AND
|
||||
c.oid = d.adrelid AND
|
||||
d.adnum = $colnum
|
||||
";
|
||||
$sdc->query($sql_get_default);
|
||||
$sdc->next_record();
|
||||
if ($sdc->f(0))
|
||||
{
|
||||
if (ereg('nextval',$sdc->f(0)))
|
||||
{
|
||||
$default = '';
|
||||
$nullcomma = '';
|
||||
}
|
||||
else
|
||||
{
|
||||
$default = "'default' => '".$sdc->f(0)."'";
|
||||
$nullcomma = ',';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$default = '';
|
||||
$nullcomma = '';
|
||||
}
|
||||
$default = ereg_replace("''","'",$default);
|
||||
|
||||
$this->sCol[] = "\t\t\t\t'" . $colname . "' => array(" . $type . ',' . $null . $nullcomma . $default . '),' . "\n";
|
||||
}
|
||||
$sql_pri_keys = "
|
||||
SELECT
|
||||
ic.relname AS index_name,
|
||||
bc.relname AS tab_name,
|
||||
ta.attname AS column_name,
|
||||
i.indisunique AS unique_key,
|
||||
i.indisprimary AS primary_key
|
||||
FROM
|
||||
pg_class bc,
|
||||
pg_class ic,
|
||||
pg_index i,
|
||||
pg_attribute ta,
|
||||
pg_attribute ia
|
||||
WHERE
|
||||
bc.oid = i.indrelid
|
||||
AND ic.oid = i.indexrelid
|
||||
AND ia.attrelid = i.indexrelid
|
||||
AND ta.attrelid = bc.oid
|
||||
AND bc.relname = '$sTableName'
|
||||
AND ta.attrelid = i.indrelid
|
||||
AND ta.attnum = i.indkey[ia.attnum-1]
|
||||
ORDER BY
|
||||
index_name, tab_name, column_name";
|
||||
$sdc->query($sql_pri_keys);
|
||||
while ($sdc->next_record())
|
||||
{
|
||||
//echo '<br> checking: ' . $sdc->f(4);
|
||||
if ($sdc->f(4) == 't')
|
||||
{
|
||||
$this->pk[] = $sdc->f(2);
|
||||
}
|
||||
if ($sdc->f(3) == 't')
|
||||
{
|
||||
$this->uc[] = $sdc->f(2);
|
||||
}
|
||||
}
|
||||
/* ugly as heck, but is here to chop the trailing comma on the last element (for php3) */
|
||||
$this->sCol[count($this->sCol) - 1] = substr($this->sCol[count($this->sCol) - 1],0,-2) . "\n";
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function _CopyAlteredTable($oProc, &$aTables, $sSource, $sDest)
|
||||
{
|
||||
$oDB = $oProc->m_odb;
|
||||
$oProc->m_odb->query("select * from $sSource");
|
||||
while ($oProc->m_odb->next_record())
|
||||
{
|
||||
$sSQL = "INSERT INTO $sDest (";
|
||||
$i=0;
|
||||
@reset($aTables[$sDest]['fd']);
|
||||
while (list($name,$arraydef) = each($aTables[$sDest]['fd']))
|
||||
{
|
||||
if ($i > 0)
|
||||
{
|
||||
$sSQL .= ',';
|
||||
}
|
||||
|
||||
$sSQL .= $name;
|
||||
$i++;
|
||||
}
|
||||
|
||||
$sSQL .= ') VALUES (';
|
||||
@reset($aTables[$sDest]['fd']);
|
||||
$i=0;
|
||||
while (list($name,$arraydef) = each($aTables[$sDest]['fd']))
|
||||
{
|
||||
if ($i > 0)
|
||||
{
|
||||
$sSQL .= ',';
|
||||
}
|
||||
|
||||
if ($oProc->m_odb->f($i) != null)
|
||||
{
|
||||
switch ($arraydef['type'])
|
||||
{
|
||||
case 'blob':
|
||||
case 'char':
|
||||
case 'date':
|
||||
case 'text':
|
||||
case 'timestamp':
|
||||
case 'varchar':
|
||||
$sSQL .= "'" . $oProc->m_odb->db_addslashes($oProc->m_odb->f($i)) . "'";
|
||||
break;
|
||||
default:
|
||||
$sSQL .= intval($oProc->m_odb->f($i));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$sSQL .= 'null';
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
$sSQL .= ')';
|
||||
|
||||
$oDB->query($sSQL);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function GetSequenceForTable($oProc,$table,&$sSequenceName)
|
||||
{
|
||||
global $DEBUG;
|
||||
if($DEBUG) { echo '<br>GetSequenceForTable: ' . $table; }
|
||||
|
||||
$oProc->m_odb->query("SELECT relname FROM pg_class WHERE NOT relname ~ 'pg_.*' AND relname LIKE 'seq_$table' AND relkind='S' ORDER BY relname",__LINE__,__FILE__);
|
||||
$oProc->m_odb->next_record();
|
||||
if ($oProc->m_odb->f('relname'))
|
||||
{
|
||||
$sSequenceName = $oProc->m_odb->f('relname');
|
||||
}
|
||||
return True;
|
||||
}
|
||||
|
||||
function GetSequenceFieldForTable($oProc,$table,&$sField)
|
||||
{
|
||||
global $DEBUG;
|
||||
if($DEBUG) { echo '<br>GetSequenceFieldForTable: You rang?'; }
|
||||
$oProc->m_odb->query("SELECT a.attname FROM pg_attribute a, pg_class c, pg_attrdef d WHERE c.relname='$table' AND c.oid=d.adrelid AND d.adsrc LIKE '%seq_$table%' AND a.attrelid=c.oid AND d.adnum=a.attnum");
|
||||
$oProc->m_odb->next_record();
|
||||
if ($oProc->m_odb->f('attname'))
|
||||
{
|
||||
$sField = $oProc->m_odb->f('attname');
|
||||
}
|
||||
return True;
|
||||
}
|
||||
|
||||
function DropSequenceForTable($oProc,$table)
|
||||
{
|
||||
global $DEBUG;
|
||||
if($DEBUG) { echo '<br>DropSequenceForTable: ' . $table; }
|
||||
|
||||
$this->GetSequenceForTable($oProc,$table,$sSequenceName);
|
||||
if ($sSequenceName)
|
||||
{
|
||||
$oProc->m_odb->query("DROP SEQUENCE " . $sSequenceName,__LINE__,__FILE__);
|
||||
}
|
||||
return True;
|
||||
}
|
||||
|
||||
function DropTable($oProc, &$aTables, $sTableName)
|
||||
{
|
||||
$this->DropSequenceForTable($oProc,$sTableName);
|
||||
|
||||
return !!($oProc->m_odb->query("DROP TABLE " . $sTableName));
|
||||
}
|
||||
|
||||
function DropColumn($oProc, &$aTables, $sTableName, $aNewTableDef, $sColumnName, $bCopyData = true)
|
||||
{
|
||||
if ($bCopyData)
|
||||
{
|
||||
$oProc->m_odb->query("SELECT * INTO $sTableName" . "_tmp FROM $sTableName");
|
||||
}
|
||||
|
||||
$this->DropTable($oProc, $aTables, $sTableName);
|
||||
|
||||
$oProc->_GetTableSQL($sTableName, $aNewTableDef, $sTableSQL, $sSequenceSQL);
|
||||
if($sSequenceSQL)
|
||||
{
|
||||
$oProc->m_odb->query($sSequenceSQL);
|
||||
}
|
||||
$query = "CREATE TABLE $sTableName ($sTableSQL)";
|
||||
if (!$bCopyData)
|
||||
{
|
||||
return !!($oProc->m_odb->query($query));
|
||||
}
|
||||
|
||||
$oProc->m_odb->query($query);
|
||||
$this->_GetColumns($oProc, $sTableName . '_tmp', $sColumns, $sColumnName);
|
||||
$query = "INSERT INTO $sTableName SELECT $sColumns FROM $sTableName" . '_tmp';
|
||||
$bRet = !!($oProc->m_odb->query($query));
|
||||
return ($bRet && $this->DropTable($oProc, $aTables, $sTableName . '_tmp'));
|
||||
}
|
||||
|
||||
function RenameTable($oProc, &$aTables, $sOldTableName, $sNewTableName)
|
||||
{
|
||||
global $DEBUG;
|
||||
if ($DEBUG) { echo '<br>RenameTable(): Fetching old sequence for: ' . $sOldTableName; }
|
||||
$this->GetSequenceForTable($oProc,$sOldTableName,$sSequenceName);
|
||||
if ($DEBUG) { echo ' - ' . $sSequenceName; }
|
||||
if ($DEBUG) { echo '<br>RenameTable(): Fetching sequence field for: ' . $sOldTableName; }
|
||||
$this->GetSequenceFieldForTable($oProc,$sOldTableName,$sField);
|
||||
if ($DEBUG) { echo ' - ' . $sField; }
|
||||
|
||||
if ($sSequenceName)
|
||||
{
|
||||
$oProc->m_odb->query("SELECT last_value FROM seq_$sOldTableName",__LINE__,__FILE__);
|
||||
$oProc->m_odb->next_record();
|
||||
$lastval = $oProc->m_odb->f(0);
|
||||
|
||||
if ($DEBUG) { echo '<br>RenameTable(): dropping old sequence: ' . $sSequenceName . ' used on field: ' . $sField; }
|
||||
$this->DropSequenceForTable($oProc,$sOldTableName);
|
||||
|
||||
if ($lastval)
|
||||
{
|
||||
$lastval = ' start ' . $lastval;
|
||||
}
|
||||
$this->GetSequenceSQL($sNewTableName,$sSequenceSQL);
|
||||
if ($DEBUG) { echo '<br>RenameTable(): Making new sequence using: ' . $sSequenceSQL . $lastval; }
|
||||
$oProc->m_odb->query($sSequenceSQL . $lastval,__LINE__,__FILE__);
|
||||
if ($DEBUG) { echo '<br>RenameTable(): Altering column default for: ' . $sField; }
|
||||
$oProc->m_odb->query("ALTER TABLE $sOldTableName ALTER $sField SET DEFAULT nextval('seq_" . $sNewTableName . "')",__LINE__,__FILE__);
|
||||
}
|
||||
|
||||
$indexnames = $oProc->m_odb->index_names();
|
||||
while(list($key,$val) = @each($indexnames))
|
||||
{
|
||||
$indexes[] = $val['index_name'];
|
||||
}
|
||||
if(isinarray($sOldTableName . '_pkey',$indexes))
|
||||
{
|
||||
$oProc->m_odb->query("DROP INDEX " . $sOldTableName . "_pkey",__LINE__,__FILE__);
|
||||
}
|
||||
|
||||
return !!($oProc->m_odb->query("ALTER TABLE $sOldTableName RENAME TO $sNewTableName"));
|
||||
}
|
||||
|
||||
function RenameColumn($oProc, &$aTables, $sTableName, $sOldColumnName, $sNewColumnName, $bCopyData = true)
|
||||
{
|
||||
/*
|
||||
This really needs testing - it can affect primary keys, and other table-related objects
|
||||
like sequences and such
|
||||
*/
|
||||
if ($bCopyData)
|
||||
{
|
||||
$oProc->m_odb->query("SELECT * INTO $sTableName" . "_tmp FROM $sTableName");
|
||||
}
|
||||
|
||||
$this->DropTable($oProc, $aTables, $sTableName);
|
||||
|
||||
if (!$bCopyData)
|
||||
{
|
||||
return $this->CreateTable($oProc, $aTables, $sTableName, $oProc->m_aTables[$sTableName], false);
|
||||
}
|
||||
|
||||
$this->CreateTable($oProc, $aTables, $sTableName, $aTables[$sTableName], True);
|
||||
$this->_GetColumns($oProc, $sTableName . "_tmp", $sColumns);
|
||||
$query = "INSERT INTO $sTableName SELECT $sColumns FROM $sTableName" . "_tmp";
|
||||
|
||||
$bRet = !!($oProc->m_odb->query($query));
|
||||
return ($bRet && $this->DropTable($oProc, $aTables, $sTableName . "_tmp"));
|
||||
}
|
||||
|
||||
function AlterColumn($oProc, &$aTables, $sTableName, $sColumnName, &$aColumnDef, $bCopyData = true)
|
||||
{
|
||||
if ($bCopyData)
|
||||
{
|
||||
$oProc->m_odb->query("SELECT * INTO $sTableName" . "_tmp FROM $sTableName");
|
||||
}
|
||||
|
||||
$this->DropTable($oProc, $aTables, $sTableName);
|
||||
|
||||
if (!$bCopyData)
|
||||
{
|
||||
return $this->CreateTable($oProc, $aTables, $sTableName, $aTables[$sTableName], True);
|
||||
}
|
||||
|
||||
$this->CreateTable($oProc, $aTables, $sTableName, $aTables[$sTableName], True);
|
||||
$this->_GetColumns($oProc, $sTableName . "_tmp", $sColumns, '', $sColumnName, $aColumnDef['type'] == 'auto' ? 'int4' : $aColumnDef['type']);
|
||||
|
||||
/*
|
||||
TODO: analyze the type of change and determine if this is used or _CopyAlteredTable
|
||||
this is a performance consideration only, _CopyAlteredTable should be safe
|
||||
$query = "INSERT INTO $sTableName SELECT $sColumns FROM $sTableName" . "_tmp";
|
||||
$bRet = !!($oProc->m_odb->query($query));
|
||||
*/
|
||||
|
||||
$bRet = $this->_CopyAlteredTable($oProc, $aTables, $sTableName . '_tmp', $sTableName);
|
||||
|
||||
return ($bRet && $this->DropTable($oProc, $aTables, $sTableName . "_tmp"));
|
||||
}
|
||||
|
||||
function AddColumn($oProc, &$aTables, $sTableName, $sColumnName, &$aColumnDef)
|
||||
{
|
||||
$oProc->_GetFieldSQL($aColumnDef, $sFieldSQL);
|
||||
$query = "ALTER TABLE $sTableName ADD COLUMN $sColumnName $sFieldSQL";
|
||||
|
||||
return !!($oProc->m_odb->query($query));
|
||||
}
|
||||
|
||||
function GetSequenceSQL($sTableName, &$sSequenceSQL)
|
||||
{
|
||||
$sSequenceSQL = sprintf("CREATE SEQUENCE seq_%s", $sTableName);
|
||||
return true;
|
||||
}
|
||||
|
||||
function CreateTable($oProc, $aTables, $sTableName, $aTableDef, $bCreateSequence = true)
|
||||
{
|
||||
global $DEBUG;
|
||||
if ($oProc->_GetTableSQL($sTableName, $aTableDef, $sTableSQL, $sSequenceSQL))
|
||||
{
|
||||
/* create sequence first since it will be needed for default */
|
||||
if ($bCreateSequence && $sSequenceSQL != '')
|
||||
{
|
||||
if ($DEBUG) { echo '<br>Making sequence using: ' . $sSequenceSQL; }
|
||||
$oProc->m_odb->query($sSequenceSQL);
|
||||
}
|
||||
|
||||
$query = "CREATE TABLE $sTableName ($sTableSQL)";
|
||||
|
||||
return !!($oProc->m_odb->query($query));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,770 +0,0 @@
|
||||
<?php
|
||||
/**************************************************************************\
|
||||
* phpGroupWare - Setup *
|
||||
* http://www.phpgroupware.org *
|
||||
* -------------------------------------------- *
|
||||
* This file written by Joseph Engo<jengo@phpgroupware.org> *
|
||||
* and Dan Kuykendall<seek3r@phpgroupware.org> *
|
||||
* and Mark Peters<skeeter@phpgroupware.org> *
|
||||
* and Miles Lott<milosch@phpgroupware.org> *
|
||||
* -------------------------------------------- *
|
||||
* 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$ */
|
||||
|
||||
include('./inc/class.setup_detection.inc.php');
|
||||
include('./inc/class.setup_process.inc.php');
|
||||
include('./inc/class.setup_lang.inc.php');
|
||||
include('./inc/class.setup_html.inc.php');
|
||||
class phpgw_setup extends phpgw_setup_html
|
||||
{
|
||||
var $db;
|
||||
var $oProc;
|
||||
var $tables;
|
||||
|
||||
/*!
|
||||
@function loaddb
|
||||
@abstract include api db class for the ConfigDomain and connect to the db
|
||||
*/
|
||||
function loaddb()
|
||||
{
|
||||
$GLOBALS['ConfigDomain'] = @$GLOBALS['HTTP_COOKIE_VARS']['ConfigDomain'] ? @$GLOBALS['HTTP_COOKIE_VARS']['ConfigDomain'] : @$GLOBALS['HTTP_POST_VARS']['ConfigDomain'];
|
||||
if(empty($GLOBALS['ConfigDomain']))
|
||||
{
|
||||
/* This is to fix the reading of this value immediately after the cookie was set on login */
|
||||
$GLOBALS['ConfigDomain'] = @$GLOBALS['HTTP_POST_VARS']['FormDomain'] ? @$GLOBALS['HTTP_POST_VARS']['FormDomain'] : 'default';
|
||||
}
|
||||
|
||||
/* Database setup */
|
||||
if (!isset($GLOBALS['phpgw_info']['server']['api_inc']))
|
||||
{
|
||||
$GLOBALS['phpgw_info']['server']['api_inc'] = PHPGW_SERVER_ROOT . '/phpgwapi/inc';
|
||||
}
|
||||
include($GLOBALS['phpgw_info']['server']['api_inc'] . '/class.db_'.$GLOBALS['phpgw_domain'][$GLOBALS['ConfigDomain']]['db_type'].'.inc.php');
|
||||
$this->db = new db;
|
||||
$this->db->Host = $GLOBALS['phpgw_domain'][$GLOBALS['ConfigDomain']]['db_host'];
|
||||
$this->db->Type = $GLOBALS['phpgw_domain'][$GLOBALS['ConfigDomain']]['db_type'];
|
||||
$this->db->Database = $GLOBALS['phpgw_domain'][$GLOBALS['ConfigDomain']]['db_name'];
|
||||
$this->db->User = $GLOBALS['phpgw_domain'][$GLOBALS['ConfigDomain']]['db_user'];
|
||||
$this->db->Password = $GLOBALS['phpgw_domain'][$GLOBALS['ConfigDomain']]['db_pass'];
|
||||
}
|
||||
|
||||
/*!
|
||||
@function auth
|
||||
@abstract authenticate the setup user
|
||||
@param $auth_type ???
|
||||
*/
|
||||
function auth($auth_type = "Config")
|
||||
{
|
||||
$FormLogout = @$GLOBALS['HTTP_GET_VARS']['FormLogout'] ? @$GLOBALS['HTTP_GET_VARS']['FormLogout'] : @$GLOBALS['HTTP_POST_VARS']['FormLogout'];
|
||||
$ConfigLogin = @$GLOBALS['HTTP_POST_VARS']['ConfigLogin'] ? @$GLOBALS['HTTP_POST_VARS']['ConfigLogin'] : @$GLOBALS['HTTP_COOKIE_VARS']['ConfigLogin'];
|
||||
$HeaderLogin = @$GLOBALS['HTTP_POST_VARS']['HeaderLogin'] ? @$GLOBALS['HTTP_POST_VARS']['HeaderLogin'] : @$GLOBALS['HTTP_COOKIE_VARS']['HeaderLogin'];
|
||||
$FormDomain = @$GLOBALS['HTTP_POST_VARS']['FormDomain'];
|
||||
$FormPW = @$GLOBALS['HTTP_POST_VARS']['FormPW'];
|
||||
$ConfigDomain = @$GLOBALS['HTTP_POST_VARS']['ConfigDomain'] ? @$GLOBALS['HTTP_POST_VARS']['ConfigDomain'] : @$GLOBALS['HTTP_COOKIE_VARS']['ConfigDomain'];
|
||||
$ConfigPW = @$GLOBALS['HTTP_POST_VARS']['ConfigPW'] ? @$GLOBALS['HTTP_POST_VARS']['ConfigPW'] : @$GLOBALS['HTTP_COOKIE_VARS']['ConfigPW'];
|
||||
$HeaderPW = @$GLOBALS['HTTP_COOKIE_VARS']['HeaderPW'] ? @$GLOBALS['HTTP_COOKIE_VARS']['HeaderPW'] : @$GLOBALS['HTTP_POST_VARS']['HeaderPW'];
|
||||
$ConfigLang = @$GLOBALS['HTTP_POST_VARS']['ConfigLang'] ? @$GLOBALS['HTTP_POST_VARS']['ConfigLang'] : @$GLOBALS['HTTP_COOKIE_VARS']['ConfigLang'];
|
||||
|
||||
if (isset($FormLogout) && !empty($FormLogout))
|
||||
{
|
||||
if ($FormLogout == 'config' ||
|
||||
$FormLogout == 'ldap' ||
|
||||
$FormLogout == 'ldapexport' ||
|
||||
$FormLogout == 'ldapimport' ||
|
||||
$FormLogout == 'sqltoarray')
|
||||
{
|
||||
setcookie('ConfigPW',''); /* scrub the old one */
|
||||
setcookie('ConfigDomain',''); /* scrub the old one */
|
||||
setcookie('ConfigLang','');
|
||||
$GLOBALS['phpgw_info']['setup']['ConfigLoginMSG'] = 'You have successfully logged out';
|
||||
$GLOBALS['phpgw_info']['setup']['HeaderLoginMSG'] = '';
|
||||
return False;
|
||||
}
|
||||
elseif($FormLogout == 'header')
|
||||
{
|
||||
setcookie('HeaderPW',''); /* scrub the old one */
|
||||
$GLOBALS['phpgw_info']['setup']['HeaderLoginMSG'] = 'You have successfully logged out';
|
||||
$GLOBALS['phpgw_info']['setup']['ConfigLoginMSG'] = '';
|
||||
return False;
|
||||
}
|
||||
}
|
||||
elseif (isset($ConfigPW) && !empty($ConfigPW))
|
||||
{
|
||||
if ($ConfigPW != $GLOBALS['phpgw_domain'][$ConfigDomain]['config_passwd'] && $auth_type == 'Config')
|
||||
{
|
||||
setcookie('ConfigPW',''); /* scrub the old one */
|
||||
setcookie('ConfigDomain',''); /* scrub the old one */
|
||||
setcookie('ConfigLang','');
|
||||
$GLOBALS['phpgw_info']['setup']['ConfigLoginMSG'] = 'Invalid session cookie (cookies must be enabled)';
|
||||
$GLOBALS['phpgw_info']['setup']['HeaderLoginMSG'] = '';
|
||||
return False;
|
||||
}
|
||||
else
|
||||
{
|
||||
return True;
|
||||
}
|
||||
}
|
||||
elseif (isset($FormPW) && !empty($FormPW))
|
||||
{
|
||||
if (isset($ConfigLogin))
|
||||
{
|
||||
if ($FormPW == $GLOBALS['phpgw_domain'][$FormDomain]['config_passwd'] && $auth_type == 'Config')
|
||||
{
|
||||
setcookie('HeaderPW',''); /* scrub the old one */
|
||||
setcookie('ConfigPW',"$FormPW");
|
||||
setcookie('ConfigDomain',"$FormDomain");
|
||||
setcookie('ConfigLang',"$ConfigLang");
|
||||
$ConfigDomain = "$FormDomain";
|
||||
return True;
|
||||
}
|
||||
else
|
||||
{
|
||||
$GLOBALS['phpgw_info']['setup']['ConfigLoginMSG'] = 'Invalid password';
|
||||
$GLOBALS['phpgw_info']['setup']['HeaderLoginMSG'] = '';
|
||||
return False;
|
||||
}
|
||||
}
|
||||
elseif (isset($HeaderLogin) && !empty($HeaderLogin))
|
||||
{
|
||||
if ($FormPW == $GLOBALS['phpgw_info']['server']['header_admin_password'] && $auth_type == 'Header')
|
||||
{
|
||||
setcookie('HeaderPW',"$FormPW");
|
||||
return True;
|
||||
}
|
||||
else
|
||||
{
|
||||
$GLOBALS['phpgw_info']['setup']['HeaderLoginMSG'] = 'Invalid password';
|
||||
$GLOBALS['phpgw_info']['setup']['ConfigLoginMSG'] = '';
|
||||
return False;
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif (isset($HeaderPW) && !empty($HeaderPW))
|
||||
{
|
||||
if ($HeaderPW != $GLOBALS['phpgw_info']['server']['header_admin_password'] && $auth_type == 'Header')
|
||||
{
|
||||
setcookie('HeaderPW',''); /* scrub the old one */
|
||||
$GLOBALS['phpgw_info']['setup']['HeaderLoginMSG'] = 'Invalid session cookie (cookies must be enabled)';
|
||||
$GLOBALS['phpgw_info']['setup']['ConfigLoginMSG'] = '';
|
||||
return False;
|
||||
}
|
||||
else
|
||||
{
|
||||
return True;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return False;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
@function isinarray
|
||||
@abstract php3/4 compliant in_array()
|
||||
@param $needle String to search for
|
||||
@param $haystack Array to search
|
||||
*/
|
||||
function isinarray($needle,$haystack='')
|
||||
{
|
||||
if($haystack == '')
|
||||
{
|
||||
settype($haystack,'array');
|
||||
$haystack = Array();
|
||||
}
|
||||
for($i=0;$i<count($haystack) && $haystack[$i] !=$needle;$i++);
|
||||
return ($i!=count($haystack));
|
||||
}
|
||||
|
||||
/*!
|
||||
@function get_major
|
||||
@abstract Return X.X.X major version from X.X.X.X versionstring
|
||||
@param $
|
||||
*/
|
||||
function get_major($versionstring)
|
||||
{
|
||||
if (!$versionstring)
|
||||
{
|
||||
return False;
|
||||
}
|
||||
|
||||
$version = ereg_replace('pre','.',$versionstring);
|
||||
$varray = explode('.',$version);
|
||||
$major = implode('.',array($varray[0],$varray[1],$varray[2]));
|
||||
|
||||
return $major;
|
||||
}
|
||||
|
||||
/*!
|
||||
@function clear_session_cache
|
||||
@abstract Clear system/user level cache so as to have it rebuilt with the next access
|
||||
@param None
|
||||
*/
|
||||
function clear_session_cache()
|
||||
{
|
||||
$tablenames = @$this->db->table_names();
|
||||
while(list($key,$val) = @each($tablenames))
|
||||
{
|
||||
$tables[] = $val['table_name'];
|
||||
}
|
||||
if ($this->isinarray('phpgw_app_sessions',$tables))
|
||||
{
|
||||
$this->db->lock(array('phpgw_app_sessions'));
|
||||
@$this->db->query("DELETE FROM phpgw_app_sessions WHERE sessionid = '0' and loginid = '0' and app = 'phpgwapi' and location = 'config'",__LINE__,__FILE__);
|
||||
@$this->db->query("DELETE FROM phpgw_app_sessions WHERE app = 'phpgwapi' and location = 'phpgw_info_cache'",__LINE__,__FILE__);
|
||||
$this->db->unlock();
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
@function register_app
|
||||
@abstract Add an application to the phpgw_applications table
|
||||
@param $appname Application 'name' with a matching $setup_info[$appname] array slice
|
||||
@param $enable optional, set to True/False to override setup.inc.php setting
|
||||
*/
|
||||
function register_app($appname,$enable=99)
|
||||
{
|
||||
$setup_info = $GLOBALS['setup_info'];
|
||||
|
||||
if(!$appname)
|
||||
{
|
||||
return False;
|
||||
}
|
||||
|
||||
if ($enable==99)
|
||||
{
|
||||
$enable = $setup_info[$appname]['enable'];
|
||||
}
|
||||
$enable = intval($enable);
|
||||
|
||||
/*
|
||||
Use old applications table if the currentver is less than 0.9.10pre8,
|
||||
but not if the currentver = '', which probably means new install.
|
||||
*/
|
||||
if ($this->alessthanb($setup_info['phpgwapi']['currentver'],'0.9.10pre8') && ($setup_info['phpgwapi']['currentver'] != ''))
|
||||
{
|
||||
$appstbl = 'applications';
|
||||
}
|
||||
else
|
||||
{
|
||||
$appstbl = 'phpgw_applications';
|
||||
if($this->amorethanb($setup_info['phpgwapi']['currentver'],'0.9.13.014'))
|
||||
{
|
||||
$use_appid = True;
|
||||
}
|
||||
}
|
||||
|
||||
if($GLOBALS['DEBUG'])
|
||||
{
|
||||
echo '<br>register_app(): ' . $appname . ', version: ' . $setup_info[$appname]['version'] . ', table: ' . $appstbl . '<br>';
|
||||
// _debug_array($setup_info[$appname]);
|
||||
}
|
||||
|
||||
if ($setup_info[$appname]['version'])
|
||||
{
|
||||
if ($setup_info[$appname]['tables'])
|
||||
{
|
||||
$tables = implode(',',$setup_info[$appname]['tables']);
|
||||
}
|
||||
if($use_appid)
|
||||
{
|
||||
$this->db->query("SELECT MAX(app_id) FROM $appstbl");
|
||||
$this->db->next_record();
|
||||
if($this->db->f(0))
|
||||
{
|
||||
$app_id = ($this->db->f(0) + 1) . ',';
|
||||
$app_idstr = 'app_id,';
|
||||
}
|
||||
else
|
||||
{
|
||||
srand(100000);
|
||||
$app_id = rand(1,100000) . ',';
|
||||
$app_idstr = 'app_id,';
|
||||
}
|
||||
}
|
||||
$this->db->query("INSERT INTO $appstbl "
|
||||
. "($app_idstr app_name,app_title,app_enabled,app_order,app_tables,app_version) "
|
||||
. "VALUES ("
|
||||
. $app_id
|
||||
. "'" . $setup_info[$appname]['name'] . "',"
|
||||
. "'" . $setup_info[$appname]['title'] . "',"
|
||||
. $enable . ","
|
||||
. intval($setup_info[$appname]['app_order']) . ","
|
||||
. "'" . $tables . "',"
|
||||
. "'" . $setup_info[$appname]['version'] . "');"
|
||||
);
|
||||
$this->clear_session_cache();
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
@function app_registered
|
||||
@abstract Check if an application has info in the db
|
||||
@param $appname Application 'name' with a matching $setup_info[$appname] array slice
|
||||
@param $enabled optional, set to False to not enable this app
|
||||
*/
|
||||
function app_registered($appname)
|
||||
{
|
||||
$setup_info = $GLOBALS['setup_info'];
|
||||
|
||||
if(!$appname)
|
||||
{
|
||||
return False;
|
||||
}
|
||||
|
||||
if ($this->alessthanb($setup_info['phpgwapi']['currentver'],'0.9.10pre8') && ($setup_info['phpgwapi']['currentver'] != ''))
|
||||
{
|
||||
$appstbl = 'applications';
|
||||
}
|
||||
else
|
||||
{
|
||||
$appstbl = 'phpgw_applications';
|
||||
}
|
||||
|
||||
if(@$GLOBALS['DEBUG'])
|
||||
{
|
||||
echo '<br>app_registered(): checking ' . $appname . ', table: ' . $appstbl;
|
||||
// _debug_array($setup_info[$appname]);
|
||||
}
|
||||
|
||||
$this->db->query("SELECT COUNT(app_name) FROM $appstbl WHERE app_name='".$appname."'");
|
||||
$this->db->next_record();
|
||||
if ($this->db->f(0))
|
||||
{
|
||||
if(@$GLOBALS['DEBUG'])
|
||||
{
|
||||
echo '... app previously registered.';
|
||||
}
|
||||
return True;
|
||||
}
|
||||
if(@$GLOBALS['DEBUG'])
|
||||
{
|
||||
echo '... app not registered';
|
||||
}
|
||||
return False;
|
||||
}
|
||||
|
||||
/*!
|
||||
@function update_app
|
||||
@abstract Update application info in the db
|
||||
@param $appname Application 'name' with a matching $setup_info[$appname] array slice
|
||||
@param $enabled optional, set to False to not enable this app
|
||||
*/
|
||||
function update_app($appname)
|
||||
{
|
||||
$setup_info = $GLOBALS['setup_info'];
|
||||
|
||||
if(!$appname)
|
||||
{
|
||||
return False;
|
||||
}
|
||||
|
||||
if ($this->alessthanb($setup_info['phpgwapi']['currentver'],'0.9.10pre8') && ($setup_info['phpgwapi']['currentver'] != ''))
|
||||
{
|
||||
$appstbl = 'applications';
|
||||
}
|
||||
else
|
||||
{
|
||||
$appstbl = 'phpgw_applications';
|
||||
}
|
||||
|
||||
if($GLOBALS['DEBUG'])
|
||||
{
|
||||
echo '<br>update_app(): ' . $appname . ', version: ' . $setup_info[$appname]['currentver'] . ', table: ' . $appstbl . '<br>';
|
||||
// _debug_array($setup_info[$appname]);
|
||||
}
|
||||
|
||||
$this->db->query("SELECT COUNT(app_name) FROM $appstbl WHERE app_name='".$appname."'");
|
||||
$this->db->next_record();
|
||||
if (!$this->db->f(0))
|
||||
{
|
||||
return False;
|
||||
}
|
||||
|
||||
if ($setup_info[$appname]['version'])
|
||||
{
|
||||
//echo '<br>' . $setup_info[$appname]['version'];
|
||||
if ($setup_info[$appname]['tables'])
|
||||
{
|
||||
$tables = implode(',',$setup_info[$appname]['tables']);
|
||||
}
|
||||
|
||||
$sql = "UPDATE $appstbl "
|
||||
. "SET app_name='" . $setup_info[$appname]['name'] . "',"
|
||||
. " app_title='" . $setup_info[$appname]['title'] . "',"
|
||||
. " app_enabled=" . intval($setup_info[$appname]['enable']) . ","
|
||||
. " app_order=" . intval($setup_info[$appname]['app_order']) . ","
|
||||
. " app_tables='" . $tables . "',"
|
||||
. " app_version='" . $setup_info[$appname]['version'] . "'"
|
||||
. " WHERE app_name='" . $appname . "'";
|
||||
//echo $sql; exit;
|
||||
|
||||
$this->db->query($sql);
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
@function update_app_version
|
||||
@abstract Update application version in applications table, post upgrade
|
||||
@param $setup_info Array of application information (multiple apps or single)
|
||||
@param $appname Application 'name' with a matching $setup_info[$appname] array slice
|
||||
@param $tableschanged ???
|
||||
*/
|
||||
function update_app_version($setup_info, $appname, $tableschanged = True)
|
||||
{
|
||||
if(!$appname)
|
||||
{
|
||||
return False;
|
||||
}
|
||||
|
||||
if ($this->alessthanb($setup_info['phpgwapi']['currentver'],'0.9.10pre8') && ($setup_info['phpgwapi']['currentver'] != ''))
|
||||
{
|
||||
$appstbl = 'applications';
|
||||
}
|
||||
else
|
||||
{
|
||||
$appstbl = 'phpgw_applications';
|
||||
}
|
||||
|
||||
if ($tableschanged == True)
|
||||
{
|
||||
$GLOBALS['phpgw_info']['setup']['tableschanged'] = True;
|
||||
}
|
||||
if ($setup_info[$appname]['currentver'])
|
||||
{
|
||||
$this->db->query("UPDATE $appstbl SET app_version='" . $setup_info[$appname]['currentver'] . "' WHERE app_name='".$appname."'");
|
||||
}
|
||||
return $setup_info;
|
||||
}
|
||||
|
||||
/*!
|
||||
@function deregister_app
|
||||
@abstract de-Register an application
|
||||
@param $appname Application 'name' with a matching $setup_info[$appname] array slice
|
||||
*/
|
||||
function deregister_app($appname)
|
||||
{
|
||||
if(!$appname)
|
||||
{
|
||||
return False;
|
||||
}
|
||||
$setup_info = $GLOBALS['setup_info'];
|
||||
|
||||
if ($this->alessthanb($setup_info['phpgwapi']['currentver'],'0.9.10pre8') && ($setup_info['phpgwapi']['currentver'] != ''))
|
||||
{
|
||||
$appstbl = 'applications';
|
||||
}
|
||||
else
|
||||
{
|
||||
$appstbl = 'phpgw_applications';
|
||||
}
|
||||
|
||||
//echo 'DELETING application: ' . $appname;
|
||||
$this->db->query("DELETE FROM $appstbl WHERE app_name='". $appname ."'");
|
||||
$this->clear_session_cache();
|
||||
}
|
||||
|
||||
/*!
|
||||
@function register_hooks
|
||||
@abstract Register an application's hooks
|
||||
@param $appname Application 'name' with a matching $setup_info[$appname] array slice
|
||||
*/
|
||||
function register_hooks($appname)
|
||||
{
|
||||
$setup_info = $GLOBALS['setup_info'];
|
||||
|
||||
if(!$appname)
|
||||
{
|
||||
return False;
|
||||
}
|
||||
|
||||
if ($this->alessthanb($setup_info['phpgwapi']['currentver'],'0.9.8pre5') && ($setup_info['phpgwapi']['currentver'] != ''))
|
||||
{
|
||||
/* No phpgw_hooks table yet. */
|
||||
return False;
|
||||
}
|
||||
|
||||
$this->db->query("SELECT COUNT(hook_appname) FROM phpgw_hooks WHERE hook_appname='".$appname."'");
|
||||
$this->db->next_record();
|
||||
if ($this->db->f(0))
|
||||
{
|
||||
$this->deregister_hooks($appname);
|
||||
}
|
||||
|
||||
//echo "ADDING hooks for: " . $setup_info[$appname]['name'];
|
||||
if (is_array($setup_info[$appname]['hooks']))
|
||||
{
|
||||
while (list($key,$hook) = each($setup_info[$appname]['hooks']))
|
||||
{
|
||||
$this->db->query("INSERT INTO phpgw_hooks "
|
||||
. "(hook_appname,hook_location,hook_filename) "
|
||||
. "VALUES ("
|
||||
. "'" . $setup_info[$appname]['name'] . "',"
|
||||
. "'" . $hook . "',"
|
||||
. "'" . "hook_" . $hook . ".inc.php" . "');"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
@function update_hooks
|
||||
@abstract Update an application's hooks
|
||||
@param $appname Application 'name' with a matching $setup_info[$appname] array slice
|
||||
*/
|
||||
function update_hooks($appname)
|
||||
{
|
||||
$setup_info = $GLOBALS['setup_info'];
|
||||
|
||||
if(!$appname)
|
||||
{
|
||||
return False;
|
||||
}
|
||||
|
||||
if ($this->alessthanb($setup_info['phpgwapi']['currentver'],'0.9.8pre5'))
|
||||
{
|
||||
/* No phpgw_hooks table yet. */
|
||||
return False;
|
||||
}
|
||||
|
||||
$this->db->query("SELECT COUNT(*) FROM phpgw_hooks WHERE hook_appname='".$appname."'");
|
||||
$this->db->next_record();
|
||||
if (!$this->db->f(0))
|
||||
{
|
||||
return False;
|
||||
}
|
||||
|
||||
if ($setup_info[$appname]['version'])
|
||||
{
|
||||
if (is_array($setup_info[$appname]['hooks']))
|
||||
{
|
||||
$this->deregister_hooks($appname);
|
||||
$this->register_hooks($appname);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
@function deregister_hooks
|
||||
@abstract de-Register an application's hooks
|
||||
@param $appname Application 'name' with a matching $setup_info[$appname] array slice
|
||||
*/
|
||||
function deregister_hooks($appname)
|
||||
{
|
||||
if ($this->alessthanb($setup_info['phpgwapi']['currentver'],'0.9.8pre5'))
|
||||
{
|
||||
/* No phpgw_hooks table yet. */
|
||||
return False;
|
||||
}
|
||||
|
||||
if(!$appname)
|
||||
{
|
||||
return False;
|
||||
}
|
||||
|
||||
//echo "DELETING hooks for: " . $setup_info[$appname]['name'];
|
||||
$this->db->query("DELETE FROM phpgw_hooks WHERE hook_appname='". $appname ."'");
|
||||
}
|
||||
|
||||
/*!
|
||||
@function hook
|
||||
@abstract call the hooks for a single application
|
||||
@param $location hook location - required
|
||||
@param $appname application name - optional
|
||||
*/
|
||||
function hook($location, $appname = '')
|
||||
{
|
||||
if (! $appname)
|
||||
{
|
||||
$appname = $GLOBALS['phpgw_info']['flags']['currentapp'];
|
||||
}
|
||||
$SEP = filesystem_separator();
|
||||
|
||||
$f = PHPGW_SERVER_ROOT . $SEP . $appname . $SEP . 'inc' . $SEP . 'hook_' . $location . '.inc.php';
|
||||
if (file_exists($f))
|
||||
{
|
||||
include($f);
|
||||
return True;
|
||||
}
|
||||
else
|
||||
{
|
||||
return False;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@function alessthanb
|
||||
@abstract phpgw version checking, is param 1 < param 2 in phpgw versionspeak?
|
||||
@param $a phpgw version number to check if less than $b
|
||||
@param $b phpgw version number to check $a against
|
||||
#return True if $a < $b
|
||||
*/
|
||||
function alessthanb($a,$b,$DEBUG=False)
|
||||
{
|
||||
$num = array('1st','2nd','3rd','4th');
|
||||
|
||||
if ($DEBUG)
|
||||
{
|
||||
echo'<br>Input values: '
|
||||
. 'A="'.$a.'", B="'.$b.'"';
|
||||
}
|
||||
$newa = ereg_replace('pre','.',$a);
|
||||
$newb = ereg_replace('pre','.',$b);
|
||||
$testa = explode('.',$newa);
|
||||
if(@$testa[1] == '')
|
||||
{
|
||||
$testa[1] = 0;
|
||||
}
|
||||
if(@$testa[3] == '')
|
||||
{
|
||||
$testa[3] = 0;
|
||||
}
|
||||
$testb = explode('.',$newb);
|
||||
if(@$testb[1] == '')
|
||||
{
|
||||
$testb[1] = 0;
|
||||
}
|
||||
if(@$testb[3] == '')
|
||||
{
|
||||
$testb[3] = 0;
|
||||
}
|
||||
$less = 0;
|
||||
|
||||
for ($i=0;$i<count($testa);$i++)
|
||||
{
|
||||
if ($DEBUG) { echo'<br>Checking if '. intval($testa[$i]) . ' is less than ' . intval($testb[$i]) . ' ...'; }
|
||||
if (intval($testa[$i]) < intval($testb[$i]))
|
||||
{
|
||||
if ($DEBUG) { echo ' yes.'; }
|
||||
$less++;
|
||||
if ($i<3)
|
||||
{
|
||||
/* Ensure that this is definitely smaller */
|
||||
if ($DEBUG) { echo" This is the $num[$i] octet, so A is definitely less than B."; }
|
||||
$less = 5;
|
||||
break;
|
||||
}
|
||||
}
|
||||
elseif(intval($testa[$i]) > intval($testb[$i]))
|
||||
{
|
||||
if ($DEBUG) { echo ' no.'; }
|
||||
$less--;
|
||||
if ($i<2)
|
||||
{
|
||||
/* Ensure that this is definitely greater */
|
||||
if ($DEBUG) { echo" This is the $num[$i] octet, so A is definitely greater than B."; }
|
||||
$less = -5;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($DEBUG) { echo ' no, they are equal.'; }
|
||||
$less = 0;
|
||||
}
|
||||
}
|
||||
if ($DEBUG) { echo '<br>Check value is: "'.$less.'"'; }
|
||||
if ($less>0)
|
||||
{
|
||||
if ($DEBUG) { echo '<br>A is less than B'; }
|
||||
return True;
|
||||
}
|
||||
elseif($less<0)
|
||||
{
|
||||
if ($DEBUG) { echo '<br>A is greater than B'; }
|
||||
return False;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($DEBUG) { echo '<br>A is equal to B'; }
|
||||
return False;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
@function amorethanb
|
||||
@abstract phpgw version checking, is param 1 > param 2 in phpgw versionspeak?
|
||||
@param $a phpgw version number to check if more than $b
|
||||
@param $b phpgw version number to check $a against
|
||||
#return True if $a < $b
|
||||
*/
|
||||
function amorethanb($a,$b,$DEBUG=False)
|
||||
{
|
||||
$num = array('1st','2nd','3rd','4th');
|
||||
|
||||
if ($DEBUG)
|
||||
{
|
||||
echo'<br>Input values: '
|
||||
. 'A="'.$a.'", B="'.$b.'"';
|
||||
}
|
||||
$newa = ereg_replace('pre','.',$a);
|
||||
$newb = ereg_replace('pre','.',$b);
|
||||
$testa = explode('.',$newa);
|
||||
if($testa[3] == '')
|
||||
{
|
||||
$testa[3] = 0;
|
||||
}
|
||||
$testb = explode('.',$newb);
|
||||
if($testb[3] == '')
|
||||
{
|
||||
$testb[3] = 0;
|
||||
}
|
||||
$less = 0;
|
||||
|
||||
for ($i=0;$i<count($testa);$i++)
|
||||
{
|
||||
if ($DEBUG) { echo'<br>Checking if '. intval($testa[$i]) . ' is more than ' . intval($testb[$i]) . ' ...'; }
|
||||
if (intval($testa[$i]) > intval($testb[$i]))
|
||||
{
|
||||
if ($DEBUG) { echo ' yes.'; }
|
||||
$less++;
|
||||
if ($i<3)
|
||||
{
|
||||
/* Ensure that this is definitely greater */
|
||||
if ($DEBUG) { echo" This is the $num[$i] octet, so A is definitely greater than B."; }
|
||||
$less = 5;
|
||||
break;
|
||||
}
|
||||
}
|
||||
elseif(intval($testa[$i]) < intval($testb[$i]))
|
||||
{
|
||||
if ($DEBUG) { echo ' no.'; }
|
||||
$less--;
|
||||
if ($i<2)
|
||||
{
|
||||
/* Ensure that this is definitely smaller */
|
||||
if ($DEBUG) { echo" This is the $num[$i] octet, so A is definitely less than B."; }
|
||||
$less = -5;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($DEBUG) { echo ' no, they are equal.'; }
|
||||
$less = 0;
|
||||
}
|
||||
}
|
||||
if ($DEBUG) { echo '<br>Check value is: "'.$less.'"'; }
|
||||
if ($less>0)
|
||||
{
|
||||
if ($DEBUG) { echo '<br>A is greater than B'; }
|
||||
return True;
|
||||
}
|
||||
elseif($less<0)
|
||||
{
|
||||
if ($DEBUG) { echo '<br>A is less than B'; }
|
||||
return False;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($DEBUG) { echo '<br>A is equal to B'; }
|
||||
return False;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,442 +0,0 @@
|
||||
<?php
|
||||
/**************************************************************************\
|
||||
* phpGroupWare - Setup *
|
||||
* http://www.phpgroupware.org *
|
||||
* -------------------------------------------- *
|
||||
* This file written by Dan Kuykendall<seek3r@phpgroupware.org> *
|
||||
* and Miles Lott<milosch@phpgroupware.org> *
|
||||
* -------------------------------------------- *
|
||||
* 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$ */
|
||||
|
||||
class phpgw_setup_detection
|
||||
{
|
||||
var $db;
|
||||
var $oProc;
|
||||
var $tables;
|
||||
|
||||
function get_versions()
|
||||
{
|
||||
$d = dir(PHPGW_SERVER_ROOT);
|
||||
while($entry=$d->read())
|
||||
{
|
||||
if (!ereg('setup',$entry) && is_dir(PHPGW_SERVER_ROOT.'/'.$entry))
|
||||
{
|
||||
$f = PHPGW_SERVER_ROOT . '/' . $entry . '/setup/setup.inc.php';
|
||||
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='')
|
||||
{
|
||||
$this->db->Halt_On_Error = 'no';
|
||||
$tables = $this->db->table_names();
|
||||
while(list($key,$val) = @each($tables))
|
||||
{
|
||||
$tname[] = $val['table_name'];
|
||||
}
|
||||
$newapps = $this->isinarray('phpgw_applications',$tname);
|
||||
$oldapps = $this->isinarray('applications',$tname);
|
||||
|
||||
if ( ( is_array($tables) ) && ( count($tables) > 0 ) && ( $newapps || $oldapps ) )
|
||||
{
|
||||
/* one of these tables exists. checking for post/pre beta version */
|
||||
if ($newapps)
|
||||
{
|
||||
$this->db->query('select * from phpgw_applications',__LINE__,__FILE__);
|
||||
while (@$this->db->next_record())
|
||||
{
|
||||
$setup_info[$this->db->f('app_name')]['currentver'] = $this->db->f('app_version');
|
||||
$setup_info[$this->db->f('app_name')]['enabled'] = $this->db->f('app_enabled');
|
||||
}
|
||||
/* This is to catch old setup installs that did not have phpgwapi listed as an app */
|
||||
$tmp = $setup_info['phpgwapi']['version']; /* save the file version */
|
||||
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;
|
||||
// There seems to be a problem here. If ['phpgwapi']['currentver'] is set,
|
||||
// The GLOBALS never gets set.
|
||||
$GLOBALS['setup_info'] = $setup_info;
|
||||
$this->register_app('phpgwapi');
|
||||
}
|
||||
else
|
||||
{
|
||||
$GLOBALS['setup_info'] = $setup_info;
|
||||
}
|
||||
$setup_info['phpgwapi']['version'] = $tmp; /* restore the file version */
|
||||
}
|
||||
elseif ($oldapps)
|
||||
{
|
||||
$this->db->query('select * from applications');
|
||||
while (@$this->db->next_record())
|
||||
{
|
||||
if ($this->db->f('app_name') == 'admin')
|
||||
{
|
||||
$setup_info['phpgwapi']['currentver'] = $this->db->f('app_version');
|
||||
}
|
||||
$setup_info[$this->db->f('app_name')]['currentver'] = $this->db->f('app_version');
|
||||
}
|
||||
}
|
||||
}
|
||||
// _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)
|
||||
{
|
||||
reset ($setup_info);
|
||||
while (list ($key, $value) = each ($setup_info))
|
||||
{
|
||||
//echo '<br>'.$setup_info[$key]['name'].'STATUS: '.$setup_info[$key]['status'];
|
||||
/* Only set this if it has not already failed to upgrade - Milosch */
|
||||
if (!( (@$setup_info[$key]['status'] == 'F') || (@$setup_info[$key]['status'] == 'C') ))
|
||||
{
|
||||
//if ($setup_info[$key]['currentver'] > $setup_info[$key]['version'])
|
||||
if ($this->amorethanb($setup_info[$key]['currentver'],@$setup_info[$key]['version']))
|
||||
{
|
||||
$setup_info[$key]['status'] = 'V';
|
||||
}
|
||||
elseif (@$setup_info[$key]['currentver'] == @$setup_info[$key]['version'])
|
||||
{
|
||||
$setup_info[$key]['status'] = 'C';
|
||||
}
|
||||
elseif ($this->alessthanb(@$setup_info[$key]['currentver'],@$setup_info[$key]['version']))
|
||||
{
|
||||
$setup_info[$key]['status'] = 'U';
|
||||
}
|
||||
else
|
||||
{
|
||||
$setup_info[$key]['status'] = 'U';
|
||||
}
|
||||
}
|
||||
}
|
||||
// _debug_array($setup_info);
|
||||
return $setup_info;
|
||||
}
|
||||
|
||||
function check_depends($setup_info)
|
||||
{
|
||||
reset ($setup_info);
|
||||
/* Run the list of apps */
|
||||
while (list ($key, $value) = each ($setup_info))
|
||||
{
|
||||
/* Does this app have any depends */
|
||||
if (isset($value['depends']))
|
||||
{
|
||||
/* If so find out which apps it depends on */
|
||||
while (list ($depkey, $depvalue) = each ($value['depends']))
|
||||
{
|
||||
/* 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 */
|
||||
while (list ($depskey, $depsvalue) = each ($value['depends'][$depkey]['versions']))
|
||||
{
|
||||
$major = $this->get_major($setup_info[$value['depends'][$depkey]['appname']]['currentver']);
|
||||
if ($major == $depsvalue)
|
||||
{
|
||||
$setup_info['depends'][$depkey]['status'] = True;
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
reset ($value['depends']);
|
||||
while (list ($depkey, $depvalue) = each ($value['depends']))
|
||||
{
|
||||
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')
|
||||
{
|
||||
if($setup_info[$key]['status'] == 'C')
|
||||
{
|
||||
$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)
|
||||
{
|
||||
@reset ($setup_info);
|
||||
while(list($key,$value) = @each($setup_info))
|
||||
{
|
||||
if(isset($value['no_mass_update']))
|
||||
{
|
||||
unset($setup_info[$key]);
|
||||
}
|
||||
}
|
||||
return $setup_info;
|
||||
}
|
||||
|
||||
function check_header()
|
||||
{
|
||||
if(!file_exists('../header.inc.php'))
|
||||
{
|
||||
$GLOBALS['phpgw_info']['setup']['header_msg'] = 'Stage One';
|
||||
return '1';
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!isset($GLOBALS['phpgw_info']['server']['header_admin_password']))
|
||||
{
|
||||
$GLOBALS['phpgw_info']['setup']['header_msg'] = 'Stage One (No header admin password set)';
|
||||
return '2';
|
||||
}
|
||||
elseif (!isset($GLOBALS['phpgw_domain']))
|
||||
{
|
||||
$GLOBALS['phpgw_info']['setup']['header_msg'] = 'Stage One (Upgrade your header.inc.php)';
|
||||
return '3';
|
||||
}
|
||||
elseif ($GLOBALS['phpgw_info']['server']['versions']['header'] != $GLOBALS['phpgw_info']['server']['versions']['current_header'])
|
||||
{
|
||||
$GLOBALS['phpgw_info']['setup']['header_msg'] = 'Stage One (Upgrade your header.inc.php)';
|
||||
return '3';
|
||||
}
|
||||
}
|
||||
/* header.inc.php part settled. Moving to authentication */
|
||||
$GLOBALS['phpgw_info']['setup']['header_msg'] = 'Stage One (Completed)';
|
||||
return '10';
|
||||
}
|
||||
|
||||
function check_db()
|
||||
{
|
||||
$setup_info = $GLOBALS['setup_info'];
|
||||
|
||||
$this->db->Halt_On_Error = 'no';
|
||||
// _debug_array($setup_info);
|
||||
|
||||
if (!isset($setup_info['phpgwapi']['currentver']))
|
||||
{
|
||||
$setup_info = $this->get_db_versions($setup_info);
|
||||
}
|
||||
// _debug_array($setup_info);
|
||||
if (isset($setup_info['phpgwapi']['currentver']))
|
||||
{
|
||||
if ($setup_info['phpgwapi']['currentver'] == $setup_info['phpgwapi']['version'])
|
||||
{
|
||||
$GLOBALS['phpgw_info']['setup']['header_msg'] = 'Stage 1 (Tables Complete)';
|
||||
return 10;
|
||||
}
|
||||
else
|
||||
{
|
||||
$GLOBALS['phpgw_info']['setup']['header_msg'] = 'Stage 1 (Tables need upgrading)';
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* no tables, so checking if we can create them */
|
||||
$this->db->query('CREATE TABLE phpgw_testrights ( testfield varchar(5) NOT NULL )');
|
||||
if (! $this->db->Errno)
|
||||
{
|
||||
$this->db->query('DROP TABLE phpgw_testrights');
|
||||
$GLOBALS['phpgw_info']['setup']['header_msg'] = 'Stage 3 (Install Applications)';
|
||||
return 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
$GLOBALS['phpgw_info']['setup']['header_msg'] = 'Stage 1 (Create Database)';
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function check_config()
|
||||
{
|
||||
$this->db->Halt_On_Error = 'no';
|
||||
if ($GLOBALS['phpgw_info']['setup']['stage']['db'] != 10)
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
/* Since 0.9.10pre6 config table is named as phpgw_config */
|
||||
$config_table = 'config';
|
||||
$ver = explode('.',$GLOBALS['phpgw_info']['server']['versions']['phpgwapi']);
|
||||
|
||||
if(ereg("([0-9]+)(pre)([0-9]+)",$ver[2],$regs))
|
||||
{
|
||||
if(($regs[1] == '10') && ($regs[3] >= '6'))
|
||||
{
|
||||
$config_table = 'phpgw_config';
|
||||
}
|
||||
}
|
||||
|
||||
@$this->db->query("select config_value from $config_table where config_name='freshinstall'");
|
||||
$this->db->next_record();
|
||||
$configed = $this->db->f('config_value');
|
||||
if ($configed)
|
||||
{
|
||||
$GLOBALS['phpgw_info']['setup']['header_msg'] = 'Stage 2 (Needs Configuration)';
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$GLOBALS['phpgw_info']['setup']['header_msg'] = 'Stage 2 (Configuration OK)';
|
||||
return 10;
|
||||
}
|
||||
}
|
||||
|
||||
function check_lang()
|
||||
{
|
||||
$this->db->Halt_On_Error = 'no';
|
||||
if($GLOBALS['phpgw_info']['setup']['stage']['db'] != 10)
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
if($this->alessthanb($GLOBALS['setup_info']['phpgwapi']['currentver'], '0.9.15.002'))
|
||||
{
|
||||
$langtbl = 'lang';
|
||||
$langstbl = 'languages';
|
||||
}
|
||||
else
|
||||
{
|
||||
$langtbl = 'phpgw_lang';
|
||||
$langstbl = 'phpgw_languages';
|
||||
}
|
||||
|
||||
$this->db->query("SELECT DISTINCT lang FROM $langtbl",__LINE__,__FILE__);
|
||||
if ($this->db->num_rows() == 0)
|
||||
{
|
||||
$GLOBALS['phpgw_info']['setup']['header_msg'] = 'Stage 3 (No languages installed)';
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
while(@$this->db->next_record())
|
||||
{
|
||||
$GLOBALS['phpgw_info']['setup']['installed_langs'][$this->db->f('lang')] = $this->db->f('lang');
|
||||
}
|
||||
reset($GLOBALS['phpgw_info']['setup']['installed_langs']);
|
||||
while(list($key, $value) = each($GLOBALS['phpgw_info']['setup']['installed_langs']))
|
||||
{
|
||||
$sql = "SELECT lang_name FROM $langstbl WHERE lang_id = '".$value."';";
|
||||
$this->db->query($sql);
|
||||
$this->db->next_record();
|
||||
$GLOBALS['phpgw_info']['setup']['installed_langs'][$value] = $this->db->f('lang_name');
|
||||
}
|
||||
$GLOBALS['phpgw_info']['setup']['header_msg'] = 'Stage 3 (Completed)';
|
||||
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;
|
||||
$this->db->Halt_On_Error = 'no';
|
||||
$tablenames = $this->db->table_names();
|
||||
while(list($key,$val) = @each($tablenames))
|
||||
{
|
||||
$tables[] = $val['table_name'];
|
||||
}
|
||||
while(list($key,$val) = @each($copy[$appname]['tables']))
|
||||
{
|
||||
if ($GLOBALS['DEBUG'])
|
||||
{
|
||||
echo '<br>check_app_tables(): Checking: ' . $appname . ',table: ' . $val;
|
||||
}
|
||||
if(!$this->isinarray($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;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,209 +0,0 @@
|
||||
<?php
|
||||
/**************************************************************************\
|
||||
* phpGroupWare - Setup *
|
||||
* http://www.phpgroupware.org *
|
||||
* -------------------------------------------- *
|
||||
* This file written by Tony Puglisi (Angles) <angles@phpgroupware.org> *
|
||||
* and Miles Lott<milosch@phpgroupware.org> *
|
||||
* -------------------------------------------- *
|
||||
* 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$ */
|
||||
|
||||
class phpgw_setup_html extends phpgw_setup_lang
|
||||
{
|
||||
/*!
|
||||
@function generate_header
|
||||
@abstract generate header.inc.php file output - NOT a generic html header function
|
||||
*/
|
||||
function generate_header()
|
||||
{
|
||||
$setting = $GLOBALS['HTTP_POST_VARS']['setting'];
|
||||
|
||||
$GLOBALS['header_template']->set_file(array('header' => 'header.inc.php.template'));
|
||||
$var = Array();
|
||||
while(list($k,$v) = @each($setting))
|
||||
{
|
||||
$var[strtoupper($k)] = $v;
|
||||
}
|
||||
$GLOBALS['header_template']->set_var($var);
|
||||
return $GLOBALS['header_template']->parse('out','header');
|
||||
}
|
||||
|
||||
function setup_tpl_dir($app_name='setup')
|
||||
{
|
||||
/* hack to get tpl dir */
|
||||
if (is_dir(PHPGW_SERVER_ROOT))
|
||||
{
|
||||
$srv_root = PHPGW_SERVER_ROOT . SEP . "$app_name" . SEP;
|
||||
}
|
||||
else
|
||||
{
|
||||
$srv_root = '';
|
||||
}
|
||||
|
||||
$tpl_typical = 'templates' . SEP . 'default';
|
||||
$tpl_root = "$srv_root" ."$tpl_typical";
|
||||
return $tpl_root;
|
||||
}
|
||||
|
||||
function show_header($title = '',$nologoutbutton = False, $logoutfrom = 'config', $configdomain = '')
|
||||
{
|
||||
$GLOBALS['setup_tpl']->set_var('lang_charset',lang('charset'));
|
||||
if ($nologoutbutton)
|
||||
{
|
||||
$btn_logout = ' ';
|
||||
}
|
||||
else
|
||||
{
|
||||
$btn_logout = '<a href="index.php?FormLogout=' . $logoutfrom . '" class="link">'.lang('Logout').'</a>';
|
||||
}
|
||||
|
||||
$GLOBALS['setup_tpl']->set_var('lang_setup', lang('setup'));
|
||||
$GLOBALS['setup_tpl']->set_var('page_title',$title);
|
||||
if ($configdomain == '')
|
||||
{
|
||||
$GLOBALS['setup_tpl']->set_var('configdomain','');
|
||||
}
|
||||
else
|
||||
{
|
||||
$GLOBALS['setup_tpl']->set_var('configdomain',' - ' . lang('Domain') . ': '.$configdomain);
|
||||
}
|
||||
$GLOBALS['setup_tpl']->set_var('pgw_ver',$GLOBALS['phpgw_info']['server']['versions']['phpgwapi']);
|
||||
$GLOBALS['setup_tpl']->set_var('logoutbutton',$btn_logout);
|
||||
$GLOBALS['setup_tpl']->pparse('out','T_head');
|
||||
/* $setup_tpl->set_var('T_head',''); */
|
||||
}
|
||||
|
||||
function show_footer()
|
||||
{
|
||||
$GLOBALS['setup_tpl']->pparse('out','T_footer');
|
||||
unset($GLOBALS['setup_tpl']);
|
||||
}
|
||||
|
||||
function show_alert_msg($alert_word='Setup alert',$alert_msg='setup alert (generic)')
|
||||
{
|
||||
$GLOBALS['setup_tpl']->set_var('V_alert_word',$alert_word);
|
||||
$GLOBALS['setup_tpl']->set_var('V_alert_msg',$alert_msg);
|
||||
$GLOBALS['setup_tpl']->pparse('out','T_alert_msg');
|
||||
}
|
||||
|
||||
function make_frm_btn_simple($pre_frm_blurb='',$frm_method='POST',$frm_action='',$input_type='submit',$input_value='',$post_frm_blurb='')
|
||||
{
|
||||
/* a simple form has simple components */
|
||||
$simple_form =
|
||||
$pre_frm_blurb ."\n"
|
||||
.'<form method="'.$frm_method.'" action="'.$frm_action.'">' ."\n"
|
||||
.'<input type="'.$input_type.'" value="'.$input_value.'">' ."\n"
|
||||
.'</form>' ."\n"
|
||||
.$post_frm_blurb ."\n";
|
||||
return $simple_form;
|
||||
}
|
||||
|
||||
function make_href_link_simple($pre_link_blurb='',$href_link='',$href_text='default text',$post_link_blurb='')
|
||||
{
|
||||
/* a simple href link has simple components */
|
||||
$simple_link =
|
||||
$pre_link_blurb
|
||||
.'<a href="' .$href_link .'">' .$href_text .'</a> '
|
||||
.$post_link_blurb ."\n";
|
||||
return $simple_link;
|
||||
}
|
||||
|
||||
function login_form()
|
||||
{
|
||||
/* begin use TEMPLATE login_main.tpl */
|
||||
$GLOBALS['setup_tpl']->set_var('ConfigLoginMSG',$GLOBALS['phpgw_info']['setup']['ConfigLoginMSG']);
|
||||
$GLOBALS['setup_tpl']->set_var('HeaderLoginMSG',$GLOBALS['phpgw_info']['setup']['HeaderLoginMSG']);
|
||||
|
||||
if ($GLOBALS['phpgw_info']['setup']['stage']['header'] == '10')
|
||||
{
|
||||
/*
|
||||
Begin use SUB-TEMPLATE login_stage_header,
|
||||
fills V_login_stage_header used inside of login_main.tpl
|
||||
*/
|
||||
$GLOBALS['setup_tpl']->set_var('lang_select',lang_select());
|
||||
if (count($GLOBALS['phpgw_domain']) > 1)
|
||||
{
|
||||
// use BLOCK B_multi_domain inside of login_stage_header
|
||||
$GLOBALS['setup_tpl']->parse('V_multi_domain','B_multi_domain');
|
||||
// in this case, the single domain block needs to be nothing
|
||||
$GLOBALS['setup_tpl']->set_var('V_single_domain','');
|
||||
}
|
||||
else
|
||||
{
|
||||
reset($GLOBALS['phpgw_domain']);
|
||||
$default_domain = each($GLOBALS['phpgw_domain']);
|
||||
$GLOBALS['setup_tpl']->set_var('default_domain_zero',$default_domain[0]);
|
||||
|
||||
/* Use BLOCK B_single_domain inside of login_stage_header */
|
||||
$GLOBALS['setup_tpl']->parse('V_single_domain','B_single_domain');
|
||||
/* in this case, the multi domain block needs to be nothing */
|
||||
$GLOBALS['setup_tpl']->set_var('V_multi_domain','');
|
||||
}
|
||||
/*
|
||||
End use SUB-TEMPLATE login_stage_header
|
||||
put all this into V_login_stage_header for use inside login_main
|
||||
*/
|
||||
$GLOBALS['setup_tpl']->parse('V_login_stage_header','T_login_stage_header');
|
||||
}
|
||||
else
|
||||
{
|
||||
/* begin SKIP SUB-TEMPLATE login_stage_header */
|
||||
$GLOBALS['setup_tpl']->set_var('V_multi_domain','');
|
||||
$GLOBALS['setup_tpl']->set_var('V_single_domain','');
|
||||
$GLOBALS['setup_tpl']->set_var('V_login_stage_header','');
|
||||
}
|
||||
/*
|
||||
end use TEMPLATE login_main.tpl
|
||||
now out the login_main template
|
||||
*/
|
||||
$GLOBALS['setup_tpl']->pparse('out','T_login_main');
|
||||
}
|
||||
|
||||
function get_template_list()
|
||||
{
|
||||
$d = dir(PHPGW_SERVER_ROOT . '/phpgwapi/templates');
|
||||
|
||||
while($entry=$d->read())
|
||||
{
|
||||
if ($entry != 'CVS' && $entry != '.' && $entry != '..')
|
||||
{
|
||||
$list[$entry]['name'] = $entry;
|
||||
$f = PHPGW_SERVER_ROOT . '/phpgwapi/templates/' . $entry . '/details.inc.php';
|
||||
if (file_exists ($f))
|
||||
{
|
||||
include($f);
|
||||
$list[$entry]['title'] = 'Use ' . $GLOBALS['phpgw_info']['template'][$entry]['title'] . 'interface';
|
||||
}
|
||||
else
|
||||
{
|
||||
$list[$entry]['title'] = $entry;
|
||||
}
|
||||
}
|
||||
}
|
||||
$d->close();
|
||||
reset ($list);
|
||||
return $list;
|
||||
}
|
||||
|
||||
function list_themes()
|
||||
{
|
||||
$dh = dir(PHPGW_SERVER_ROOT . '/phpgwapi/themes');
|
||||
while ($file = $dh->read())
|
||||
{
|
||||
if (eregi("\.theme$", $file))
|
||||
{
|
||||
$list[] = substr($file,0,strpos($file,'.'));
|
||||
}
|
||||
}
|
||||
$dh->close();
|
||||
reset ($list);
|
||||
return $list;
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,230 +0,0 @@
|
||||
<?php
|
||||
/**************************************************************************\
|
||||
* phpGroupWare API - Translation class for phpgw lang files *
|
||||
* This file written by Miles Lott <milosch@phpgroupware.org> *
|
||||
* and Dan Kuykendall <seek3r@phpgroupware.org> *
|
||||
* Handles multi-language support using flat files *
|
||||
* -------------------------------------------------------------------------*
|
||||
* This library is part of the phpGroupWare API *
|
||||
* http://www.phpgroupware.org/api *
|
||||
* ------------------------------------------------------------------------ *
|
||||
* This library is free software; you can redistribute it and/or modify it *
|
||||
* under the terms of the GNU Lesser General Public License as published by *
|
||||
* the Free Software Foundation; either version 2.1 of the License, *
|
||||
* or any later version. *
|
||||
* This library 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 Lesser General Public License for more details. *
|
||||
* You should have received a copy of the GNU Lesser General Public License *
|
||||
* along with this library; if not, write to the Free Software Foundation, *
|
||||
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
|
||||
\**************************************************************************/
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
class phpgw_setup_lang extends phpgw_setup_process
|
||||
{
|
||||
var $langarray;
|
||||
var $langtbl = 'phpgw_lang';
|
||||
|
||||
/*!
|
||||
@function setup_lang
|
||||
@abstract constructor for the class, loads all phrases into langarray
|
||||
@param $lang user lang variable (defaults to en)
|
||||
*/
|
||||
function phpgw_setup_lang()
|
||||
{
|
||||
$ConfigLang = @$GLOBALS['HTTP_COOKIE_VARS']['ConfigLang'] ? @$GLOBALS['HTTP_COOKIE_VARS']['ConfigLang'] : @$GLOBALS['HTTP_POST_VARS']['ConfigLang'];
|
||||
|
||||
if($this->alessthanb(@$GLOBALS['setup_info']['phpgwapi']['currentver'], '0.9.15.002'))
|
||||
{
|
||||
$this->langtbl = 'lang';
|
||||
}
|
||||
|
||||
if(!$ConfigLang)
|
||||
{
|
||||
$lang = 'en';
|
||||
}
|
||||
else
|
||||
{
|
||||
$lang = $ConfigLang;
|
||||
}
|
||||
|
||||
$fn = '.' . SEP . 'lang' . SEP . 'phpgw_' . $lang . '.lang';
|
||||
if (!file_exists($fn))
|
||||
{
|
||||
$fn = '.' . SEP . 'lang' . SEP . 'phpgw_en.lang';
|
||||
}
|
||||
|
||||
if (file_exists($fn))
|
||||
{
|
||||
$fp = fopen($fn,'r');
|
||||
while ($data = fgets($fp,8000))
|
||||
{
|
||||
list($message_id,$app_name,$null,$content) = explode("\t",$data);
|
||||
if ($app_name == 'setup' || $app_name == 'common' || $app_name == 'all')
|
||||
{
|
||||
$this->langarray[] = array(
|
||||
'message_id' => $message_id,
|
||||
'content' => trim($content)
|
||||
);
|
||||
}
|
||||
}
|
||||
fclose($fp);
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
@function translate
|
||||
@abstract Translate phrase to user selected lang
|
||||
@param $key phrase to translate
|
||||
@param $vars vars sent to lang function, passed to us
|
||||
*/
|
||||
function translate($key, $vars=False)
|
||||
{
|
||||
if (!$vars)
|
||||
{
|
||||
$vars = array();
|
||||
}
|
||||
|
||||
$ret = $key;
|
||||
|
||||
@reset($this->langarray);
|
||||
while(list($null,$data) = @each($this->langarray))
|
||||
{
|
||||
$lang[strtolower($data['message_id'])] = $data['content'];
|
||||
}
|
||||
|
||||
if (isset($lang[strtolower ($key)]) && $lang[strtolower ($key)])
|
||||
{
|
||||
$ret = $lang[strtolower ($key)];
|
||||
}
|
||||
else
|
||||
{
|
||||
$ret = $key.'*';
|
||||
}
|
||||
$ndx = 1;
|
||||
while( list($key,$val) = each( $vars ) )
|
||||
{
|
||||
$ret = preg_replace( "/%$ndx/", $val, $ret );
|
||||
++$ndx;
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/* Following functions are called for app (un)install */
|
||||
|
||||
/*!
|
||||
@function get_langs
|
||||
@abstract return array of installed languages, e.g. array('de','en')
|
||||
*/
|
||||
function get_langs($DEBUG=False)
|
||||
{
|
||||
if($DEBUG)
|
||||
{
|
||||
echo '<br>get_langs(): checking db...' . "\n";
|
||||
}
|
||||
$GLOBALS['phpgw_setup']->db->query("SELECT DISTINCT(lang) FROM $this->langtbl",__LINE__,__FILE__);
|
||||
$langs = array();
|
||||
|
||||
while($GLOBALS['phpgw_setup']->db->next_record())
|
||||
{
|
||||
if($DEBUG)
|
||||
{
|
||||
echo '<br>get_langs(): found ' . $GLOBALS['phpgw_setup']->db->f(0);
|
||||
}
|
||||
$langs[] = $GLOBALS['phpgw_setup']->db->f(0);
|
||||
}
|
||||
return $langs;
|
||||
}
|
||||
|
||||
/*!
|
||||
@function drop_langs
|
||||
@abstract delete all lang entries for an application, return True if langs were found
|
||||
@param $appname app_name whose translations you want to delete
|
||||
*/
|
||||
function drop_langs($appname,$DEBUG=False)
|
||||
{
|
||||
if($DEBUG)
|
||||
{
|
||||
echo '<br>drop_langs(): Working on: ' . $appname;
|
||||
}
|
||||
$GLOBALS['phpgw_setup']->db->query("SELECT COUNT(message_id) FROM $this->langtbl WHERE app_name='$appname'",__LINE__,__FILE__);
|
||||
$GLOBALS['phpgw_setup']->db->next_record();
|
||||
if($GLOBALS['phpgw_setup']->db->f(0))
|
||||
{
|
||||
$GLOBALS['phpgw_setup']->db->query("DELETE FROM $this->langtbl WHERE app_name='$appname'",__LINE__,__FILE__);
|
||||
return True;
|
||||
}
|
||||
return False;
|
||||
}
|
||||
|
||||
/*!
|
||||
@function add_langs
|
||||
@abstract process an application's lang files, calling get_langs() to see what langs the admin installed already
|
||||
@param $appname app_name of application to process
|
||||
*/
|
||||
function add_langs($appname,$DEBUG=False,$force_en=False)
|
||||
{
|
||||
$langs = $this->get_langs($DEBUG);
|
||||
if($force_en && !isinarray('en',$langs))
|
||||
{
|
||||
$langs[] = 'en';
|
||||
}
|
||||
|
||||
if($DEBUG)
|
||||
{
|
||||
echo '<br>add_langs(): chose these langs: ';
|
||||
_debug_array($langs);
|
||||
}
|
||||
|
||||
$GLOBALS['phpgw_setup']->db->transaction_begin();
|
||||
|
||||
while (list($null,$lang) = each($langs))
|
||||
{
|
||||
if($DEBUG)
|
||||
{
|
||||
echo '<br>add_langs(): Working on: ' . $lang . ' for ' . $appname;
|
||||
}
|
||||
$appfile = PHPGW_SERVER_ROOT . SEP . $appname . SEP . 'setup' . SEP . 'phpgw_' . strtolower($lang) . '.lang';
|
||||
if(file_exists($appfile))
|
||||
{
|
||||
if($DEBUG)
|
||||
{
|
||||
echo '<br>add_langs(): Including: ' . $appfile;
|
||||
}
|
||||
$raw_file = file($appfile);
|
||||
|
||||
while (list($null,$line) = @each($raw_file))
|
||||
{
|
||||
list($message_id,$app_name,$GLOBALS['phpgw_setup']->db_lang,$content) = explode("\t",$line);
|
||||
$message_id = $GLOBALS['phpgw_setup']->db->db_addslashes(chop($message_id));
|
||||
/* echo '<br>APPNAME:' . $app_name . ' PHRASE:' . $message_id; */
|
||||
$app_name = $GLOBALS['phpgw_setup']->db->db_addslashes(chop($app_name));
|
||||
$GLOBALS['phpgw_setup']->db_lang = $GLOBALS['phpgw_setup']->db->db_addslashes(chop($GLOBALS['phpgw_setup']->db_lang));
|
||||
$content = $GLOBALS['phpgw_setup']->db->db_addslashes(chop($content));
|
||||
|
||||
$GLOBALS['phpgw_setup']->db->query("SELECT COUNT(*) FROM $this->langtbl WHERE message_id='$message_id' and lang='"
|
||||
. $GLOBALS['phpgw_setup']->db_lang . "'",__LINE__,__FILE__);
|
||||
$GLOBALS['phpgw_setup']->db->next_record();
|
||||
|
||||
if ($GLOBALS['phpgw_setup']->db->f(0) == 0)
|
||||
{
|
||||
if($message_id && $content)
|
||||
{
|
||||
if($DEBUG)
|
||||
{
|
||||
echo "<br>add_langs(): adding - INSERT INTO $this->langtbl VALUES ('$message_id','$app_name','$phpgw_setup->db_lang','$content')";
|
||||
}
|
||||
$GLOBALS['phpgw_setup']->db->query("INSERT INTO $this->langtbl VALUES ('$message_id','$app_name','"
|
||||
. $GLOBALS['phpgw_setup']->db_lang . "','$content')",__LINE__,__FILE__);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$GLOBALS['phpgw_setup']->db->transaction_commit();
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,796 +0,0 @@
|
||||
<?php
|
||||
/**************************************************************************\
|
||||
* phpGroupWare - Setup *
|
||||
* http://www.phpgroupware.org *
|
||||
* -------------------------------------------- *
|
||||
* This file written by Miles Lott<milosch@phpgroupware.org> *
|
||||
* -------------------------------------------- *
|
||||
* 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$ */
|
||||
|
||||
/* app status values:
|
||||
U Upgrade required/available
|
||||
R upgrade in pRogress
|
||||
C upgrade Completed successfully
|
||||
D 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)
|
||||
*/
|
||||
|
||||
class phpgw_setup_process extends phpgw_setup_detection
|
||||
{
|
||||
var $db;
|
||||
var $oProc;
|
||||
var $tables;
|
||||
var $updateincluded = array();
|
||||
|
||||
/*!
|
||||
@function init_process
|
||||
@abstract create schema_proc object
|
||||
@param none
|
||||
*/
|
||||
function init_process()
|
||||
{
|
||||
$ConfigDomain = $GLOBALS['HTTP_COOKIE_VARS']['ConfigDomain'] ? $GLOBALS['HTTP_COOKIE_VARS']['ConfigDomain'] : $GLOBALS['HTTP_POST_VARS']['ConfigDomain'];
|
||||
$phpgw_domain = $GLOBALS['phpgw_domain'];
|
||||
$phpgw_info = $GLOBALS['phpgw_info'];
|
||||
|
||||
$this->oProc = CreateObject('setup.schema_proc',$phpgw_domain[$ConfigDomain]['db_type']);
|
||||
//$this->oProc = CreateObject('setup.schema_proc','pgsql');
|
||||
$this->oProc->m_odb = $this->db;
|
||||
$this->oProc->m_odb->Host = $phpgw_domain[$ConfigDomain]['db_host'];
|
||||
$this->oProc->m_odb->Database = $phpgw_domain[$ConfigDomain]['db_name'];
|
||||
$this->oProc->m_odb->User = $phpgw_domain[$ConfigDomain]['db_user'];
|
||||
$this->oProc->m_odb->Password = $phpgw_domain[$ConfigDomain]['db_pass'];
|
||||
$this->oProc->m_odb->Halt_On_Error = 'report';
|
||||
$this->oProc->m_odb->connect();
|
||||
}
|
||||
|
||||
/*!
|
||||
@function process_pass
|
||||
@abstract the mother of all multipass upgrade parental loop functions
|
||||
@param $setup_info array of application info from setup.inc.php files
|
||||
@param $type optional, defaults to new(install), could also be 'upgrade'
|
||||
@param $DEBUG optional, print debugging info
|
||||
@param $force_en optional, install english language files
|
||||
*/
|
||||
function process_pass($setup_info,$method='new',$DEBUG=False,$force_en=False)
|
||||
{
|
||||
if (!$method)
|
||||
{
|
||||
return False;
|
||||
}
|
||||
// Place api first
|
||||
$pass['phpgwapi'] = $setup_info['phpgwapi'];
|
||||
@reset($setup_info);
|
||||
$setup_info = $this->get_versions($setup_info);
|
||||
@reset($setup_info);
|
||||
|
||||
$i = 1;
|
||||
$passed = array();
|
||||
$passing = array();
|
||||
$pass_string = implode (':', $pass);
|
||||
$passing_string = implode (':', $passing);
|
||||
while ($pass_string != $passing_string)
|
||||
{
|
||||
$passing = array();
|
||||
if ($DEBUG) { echo '<br>process_pass(): #' . $i . ' for ' . $method . ' processing' . "\n"; }
|
||||
/* Check current versions and dependencies */
|
||||
$setup_info = $this->get_db_versions($setup_info);
|
||||
$setup_info = $this->compare_versions($setup_info);
|
||||
//_debug_array($setup_info);exit;
|
||||
$setup_info = $this->check_depends($setup_info);
|
||||
//if($i==2) { _debug_array($passed);exit; }
|
||||
|
||||
/* stuff the rest of the apps, but only those with available upgrades */
|
||||
while(list($key,$value) = @each($setup_info))
|
||||
{
|
||||
if (($value['name'] != 'phpgwapi') && ($value['status'] == 'U'))
|
||||
{
|
||||
if ( ($passed[$value['name']]['status'] != 'F') && ($passed[$value['name']]['status'] != 'C') )
|
||||
{
|
||||
$pass[$value['name']] = $setup_info[$value['name']];
|
||||
}
|
||||
}
|
||||
/*
|
||||
Now if we are on the 2nd or more passes, add api in
|
||||
if (!$pass['phpgwapi'])
|
||||
{
|
||||
$pass['phpgwapi'] = $setup_info['phpgwapi'];
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
switch ($method)
|
||||
{
|
||||
case 'new':
|
||||
/* Create tables and insert new records for each app in this list */
|
||||
$passing = $this->process_current($pass,$DEBUG);
|
||||
$passing = $this->process_default_records($passing,$DEBUG);
|
||||
$passing = $this->process_add_langs($passing,$DEBUG,$force_en);
|
||||
break;
|
||||
case 'upgrade':
|
||||
/* Run upgrade scripts on each app in the list */
|
||||
$passing = $this->process_upgrade($pass,$DEBUG);
|
||||
$passing = $this->process_upgrade_langs($passing,$DEBUG);
|
||||
//_debug_array($pass);exit;
|
||||
break;
|
||||
default:
|
||||
/* What the heck are you doing? */
|
||||
return False;
|
||||
break;
|
||||
}
|
||||
|
||||
$pass = array();
|
||||
@reset($passing);
|
||||
while(list($key,$value) = @each($passing))
|
||||
{
|
||||
if($value['status'] == 'C')
|
||||
{
|
||||
$passed[$value['name']] = $passing[$value['name']];
|
||||
if ($DEBUG) { echo '<br>process_pass(): '.$passed[$value['name']]['name'] . ' install completed'."\n"; }
|
||||
}
|
||||
elseif($value['status'] == 'F')
|
||||
{
|
||||
$setup_info[$value['name']] = $passing[$value['name']];
|
||||
if ($DEBUG) { echo '<br>process_pass(): '.$setup_info[$value['name']]['name'] . ' install failed'."\n"; }
|
||||
}
|
||||
elseif($value['status'] == 'D')
|
||||
{
|
||||
$pass[$value['name']] = $setup_info[$value['name']];
|
||||
if ($DEBUG) { echo '<br>process_pass(): '.$pass[$value['name']]['name'] . ' fails dependency check on this pass'."\n"; }
|
||||
}
|
||||
else
|
||||
{
|
||||
$tmp = $passing[$value['name']]['name'];
|
||||
if ($DEBUG) { echo '<br>process_pass(): '.$tmp . ' skipped on this pass'."\n"; }
|
||||
}
|
||||
}
|
||||
|
||||
$i++;
|
||||
if ($i == 20) /* Then oops it broke */
|
||||
{
|
||||
echo '<br>Setup failure: excess looping in process_pass():'."\n";
|
||||
echo '<br>Pass:<br>'."\n";
|
||||
_debug_array($pass);
|
||||
echo '<br>Passed:<br>'."\n";
|
||||
_debug_array($passed);
|
||||
exit;
|
||||
}
|
||||
$pass_string = implode (':', $pass);
|
||||
$passing_string = implode (':', $passing);
|
||||
}
|
||||
|
||||
/* now return the list */
|
||||
@reset($passed);
|
||||
while(list($key,$value) = @each($passed))
|
||||
{
|
||||
$setup_info[$value['name']] = $passed[$value['name']];
|
||||
}
|
||||
|
||||
return ($setup_info);
|
||||
}
|
||||
|
||||
/*!
|
||||
@function process_droptables
|
||||
@abstract drop tables per application, check that they are in the db first
|
||||
@param $setup_info array of application info from setup.inc.php files, etc.
|
||||
*/
|
||||
function process_droptables($setup_info,$DEBUG=False)
|
||||
{
|
||||
if (!$this->oProc)
|
||||
{
|
||||
$this->init_process();
|
||||
}
|
||||
$this->oProc->m_bDeltaOnly = False;
|
||||
|
||||
/* The following is built so below we won't try to drop a table that isn't there. */
|
||||
$tablenames = $this->db->table_names();
|
||||
while(list($key,$val) = @each($tablenames))
|
||||
{
|
||||
$tables[] = $val['table_name'];
|
||||
}
|
||||
|
||||
@reset($setup_info);
|
||||
while (list($key,$null) = @each($setup_info))
|
||||
{
|
||||
if ($setup_info[$key]['tables'])
|
||||
{
|
||||
while (list($a,$table) = @each($setup_info[$key]['tables']))
|
||||
{
|
||||
//echo $table;
|
||||
if ($this->isinarray($table,$tables))
|
||||
{
|
||||
if ($DEBUG){ echo '<br>process_droptables(): Dropping :'. $setup_info[$key]['name'] . ' table: ' . $table; }
|
||||
$this->oProc->DropTable($table);
|
||||
// Update the array values for return below
|
||||
$setup_info[$key]['status'] = 'U';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Done, return current status */
|
||||
return ($setup_info);
|
||||
}
|
||||
|
||||
/*!
|
||||
@function process_current
|
||||
@abstract process current table setup in each application/setup dir
|
||||
@param $appinfo array of application info from setup.inc.php files, etc.
|
||||
@discussion This duplicates the old newtables behavior, using schema_proc
|
||||
*/
|
||||
function process_current($setup_info,$DEBUG=False)
|
||||
{
|
||||
if (!$this->oProc)
|
||||
{
|
||||
$this->init_process();
|
||||
}
|
||||
$this->oProc->m_bDeltaOnly = False;
|
||||
|
||||
@reset($setup_info);
|
||||
while (list($key,$null) = @each($setup_info))
|
||||
{
|
||||
$enabled = False;
|
||||
$appname = $setup_info[$key]['name'];
|
||||
$apptitle = $setup_info[$key]['title'];
|
||||
|
||||
if($DEBUG) { echo '<br>process_current(): Incoming status: ' . $appname . ',status: '. $setup_info[$key]['status']; }
|
||||
|
||||
$appdir = PHPGW_SERVER_ROOT . SEP . $appname . SEP . 'setup' . SEP;
|
||||
|
||||
if ($setup_info[$key]['tables'] && file_exists($appdir.'tables_current.inc.php'))
|
||||
{
|
||||
if($DEBUG) { echo '<br>process_current(): Including: ' . $appdir.'tables_current.inc.php'; }
|
||||
include ($appdir.'tables_current.inc.php');
|
||||
$ret = $this->post_process($phpgw_baseline,$DEBUG);
|
||||
if($ret)
|
||||
{
|
||||
if ($this->app_registered($appname))
|
||||
{
|
||||
$this->update_app($appname);
|
||||
$this->update_hooks($appname);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->register_app($appname);
|
||||
$this->register_hooks($appname);
|
||||
}
|
||||
// Update the array values for return below
|
||||
$setup_info[$key]['status'] = 'C';
|
||||
}
|
||||
else
|
||||
{
|
||||
/* script processing failed */
|
||||
if($DEBUG) { echo '<br>process_current(): Failed for ' . $appname . ',status: '. $setup_info[$key]['status']; }
|
||||
$setup_info[$key]['status'] = 'F';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if($DEBUG) { echo '<br>process_current(): No current tables for ' . $apptitle . "\n"; }
|
||||
/*
|
||||
Add the app, but disable it if it has tables defined.
|
||||
A manual sql script install is needed, but we do add the hooks
|
||||
*/
|
||||
$enabled = 99;
|
||||
if ($setup_info[$key]['tables'][0] != '')
|
||||
{
|
||||
$enabled = False;
|
||||
}
|
||||
if ($this->app_registered($appname))
|
||||
{
|
||||
$this->update_app($appname);
|
||||
$this->update_hooks($appname);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->register_app($appname,$enabled);
|
||||
$this->register_hooks($appname);
|
||||
}
|
||||
$setup_info[$key]['status'] = 'C';
|
||||
}
|
||||
if($DEBUG) { echo '<br>process_current(): Outgoing status: ' . $appname . ',status: '. $setup_info[$key]['status']; }
|
||||
}
|
||||
|
||||
/* Done, return current status */
|
||||
return ($setup_info);
|
||||
}
|
||||
|
||||
/*!
|
||||
@function process_default_records
|
||||
@abstract process default_records.inc.php in each application/setup dir
|
||||
@param $setup_info array of application info from setup.inc.php files, etc.
|
||||
*/
|
||||
function process_default_records($setup_info,$DEBUG=False)
|
||||
{
|
||||
if (!$this->oProc)
|
||||
{
|
||||
$this->init_process();
|
||||
}
|
||||
$this->oProc->m_bDeltaOnly = False;
|
||||
$oProc = $this->oProc;
|
||||
|
||||
@reset($setup_info);
|
||||
while (list($key,$null) = @each($setup_info))
|
||||
{
|
||||
$appname = $setup_info[$key]['name'];
|
||||
$appdir = PHPGW_SERVER_ROOT . SEP . $appname . SEP . 'setup' . SEP;
|
||||
|
||||
if ($setup_info[$key]['tables'] && file_exists($appdir.'default_records.inc.php'))
|
||||
{
|
||||
if ($DEBUG)
|
||||
{
|
||||
echo '<br>process_default_records(): Including default records for ' . $appname . "\n";
|
||||
}
|
||||
$this->oProc->m_odb->transaction_begin();
|
||||
include ($appdir.'default_records.inc.php');
|
||||
$this->oProc->m_odb->transaction_commit();
|
||||
}
|
||||
/* $setup_info[$key]['status'] = 'C'; */
|
||||
}
|
||||
|
||||
/* Done, return current status */
|
||||
return ($setup_info);
|
||||
}
|
||||
|
||||
/*!
|
||||
@function process_add_langs
|
||||
@abstract process application lang files and uninstall
|
||||
@param $setup_info array of application info from setup.inc.php files, etc.
|
||||
*/
|
||||
function process_add_langs($setup_info,$DEBUG=False,$force_en=False)
|
||||
{
|
||||
@reset($setup_info);
|
||||
while (list($key,$null) = @each($setup_info))
|
||||
{
|
||||
$appname = $setup_info[$key]['name'];
|
||||
/* This is in the setup_lang class */
|
||||
$this->add_langs($appname,$DEBUG,$force_en);
|
||||
if($DEBUG)
|
||||
{
|
||||
echo '<br>process_add_langs(): Translations added for ' . $appname . "\n";
|
||||
}
|
||||
}
|
||||
/* Done, return current status */
|
||||
return ($setup_info);
|
||||
}
|
||||
|
||||
/*!
|
||||
@function process_drop_langs
|
||||
@abstract process application lang files and install
|
||||
@param $setup_info array of application info from setup.inc.php files, etc.
|
||||
*/
|
||||
function process_drop_langs($setup_info,$DEBUG=False)
|
||||
{
|
||||
@reset($setup_info);
|
||||
while (list($key,$null) = @each($setup_info))
|
||||
{
|
||||
$appname = $setup_info[$key]['name'];
|
||||
/* This is in the setup_lang class */
|
||||
$this->drop_langs($appname,$DEBUG);
|
||||
if($DEBUG)
|
||||
{
|
||||
echo '<br>process_drop_langs(): Translations removed for ' . $appname . "\n";
|
||||
}
|
||||
}
|
||||
/* Done, return current status */
|
||||
return ($setup_info);
|
||||
}
|
||||
|
||||
/*!
|
||||
@function process_upgrade_langs
|
||||
@abstract process application lang files and reinstall
|
||||
@param $setup_info array of application info from setup.inc.php files, etc.
|
||||
*/
|
||||
function process_upgrade_langs($setup_info,$DEBUG=False)
|
||||
{
|
||||
@reset($setup_info);
|
||||
while (list($key,$null) = @each($setup_info))
|
||||
{
|
||||
/* Don't upgrade lang files in the middle of an upgrade */
|
||||
if($setup_info[$key]['status'] == 'R')
|
||||
{
|
||||
continue;
|
||||
}
|
||||
$appname = $setup_info[$key]['name'];
|
||||
/* These are in the setup_lang class */
|
||||
$this->drop_langs($appname,$DEBUG);
|
||||
$this->add_langs($appname,$DEBUG);
|
||||
if($DEBUG)
|
||||
{
|
||||
echo '<br>process_upgrade_langs(): Translations reinstalled for ' . $appname . "\n";
|
||||
}
|
||||
}
|
||||
/* Done, return current status */
|
||||
return ($setup_info);
|
||||
}
|
||||
/*!
|
||||
@function process_test_data
|
||||
@abstract process test_data.inc.php in each application/setup dir for developer tests
|
||||
This data should work with the baseline tables
|
||||
@param $setup_info array of application info from setup.inc.php files, etc.
|
||||
*/
|
||||
function process_test_data($setup_info,$DEBUG=False)
|
||||
{
|
||||
if (!$this->oProc)
|
||||
{
|
||||
$this->init_process();
|
||||
}
|
||||
$this->oProc->m_bDeltaOnly = False;
|
||||
$oProc = $this->oProc;
|
||||
|
||||
@reset($setup_info);
|
||||
while (list($key,$null) = @each($setup_info))
|
||||
{
|
||||
$appname = $setup_info[$key]['name'];
|
||||
$appdir = PHPGW_SERVER_ROOT . SEP . $appname . SEP . 'setup' . SEP;
|
||||
|
||||
if (file_exists($appdir.'test_data.inc.php'))
|
||||
{
|
||||
if ($DEBUG)
|
||||
{
|
||||
echo '<br>process_test_data(): Including baseline test data for ' . $appname . "\n";
|
||||
}
|
||||
$this->oProc->m_odb->transaction_begin();
|
||||
include ($appdir.'test_data.inc.php');
|
||||
$this->oProc->m_odb->transaction_commit();
|
||||
}
|
||||
}
|
||||
|
||||
/* Done, return current status */
|
||||
return ($setup_info);
|
||||
}
|
||||
|
||||
/*!
|
||||
@function process_baseline
|
||||
@abstract process baseline table setup in each application/setup dir
|
||||
@param $appinfo array of application info from setup.inc.php files, etc.
|
||||
*/
|
||||
function process_baseline($setup_info,$DEBUG=False)
|
||||
{
|
||||
if (!$this->oProc)
|
||||
{
|
||||
$this->init_process();
|
||||
}
|
||||
|
||||
@reset($setup_info);
|
||||
while (list($key,$null) = @each($setup_info))
|
||||
{
|
||||
$appname = $setup_info[$key]['name'];
|
||||
$appdir = PHPGW_SERVER_ROOT . SEP . $appname . SEP . 'setup' . SEP;
|
||||
|
||||
if (file_exists($appdir.'tables_baseline.inc.php'))
|
||||
{
|
||||
if ($DEBUG)
|
||||
{
|
||||
echo '<br>process_baseline(): Including baseline tables for ' . $appname . "\n";
|
||||
}
|
||||
include ($appdir.'tables_baseline.inc.php');
|
||||
$this->oProc->GenerateScripts($phpgw_baseline, $DEBUG);
|
||||
$this->post_process($phpgw_baseline,$DEBUG);
|
||||
|
||||
/* Update the array values for return below */
|
||||
/* $setup_info[$key]['status'] = 'R'; */
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($DEBUG)
|
||||
{
|
||||
echo '<br>process_baseline(): No baseline tables for ' . $appname . "\n";
|
||||
}
|
||||
//$setup_info[$key]['status'] = 'C';
|
||||
}
|
||||
}
|
||||
|
||||
/* Done, return current status */
|
||||
return ($setup_info);
|
||||
}
|
||||
|
||||
/*!
|
||||
@function process_upgrade
|
||||
@abstract process available upgrades in each application/setup dir
|
||||
@param $appinfo array of application info from setup.inc.php files, etc.
|
||||
*/
|
||||
function process_upgrade($setup_info,$DEBUG=False)
|
||||
{
|
||||
if (!@$this->oProc)
|
||||
{
|
||||
$this->init_process();
|
||||
}
|
||||
$this->oProc->m_odb->HaltOnError = 'no';
|
||||
$this->oProc->m_bDeltaOnly = True;
|
||||
|
||||
@reset($setup_info);
|
||||
while (list($key,$null) = @each($setup_info))
|
||||
{
|
||||
/* Don't try to upgrade an app that is not installed */
|
||||
if(!$this->app_registered($setup_info[$key]['name']))
|
||||
{
|
||||
if ($DEBUG)
|
||||
{
|
||||
echo '<br>process_upgrade(): Application not installed: ' . $appname . "\n";
|
||||
}
|
||||
unset($setup_info[$key]);
|
||||
continue;
|
||||
}
|
||||
|
||||
/* if upgrade required, or if we are running again after an upgrade or dependency failure */
|
||||
if ($DEBUG) { echo '<br>process_upgrade(): Incoming : appname: '.$setup_info[$key]['name'] . ' status: ' . $setup_info[$key]['status']; }
|
||||
if ($setup_info[$key]['status'] == 'U' ||
|
||||
$setup_info[$key]['status'] == 'D' ||
|
||||
$setup_info[$key]['status'] == 'V' ||
|
||||
$setup_info[$key]['status'] == '') // TODO this is not getting set for api upgrade, sometimes ???
|
||||
{
|
||||
$appname = $setup_info[$key]['name'];
|
||||
$apptitle = $setup_info[$key]['title'];
|
||||
$currentver = $setup_info[$key]['currentver'];
|
||||
$targetver = $setup_info[$key]['version']; // The version we need to match when done
|
||||
$appdir = PHPGW_SERVER_ROOT . SEP . $appname . SEP . 'setup' . SEP;
|
||||
|
||||
$test = array();
|
||||
$this->oProc->m_aTables = $phpgw_baseline = array();
|
||||
/*
|
||||
$phpgw_baseline = array();
|
||||
|
||||
$tmpapp = array();
|
||||
$tmpapp[] = $setup_info[$key];
|
||||
$this->process_baseline($tmpapp,$DEBUG);
|
||||
$this->oProc->m_aTables = $phpgw_baseline;
|
||||
// So far, including the baseline file is not helping.
|
||||
// Only AlterColumn/RenameColumn seem to be failing silently.
|
||||
// This is because we are not keeping up with table changes, so a table in baseline
|
||||
// either does not exist anymore, or the baseline is being lost.
|
||||
*/
|
||||
if ($setup_info[$key]['tables'] && file_exists($appdir.'tables_baseline.inc.php'))
|
||||
{
|
||||
if ($DEBUG)
|
||||
{
|
||||
echo '<br>process_baseline(): Including baseline tables for ' . $appname . "\n";
|
||||
}
|
||||
include ($appdir.'tables_baseline.inc.php');
|
||||
$this->oProc->m_aTables = $phpgw_baseline;
|
||||
/* $this->oProc->GenerateScripts($phpgw_baseline, $DEBUG); */
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($DEBUG)
|
||||
{
|
||||
echo '<br>process_baseline(): No baseline tables for ' . $appname . "\n";
|
||||
}
|
||||
/* This should be a break with a status setting, or not at all
|
||||
break;
|
||||
*/
|
||||
}
|
||||
if (file_exists($appdir . 'tables_update.inc.php') && !@$this->updateincluded[$appname])
|
||||
{
|
||||
include ($appdir . 'tables_update.inc.php');
|
||||
$this->updateincluded[$appname] = True;
|
||||
|
||||
/* $test array comes from update file. It is a list of available upgrade functions */
|
||||
@reset($test);
|
||||
while (list($x,$value) = @each($test))
|
||||
{
|
||||
$currentver = $setup_info[$key]['currentver'];
|
||||
|
||||
/* build upgrade function name */
|
||||
$function = $appname . '_upgrade' . ereg_replace("\.", '_', $value);
|
||||
|
||||
if ($DEBUG)
|
||||
{
|
||||
echo '<br>process_upgrade(): appname: ' . $appname;
|
||||
echo '<br>process_upgrade(): currentver: ' . $currentver;
|
||||
echo '<br>process_upgrade(): targetver: ' . $targetver;
|
||||
echo '<br>process_upgrade(): status: ' . $setup_info[$key]['status'];
|
||||
echo '<br>process_upgrade(): checking: ' . $value;
|
||||
echo '<br>process_upgrade(): function: ' . $function;
|
||||
}
|
||||
|
||||
if ($value == $targetver)
|
||||
{
|
||||
$this->oProc->m_bDeltaOnly = False;
|
||||
/* Done upgrading */
|
||||
if($DEBUG)
|
||||
{
|
||||
echo '<br>process_upgrade(): Upgrade of ' . $appname . ' to ' . $targetver . ' is completed.' . "\n";
|
||||
}
|
||||
$appstatus = 'C';
|
||||
$setup_info[$key]['status'] = $appstatus;
|
||||
$setup_info[$key]['currentver'] = $targetver;
|
||||
if ($this->app_registered($appname))
|
||||
{
|
||||
$this->update_app($appname);
|
||||
$this->update_hooks($appname);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->register_app($appname);
|
||||
$this->register_hooks($appname);
|
||||
}
|
||||
//break;
|
||||
}
|
||||
elseif (($value == $currentver) || !$currentver)
|
||||
{
|
||||
/* start upgrading db in addition to baseline */
|
||||
$this->oProc->m_bDeltaOnly = False;
|
||||
if ($DEBUG) { echo '<br>process_upgrade(): running ' . $function; }
|
||||
/* run upgrade function */
|
||||
$success = $function();
|
||||
if ($success != False)
|
||||
{
|
||||
$setup_info[$key]['currentver'] = $success;
|
||||
if ($DEBUG)
|
||||
{
|
||||
echo '<br>process_upgrade(): Upgrade of ' . $appname
|
||||
. ' from ' . $value
|
||||
. ' to ' . $setup_info[$key]['currentver']
|
||||
. ' is completed.' . "\n";
|
||||
}
|
||||
$appstatus = 'R';
|
||||
$setup_info[$key]['status'] = $appstatus;
|
||||
if ($this->app_registered($appname))
|
||||
{
|
||||
if($DEBUG)
|
||||
{
|
||||
echo '<br>process_upgrade(): Updating registration of ' . $appname . ', new version: ' . $setup_info[$key]['currentver'];
|
||||
}
|
||||
$this->update_app($appname);
|
||||
$this->update_hooks($appname);
|
||||
}
|
||||
else
|
||||
{
|
||||
if($DEBUG)
|
||||
{
|
||||
echo '<br>process_upgrade(): Registering ' . $appname . ', version: ' . $setup_info[$key]['currentver'];
|
||||
}
|
||||
$this->register_app($appname);
|
||||
$this->register_hooks($appname);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if($DEBUG)
|
||||
{
|
||||
echo '<br>process_upgrade(): Upgrade of ' . $appname
|
||||
. ' from ' . $currentver
|
||||
. ' to ' . $value
|
||||
. ' failed!!!' . "\n";
|
||||
}
|
||||
$appstatus = 'F';
|
||||
break;
|
||||
}
|
||||
}
|
||||
elseif ($this->alessthanb($value,$currentver))
|
||||
{
|
||||
if ($DEBUG) { echo '<br>process_upgrade(): running baseline delta only: ' . $function . '...'; }
|
||||
$this->oProc->m_bDeltaOnly = True;
|
||||
$success = $function();
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($setup_info[$appname]['tables'])
|
||||
{
|
||||
$appstatus = 'F';
|
||||
|
||||
if ($DEBUG)
|
||||
{
|
||||
echo '<br>process_upgrade(): No table upgrade available for ' . $appname . "\n";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$setup_info[$key]['currentver'] == $targetver;
|
||||
$appstatus = 'C';
|
||||
if ($this->app_registered($appname))
|
||||
{
|
||||
$this->update_app($appname);
|
||||
$this->update_hooks($appname);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->register_app($appname);
|
||||
$this->register_hooks($appname);
|
||||
}
|
||||
|
||||
if ($DEBUG)
|
||||
{
|
||||
echo '<br>process_upgrade(): No table upgrade required for ' . $appname . "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$appstatus = 'C';
|
||||
if ($DEBUG)
|
||||
{
|
||||
echo '<br>process_upgrade(): No upgrade required for ' . $appname . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
/* Done with this app, update status */
|
||||
$setup_info[$key]['status'] = $appstatus;
|
||||
if ($DEBUG)
|
||||
{
|
||||
echo '<br>process_upgrade(): Outgoing : appname: '.$setup_info[$key]['name'] . ' status: ' . $setup_info[$key]['status'];
|
||||
}
|
||||
}
|
||||
|
||||
/* Done, return current status */
|
||||
return ($setup_info);
|
||||
}
|
||||
|
||||
/*!
|
||||
@function post_process
|
||||
@abstract commit above processing to the db
|
||||
*/
|
||||
function post_process($tables,$DEBUG=False)
|
||||
{
|
||||
if (!$tables)
|
||||
{
|
||||
return False;
|
||||
}
|
||||
|
||||
$ret = $this->oProc->GenerateScripts($tables,$DEBUG);
|
||||
if ($ret)
|
||||
{
|
||||
$oret = $this->oProc->ExecuteScripts($tables,$DEBUG);
|
||||
if ($oret)
|
||||
{
|
||||
return True;
|
||||
}
|
||||
else
|
||||
{
|
||||
return False;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return False;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
@function sql_to_array
|
||||
@abstract send this a table name, returns printable column spec and keys for the table from schema_proc
|
||||
@param $tablename table whose array you want to see
|
||||
*/
|
||||
function sql_to_array($tablename = '')
|
||||
{
|
||||
if (!$tablename)
|
||||
{
|
||||
return False;
|
||||
}
|
||||
|
||||
if (!$this->oProc)
|
||||
{
|
||||
$this->init_process();
|
||||
}
|
||||
|
||||
$this->oProc->m_oTranslator->_GetColumns($this->oProc, $tablename, $sColumns, $sColumnName);
|
||||
|
||||
while (list($key,$tbldata) = each ($this->oProc->m_oTranslator->sCol))
|
||||
{
|
||||
$arr .= $tbldata;
|
||||
}
|
||||
$pk = $this->oProc->m_oTranslator->pk;
|
||||
$fk = $this->oProc->m_oTranslator->fk;
|
||||
$ix = $this->oProc->m_oTranslator->ix;
|
||||
$uc = $this->oProc->m_oTranslator->uc;
|
||||
|
||||
return array($arr,$pk,$fk,$ix,$uc);
|
||||
}
|
||||
}
|
||||
?>
|
@ -27,113 +27,26 @@
|
||||
}
|
||||
unset($d1);unset($d2);unset($d3);
|
||||
/* ######## End security check ########## */
|
||||
|
||||
if(file_exists('../header.inc.php'))
|
||||
{
|
||||
include('../header.inc.php');
|
||||
}
|
||||
else
|
||||
/* If we included the header.inc.php, but it is somehow broken, cover ourselves... */
|
||||
if(!defined('PHPGW_SERVER_ROOT') && !defined('PHPGW_INCLUDE_ROOT'))
|
||||
{
|
||||
define('PHPGW_SERVER_ROOT','..');
|
||||
define('PHPGW_INCLUDE_ROOT','..');
|
||||
}
|
||||
|
||||
function CreateObject($class,
|
||||
$p1='_UNDEF_',$p2='_UNDEF_',$p3='_UNDEF_',$p4='_UNDEF_',
|
||||
$p5='_UNDEF_',$p6='_UNDEF_',$p7='_UNDEF_',$p8='_UNDEF_',
|
||||
$p9='_UNDEF_',$p10='_UNDEF_',$p11='_UNDEF_',$p12='_UNDEF_',
|
||||
$p13='_UNDEF_',$p14='_UNDEF_',$p15='_UNDEF_',$p16='_UNDEF_')
|
||||
if (floor(phpversion()) == 3)
|
||||
{
|
||||
list($appname,$classname) = explode('.', $class);
|
||||
|
||||
if (!isset($GLOBALS['phpgw_info']['flags']['included_classes'][$classname]) ||
|
||||
!$GLOBALS['phpgw_info']['flags']['included_classes'][$classname])
|
||||
{
|
||||
$GLOBALS['phpgw_info']['flags']['included_classes'][$classname] = True;
|
||||
include(PHPGW_INCLUDE_ROOT.'/'.$appname.'/inc/class.'.$classname.'.inc.php');
|
||||
}
|
||||
if ($p1 == '_UNDEF_' && $p1 != 1)
|
||||
{
|
||||
eval('$obj = new ' . $classname . ';');
|
||||
}
|
||||
else
|
||||
{
|
||||
$input = array($p1,$p2,$p3,$p4,$p5,$p6,$p7,$p8,$p9,$p10,$p11,$p12,$p13,$p14,$p15,$p16);
|
||||
$i = 1;
|
||||
$code = '$obj = new ' . $classname . '(';
|
||||
while (list($x,$test) = each($input))
|
||||
{
|
||||
if (($test == '_UNDEF_' && $test != 1 ) || $i == 17)
|
||||
{
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
$code .= '$p' . $i . ',';
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
$code = substr($code,0,-1) . ');';
|
||||
eval($code);
|
||||
}
|
||||
return $obj;
|
||||
}
|
||||
|
||||
/* This is needed is some parts of setup, until we include the API directly */
|
||||
function filesystem_separator()
|
||||
{
|
||||
if (PHP_OS == 'Windows' || PHP_OS == 'OS/2')
|
||||
{
|
||||
return '\\';
|
||||
}
|
||||
else
|
||||
{
|
||||
return '/';
|
||||
}
|
||||
include(PHPGW_INCLUDE_ROOT . '/phpgwapi/inc/php3_support_functions.inc.php');
|
||||
}
|
||||
include(PHPGW_INCLUDE_ROOT . '/phpgwapi/inc/common_functions.inc.php');
|
||||
|
||||
define('SEP',filesystem_separator());
|
||||
|
||||
/*!
|
||||
@function get_account_id
|
||||
@abstract Return a properly formatted account_id.
|
||||
@author skeeter
|
||||
@discussion This function will return a properly formatted account_id. This can take either a name or an account_id as paramters. If a name is provided it will return the associated id.
|
||||
@syntax get_account_id($accountid);
|
||||
@example $account_id = get_account_id($accountid);
|
||||
@param $account_id either a name or an id
|
||||
@param $default_id either a name or an id
|
||||
*/
|
||||
function get_account_id($account_id = '',$default_id = '')
|
||||
{
|
||||
if (is_int($account_id))
|
||||
{
|
||||
return $account_id;
|
||||
}
|
||||
elseif ($account_id == '')
|
||||
{
|
||||
if ($default_id == '')
|
||||
{
|
||||
return (isset($GLOBALS['phpgw_info']['user']['account_id'])?$GLOBALS['phpgw_info']['user']['account_id']:0);
|
||||
}
|
||||
elseif (is_string($default_id))
|
||||
{
|
||||
return $GLOBALS['phpgw']->accounts->name2id($default_id);
|
||||
}
|
||||
return intval($default_id);
|
||||
}
|
||||
elseif (is_string($account_id))
|
||||
{
|
||||
if($GLOBALS['phpgw']->accounts->exists(intval($account_id)) == True)
|
||||
{
|
||||
return intval($account_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
return $GLOBALS['phpgw']->accounts->name2id($account_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
@function lang
|
||||
@abstract function to handle multilanguage support
|
||||
@ -148,7 +61,7 @@
|
||||
{
|
||||
$vars = array($m1,$m2,$m3,$m4,$m5,$m6,$m7,$m8,$m9,$m10);
|
||||
}
|
||||
$value = $GLOBALS['phpgw_setup']->translate("$key", $vars );
|
||||
$value = $GLOBALS['phpgw_setup']->translation->translate("$key", $vars );
|
||||
return $value;
|
||||
}
|
||||
|
||||
@ -159,8 +72,8 @@
|
||||
*/
|
||||
function get_langs()
|
||||
{
|
||||
$f = fopen('./lang/languages','r');
|
||||
while ($line = fgets($f,200))
|
||||
$f = fopen('./lang/languages','rb');
|
||||
while($line = fgets($f,200))
|
||||
{
|
||||
list($x,$y) = split("\t",$line);
|
||||
$languages[$x]['lang'] = trim($x);
|
||||
@ -172,7 +85,7 @@
|
||||
$d = dir('./lang');
|
||||
while($entry=$d->read())
|
||||
{
|
||||
if (ereg('^phpgw_',$entry))
|
||||
if(ereg('^phpgw_',$entry))
|
||||
{
|
||||
$z = substr($entry,6,2);
|
||||
$languages[$z]['available'] = True;
|
||||
@ -190,9 +103,9 @@
|
||||
|
||||
$select = '<select name="ConfigLang">' . "\n";
|
||||
$languages = get_langs();
|
||||
while (list($null,$data) = each($languages))
|
||||
while(list($null,$data) = each($languages))
|
||||
{
|
||||
if ($data['available'])
|
||||
if($data['available'])
|
||||
{
|
||||
$selected = '';
|
||||
$short = substr($data['lang'],0,2);
|
||||
@ -208,44 +121,6 @@
|
||||
return $select;
|
||||
}
|
||||
|
||||
/*!
|
||||
@function isinarray
|
||||
@abstract php3/4 compliant in_array()
|
||||
@param $needle String to search for
|
||||
@param $haystack Array to search
|
||||
*/
|
||||
function isinarray($needle,$haystack='')
|
||||
{
|
||||
if($haystack == '')
|
||||
{
|
||||
settype($haystack,'array');
|
||||
$haystack = Array();
|
||||
}
|
||||
for($i=0;$i<count($haystack) && $haystack[$i] !=$needle;$i++);
|
||||
return ($i!=count($haystack));
|
||||
}
|
||||
|
||||
/* Include to check user authorization against the
|
||||
password in ../header.inc.php to protect all of the setup
|
||||
pages from unauthorized use.
|
||||
*/
|
||||
|
||||
function _debug_array($array)
|
||||
{
|
||||
if(floor(phpversion()) == 4)
|
||||
{
|
||||
ob_start();
|
||||
echo '<pre>'; print_r($array); echo '</pre>';
|
||||
$contents = ob_get_contents();
|
||||
ob_end_clean();
|
||||
echo $contents;
|
||||
}
|
||||
else
|
||||
{
|
||||
echo '<pre>'; var_dump($array); echo '</pre>';
|
||||
}
|
||||
}
|
||||
|
||||
if(file_exists(PHPGW_SERVER_ROOT.'/phpgwapi/setup/setup.inc.php'))
|
||||
{
|
||||
include(PHPGW_SERVER_ROOT.'/phpgwapi/setup/setup.inc.php'); /* To set the current core version */
|
||||
@ -259,6 +134,5 @@
|
||||
|
||||
$GLOBALS['phpgw_info']['server']['app_images'] = 'templates/default/images';
|
||||
|
||||
include('./inc/class.setup.inc.php');
|
||||
$phpgw_setup = new phpgw_setup;
|
||||
$GLOBALS['phpgw_setup'] = CreateObject('phpgwapi.setup',True,True);
|
||||
?>
|
||||
|
@ -1,534 +0,0 @@
|
||||
<?php
|
||||
// by Edd Dumbill (C) 1999-2001
|
||||
// <edd@usefulinc.com>
|
||||
// xmlrpc.inc,v 1.18 2001/07/06 18:23:57 edmundd
|
||||
|
||||
// License is granted to use or modify this software ("XML-RPC for PHP")
|
||||
// for commercial or non-commercial use provided the copyright of the author
|
||||
// is preserved in any distributed or derivative work.
|
||||
|
||||
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESSED OR
|
||||
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
// IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
if (!function_exists('xml_parser_create'))
|
||||
{
|
||||
// Win 32 fix. From: "Leo West" <lwest@imaginet.fr>
|
||||
if($WINDIR)
|
||||
{
|
||||
dl('php3_xml.dll');
|
||||
}
|
||||
else
|
||||
{
|
||||
dl('xml.so');
|
||||
}
|
||||
}
|
||||
|
||||
define('xmlrpcI4','i4');
|
||||
define('xmlrpcInt','int');
|
||||
define('xmlrpcBoolean','boolean');
|
||||
define('xmlrpcDouble','double');
|
||||
define('xmlrpcString','string');
|
||||
define('xmlrpcDateTime','dateTime.iso8601');
|
||||
define('xmlrpcBase64','base64');
|
||||
define('xmlrpcArray','array');
|
||||
define('xmlrpcStruct','struct');
|
||||
|
||||
$GLOBALS['xmlrpcTypes'] = array(
|
||||
xmlrpcI4 => 1,
|
||||
xmlrpcInt => 1,
|
||||
xmlrpcBoolean => 1,
|
||||
xmlrpcString => 1,
|
||||
xmlrpcDouble => 1,
|
||||
xmlrpcDateTime => 1,
|
||||
xmlrpcBase64 => 1,
|
||||
xmlrpcArray => 2,
|
||||
xmlrpcStruct => 3
|
||||
);
|
||||
|
||||
$GLOBALS['xmlEntities']=array(
|
||||
'amp' => '&',
|
||||
'quot' => '"',
|
||||
'lt' => '<',
|
||||
'gt' => '>',
|
||||
'apos' => "'"
|
||||
);
|
||||
|
||||
$GLOBALS['xmlrpcerr']['unknown_method'] = 1;
|
||||
$GLOBALS['xmlrpcstr']['unknown_method'] = 'Unknown method';
|
||||
$GLOBALS['xmlrpcerr']['invalid_return'] = 2;
|
||||
$GLOBALS['xmlrpcstr']['invalid_return'] = 'Invalid return payload: enabling debugging to examine incoming payload';
|
||||
$GLOBALS['xmlrpcerr']['incorrect_params'] = 3;
|
||||
$GLOBALS['xmlrpcstr']['incorrect_params'] = 'Incorrect parameters passed to method';
|
||||
$GLOBALS['xmlrpcerr']['introspect_unknown'] = 4;
|
||||
$GLOBALS['xmlrpcstr']['introspect_unknown'] = "Can't introspect: method unknown";
|
||||
$GLOBALS['xmlrpcerr']['http_error'] = 5;
|
||||
$GLOBALS['xmlrpcstr']['http_error'] = "Didn't receive 200 OK from remote server.";
|
||||
|
||||
$GLOBALS['xmlrpc_defencoding'] = 'UTF-8';
|
||||
|
||||
$GLOBALS['xmlrpcName'] = 'XML-RPC for PHP';
|
||||
$GLOBALS['xmlrpcVersion'] = '1.0b9';
|
||||
|
||||
// let user errors start at 800
|
||||
$GLOBALS['xmlrpcerruser'] = 800;
|
||||
// let XML parse errors start at 100
|
||||
$GLOBALS['xmlrpcerrxml'] = 100;
|
||||
|
||||
// formulate backslashes for escaping regexp
|
||||
$GLOBALS['xmlrpc_backslash'] = chr(92) . chr(92);
|
||||
|
||||
// used to store state during parsing
|
||||
// quick explanation of components:
|
||||
// st - used to build up a string for evaluation
|
||||
// ac - used to accumulate values
|
||||
// qt - used to decide if quotes are needed for evaluation
|
||||
// cm - used to denote struct or array (comma needed)
|
||||
// isf - used to indicate a fault
|
||||
// lv - used to indicate "looking for a value": implements
|
||||
// the logic to allow values with no types to be strings
|
||||
// params - used to store parameters in method calls
|
||||
// method - used to store method name
|
||||
|
||||
$GLOBALS['_xh']=array();
|
||||
|
||||
function xmlrpc_entity_decode($string)
|
||||
{
|
||||
$top = split('&', $string);
|
||||
$op = '';
|
||||
$i = 0;
|
||||
while($i<sizeof($top))
|
||||
{
|
||||
if (ereg("^([#a-zA-Z0-9]+);", $top[$i], $regs))
|
||||
{
|
||||
$op .= ereg_replace("^[#a-zA-Z0-9]+;",
|
||||
xmlrpc_lookup_entity($regs[1]), $top[$i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($i == 0)
|
||||
{
|
||||
$op = $top[$i];
|
||||
}
|
||||
else
|
||||
{
|
||||
$op .= '&' . $top[$i];
|
||||
}
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
return $op;
|
||||
}
|
||||
|
||||
function xmlrpc_lookup_entity($ent)
|
||||
{
|
||||
if (isset($GLOBALS['xmlEntities'][strtolower($ent)]))
|
||||
{
|
||||
return $GLOBALS['xmlEntities'][strtolower($ent)];
|
||||
}
|
||||
if (ereg("^#([0-9]+)$", $ent, $regs))
|
||||
{
|
||||
return chr($regs[1]);
|
||||
}
|
||||
return '?';
|
||||
}
|
||||
|
||||
function xmlrpc_se($parser, $name, $attrs)
|
||||
{
|
||||
switch($name)
|
||||
{
|
||||
case 'STRUCT':
|
||||
case 'ARRAY':
|
||||
$GLOBALS['_xh'][$parser]['st'] .= 'array(';
|
||||
$GLOBALS['_xh'][$parser]['cm']++;
|
||||
// this last line turns quoting off
|
||||
// this means if we get an empty array we'll
|
||||
// simply get a bit of whitespace in the eval
|
||||
$GLOBALS['_xh'][$parser]['qt']=0;
|
||||
break;
|
||||
case 'NAME':
|
||||
$GLOBALS['_xh'][$parser]['st'] .= "'";
|
||||
$GLOBALS['_xh'][$parser]['ac'] = '';
|
||||
break;
|
||||
case 'FAULT':
|
||||
$GLOBALS['_xh'][$parser]['isf'] = 1;
|
||||
break;
|
||||
case 'PARAM':
|
||||
$GLOBALS['_xh'][$parser]['st'] = '';
|
||||
break;
|
||||
case 'VALUE':
|
||||
$GLOBALS['_xh'][$parser]['st'] .= " CreateObject('phpgwapi.xmlrpcval',";
|
||||
$GLOBALS['_xh'][$parser]['vt'] = xmlrpcString;
|
||||
$GLOBALS['_xh'][$parser]['ac'] = '';
|
||||
$GLOBALS['_xh'][$parser]['qt'] = 0;
|
||||
$GLOBALS['_xh'][$parser]['lv'] = 1;
|
||||
// look for a value: if this is still 1 by the
|
||||
// time we reach the first data segment then the type is string
|
||||
// by implication and we need to add in a quote
|
||||
break;
|
||||
case 'I4':
|
||||
case 'INT':
|
||||
case 'STRING':
|
||||
case 'BOOLEAN':
|
||||
case 'DOUBLE':
|
||||
case 'DATETIME.ISO8601':
|
||||
case 'BASE64':
|
||||
$GLOBALS['_xh'][$parser]['ac']=''; // reset the accumulator
|
||||
|
||||
if ($name=='DATETIME.ISO8601' || $name=='STRING')
|
||||
{
|
||||
$GLOBALS['_xh'][$parser]['qt']=1;
|
||||
if ($name=='DATETIME.ISO8601')
|
||||
{
|
||||
$GLOBALS['_xh'][$parser]['vt']=xmlrpcDateTime;
|
||||
}
|
||||
}
|
||||
elseif($name=='BASE64')
|
||||
{
|
||||
$GLOBALS['_xh'][$parser]['qt']=2;
|
||||
}
|
||||
else
|
||||
{
|
||||
// No quoting is required here -- but
|
||||
// at the end of the element we must check
|
||||
// for data format errors.
|
||||
$GLOBALS['_xh'][$parser]['qt']=0;
|
||||
}
|
||||
break;
|
||||
case 'MEMBER':
|
||||
$GLOBALS['_xh'][$parser]['ac']='';
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if ($name!='VALUE')
|
||||
{
|
||||
$GLOBALS['_xh'][$parser]['lv']=0;
|
||||
}
|
||||
}
|
||||
|
||||
function xmlrpc_ee($parser, $name)
|
||||
{
|
||||
switch($name)
|
||||
{
|
||||
case 'STRUCT':
|
||||
case 'ARRAY':
|
||||
if ($GLOBALS['_xh'][$parser]['cm'] && substr($GLOBALS['_xh'][$parser]['st'], -1) ==',')
|
||||
{
|
||||
$GLOBALS['_xh'][$parser]['st']=substr($GLOBALS['_xh'][$parser]['st'],0,-1);
|
||||
}
|
||||
$GLOBALS['_xh'][$parser]['st'].=')';
|
||||
$GLOBALS['_xh'][$parser]['vt']=strtolower($name);
|
||||
$GLOBALS['_xh'][$parser]['cm']--;
|
||||
break;
|
||||
case 'NAME':
|
||||
$GLOBALS['_xh'][$parser]['st'].= $GLOBALS['_xh'][$parser]['ac'] . "' => ";
|
||||
break;
|
||||
case 'BOOLEAN':
|
||||
// special case here: we translate boolean 1 or 0 into PHP
|
||||
// constants true or false
|
||||
if ($GLOBALS['_xh'][$parser]['ac']=='1')
|
||||
{
|
||||
$GLOBALS['_xh'][$parser]['ac']='True';
|
||||
}
|
||||
else
|
||||
{
|
||||
$GLOBALS['_xh'][$parser]['ac']='false';
|
||||
}
|
||||
$GLOBALS['_xh'][$parser]['vt']=strtolower($name);
|
||||
// Drop through intentionally.
|
||||
case 'I4':
|
||||
case 'INT':
|
||||
case 'STRING':
|
||||
case 'DOUBLE':
|
||||
case 'DATETIME.ISO8601':
|
||||
case 'BASE64':
|
||||
if ($GLOBALS['_xh'][$parser]['qt']==1)
|
||||
{
|
||||
// we use double quotes rather than single so backslashification works OK
|
||||
$GLOBALS['_xh'][$parser]['st'].='"'. $GLOBALS['_xh'][$parser]['ac'] . '"';
|
||||
}
|
||||
elseif ($GLOBALS['_xh'][$parser]['qt']==2)
|
||||
{
|
||||
$GLOBALS['_xh'][$parser]['st'].="base64_decode('". $GLOBALS['_xh'][$parser]['ac'] . "')";
|
||||
}
|
||||
else if ($name=='BOOLEAN')
|
||||
{
|
||||
$GLOBALS['_xh'][$parser]['st'].=$GLOBALS['_xh'][$parser]['ac'];
|
||||
}
|
||||
else
|
||||
{
|
||||
// we have an I4, INT or a DOUBLE
|
||||
// we must check that only 0123456789-.<space> are characters here
|
||||
if (!ereg("^\-?[0123456789 \t\.]+$", $GLOBALS['_xh'][$parser]['ac']))
|
||||
{
|
||||
// TODO: find a better way of throwing an error
|
||||
// than this!
|
||||
error_log('XML-RPC: non numeric value received in INT or DOUBLE');
|
||||
$GLOBALS['_xh'][$parser]['st'].='ERROR_NON_NUMERIC_FOUND';
|
||||
}
|
||||
else
|
||||
{
|
||||
// it's ok, add it on
|
||||
$GLOBALS['_xh'][$parser]['st'].=$GLOBALS['_xh'][$parser]['ac'];
|
||||
}
|
||||
}
|
||||
$GLOBALS['_xh'][$parser]['ac']=""; $GLOBALS['_xh'][$parser]['qt']=0;
|
||||
$GLOBALS['_xh'][$parser]['lv']=3; // indicate we've found a value
|
||||
break;
|
||||
case 'VALUE':
|
||||
// deal with a string value
|
||||
if (strlen($GLOBALS['_xh'][$parser]['ac'])>0 &&
|
||||
$GLOBALS['_xh'][$parser]['vt']==xmlrpcString)
|
||||
{
|
||||
$GLOBALS['_xh'][$parser]['st'].='"'. $GLOBALS['_xh'][$parser]['ac'] . '"';
|
||||
}
|
||||
// This if() detects if no scalar was inside <VALUE></VALUE>
|
||||
// and pads an empty "".
|
||||
if($GLOBALS['_xh'][$parser]['st'][strlen($GLOBALS['_xh'][$parser]['st'])-1] == '(')
|
||||
{
|
||||
$GLOBALS['_xh'][$parser]['st'].= '""';
|
||||
}
|
||||
$GLOBALS['_xh'][$parser]['st'].=", '" . $GLOBALS['_xh'][$parser]['vt'] . "')";
|
||||
if ($GLOBALS['_xh'][$parser]['cm'])
|
||||
{
|
||||
$GLOBALS['_xh'][$parser]['st'].=",";
|
||||
}
|
||||
break;
|
||||
case 'MEMBER':
|
||||
$GLOBALS['_xh'][$parser]['ac']="";
|
||||
$GLOBALS['_xh'][$parser]['qt']=0;
|
||||
break;
|
||||
case 'DATA':
|
||||
$GLOBALS['_xh'][$parser]['ac']="";
|
||||
$GLOBALS['_xh'][$parser]['qt']=0;
|
||||
break;
|
||||
case 'PARAM':
|
||||
$GLOBALS['_xh'][$parser]['params'][]=$GLOBALS['_xh'][$parser]['st'];
|
||||
break;
|
||||
case 'METHODNAME':
|
||||
$GLOBALS['_xh'][$parser]['method']=ereg_replace("^[\n\r\t ]+", "", $GLOBALS['_xh'][$parser]['ac']);
|
||||
break;
|
||||
case 'BOOLEAN':
|
||||
// special case here: we translate boolean 1 or 0 into PHP
|
||||
// constants true or false
|
||||
if ($GLOBALS['_xh'][$parser]['ac']=='1')
|
||||
{
|
||||
$GLOBALS['_xh'][$parser]['ac']='True';
|
||||
}
|
||||
else
|
||||
{
|
||||
$GLOBALS['_xh'][$parser]['ac']='false';
|
||||
}
|
||||
$GLOBALS['_xh'][$parser]['vt']=strtolower($name);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
// if it's a valid type name, set the type
|
||||
if (isset($GLOBALS['xmlrpcTypes'][strtolower($name)]))
|
||||
{
|
||||
$GLOBALS['_xh'][$parser]['vt']=strtolower($name);
|
||||
}
|
||||
}
|
||||
|
||||
function xmlrpc_cd($parser, $data)
|
||||
{
|
||||
//if (ereg("^[\n\r \t]+$", $data)) return;
|
||||
// print "adding [${data}]\n";
|
||||
|
||||
if ($GLOBALS['_xh'][$parser]['lv']!=3)
|
||||
{
|
||||
// "lookforvalue==3" means that we've found an entire value
|
||||
// and should discard any further character data
|
||||
if ($GLOBALS['_xh'][$parser]['lv']==1)
|
||||
{
|
||||
// if we've found text and we're just in a <value> then
|
||||
// turn quoting on, as this will be a string
|
||||
$GLOBALS['_xh'][$parser]['qt']=1;
|
||||
// and say we've found a value
|
||||
$GLOBALS['_xh'][$parser]['lv']=2;
|
||||
}
|
||||
if (isset($GLOBALS['_xh'][$parser]['qt']) && $GLOBALS['_xh'][$parser]['qt'])
|
||||
{
|
||||
// quoted string: replace characters that eval would
|
||||
// do special things with
|
||||
$GLOBALS['_xh'][$parser]['ac'].=str_replace('$', '\$',
|
||||
str_replace('"', '\"',
|
||||
str_replace(chr(92),$GLOBALS['xmlrpc_backslash'], $data)));
|
||||
}
|
||||
else
|
||||
{
|
||||
$GLOBALS['_xh'][$parser]['ac'].=$data;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function xmlrpc_dh($parser, $data)
|
||||
{
|
||||
if (substr($data, 0, 1) == '&' && substr($data, -1, 1) == ';')
|
||||
{
|
||||
if ($GLOBALS['_xh'][$parser]['lv']==1)
|
||||
{
|
||||
$GLOBALS['_xh'][$parser]['qt']=1;
|
||||
$GLOBALS['_xh'][$parser]['lv']=2;
|
||||
}
|
||||
$GLOBALS['_xh'][$parser]['ac'].=$data;
|
||||
}
|
||||
}
|
||||
|
||||
// date helpers
|
||||
function iso8601_encode($timet, $utc=0)
|
||||
{
|
||||
// return an ISO8601 encoded string
|
||||
// really, timezones ought to be supported
|
||||
// but the XML-RPC spec says:
|
||||
//
|
||||
// "Don't assume a timezone. It should be specified by the server in its
|
||||
// documentation what assumptions it makes about timezones."
|
||||
//
|
||||
// these routines always assume localtime unless
|
||||
// $utc is set to 1, in which case UTC is assumed
|
||||
// and an adjustment for locale is made when encoding
|
||||
if (!$utc)
|
||||
{
|
||||
$t=strftime("%Y%m%dT%H:%M:%S", $timet);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (function_exists("gmstrftime"))
|
||||
{
|
||||
// gmstrftime doesn't exist in some versions
|
||||
// of PHP
|
||||
$t=gmstrftime("%Y%m%dT%H:%M:%S", $timet);
|
||||
}
|
||||
else
|
||||
{
|
||||
$t=strftime("%Y%m%dT%H:%M:%S", $timet-date("Z"));
|
||||
}
|
||||
}
|
||||
return $t;
|
||||
}
|
||||
|
||||
function iso8601_decode($idate, $utc=0)
|
||||
{
|
||||
// return a timet in the localtime, or UTC
|
||||
$t=0;
|
||||
if (ereg("([0-9]{4})([0-9]{2})([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})",$idate, $regs))
|
||||
{
|
||||
if ($utc)
|
||||
{
|
||||
$t=gmmktime($regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
$t=mktime($regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1]);
|
||||
}
|
||||
}
|
||||
return $t;
|
||||
}
|
||||
|
||||
/****************************************************************
|
||||
* xmlrpc_decode takes a message in PHP xmlrpc object format and *
|
||||
* tranlates it into native PHP types. *
|
||||
* *
|
||||
* author: Dan Libby (dan@libby.com) *
|
||||
****************************************************************/
|
||||
function xmlrpc_decode($xmlrpc_val)
|
||||
{
|
||||
$kind = @$xmlrpc_val->kindOf();
|
||||
|
||||
if($kind == "scalar")
|
||||
{
|
||||
return $xmlrpc_val->scalarval();
|
||||
}
|
||||
elseif($kind == "array")
|
||||
{
|
||||
$size = $xmlrpc_val->arraysize();
|
||||
$arr = array();
|
||||
|
||||
for($i = 0; $i < $size; $i++)
|
||||
{
|
||||
$arr[]=xmlrpc_decode($xmlrpc_val->arraymem($i));
|
||||
}
|
||||
return $arr;
|
||||
}
|
||||
elseif($kind == "struct")
|
||||
{
|
||||
$xmlrpc_val->structreset();
|
||||
$arr = array();
|
||||
|
||||
while(list($key,$value)=$xmlrpc_val->structeach())
|
||||
{
|
||||
$arr[$key] = xmlrpc_decode($value);
|
||||
}
|
||||
return $arr;
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************
|
||||
* xmlrpc_encode takes native php types and encodes them into *
|
||||
* xmlrpc PHP object format. *
|
||||
* BUG: All sequential arrays are turned into structs. I don't *
|
||||
* know of a good way to determine if an array is sequential *
|
||||
* only. *
|
||||
* *
|
||||
* feature creep -- could support more types via optional type *
|
||||
* argument. *
|
||||
* *
|
||||
* author: Dan Libby (dan@libby.com) *
|
||||
****************************************************************/
|
||||
function xmlrpc_encode($php_val)
|
||||
{
|
||||
$type = gettype($php_val);
|
||||
$xmlrpc_val = CreateObject('phpgwapi.xmlrpcval');
|
||||
|
||||
switch($type)
|
||||
{
|
||||
case "array":
|
||||
case "object":
|
||||
$arr = array();
|
||||
while (list($k,$v) = each($php_val))
|
||||
{
|
||||
$arr[$k] = xmlrpc_encode($v);
|
||||
}
|
||||
$xmlrpc_val->addStruct($arr);
|
||||
break;
|
||||
case "integer":
|
||||
$xmlrpc_val->addScalar($php_val, xmlrpcInt);
|
||||
break;
|
||||
case "double":
|
||||
$xmlrpc_val->addScalar($php_val, xmlrpcDouble);
|
||||
break;
|
||||
case "string":
|
||||
$xmlrpc_val->addScalar($php_val, xmlrpcString);
|
||||
break;
|
||||
// <G_Giunta_2001-02-29>
|
||||
// Add support for encoding/decoding of booleans, since they are supported in PHP
|
||||
case "boolean":
|
||||
$xmlrpc_val->addScalar($php_val, xmlrpcBoolean);
|
||||
break;
|
||||
// </G_Giunta_2001-02-29>
|
||||
case "unknown type":
|
||||
default:
|
||||
$xmlrpc_val = false;
|
||||
break;
|
||||
}
|
||||
return $xmlrpc_val;
|
||||
}
|
||||
|
||||
$GLOBALS['_xmlrpc_debuginfo'] = '';
|
||||
function xmlrpc_debugmsg($m)
|
||||
{
|
||||
$GLOBALS['_xmlrpc_debuginfo'] .= $m . "\n";
|
||||
}
|
||||
|
||||
?>
|
100
setup/index.php
100
setup/index.php
@ -29,7 +29,7 @@
|
||||
|
||||
set_time_limit(0);
|
||||
|
||||
$tpl_root = $phpgw_setup->setup_tpl_dir('setup');
|
||||
$tpl_root = $GLOBALS['phpgw_setup']->html->setup_tpl_dir('setup');
|
||||
$setup_tpl = CreateObject('phpgwapi.Template',$tpl_root);
|
||||
$setup_tpl->set_file(array(
|
||||
'T_head' => 'head.tpl',
|
||||
@ -55,33 +55,33 @@
|
||||
$setup_tpl->set_block('T_setup_db_blocks','B_db_stage_default','V_db_stage_default');
|
||||
|
||||
// Check header and authentication
|
||||
$GLOBALS['phpgw_info']['setup']['stage']['header'] = $phpgw_setup->check_header();
|
||||
$GLOBALS['phpgw_info']['setup']['stage']['header'] = $GLOBALS['phpgw_setup']->detection->check_header();
|
||||
if ($GLOBALS['phpgw_info']['setup']['stage']['header'] != '10')
|
||||
{
|
||||
Header('Location: manageheader.php');
|
||||
exit;
|
||||
}
|
||||
elseif (!$phpgw_setup->auth('Config'))
|
||||
elseif (!$GLOBALS['phpgw_setup']->auth('Config'))
|
||||
{
|
||||
$phpgw_setup->show_header(lang('Please login'),True);
|
||||
$phpgw_setup->login_form();
|
||||
$phpgw_setup->show_footer();
|
||||
$GLOBALS['phpgw_setup']->html->show_header(lang('Please login'),True);
|
||||
$GLOBALS['phpgw_setup']->html->login_form();
|
||||
$GLOBALS['phpgw_setup']->html->show_footer();
|
||||
exit;
|
||||
}
|
||||
|
||||
$phpgw_setup->loaddb();
|
||||
$GLOBALS['phpgw_setup']->loaddb();
|
||||
|
||||
/* Add cleaning of app_sessions per skeeter, but with a check for the table being there, just in case */
|
||||
$phpgw_setup->clear_session_cache();
|
||||
$GLOBALS['phpgw_setup']->clear_session_cache();
|
||||
|
||||
// Database actions
|
||||
$setup_info = $phpgw_setup->get_versions();
|
||||
$GLOBALS['phpgw_info']['setup']['stage']['db'] = $phpgw_setup->check_db();
|
||||
$setup_info = $GLOBALS['phpgw_setup']->detection->get_versions();
|
||||
$GLOBALS['phpgw_info']['setup']['stage']['db'] = $GLOBALS['phpgw_setup']->detection->check_db();
|
||||
if ($GLOBALS['phpgw_info']['setup']['stage']['db'] != 1)
|
||||
{
|
||||
$setup_info = $phpgw_setup->get_versions();
|
||||
$setup_info = $phpgw_setup->get_db_versions($setup_info);
|
||||
$GLOBALS['phpgw_info']['setup']['stage']['db'] = $phpgw_setup->check_db();
|
||||
$setup_info = $GLOBALS['phpgw_setup']->detection->get_versions();
|
||||
$setup_info = $GLOBALS['phpgw_setup']->detection->get_db_versions($setup_info);
|
||||
$GLOBALS['phpgw_info']['setup']['stage']['db'] = $GLOBALS['phpgw_setup']->detection->check_db();
|
||||
if($GLOBALS['DEBUG'])
|
||||
{
|
||||
_debug_array($setup_info);
|
||||
@ -139,16 +139,16 @@
|
||||
// Old PHP
|
||||
if (phpversion() < '3.0.16')
|
||||
{
|
||||
$phpgw_setup->show_header($GLOBALS['phpgw_info']['setup']['header_msg'],True);
|
||||
$phpgw_setup->show_alert_msg('Error',
|
||||
$GLOBALS['phpgw_setup']->html->show_header($GLOBALS['phpgw_info']['setup']['header_msg'],True);
|
||||
$GLOBALS['phpgw_setup']->html->show_alert_msg('Error',
|
||||
lang('You appear to be running an old version of PHP <br>It its recommend that you upgrade to a new version. <br>Older version of PHP might not run phpGroupWare correctly, if at all. <br><br>Please upgrade to at least version 3.0.16'));
|
||||
$phpgw_setup->show_footer();
|
||||
$GLOBALS['phpgw_setup']->html->show_footer();
|
||||
exit;
|
||||
}
|
||||
|
||||
// BEGIN setup page
|
||||
|
||||
//$phpgw_setup->app_status();
|
||||
//$GLOBALS['phpgw_setup']->app_status();
|
||||
$GLOBALS['phpgw_info']['server']['app_images'] = 'templates/default/images';
|
||||
$incomplete = $GLOBALS['phpgw_info']['server']['app_images'] . '/incomplete.gif';
|
||||
$completed = $GLOBALS['phpgw_info']['server']['app_images'] . '/completed.gif';
|
||||
@ -229,32 +229,33 @@
|
||||
$db_filled_block = $setup_tpl->get_var('V_db_stage_6_pre');
|
||||
|
||||
// FIXME : CAPTURE THIS OUTPUT
|
||||
$phpgw_setup->db->Halt_On_Error = 'report';
|
||||
$GLOBALS['phpgw_setup']->db->Halt_On_Error = 'report';
|
||||
|
||||
switch ($GLOBALS['phpgw_info']['setup']['currentver']['phpgwapi'])
|
||||
{
|
||||
case 'dbcreate':
|
||||
$phpgw_setup->db->create_database($db_root, $db_pass);
|
||||
$GLOBALS['phpgw_setup']->db->create_database($db_root, $db_pass);
|
||||
break;
|
||||
case 'drop':
|
||||
$setup_info = $phpgw_setup->get_versions($setup_info);
|
||||
$setup_info = $phpgw_setup->process_droptables($setup_info);
|
||||
$setup_info = $GLOBALS['phpgw_setup']->detection->get_versions($setup_info);
|
||||
$setup_info = $GLOBALS['phpgw_setup']->process->droptables($setup_info);
|
||||
break;
|
||||
case 'new':
|
||||
/* process all apps and langs(last param True), excluding apps with the no_mass_update flag set. */
|
||||
$setup_info = $phpgw_setup->upgrade_exclude($setup_info);
|
||||
$setup_info = $phpgw_setup->process_pass($setup_info,'new',$GLOBALS['DEBUG'],True);
|
||||
$setup_info = $GLOBALS['phpgw_setup']->detection->upgrade_exclude($setup_info);
|
||||
$setup_info = $GLOBALS['phpgw_setup']->process->pass($setup_info,'new',$GLOBALS['DEBUG'],True);
|
||||
|
||||
$GLOBALS['included'] = True;
|
||||
include('lang.php');
|
||||
$GLOBALS['phpgw_info']['setup']['currentver']['phpgwapi'] = 'oldversion';
|
||||
break;
|
||||
case 'oldversion':
|
||||
$setup_info = $phpgw_setup->process_pass($setup_info,'upgrade',$GLOBALS['DEBUG']);
|
||||
$setup_info = $GLOBALS['phpgw_setup']->process->pass($setup_info,'upgrade',$GLOBALS['DEBUG']);
|
||||
$GLOBALS['phpgw_info']['setup']['currentver']['phpgwapi'] = 'oldversion';
|
||||
break;
|
||||
}
|
||||
|
||||
$phpgw_setup->db->Halt_On_Error = 'no';
|
||||
$GLOBALS['phpgw_setup']->db->Halt_On_Error = 'no';
|
||||
|
||||
$setup_tpl->set_var('tableshave',lang('If you did not receive any errors, your applications have been'));
|
||||
$setup_tpl->set_var('re-check_my_installation',lang('Re-Check My Installation'));
|
||||
@ -282,7 +283,7 @@
|
||||
|
||||
// Config Section
|
||||
$setup_tpl->set_var('config_step_text',lang('Step 2 - Configuration'));
|
||||
$GLOBALS['phpgw_info']['setup']['stage']['config'] = $phpgw_setup->check_config();
|
||||
$GLOBALS['phpgw_info']['setup']['stage']['config'] = $GLOBALS['phpgw_setup']->detection->check_config();
|
||||
|
||||
// begin DEBUG code
|
||||
//$GLOBALS['phpgw_info']['setup']['stage']['config'] = 10;
|
||||
@ -293,7 +294,7 @@
|
||||
case 1:
|
||||
$setup_tpl->set_var('config_status_img',$incomplete);
|
||||
$setup_tpl->set_var('config_status_alt',lang('not completed'));
|
||||
$btn_config_now = $phpgw_setup->make_frm_btn_simple(
|
||||
$btn_config_now = $GLOBALS['phpgw_setup']->html->make_frm_btn_simple(
|
||||
lang('Please configure phpGroupWare for your environment'),
|
||||
'POST','config.php',
|
||||
'submit',lang('Configure Now'),
|
||||
@ -304,21 +305,21 @@
|
||||
case 10:
|
||||
$setup_tpl->set_var('config_status_img',$completed);
|
||||
$setup_tpl->set_var('config_status_alt',lang('completed'));
|
||||
$btn_edit_config = $phpgw_setup->make_frm_btn_simple(
|
||||
$btn_edit_config = $GLOBALS['phpgw_setup']->html->make_frm_btn_simple(
|
||||
lang('Configuration completed'),
|
||||
'POST','config.php',
|
||||
'submit',lang('Edit Current Configuration'),
|
||||
''
|
||||
);
|
||||
$phpgw_setup->db->query("select config_value FROM phpgw_config WHERE config_name='auth_type'");
|
||||
$phpgw_setup->db->next_record();
|
||||
if ($phpgw_setup->db->f(0) == 'ldap')
|
||||
$GLOBALS['phpgw_setup']->db->query("select config_value FROM phpgw_config WHERE config_name='auth_type'");
|
||||
$GLOBALS['phpgw_setup']->db->next_record();
|
||||
if ($GLOBALS['phpgw_setup']->db->f(0) == 'ldap')
|
||||
{
|
||||
$phpgw_setup->db->query("select config_value FROM phpgw_config WHERE config_name='ldap_host'");
|
||||
$phpgw_setup->db->next_record();
|
||||
if ($phpgw_setup->db->f(0) != '')
|
||||
$GLOBALS['phpgw_setup']->db->query("select config_value FROM phpgw_config WHERE config_name='ldap_host'");
|
||||
$GLOBALS['phpgw_setup']->db->next_record();
|
||||
if ($GLOBALS['phpgw_setup']->db->f(0) != '')
|
||||
{
|
||||
$btn_config_ldap = $phpgw_setup->make_frm_btn_simple(
|
||||
$btn_config_ldap = $GLOBALS['phpgw_setup']->html->make_frm_btn_simple(
|
||||
lang('LDAP account import/export'),
|
||||
'POST','ldap.php',
|
||||
'submit',lang('Configure Now'),
|
||||
@ -329,11 +330,11 @@
|
||||
{
|
||||
$btn_config_ldap = '';
|
||||
}
|
||||
$phpgw_setup->db->query("select config_value FROM phpgw_config WHERE config_name='webserver_url'");
|
||||
$phpgw_setup->db->next_record();
|
||||
if ($phpgw_setup->db->f(0))
|
||||
$GLOBALS['phpgw_setup']->db->query("select config_value FROM phpgw_config WHERE config_name='webserver_url'");
|
||||
$GLOBALS['phpgw_setup']->db->next_record();
|
||||
if ($GLOBALS['phpgw_setup']->db->f(0))
|
||||
{
|
||||
$link_make_accts = $phpgw_setup->make_href_link_simple(
|
||||
$link_make_accts = $GLOBALS['phpgw_setup']->html->make_href_link_simple(
|
||||
'<br>',
|
||||
'setup_demo.php',
|
||||
lang('Click Here'),
|
||||
@ -349,7 +350,7 @@
|
||||
else
|
||||
{
|
||||
$btn_config_ldap = '';
|
||||
$link_make_accts = $phpgw_setup->make_href_link_simple(
|
||||
$link_make_accts = $GLOBALS['phpgw_setup']->html->make_href_link_simple(
|
||||
'<br>',
|
||||
'setup_demo.php',
|
||||
lang('Click Here'),
|
||||
@ -370,7 +371,7 @@
|
||||
|
||||
// Lang Section
|
||||
$setup_tpl->set_var('lang_step_text',lang('Step 3 - Language Management'));
|
||||
$GLOBALS['phpgw_info']['setup']['stage']['lang'] = $phpgw_setup->check_lang();
|
||||
$GLOBALS['phpgw_info']['setup']['stage']['lang'] = $GLOBALS['phpgw_setup']->detection->check_lang();
|
||||
|
||||
// begin DEBUG code
|
||||
//$GLOBALS['phpgw_info']['setup']['stage']['lang'] = 0;
|
||||
@ -381,7 +382,7 @@
|
||||
case 1:
|
||||
$setup_tpl->set_var('lang_status_img',$incomplete);
|
||||
$setup_tpl->set_var('lang_status_alt','not completed');
|
||||
$btn_install_lang = $phpgw_setup->make_frm_btn_simple(
|
||||
$btn_install_lang = $GLOBALS['phpgw_setup']->html->make_frm_btn_simple(
|
||||
lang('You do not have any languages installed. Please install one now <br>'),
|
||||
'POST','lang.php',
|
||||
'submit',lang('Install Language'),
|
||||
@ -405,7 +406,7 @@
|
||||
|
||||
$setup_tpl->set_var('lang_status_img',$completed);
|
||||
$setup_tpl->set_var('lang_status_alt','completed');
|
||||
$btn_manage_lang = $phpgw_setup->make_frm_btn_simple(
|
||||
$btn_manage_lang = $GLOBALS['phpgw_setup']->html->make_frm_btn_simple(
|
||||
lang('This stage is completed<br>') . lang('Currently installed languages: x <br>',$langs_list),
|
||||
'POST','lang.php',
|
||||
'submit',lang('Manage Languages'),
|
||||
@ -420,14 +421,14 @@
|
||||
}
|
||||
|
||||
$setup_tpl->set_var('apps_step_text',lang('Step 4 - Advanced Application Management'));
|
||||
// $GLOBALS['phpgw_info']['setup']['stage']['apps'] = $phpgw_setup->check_apps();
|
||||
// $GLOBALS['phpgw_info']['setup']['stage']['apps'] = $GLOBALS['phpgw_setup']->check_apps();
|
||||
switch($GLOBALS['phpgw_info']['setup']['stage']['db'])
|
||||
{
|
||||
case 1:
|
||||
case 10:
|
||||
$setup_tpl->set_var('apps_status_img',$completed);
|
||||
$setup_tpl->set_var('apps_status_alt',lang('completed'));
|
||||
$btn_manage_apps = $phpgw_setup->make_frm_btn_simple(
|
||||
$btn_manage_apps = $GLOBALS['phpgw_setup']->html->make_frm_btn_simple(
|
||||
lang('This stage is completed<br>'),
|
||||
'','applications.php',
|
||||
'submit',lang('Manage Applications'),
|
||||
@ -441,7 +442,12 @@
|
||||
break;
|
||||
}
|
||||
|
||||
$phpgw_setup->show_header($GLOBALS['phpgw_info']['setup']['header_msg'],False,'config',$GLOBALS['ConfigDomain'] . '(' . $GLOBALS['phpgw_domain'][$GLOBALS['ConfigDomain']]['db_type'] . ')');
|
||||
$GLOBALS['phpgw_setup']->html->show_header(
|
||||
$GLOBALS['phpgw_info']['setup']['header_msg'],
|
||||
False,
|
||||
'config',
|
||||
$GLOBALS['ConfigDomain'] . '(' . $GLOBALS['phpgw_domain'][$GLOBALS['ConfigDomain']]['db_type'] . ')'
|
||||
);
|
||||
$setup_tpl->pparse('out','T_setup_main');
|
||||
$phpgw_setup->show_footer();
|
||||
$GLOBALS['phpgw_setup']->html->show_footer();
|
||||
?>
|
||||
|
@ -23,12 +23,12 @@
|
||||
include('./inc/functions.inc.php');
|
||||
// Authorize the user to use setup app and load the database
|
||||
// Does not return unless user is authorized
|
||||
if (!$phpgw_setup->auth('Config'))
|
||||
if (!$GLOBALS['phpgw_setup']->auth('Config'))
|
||||
{
|
||||
Header('Location: index.php');
|
||||
exit;
|
||||
}
|
||||
$phpgw_setup->loaddb();
|
||||
$GLOBALS['phpgw_setup']->loaddb();
|
||||
|
||||
include(PHPGW_API_INC.'/class.common.inc.php');
|
||||
$common = new common;
|
||||
@ -45,10 +45,10 @@
|
||||
$submit = True;
|
||||
}
|
||||
|
||||
$setup_info_temp = $phpgw_setup->get_versions();
|
||||
$setup_info = $phpgw_setup->get_db_versions($setup_info_temp);
|
||||
$setup_info_temp = $GLOBALS['phpgw_setup']->detection->get_versions();
|
||||
$setup_info = $GLOBALS['phpgw_setup']->detection->get_db_versions($setup_info_temp);
|
||||
|
||||
if($phpgw_setup->alessthanb($setup_info['phpgwapi']['currentver'], '0.9.15.002'))
|
||||
if($GLOBALS['phpgw_setup']->alessthanb($setup_info['phpgwapi']['currentver'], '0.9.15.002'))
|
||||
{
|
||||
$langtbl = 'lang';
|
||||
$langstbl = 'languages';
|
||||
@ -63,12 +63,12 @@
|
||||
{
|
||||
$lang_selected = $HTTP_POST_VARS['lang_selected'];
|
||||
$upgrademethod = $HTTP_POST_VARS['upgrademethod'];
|
||||
$phpgw_setup->db->transaction_begin();
|
||||
$GLOBALS['phpgw_setup']->db->transaction_begin();
|
||||
if (count($lang_selected))
|
||||
{
|
||||
if ($upgrademethod == 'dumpold')
|
||||
{
|
||||
$phpgw_setup->db->query('DELETE FROM '.$langtbl,__LINE__,__FILE__);
|
||||
$GLOBALS['phpgw_setup']->db->query('DELETE FROM '.$langtbl,__LINE__,__FILE__);
|
||||
//echo '<br>Test: dumpold';
|
||||
}
|
||||
while (list($null,$lang) = each($lang_selected))
|
||||
@ -78,10 +78,10 @@
|
||||
if ($upgrademethod == 'addonlynew')
|
||||
{
|
||||
//echo "<br>Test: addonlynew - select count(*) from lang where lang='$lang'";
|
||||
$phpgw_setup->db->query("SELECT COUNT(*) FROM $langtbl WHERE lang='$lang'",__LINE__,__FILE__);
|
||||
$phpgw_setup->db->next_record();
|
||||
$GLOBALS['phpgw_setup']->db->query("SELECT COUNT(*) FROM $langtbl WHERE lang='$lang'",__LINE__,__FILE__);
|
||||
$GLOBALS['phpgw_setup']->db->next_record();
|
||||
|
||||
if ($phpgw_setup->db->f(0) == 0)
|
||||
if ($GLOBALS['phpgw_setup']->db->f(0) == 0)
|
||||
{
|
||||
//echo '<br>Test: addonlynew - True';
|
||||
$addlang = True;
|
||||
@ -90,15 +90,15 @@
|
||||
if (($addlang && $upgrademethod == 'addonlynew') || ($upgrademethod != 'addonlynew'))
|
||||
{
|
||||
//echo '<br>Test: loop above file()';
|
||||
$setup_info = $phpgw_setup->get_versions();
|
||||
$setup_info = $phpgw_setup->get_db_versions($setup_info);
|
||||
$setup_info = $GLOBALS['phpgw_setup']->detection->get_versions();
|
||||
$setup_info = $GLOBALS['phpgw_setup']->detection->get_db_versions($setup_info);
|
||||
$raw = $raw_file = array();
|
||||
// Visit each app/setup dir, look for a lang file
|
||||
while (list($key,$app) = each($setup_info))
|
||||
{
|
||||
$appfile = PHPGW_SERVER_ROOT . SEP . $app['name'] . SEP . 'setup' . SEP . 'phpgw_' . strtolower($lang) . '.lang';
|
||||
//echo '<br>Checking in: ' . $app['name'];
|
||||
if($phpgw_setup->app_registered($app['name']) && file_exists($appfile))
|
||||
if($GLOBALS['phpgw_setup']->app_registered($app['name']) && file_exists($appfile))
|
||||
{
|
||||
//echo '<br>Including: ' . $appfile;
|
||||
$raw[] = file($appfile);
|
||||
@ -110,21 +110,22 @@
|
||||
while (list($_null,$line) = @each($raw_file))
|
||||
{
|
||||
$addit = False;
|
||||
list($message_id,$app_name,$phpgw_setup->db_lang,$content) = explode("\t",$line);
|
||||
$message_id = $phpgw_setup->db->db_addslashes(chop($message_id));
|
||||
list($message_id,$app_name,$GLOBALS['phpgw_setup']->db_lang,$content) = explode("\t",$line);
|
||||
$message_id = $GLOBALS['phpgw_setup']->db->db_addslashes(chop($message_id));
|
||||
//echo '<br>APPNAME:' . $app_name . ' PHRASE:' . $message_id;
|
||||
$app_name = $phpgw_setup->db->db_addslashes(chop($app_name));
|
||||
$phpgw_setup->db_lang = $phpgw_setup->db->db_addslashes(chop($phpgw_setup->db_lang));
|
||||
$content = $phpgw_setup->db->db_addslashes(chop($content));
|
||||
$app_name = $GLOBALS['phpgw_setup']->db->db_addslashes(chop($app_name));
|
||||
$GLOBALS['phpgw_setup']->db_lang = $GLOBALS['phpgw_setup']->db->db_addslashes(chop($GLOBALS['phpgw_setup']->db_lang));
|
||||
$content = $GLOBALS['phpgw_setup']->db->db_addslashes(chop($content));
|
||||
if ($upgrademethod == 'addmissing')
|
||||
{
|
||||
//echo '<br>Test: addmissing';
|
||||
$phpgw_setup->db->query("SELECT COUNT(*) FROM $langtbl WHERE message_id='$message_id' and lang='$phpgw_setup->db_lang'",__LINE__,__FILE__);
|
||||
$phpgw_setup->db->next_record();
|
||||
$GLOBALS['phpgw_setup']->db->query("SELECT COUNT(*) FROM $langtbl WHERE message_id='$message_id' and lang='"
|
||||
. $GLOBALS['phpgw_setup']->db_lang . "'",__LINE__,__FILE__);
|
||||
$GLOBALS['phpgw_setup']->db->next_record();
|
||||
|
||||
if ($phpgw_setup->db->f(0) == 0)
|
||||
if ($GLOBALS['phpgw_setup']->db->f(0) == 0)
|
||||
{
|
||||
//echo '<br>Test: addmissing - True - Total: ' . $phpgw_setup->db->f(0);
|
||||
//echo '<br>Test: addmissing - True - Total: ' . $GLOBALS['phpgw_setup']->db->f(0);
|
||||
$addit = True;
|
||||
}
|
||||
}
|
||||
@ -133,15 +134,16 @@
|
||||
{
|
||||
if($message_id && $content)
|
||||
{
|
||||
// echo "<br>adding - insert into $langtbl(message_id,app_name,lang,content) values ('$message_id','$app_name','$phpgw_setup->db_lang','$content')";
|
||||
$phpgw_setup->db->query("INSERT into $langtbl(message_id,app_name,lang,content) VALUES ('$message_id','$app_name','$phpgw_setup->db_lang','$content')",__LINE__,__FILE__);
|
||||
// echo "<br>adding - insert into $langtbl(message_id,app_name,lang,content) values ('$message_id','$app_name','" . $GLOBALS['phpgw_setup']->db_lang . "','$content')";
|
||||
$GLOBALS['phpgw_setup']->db->query("INSERT into $langtbl(message_id,app_name,lang,content) VALUES ('$message_id','$app_name','"
|
||||
. $GLOBALS['phpgw_setup']->db_lang . "','$content')",__LINE__,__FILE__);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$phpgw_setup->db->transaction_commit();
|
||||
$GLOBALS['phpgw_setup']->db->transaction_commit();
|
||||
}
|
||||
|
||||
if(!@$GLOBALS['included'])
|
||||
@ -160,7 +162,7 @@
|
||||
|
||||
if (!@$GLOBALS['included'])
|
||||
{
|
||||
$tpl_root = $phpgw_setup->setup_tpl_dir('setup');
|
||||
$tpl_root = $GLOBALS['phpgw_setup']->html->setup_tpl_dir('setup');
|
||||
$setup_tpl = CreateObject('phpgwapi.Template',$tpl_root);
|
||||
$setup_tpl->set_file(array(
|
||||
'T_head' => 'head.tpl',
|
||||
@ -180,12 +182,12 @@
|
||||
|
||||
$select_box_desc = lang('Select which languages you would like to use');
|
||||
$select_box_langs = '';
|
||||
$phpgw_setup->db->query("select lang_id,lang_name from $langstbl where available='Yes'");
|
||||
while ($phpgw_setup->db->next_record())
|
||||
$GLOBALS['phpgw_setup']->db->query("select lang_id,lang_name from $langstbl where available='Yes'");
|
||||
while ($GLOBALS['phpgw_setup']->db->next_record())
|
||||
{
|
||||
$select_box_langs .=
|
||||
'<option value="' . $phpgw_setup->db->f('lang_id') . '">'
|
||||
. $phpgw_setup->db->f('lang_name') . '</option>'
|
||||
'<option value="' . $GLOBALS['phpgw_setup']->db->f('lang_id') . '">'
|
||||
. $GLOBALS['phpgw_setup']->db->f('lang_name') . '</option>'
|
||||
."\n";
|
||||
}
|
||||
|
||||
@ -220,9 +222,9 @@
|
||||
$setup_tpl->set_var('lang_cancel',lang('cancel'));
|
||||
|
||||
$ConfigDomain = $HTTP_COOKIE_VARS['ConfigDomain'] ? $HTTP_COOKIE_VARS['ConfigDomain'] : $HTTP_POST_VARS['ConfigDomain'];
|
||||
$phpgw_setup->show_header("$stage_title",False,'config',$ConfigDomain . '(' . $phpgw_domain[$ConfigDomain]['db_type'] . ')');
|
||||
$GLOBALS['phpgw_setup']->html->show_header("$stage_title",False,'config',$ConfigDomain . '(' . $phpgw_domain[$ConfigDomain]['db_type'] . ')');
|
||||
$setup_tpl->pparse('out','T_lang_main');
|
||||
$phpgw_setup->show_footer();
|
||||
$GLOBALS['phpgw_setup']->html->show_footer();
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@ -21,7 +21,7 @@
|
||||
include('./inc/functions.inc.php');
|
||||
|
||||
// Authorize the user to use setup app and load the database
|
||||
if (!$phpgw_setup->auth('Config'))
|
||||
if (!$GLOBALS['phpgw_setup']->auth('Config'))
|
||||
{
|
||||
Header('Location: index.php');
|
||||
exit;
|
||||
@ -34,7 +34,7 @@
|
||||
exit;
|
||||
}
|
||||
|
||||
$tpl_root = $phpgw_setup->setup_tpl_dir('setup');
|
||||
$tpl_root = $GLOBALS['phpgw_setup']->html->setup_tpl_dir('setup');
|
||||
$setup_tpl = CreateObject('phpgwapi.Template',$tpl_root);
|
||||
$setup_tpl->set_file(array(
|
||||
'ldap' => 'ldap.tpl',
|
||||
@ -43,12 +43,12 @@
|
||||
'T_alert_msg' => 'msg_alert_msg.tpl'
|
||||
));
|
||||
|
||||
$phpgw_setup->show_header(lang('LDAP Config'),'','ldap',$ConfigDomain);
|
||||
$GLOBALS['phpgw_setup']->html->show_header(lang('LDAP Config'),'','ldap',$ConfigDomain);
|
||||
|
||||
if ($error)
|
||||
{
|
||||
//echo '<br><center><b>Error:</b> '.$error.'</center>';
|
||||
$phpgw_setup->show_alert_msg('Error',$error);
|
||||
$GLOBALS['phpgw_setup']->html->show_alert_msg('Error',$error);
|
||||
}
|
||||
|
||||
$setup_tpl->set_block('ldap','header','header');
|
||||
@ -73,5 +73,5 @@
|
||||
$setup_tpl->pfp('out','cancel_only');
|
||||
$setup_tpl->pfp('out','footer');
|
||||
|
||||
$phpgw_setup->show_footer();
|
||||
$GLOBALS['phpgw_setup']->html->show_footer();
|
||||
?>
|
||||
|
@ -21,7 +21,7 @@
|
||||
include('./inc/functions.inc.php');
|
||||
|
||||
// Authorize the user to use setup app and load the database
|
||||
if (!$phpgw_setup->auth('Config'))
|
||||
if (!$GLOBALS['phpgw_setup']->auth('Config'))
|
||||
{
|
||||
Header('Location: index.php');
|
||||
exit;
|
||||
@ -39,10 +39,10 @@
|
||||
$phpgw->common = CreateObject('phpgwapi.common');
|
||||
|
||||
$common = $phpgw->common;
|
||||
$phpgw_setup->loaddb();
|
||||
$phpgw->db = $phpgw_setup->db;
|
||||
$GLOBALS['phpgw_setup']->loaddb();
|
||||
$phpgw->db = $GLOBALS['phpgw_setup']->db;
|
||||
|
||||
$tpl_root = $phpgw_setup->setup_tpl_dir('setup');
|
||||
$tpl_root = $GLOBALS['phpgw_setup']->html->setup_tpl_dir('setup');
|
||||
$setup_tpl = CreateObject('phpgwapi.Template',$tpl_root);
|
||||
$setup_tpl->set_file(array(
|
||||
'ldap' => 'ldap.tpl',
|
||||
@ -51,54 +51,54 @@
|
||||
'T_alert_msg' => 'msg_alert_msg.tpl'
|
||||
));
|
||||
|
||||
$phpgw_info['server']['account_repository'] = 'ldap';
|
||||
|
||||
$phpgw->accounts = CreateObject('phpgwapi.accounts');
|
||||
$acct = $phpgw->accounts;
|
||||
|
||||
$phpgw_setup->db->query("select config_name,config_value from phpgw_config where config_name like 'ldap%'",__LINE__,__FILE__);
|
||||
while ($phpgw_setup->db->next_record())
|
||||
$GLOBALS['phpgw_setup']->db->query("SELECT config_name,config_value FROM phpgw_config WHERE config_name LIKE 'ldap%'",__LINE__,__FILE__);
|
||||
while ($GLOBALS['phpgw_setup']->db->next_record())
|
||||
{
|
||||
$config[$phpgw_setup->db->f('config_name')] = $phpgw_setup->db->f('config_value');
|
||||
$config[$GLOBALS['phpgw_setup']->db->f('config_name')] = $GLOBALS['phpgw_setup']->db->f('config_value');
|
||||
}
|
||||
$phpgw_info['server']['ldap_host'] = $config['ldap_host'];
|
||||
$phpgw_info['server']['ldap_context'] = $config['ldap_context'];
|
||||
$phpgw_info['server']['ldap_group_context'] = $config['ldap_group_context'];
|
||||
$phpgw_info['server']['ldap_root_dn'] = $config['ldap_root_dn'];
|
||||
$phpgw_info['server']['ldap_root_pw'] = $config['ldap_root_pw'];
|
||||
$phpgw_info["server"]['ldap_account_home'] = $config['ldap_account_home'];
|
||||
$phpgw_info["server"]['ldap_account_shell'] = $config['ldap_account_shell'];
|
||||
$phpgw_info['server']['ldap_account_home'] = $config['ldap_account_home'];
|
||||
$phpgw_info['server']['ldap_account_shell'] = $config['ldap_account_shell'];
|
||||
$phpgw_info['server']['ldap_extra_attributes'] = $config['ldap_extra_attributes'];
|
||||
|
||||
$phpgw_info['server']['account_repository'] = 'ldap';
|
||||
|
||||
$phpgw->accounts = CreateObject('phpgwapi.accounts');
|
||||
$acct = $phpgw->accounts;
|
||||
|
||||
// First, see if we can connect to the LDAP server, if not send `em back to config.php with an
|
||||
// error message.
|
||||
|
||||
// connect to ldap server
|
||||
if (! $ldap = $common->ldapConnect())
|
||||
if(!$ldap = $common->ldapConnect())
|
||||
{
|
||||
$noldapconnection = True;
|
||||
}
|
||||
|
||||
if ($noldapconnection)
|
||||
if($noldapconnection)
|
||||
{
|
||||
Header('Location: config.php?error=badldapconnection');
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM phpgw_accounts WHERE account_type='u'";
|
||||
$phpgw_setup->db->query($sql,__LINE__,__FILE__);
|
||||
while($phpgw_setup->db->next_record())
|
||||
$GLOBALS['phpgw_setup']->db->query($sql,__LINE__,__FILE__);
|
||||
while($GLOBALS['phpgw_setup']->db->next_record())
|
||||
{
|
||||
$i = $phpgw_setup->db->f('account_id');
|
||||
$account_info[$i]['account_id'] = $phpgw_setup->db->f('account_id');
|
||||
$account_info[$i]['account_lid'] = $phpgw_setup->db->f('account_lid');
|
||||
$account_info[$i]['account_firstname'] = $phpgw_setup->db->f('account_firstname');
|
||||
$account_info[$i]['account_lastname'] = $phpgw_setup->db->f('account_lastname');
|
||||
$account_info[$i]['account_status'] = $phpgw_setup->db->f('account_status');
|
||||
$account_info[$i]['account_expires'] = $phpgw_setup->db->f('account_expires');
|
||||
$i = $GLOBALS['phpgw_setup']->db->f('account_id');
|
||||
$account_info[$i]['account_id'] = $GLOBALS['phpgw_setup']->db->f('account_id');
|
||||
$account_info[$i]['account_lid'] = $GLOBALS['phpgw_setup']->db->f('account_lid');
|
||||
$account_info[$i]['account_firstname'] = $GLOBALS['phpgw_setup']->db->f('account_firstname');
|
||||
$account_info[$i]['account_lastname'] = $GLOBALS['phpgw_setup']->db->f('account_lastname');
|
||||
$account_info[$i]['account_status'] = $GLOBALS['phpgw_setup']->db->f('account_status');
|
||||
$account_info[$i]['account_expires'] = $GLOBALS['phpgw_setup']->db->f('account_expires');
|
||||
}
|
||||
|
||||
while (list($key,$data) = @each($account_info))
|
||||
while(list($key,$data) = @each($account_info))
|
||||
{
|
||||
$tmp = $data['account_id'];
|
||||
$newaccount[$tmp] = $data;
|
||||
@ -106,36 +106,36 @@
|
||||
$account_info = $newaccount;
|
||||
|
||||
$sql = "SELECT * FROM phpgw_accounts WHERE account_type='g'";
|
||||
$phpgw_setup->db->query($sql,__LINE__,__FILE__);
|
||||
while($phpgw_setup->db->next_record())
|
||||
$GLOBALS['phpgw_setup']->db->query($sql,__LINE__,__FILE__);
|
||||
while($GLOBALS['phpgw_setup']->db->next_record())
|
||||
{
|
||||
$i = $phpgw_setup->db->f('account_id');
|
||||
$group_info[$i]['account_id'] = $phpgw_setup->db->f('account_id');
|
||||
$group_info[$i]['account_lid'] = $phpgw_setup->db->f('account_lid');
|
||||
$group_info[$i]['account_firstname'] = $phpgw_setup->db->f('account_firstname');
|
||||
$group_info[$i]['account_lastname'] = $phpgw_setup->db->f('account_lastname');
|
||||
$group_info[$i]['account_status'] = $phpgw_setup->db->f('account_status');
|
||||
$group_info[$i]['account_expires'] = $phpgw_setup->db->f('account_expires');
|
||||
$i = $GLOBALS['phpgw_setup']->db->f('account_id');
|
||||
$group_info[$i]['account_id'] = $GLOBALS['phpgw_setup']->db->f('account_id');
|
||||
$group_info[$i]['account_lid'] = $GLOBALS['phpgw_setup']->db->f('account_lid');
|
||||
$group_info[$i]['account_firstname'] = $GLOBALS['phpgw_setup']->db->f('account_firstname');
|
||||
$group_info[$i]['account_lastname'] = $GLOBALS['phpgw_setup']->db->f('account_lastname');
|
||||
$group_info[$i]['account_status'] = $GLOBALS['phpgw_setup']->db->f('account_status');
|
||||
$group_info[$i]['account_expires'] = $GLOBALS['phpgw_setup']->db->f('account_expires');
|
||||
}
|
||||
|
||||
while (list($key,$data) = @each($group_info))
|
||||
while(list($key,$data) = @each($group_info))
|
||||
{
|
||||
$tmp = $data['account_id'][0];
|
||||
$newgroup[$tmp] = $data;
|
||||
}
|
||||
$group_info = $newgroup;
|
||||
|
||||
if ($cancel)
|
||||
if($cancel)
|
||||
{
|
||||
Header("Location: ldap.php");
|
||||
Header('Location: ldap.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($submit)
|
||||
if($submit)
|
||||
{
|
||||
if ($ldapgroups)
|
||||
if($ldapgroups)
|
||||
{
|
||||
while (list($key,$groupid) = each($ldapgroups))
|
||||
while(list($key,$groupid) = each($ldapgroups))
|
||||
{
|
||||
$id_exist = 0;
|
||||
$thisacctid = $group_info[$groupid]['account_id'];
|
||||
@ -145,15 +145,15 @@
|
||||
$thismembers = $group_info[$groupid]['members'];
|
||||
|
||||
// Do some checks before we try to import the data to LDAP.
|
||||
if (!empty($thisacctid) && !empty($thisacctlid))
|
||||
if(!empty($thisacctid) && !empty($thisacctlid))
|
||||
{
|
||||
$groups = CreateObject('phpgwapi.accounts',intval($thisacctid));
|
||||
$groups->db = $phpgw_setup->db;
|
||||
$groups->db = $GLOBALS['phpgw_setup']->db;
|
||||
|
||||
// Check if the account is already there.
|
||||
// If so, we won't try to create it again.
|
||||
$acct_exist = $acct->name2id($thisacctlid);
|
||||
if ($acct_exist)
|
||||
if($acct_exist)
|
||||
{
|
||||
$thisacctid = $acct_exist;
|
||||
}
|
||||
@ -182,9 +182,9 @@
|
||||
}
|
||||
}
|
||||
|
||||
if ($users)
|
||||
if($users)
|
||||
{
|
||||
while (list($key,$accountid) = each($users))
|
||||
while(list($key,$accountid) = each($users))
|
||||
{
|
||||
$id_exist = 0; $acct_exist = 0;
|
||||
$thisacctid = $account_info[$accountid]['account_id'];
|
||||
@ -193,15 +193,15 @@
|
||||
$thislastname = $account_info[$accountid]['account_lastname'];
|
||||
|
||||
// Do some checks before we try to import the data.
|
||||
if (!empty($thisacctid) && !empty($thisacctlid))
|
||||
if(!empty($thisacctid) && !empty($thisacctlid))
|
||||
{
|
||||
$accounts = CreateObject('phpgwapi.accounts',intval($thisacctid));
|
||||
$accounts->db = $phpgw_setup->db;
|
||||
$accounts->db = $GLOBALS['phpgw_setup']->db;
|
||||
|
||||
// Check if the account is already there.
|
||||
// If so, we won't try to create it again.
|
||||
$acct_exist = $acct->name2id($thisacctlid);
|
||||
if ($acct_exist)
|
||||
if($acct_exist)
|
||||
{
|
||||
$thisacctid = $acct_exist;
|
||||
}
|
||||
@ -230,19 +230,19 @@
|
||||
$setup_complete = True;
|
||||
}
|
||||
|
||||
$phpgw_setup->show_header('LDAP Export','','ldapexport',$ConfigDomain);
|
||||
$GLOBALS['phpgw_setup']->html->show_header('LDAP Export','','ldapexport',$ConfigDomain);
|
||||
|
||||
if ($error)
|
||||
if($error)
|
||||
{
|
||||
//echo '<br><center><b>Error:</b> '.$error.'</center>';
|
||||
$phpgw_setup->show_alert_msg('Error',$error);
|
||||
$GLOBALS['phpgw_setup']->html->show_alert_msg('Error',$error);
|
||||
}
|
||||
|
||||
if ($setup_complete)
|
||||
if($setup_complete)
|
||||
{
|
||||
echo lang('<br><center>Export has been completed! You will need to set the user passwords manually.</center>');
|
||||
echo lang('<br><center>Click <a href="index.php">here</a> to return to setup </center>');
|
||||
$phpgw_setup->show_footer();
|
||||
$GLOBALS['phpgw_setup']->html->show_footer();
|
||||
exit;
|
||||
}
|
||||
|
||||
@ -254,7 +254,7 @@
|
||||
$setup_tpl->set_block('ldap','submit','submit');
|
||||
$setup_tpl->set_block('ldap','footer','footer');
|
||||
|
||||
while (list($key,$account) = @each($account_info))
|
||||
while(list($key,$account) = @each($account_info))
|
||||
{
|
||||
$user_list .= '<option value="' . $account['account_id'] . '">'
|
||||
. $common->display_fullname($account['account_lid'],$account['account_firstname'],$account['account_lastname'])
|
||||
@ -262,14 +262,14 @@
|
||||
}
|
||||
|
||||
@reset($account_info);
|
||||
while (list($key,$account) = @each($account_info))
|
||||
while(list($key,$account) = @each($account_info))
|
||||
{
|
||||
$admin_list .= '<option value="' . $account['account_id'] . '">'
|
||||
. $common->display_fullname($account['account_lid'],$account['account_firstname'],$account['account_lastname'])
|
||||
. '</option>';
|
||||
}
|
||||
|
||||
while (list($key,$group) = @each($group_info))
|
||||
while(list($key,$group) = @each($group_info))
|
||||
{
|
||||
$group_list .= '<option value="' . $group['account_id'] . '">'
|
||||
. $group['account_lid']
|
||||
@ -294,11 +294,12 @@
|
||||
{
|
||||
$setup_tpl->pfp('out','user_list');
|
||||
}
|
||||
if ($group_info)
|
||||
if($group_info)
|
||||
{
|
||||
$setup_tpl->pfp('out','group_list');
|
||||
}
|
||||
$setup_tpl->pfp('out','submit');
|
||||
$setup_tpl->pfp('out','footer');
|
||||
$phpgw_setup->show_footer();
|
||||
|
||||
$GLOBALS['phpgw_setup']->html->show_footer();
|
||||
?>
|
||||
|
@ -21,7 +21,7 @@
|
||||
include('./inc/functions.inc.php');
|
||||
|
||||
// Authorize the user to use setup app and load the database
|
||||
if (!$phpgw_setup->auth('Config'))
|
||||
if (!$GLOBALS['phpgw_setup']->auth('Config'))
|
||||
{
|
||||
Header('Location: index.php');
|
||||
exit;
|
||||
@ -39,10 +39,10 @@
|
||||
$phpgw->common = CreateObject('phpgwapi.common');
|
||||
|
||||
$common = $phpgw->common;
|
||||
$phpgw_setup->loaddb();
|
||||
$phpgw->db = $phpgw_setup->db;
|
||||
$GLOBALS['phpgw_setup']->loaddb();
|
||||
$phpgw->db = $GLOBALS['phpgw_setup']->db;
|
||||
|
||||
$tpl_root = $phpgw_setup->setup_tpl_dir('setup');
|
||||
$tpl_root = $GLOBALS['phpgw_setup']->html->setup_tpl_dir('setup');
|
||||
$setup_tpl = CreateObject('phpgwapi.Template',$tpl_root);
|
||||
$setup_tpl->set_file(array(
|
||||
'ldap' => 'ldap.tpl',
|
||||
@ -56,10 +56,10 @@
|
||||
$phpgw->applications = CreateObject('phpgwapi.applications');
|
||||
$applications = $phpgw->applications;
|
||||
|
||||
$phpgw_setup->db->query("SELECT config_name,config_value FROM phpgw_config WHERE config_name LIKE 'ldap%' OR config_name='account_repository'",__LINE__,__FILE__);
|
||||
while ($phpgw_setup->db->next_record())
|
||||
$GLOBALS['phpgw_setup']->db->query("SELECT config_name,config_value FROM phpgw_config WHERE config_name LIKE 'ldap%' OR config_name='account_repository'",__LINE__,__FILE__);
|
||||
while ($GLOBALS['phpgw_setup']->db->next_record())
|
||||
{
|
||||
$config[$phpgw_setup->db->f('config_name')] = $phpgw_setup->db->f('config_value');
|
||||
$config[$GLOBALS['phpgw_setup']->db->f('config_name')] = $GLOBALS['phpgw_setup']->db->f('config_value');
|
||||
}
|
||||
$phpgw_info['server']['ldap_host'] = $config['ldap_host'];
|
||||
$phpgw_info['server']['ldap_context'] = $config['ldap_context'];
|
||||
@ -128,11 +128,11 @@
|
||||
$group_info = array();
|
||||
}
|
||||
|
||||
$phpgw_setup->db->query("SELECT app_name,app_title FROM phpgw_applications WHERE app_enabled != '0' AND app_enabled != '3' AND "
|
||||
$GLOBALS['phpgw_setup']->db->query("SELECT app_name,app_title FROM phpgw_applications WHERE app_enabled != '0' AND app_enabled != '3' AND "
|
||||
. "app_name != 'administration' ORDER BY app_title",__LINE__,__FILE__);
|
||||
while ($phpgw_setup->db->next_record())
|
||||
while ($GLOBALS['phpgw_setup']->db->next_record())
|
||||
{
|
||||
$apps[$phpgw_setup->db->f('app_name')] = $phpgw_setup->db->f('app_title');
|
||||
$apps[$GLOBALS['phpgw_setup']->db->f('app_name')] = $GLOBALS['phpgw_setup']->db->f('app_title');
|
||||
}
|
||||
|
||||
if ($cancel)
|
||||
@ -170,7 +170,7 @@
|
||||
if (!empty($thisacctid) && !empty($thisacctlid))
|
||||
{
|
||||
$accounts = CreateObject('phpgwapi.accounts',intval($thisacctid));
|
||||
$accounts->db = $phpgw_setup->db;
|
||||
$accounts->db = $GLOBALS['phpgw_setup']->db;
|
||||
|
||||
// Check if the account is already there.
|
||||
// If so, we won't try to create it again.
|
||||
@ -202,7 +202,7 @@
|
||||
// these rights. Instead, we make the user a member of the Default group
|
||||
// below.
|
||||
$acl = CreateObject('phpgwapi.acl',intval($thisacctid));
|
||||
$acl->db = $phpgw_setup->db;
|
||||
$acl->db = $GLOBALS['phpgw_setup']->db;
|
||||
$acl->read_repository();
|
||||
|
||||
// Only give them admin if we asked for them to have it.
|
||||
@ -250,7 +250,7 @@
|
||||
if (!empty($thisacctid) && !empty($thisacctlid))
|
||||
{
|
||||
$groups = CreateObject('phpgwapi.accounts',intval($thisacctid));
|
||||
$groups->db = $phpgw_setup->db;
|
||||
$groups->db = $GLOBALS['phpgw_setup']->db;
|
||||
|
||||
// Check if the account is already there.
|
||||
// If so, we won't try to create it again.
|
||||
@ -303,7 +303,7 @@
|
||||
if($tmpid)
|
||||
{
|
||||
$acl = CreateObject('phpgwapi.acl',$tmpid);
|
||||
$acl->db = $phpgw_setup->db;
|
||||
$acl->db = $GLOBALS['phpgw_setup']->db;
|
||||
$acl->account_id = intval($tmpid);
|
||||
$acl->read_repository();
|
||||
|
||||
@ -320,7 +320,7 @@
|
||||
App access is added below.
|
||||
*/
|
||||
$pref = CreateObject('phpgwapi.preferences',$tmpid);
|
||||
$pref->db = $phpgw_setup->db;
|
||||
$pref->db = $GLOBALS['phpgw_setup']->db;
|
||||
$pref->account_id = intval($tmpid);
|
||||
$pref->read_repository();
|
||||
@reset($s_apps);
|
||||
@ -334,7 +334,7 @@
|
||||
/* Now give this group some rights */
|
||||
$phpgw_info['user']['account_id'] = $thisacctid;
|
||||
$acl = CreateObject('phpgwapi.acl');
|
||||
$acl->db = $phpgw_setup->db;
|
||||
$acl->db = $GLOBALS['phpgw_setup']->db;
|
||||
$acl->account_id = intval($thisacctid);
|
||||
$acl->read_repository();
|
||||
@reset($s_apps);
|
||||
@ -352,7 +352,7 @@
|
||||
{
|
||||
/* Create the 'Default' group */
|
||||
$groups = CreateObject('phpgwapi.accounts',$defaultgroupid);
|
||||
$groups->db = $phpgw_setup->db;
|
||||
$groups->db = $GLOBALS['phpgw_setup']->db;
|
||||
|
||||
// Check if the group account is already there.
|
||||
// If so, set our group_id to that account's id for use below.
|
||||
@ -381,7 +381,7 @@
|
||||
$defaultgroupid = $acct->name2id('Default');
|
||||
|
||||
$acl = CreateObject('phpgwapi.acl',$defaultgroupid);
|
||||
$acl->db = $phpgw_setup->db;
|
||||
$acl->db = $GLOBALS['phpgw_setup']->db;
|
||||
$acl->account_id = intval($defaultgroupid);
|
||||
$acl->read_repository();
|
||||
@reset($s_apps);
|
||||
@ -396,18 +396,18 @@
|
||||
$setup_complete = True;
|
||||
}
|
||||
|
||||
$phpgw_setup->show_header('LDAP Import','','ldapimport',$ConfigDomain);
|
||||
$GLOBALS['phpgw_setup']->html->show_header('LDAP Import','','ldapimport',$ConfigDomain);
|
||||
|
||||
if ($error)
|
||||
{
|
||||
//echo '<br><center><b>Error:</b> '.$error.'</center>';
|
||||
$phpgw_setup->show_alert_msg('Error',$error);
|
||||
$GLOBALS['phpgw_setup']->html->show_alert_msg('Error',$error);
|
||||
}
|
||||
|
||||
if ($setup_complete)
|
||||
{
|
||||
echo lang('<br><center>Import has been completed! Click <a href="index.php">here</a> to return to setup </center>');
|
||||
$phpgw_setup->show_footer();
|
||||
$GLOBALS['phpgw_setup']->html->show_footer();
|
||||
exit;
|
||||
}
|
||||
|
||||
@ -476,5 +476,6 @@
|
||||
$setup_tpl->pfp('out','app_list');
|
||||
$setup_tpl->pfp('out','submit');
|
||||
$setup_tpl->pfp('out','footer');
|
||||
$phpgw_setup->show_footer();
|
||||
|
||||
$GLOBALS['phpgw_setup']->html->show_footer();
|
||||
?>
|
||||
|
@ -21,7 +21,7 @@
|
||||
include('./inc/functions.inc.php');
|
||||
|
||||
/* Authorize the user to use setup app and load the database */
|
||||
if (!$phpgw_setup->auth('Config'))
|
||||
if (!$GLOBALS['phpgw_setup']->auth('Config'))
|
||||
{
|
||||
Header('Location: index.php');
|
||||
exit;
|
||||
@ -39,10 +39,10 @@
|
||||
$phpgw->common = CreateObject('phpgwapi.common');
|
||||
|
||||
$common = $phpgw->common;
|
||||
$phpgw_setup->loaddb();
|
||||
$phpgw->db = $phpgw_setup->db;
|
||||
$GLOBALS['phpgw_setup']->loaddb();
|
||||
$phpgw->db = $GLOBALS['phpgw_setup']->db;
|
||||
|
||||
$tpl_root = $phpgw_setup->setup_tpl_dir('setup');
|
||||
$tpl_root = $GLOBALS['phpgw_setup']->html->setup_tpl_dir('setup');
|
||||
$setup_tpl = CreateObject('phpgwapi.Template',$tpl_root);
|
||||
$setup_tpl->set_file(array(
|
||||
'ldap' => 'ldap.tpl',
|
||||
@ -51,10 +51,10 @@
|
||||
'T_alert_msg' => 'msg_alert_msg.tpl'
|
||||
));
|
||||
|
||||
$phpgw_setup->db->query("SELECT config_name,config_value FROM phpgw_config WHERE config_name LIKE 'ldap%' OR config_name='account_repository'",__LINE__,__FILE__);
|
||||
while ($phpgw_setup->db->next_record())
|
||||
$GLOBALS['phpgw_setup']->db->query("SELECT config_name,config_value FROM phpgw_config WHERE config_name LIKE 'ldap%' OR config_name='account_repository'",__LINE__,__FILE__);
|
||||
while ($GLOBALS['phpgw_setup']->db->next_record())
|
||||
{
|
||||
$config[$phpgw_setup->db->f('config_name')] = $phpgw_setup->db->f('config_value');
|
||||
$config[$GLOBALS['phpgw_setup']->db->f('config_name')] = $GLOBALS['phpgw_setup']->db->f('config_value');
|
||||
}
|
||||
$phpgw_info['server']['ldap_host'] = $config['ldap_host'];
|
||||
$phpgw_info['server']['ldap_context'] = $config['ldap_context'];
|
||||
@ -110,11 +110,11 @@
|
||||
$group_info = array();
|
||||
}
|
||||
|
||||
$phpgw_setup->db->query("SELECT app_name,app_title FROM phpgw_applications WHERE app_enabled != '0' AND app_enabled != '3' AND "
|
||||
$GLOBALS['phpgw_setup']->db->query("SELECT app_name,app_title FROM phpgw_applications WHERE app_enabled != '0' AND app_enabled != '3' AND "
|
||||
. "app_name != 'administration' ORDER BY app_title",__LINE__,__FILE__);
|
||||
while ($phpgw_setup->db->next_record())
|
||||
while ($GLOBALS['phpgw_setup']->db->next_record())
|
||||
{
|
||||
$apps[$phpgw_setup->db->f('app_name')] = $phpgw_setup->db->f('app_title');
|
||||
$apps[$GLOBALS['phpgw_setup']->db->f('app_name')] = $GLOBALS['phpgw_setup']->db->f('app_title');
|
||||
}
|
||||
|
||||
if ($cancel)
|
||||
@ -123,16 +123,16 @@
|
||||
exit;
|
||||
}
|
||||
|
||||
$phpgw_setup->show_header('LDAP Modify','','ldapmodify',$ConfigDomain);
|
||||
$GLOBALS['phpgw_setup']->html->show_header('LDAP Modify','','ldapmodify',$ConfigDomain);
|
||||
|
||||
if ($submit)
|
||||
{
|
||||
$acl = CreateObject('phpgwapi.acl');
|
||||
$acl->db = $phpgw_setup->db;
|
||||
$acl->db = $GLOBALS['phpgw_setup']->db;
|
||||
if ($ldapgroups)
|
||||
{
|
||||
$groups = CreateObject('phpgwapi.accounts');
|
||||
$groups->db = $phpgw_setup->db;
|
||||
$groups->db = $GLOBALS['phpgw_setup']->db;
|
||||
while (list($key,$groupid) = each($ldapgroups))
|
||||
{
|
||||
$id_exist = 0;
|
||||
@ -243,7 +243,7 @@
|
||||
if($users)
|
||||
{
|
||||
$accounts = CreateObject('phpgwapi.accounts');
|
||||
$accounts->db = $phpgw_setup->db;
|
||||
$accounts->db = $GLOBALS['phpgw_setup']->db;
|
||||
while (list($key,$id) = each($users))
|
||||
{
|
||||
$id_exist = 0;
|
||||
@ -343,13 +343,13 @@
|
||||
if ($error)
|
||||
{
|
||||
/* echo '<br><center><b>Error:</b> '.$error.'</center>'; */
|
||||
$phpgw_setup->show_alert_msg('Error',$error);
|
||||
$GLOBALS['phpgw_setup']->html->show_alert_msg('Error',$error);
|
||||
}
|
||||
|
||||
if ($setup_complete)
|
||||
{
|
||||
echo lang('<br><center>Modifications have been completed! Click <a href="index.php">here</a> to return to setup </center>');
|
||||
$phpgw_setup->show_footer();
|
||||
$GLOBALS['phpgw_setup']->html->show_footer();
|
||||
exit;
|
||||
}
|
||||
|
||||
@ -411,5 +411,6 @@
|
||||
$setup_tpl->pfp('out','app_list');
|
||||
$setup_tpl->pfp('out','submit');
|
||||
$setup_tpl->pfp('out','footer');
|
||||
$phpgw_setup->show_footer();
|
||||
|
||||
$GLOBALS['phpgw_setup']->html->show_footer();
|
||||
?>
|
||||
|
@ -11,7 +11,8 @@
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
$phpgw_info['flags'] = array(
|
||||
$phpgw_info = array();
|
||||
$GLOBALS['phpgw_info']['flags'] = array(
|
||||
'nocachecontrol' => True,
|
||||
'noheader' => True,
|
||||
'nonavbar' => True,
|
||||
@ -21,7 +22,7 @@
|
||||
include('./inc/functions.inc.php');
|
||||
|
||||
include('../phpgwapi/setup/setup.inc.php');
|
||||
$phpgw_info['server']['versions']['current_header'] = $setup_info['phpgwapi']['versions']['current_header'];
|
||||
$GLOBALS['phpgw_info']['server']['versions']['current_header'] = $setup_info['phpgwapi']['versions']['current_header'];
|
||||
unset($setup_info);
|
||||
#include('../version.inc.php');
|
||||
|
||||
@ -38,17 +39,17 @@
|
||||
|
||||
if ($errors)
|
||||
{
|
||||
$GLOBALS['phpgw_setup']->show_header('Error',True);
|
||||
$GLOBALS['phpgw_setup']->html->show_header('Error',True);
|
||||
echo $errors;
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/* authentication phase */
|
||||
$phpgw_info['setup']['stage']['header'] = $phpgw_setup->check_header();
|
||||
$GLOBALS['phpgw_info']['setup']['stage']['header'] = $GLOBALS['phpgw_setup']->detection->check_header();
|
||||
|
||||
// added these to let the app work, need to templatize still
|
||||
$tpl_root = $phpgw_setup->setup_tpl_dir('setup');
|
||||
$tpl_root = $GLOBALS['phpgw_setup']->html->setup_tpl_dir('setup');
|
||||
$setup_tpl = CreateObject('phpgwapi.Template',$tpl_root);
|
||||
$setup_tpl->set_file(array(
|
||||
'T_head' => 'head.tpl',
|
||||
@ -62,36 +63,36 @@
|
||||
$setup_tpl->set_block('T_login_stage_header','B_multi_domain','V_multi_domain');
|
||||
$setup_tpl->set_block('T_login_stage_header','B_single_domain','V_single_domain');
|
||||
|
||||
switch($phpgw_info['setup']['stage']['header'])
|
||||
switch($GLOBALS['phpgw_info']['setup']['stage']['header'])
|
||||
{
|
||||
case '1':
|
||||
$phpgw_info['setup']['HeaderFormMSG'] = 'Create your header.inc.php';
|
||||
$phpgw_info['setup']['PageMSG'] = 'You have not created your header.inc.php yet!<br> You can create it now.';
|
||||
$GLOBALS['phpgw_info']['setup']['HeaderFormMSG'] = 'Create your header.inc.php';
|
||||
$GLOBALS['phpgw_info']['setup']['PageMSG'] = 'You have not created your header.inc.php yet!<br> You can create it now.';
|
||||
break;
|
||||
case '2':
|
||||
$phpgw_info['setup']['HeaderFormMSG'] = 'Your header admin password is NOT set. Please set it now!';
|
||||
$phpgw_info['setup']['PageMSG'] = 'Your header admin password is NOT set. Please set it now!';
|
||||
$GLOBALS['phpgw_info']['setup']['HeaderFormMSG'] = 'Your header admin password is NOT set. Please set it now!';
|
||||
$GLOBALS['phpgw_info']['setup']['PageMSG'] = 'Your header admin password is NOT set. Please set it now!';
|
||||
break;
|
||||
case '3':
|
||||
$phpgw_info['setup']['HeaderFormMSG'] = 'Your header.inc.php needs upgrading.';
|
||||
$phpgw_info['setup']['PageMSG'] = 'Your header.inc.php needs upgrading.<br><blink><font color=CC0000><b>WARNING!</b></font></blink><br>If you are using virtual domain support, this will <b>NOT</b> copy those domains over. You will need to do this manually, <b>MAKE BACKUPS!</b>';
|
||||
$phpgw_info['setup']['HeaderLoginMSG'] = 'Your header.inc.php needs upgrading.';
|
||||
if (!$phpgw_setup->auth('Header'))
|
||||
$GLOBALS['phpgw_info']['setup']['HeaderFormMSG'] = 'Your header.inc.php needs upgrading.';
|
||||
$GLOBALS['phpgw_info']['setup']['PageMSG'] = 'Your header.inc.php needs upgrading.<br><blink><font color=CC0000><b>WARNING!</b></font></blink><br>If you are using virtual domain support, this will <b>NOT</b> copy those domains over. You will need to do this manually, <b>MAKE BACKUPS!</b>';
|
||||
$GLOBALS['phpgw_info']['setup']['HeaderLoginMSG'] = 'Your header.inc.php needs upgrading.';
|
||||
if (!$GLOBALS['phpgw_setup']->auth('Header'))
|
||||
{
|
||||
$phpgw_setup->show_header('Please login',True);
|
||||
$phpgw_setup->login_form();
|
||||
$GLOBALS['phpgw_setup']->html->show_header('Please login',True);
|
||||
$GLOBALS['phpgw_setup']->html->login_form();
|
||||
exit;
|
||||
}
|
||||
break;
|
||||
case '10':
|
||||
if (!$phpgw_setup->auth('Header'))
|
||||
if (!$GLOBALS['phpgw_setup']->auth('Header'))
|
||||
{
|
||||
$phpgw_setup->show_header('Please login',True);
|
||||
$phpgw_setup->login_form();
|
||||
$GLOBALS['phpgw_setup']->html->show_header('Please login',True);
|
||||
$GLOBALS['phpgw_setup']->html->login_form();
|
||||
exit;
|
||||
}
|
||||
$phpgw_info['setup']['HeaderFormMSG'] = 'Edit your header.inc.php';
|
||||
$phpgw_info['setup']['PageMSG'] = 'Edit your existing header.inc.php';
|
||||
$GLOBALS['phpgw_info']['setup']['HeaderFormMSG'] = 'Edit your header.inc.php';
|
||||
$GLOBALS['phpgw_info']['setup']['PageMSG'] = 'Edit your existing header.inc.php';
|
||||
break;
|
||||
}
|
||||
|
||||
@ -104,15 +105,15 @@
|
||||
header('Content-type: application/octet-stream');
|
||||
header('Pragma: no-cache');
|
||||
header('Expires: 0');
|
||||
$newheader = $phpgw_setup->generate_header();
|
||||
$newheader = $GLOBALS['phpgw_setup']->html->generate_header();
|
||||
echo $newheader;
|
||||
break;
|
||||
case 'view':
|
||||
check_form_values();
|
||||
$header_template = CreateObject('phpgwapi.Template','../');
|
||||
$phpgw_setup->show_header('Generated header.inc.php', False, 'header');
|
||||
$GLOBALS['phpgw_setup']->html->show_header('Generated header.inc.php', False, 'header');
|
||||
echo '<br>Save this text as contents of your header.inc.php<br><hr>';
|
||||
$newheader = $phpgw_setup->generate_header();
|
||||
$newheader = $GLOBALS['phpgw_setup']->html->generate_header();
|
||||
echo '<pre>';
|
||||
echo htmlentities($newheader);
|
||||
echo '</pre><hr>';
|
||||
@ -128,11 +129,11 @@
|
||||
$header_template = CreateObject('phpgwapi.Template','../');
|
||||
if(is_writeable ('../header.inc.php')|| (!file_exists ('../header.inc.php') && is_writeable ('../')))
|
||||
{
|
||||
$newheader = $phpgw_setup->generate_header();
|
||||
$newheader = $GLOBALS['phpgw_setup']->html->generate_header();
|
||||
$fsetup = fopen('../header.inc.php','wb');
|
||||
fwrite($fsetup,$newheader);
|
||||
fclose($fsetup);
|
||||
$phpgw_setup->show_header('Saved header.inc.php', False, 'header');
|
||||
$GLOBALS['phpgw_setup']->html->show_header('Saved header.inc.php', False, 'header');
|
||||
echo '<form action="index.php" method=post>';
|
||||
echo '<br>Created header.inc.php! ';
|
||||
echo '<input type=hidden name="FormLogout" value="header">';
|
||||
@ -143,15 +144,15 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
$phpgw_setup->show_header('Error generating header.inc.php', False, 'header');
|
||||
$GLOBALS['phpgw_setup']->html->show_header('Error generating header.inc.php', False, 'header');
|
||||
echo 'Could not open header.inc.php for writing!<br>' . "\n";
|
||||
echo 'Please check read/write permissions on directories or back up and use another option.<br>';
|
||||
echo '</td></tr></table></body></html>';
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$phpgw_setup->show_header($phpgw_info['setup']['HeaderFormMSG'], False, 'header');
|
||||
echo $phpgw_info['setup']['PageMSG'];
|
||||
$GLOBALS['phpgw_setup']->html->show_header($GLOBALS['phpgw_info']['setup']['HeaderFormMSG'], False, 'header');
|
||||
echo $GLOBALS['phpgw_info']['setup']['PageMSG'];
|
||||
/*
|
||||
echo '<table border="0" width="100%" cellspacing="0" cellpadding="2">';
|
||||
echo ' <tr><td align="center" WIDTH="20%" bgcolor="486591" colspan=2><font color="fefefe">Analysis</td></tr>';
|
||||
@ -229,7 +230,7 @@
|
||||
if(file_exists('../header.inc.php') && is_file('../header.inc.php'))
|
||||
{
|
||||
echo 'Found existing configuration file. Loading settings from the file...<br>' . "\n";
|
||||
$phpgw_info['flags']['noapi'] = True;
|
||||
$GLOBALS['phpgw_info']['flags']['noapi'] = True;
|
||||
include('../header.inc.php');
|
||||
$no_guess = true;
|
||||
/* This code makes sure the newer multi-domain supporting header.inc.php is being used */
|
||||
@ -240,56 +241,56 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($phpgw_info['server']['header_version'] != $phpgw_info['server']['current_header_version'])
|
||||
if ($GLOBALS['phpgw_info']['server']['header_version'] != $GLOBALS['phpgw_info']['server']['current_header_version'])
|
||||
{
|
||||
echo 'Your using an old header.inc.php version...<br>' . "\n";
|
||||
echo 'Importing old settings into the new format....<br>' . "\n";
|
||||
}
|
||||
reset($phpgw_domain);
|
||||
$default_domain = each($phpgw_domain);
|
||||
$phpgw_info['server']['default_domain'] = $default_domain[0];
|
||||
$GLOBALS['phpgw_info']['server']['default_domain'] = $default_domain[0];
|
||||
unset ($default_domain); // we kill this for security reasons
|
||||
$phpgw_info['server']['db_host'] = $phpgw_domain[$phpgw_info['server']['default_domain']]['db_host'];
|
||||
$phpgw_info['server']['db_name'] = $phpgw_domain[$phpgw_info['server']['default_domain']]['db_name'];
|
||||
$phpgw_info['server']['db_user'] = $phpgw_domain[$phpgw_info['server']['default_domain']]['db_user'];
|
||||
$phpgw_info['server']['db_pass'] = $phpgw_domain[$phpgw_info['server']['default_domain']]['db_pass'];
|
||||
$phpgw_info['server']['db_type'] = $phpgw_domain[$phpgw_info['server']['default_domain']]['db_type'];
|
||||
$phpgw_info['server']['config_passwd'] = $phpgw_domain[$phpgw_info['server']['default_domain']]['config_passwd'];
|
||||
$GLOBALS['phpgw_info']['server']['db_host'] = $phpgw_domain[$GLOBALS['phpgw_info']['server']['default_domain']]['db_host'];
|
||||
$GLOBALS['phpgw_info']['server']['db_name'] = $phpgw_domain[$GLOBALS['phpgw_info']['server']['default_domain']]['db_name'];
|
||||
$GLOBALS['phpgw_info']['server']['db_user'] = $phpgw_domain[$GLOBALS['phpgw_info']['server']['default_domain']]['db_user'];
|
||||
$GLOBALS['phpgw_info']['server']['db_pass'] = $phpgw_domain[$GLOBALS['phpgw_info']['server']['default_domain']]['db_pass'];
|
||||
$GLOBALS['phpgw_info']['server']['db_type'] = $phpgw_domain[$GLOBALS['phpgw_info']['server']['default_domain']]['db_type'];
|
||||
$GLOBALS['phpgw_info']['server']['config_passwd'] = $phpgw_domain[$GLOBALS['phpgw_info']['server']['default_domain']]['config_passwd'];
|
||||
}
|
||||
if (defined('PHPGW_SERVER_ROOT'))
|
||||
{
|
||||
$phpgw_info['server']['server_root'] = PHPGW_SERVER_ROOT;
|
||||
$phpgw_info['server']['include_root'] = PHPGW_INCLUDE_ROOT;
|
||||
$GLOBALS['phpgw_info']['server']['server_root'] = PHPGW_SERVER_ROOT;
|
||||
$GLOBALS['phpgw_info']['server']['include_root'] = PHPGW_INCLUDE_ROOT;
|
||||
}
|
||||
elseif (!isset($phpgw_info['server']['include_root']) && $phpgw_info['server']['header_version'] <= 1.6)
|
||||
elseif (!isset($GLOBALS['phpgw_info']['server']['include_root']) && $GLOBALS['phpgw_info']['server']['header_version'] <= 1.6)
|
||||
{
|
||||
$phpgw_info['server']['include_root'] = $phpgw_info['server']['server_root'];
|
||||
$GLOBALS['phpgw_info']['server']['include_root'] = $GLOBALS['phpgw_info']['server']['server_root'];
|
||||
}
|
||||
elseif (!isset($phpgw_info['server']['header_version']) && $phpgw_info['server']['header_version'] <= 1.6)
|
||||
elseif (!isset($GLOBALS['phpgw_info']['server']['header_version']) && $GLOBALS['phpgw_info']['server']['header_version'] <= 1.6)
|
||||
{
|
||||
$phpgw_info['server']['include_root'] = $phpgw_info['server']['server_root'];
|
||||
$GLOBALS['phpgw_info']['server']['include_root'] = $GLOBALS['phpgw_info']['server']['server_root'];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
echo 'sample configuration not found. using built in defaults<br>' . "\n";
|
||||
$phpgw_info['server']['server_root'] = '/path/to/phpgroupware';
|
||||
$phpgw_info['server']['include_root'] = '/path/to/phpgroupware';
|
||||
$GLOBALS['phpgw_info']['server']['server_root'] = '/path/to/phpgroupware';
|
||||
$GLOBALS['phpgw_info']['server']['include_root'] = '/path/to/phpgroupware';
|
||||
/* This is the basic include needed on each page for phpGroupWare application compliance */
|
||||
$phpgw_info['flags']['htmlcompliant'] = True;
|
||||
$GLOBALS['phpgw_info']['flags']['htmlcompliant'] = True;
|
||||
|
||||
/* These are the settings for the database system */
|
||||
$phpgw_info['server']['db_host'] = 'localhost';
|
||||
$phpgw_info['server']['db_name'] = 'phpgroupware';
|
||||
$phpgw_info['server']['db_user'] = 'phpgroupware';
|
||||
$phpgw_info['server']['db_pass'] = 'your_password';
|
||||
$phpgw_info['server']['db_type'] = 'mysql'; //mysql, pgsql (for postgresql), or oracle
|
||||
$GLOBALS['phpgw_info']['server']['db_host'] = 'localhost';
|
||||
$GLOBALS['phpgw_info']['server']['db_name'] = 'phpgroupware';
|
||||
$GLOBALS['phpgw_info']['server']['db_user'] = 'phpgroupware';
|
||||
$GLOBALS['phpgw_info']['server']['db_pass'] = 'your_password';
|
||||
$GLOBALS['phpgw_info']['server']['db_type'] = 'mysql'; //mysql, pgsql (for postgresql), or oracle
|
||||
|
||||
/* These are a few of the advanced settings */
|
||||
$phpgw_info['server']['db_persistent'] = True;
|
||||
$phpgw_info['server']['config_passwd'] = 'changeme';
|
||||
$phpgw_info['server']['mcrypt_enabled'] = False;
|
||||
$phpgw_info['server']['mcrypt_version'] = '2.6.3';
|
||||
$GLOBALS['phpgw_info']['server']['db_persistent'] = True;
|
||||
$GLOBALS['phpgw_info']['server']['config_passwd'] = 'changeme';
|
||||
$GLOBALS['phpgw_info']['server']['mcrypt_enabled'] = False;
|
||||
$GLOBALS['phpgw_info']['server']['mcrypt_version'] = '2.6.3';
|
||||
|
||||
srand((double)microtime()*1000000);
|
||||
$random_char = array(
|
||||
@ -300,7 +301,7 @@
|
||||
|
||||
for ($i=0; $i<30; $i++)
|
||||
{
|
||||
$phpgw_info['server']['mcrypt_iv'] .= $random_char[rand(1,count($random_char))];
|
||||
$GLOBALS['phpgw_info']['server']['mcrypt_iv'] .= $random_char[rand(1,count($random_char))];
|
||||
}
|
||||
}
|
||||
|
||||
@ -310,29 +311,29 @@
|
||||
echo 'Now guessing better values for defaults <br>' . "\n";
|
||||
$this_dir = dirname($SCRIPT_FILENAME);
|
||||
$updir = ereg_replace('/setup','',$this_dir);
|
||||
$phpgw_info['server']['server_root'] = $updir;
|
||||
$phpgw_info['server']['include_root'] = $updir;
|
||||
$GLOBALS['phpgw_info']['server']['server_root'] = $updir;
|
||||
$GLOBALS['phpgw_info']['server']['include_root'] = $updir;
|
||||
}
|
||||
?>
|
||||
</td></tr>
|
||||
<tr bgcolor="486591"><th colspan="2"><font color="fefefe">Settings</font></th></tr>
|
||||
<form action="manageheader.php" method="post">
|
||||
<input type="hidden" name="setting[write_config]" value="true">
|
||||
<tr><td colspan="2"><b>Server Root</b><br><input type="text" name="setting[server_root]" size="80" value="<?php echo $phpgw_info['server']['server_root'] ?>"></td></tr>
|
||||
<tr><td colspan="2"><b>Include Root (this should be the same as Server Root unless you know what you are doing)</b><br><input type="text" name="setting[include_root]" size="80" value="<?php echo $phpgw_info['server']['include_root'] ?>"></td></tr>
|
||||
<tr><td colspan="2"><b>Admin password to header manager </b><br><input type="text" name="setting[HEADER_ADMIN_PASSWORD]" size="80" value="<?php echo $phpgw_info['server']['header_admin_password'] ?>"></td></tr>
|
||||
<tr><td colspan="2"><b>Server Root</b><br><input type="text" name="setting[server_root]" size="80" value="<?php echo $GLOBALS['phpgw_info']['server']['server_root'] ?>"></td></tr>
|
||||
<tr><td colspan="2"><b>Include Root (this should be the same as Server Root unless you know what you are doing)</b><br><input type="text" name="setting[include_root]" size="80" value="<?php echo $GLOBALS['phpgw_info']['server']['include_root'] ?>"></td></tr>
|
||||
<tr><td colspan="2"><b>Admin password to header manager </b><br><input type="text" name="setting[HEADER_ADMIN_PASSWORD]" size="80" value="<?php echo $GLOBALS['phpgw_info']['server']['header_admin_password'] ?>"></td></tr>
|
||||
<br><br>
|
||||
<tr><td><b>DB Host</b><br><input type="text" name="setting[db_host]" value="<?php echo $phpgw_info['server']['db_host'] ?>"></td><td>Hostname/IP of Databaseserver</td></tr>
|
||||
<tr><td><b>DB Name</b><br><input type="text" name="setting[db_name]" value="<?php echo $phpgw_info['server']['db_name'] ?>"></td><td>Name of Database</td></tr>
|
||||
<tr><td><b>DB User</b><br><input type="text" name="setting[db_user]" value="<?php echo $phpgw_info['server']['db_user'] ?>"></td><td>Name of DB User as phpgroupware has to connect as</td></tr>
|
||||
<tr><td><b>DB Password</b><br><input type="text" name="setting[db_pass]" value="<?php echo $phpgw_info['server']['db_pass'] ?>"></td><td>Password of DB User</td></tr>
|
||||
<tr><td><b>DB Host</b><br><input type="text" name="setting[db_host]" value="<?php echo $GLOBALS['phpgw_info']['server']['db_host'] ?>"></td><td>Hostname/IP of Databaseserver</td></tr>
|
||||
<tr><td><b>DB Name</b><br><input type="text" name="setting[db_name]" value="<?php echo $GLOBALS['phpgw_info']['server']['db_name'] ?>"></td><td>Name of Database</td></tr>
|
||||
<tr><td><b>DB User</b><br><input type="text" name="setting[db_user]" value="<?php echo $GLOBALS['phpgw_info']['server']['db_user'] ?>"></td><td>Name of DB User as phpgroupware has to connect as</td></tr>
|
||||
<tr><td><b>DB Password</b><br><input type="text" name="setting[db_pass]" value="<?php echo $GLOBALS['phpgw_info']['server']['db_pass'] ?>"></td><td>Password of DB User</td></tr>
|
||||
<tr><td><b>DB Type</b><br><select name="setting[db_type]">
|
||||
<?php
|
||||
$selected = '';
|
||||
$found_dbtype = false;
|
||||
while(list($k,$v) = each($supported_db))
|
||||
{
|
||||
if($v == $phpgw_info['server']['db_type'])
|
||||
if($v == $GLOBALS['phpgw_info']['server']['db_type'])
|
||||
{
|
||||
$selected = ' selected ';
|
||||
$found_dbtype = true;
|
||||
@ -347,11 +348,11 @@
|
||||
</select>
|
||||
</td><td>What Database do you want to use with PHPGroupWare?</td></tr>
|
||||
|
||||
<tr><td><b>Configuration Password</b><br><input type=text name="setting[config_pass]" value="<?php echo $phpgw_info['server']['config_passwd'] ?>"></td><td>Password needed for configuration</td></tr>
|
||||
<tr><td><b>Configuration Password</b><br><input type=text name="setting[config_pass]" value="<?php echo $GLOBALS['phpgw_info']['server']['config_passwd'] ?>"></td><td>Password needed for configuration</td></tr>
|
||||
<tr><td><b>Persistent connection</b><br>
|
||||
<select type="checkbox" name="setting[db_persistent]">
|
||||
<option value="True"<?php echo ($phpgw_info['server']['db_persistent']?' selected':''); ?>>True</option>
|
||||
<option value="False"<?php echo (! $phpgw_info['server']['db_persistent']?' selected':''); ?>>False</option>
|
||||
<option value="True"<?php echo ($GLOBALS['phpgw_info']['server']['db_persistent']?' selected':''); ?>>True</option>
|
||||
<option value="False"<?php echo (! $GLOBALS['phpgw_info']['server']['db_persistent']?' selected':''); ?>>False</option>
|
||||
</select></td>
|
||||
<td>Do you want persistent connections (higher performance, but eats memory)</td></tr>
|
||||
|
||||
@ -360,7 +361,7 @@
|
||||
$selected = '';
|
||||
while(list($k,$v) = each($supported_sessions_type))
|
||||
{
|
||||
if($v == $phpgw_info['server']['sessions_type'])
|
||||
if($v == $GLOBALS['phpgw_info']['server']['sessions_type'])
|
||||
{
|
||||
$selected = ' selected ';
|
||||
}
|
||||
@ -375,7 +376,7 @@
|
||||
</td><td>What sessions management type do you want to use (PHP4 session management often performs better)?</td></tr>
|
||||
<tr><td colspan=2><b>Enable MCrypt</b><br>
|
||||
<select name="setting[enable_mcrypt]">
|
||||
<?php if($phpgw_info["server"]["mcrypt_enabled"] == True) { ?>
|
||||
<?php if($GLOBALS['phpgw_info']["server"]["mcrypt_enabled"] == True) { ?>
|
||||
<option value="True" selected>True
|
||||
<option value="False">False
|
||||
<?php } else { ?>
|
||||
@ -384,19 +385,19 @@
|
||||
<?php } ?>
|
||||
</select>
|
||||
</td></tr>
|
||||
<tr><td><b>MCrypt version</b><br><input type="text" name="setting[mcrypt_version]" value="<?php echo $phpgw_info['server']['versions']['mcrypt'] ?>"></td><td>Set this to "old" for versions < 2.4, otherwise the exact mcrypt version you use</td></tr>
|
||||
<tr><td><b>MCrypt initilazation vector</b><br><input type="text" name="setting[mcrypt_iv]" value="<?php echo $phpgw_info['server']['mcrypt_iv'] ?>" size="30"></td><td>It should be around 30 bytes in length.<br>Note: The default has been randomly generated.</td></tr>
|
||||
<tr><td><b>MCrypt version</b><br><input type="text" name="setting[mcrypt_version]" value="<?php echo $GLOBALS['phpgw_info']['server']['versions']['mcrypt'] ?>"></td><td>Set this to "old" for versions < 2.4, otherwise the exact mcrypt version you use</td></tr>
|
||||
<tr><td><b>MCrypt initilazation vector</b><br><input type="text" name="setting[mcrypt_iv]" value="<?php echo $GLOBALS['phpgw_info']['server']['mcrypt_iv'] ?>" size="30"></td><td>It should be around 30 bytes in length.<br>Note: The default has been randomly generated.</td></tr>
|
||||
<tr><td><b>Domain select box on login</b><br>
|
||||
<select name="setting[domain_selectbox]">
|
||||
<option value="True"<?php echo ($phpgw_info['server']['domain_selectbox']?' selected':''); ?>>True</option>
|
||||
<option value="False"<?php echo (! $phpgw_info['server']['domain_selectbox']?' selected':''); ?>>False</option>
|
||||
<option value="True"<?php echo ($GLOBALS['phpgw_info']['server']['domain_selectbox']?' selected':''); ?>>True</option>
|
||||
<option value="False"<?php echo (! $GLOBALS['phpgw_info']['server']['domain_selectbox']?' selected':''); ?>>False</option>
|
||||
</select></td><td> </td>
|
||||
</tr>
|
||||
</table>
|
||||
<?php
|
||||
if(!$found_dbtype)
|
||||
{
|
||||
echo '<br><font color=red>Warning!<br>The db_type in defaults ('.$phpgw_info['server']['db_type'].') is not supported on this server. using first supported type.</font>';
|
||||
echo '<br><font color=red>Warning!<br>The db_type in defaults ('.$GLOBALS['phpgw_info']['server']['db_type'].') is not supported on this server. using first supported type.</font>';
|
||||
}
|
||||
echo "<br>";
|
||||
|
||||
@ -415,8 +416,8 @@
|
||||
echo '<input type=hidden name="FormLogout" value="header">';
|
||||
//echo '<input type=hidden name="FormLogout" value="config">';
|
||||
//echo '<input type=hidden name="ConfigLogin" value="Login">';
|
||||
//echo '<input type=hidden name="FormPW" value="'.$phpgw_domain[$phpgw_info["server"]["default_domain"]]["config_passwd"].'">';
|
||||
//echo '<input type=hidden name="FormDomain" value="'.$phpgw_info["server"]["default_domain"].'">';
|
||||
//echo '<input type=hidden name="FormPW" value="'.$phpgw_domain[$GLOBALS['phpgw_info']["server"]["default_domain"]]["config_passwd"].'">';
|
||||
//echo '<input type=hidden name="FormDomain" value="'.$GLOBALS['phpgw_info']["server"]["default_domain"].'">';
|
||||
echo '<input type=submit name="junk" value="continue">';
|
||||
echo '</form>';
|
||||
echo '</body>';
|
||||
|
@ -23,14 +23,14 @@
|
||||
include ('./inc/functions.inc.php');
|
||||
|
||||
// Check header and authentication
|
||||
if (!$phpgw_setup->auth('Config'))
|
||||
if (!$GLOBALS['phpgw_setup']->auth('Config'))
|
||||
{
|
||||
Header('Location: index.php');
|
||||
exit;
|
||||
}
|
||||
// Does not return unless user is authorized
|
||||
|
||||
$tpl_root = $GLOBALS['phpgw_setup']->setup_tpl_dir('setup');
|
||||
$tpl_root = $GLOBALS['phpgw_setup']->html->setup_tpl_dir('setup');
|
||||
$GLOBALS['setup_tpl'] = CreateObject('phpgwapi.Template',$tpl_root);
|
||||
$GLOBALS['setup_tpl']->set_file(array(
|
||||
'T_head' => 'head.tpl',
|
||||
@ -87,15 +87,15 @@
|
||||
}
|
||||
|
||||
$GLOBALS['phpgw_setup']->loaddb();
|
||||
$GLOBALS['phpgw_info']['setup']['stage']['db'] = $GLOBALS['phpgw_setup']->check_db();
|
||||
$GLOBALS['phpgw_info']['setup']['stage']['db'] = $GLOBALS['phpgw_setup']->detection->check_db();
|
||||
|
||||
$GLOBALS['setup_info'] = $GLOBALS['phpgw_setup']->get_versions();
|
||||
$GLOBALS['setup_info'] = $GLOBALS['phpgw_setup']->detection->get_versions();
|
||||
//var_dump($GLOBALS['setup_info']);exit;
|
||||
$GLOBALS['setup_info'] = $GLOBALS['phpgw_setup']->get_db_versions($GLOBALS['setup_info']);
|
||||
$GLOBALS['setup_info'] = $GLOBALS['phpgw_setup']->detection->get_db_versions($GLOBALS['setup_info']);
|
||||
//var_dump($GLOBALS['setup_info']);exit;
|
||||
$GLOBALS['setup_info'] = $GLOBALS['phpgw_setup']->compare_versions($GLOBALS['setup_info']);
|
||||
$GLOBALS['setup_info'] = $GLOBALS['phpgw_setup']->detection->compare_versions($GLOBALS['setup_info']);
|
||||
//var_dump($GLOBALS['setup_info']);exit;
|
||||
$GLOBALS['setup_info'] = $GLOBALS['phpgw_setup']->check_depends($GLOBALS['setup_info']);
|
||||
$GLOBALS['setup_info'] = $GLOBALS['phpgw_setup']->detection->check_depends($GLOBALS['setup_info']);
|
||||
//var_dump($GLOBALS['setup_info']);exit;
|
||||
@ksort($GLOBALS['setup_info']);
|
||||
|
||||
@ -106,7 +106,7 @@
|
||||
}
|
||||
|
||||
$ConfigDomain = $HTTP_COOKIE_VARS['ConfigDomain'] ? $HTTP_COOKIE_VARS['ConfigDomain'] : $HTTP_POST_VARS['ConfigDomain'];
|
||||
$GLOBALS['phpgw_setup']->show_header(lang("Developers' Table Schema Toy"),False,'config',$ConfigDomain);
|
||||
$GLOBALS['phpgw_setup']->html->show_header(lang("Developers' Table Schema Toy"),False,'config',$ConfigDomain);
|
||||
|
||||
if ($HTTP_POST_VARS['submit'])
|
||||
{
|
||||
@ -127,7 +127,7 @@
|
||||
|
||||
// Drop newest tables
|
||||
$terror[$appname]['tables'] = $GLOBALS['setup_info'][$appname]['tables'];
|
||||
$GLOBALS['phpgw_setup']->process_droptables($terror,$GLOBALS['DEBUG']);
|
||||
$GLOBALS['phpgw_setup']->process->droptables($terror,$GLOBALS['DEBUG']);
|
||||
$terror[$appname]['tables'] = array();
|
||||
|
||||
// Reset tables field to baseline table names
|
||||
@ -145,13 +145,13 @@
|
||||
{
|
||||
echo '<br>Processing ' . $terror[$appname]['name'] . ' to ' . $version[$appname];
|
||||
|
||||
$terror = $GLOBALS['phpgw_setup']->process_droptables($terror,$GLOBALS['DEBUG']);
|
||||
$terror = $GLOBALS['phpgw_setup']->process->droptables($terror,$GLOBALS['DEBUG']);
|
||||
$GLOBALS['phpgw_setup']->deregister_app($terror[$appname]['name']);
|
||||
|
||||
$terror = $GLOBALS['phpgw_setup']->process_baseline($terror,$GLOBALS['DEBUG']);
|
||||
$terror = $GLOBALS['phpgw_setup']->process_test_data($terror,$GLOBALS['DEBUG']);
|
||||
$terror = $GLOBALS['phpgw_setup']->process->baseline($terror,$GLOBALS['DEBUG']);
|
||||
$terror = $GLOBALS['phpgw_setup']->process->test_data($terror,$GLOBALS['DEBUG']);
|
||||
|
||||
$terror = $GLOBALS['phpgw_setup']->process_upgrade($terror,$GLOBALS['DEBUG']);
|
||||
$terror = $GLOBALS['phpgw_setup']->process->upgrade($terror,$GLOBALS['DEBUG']);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -271,5 +271,5 @@
|
||||
$GLOBALS['setup_tpl']->set_var('cancel',lang('Cancel'));
|
||||
$GLOBALS['setup_tpl']->pparse('out','app_footer');
|
||||
$GLOBALS['setup_tpl']->pparse('out','footer');
|
||||
$GLOBALS['phpgw_setup']->show_footer();
|
||||
$GLOBALS['phpgw_setup']->html->show_footer();
|
||||
?>
|
||||
|
@ -16,14 +16,14 @@
|
||||
$GLOBALS['phpgw_info']['flags'] = array(
|
||||
'noheader' => True,
|
||||
'nonavbar' => True,
|
||||
'currentapp' => "home",
|
||||
'currentapp' => 'home',
|
||||
'noapi' => True
|
||||
);
|
||||
include('./inc/functions.inc.php');
|
||||
|
||||
// Authorize the user to use setup app and load the database
|
||||
// Does not return unless user is authorized
|
||||
if (!$phpgw_setup->auth('Config') || $HTTP_POST_VARS['cancel'])
|
||||
if(!$GLOBALS['phpgw_setup']->auth('Config') || $HTTP_POST_VARS['cancel'])
|
||||
{
|
||||
Header('Location: index.php');
|
||||
exit;
|
||||
@ -45,9 +45,9 @@
|
||||
return $GLOBALS['phpgw']->accounts->name2id($username);
|
||||
}
|
||||
|
||||
if (!$HTTP_POST_VARS['submit'])
|
||||
if(!$HTTP_POST_VARS['submit'])
|
||||
{
|
||||
$tpl_root = $phpgw_setup->setup_tpl_dir('setup');
|
||||
$tpl_root = $GLOBALS['phpgw_setup']->html->setup_tpl_dir('setup');
|
||||
$setup_tpl = CreateObject('phpgwapi.Template',$tpl_root);
|
||||
$setup_tpl->set_file(array(
|
||||
'T_head' => 'head.tpl',
|
||||
@ -60,7 +60,7 @@
|
||||
$setup_tpl->set_block('T_login_stage_header','B_multi_domain','V_multi_domain');
|
||||
$setup_tpl->set_block('T_login_stage_header','B_single_domain','V_single_domain');
|
||||
|
||||
$phpgw_setup->show_header(lang('Demo Server Setup'));
|
||||
$GLOBALS['phpgw_setup']->html->show_header(lang('Demo Server Setup'));
|
||||
|
||||
$setup_tpl->set_var('action_url','setup_demo.php');
|
||||
$setup_tpl->set_var('description',lang('This will create 1 admin account and 3 demo accounts<br>The username/passwords are: demo/guest, demo2/guest and demo3/guest.<br><b>!!!THIS WILL DELETE ALL EXISTING ACCOUNTS!!!</b><br>')
|
||||
@ -77,7 +77,7 @@
|
||||
$setup_tpl->set_var('lang_submit',lang('submit'));
|
||||
$setup_tpl->set_var('lang_cancel',lang('cancel'));
|
||||
$setup_tpl->pparse('out','T_setup_demo');
|
||||
$phpgw_setup->show_footer();
|
||||
$GLOBALS['phpgw_setup']->html->show_footer();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -88,23 +88,23 @@
|
||||
$fname = $HTTP_POST_VARS['fname'];
|
||||
$lname = $HTTP_POST_VARS['lname'];
|
||||
|
||||
if ($passwd != $passwd2)
|
||||
if($passwd != $passwd2)
|
||||
{
|
||||
echo lang('Passwords did not match, please re-enter') . '.';
|
||||
exit;
|
||||
}
|
||||
if (!$username)
|
||||
if(!$username)
|
||||
{
|
||||
echo lang('You must enter a username for the admin') . '.';
|
||||
exit;
|
||||
}
|
||||
|
||||
$phpgw_setup->loaddb();
|
||||
$GLOBALS['phpgw_setup']->loaddb();
|
||||
/* Load up some configured values */
|
||||
$phpgw_setup->db->query("SELECT config_name,config_value FROM phpgw_config WHERE config_name LIKE 'ldap%' OR config_name='account_repository'",__LINE__,__FILE__);
|
||||
while ($phpgw_setup->db->next_record())
|
||||
$GLOBALS['phpgw_setup']->db->query("SELECT config_name,config_value FROM phpgw_config WHERE config_name LIKE 'ldap%' OR config_name='account_repository'",__LINE__,__FILE__);
|
||||
while ($GLOBALS['phpgw_setup']->db->next_record())
|
||||
{
|
||||
$config[$phpgw_setup->db->f('config_name')] = $phpgw_setup->db->f('config_value');
|
||||
$config[$GLOBALS['phpgw_setup']->db->f('config_name')] = $GLOBALS['phpgw_setup']->db->f('config_value');
|
||||
}
|
||||
$GLOBALS['phpgw_info']['server']['ldap_host'] = $config['ldap_host'];
|
||||
$GLOBALS['phpgw_info']['server']['ldap_context'] = $config['ldap_context'];
|
||||
@ -126,7 +126,7 @@
|
||||
var $accounts;
|
||||
}
|
||||
$GLOBALS['phpgw'] = new phpgw;
|
||||
$GLOBALS['phpgw']->db = $phpgw_setup->db;
|
||||
$GLOBALS['phpgw']->db = $GLOBALS['phpgw_setup']->db;
|
||||
$GLOBALS['phpgw']->common = CreateObject('phpgwapi.common');
|
||||
$GLOBALS['phpgw']->accounts = CreateObject('phpgwapi.accounts');
|
||||
if(($GLOBALS['phpgw_info']['server']['account_repository'] == 'ldap') &&
|
||||
@ -137,12 +137,12 @@
|
||||
}
|
||||
|
||||
/* Begin transaction for acl, etc */
|
||||
$phpgw_setup->db->transaction_begin();
|
||||
$GLOBALS['phpgw_setup']->db->transaction_begin();
|
||||
|
||||
/* Now, clear out existing tables */
|
||||
$phpgw_setup->db->query('DELETE FROM phpgw_accounts');
|
||||
$phpgw_setup->db->query('DELETE FROM phpgw_preferences');
|
||||
$phpgw_setup->db->query('DELETE FROM phpgw_acl');
|
||||
$GLOBALS['phpgw_setup']->db->query('DELETE FROM phpgw_accounts');
|
||||
$GLOBALS['phpgw_setup']->db->query('DELETE FROM phpgw_preferences');
|
||||
$GLOBALS['phpgw_setup']->db->query('DELETE FROM phpgw_acl');
|
||||
|
||||
$defaultprefs = 'a:3:{s:6:"common";a:10:{s:9:"maxmatchs";s:2:"15";s:12:"template_set";s:8:"verdilak";s:5:"theme";s:6:"purple";s:13:"navbar_format";s:5:"icons";s:9:"tz_offset";s:0:"";s:10:"dateformat";s:5:"m/d/Y";s:10:"timeformat";s:2:"12";s:4:"lang";s:2:"en";s:11:"default_app";s:0:"";s:8:"currency";s:1:"$";}s:11:"addressbook";a:1:{s:0:"";s:4:"True";}s:8:"calendar";a:4:{s:13:"workdaystarts";s:1:"7";s:11:"workdayends";s:2:"15";s:13:"weekdaystarts";s:6:"Monday";s:15:"defaultcalendar";s:9:"month.php";}}';
|
||||
|
||||
@ -151,64 +151,64 @@
|
||||
$admingroupid = add_account('Admins','Admin', 'Group',$passwd,'g');
|
||||
|
||||
/* Creation of the demo accounts is now optional - the checkbox is on by default. */
|
||||
if ($HTTP_POST_VARS['create_demo'])
|
||||
if($HTTP_POST_VARS['create_demo'])
|
||||
{
|
||||
/* Create records for demo accounts */
|
||||
$accountid = add_account('demo','Demo','Account','guest');
|
||||
|
||||
$phpgw_setup->db->query("INSERT INTO phpgw_preferences (preference_owner, preference_value) VALUES ('$accountid', '$defaultprefs')");
|
||||
$phpgw_setup->db->query("INSERT INTO phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) VALUES ('preferences', 'changepassword', ".$accountid.", 0)");
|
||||
$phpgw_setup->db->query("INSERT INTO phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) VALUES ('phpgw_group', '".$defaultgroupid."', $accountid, 1)");
|
||||
$phpgw_setup->db->query("INSERT INTO phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) VALUES ('addressbook', 'run', ".$accountid.", 1)");
|
||||
$phpgw_setup->db->query("INSERT INTO phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) VALUES ('filemanager', 'run', ".$accountid.", 1)");
|
||||
$phpgw_setup->db->query("INSERT INTO phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) VALUES ('calendar', 'run', ".$accountid.", 1)");
|
||||
$phpgw_setup->db->query("INSERT INTO phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) VALUES ('email', 'run', ".$accountid.", 1)");
|
||||
$phpgw_setup->db->query("INSERT INTO phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) VALUES ('notes', 'run', ".$accountid.", 1)");
|
||||
$phpgw_setup->db->query("INSERT INTO phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) VALUES ('todo', 'run', ".$accountid.", 1)");
|
||||
$GLOBALS['phpgw_setup']->db->query("INSERT INTO phpgw_preferences (preference_owner, preference_value) VALUES ('$accountid', '$defaultprefs')");
|
||||
$GLOBALS['phpgw_setup']->db->query("INSERT INTO phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) VALUES ('preferences', 'changepassword', ".$accountid.", 0)");
|
||||
$GLOBALS['phpgw_setup']->db->query("INSERT INTO phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) VALUES ('phpgw_group', '".$defaultgroupid."', $accountid, 1)");
|
||||
$GLOBALS['phpgw_setup']->db->query("INSERT INTO phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) VALUES ('addressbook', 'run', ".$accountid.", 1)");
|
||||
$GLOBALS['phpgw_setup']->db->query("INSERT INTO phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) VALUES ('filemanager', 'run', ".$accountid.", 1)");
|
||||
$GLOBALS['phpgw_setup']->db->query("INSERT INTO phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) VALUES ('calendar', 'run', ".$accountid.", 1)");
|
||||
$GLOBALS['phpgw_setup']->db->query("INSERT INTO phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) VALUES ('email', 'run', ".$accountid.", 1)");
|
||||
$GLOBALS['phpgw_setup']->db->query("INSERT INTO phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) VALUES ('notes', 'run', ".$accountid.", 1)");
|
||||
$GLOBALS['phpgw_setup']->db->query("INSERT INTO phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) VALUES ('todo', 'run', ".$accountid.", 1)");
|
||||
|
||||
$accountid = add_account('demo2','Demo2','Account','guest');
|
||||
|
||||
$phpgw_setup->db->query("INSERT INTO phpgw_preferences (preference_owner, preference_value) VALUES ('$accountid', '$defaultprefs')");
|
||||
$phpgw_setup->db->query("INSERT INTO phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) VALUES ('preferences', 'changepassword', ".$accountid.", 0)");
|
||||
$phpgw_setup->db->query("INSERT INTO phpgw_acl (acl_appname, acl_account, acl_location, acl_rights) VALUES ('phpgw_group', '".$defaultgroupid."', $accountid, 1)");
|
||||
$phpgw_setup->db->query("INSERT INTO phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) VALUES ('addressbook', 'run', ".$accountid.", 1)");
|
||||
$phpgw_setup->db->query("INSERT INTO phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) VALUES ('filemanager', 'run', ".$accountid.", 1)");
|
||||
$phpgw_setup->db->query("INSERT INTO phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) VALUES ('calendar', 'run', ".$accountid.", 1)");
|
||||
$phpgw_setup->db->query("INSERT INTO phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) VALUES ('email', 'run', ".$accountid.", 1)");
|
||||
$phpgw_setup->db->query("INSERT INTO phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) VALUES ('notes', 'run', ".$accountid.", 1)");
|
||||
$phpgw_setup->db->query("INSERT INTO phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) VALUES ('todo', 'run', ".$accountid.", 1)");
|
||||
$GLOBALS['phpgw_setup']->db->query("INSERT INTO phpgw_preferences (preference_owner, preference_value) VALUES ('$accountid', '$defaultprefs')");
|
||||
$GLOBALS['phpgw_setup']->db->query("INSERT INTO phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) VALUES ('preferences', 'changepassword', ".$accountid.", 0)");
|
||||
$GLOBALS['phpgw_setup']->db->query("INSERT INTO phpgw_acl (acl_appname, acl_account, acl_location, acl_rights) VALUES ('phpgw_group', '".$defaultgroupid."', $accountid, 1)");
|
||||
$GLOBALS['phpgw_setup']->db->query("INSERT INTO phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) VALUES ('addressbook', 'run', ".$accountid.", 1)");
|
||||
$GLOBALS['phpgw_setup']->db->query("INSERT INTO phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) VALUES ('filemanager', 'run', ".$accountid.", 1)");
|
||||
$GLOBALS['phpgw_setup']->db->query("INSERT INTO phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) VALUES ('calendar', 'run', ".$accountid.", 1)");
|
||||
$GLOBALS['phpgw_setup']->db->query("INSERT INTO phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) VALUES ('email', 'run', ".$accountid.", 1)");
|
||||
$GLOBALS['phpgw_setup']->db->query("INSERT INTO phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) VALUES ('notes', 'run', ".$accountid.", 1)");
|
||||
$GLOBALS['phpgw_setup']->db->query("INSERT INTO phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) VALUES ('todo', 'run', ".$accountid.", 1)");
|
||||
|
||||
$accountid = add_account('demo3','Demo3','Account','guest');
|
||||
|
||||
$phpgw_setup->db->query("INSERT INTO phpgw_preferences (preference_owner, preference_value) VALUES ('$accountid', '$defaultprefs')");
|
||||
$phpgw_setup->db->query("INSERT INTO phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) VALUES ('preferences', 'changepassword', ".$accountid.", 0)");
|
||||
$phpgw_setup->db->query("INSERT INTO phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) VALUES ('phpgw_group', '".$defaultgroupid."', $accountid, 1)");
|
||||
$phpgw_setup->db->query("INSERT INTO phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) VALUES ('addressbook', 'run', ".$accountid.", 1)");
|
||||
$phpgw_setup->db->query("INSERT INTO phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) VALUES ('filemanager', 'run', ".$accountid.", 1)");
|
||||
$phpgw_setup->db->query("INSERT INTO phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) VALUES ('calendar', 'run', ".$accountid.", 1)");
|
||||
$phpgw_setup->db->query("INSERT INTO phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) VALUES ('email', 'run', ".$accountid.", 1)");
|
||||
$phpgw_setup->db->query("INSERT INTO phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) VALUES ('notes', 'run', ".$accountid.", 1)");
|
||||
$phpgw_setup->db->query("INSERT INTO phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) VALUES ('todo', 'run', ".$accountid.", 1)");
|
||||
$GLOBALS['phpgw_setup']->db->query("INSERT INTO phpgw_preferences (preference_owner, preference_value) VALUES ('$accountid', '$defaultprefs')");
|
||||
$GLOBALS['phpgw_setup']->db->query("INSERT INTO phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) VALUES ('preferences', 'changepassword', ".$accountid.", 0)");
|
||||
$GLOBALS['phpgw_setup']->db->query("INSERT INTO phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) VALUES ('phpgw_group', '".$defaultgroupid."', $accountid, 1)");
|
||||
$GLOBALS['phpgw_setup']->db->query("INSERT INTO phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) VALUES ('addressbook', 'run', ".$accountid.", 1)");
|
||||
$GLOBALS['phpgw_setup']->db->query("INSERT INTO phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) VALUES ('filemanager', 'run', ".$accountid.", 1)");
|
||||
$GLOBALS['phpgw_setup']->db->query("INSERT INTO phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) VALUES ('calendar', 'run', ".$accountid.", 1)");
|
||||
$GLOBALS['phpgw_setup']->db->query("INSERT INTO phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) VALUES ('email', 'run', ".$accountid.", 1)");
|
||||
$GLOBALS['phpgw_setup']->db->query("INSERT INTO phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) VALUES ('notes', 'run', ".$accountid.", 1)");
|
||||
$GLOBALS['phpgw_setup']->db->query("INSERT INTO phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) VALUES ('todo', 'run', ".$accountid.", 1)");
|
||||
}
|
||||
|
||||
/* Create records for administrator account */
|
||||
$accountid = add_account($username,$fname,$lname,$passwd);
|
||||
|
||||
$phpgw_setup->db->query("INSERT INTO phpgw_preferences (preference_owner, preference_value) VALUES ('$accountid', '$defaultprefs')");
|
||||
$phpgw_setup->db->query("INSERT INTO phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) VALUES ('phpgw_group', '".$defaultgroupid."', $accountid, 1)");
|
||||
$phpgw_setup->db->query("INSERT INTO phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) VALUES ('phpgw_group', '".$admingroupid."', $accountid, 1)");
|
||||
$phpgw_setup->db->query("INSERT INTO phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) VALUES ('preferences', 'changepassword', ".$accountid.", 1)");
|
||||
$phpgw_setup->db->query("INSERT INTO phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) VALUES ('admin', 'run', ".$accountid.", 1)");
|
||||
$phpgw_setup->db->query("INSERT INTO phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) VALUES ('addressbook', 'run', ".$accountid.", 1)");
|
||||
$phpgw_setup->db->query("INSERT INTO phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) VALUES ('filemanager', 'run', ".$accountid.", 1)");
|
||||
$phpgw_setup->db->query("INSERT INTO phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) VALUES ('calendar', 'run', ".$accountid.", 1)");
|
||||
$phpgw_setup->db->query("INSERT INTO phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) VALUES ('email', 'run', ".$accountid.", 1)");
|
||||
$phpgw_setup->db->query("INSERT INTO phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) VALUES ('notes', 'run', ".$accountid.", 1)");
|
||||
$phpgw_setup->db->query("INSERT INTO phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) VALUES ('nntp', 'run', ".$accountid.", 1)");
|
||||
$phpgw_setup->db->query("INSERT INTO phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) VALUES ('todo', 'run', ".$accountid.", 1)");
|
||||
$phpgw_setup->db->query("INSERT INTO phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) VALUES ('manual', 'run', ".$accountid.", 1)");
|
||||
$GLOBALS['phpgw_setup']->db->query("INSERT INTO phpgw_preferences (preference_owner, preference_value) VALUES ('$accountid', '$defaultprefs')");
|
||||
$GLOBALS['phpgw_setup']->db->query("INSERT INTO phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) VALUES ('phpgw_group', '".$defaultgroupid."', $accountid, 1)");
|
||||
$GLOBALS['phpgw_setup']->db->query("INSERT INTO phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) VALUES ('phpgw_group', '".$admingroupid."', $accountid, 1)");
|
||||
$GLOBALS['phpgw_setup']->db->query("INSERT INTO phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) VALUES ('preferences', 'changepassword', ".$accountid.", 1)");
|
||||
$GLOBALS['phpgw_setup']->db->query("INSERT INTO phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) VALUES ('admin', 'run', ".$accountid.", 1)");
|
||||
$GLOBALS['phpgw_setup']->db->query("INSERT INTO phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) VALUES ('addressbook', 'run', ".$accountid.", 1)");
|
||||
$GLOBALS['phpgw_setup']->db->query("INSERT INTO phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) VALUES ('filemanager', 'run', ".$accountid.", 1)");
|
||||
$GLOBALS['phpgw_setup']->db->query("INSERT INTO phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) VALUES ('calendar', 'run', ".$accountid.", 1)");
|
||||
$GLOBALS['phpgw_setup']->db->query("INSERT INTO phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) VALUES ('email', 'run', ".$accountid.", 1)");
|
||||
$GLOBALS['phpgw_setup']->db->query("INSERT INTO phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) VALUES ('notes', 'run', ".$accountid.", 1)");
|
||||
$GLOBALS['phpgw_setup']->db->query("INSERT INTO phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) VALUES ('nntp', 'run', ".$accountid.", 1)");
|
||||
$GLOBALS['phpgw_setup']->db->query("INSERT INTO phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) VALUES ('todo', 'run', ".$accountid.", 1)");
|
||||
$GLOBALS['phpgw_setup']->db->query("INSERT INTO phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) VALUES ('manual', 'run', ".$accountid.", 1)");
|
||||
|
||||
$phpgw_setup->db->transaction_commit();
|
||||
$GLOBALS['phpgw_setup']->db->transaction_commit();
|
||||
|
||||
Header('Location: index.php');
|
||||
exit;
|
||||
|
@ -20,15 +20,15 @@
|
||||
);
|
||||
include ('./inc/functions.inc.php');
|
||||
|
||||
// Check header and authentication
|
||||
if (!$phpgw_setup->auth('Config'))
|
||||
/* Check header and authentication */
|
||||
if (!$GLOBALS['phpgw_setup']->auth('Config'))
|
||||
{
|
||||
Header('Location: index.php');
|
||||
exit;
|
||||
}
|
||||
// Does not return unless user is authorized
|
||||
|
||||
$tpl_root = $phpgw_setup->setup_tpl_dir('setup');
|
||||
$tpl_root = $GLOBALS['phpgw_setup']->html->setup_tpl_dir('setup');
|
||||
$setup_tpl = CreateObject('phpgwapi.Template',$tpl_root);
|
||||
|
||||
$download = $HTTP_POST_VARS['download'] ? $HTTP_POST_VARS['download'] : $HTTP_GET_VARS['download'];
|
||||
@ -70,14 +70,14 @@
|
||||
$setup_tpl->set_block('sqlarr','sqlfooter','sqlfooter');
|
||||
}
|
||||
|
||||
$phpgw_setup->loaddb();
|
||||
$GLOBALS['phpgw_setup']->loaddb();
|
||||
|
||||
function parse_vars($table,$term)
|
||||
{
|
||||
$GLOBALS['setup_tpl']->set_var('table', $table);
|
||||
$GLOBALS['setup_tpl']->set_var('term',$term);
|
||||
|
||||
list($arr,$pk,$fk,$ix,$uc) = $GLOBALS['phpgw_setup']->sql_to_array($table);
|
||||
list($arr,$pk,$fk,$ix,$uc) = $GLOBALS['phpgw_setup']->process->sql_to_array($table);
|
||||
$GLOBALS['setup_tpl']->set_var('arr',$arr);
|
||||
if (count($pk) > 1)
|
||||
{
|
||||
@ -169,7 +169,7 @@
|
||||
|
||||
if (!$download)
|
||||
{
|
||||
$phpgw_setup->show_header();
|
||||
$GLOBALS['phpgw_setup']->html->show_header();
|
||||
}
|
||||
|
||||
if ($showall)
|
||||
@ -182,7 +182,7 @@
|
||||
$term = ',';
|
||||
$dlstring .= printout('sqlheader');
|
||||
|
||||
$db = $phpgw_setup->db;
|
||||
$db = $GLOBALS['phpgw_setup']->db;
|
||||
$db->query('SHOW TABLES');
|
||||
while($db->next_record())
|
||||
{
|
||||
@ -236,7 +236,7 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
$phpgw_setup->show_header();
|
||||
$GLOBALS['phpgw_setup']->html->show_header();
|
||||
|
||||
$setup_tpl->set_var('action_url','sqltoarray.php');
|
||||
$setup_tpl->set_var('lang_submit','Show selected');
|
||||
|
Loading…
Reference in New Issue
Block a user