Switch to always use structs for iomap since they best represent one level

associative arrays; Add ability to call a bo layer class
This commit is contained in:
Miles Lott 2001-08-20 16:33:26 +00:00
parent ca0ed1f136
commit aedb803a1c
3 changed files with 83 additions and 46 deletions

View File

@ -142,15 +142,17 @@
$hostpart = ereg_replace('http://','',$hostpart);
if(gettype($args) != 'array')
{
$arr[] = CreateObject('phpgwapi.xmlrpcval',$args,'string');
$ele[] = CreateObject('phpgwapi.xmlrpcval',$args,'string');
}
else
{
while(list($key,$val) = @each($args))
{
$arr[] = CreateObject('phpgwapi.xmlrpcval',$val, 'string');
$ele[$key] = CreateObject('phpgwapi.xmlrpcval',$val, 'string');
}
}
$arr[] = CreateObject('phpgwapi.xmlrpcval',$ele,'struct');
$f = CreateObject('phpgwapi.xmlrpcmsg', $method_name, $arr,'struct');
$this->debug("<pre>" . htmlentities($f->serialize()) . "</pre>\n",$debug);
$c = CreateObject('phpgwapi.xmlrpc_client',$this->urlparts['xmlrpc'], $hostpart, 80);
@ -183,15 +185,17 @@
$hostpart = ereg_replace('http://','',$hostpart);
if(gettype($args) != 'array')
{
$arr[] = CreateObject('phpgwapi.xmlrpcval',$args,'string');
$ele[] = CreateObject('phpgwapi.xmlrpcval',$args,'string');
}
else
{
while(list($key,$val) = @each($args))
{
$arr[] = CreateObject('phpgwapi.xmlrpcval',$val, 'string');
$ele[$key] = CreateObject('phpgwapi.xmlrpcval',$val, 'string');
}
}
$arr[] = CreateObject('phpgwapi.xmlrpcval',$ele,'struct');
$f = CreateObject('phpgwapi.xmlrpcmsg', $method_name, $arr,'struct');
$this->debug("<pre>" . htmlentities($f->serialize()) . "</pre>\n",$debug);
$c = CreateObject('phpgwapi.xmlrpc_client',$this->urlparts['xmlrpc'], $hostpart, 80);

View File

@ -117,7 +117,7 @@
}
}
}
return array(0, "Wanted ${wanted}, got ${got} at param ${pno})");
return array(0, "Wanted $wanted, got $got at param $pno)");
}
function parseRequest($data='')
@ -183,17 +183,13 @@
}
if(!isset($dmap[$methName]['function']))
{
/* these params are xmlrcpvals, need extract */
$params = $GLOBALS['_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;
}
/* phpgw mod - fetch the (bo) class methods to create the dmap */
$method = $methName;
$tmp = explode('.',$methName);
$methName = $tmp[2];
$listmeth = $tmp[0] . '.' . $tmp[1] . '.' . 'list_methods';
$dmap = ExecMethod($listmeth,'xmlrpc');
$this->dmap = $dmap;
}
if (isset($dmap[$methName]['function']))
{
@ -217,25 +213,53 @@
{
$code = '$r =' . $dmap[$methName]['function'] . '($m);';
$code = ereg_replace(',,',",'',",$code);
eval($code);
}
else
{
$params = $GLOBALS['_xh'][$parser]['params'];
$code = '$r =' . "ExecMethod('" . $dmap[$methName]['function'] . "'" . ',$params);';
/* phpgw mod - finally, execute the function call and return the values */
$params = $GLOBALS['_xh'][$parser]['params'][0];
$code = '$p = ' . $params . ';';
eval($code);
$params = $p->getval();
$res = ExecMethod($method,$params);
while(list($key,$val) = @each($res))
{
if(gettype($val) == 'array')
{
while(list($x,$y) = @each($val))
{
$ele[$x] = CreateObject('phpgwapi.xmlrpcval',$y,'string');
}
}
else
{
$ele[$key] = CreateObject('phpgwapi.xmlrpcval',$val,'string');
}
}
$r = CreateObject('phpgwapi.xmlrpcresp',CreateObject('phpgwapi.xmlrpcval',$ele,'struct'));
}
eval($code);
}
}
else
{
$r= CreateObject('phpgwapi.xmlrpcresp',CreateObject('phpgwapi.xmlrpcval'),$GLOBALS['xmlrpcerr']['incorrect_params'],$GLOBALS['xmlrpcstr']['incorrect_params'].': ' . $sr[1]
$r = CreateObject(
'phpgwapi.xmlrpcresp',
CreateObject('phpgwapi.xmlrpcval'),
$GLOBALS['xmlrpcerr']['incorrect_params'],
$GLOBALS['xmlrpcstr']['incorrect_params'] . ': ' . $sr[1]
);
}
}
else
{
// else prepare error response
$r= CreateObject('phpgwapi.xmlrpcresp',CreateObject('phpgwapi.xmlrpcval'),$GLOBALS['xmlrpcerr']['unknown_method'],$GLOBALS['xmlrpcstr']['unknown_method']);
$r = CreateObject(
'phpgwapi.xmlrpcresp',
CreateObject('phpgwapi.xmlrpcval'),
$GLOBALS['xmlrpcerr']['unknown_method'],
$GLOBALS['xmlrpcstr']['unknown_method']
);
}
}
return $r;

