[geeklog-cvs] Auth_Enterprise/Server AEXMLRPCHandler.class.php,1.3,1.4
tony at iowaoutdoors.org
tony at iowaoutdoors.org
Sat Jul 3 14:09:42 EDT 2004
Update of /var/cvs/Auth_Enterprise/Server
In directory www:/tmp/cvs-serv32358
Modified Files:
AEXMLRPCHandler.class.php
Log Message:
Tons of changes to get XMLRPC support working. All seems fine now.
Index: AEXMLRPCHandler.class.php
===================================================================
RCS file: /var/cvs/Auth_Enterprise/Server/AEXMLRPCHandler.class.php,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** AEXMLRPCHandler.class.php 1 Jul 2004 18:45:42 -0000 1.3
--- AEXMLRPCHandler.class.php 3 Jul 2004 18:09:40 -0000 1.4
***************
*** 22,25 ****
--- 22,40 ----
/**
+ * PEAR's XML RPC server implementation
+ */
+ require_once 'XML/RPC/Server.php';
+
+ /**
+ * Auth_Enterprise Privilege class
+ */
+ require_once 'Auth_Enterprise/Common/AEPrivilege.class.php';
+
+ /**
+ * Auth_Enterprise Group class
+ */
+ require_once 'Auth_Enterprise/Common/AEGroup.class.php';
+
+ /**
* Auth_Enteprise's XMLRPC Handler
*
***************
*** 58,61 ****
--- 73,81 ----
);
+ $methodsWithObjectParams = array(
+ 'setUserPrivilegesByAdmin' => 6,
+ 'setUserGroupsByAdmin' => 6
+ );
+
// Convert parameters into an array to be sent to
// the provider method
***************
*** 67,70 ****
--- 87,95 ----
$methodToCall = $fnParams[0];
+ // This is a hack, yes a bad one, to convert group and privilege parameters to objects
+ if (in_array($methodToCall, array_keys($methodsWithObjectParams))) {
+ $fnParams[$methodsWithObjectParams[$methodToCall] - 1] = AEXMLRPCHandler::convertParamToObjects($fnParams[$methodsWithObjectParams[$methodToCall] - 1]);
+ }
+
// Get application ID
$appId = $fnParams[1];
***************
*** 101,104 ****
--- 126,130 ----
}
} catch (AEBaseException $e) {
+ print $e->getMessage(); exit;
return new XML_RPC_Response(0, $xmlrpcerruser + $e->getXMLErrorOffset(), $e->getMessage());
} catch (Exception $e) {
***************
*** 111,114 ****
--- 137,153 ----
if (is_object($retVal)) {
$retVal = $retVal->toArray();
+ } else {
+ // We may have gotten an array of objects so handle that
+ if (is_array($retVal)) {
+ $newArray = array();
+ foreach ($retVal as $curVal) {
+ if (is_object($curVal)) {
+ $newArray[] = $curVal->toArray();
+ } else {
+ $newArray[] = $curVal;
+ }
+ }
+ }
+ $retVal = $newArray;
}
***************
*** 118,122 ****
--- 157,193 ----
}
+ public static function convertParamToObjects($param)
+ {
+ if (!is_array($param)) {
+ return array();
+ }
+
+ $retval = array();
+ foreach ($param as $curItem) {
+ $curItem = $curItem->scalarval();
+ if (in_array('privilegeCode', array_keys($curItem))) {
+ $tmpObj = new AEPrivilege();
+ $tmpObj->setPrivilegeCode($curItem['privilegeCode']->scalarval());
+ $tmpObj->setPrivilegeDesc($curItem['privilegeDesc']->scalarval());
+ } else {
+ if (in_array('groupId', array_keys($curItem))) {
+ $tmpObj = new AEGroup();
+ $tmpObj->setGroupId($curItem['groupId']->scalarval());
+ $tmpObj->setGroupLogicalName($curItem['groupLogicalName']->scalarval());
+ $tmpObj->setGroupDisplayName($curItem['groupDisplayName']->scalarval());
+ $tmpObj->setGroupDesc($curItem['groupDesc']->scalarval());
+ }
+ }
+ $retval[] = $tmpObj;
+ }
+
+ return $retval;
+ }
+
}
+ // Here's where the magic happens. This code instantiates the XMLRPC server and processes any
+ // requests immediately
+ $XMLRPCServer = new XML_RPC_Server(array('Auth_Enterprise.processRequest' => array('function' => 'AEXMLRPCHandler::handleRequest')));
+
?>
\ No newline at end of file
More information about the geeklog-cvs
mailing list