From 7849d1ecbb1d1bdd84df7cee2798a57bd2e9b4b4 Mon Sep 17 00:00:00 2001 From: Miles Lott Date: Wed, 8 Aug 2001 23:28:03 +0000 Subject: [PATCH] Start work on calling boclasses --- phpgwapi/inc/class.xmlrpc_server.inc.php | 158 ++++------------------- phpgwapi/inc/xml_functions.inc.php | 135 ++++++++++++++++++- 2 files changed, 158 insertions(+), 135 deletions(-) diff --git a/phpgwapi/inc/class.xmlrpc_server.inc.php b/phpgwapi/inc/class.xmlrpc_server.inc.php index 46da0cca18..4fb94c61df 100644 --- a/phpgwapi/inc/class.xmlrpc_server.inc.php +++ b/phpgwapi/inc/class.xmlrpc_server.inc.php @@ -21,138 +21,6 @@ // XML RPC Server class // requires: xmlrpc.inc - // listMethods: either a string, or nothing - $_xmlrpcs_listMethods_sig = array(array($xmlrpcArray, $xmlrpcString), array($xmlrpcArray)); - $_xmlrpcs_listMethods_doc = 'This method lists all the methods that the XML-RPC server knows how to dispatch'; - function _xmlrpcs_listMethods($server, $m) - { - global $xmlrpcerr, $xmlrpcstr, $_xmlrpcs_dmap; - - $v = CreateObject('phpgwapi.xmlrpcval'); - $dmap = $server->dmap; - $outAr = array(); - for(reset($dmap); list($key, $val) = each($dmap); ) - { - $outAr[] = CreateObject('phpgwapi.xmlrpcval',$key, 'string'); - } - $dmap = $_xmlrpcs_dmap; - for(reset($dmap); list($key, $val) = each($dmap); ) - { - $outAr[] = CreateObject('phpgwapi.xmlrpcval',$key, 'string'); - } - $v->addArray($outAr); - return CreateObject('phpgwapi.xmlrpcresp',$v); - } - - $_xmlrpcs_methodSignature_sig=array(array($xmlrpcArray, $xmlrpcString)); - $_xmlrpcs_methodSignature_doc='Returns an array of known signatures (an array of arrays) for the method name passed. If no signatures are known, returns a none-array (test for type != array to detect missing signature)'; - function _xmlrpcs_methodSignature($server, $m) - { - global $xmlrpcerr, $xmlrpcstr, $_xmlrpcs_dmap; - - $methName = $m->getParam(0); - $methName = $methName->scalarval(); - if (ereg("^system\.", $methName)) - { - $dmap = $_xmlrpcs_dmap; - $sysCall = 1; - } - else - { - $dmap = $server->dmap; - $sysCall = 0; - } - // print "\n"; - if (isset($dmap[$methName])) - { - if ($dmap[$methName]['signature']) - { - $sigs = array(); - $thesigs=$dmap[$methName]['signature']; - for($i=0; $igetParam(0); - $methName = $methName->scalarval(); - if (ereg("^system\.", $methName)) - { - $dmap = $_xmlrpcs_dmap; $sysCall=1; - } - else - { - $dmap = $server->dmap; $sysCall=0; - } - // print "\n"; - if (isset($dmap[$methName])) - { - if ($dmap[$methName]['docstring']) - { - $r = CreateObject('phpgwapi.xmlrpcresp', CreateObject('phpgwapi.xmlrpcval',$dmap[$methName]['docstring']),'string'); - } - else - { - $r = CreateObject('phpgwapi.xmlrpcresp', CreateObject('phpgwapi.xmlrpcval'), 'string'); - } - } - else - { - $r = CreateObject('phpgwapi.xmlrpcresp',0,$xmlrpcerr['introspect_unknown'],$xmlrpcstr['introspect_unknown']); - } - return $r; - } - - $_xmlrpcs_dmap=array( - 'system.listMethods' => array( - 'function' => '_xmlrpcs_listMethods', - 'signature' => $_xmlrpcs_listMethods_sig, - 'docstring' => $_xmlrpcs_listMethods_doc - ), - 'system.methodHelp' => array( - 'function' => '_xmlrpcs_methodHelp', - 'signature' => $_xmlrpcs_methodHelp_sig, - 'docstring' => $_xmlrpcs_methodHelp_doc - ), - 'system.methodSignature' => array( - 'function' => '_xmlrpcs_methodSignature', - 'signature' => $_xmlrpcs_methodSignature_sig, - 'docstring' => $_xmlrpcs_methodSignature_doc - ) - ); - - $_xmlrpc_debuginfo = ''; - function xmlrpc_debugmsg($m) - { - global $_xmlrpc_debuginfo; - $_xmlrpc_debuginfo = $_xmlrpc_debuginfo . $m . "\n"; - } - /* BEGIN server class */ class xmlrpc_server { @@ -293,6 +161,20 @@ { $dmap = $this->dmap; $sysCall=0; } + if(!isset($dmap[$methName]['function'])) + { + /* these params are xmlrcpvals, need extract */ + $params = $_xh[$parser]['params']; + $code = "\$obj = ExecMethod('" . $methName . "',\$params);"; + /* echo $code; */ + /* _debug_array($params); */ + eval($code); + if(is_object($obj)) + { + /* This works */ + $dmap = $obj->xml_functions; + } + } if (isset($dmap[$methName]['function'])) { // dispatch if exists @@ -311,8 +193,16 @@ } else { - $code = '$r=' . $dmap[$methName]['function'] . '($m);'; - $code = ereg_replace(',,',",'',",$code); + if(function_exists($dmap[$methName]['function'])) + { + $code = '$r =' . $dmap[$methName]['function'] . '($m);'; + $code = ereg_replace(',,',",'',",$code); + } + else + { + $params = $_xh[$parser]['params']; + $code = '$r =' . "ExecMethod('" . $dmap[$methName]['function'] . "'" . ',$params);'; + } eval($code); } } diff --git a/phpgwapi/inc/xml_functions.inc.php b/phpgwapi/inc/xml_functions.inc.php index cd842db3df..afccd2828c 100644 --- a/phpgwapi/inc/xml_functions.inc.php +++ b/phpgwapi/inc/xml_functions.inc.php @@ -451,7 +451,7 @@ ****************************************************************/ function xmlrpc_decode($xmlrpc_val) { - $kind = $xmlrpc_val->kindOf(); + $kind = @$xmlrpc_val->kindOf(); if($kind == "scalar") { @@ -537,4 +537,137 @@ } return $xmlrpc_val; } + + // listMethods: either a string, or nothing + $_xmlrpcs_listMethods_sig = array(array($xmlrpcArray, $xmlrpcString), array($xmlrpcArray)); + $_xmlrpcs_listMethods_doc = 'This method lists all the methods that the XML-RPC server knows how to dispatch'; + function _xmlrpcs_listMethods($server, $m) + { + global $xmlrpcerr, $xmlrpcstr, $_xmlrpcs_dmap; + + $v = CreateObject('phpgwapi.xmlrpcval'); + $dmap = $server->dmap; + $outAr = array(); + for(reset($dmap); list($key, $val) = each($dmap); ) + { + $outAr[] = CreateObject('phpgwapi.xmlrpcval',$key, 'string'); + } + $dmap = $_xmlrpcs_dmap; + for(reset($dmap); list($key, $val) = each($dmap); ) + { + $outAr[] = CreateObject('phpgwapi.xmlrpcval',$key, 'string'); + } + $v->addArray($outAr); + return CreateObject('phpgwapi.xmlrpcresp',$v); + } + + $_xmlrpcs_methodSignature_sig=array(array($xmlrpcArray, $xmlrpcString)); + $_xmlrpcs_methodSignature_doc='Returns an array of known signatures (an array of arrays) for the method name passed. If no signatures are known, returns a none-array (test for type != array to detect missing signature)'; + function _xmlrpcs_methodSignature($server, $m) + { + global $xmlrpcerr, $xmlrpcstr, $_xmlrpcs_dmap; + + $methName = $m->getParam(0); + $methName = $methName->scalarval(); + if (ereg("^system\.", $methName)) + { + $dmap = $_xmlrpcs_dmap; + $sysCall = 1; + } + else + { + $dmap = $server->dmap; + $sysCall = 0; + } + // print "\n"; + if (isset($dmap[$methName])) + { + if ($dmap[$methName]['signature']) + { + $sigs = array(); + $thesigs=$dmap[$methName]['signature']; + for($i=0; $igetParam(0); + $methName = $methName->scalarval(); + if (ereg("^system\.", $methName)) + { + $dmap = $_xmlrpcs_dmap; $sysCall=1; + } + else + { + $dmap = $server->dmap; $sysCall=0; + } + // print "\n"; + if (isset($dmap[$methName])) + { + if ($dmap[$methName]['docstring']) + { + $r = CreateObject('phpgwapi.xmlrpcresp', CreateObject('phpgwapi.xmlrpcval',$dmap[$methName]['docstring']),'string'); + } + else + { + $r = CreateObject('phpgwapi.xmlrpcresp', CreateObject('phpgwapi.xmlrpcval'), 'string'); + } + } + else + { + $r = CreateObject('phpgwapi.xmlrpcresp',0,$xmlrpcerr['introspect_unknown'],$xmlrpcstr['introspect_unknown']); + } + return $r; + } + + $_xmlrpcs_dmap=array( + 'system.listMethods' => array( + 'function' => '_xmlrpcs_listMethods', + 'signature' => $_xmlrpcs_listMethods_sig, + 'docstring' => $_xmlrpcs_listMethods_doc + ), + 'system.methodHelp' => array( + 'function' => '_xmlrpcs_methodHelp', + 'signature' => $_xmlrpcs_methodHelp_sig, + 'docstring' => $_xmlrpcs_methodHelp_doc + ), + 'system.methodSignature' => array( + 'function' => '_xmlrpcs_methodSignature', + 'signature' => $_xmlrpcs_methodSignature_sig, + 'docstring' => $_xmlrpcs_methodSignature_doc + ) + ); + + $_xmlrpc_debuginfo = ''; + function xmlrpc_debugmsg($m) + { + global $_xmlrpc_debuginfo; + $_xmlrpc_debuginfo = $_xmlrpc_debuginfo . $m . "\n"; + } + ?>