Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

eztrade/xmlrpc/xmlrpcserver.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: xmlrpcserver.php 6233 2001-07-20 11:42:02Z jakobn $
5 //
6 // Created on: <23-Oct-2000 17:53:46 bf>
7 //
8 // This source file is part of Exponential Basic, publishing software.
9 //
10 // Copyright (C) 1999-2001 eZ Systems. All rights reserved.
11 //
12 // This program is free software; you can redistribute it and/or
13 // modify it under the terms of the GNU General Public License
14 // as published by the Free Software Foundation; either version 2
15 // of the License, or (at your option) any later version.
16 //
17 // This program is distributed in the hope that it will be useful,
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 // GNU General Public License for more details.
21 //
22 // You should have received a copy of the GNU General Public License
23 // along with this program; if not, write to the Free Software
24 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, US
25 //
26
27 ob_end_clean();
28 ob_start();
29
30 // include_once( "classes/INIFile.php" );
31 // include_once( "classes/ezlocale.php" );
32
33 // eZ trade classes
34 // include_once( "eztrade/classes/ezproductcategory.php" );
35 // include_once( "eztrade/classes/ezproduct.php" );
36 // include_once( "eztrade/classes/ezorder.php" );
37 // include_once( "eztrade/classes/ezpreorder.php" );
38
39 // eZ user
40 // include_once( "ezuser/classes/ezuser.php" );
41 // include_once( "ezuser/classes/ezpermission.php" );
42
43
44 // include the server
45 // include_once( "ezxmlrpc/classes/ezxmlrpcserver.php" );
46
47 // include the datatype(s) we need
48 // include_once( "ezxmlrpc/classes/ezxmlrpcstring.php" );
49 // include_once( "ezxmlrpc/classes/ezxmlrpcint.php" );
50 // include_once( "ezxmlrpc/classes/ezxmlrpcdouble.php" );
51 // include_once( "ezxmlrpc/classes/ezxmlrpcarray.php" );
52 // include_once( "ezxmlrpc/classes/ezxmlrpcresponse.php" );
53
54 // for payment information
55 // include_once( "eztrade/classes/ezcheckout.php" );
56
57
58 $VersionNumber = "Pre release 1.0";
59
60 $server = new eZXMLRPCServer( );
61
62 // register functions
63 $server->registerFunction( "version" );
64 $server->registerFunction( "newOrders", array( new eZXMLRPCString(), new eZXMLRPCString() ) );
65
66 // process the server requests
67 $server->processRequest();
68
69 // implemented functions
70 function version( )
71 {
72 $VersionNumber = $GLOBALS["VersionNumber"];
73 return new eZXMLRPCString( "This is eZ trade xml rpc version: $VersionNumber" );
74 }
75
76 //
77 // Returns all the new orders and sets them to exported.
78 //
79 function &newOrders( $args )
80 {
81 $user = new eZUser();
82 $user = $user->validateUser( $args[0]->value(), $args[1]->value() );
83
84 if ( ( is_a( $user, "eZUser" ) ) and eZPermission::checkPermission( $user, "eZUser", "AdminLogin" ) )
85 {
86 $ini =& eZINI::instance( 'site.ini' );
87
88 $Language = $ini->variable( "eZTradeMain", "Language" );
89 $locale = new eZLocale( $Language );
90
91 $orders = array();
92
93 // fetch all new orders
94 $order = new eZOrder();
95
96 // perform search
97 $orderArray =& $order->getNew( );
98
99 foreach ( $orderArray as $orderItem )
100 {
101 $preOrder = new eZPreOrder();
102 $preOrder->getByOrderID( $orderItem->id() );
103
104 // set the order item to be exported
105 $orderItem->setIsExported( true );
106 $orderItem->store();
107
108 $datetime =& $orderItem->date();
109
110 $date = $datetime->date();
111 $time = $datetime->time();
112
113 $user =& $orderItem->user();
114
115 if ( $user )
116 {
117 $shippingAddress =& $orderItem->shippingAddress();
118 $shippingCountry =& $shippingAddress->country();
119
120 $billingAddress =& $orderItem->billingAddress();
121 $billingCountry =& $billingAddress->country();
122
123 $checkout = new eZCheckout();
124 $instance =& $checkout->instance();
125 $paymentMethod = $instance->paymentName( $orderItem->paymentMethod() );
126
127 $itemArray = array();
128
129 $items = $orderItem->items( $OrderType );
130
131 $shippingUser = $orderItem->shippingUser();
132
133 foreach ( $items as $item )
134 {
135 $product = $item->product();
136
137 $optionValues =& $item->optionValues();
138
139 foreach ( $optionValues as $optionValue )
140 {
141 $optionArray[] = new eZXMLRPCStruct( array( "OptionName" => new eZXMLRPCString( $optionValue->optionName() ),
142 "OptionValue" => new eZXMLRPCString( $optionValue->valueName() ),
143 "OptionValueRemoteID" => new eZXMLRPCString( $optionValue->remoteID() ) )
144 );
145 }
146
147
148 $itemArray[] = new eZXMLRPCStruct( array( "ProductID" => new eZXMLRPCInt( $product->id() ),
149 "RemoteID" => new eZXMLRPCString( $product->remoteID() ),
150 "ProductNumber" => new eZXMLRPCInt( $product->productNumber() ),
151 "Name" => new eZXMLRPCString( $product->name() ),
152 "Count" => new eZXMLRPCInt( $item->count() ),
153 "Price" => new eZXMLRPCDouble( ( $item->price() / $item->count() ) ),
154 "TotalPrice" => new eZXMLRPCDouble( ($item->price() ) ),
155 "Options" => new eZXMLRPCArray( $optionArray )
156 ) );
157 }
158
159 $orders[] = new eZXMLRPCStruct(
160 array(
161 "OrderID" => new eZXMLRPCInt( $orderItem->id() ),
162 "PreOrderID" => new eZXMLRPCInt( $preOrder->id() ),
163 "PaymentMethod" => new eZXMLRPCString( $paymentMethod ),
164 "Date" => new eZXMLRPCString( $locale->format( $date ) ),
165 "Time" => new eZXMLRPCString( $locale->format( $time ) ),
166 "ShippingCharge" => new eZXMLRPCDouble( $orderItem->shippingCharge() ),
167 "ShippingFirstName" => new eZXMLRPCString( $shippingUser->firstName() ),
168 "ShippingLastName" => new eZXMLRPCString( $shippingUser->lastName() ),
169 "ShippingStreet1" => new eZXMLRPCString( $shippingAddress->street1() ),
170 "ShippingStreet2" => new eZXMLRPCString( $shippingAddress->street2() ),
171 "ShippingZip" => new eZXMLRPCString( $shippingAddress->zip() ),
172 "ShippingPlace" => new eZXMLRPCString( $shippingAddress->place() ),
173 "ShippingCountry" => new eZXMLRPCString( $shippingCountry->name() ),
174 "BillingFirstName" => new eZXMLRPCString( $user->firstName() ),
175 "BillingLastName" => new eZXMLRPCString( $user->lastName() ),
176 "BillingStreet1" => new eZXMLRPCString( $billingAddress->street1() ),
177 "BillingStreet2" => new eZXMLRPCString( $billingAddress->street2() ),
178 "BillingZip" => new eZXMLRPCString( $billingAddress->zip() ),
179 "BillingPlace" => new eZXMLRPCString( $billingAddress->place() ),
180 "BillingCountry" => new eZXMLRPCString( $billingCountry->name() ),
181 "OrderLines" => new eZXMLRPCArray( $itemArray )
182 ) );
183 }
184 }
185
186 $tmp = new eZXMLRPCArray( $orders );
187 }
188 else
189 {
190 $tmp = new eZXMLRPCResponse( );
191 $tmp->setError( 100, "Authorization failed." );
192 }
193
194 return $tmp;
195 }
196
197 ob_end_flush();
198 exit();
199 ?>
$locale
$locale
Definition: admin/adlist.php:127
$items
$items
Definition: admin/orderview.php:211
$datetime
$datetime
Definition: appointmentview.php:108
$date
$date
Definition: bugpreview.php:66
$tmp
$tmp
Definition: bugview.php:99
$shippingAddress
$shippingAddress
Definition: checkout.php:615
eZCheckout
Definition: ezcheckout.php:48
eZLocale
Definition: ezlocale.php:119
eZOrder
Definition: ezorder.php:52
eZPermission\checkPermission
static checkPermission( $user, $moduleName, $permissionName)
Definition: ezpermission.php:430
eZPreOrder
Definition: ezpreorder.php:44
eZUser
Definition: ezuser.php:76
eZXMLRPCArray
Definition: ezxmlrpcarray.php:37
eZXMLRPCDouble
Definition: ezxmlrpcdouble.php:37
eZXMLRPCInt
Definition: ezxmlrpcint.php:37
eZXMLRPCResponse
Definition: ezxmlrpcresponse.php:50
eZXMLRPCServer
Definition: ezxmlrpcserver.php:82
eZXMLRPCString
Definition: ezxmlrpcstring.php:37
eZXMLRPCStruct
Definition: ezxmlrpcstruct.php:37
$Language
$Language
Definition: classes/admin/linklist.php:65
$ini
$ini
Definition: classes/admin/linklist.php:64
$item
$item
Definition: classes/admin/linklist.php:228
$args
$args
Definition: companytypelist.php:125
$orders
$orders
Definition: customerview.php:87
$VersionNumber
$VersionNumber
Definition: eztrade/xmlrpc/xmlrpcserver.php:58
version
version()
Definition: eztrade/xmlrpc/xmlrpcserver.php:70
newOrders
& newOrders( $args)
Definition: eztrade/xmlrpc/xmlrpcserver.php:79
$server
$server
Definition: eztrade/xmlrpc/xmlrpcserver.php:60
exit
exit
Definition: folder.php:81
$product
$product
Definition: homepage.php:202
$time
$time
Definition: homepage.php:327
$paymentMethod
$paymentMethod
Definition: orderedit.php:668
$instance
$instance
Definition: orderedit.php:667
$checkout
foreach( $historyArray as $status) $checkout
Definition: orderedit.php:666
$billingAddress
$billingAddress
Definition: paypal.php:44
$order
$order
Definition: productreport.php:182
$user
$user
Definition: user/adlist.php:39
$orderArray
if(! $user) $orderArray
Definition: user/orderlist.php:79
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.