From 0ecc01baaa2275d70cc09f89f7b2f92f50899d38 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Sat, 25 Oct 2003 16:08:05 +0000 Subject: [PATCH] - fixed the parser to correctly return nested arrays/structs - added support for datetime.iso8601 type, it is recogniced by the regular expression '^[0-9]{8}T[0-9]{4}$' as php has no special datetime type --- phpgwapi/inc/class.xmlrpc_server.inc.php | 48 ++++++++---------------- 1 file changed, 15 insertions(+), 33 deletions(-) diff --git a/phpgwapi/inc/class.xmlrpc_server.inc.php b/phpgwapi/inc/class.xmlrpc_server.inc.php index 4d21ab9535..41fde67542 100644 --- a/phpgwapi/inc/class.xmlrpc_server.inc.php +++ b/phpgwapi/inc/class.xmlrpc_server.inc.php @@ -218,45 +218,28 @@ } } - function build_resp($_res,$recursed=False) + function build_resp($_res) { if (is_array($_res)) { - @reset($_res); - while (list($key,$val) = @each($_res)) + foreach($_res as $key => $val) { $ele[$key] = $this->build_resp($val,True); } - $this->resp_struct[] = CreateObject('phpgwapi.xmlrpcval',$ele,'struct'); + return CreateObject('phpgwapi.xmlrpcval',$ele,'struct'); } - else + $_type = (is_integer($_res) ? 'int' : gettype($_res)); + + if ($_type == string && ereg('^[0-9]{8}T[0-9]{4}$',$_res)) { - $_type = (is_integer($_res)?'int':gettype($_res)); - if ($recursed) - { - // Passing an integer of 0 to the xmlrpcval constructor results in the value being lost. (jengo) - if ($_type == 'int' && $_res == 0) - { - return CreateObject('phpgwapi.xmlrpcval','0',$_type); - } - else - { - return CreateObject('phpgwapi.xmlrpcval',$_res,$_type); - } - } - else - { - // Passing an integer of 0 to the xmlrpcval constructor results in the value being lost. (jengo) - if ($_type == 'int' && $_res == 0) - { - $this->resp_struct[] = CreateObject('phpgwapi.xmlrpcval','0',$_type); - } - else - { - $this->resp_struct[] = CreateObject('phpgwapi.xmlrpcval',$_res,$_type); - } - } + $_type = 'dateTime.iso8601'; } + // Passing an integer of 0 to the xmlrpcval constructor results in the value being lost. (jengo) + if ($_type == 'int' && $_res == 0) + { + return CreateObject('phpgwapi.xmlrpcval','0',$_type); + } + return CreateObject('phpgwapi.xmlrpcval',$_res,$_type); } function parseRequest($data='') @@ -271,7 +254,7 @@ $GLOBALS['_xh'][$parser] = array(); $GLOBALS['_xh'][$parser]['st'] = ''; - $GLOBALS['_xh'][$parser]['cm'] = 0; + $GLOBALS['_xh'][$parser]['cm'] = 0; $GLOBALS['_xh'][$parser]['isf'] = 0; $GLOBALS['_xh'][$parser]['params'] = array(); $GLOBALS['_xh'][$parser]['method'] = ''; @@ -424,8 +407,7 @@ } /* $res = ExecMethod($method,$params); */ /* _debug_array($res);exit; */ - $this->resp_struct = array(); - $this->build_resp($res); + $this->resp_struct = array($this->build_resp($res,True)); /*_debug_array($this->resp_struct); */ @reset($this->resp_struct); $r = CreateObject('phpgwapi.xmlrpcresp',CreateObject('phpgwapi.xmlrpcval',$this->resp_struct,'struct'));