mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-27 09:09:04 +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
|
||||
*
|
||||
|
@ -1,35 +1,36 @@
|
||||
<?php
|
||||
/**************************************************************************\
|
||||
* eGroupWare API loader *
|
||||
* This file was originaly written by Dan Kuykendall and Joseph Engo *
|
||||
* Copyright (C) 2000, 2001 Dan Kuykendall *
|
||||
* Parts Copyright (C) 2003 Free Software Foundation *
|
||||
* -------------------------------------------------------------------------*
|
||||
* Rewritten by RalfBecker@outdoor-training.de to store the eGW enviroment *
|
||||
* (egw-object and egw_info-array) in a php-session and restore it from *
|
||||
* there instead of creating it completly new on each page-request. *
|
||||
* The enviroment gets now created by the egw-class *
|
||||
* -------------------------------------------------------------------------*
|
||||
* This library is part of the eGroupWare API http://www.egroupware.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. *
|
||||
\**************************************************************************/
|
||||
/**
|
||||
* eGroupWare API - Applications
|
||||
*
|
||||
* @link http://www.egroupware.org
|
||||
* This file was originaly written by Dan Kuykendall and Joseph Engo
|
||||
* Copyright (C) 2000, 2001 Dan Kuykendall
|
||||
* Parts Copyright (C) 2003 Free Software Foundation
|
||||
* @author RalfBecker@outdoor-training.de
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package api
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
/**
|
||||
/**
|
||||
* New written class to create the eGW enviroment AND restore it from a php-session
|
||||
*
|
||||
* @author RalfBecker@outdoor-training.de
|
||||
* @copyright GPL
|
||||
* @package api
|
||||
* @access public
|
||||
* Rewritten by RalfBecker@outdoor-training.de to store the eGW enviroment
|
||||
* (egw-object and egw_info-array) in a php-session and restore it from
|
||||
* there instead of creating it completly new on each page-request.
|
||||
* The enviroment gets now created by the egw-class
|
||||
*
|
||||
* Use now a php5 getter method to create the usuall subobject on demand, to allow a quicker
|
||||
* header include on sites not useing php4-restore.
|
||||
* This also makes a lot of application code, like the following, unnecessary:
|
||||
* if (!is_object($GLOBALS['egw']->datetime)
|
||||
* {
|
||||
* $GLOBALS['egw']->datetime = CreateObject('phpgwapi.datetime');
|
||||
* }
|
||||
* You can now simply use $GLOBALS['egw']->datetime, and the egw class instanciates it for you on demand.
|
||||
*/
|
||||
class egw
|
||||
{
|
||||
class egw
|
||||
{
|
||||
/**
|
||||
* Turn on debug mode. Will output additional data for debugging purposes.
|
||||
* @var string
|
||||
@ -42,7 +43,6 @@
|
||||
* @var egw_db
|
||||
*/
|
||||
var $db;
|
||||
var $config_table = 'egw_config';
|
||||
/**
|
||||
* Instance of the account object
|
||||
*
|
||||
@ -55,13 +55,12 @@
|
||||
* @var common
|
||||
*/
|
||||
var $common;
|
||||
|
||||
/**
|
||||
* savant2 templating object
|
||||
* Current app at the instancation of the class
|
||||
*
|
||||
* @var tplsavant2
|
||||
* @var string
|
||||
*/
|
||||
var $tplsav2;
|
||||
var $currentapp;
|
||||
|
||||
/**
|
||||
* Constructor: Instantiates the sub-classes
|
||||
@ -69,7 +68,7 @@
|
||||
* @author RalfBecker@outdoor-training.de
|
||||
* @param array $domain_names array with valid egw-domain names
|
||||
*/
|
||||
function egw($domain_names=null)
|
||||
function __construct($domain_names=null)
|
||||
{
|
||||
$GLOBALS['egw'] =& $this; // we need to be immediately available there for the other classes we instantiate
|
||||
// for the migration: reference us to the old phpgw object
|
||||
@ -87,7 +86,7 @@
|
||||
function setup($domain_names,$createsessionobject=True)
|
||||
{
|
||||
// create the DB-object
|
||||
$this->db =& CreateObject('phpgwapi.egw_db');
|
||||
$this->db = new egw_db();
|
||||
if ($this->debug)
|
||||
{
|
||||
$this->db->Debug = 1;
|
||||
@ -104,14 +103,12 @@
|
||||
$GLOBALS['egw_info']['server']['db_type']
|
||||
);
|
||||
// check if eGW is already setup, if not redirect to setup/
|
||||
$this->db->select($this->config_table,'COUNT(config_name)',false,__LINE__,__FILE__);
|
||||
if(!$this->db->next_record())
|
||||
if (!$this->db->select(config::TABLE,'COUNT(config_name)',false,__LINE__,__FILE__)->fetchSingle())
|
||||
{
|
||||
$setup_dir = str_replace($_SERVER['PHP_SELF'],'index.php','setup/');
|
||||
|
||||
// we check for the old table too, to not scare updating users ;-)
|
||||
$this->db->select('phpgw_config','COUNT(config_name)',false,__LINE__,__FILE__);
|
||||
if ($this->db->next_record())
|
||||
if ($this->db->select('phpgw_config','COUNT(config_name)',false,__LINE__,__FILE__)->fetchSingle())
|
||||
{
|
||||
throw new Exception('<center><b>Fatal Error:</b> You need to <a href="' . $setup_dir . '">update eGroupWare</a> before you can continue using it.</center>',999);
|
||||
}
|
||||
@ -125,46 +122,38 @@
|
||||
$this->db->Halt_On_Error = 'yes';
|
||||
|
||||
// Set the DB's client charset if a system-charset is set
|
||||
$this->db->select($this->config_table,'config_value',array(
|
||||
$system_charset = $this->db->select(config::TABLE,'config_value',array(
|
||||
'config_app' => 'phpgwapi',
|
||||
'config_name' => 'system_charset',
|
||||
),__LINE__,__FILE__);
|
||||
if ($this->db->next_record() && $this->db->f(0))
|
||||
),__LINE__,__FILE__)->fetchSingle();
|
||||
if ($system_charset)
|
||||
{
|
||||
$this->db->Link_ID->SetCharSet($this->db->f(0));
|
||||
$this->db->Link_ID->SetCharSet($system_charset);
|
||||
}
|
||||
// load up the $GLOBALS['egw_info']['server'] array
|
||||
$this->db->select($this->config_table,'*',array('config_app' => 'phpgwapi'),__LINE__,__FILE__);
|
||||
while (($row = $this->db->row(true)))
|
||||
foreach($this->db->select(config::TABLE,'*',array('config_app' => 'phpgwapi'),__LINE__,__FILE__) as $row)
|
||||
{
|
||||
$GLOBALS['egw_info']['server'][$row['config_name']] = stripslashes($row['config_value']);
|
||||
}
|
||||
//$GLOBALS['egw_info']['server'] = config::read('phpgwapi'); would unserialize arrays
|
||||
|
||||
// setup the other subclasses
|
||||
$this->log =& CreateObject('phpgwapi.errorlog');
|
||||
$this->translation =& CreateObject('phpgwapi.translation');
|
||||
$this->common =& CreateObject('phpgwapi.common');
|
||||
$this->hooks =& CreateObject('phpgwapi.hooks');
|
||||
$this->auth =& CreateObject('phpgwapi.auth');
|
||||
# maybe we can also include this file at another place
|
||||
# with PHP5 we can also use autoloading now
|
||||
include_once(EGW_INCLUDE_ROOT.'/phpgwapi/inc/class.accounts.inc.php');
|
||||
$this->translation = new translation();
|
||||
$this->common = new common();
|
||||
$this->auth = new auth();
|
||||
$this->accounts = accounts::getInstance();
|
||||
$this->acl =& CreateObject('phpgwapi.acl');
|
||||
$this->acl = new acl();
|
||||
/* Do not create the session object if called by the sessions class. This way
|
||||
* we ensure the correct db based on the user domain.
|
||||
*/
|
||||
if($createsessionobject)
|
||||
{
|
||||
$this->session =& CreateObject('phpgwapi.sessions',$domain_names);
|
||||
$this->session = new sessions($domain_names);
|
||||
}
|
||||
$this->preferences =& CreateObject('phpgwapi.preferences');
|
||||
$this->applications =& CreateObject('phpgwapi.applications');
|
||||
$this->contenthistory =& CreateObject('phpgwapi.contenthistory');
|
||||
$this->datetime =& CreateObject('phpgwapi.egw_datetime');
|
||||
$this->preferences = new preferences();
|
||||
$this->applications = new applications();
|
||||
|
||||
include_once(EGW_INCLUDE_ROOT.'/phpgwapi/inc/class.error.inc.php');
|
||||
|
||||
register_shutdown_function(array($this->common, 'egw_final'));
|
||||
register_shutdown_function(array($this, 'shutdown'));
|
||||
|
||||
if ($GLOBALS['egw_info']['flags']['currentapp'] != 'login' && $GLOBALS['egw_info']['flags']['currentapp'] != 'logout')
|
||||
{
|
||||
@ -173,12 +162,6 @@
|
||||
|
||||
$this->define_egw_constants();
|
||||
|
||||
// setup the new eGW framework (template sets)
|
||||
$class = $GLOBALS['egw_info']['server']['template_set'].'_framework';
|
||||
require_once(EGW_INCLUDE_ROOT . '/phpgwapi/templates/' . $GLOBALS['egw_info']['server']['template_set'].
|
||||
'/class.'.$class.'.inc.php');
|
||||
$this->framework = new $class; // =& removed because of problems with php4, does not matter with php5 anyway!
|
||||
|
||||
$this->check_app_rights();
|
||||
|
||||
$this->load_optional_classes();
|
||||
@ -199,30 +182,14 @@
|
||||
$GLOBALS['egw'] =& $this; // we need to be immediately available there for the other classes we instantiate
|
||||
// for the migration: reference us to the old phpgw object
|
||||
$GLOBALS['phpgw'] =& $this;
|
||||
register_shutdown_function(array($this->common, 'egw_final'));
|
||||
|
||||
$this->db->connect(); // we need to re-connect
|
||||
// Set the DB's client charset if a system-charset is set
|
||||
$this->db->select($this->config_table,'config_value',array(
|
||||
'config_app' => 'phpgwapi',
|
||||
'config_name' => 'system_charset',
|
||||
),__LINE__,__FILE__);
|
||||
if ($this->db->next_record() && $this->db->f(0))
|
||||
if ($GLOBALS['egw_info']['server']['system_charset'])
|
||||
{
|
||||
$this->db->Link_ID->SetCharSet($this->db->f(0));
|
||||
$this->db->Link_ID->SetCharSet($GLOBALS['egw_info']['server']['system_charset']);
|
||||
}
|
||||
|
||||
if ($GLOBALS['egw_info']['system']['system_charset'])
|
||||
{
|
||||
$this->db->Link_ID->SetCharSet($GLOBALS['egw_info']['system']['system_charset']);
|
||||
}
|
||||
foreach(array('translation','hooks','auth','accounts','acl','session','preferences','applications','contenthistory','contacts') as $class)
|
||||
{
|
||||
if (is_object($this->$class->db))
|
||||
{
|
||||
$this->$class->db->Link_ID =& $this->db->Link_ID;
|
||||
}
|
||||
}
|
||||
register_shutdown_function(array($this, 'shutdown'));
|
||||
|
||||
$this->define_egw_constants();
|
||||
}
|
||||
|
||||
@ -236,7 +203,7 @@
|
||||
function wakeup2()
|
||||
{
|
||||
// do some application specific stuff, need to be done as we are different (current) app now
|
||||
if (is_object($this->template))
|
||||
if (isset($this->template))
|
||||
{
|
||||
$this->template->set_root(EGW_APP_TPL);
|
||||
}
|
||||
@ -258,22 +225,6 @@
|
||||
*/
|
||||
function load_optional_classes()
|
||||
{
|
||||
// load classes explicitly mentioned
|
||||
foreach($GLOBALS['egw_info']['flags'] as $enable_class => $enable)
|
||||
{
|
||||
if ($enable && substr($enable_class,0,7) == 'enable_')
|
||||
{
|
||||
$enable_class = substr($enable_class,7,-6);
|
||||
$this->$enable_class =& CreateObject('phpgwapi.'.$enable_class);
|
||||
}
|
||||
}
|
||||
|
||||
// load the template class, if not turned off
|
||||
if(!$GLOBALS['egw_info']['flags']['disable_Template_class'])
|
||||
{
|
||||
$this->template =& CreateObject('phpgwapi.Template',EGW_APP_TPL);
|
||||
}
|
||||
|
||||
// output the header unless the developer turned it off
|
||||
if (!@$GLOBALS['egw_info']['flags']['noheader'])
|
||||
{
|
||||
@ -347,6 +298,8 @@
|
||||
*/
|
||||
function check_app_rights()
|
||||
{
|
||||
$this->currentapp = $GLOBALS['egw_info']['flags']['currentapp']; // some apps change it later
|
||||
|
||||
if ($GLOBALS['egw_info']['flags']['currentapp'] != 'about')
|
||||
{
|
||||
// This will need to use ACL in the future
|
||||
@ -357,25 +310,8 @@
|
||||
{
|
||||
throw new egw_exception_no_permission_admin();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new egw_exception_no_permission_app($currentapp);
|
||||
}
|
||||
// old code no longer called
|
||||
$this->common->egw_header();
|
||||
if ($GLOBALS['egw_info']['flags']['nonavbar'])
|
||||
{
|
||||
echo parse_navbar();
|
||||
}
|
||||
error_log('Permission denied, attempted to access '.$GLOBALS['egw_info']['flags']['currentapp']);
|
||||
$this->log->write(array('text'=>'W-Permissions, Attempted to access %1','p1'=>$GLOBALS['egw_info']['flags']['currentapp']));
|
||||
|
||||
$this->tplsav2 = CreateObject('phpgwapi.tplsavant2'); // create it only when neccessary
|
||||
$this->tplsav2->assign('currentapp',$GLOBALS['egw_info']['flags']['currentapp']);
|
||||
$this->tplsav2->set_tpl_path($this->tplsav2->get_tpl_dir(false,'phpgwapi'));
|
||||
$this->tplsav2->display('appl_access_not_permitted.tpl.php');
|
||||
$this->common->egw_exit(True);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -433,7 +369,6 @@
|
||||
function invalidate_session_cache()
|
||||
{
|
||||
unset($_SESSION['egw_info_cache']);
|
||||
unset($_SESSION['egw_included_files']);
|
||||
unset($_SESSION['egw_object_cache']);
|
||||
}
|
||||
|
||||
@ -451,8 +386,6 @@
|
||||
/**
|
||||
* Link url generator
|
||||
*
|
||||
* Used for backwards compatibility and as a shortcut. If no url is passed, it will use PHP_SELF. Wrapper to session->link()
|
||||
*
|
||||
* @param string $string The url the link is for
|
||||
* @param string/array $extravars Extra params to be passed to the url
|
||||
* @return string The full url after processing
|
||||
@ -462,6 +395,13 @@
|
||||
return $this->session->link($url, $extravars);
|
||||
}
|
||||
|
||||
/**
|
||||
* Redirects direct to a generated link
|
||||
*
|
||||
* @param string $string The url the link is for
|
||||
* @param string/array $extravars Extra params to be passed to the url
|
||||
* @return string The full url after processing
|
||||
*/
|
||||
function redirect_link($url = '',$extravars='')
|
||||
{
|
||||
$this->redirect($this->session->link($url, $extravars));
|
||||
@ -518,4 +458,104 @@
|
||||
}
|
||||
return $this->translation->translate($key,$args);
|
||||
}
|
||||
|
||||
/**
|
||||
* eGW's shutdown handler
|
||||
*/
|
||||
function shutdown()
|
||||
{
|
||||
if (!defined('EGW_SHUTDOWN'))
|
||||
{
|
||||
define('EGW_SHUTDOWN',True);
|
||||
|
||||
if (isset($this->accounts))
|
||||
{
|
||||
$this->accounts->save_session_cache();
|
||||
}
|
||||
if (class_exists('egw_link',false)) // false = no autoload!
|
||||
{
|
||||
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 (isset($this->crypto))
|
||||
{
|
||||
$this->crypto->cleanup();
|
||||
unset($this->crypto);
|
||||
}
|
||||
$this->db->disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Classes which get instanciated in a different name
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
static $sub_objects = array(
|
||||
'log' => 'errorlog',
|
||||
'js' => 'javascript',
|
||||
'link' => 'bolink', // depricated use static egw_link methods
|
||||
'datetime' => 'egw_datetime',
|
||||
'session' => 'sessions',
|
||||
'framework' => true, // special handling in __get()
|
||||
'template' => 'Template',
|
||||
);
|
||||
|
||||
/**
|
||||
* Magic function to check if a sub-object is set
|
||||
*
|
||||
* @param string $name
|
||||
* @return boolean
|
||||
*/
|
||||
function __isset($name)
|
||||
{
|
||||
//error_log(__METHOD__."($name)");
|
||||
return isset($this->$name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic function to return a sub-object
|
||||
*
|
||||
* @param string $name
|
||||
* @return mixed
|
||||
*/
|
||||
function __get($name)
|
||||
{
|
||||
error_log(__METHOD__."($name)".function_backtrace());
|
||||
|
||||
if (isset($this->$name))
|
||||
{
|
||||
return $this->$name;
|
||||
}
|
||||
|
||||
if (!isset(self::$sub_objects[$name]) && !class_exists($name))
|
||||
{
|
||||
error_log(__METHOD__.": There's NO $name object!");
|
||||
return null;
|
||||
}
|
||||
switch($name)
|
||||
{
|
||||
case 'framework':
|
||||
// setup the new eGW framework (template sets)
|
||||
$class = $GLOBALS['egw_info']['server']['template_set'].'_framework';
|
||||
require_once($file=EGW_INCLUDE_ROOT.'/phpgwapi/templates/'.$GLOBALS['egw_info']['server']['template_set'].'/class.'.$class.'.inc.php');
|
||||
if (!in_array($file,(array)$_SESSION['egw_required_files']))
|
||||
{
|
||||
$_SESSION['egw_required_files'][] = $file; // automatic load the used framework class, when the object get's restored
|
||||
}
|
||||
break;
|
||||
case 'template': // need to be instancated for the current app
|
||||
return $this->template = new Template($GLOBALS['egw']->common->get_tpl_dir($this->currentapp));
|
||||
default:
|
||||
$class = isset(self::$sub_objects[$name]) ? self::$sub_objects[$name] : $name;
|
||||
break;
|
||||
}
|
||||
return $this->$name = new $class();
|
||||
}
|
||||
}
|
||||
|
@ -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,10 +377,28 @@ 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,19 +387,14 @@ 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))
|
||||
function _get_notification_bell()
|
||||
{
|
||||
$GLOBALS['egw']->html =& new html();
|
||||
}
|
||||
return $GLOBALS['egw']->html->div( $GLOBALS['egw']->html->a_href( $GLOBALS['egw']->html->image('notifications','notificationbell',lang('notifications')),
|
||||
return html::div(
|
||||
html::a_href(
|
||||
html::image('notifications','notificationbell',lang('notifications')),
|
||||
'javascript: notificationwindow_display();'
|
||||
),
|
||||
'id="notificationbell"', // options
|
||||
@ -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,12 +686,21 @@
|
||||
if (class_exists($classname))
|
||||
{
|
||||
$args = func_get_args();
|
||||
if(count($args) == 1)
|
||||
switch(count($args))
|
||||
{
|
||||
case 1:
|
||||
$obj =& new $classname;
|
||||
}
|
||||
else
|
||||
{
|
||||
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)
|
||||
{
|
||||
@ -702,6 +711,7 @@
|
||||
}
|
||||
$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();
|
||||
}
|
||||
}
|
||||
/* 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,11 +853,9 @@
|
||||
return $returnval;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
*/
|
||||
return "<p>ExecMethod('$method'): error in parts!<br />".function_backtrace()."</p>\n";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* duplicates the result of copying an object under php3/4 even when using php5
|
||||
@ -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']);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
/**
|
||||
/**
|
||||
* eGW idots template
|
||||
*
|
||||
* @link http://www.egroupware.org
|
||||
@ -12,20 +12,15 @@
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
require_once(EGW_API_INC.'/class.egw_framework.inc.php');
|
||||
require_once(EGW_API_INC.'/class.Template.inc.php');
|
||||
require_once(EGW_API_INC.'/class.dragdrop.inc.php');
|
||||
require_once(EGW_API_INC.'/class.tplsavant2.inc.php');
|
||||
|
||||
/**
|
||||
* eGW idots template
|
||||
*
|
||||
* The idots_framework class draws the default idots template. It's a phplib template based template-set.
|
||||
*
|
||||
* Other phplib template based template-sets should extend (not copy!) this class and reimplement methods they which to change.
|
||||
*/
|
||||
class idots_framework extends egw_framework
|
||||
{
|
||||
/**
|
||||
* eGW idots template
|
||||
*
|
||||
* The idots_framework class draws the default idots template. It's a phplib template based template-set.
|
||||
*
|
||||
* Other phplib template based template-sets should extend (not copy!) this class and reimplement methods they which to change.
|
||||
*/
|
||||
class idots_framework extends egw_framework
|
||||
{
|
||||
/**
|
||||
* HTML of the sidebox menu, get's collected here by calls to $this->sidebox
|
||||
*
|
||||
@ -160,17 +155,14 @@
|
||||
}
|
||||
if($GLOBALS['egw_info']['user']['apps']['manual'] && $apps['manual'])
|
||||
{
|
||||
$file['manual'] = array('text' => 'manual',
|
||||
$file['manual'] = array(
|
||||
'text' => 'manual',
|
||||
'no_lang' => false,
|
||||
'target' => $apps['manual']['target'],
|
||||
'link' => $apps['manual']['url']);
|
||||
'link' => $apps['manual']['url']
|
||||
);
|
||||
}
|
||||
$file += array(
|
||||
/*array(
|
||||
'text' => lang('About %1',$GLOBALS['egw_info']['apps'][$GLOBALS['egw_info']['flags']['currentapp']]['title']),
|
||||
'no_lang' => True,
|
||||
'link' => $apps['about']['url']
|
||||
),*/
|
||||
$GLOBALS['egw_info']['user']['userid'] != 'anonymous' ? 'Logout' : 'Login' =>$apps['logout']['url']
|
||||
);
|
||||
$this->sidebox('',$menu_title,$file);
|
||||
@ -206,7 +198,7 @@
|
||||
{
|
||||
$sideboxwidth = $GLOBALS['egw_info']['user']['preferences']['common']['idotssideboxwidth'];
|
||||
}
|
||||
if(intval($sideboxwidth)<1)
|
||||
if((int)$sideboxwidth < 1)
|
||||
{
|
||||
$sideboxwidth = 203;
|
||||
}
|
||||
@ -267,11 +259,7 @@
|
||||
function login_screen($extra_vars)
|
||||
{
|
||||
$tmpl =& new Template($GLOBALS['egw_info']['server']['template_dir']);
|
||||
if (!is_object($GLOBALS['egw']->html))
|
||||
{
|
||||
require_once(EGW_API_INC.'/class.html.inc.php');
|
||||
$GLOBALS['egw']->html = new html;
|
||||
}
|
||||
|
||||
$tmpl->set_file(array('login_form' => 'login.tpl'));
|
||||
|
||||
$tmpl->set_var('lang_message',$GLOBALS['loginscreenmessage']);
|
||||
@ -286,7 +274,7 @@
|
||||
}
|
||||
$tmpl->set_var(array(
|
||||
'lang_domain' => lang('domain'),
|
||||
'select_domain' => $GLOBALS['egw']->html->select('logindomain',$_COOKIE['last_domain'],$domains,true),
|
||||
'select_domain' => html::select('logindomain',$_COOKIE['last_domain'],$domains,true),
|
||||
));
|
||||
}
|
||||
else
|
||||
@ -294,7 +282,7 @@
|
||||
/* trick to make domain section disapear */
|
||||
$tmpl->set_block('login_form','domain_selection');
|
||||
$tmpl->set_var('domain_selection',$GLOBALS['egw_info']['user']['domain'] ?
|
||||
$GLOBALS['egw']->html->input_hidden('logindomain',$GLOBALS['egw_info']['user']['domain']) : '');
|
||||
html::input_hidden('logindomain',$GLOBALS['egw_info']['user']['domain']) : '');
|
||||
|
||||
if($last_loginid !== '')
|
||||
{
|
||||
@ -308,11 +296,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
require_once(EGW_API_INC.'/class.config.inc.php');
|
||||
$cnf_reg =& new config('registration');
|
||||
$cnf_reg->read_repository();
|
||||
$config_reg = $cnf_reg->config_data;
|
||||
unset($cnf_reg);
|
||||
$config_reg = config::read('registration');
|
||||
|
||||
if($config_reg['enable_registration'] == 'True')
|
||||
{
|
||||
@ -379,7 +363,7 @@
|
||||
{
|
||||
$tmpl->set_var(array(
|
||||
'lang_language' => lang('Language'),
|
||||
'select_language' => $GLOBALS['egw']->html->select('lang',$GLOBALS['egw_info']['user']['preferences']['common']['lang'],
|
||||
'select_language' => html::select('lang',$GLOBALS['egw_info']['user']['preferences']['common']['lang'],
|
||||
$GLOBALS['egw']->translation->get_installed_langs(),true),
|
||||
));
|
||||
}
|
||||
@ -398,7 +382,7 @@
|
||||
{
|
||||
$tmpl->set_block('login_form','remember_me_selection');
|
||||
$tmpl->set_var('lang_remember_me',lang('Remember me'));
|
||||
$tmpl->set_var('select_remember_me',$GLOBALS['egw']->html->select('remember_me', 'forever', array(
|
||||
$tmpl->set_var('select_remember_me',html::select('remember_me', 'forever', array(
|
||||
false => lang('not'),
|
||||
'1hour' => lang('1 Hour'),
|
||||
'1day' => lang('1 Day'),
|
||||
@ -415,11 +399,6 @@
|
||||
}
|
||||
$tmpl->set_var('autocomplete', ($GLOBALS['egw_info']['server']['autocomplete_login'] ? 'autocomplete="off"' : ''));
|
||||
|
||||
if (!is_object($GLOBALS['egw']->js))
|
||||
{
|
||||
require_once(EGW_API_INC.'/class.javascript.inc.php');
|
||||
$GLOBALS['egw']->js = new javascript();
|
||||
}
|
||||
$GLOBALS['egw']->js->set_onload('document.login_form.login.focus();');
|
||||
|
||||
$this->render($tmpl->fp('loginout','login_form'),false,false);
|
||||
@ -475,11 +454,7 @@
|
||||
|
||||
if($GLOBALS['egw_info']['user']['userid'] == 'anonymous')
|
||||
{
|
||||
require_once(EGW_API_INC.'/class.config.inc.php');
|
||||
$cnf_reg =& new config('registration');
|
||||
$cnf_reg->read_repository();
|
||||
$config_reg = $cnf_reg->config_data;
|
||||
unset($cnf_reg);
|
||||
$config_reg = config::read('registration');
|
||||
|
||||
$this->tpl->set_var(array(
|
||||
'url' => $GLOBALS['egw']->link('/logout.php'),
|
||||
@ -659,12 +634,7 @@
|
||||
|
||||
if(!is_null($tooltip))
|
||||
{
|
||||
if (!is_object($GLOBALS['egw']->html))
|
||||
{
|
||||
require_once(EGW_API_INC.'/class.html.inc.php');
|
||||
$GLOBALS['egw']->html = new html;
|
||||
}
|
||||
$icon_arr['tooltip'] = $GLOBALS['egw']->html->tooltip($tooltip);
|
||||
$icon_arr['tooltip'] = html::tooltip($tooltip);
|
||||
}
|
||||
|
||||
$this->topmenu_icon_arr[]=$icon_arr;
|
||||
@ -712,23 +682,23 @@
|
||||
}
|
||||
if (DEBUG_TIMER)
|
||||
{
|
||||
$totaltime = sprintf('%4.2lf',perfgetmicrotime() - $GLOBALS['egw_info']['flags']['page_start_time']);
|
||||
$totaltime = sprintf('%4.2lf',microtime(true) - $GLOBALS['egw_info']['flags']['page_start_time']);
|
||||
|
||||
$content .= lang('Page was generated in %1 seconds',$totaltime);
|
||||
}
|
||||
return $content;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses one sidebox menu and add's the html to $this->sidebox_content for later use by $this->navbar
|
||||
*
|
||||
* @param string $appname
|
||||
* @param string $menu_title
|
||||
* @param array $file
|
||||
*/
|
||||
function sidebox($appname,$menu_title,$file)
|
||||
{
|
||||
/**
|
||||
* Parses one sidebox menu and add's the html to $this->sidebox_content for later use by $this->navbar
|
||||
*
|
||||
* @param string $appname
|
||||
* @param string $menu_title
|
||||
* @param array $file
|
||||
*/
|
||||
function sidebox($appname,$menu_title,$file)
|
||||
{
|
||||
if((!$appname || ($appname==$GLOBALS['egw_info']['flags']['currentapp'] && $file)) && is_object($this->tpl))
|
||||
{
|
||||
$this->tpl->set_var('lang_title',$menu_title);
|
||||
@ -740,18 +710,18 @@ function sidebox($appname,$menu_title,$file)
|
||||
}
|
||||
$this->sidebox_content .= $this->tpl->parse('out','extra_blocks_footer');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a sidebox menu item
|
||||
*
|
||||
* @internal PHP5 protected
|
||||
* @param string $item_link
|
||||
* @param string $item_text
|
||||
* @return string
|
||||
*/
|
||||
function _sidebox_menu_item($item_link='',$item_text='')
|
||||
{
|
||||
/**
|
||||
* Return a sidebox menu item
|
||||
*
|
||||
* @internal PHP5 protected
|
||||
* @param string $item_link
|
||||
* @param string $item_text
|
||||
* @return string
|
||||
*/
|
||||
function _sidebox_menu_item($item_link='',$item_text='')
|
||||
{
|
||||
if($item_text === '_NewLine_' || $item_link === '_NewLine_')
|
||||
{
|
||||
return $this->tpl->parse('out','extra_block_spacer');
|
||||
@ -774,9 +744,12 @@ function _sidebox_menu_item($item_link='',$item_text='')
|
||||
$var['item_link'] = $item_link['link'];
|
||||
if ($item_link['target'])
|
||||
{
|
||||
if (strpos($item_link['target'], 'target=') !== false) {
|
||||
if (strpos($item_link['target'], 'target=') !== false)
|
||||
{
|
||||
$var['target'] = $item_link['target'];
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
$var['target'] = ' target="' . $item_link['target'] . '"';
|
||||
}
|
||||
}
|
||||
@ -794,5 +767,5 @@ function _sidebox_menu_item($item_link='',$item_text='')
|
||||
$block .= $var['icon_or_star'] === False ? '_raw' : '_no_link';
|
||||
}
|
||||
return $this->tpl->parse('out',$block);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user