fixed createobject to only include any given file once

This commit is contained in:
seek3r 2001-01-11 17:54:32 +00:00
parent 3e2952ece1
commit 156a6b6220
2 changed files with 8 additions and 14 deletions

View File

@ -99,18 +99,14 @@
/* Load selected accounts class */
if (empty($phpgw_info["server"]["account_repository"])){$phpgw_info["server"]["account_repository"] = $phpgw_info["server"]["auth_type"];}
$this->accounts = CreateObject("phpgwapi.accounts");
include($phpgw_info["server"]["api_inc"] . "/class.preferences.inc.php");
$this->preferences = new preferences(0);
//$this->preferences = CreateObject("phpgwapi.preferences", 0);
$this->preferences = CreateObject("phpgwapi.preferences", 0);
include($phpgw_info["server"]["api_inc"] . "/class.crypto.inc.php");
$this->session = CreateObject("phpgwapi.sessions");
if ($phpgw_info["flags"]["currentapp"] == "login") {
$log = explode("@",$login);
//$this->preferences = CreateObject("phpgwapi.preferences", $log[0]);
$this->preferences = new preferences($log[0]);
$this->preferences = CreateObject("phpgwapi.preferences", $log[0]);
}else{
if (! $this->session->verify()) {
$this->db->query("select config_value from config where config_name='webserver_url'",__LINE__,__FILE__);
@ -118,8 +114,7 @@
Header("Location: " . $this->redirect($this->link($this->db->f("config_value")."/login.php","cd=10")));
exit;
}
//$this->preferences = CreateObject("phpgwapi.preferences", intval($phpgw_info["user"]["account_id"]));
$this->preferences = new preferences(intval($phpgw_info["user"]["account_id"]));
$this->preferences = CreateObject("phpgwapi.preferences", intval($phpgw_info["user"]["account_id"]));
}
$this->translation = CreateObject("phpgwapi.translation");

View File

@ -24,16 +24,15 @@
* Direct functions, which are not part of the API class *
* for whatever reason. *
\****************************************************************************/
function CreateObject($classname, $val = ""){
function CreateObject($classname, $constructor_param = ""){
global $phpgw, $phpgw_info, $phpgw_domain;
$classpart = explode (".", $classname);
$includedChk = sprintf("%s_INC_PHP_INCLUDED", strtoupper($classpart[1]));
//$includedChk = sprintf("%s_PHP3_INCLUDED", strtoupper($classpart[1]));
if (!isset($GLOBALS["$includedChk"])){
if (!$phpgw_info["flags"]["included_classes"][$classpart[1]]){
$phpgw_info["flags"]["included_classes"][$classpart[1]] = True;
include($phpgw_info["server"]["include_root"]."/".$classpart[0]."/inc/class.".$classpart[1].".inc.php");
$obj = new $classpart[1]($val);
return $obj;
}
$obj = new $classpart[1]($constructor_param);
return $obj;
}
function lang($key, $m1="", $m2="", $m3="", $m4="", $m5="", $m6="", $m7="", $m8="", $m9="", $m10="" )