fix Drupal argument passing, #9380
authormark <mark>
Thu, 12 May 2011 22:13:59 +0000 (22:13 +0000)
committermark <mark>
Thu, 12 May 2011 22:13:59 +0000 (22:13 +0000)
fs_selfservice/drupal/freeside.class.php

index 161156a..cf49a03 100644 (file)
@@ -1,5 +1,14 @@
 <?php
 
 <?php
 
+function flatten($hash) {
+  if ( !is_array($hash) ) return $hash;
+  $flat = array();
+  array_walk($hash, function($value, $key, &$to) { 
+    array_push($to, $key, $value);
+  }, &$flat);
+  return($flat);
+}
+
 class FreesideSelfService  {
 
   public $URL = '';
 class FreesideSelfService  {
 
   public $URL = '';
@@ -8,25 +17,26 @@ class FreesideSelfService  {
       $this;
     }
 
       $this;
     }
 
-    public function __call($name, $arguments) {
-
-        error_log("[FreesideSelfService] $name called, sending to ". $this->URL);
+  public function __call($name, $arguments) {
 
 
-        $request = xmlrpc_encode_request("FS.ClientAPI_XMLRPC.$name", $arguments);
-        $context = stream_context_create( array( 'http' => array(
-            'method' => "POST",
-            'header' => "Content-Type: text/xml",
-            'content' => $request
-        )));
-        $file = file_get_contents($this->URL, false, $context);
-        $response = xmlrpc_decode($file);
-        if (xmlrpc_is_fault($response)) {
-            trigger_error("[FreesideSelfService] XML-RPC communication error: $response[faultString] ($response[faultCode])");
-        } else {
-            //error_log("[FreesideSelfService] $response");
-            return $response;
-        }
+    error_log("[FreesideSelfService] $name called, sending to ". $this->URL);
+    $request = xmlrpc_encode_request("FS.ClientAPI_XMLRPC.$name", 
+      flatten($arguments[0])
+    );
+    $context = stream_context_create( array( 'http' => array(
+      'method' => "POST",
+      'header' => "Content-Type: text/xml",
+      'content' => $request
+    )));
+    $file = file_get_contents($this->URL, false, $context);
+    $response = xmlrpc_decode($file);
+    if (xmlrpc_is_fault($response)) {
+      trigger_error("[FreesideSelfService] XML-RPC communication error: $response[faultString] ($response[faultCode])");
+    } else {
+      //error_log("[FreesideSelfService] $response");
+      return $response;
     }
     }
+  }
 
 }
 
 
 }