mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-07 08:34:29 +01:00
dynamically autoloading sub-object of egw-object, moved __wakeup methods to concerned classes and other "modernsations" ;-)
This commit is contained in:
parent
3108861db0
commit
3bf9ad5efa
@ -90,10 +90,6 @@ class accounts_sql
|
||||
{
|
||||
$this->db = $GLOBALS['egw']->db;
|
||||
}
|
||||
if (!is_object($GLOBALS['egw']->acl))
|
||||
{
|
||||
$GLOBALS['egw']->acl =& CreateObject('phpgwapi.acl');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -162,10 +158,6 @@ class accounts_sql
|
||||
// encrypt password if given or unset it if not
|
||||
if ($data['account_passwd'])
|
||||
{
|
||||
if (!is_object($GLOBALS['egw']->auth))
|
||||
{
|
||||
$GLOBALS['egw']->auth =& CreateObject('phpgwapi.auth');
|
||||
}
|
||||
// if password it's not already entcrypted, do so now
|
||||
if (!preg_match('/^\\{[a-z5]{3,5}\\}.+/i',$data['account_passwd']) &&
|
||||
!preg_match('/^[0-9a-f]{32}$/',$data['account_passwd'])) // md5 hash
|
||||
@ -222,10 +214,6 @@ class accounts_sql
|
||||
}
|
||||
if ($contact_id)
|
||||
{
|
||||
if (!is_object($GLOBALS['egw']->contacts))
|
||||
{
|
||||
$GLOBALS['egw']->contacts =& CreateObject('phpgwapi.contacts');
|
||||
}
|
||||
$GLOBALS['egw']->contacts->delete($contact_id,false); // false = allow to delete accounts (!)
|
||||
}
|
||||
return true;
|
||||
@ -332,10 +320,6 @@ class accounts_sql
|
||||
function get_list($_type='both', $start = null,$sort = '', $order = '', $query = '', $offset = null, $query_type='')
|
||||
{
|
||||
//echo "<p>accounts_sql($_type,$start,$sort,$order,$query,$offset,$query_type)</p>\n";
|
||||
if (!is_object($GLOBALS['egw']->contacts))
|
||||
{
|
||||
$GLOBALS['egw']->contacts =& CreateObject('phpgwapi.contacts');
|
||||
}
|
||||
static $order2contact = array(
|
||||
'account_firstname' => 'n_given',
|
||||
'account_lastname' => 'n_family',
|
||||
|
@ -312,36 +312,6 @@
|
||||
exit;
|
||||
}
|
||||
|
||||
function egw_final()
|
||||
{
|
||||
if (!defined('EGW_FINAL'))
|
||||
{
|
||||
define('EGW_FINAL',True);
|
||||
|
||||
if (is_object($GLOBALS['egw']->accounts))
|
||||
{
|
||||
$GLOBALS['egw']->accounts->save_session_cache();
|
||||
}
|
||||
if (is_object($GLOBALS['egw']->link))
|
||||
{
|
||||
$GLOBALS['egw']->link->save_session_cache();
|
||||
}
|
||||
// call the asyncservice check_run function if it is not explicitly set to cron-only
|
||||
//
|
||||
if (!$GLOBALS['egw_info']['server']['asyncservice']) // is default
|
||||
{
|
||||
ExecMethod('phpgwapi.asyncservice.check_run','fallback');
|
||||
}
|
||||
/* Clean up mcrypt */
|
||||
if (@is_object($GLOBALS['egw']->crypto))
|
||||
{
|
||||
$GLOBALS['egw']->crypto->cleanup();
|
||||
unset($GLOBALS['egw']->crypto);
|
||||
}
|
||||
$GLOBALS['egw']->db->disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* return a random string of size $size
|
||||
*
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -255,7 +255,6 @@ class egw_db
|
||||
{
|
||||
$this->Type = $GLOBALS['egw_info']['server']['db_type'];
|
||||
}
|
||||
|
||||
if (!$this->Link_ID)
|
||||
{
|
||||
foreach(array('Host','Database','User','Password') as $name)
|
||||
@ -368,6 +367,7 @@ class egw_db
|
||||
ini_set('mssql.textlimit',2147483647);
|
||||
ini_set('mssql.sizelimit',2147483647);
|
||||
}
|
||||
$new_connection = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -377,9 +377,27 @@ class egw_db
|
||||
// next ADOdb version: if (!$this->Link_ID->isConnected()) $this->Link_ID->Connect();
|
||||
if (!$this->Link_ID->_connectionID) $this->Link_ID->Connect();
|
||||
|
||||
if ($new_connection && $GLOBALS['egw_info']['server']['sessions_type'] == 'php4-restore')
|
||||
{
|
||||
foreach(get_included_files() as $file)
|
||||
{
|
||||
if (strpos($file,'adodb') !== false && !in_array($file,(array)$_SESSION['egw_required_files']))
|
||||
{
|
||||
$_SESSION['egw_required_files'][] = $file;
|
||||
}
|
||||
}
|
||||
}
|
||||
//echo "<p>".print_r($this->Link_ID->ServerInfo(),true)."</p>\n";
|
||||
return $this->Link_ID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic method to re-connect with the database, if the object get's restored from the session
|
||||
*/
|
||||
function __wakeup()
|
||||
{
|
||||
$this->connect(); // we need to re-connect
|
||||
}
|
||||
|
||||
/**
|
||||
* changes defaults set in class-var $capabilities depending on db-type and -version
|
||||
|
@ -58,7 +58,7 @@ class egw_framework
|
||||
|
||||
if (!is_object($GLOBALS['egw']->framework))
|
||||
{
|
||||
$GLOBALS['egw']->framework =& $this;
|
||||
$GLOBALS['egw']->framework = $this;
|
||||
}
|
||||
}
|
||||
|
||||
@ -387,25 +387,20 @@ class egw_framework
|
||||
}
|
||||
$options[$action] = $label;
|
||||
}
|
||||
if (!is_object($GLOBALS['egw']->html))
|
||||
{
|
||||
$GLOBALS['egw']->html =& new html();
|
||||
}
|
||||
return $GLOBALS['egw']->html->select('quick_add','',$options,true,$options=' onchange="eval(this.value); this.value=0; return false;"');
|
||||
return html::select('quick_add','',$options,true,$options=' onchange="eval(this.value); this.value=0; return false;"');
|
||||
}
|
||||
|
||||
function _get_notification_bell() {
|
||||
if (!is_object($GLOBALS['egw']->html))
|
||||
{
|
||||
$GLOBALS['egw']->html =& new html();
|
||||
}
|
||||
return $GLOBALS['egw']->html->div( $GLOBALS['egw']->html->a_href( $GLOBALS['egw']->html->image('notifications','notificationbell',lang('notifications')),
|
||||
'javascript: notificationwindow_display();'
|
||||
),
|
||||
'id="notificationbell"', // options
|
||||
'', // class
|
||||
'display: none' //style
|
||||
);
|
||||
function _get_notification_bell()
|
||||
{
|
||||
return html::div(
|
||||
html::a_href(
|
||||
html::image('notifications','notificationbell',lang('notifications')),
|
||||
'javascript: notificationwindow_display();'
|
||||
),
|
||||
'id="notificationbell"', // options
|
||||
'', // class
|
||||
'display: none' //style
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -597,11 +592,6 @@ class egw_framework
|
||||
{
|
||||
$java_script = '';
|
||||
|
||||
if(!@is_object($GLOBALS['egw']->js))
|
||||
{
|
||||
$GLOBALS['egw']->js =& CreateObject('phpgwapi.javascript');
|
||||
}
|
||||
|
||||
// always include javascript helper functions
|
||||
$GLOBALS['egw']->js->validate_file('jsapi','jsapi');
|
||||
|
||||
@ -715,5 +705,3 @@ if (!function_exists('display_sidebox'))
|
||||
$GLOBALS['egw']->framework->sidebox($appname,$menu_title,$file);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -220,7 +220,7 @@
|
||||
{
|
||||
if ($browser)
|
||||
{
|
||||
$browser_folder = strtolower(ExecMethod('phpgwapi.browser.get_agent'));
|
||||
$browser_folder = html::$user_agent;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -686,22 +686,32 @@
|
||||
if (class_exists($classname))
|
||||
{
|
||||
$args = func_get_args();
|
||||
if(count($args) == 1)
|
||||
switch(count($args))
|
||||
{
|
||||
$obj =& new $classname;
|
||||
}
|
||||
else
|
||||
{
|
||||
$code = '$obj =& new ' . $classname . '(';
|
||||
foreach($args as $n => $arg)
|
||||
{
|
||||
if ($n)
|
||||
case 1:
|
||||
$obj =& new $classname;
|
||||
break;
|
||||
case 2:
|
||||
$obj =& new $classname($args[1]);
|
||||
break;
|
||||
case 3:
|
||||
$obj =& new $classname($args[1],$args[2]);
|
||||
break;
|
||||
case 4:
|
||||
$obj =& new $classname($args[1],$args[2],$args[3]);
|
||||
break;
|
||||
default:
|
||||
$code = '$obj =& new ' . $classname . '(';
|
||||
foreach($args as $n => $arg)
|
||||
{
|
||||
$code .= ($n > 1 ? ',' : '') . '$args[' . $n . ']';
|
||||
if ($n)
|
||||
{
|
||||
$code .= ($n > 1 ? ',' : '') . '$args[' . $n . ']';
|
||||
}
|
||||
}
|
||||
}
|
||||
$code .= ');';
|
||||
eval($code);
|
||||
$code .= ');';
|
||||
eval($code);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!is_object($obj))
|
||||
@ -724,7 +734,6 @@
|
||||
list($app,$class,$method) = explode('.',$acm);
|
||||
if (!is_object($obj =& $GLOBALS[$class]))
|
||||
{
|
||||
$newobj = 1;
|
||||
$obj =& CreateObject($acm);
|
||||
}
|
||||
|
||||
@ -736,18 +745,8 @@
|
||||
|
||||
$args = func_get_args();
|
||||
unset($args[0]);
|
||||
$code = '$return =& $obj->'.$method.'(';
|
||||
foreach ($args as $n => $arg)
|
||||
{
|
||||
if ($n)
|
||||
{
|
||||
$code .= ($n > 1 ? ',' : '') . '$args[' . $n . ']';
|
||||
}
|
||||
}
|
||||
|
||||
eval($code.');');
|
||||
if($newobj) unset($obj);
|
||||
return $return;
|
||||
|
||||
return call_user_func_array(array($obj,$method),$args);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -791,12 +790,10 @@
|
||||
{
|
||||
return $GLOBALS[$classname]->$functionname($functionparams);
|
||||
}
|
||||
else
|
||||
{
|
||||
return $GLOBALS[$classname]->$functionname();
|
||||
}
|
||||
return $GLOBALS[$classname]->$functionname();
|
||||
}
|
||||
/* if the $method includes a parent class (multi-dimensional) then we have to work from it */
|
||||
/* RalfBecker: let's check if this is still in use, I don't think so:
|
||||
elseif ($partscount >= 3)
|
||||
{
|
||||
$GLOBALS['methodparts'] = explode(".", $method);
|
||||
@ -804,14 +801,13 @@
|
||||
$appname = $GLOBALS['methodparts'][0];
|
||||
$classname = $GLOBALS['methodparts'][$classpartnum];
|
||||
$functionname = $GLOBALS['methodparts'][$partscount];
|
||||
/* Now we clear these out of the array so that we can do a proper */
|
||||
/* loop and build the $parentobject */
|
||||
// Now we clear these out of the array so that we can do a proper
|
||||
// loop and build the $parentobject
|
||||
unset ($GLOBALS['methodparts'][0]);
|
||||
unset ($GLOBALS['methodparts'][$classpartnum]);
|
||||
unset ($GLOBALS['methodparts'][$partscount]);
|
||||
reset ($GLOBALS['methodparts']);
|
||||
$firstparent = 'True';
|
||||
// while (list ($key, $val) = each ($GLOBALS['methodparts']))
|
||||
foreach($GLOBALS['methodparts'] as $val)
|
||||
{
|
||||
if ($firstparent == 'True')
|
||||
@ -857,10 +853,8 @@
|
||||
return $returnval;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return "<p>ExecMethod('$method'): error in parts!<br />".function_backtrace()."</p>\n";
|
||||
}
|
||||
*/
|
||||
return "<p>ExecMethod('$method'): error in parts!<br />".function_backtrace()."</p>\n";
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1170,7 +1164,7 @@
|
||||
if ($remove-- < 0)
|
||||
{
|
||||
$ret[] = (isset($level['class'])?$level['class'].'::':'').$level['function'].
|
||||
(!$level['class'] ? '('.str_replace(EGW_SERVER_ROOT,'',$level['args'][0]).')' : '');
|
||||
(!$level['class'] && !is_object($level['args'][0]) ? '('.str_replace(EGW_SERVER_ROOT,'',$level['args'][0]).')' : '');
|
||||
}
|
||||
}
|
||||
if (is_array($ret))
|
||||
|
@ -66,27 +66,23 @@ if ($GLOBALS['egw_info']['server']['sessions_type'] == 'php4-restore' && $_REQUE
|
||||
|
||||
if ($GLOBALS['egw_info']['flags']['currentapp'] != 'login' && $GLOBALS['egw_info']['flags']['currentapp'] != 'logout')
|
||||
{
|
||||
if (is_array($_SESSION['egw_info_cache']) && is_array($_SESSION['egw_included_files']) && $_SESSION['egw_object_cache'])
|
||||
if (is_array($_SESSION['egw_info_cache']) && $_SESSION['egw_object_cache'])
|
||||
{
|
||||
// marking the context as restored from the session, used by session->verify to not read the date from the db again
|
||||
// marking the context as restored from the session, used by session->verify to not read the data from the db again
|
||||
$GLOBALS['egw_info']['flags']['restored_from_session'] = true;
|
||||
|
||||
// restoring the egw_info-array
|
||||
$flags = $GLOBALS['egw_info']['flags'];
|
||||
$GLOBALS['egw_info'] = $_SESSION['egw_info_cache'];
|
||||
$GLOBALS['egw_info']['flags'] = $flags;
|
||||
unset($flags);
|
||||
$GLOBALS['egw_info'] = array_merge($_SESSION['egw_info_cache'],array('flags' => $GLOBALS['egw_info']['flags']));
|
||||
|
||||
// including the necessary class-definitions
|
||||
foreach($_SESSION['egw_included_files'] as $file)
|
||||
// include required class-definitions
|
||||
if (is_array($_SESSION['egw_required_files'])) // all classes, which can not be autoloaded
|
||||
{
|
||||
if (basename($file) == 'class.config.inc.php') continue;
|
||||
//echo "<p>about to include $file</p>\n";
|
||||
include_once($file);
|
||||
if (basename($file) == 'class.egw_framework.inc.php') break; // the rest is not needed and makes only problems
|
||||
foreach($_SESSION['egw_required_files'] as $file)
|
||||
{
|
||||
require_once($file);
|
||||
}
|
||||
}
|
||||
$GLOBALS['egw'] = unserialize($_SESSION['egw_object_cache']);
|
||||
include_once(EGW_API_INC.'/class.config.inc.php');
|
||||
|
||||
if (is_object($GLOBALS['egw']))
|
||||
{
|
||||
@ -100,7 +96,7 @@ if ($GLOBALS['egw_info']['server']['sessions_type'] == 'php4-restore' && $_REQUE
|
||||
$GLOBALS['egw_info'] = array('flags'=>$GLOBALS['egw_info']['flags']);
|
||||
unset($GLOBALS['egw_info']['flags']['restored_from_session']);
|
||||
unset($_SESSION['egw_info_cache']);
|
||||
unset($_SESSION['egw_included_files']);
|
||||
unset($_SESSION['egw_required_files']);
|
||||
unset($_SESSION['egw_object_cache']);
|
||||
}
|
||||
//echo "<p>could not restore egw_info and the egw-object!!!</p>\n";
|
||||
@ -108,7 +104,7 @@ if ($GLOBALS['egw_info']['server']['sessions_type'] == 'php4-restore' && $_REQUE
|
||||
else // destroy the session-cache if called by login or logout
|
||||
{
|
||||
unset($_SESSION['egw_info_cache']);
|
||||
unset($_SESSION['egw_included_files']);
|
||||
unset($_SESSION['egw_required_files']);
|
||||
unset($_SESSION['egw_object_cache']);
|
||||
}
|
||||
}
|
||||
@ -177,7 +173,7 @@ else
|
||||
print_debug('domain',@$GLOBALS['egw_info']['user']['domain'],'api');
|
||||
|
||||
// the egw-object instanciates all sub-classes (eg. $GLOBALS['egw']->db) and the egw_info array
|
||||
$GLOBALS['egw'] =& CreateObject('phpgwapi.egw',array_keys($GLOBALS['egw_domain']));
|
||||
$GLOBALS['egw'] = new egw(array_keys($GLOBALS['egw_domain']));
|
||||
|
||||
if ($GLOBALS['egw_info']['flags']['currentapp'] != 'login')
|
||||
{
|
||||
@ -194,18 +190,5 @@ if ($GLOBALS['egw_info']['server']['sessions_type'] == 'php4-restore' && $GLOBAL
|
||||
$_SESSION['egw_info_cache'] = $GLOBALS['egw_info'];
|
||||
unset($_SESSION['egw_info_cache']['flags']); // dont save the flags, they change on each request
|
||||
|
||||
// exclude 1: caller, 2: the header.inc.php, 3: phpgwapi/setup/setup.inc.php, 4: phpgwapi/inc/functions.inc.php (this file)
|
||||
$_SESSION['egw_included_files'] = array();
|
||||
foreach(array_slice(get_included_files(),4) as $file)
|
||||
{
|
||||
switch(basename($file))
|
||||
{
|
||||
case 'header.inc.php': // needs EGW_TEMPLATE_DIR and is included anyway by common::egw_header()
|
||||
case 'functions.inc.php': // not needed/wanted at all
|
||||
break;
|
||||
default:
|
||||
$_SESSION['egw_included_files'][] = $file;
|
||||
}
|
||||
}
|
||||
$_SESSION['egw_object_cache'] = serialize($GLOBALS['egw']);
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user