mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-28 01:29:05 +01:00
Fix for multiple domains via xml-rpc to ensure the correct domain
This commit is contained in:
parent
d61920a22b
commit
08b61a050e
@ -1,26 +1,26 @@
|
||||
<?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 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. *
|
||||
\**************************************************************************/
|
||||
|
||||
/* $Id$ */
|
||||
/* $Id$ */
|
||||
|
||||
/**
|
||||
/**
|
||||
* New written class to create the eGW enviroment AND restore it from a php-session
|
||||
*
|
||||
* @author RalfBecker@outdoor-training.de
|
||||
@ -28,8 +28,8 @@
|
||||
* @package api
|
||||
* @access public
|
||||
*/
|
||||
class egw
|
||||
{
|
||||
class egw
|
||||
{
|
||||
/**
|
||||
* Turn on debug mode. Will output additional data for debugging purposes.
|
||||
* @var string $debug
|
||||
@ -43,17 +43,28 @@ class egw
|
||||
var $config_table = 'phpgw_config';
|
||||
|
||||
/**
|
||||
* Constructor: Instanciates the sub-classes
|
||||
* Constructor: Instantiates the sub-classes
|
||||
*
|
||||
* @author RalfBecker@outdoor-training.de
|
||||
* @param array $domain_names array with valid egw-domain names
|
||||
*/
|
||||
function egw($domain_names=null)
|
||||
{
|
||||
$GLOBALS['egw'] =& $this; // we need to be imediatly avalilible there for the other classes we instanciate
|
||||
$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;
|
||||
$this->setup($domain_names,True);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called every time the constructor is called. Also called by sessions to ensure the correct db,
|
||||
* in which case we do not recreate the session object.
|
||||
* @author RalfBecker@outdoor-training.de (moved to setup() by milos@groupwhere.org
|
||||
* @param array $domain_names array with valid egw-domain names
|
||||
* @param boolean $createsessionobject True to create the session object (default=True)
|
||||
*/
|
||||
function setup($domain_names,$createsessionobject=True)
|
||||
{
|
||||
// create the DB-object
|
||||
$this->db =& CreateObject('phpgwapi.egw_db');
|
||||
if ($this->debug)
|
||||
@ -105,7 +116,13 @@ class egw
|
||||
$this->auth =& CreateObject('phpgwapi.auth');
|
||||
$this->accounts =& CreateObject('phpgwapi.accounts');
|
||||
$this->acl =& CreateObject('phpgwapi.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->preferences =& CreateObject('phpgwapi.preferences');
|
||||
$this->applications =& CreateObject('phpgwapi.applications');
|
||||
$this->contenthistory =& CreateObject('phpgwapi.contenthistory');
|
||||
@ -141,7 +158,7 @@ class egw
|
||||
*/
|
||||
function __wakeup()
|
||||
{
|
||||
$GLOBALS['egw'] =& $this; // we need to be imediatly avalilible there for the other classes we instanciate
|
||||
$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'));
|
||||
@ -156,7 +173,7 @@ class egw
|
||||
}
|
||||
if ($GLOBALS['egw_info']['server']['account_repository'] == 'ldap')
|
||||
{
|
||||
// reconnect the LDAP server, unfortunally this does not work via accounts::__wakeup() as the common-object is not yet availible
|
||||
// reconnect the LDAP server, unfortunally this does not work via accounts::__wakeup() as the common-object is not yet available
|
||||
$this->accounts->ds = $this->common->ldapConnect();
|
||||
}
|
||||
$this->define_egw_constants();
|
||||
@ -274,7 +291,7 @@ class egw
|
||||
}
|
||||
|
||||
/**
|
||||
* Verfiy the user has rights for the requested app
|
||||
* Verify the user has rights for the requested app
|
||||
*
|
||||
* If the user has no rights for the app (eg. called via URL) he get a permission denied page (this function does NOT return)
|
||||
*/
|
||||
@ -330,7 +347,7 @@ class egw
|
||||
}
|
||||
|
||||
/**
|
||||
* create all the defines / constants of the eGW-enviroment (plus the depricated phpgw ones)
|
||||
* create all the defines / constants of the eGW-environment (plus the deprecated phpgw ones)
|
||||
*/
|
||||
function define_egw_constants()
|
||||
{
|
||||
@ -468,4 +485,4 @@ class egw
|
||||
}
|
||||
return $this->translation->translate($key,$args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -206,46 +206,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Introspection for XML-RPC/SOAP
|
||||
* Diabled - why??
|
||||
*
|
||||
* @param string $_type tpye of introspection being sought
|
||||
* @return array available methods and args
|
||||
*/
|
||||
function DONTlist_methods($_type)
|
||||
{
|
||||
if (is_array($_type))
|
||||
{
|
||||
$_type = $_type['type'];
|
||||
}
|
||||
|
||||
switch($_type)
|
||||
{
|
||||
case 'xmlrpc':
|
||||
$xml_functions = array(
|
||||
'list_methods' => array(
|
||||
'function' => 'list_methods',
|
||||
'signature' => array(array(xmlrpcStruct,xmlrpcString)),
|
||||
'docstring' => lang('Read this list of methods.')
|
||||
),
|
||||
'update_dla' => array(
|
||||
'function' => 'update_dla',
|
||||
'signature' => array(array(xmlrpcBoolean)),
|
||||
'docstring' => lang('Returns an array of todo items')
|
||||
)
|
||||
);
|
||||
return $xml_functions;
|
||||
break;
|
||||
case 'soap':
|
||||
return $this->soap_functions;
|
||||
break;
|
||||
default:
|
||||
return array();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function split_login_domain($both,&$login,&$domain)
|
||||
{
|
||||
$parts = explode('@',$both);
|
||||
@ -309,6 +269,20 @@
|
||||
|
||||
$this->split_login_domain($session['session_lid'],$this->account_lid,$this->account_domain);
|
||||
|
||||
/* This is to ensure that we authenticate to the correct domain (might not be default) */
|
||||
if($this->account_domain != $GLOBALS['egw_info']['user']['domain'])
|
||||
{
|
||||
$GLOBALS['egw']->ADOdb = null;
|
||||
$GLOBALS['egw_info']['user']['domain'] = $this->account_domain;
|
||||
// reset the db
|
||||
$GLOBALS['egw_info']['server']['db_host'] = $GLOBALS['egw_domain'][$this->account_domain]['db_host'];
|
||||
$GLOBALS['egw_info']['server']['db_port'] = $GLOBALS['egw_domain'][$this->account_domain]['db_port'];
|
||||
$GLOBALS['egw_info']['server']['db_name'] = $GLOBALS['egw_domain'][$this->account_domain]['db_name'];
|
||||
$GLOBALS['egw_info']['server']['db_user'] = $GLOBALS['egw_domain'][$this->account_domain]['db_user'];
|
||||
$GLOBALS['egw_info']['server']['db_pass'] = $GLOBALS['egw_domain'][$this->account_domain]['db_pass'];
|
||||
$GLOBALS['egw_info']['server']['db_type'] = $GLOBALS['egw_domain'][$this->account_domain]['db_type'];
|
||||
$GLOBALS['egw']->setup('',False);
|
||||
}
|
||||
$GLOBALS['egw_info']['user']['kp3'] = $this->kp3;
|
||||
|
||||
$this->update_dla();
|
||||
@ -325,7 +299,10 @@
|
||||
$this->iv = $GLOBALS['egw_info']['server']['mcrypt_iv'];
|
||||
$GLOBALS['egw']->crypto->init(array($this->key,$this->iv));
|
||||
|
||||
if ($fill_egw_info_and_repositories) $this->read_repositories(@$GLOBALS['egw_info']['server']['cache_phpgw_info']);
|
||||
if ($fill_egw_info_and_repositories)
|
||||
{
|
||||
$this->read_repositories(@$GLOBALS['egw_info']['server']['cache_phpgw_info']);
|
||||
}
|
||||
|
||||
if ($this->user['expires'] != -1 && $this->user['expires'] < time())
|
||||
{
|
||||
@ -500,6 +477,21 @@
|
||||
}
|
||||
$now = time();
|
||||
|
||||
/* This is to ensure that we authenticate to the correct domain (might not be default) */
|
||||
if($this->account_domain != $GLOBALS['egw_info']['user']['domain'])
|
||||
{
|
||||
$GLOBALS['egw']->ADOdb = null;
|
||||
$GLOBALS['egw_info']['user']['domain'] = $this->account_domain;
|
||||
// reset the db
|
||||
$GLOBALS['egw_info']['server']['db_host'] = $GLOBALS['egw_domain'][$this->account_domain]['db_host'];
|
||||
$GLOBALS['egw_info']['server']['db_port'] = $GLOBALS['egw_domain'][$this->account_domain]['db_port'];
|
||||
$GLOBALS['egw_info']['server']['db_name'] = $GLOBALS['egw_domain'][$this->account_domain]['db_name'];
|
||||
$GLOBALS['egw_info']['server']['db_user'] = $GLOBALS['egw_domain'][$this->account_domain]['db_user'];
|
||||
$GLOBALS['egw_info']['server']['db_pass'] = $GLOBALS['egw_domain'][$this->account_domain]['db_pass'];
|
||||
$GLOBALS['egw_info']['server']['db_type'] = $GLOBALS['egw_domain'][$this->account_domain]['db_type'];
|
||||
$GLOBALS['egw']->setup('',False);
|
||||
}
|
||||
|
||||
//echo "<p>session::create(login='$login'): lid='$this->account_lid', domain='$this->account_domain'</p>\n";
|
||||
$user_ip = $this->getuser_ip();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user