added minimal egw object (egw_minimal), which is shared between egw and setup

This commit is contained in:
Ralf Becker 2008-03-22 09:29:29 +00:00
parent 9553da2f63
commit ea3ae107d1
2 changed files with 1022 additions and 1016 deletions

View File

@ -29,7 +29,7 @@
* }
* You can now simply use $GLOBALS['egw']->datetime, and the egw class instanciates it for you on demand.
*/
class egw
class egw extends egw_minimal
{
/**
* Turn on debug mode. Will output additional data for debugging purposes.
@ -37,12 +37,6 @@ class egw
* @access public
*/
var $debug = 0; // This will turn on debugging information.
/**
* Instance of the db-object
*
* @var egw_db
*/
var $db;
/**
* Instance of the account object
*
@ -55,12 +49,6 @@ class egw
* @var common
*/
var $common;
/**
* Current app at the instancation of the class
*
* @var string
*/
var $currentapp;
/**
* Constructor: Instantiates the sub-classes
@ -491,6 +479,32 @@ class egw
$this->db->disconnect();
}
}
}
/**
* Minimal eGW object used in setup, does not instanciate anything by default
*
*/
class egw_minimal
{
/**
* Instance of the db-object
*
* @var egw_db
*/
var $db;
/**
* Current app at the instancation of the class
*
* @var string
*/
var $currentapp;
/**
* Global ADOdb object, need to be defined here, to not call magic __get method
*
* @var ADOConnection
*/
var $ADOdb;
/**
* Classes which get instanciated in a different name
@ -536,7 +550,7 @@ class egw
if (!isset(self::$sub_objects[$name]) && !class_exists($name))
{
error_log(__METHOD__.": There's NO $name object!");
error_log(__METHOD__.": There's NO $name object! ".function_backtrace());
return null;
}
switch($name)

View File

@ -13,14 +13,6 @@
* @version $Id$
*/
class egw_dummy {
var $db;
var $common;
var $accounts;
function invalidate_session_cache() { }
}
class setup
{
var $db;
@ -74,14 +66,19 @@
// setup us as $GLOBALS['egw_setup'], as this gets used in our sub-objects
$GLOBALS['egw_setup'] =& $this;
$this->detection =& CreateObject('setup.setup_detection');
$this->process =& CreateObject('setup.setup_process');
if (!is_object($GLOBALS['egw']))
{
require_once(EGW_API_INC.'/class.egw.inc.php');
$GLOBALS['phpgw'] = $GLOBALS['egw'] = new egw_minimal();
}
$this->detection = new setup_detection();
$this->process = new setup_process();
if ($_REQUEST['system_charset']) $this->system_charset = $_REQUEST['system_charset'];
/* The setup application needs these */
if ($html) $this->html =& CreateObject('setup.setup_html');
if ($translation) $this->translation =& CreateObject('setup.setup_translation');
if ($html) $this->html = new setup_html();
if ($translation) $this->translation = new setup_translation();
}
/**
@ -99,14 +96,15 @@
{
$GLOBALS['egw_info']['server']['db_persistent'] = False;
}
$this->db =& CreateObject('phpgwapi.egw_db');
$this->db->Host = $GLOBALS['egw_domain'][$this->ConfigDomain]['db_host'];
$this->db->Port = $GLOBALS['egw_domain'][$this->ConfigDomain]['db_port'];
$this->db->Type = $GLOBALS['egw_domain'][$this->ConfigDomain]['db_type'];
$this->db->Database = $GLOBALS['egw_domain'][$this->ConfigDomain]['db_name'];
$this->db->User = $GLOBALS['egw_domain'][$this->ConfigDomain]['db_user'];
$this->db->Password = $GLOBALS['egw_domain'][$this->ConfigDomain]['db_pass'];
$GLOBALS['egw']->db = $this->db = new egw_db();
$this->db->connect(
$GLOBALS['egw_domain'][$this->ConfigDomain]['db_name'],
$GLOBALS['egw_domain'][$this->ConfigDomain]['db_host'],
$GLOBALS['egw_domain'][$this->ConfigDomain]['db_port'],
$GLOBALS['egw_domain'][$this->ConfigDomain]['db_user'],
$GLOBALS['egw_domain'][$this->ConfigDomain]['db_pass'],
$GLOBALS['egw_domain'][$this->ConfigDomain]['db_type']
);
$this->db->set_app('phpgwapi');
if ($connect_and_setcharset)
@ -875,8 +873,10 @@
function setup_account_object(array $config=array())
{
error_log(__METHOD__."($config)");
if (!is_object($this->accounts) || $config)
{
error_log(__METHOD__."($config) creating new this->accounts object");
if (!is_object($this->db))
{
$this->loaddb();
@ -892,14 +892,6 @@
$config[$row['config_name']] = $row['config_value'];
}
}
if (!is_object($GLOBALS['egw']))
{
$GLOBALS['egw'] =& new egw_dummy();
$GLOBALS['phpgw'] =& $GLOBALS['egw'];
}
$GLOBALS['egw']->db = clone($this->db);
$GLOBALS['egw']->common =& CreateObject('phpgwapi.common');
$this->accounts = new accounts($config);
if (!is_object($GLOBALS['egw']->accounts)) $GLOBALS['egw']->accounts = $this->accounts;
$this->accounts->cache_invalidate(); // the cache is shared for all instances of the class