View File

@ -669,61 +669,70 @@
return CreateObject('phpgwapi.xmlrpcresp',CreateObject('phpgwapi.xmlrpcval',$acct_data, 'struct'));
}
*/
$GLOBALS['_xmlrpcs_login_sig'] = array(array(xmlrpcString,xmlrpcString,xmlrpcString,xmlrpcString));
$GLOBALS['_xmlrpcs_login_sig'] = array(array(xmlrpcStruct,xmlrpcStruct));
$GLOBALS['_xmlrpcs_login_doc'] = 'phpGroupWare client or server login via XML-RPC';
function _xmlrpcs_login($server,$m)
{
$server_name = $m->getParam(0);
$username = $m->getParam(1);
$password = $m->getParam(2);
$serverdata['server_name'] = $server_name->scalarval();
$serverdata['username'] = $username->scalarval();
$serverdata['password'] = $password->scalarval();
$rdata = $m->getParam(0);
$data = $rdata->scalarval();
if($serverdata['server_name'])
$server_name = $data['server_name']->scalarval();
$username = $data['username']->scalarval();
$password = $data['password']->scalarval();
$sparts = explode('.',$server_name);
if($sparts[1])
{
list($sessionid,$kp3) = $GLOBALS['phpgw']->session->create_server($serverdata['username'].'@'.$serverdata['server_name'],$serverdata['password']);
/* we were passed an FQDN */
list($sessionid,$kp3) = $GLOBALS['phpgw']->session->create_server($username.'@'.$server_name,$password);
}
else
{
// Milosch - jengo, how do we do this?
list($sessionid,$kp3) = $GLOBALS['phpgw']->session->create($serverdata['username'],$serverdata['password']);
/* possible phpgw domain */
if($server_name)
{
$user = $username.'@'.$server_name;
}
else
{
$user = $username;
}
list($sessionid,$kp3) = $GLOBALS['phpgw']->session->create($user,$password);
}
if($sessionid && $kp3)
{
$rtrn[] = CreateObject('phpgwapi.xmlrpcval','sessionid','string');
$rtrn[] = CreateObject('phpgwapi.xmlrpcval',$sessionid,'string');
$rtrn[] = CreateObject('phpgwapi.xmlrpcval','kp3','string');
$rtrn[] = CreateObject('phpgwapi.xmlrpcval',$kp3,'string');
$rtrn['sessionid'] = CreateObject('phpgwapi.xmlrpcval',$sessionid,'string');
$rtrn['kp3'] = CreateObject('phpgwapi.xmlrpcval',$kp3,'string');
}
else
{
$rtrn[] = CreateObject('phpgwapi.xmlrpcval','GOAWAY','string');
$rtrn[] = CreateObject('phpgwapi.xmlrpcval','XOXO','string');
$rtrn['GOAWAY'] = CreateObject('phpgwapi.xmlrpcval','XOXO','string');
}
return CreateObject('phpgwapi.xmlrpcresp',CreateObject('phpgwapi.xmlrpcval',$rtrn,'struct'));
}
$GLOBALS['_xmlrpcs_logout_sig'] = array(array(xmlrpcString,xmlrpcString,xmlrpcString));
$GLOBALS['_xmlrpcs_logout_sig'] = array(array(xmlrpcStruct,xmlrpcStruct));
$GLOBALS['_xmlrpcs_logout_doc'] = 'phpGroupWare client or server logout via XML-RPC';
function _xmlrpcs_logout($server,$m)
{
$xsessionid = $m->getParam(0);
$xkp3 = $m->getParam(1);
$rdata = $m->getParam(0);
$data = $rdata->scalarval();
$sessionid = $data['sessionid']->scalarval();
$kp3 = $data['kp3']->scalarval();
$sessionid = $xsessionid->scalarval();
$kp3 = $xkp3->scalarval();
$later = $GLOBALS['phpgw']->session->destroy();
if($later)
{
$rtrn[] = CreateObject('phpgwapi.xmlrpcval','GOODBYE','string');
$rtrn[] = CreateObject('phpgwapi.xmlrpcval','XOXO','string');
$rtrn['GOODBYE'] = CreateObject('phpgwapi.xmlrpcval','XOXO','string');
}
else
{
$rtrn[] = CreateObject('phpgwapi.xmlrpcval','WHAT?','string');
/* This never happens, yet */
$rtrn['OOPS'] = CreateObject('phpgwapi.xmlrpcval','WHAT?','string');
}
return CreateObject('phpgwapi.xmlrpcresp',CreateObject('phpgwapi.xmlrpcval',$rtrn,'struct'));
}