From 9383ac2d97f7f7a1d6c58bd1ca48fed270a48244 Mon Sep 17 00:00:00 2001 From: seek3r Date: Fri, 3 Aug 2001 21:10:02 +0000 Subject: [PATCH] added inital version of ExecObj --- phpgwapi/inc/functions.inc.php | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/phpgwapi/inc/functions.inc.php b/phpgwapi/inc/functions.inc.php index 1806fd0670..db677523b3 100644 --- a/phpgwapi/inc/functions.inc.php +++ b/phpgwapi/inc/functions.inc.php @@ -86,6 +86,39 @@ error_reporting(E_ERROR | E_WARNING | E_PARSE); return $obj; } + + /*! + @function ExecObj + @abstract Execute a function, and load a class and include the class file if not done so already. + @discussion Author: seek3r
+ This function is used to create an instance of a class, + and if the class file has not been included it will do so.
+ Syntax: CreateObject('app.class', 'constructor_params');
+ Example1: ExecObj('phpgwapi.acl.read'); + @param $object to execute + @param $functionparams function param should be an array + @param $loglevel developers choice of logging level + @param $classparams params to be sent to the contructor + */ + function ExecObj($object, $functionparams, $loglevel, $classparams) + { + global $GLOBAL; + $objparts = explode (".", $object); + $appname = $objparts[0]; + $classname = $objparts[1]; + $functionname = $objparts[2]; + $code = 'global $'.$classname.';'; + eval($code); + if (!is_object($$classname)) + { + $classname = CreateObject($appname.'.'.$classname); + $code = '$'.$classname.' = CreateObject('.$appname.'.'.$classname.')';'; + /* $code = '$'.$classname.' = new '.$classname.';'; */ + eval($code); + } + ${$GLOBAL[$classname]}->${$functionname}; + } + /*! @function lang @abstract function to handle multilanguage support