addStruct() public method

public addStruct ( $vals )
Exemplo n.º 1
0
function xmlrpc_encode($php_val)
{
    global $xmlrpcInt;
    global $xmlrpcDouble;
    global $xmlrpcString;
    global $xmlrpcArray;
    global $xmlrpcStruct;
    global $xmlrpcBoolean;
    $type = gettype($php_val);
    $xmlrpc_val = new xmlrpcval();
    switch ($type) {
        case "array":
        case "object":
            $arr = array();
            while (list($k, $v) = each($php_val)) {
                $arr[$k] = xmlrpc_encode($v);
            }
            $xmlrpc_val->addStruct($arr);
            break;
        case "integer":
            $xmlrpc_val->addScalar($php_val, $xmlrpcInt);
            break;
        case "double":
            $xmlrpc_val->addScalar($php_val, $xmlrpcDouble);
            break;
        case "string":
            $xmlrpc_val->addScalar($php_val, $xmlrpcString);
            break;
            // <G_Giunta_2001-02-29>
            // Add support for encoding/decoding of booleans, since they are supported in PHP
        // <G_Giunta_2001-02-29>
        // Add support for encoding/decoding of booleans, since they are supported in PHP
        case "boolean":
            $xmlrpc_val->addScalar($php_val, $xmlrpcBoolean);
            break;
            // </G_Giunta_2001-02-29>
        // </G_Giunta_2001-02-29>
        case "unknown type":
        default:
            // giancarlo pinerolo <*****@*****.**>
            // it has to return
            // an empty object in case (which is already
            // at this point), not a boolean.
            break;
    }
    return $xmlrpc_val;
}
Exemplo n.º 2
0
function _book_request($token, $fac, $rooms, $grooms)
{
    $fac->request = 0;
    $server = _serv();
    $arooms = array();
    foreach ($rooms as $rid => $how) {
        $fat = new xmlrpcval();
        $show = new xmlrpcval($how, 'int');
        $srid = new xmlrpcval($rid, 'int');
        $fat->addStruct(array('number' => $show, 'id' => $srid));
        $arooms[] = $fat;
    }
    $lcode = $fac->lcode;
    $message = new xmlrpcmsg('rooms_request', array(new xmlrpcval($token, 'string'), new xmlrpcval($lcode, 'int'), new xmlrpcval($arooms, 'array')));
    $struct = $server->send($message)->value();
    $res = _scal($struct, 0);
    if ($res < 0) {
        return -1;
    }
    $s = $struct->arraymem(1);
    $br = parse_book_request($s);
    $fac->request = $br;
    return $br;
}
Exemplo n.º 3
0
 function __phpxmlrpc_encapsulate($arg)
 {
     // The class xmlrpcval is defined in the phpxmlrpc library. It requires both the variable
     // and the type. Dates are handled through the API as ISO 8601 string representations.
     if (is_string($arg)) {
         $encapArg = new xmlrpcval($arg, 'string');
     } elseif (is_int($arg)) {
         $encapArg = new xmlrpcval($arg, 'int');
     } elseif (is_bool($arg)) {
         $encapArg = new xmlrpcval($arg, 'boolean');
     } elseif (is_array($arg)) {
         // The API server treats indexed arrays (lists) and associative arrays (dictionaries)
         // differently where in php they are essentially the same. Assuming that having a zero
         // index set indicates an indexed array is not perfect but should suffice for the
         // purpose of the API examples.
         if (isset($arg[0])) {
             $array = array();
             foreach ($arg as $key => $value) {
                 $array[] = $this->__phpxmlrpc_encapsulate($value);
             }
             $encapArray = new xmlrpcval();
             $encapArray->addArray($array);
             $encapArg = $encapArray;
         } else {
             $struct = array();
             foreach ($arg as $key => $value) {
                 $struct[$key] = $this->__phpxmlrpc_encapsulate($value);
             }
             $encapStruct = new xmlrpcval();
             $encapStruct->addStruct($struct);
             $encapArg = $encapStruct;
         }
     } else {
         $encapArg = new xmlrpcval($arg, 'string');
     }
     return $encapArg;
 }
Exemplo n.º 4
0
 /**
  * implements <i>samurai.SessionInitiate</i>
  *
  * @param string $LocalUri as SIP-URI
  * @param string $RemoteUri as SIP-URI
  * @param string $TOS Type of service as defined in $availableTOS
  * @param string $Content depends on TOS
  * @param dateTime $schedule as unix timestamp
  *
  * @return string SessionID, if available
  *
  * @throws sipgateAPI_Server_Exception on Server responses != 200 OK
  */
 protected function samurai_SessionInitiate($LocalUri, $RemoteUri, $TOS, $Content, $Schedule = NULL)
 {
     if (isset($LocalUri)) {
         $val_a["LocalUri"] = new xmlrpcval($LocalUri);
     }
     if (isset($RemoteUri)) {
         $val_a["RemoteUri"] = new xmlrpcval($RemoteUri);
     } else {
         throw new sipgateAPI_Exception("No RemoteUri");
     }
     if (isset($TOS)) {
         $val_a["TOS"] = new xmlrpcval($TOS);
     } else {
         throw new sipgateAPI_Exception("No valid TOS");
     }
     if (isset($Content)) {
         $val_a["Content"] = new xmlrpcval($Content);
     }
     if (isset($Schedule)) {
         $val_a["Schedule"] = new xmlrpcval(iso8601_encode($Schedule), "dateTime.iso8601");
     }
     $val_s = new xmlrpcval();
     $val_s->addStruct($val_a);
     $v = array();
     $v[] = $val_s;
     // create message
     $m = new xmlrpcmsg('samurai.SessionInitiate', $v);
     // send message
     $r = $this->client->send($m);
     if (!$r->faultCode()) {
         $php_r = php_xmlrpc_decode($r->value());
         return $php_r["SessionID"];
     } else {
         throw new sipgateAPI_Server_Exception($r->faultString(), $r->faultCode());
     }
 }