Merge lp:~magentoerpconnect-community/magentoerpconnect/magento-module-with-crm_claim-integration into lp:~magentoerpconnect-core-editors/magentoerpconnect/oerp7.0-refactor
- magento-module-with-crm_claim-integration
- Merge into oerp7.0-refactor
Status: | Superseded |
---|---|
Proposed branch: | lp:~magentoerpconnect-community/magentoerpconnect/magento-module-with-crm_claim-integration |
Merge into: | lp:~magentoerpconnect-core-editors/magentoerpconnect/oerp7.0-refactor |
Diff against target: |
10031 lines (+9799/-0) 36 files modified
Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Helper/Data.php (+6/-0) Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Categories.php (+111/-0) Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Product/Attribute.php (+109/-0) Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Product/Attributegroup.php (+167/-0) Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Product/Attributeset.php (+58/-0) Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Product/Tierprice.php (+71/-0) Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Products.php (+289/-0) Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcore/Groups.php (+142/-0) Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcore/Storeviews.php (+142/-0) Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcore/Website.php (+171/-0) Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcustomer/Address.php (+241/-0) Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcustomer/Customer.php (+142/-0) Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcustomer/Group.php (+142/-0) Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcustomer/Subscriber.php (+163/-0) Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/etc/api.xml (+493/-0) Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/etc/config.xml (+45/-0) Openlabs_OpenERPConnector-1.1.0/app/etc/modules/Openlabs_OpenERPConnector.xml (+41/-0) Savoirfairelinux_Claim/app/code/local/Savoirfairelinux/Claim/Block/Form.php (+160/-0) Savoirfairelinux_Claim/app/code/local/Savoirfairelinux/Claim/Helper/Data.php (+74/-0) Savoirfairelinux_Claim/app/code/local/Savoirfairelinux/Claim/Model/System/Config/Backend/Links.php (+48/-0) Savoirfairelinux_Claim/app/code/local/Savoirfairelinux/Claim/controllers/IndexController.php (+360/-0) Savoirfairelinux_Claim/app/code/local/Savoirfairelinux/Claim/etc/adminhtml.xml (+22/-0) Savoirfairelinux_Claim/app/code/local/Savoirfairelinux/Claim/etc/config.xml (+117/-0) Savoirfairelinux_Claim/app/code/local/Savoirfairelinux/Claim/etc/modules/Savoirfairelinux_Claim.xml (+9/-0) Savoirfairelinux_Claim/app/code/local/Savoirfairelinux/Claim/etc/system.xml (+114/-0) Savoirfairelinux_Claim/app/code/local/Savoirfairelinux/Claim/lib/xmlrpc.inc (+3776/-0) Savoirfairelinux_Claim/app/code/local/Savoirfairelinux/Claim/lib/xmlrpc_wrappers.inc (+955/-0) Savoirfairelinux_Claim/app/code/local/Savoirfairelinux/Claim/lib/xmlrpcs.inc (+1246/-0) Savoirfairelinux_Claim/app/code/local/Savoirfairelinux/Claim/savoirfairelinux_claim.xml (+70/-0) Savoirfairelinux_Claim/app/design/frontend/default/default/layout/savoirfairelinux_claim.xml (+63/-0) Savoirfairelinux_Claim/app/design/frontend/default/default/template/claim/form.phtml (+121/-0) Savoirfairelinux_Claim/app/etc/modules/Savoirfairelinux_Claim.xml (+9/-0) Savoirfairelinux_Claim/app/locale/en_US/Savoirfairelinux_Claim.csv (+10/-0) Savoirfairelinux_Claim/app/locale/fr_FR/Savoirfairelinux_Claim.csv (+10/-0) Savoirfairelinux_Claim/package.xml (+18/-0) package.xml (+84/-0) |
To merge this branch: | bzr merge lp:~magentoerpconnect-community/magentoerpconnect/magento-module-with-crm_claim-integration |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
MagentoERPConnect core editors | Pending | ||
Review via email: mp+119126@code.launchpad.net |
This proposal has been superseded by a proposal from 2012-08-10.
Commit message
Description of the change
This Magento module enables Magento users to create a claim (crm_claim) in OpenERP from Magento using OpenERP API.
- 25. By Joao Alfredo Gama Batista
-
[ADD] Module to allow Magento users to create a claim in OpenERP from Magento
Unmerged revisions
- 25. By Joao Alfredo Gama Batista
-
[ADD] Module to allow Magento users to create a claim in OpenERP from Magento
- 24. By Raimon Esteve (www.zikzakmedia.com)
-
[IMP] Newsletter Subscribers. WebServices (part 2)
- 23. By Raimon Esteve (www.zikzakmedia.com)
-
[IMP] Newsletter Subscribers. WebServices:
- list
- info
- create
- update
- delete (unsubscriber)
note: magento core not avaible webservice for Newsletter Subscribers - 22. By Raphaƫl Valyi - http://www.akretion.com
-
[IMP] send attribute scope as we would eventually use it, especially to find out which attributes are translatable (scope=='store'), though that might be overkill
- 21. By Sharoon Thomas http://openlabs.co.in
-
[FIX]The attributes.list method now gives the details
- 20. By Sharoon Thomas http://openlabs.co.in
-
[ADD]Attribute set fixed
- 19. By Sharoon Thomas http://openlabs.co.in
-
[ADD]Api for tier price & customer
- 18. By Sharoon Thomas http://openlabs.co.in
-
[ADD]Added address API
- 17. By Sharoon Thomas http://openlabs.co.in
-
[ADD]Customer groups API
- 16. By Sharoon Thomas http://openlabs.co.in
-
[ADD]Attribute Groups API
Preview Diff
1 | === added directory 'Openlabs_OpenERPConnector-1.1.0' |
2 | === added directory 'Openlabs_OpenERPConnector-1.1.0/Openlabs' |
3 | === added directory 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector' |
4 | === added directory 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Helper' |
5 | === added file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Helper/Data.php' |
6 | --- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Helper/Data.php 1970-01-01 00:00:00 +0000 |
7 | +++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Helper/Data.php 2012-08-10 13:28:19 +0000 |
8 | @@ -0,0 +1,6 @@ |
9 | +<?php |
10 | +class Openlabs_OpenERPConnector_Helper_Data extends Mage_Core_Helper_Abstract |
11 | +{ |
12 | + //Linux4ever_MagentoXtender_Model_Api |
13 | +} |
14 | +?> |
15 | \ No newline at end of file |
16 | |
17 | === added directory 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model' |
18 | === added directory 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog' |
19 | === added file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Categories.php' |
20 | --- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Categories.php 1970-01-01 00:00:00 +0000 |
21 | +++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Categories.php 2012-08-10 13:28:19 +0000 |
22 | @@ -0,0 +1,111 @@ |
23 | +<?php |
24 | + |
25 | + |
26 | +/** |
27 | + * @author Sharoon Thomas |
28 | + * Inspired from Dieter's Magento Extender |
29 | + * @copyright 2009 |
30 | + */ |
31 | + |
32 | +class Openlabs_OpenERPConnector_Model_Olcatalog_Categories extends Mage_Catalog_Model_Api_Resource |
33 | +{ |
34 | + public function items($filters = null) { |
35 | + try { |
36 | + $collection = Mage :: getModel('catalog/category/attribute')->getCollection()->addAttributeToSelect('image'); |
37 | + } catch (Mage_Core_Exception $e) { |
38 | + $this->_fault('category_not_exists'); |
39 | + } |
40 | + if (is_array($filters)) { |
41 | + try { |
42 | + foreach ($filters as $field => $value) { |
43 | + $collection->addFieldToFilter($field, $value); |
44 | + } |
45 | + } catch (Mage_Core_Exception $e) { |
46 | + $this->_fault('filters_invalid', $e->getMessage()); |
47 | + // If we are adding filter on non-existent attribute |
48 | + } |
49 | + } |
50 | + $result = array (); |
51 | + foreach ($collection as $category) { |
52 | + //$result[] = $customer->toArray(); |
53 | + $result[] = array ( |
54 | + 'category_id' => $category->getId(), |
55 | + 'image' => $category->getImage(), |
56 | + ); |
57 | + } |
58 | + return $result; |
59 | + } |
60 | + |
61 | + public function info($categoryId = null) { |
62 | + if (is_numeric($categoryId)) { |
63 | + try { |
64 | + $collection = Mage :: getModel('catalog/category/attribute')->load($categoryId)->getCollection()->addAttributeToSelect('image'); |
65 | + $result = array (); |
66 | + foreach ($collection as $category) { |
67 | + //$result[] = $customer->toArray(); |
68 | + if ($category->getId() == $categoryId) { |
69 | + $image = $category->getImage(); |
70 | + if ($image) { |
71 | + $path = Mage :: getBaseDir('media') . DS . 'catalog' . DS . 'category' . DS; |
72 | + $fullpath = $path . $image; |
73 | + try { |
74 | + $fp = fopen($fullpath, "rb"); |
75 | + $imagebin = fread($fp, filesize($fullpath)); |
76 | + $img_data = base64_encode($imagebin); |
77 | + fclose($fp); |
78 | + } catch (Exception $e) { |
79 | + $this->_fault('not_media'); |
80 | + } |
81 | + } |
82 | + $result[] = array ( |
83 | + 'category_id' => $category->getId(), |
84 | + 'image' => $category->getImage(), |
85 | + 'image_data' => $img_data |
86 | + ); |
87 | + } |
88 | + } |
89 | + |
90 | + return $result; |
91 | + |
92 | + } catch (Mage_Core_Exception $e) { |
93 | + $this->_fault('group_not_exists'); |
94 | + } |
95 | + |
96 | + } |
97 | + |
98 | + } |
99 | + |
100 | +public function create($filename,$imgdata) { |
101 | + if ($filename) |
102 | + { |
103 | + $path = Mage :: getBaseDir('media') . DS . 'catalog' . DS . 'category' . DS; |
104 | + $fullpath = $path . $filename; |
105 | + try |
106 | + { |
107 | + $fp = fopen($fullpath, "w"); |
108 | + if ($fp==false) |
109 | + { |
110 | + return "Error in file creation"; |
111 | + } |
112 | + $img_data = base64_decode($imgdata); |
113 | + $imagebin = fwrite($fp,$img_data); |
114 | + fclose($fp); |
115 | + return $imagebin; |
116 | + } |
117 | + catch (Exception $e) |
118 | + { |
119 | + $this->_fault('not_created'); |
120 | + } |
121 | + return False; |
122 | + } |
123 | +} |
124 | +public function update($something=null) |
125 | +{ |
126 | + return "Not implemented yet"; |
127 | +} |
128 | +public function remove($something=null) |
129 | +{ |
130 | + return "Not implemented yet"; |
131 | +} |
132 | +} |
133 | +?> |
134 | |
135 | === added directory 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Product' |
136 | === added file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Product/Attribute.php' |
137 | --- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Product/Attribute.php 1970-01-01 00:00:00 +0000 |
138 | +++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Product/Attribute.php 2012-08-10 13:28:19 +0000 |
139 | @@ -0,0 +1,109 @@ |
140 | +<?php |
141 | + |
142 | + |
143 | +/** |
144 | + * @author Sharoon Thomas |
145 | + * Inspired from Dieter's Magento Extender |
146 | + * @copyright 2009 |
147 | + */ |
148 | + |
149 | +class Openlabs_OpenERPConnector_Model_Olcatalog_Product_Attribute extends Mage_Catalog_Model_Api_Resource { |
150 | + public function __construct() { |
151 | + $this->_storeIdSessionField = 'product_store_id'; |
152 | + $this->_ignoredAttributeCodes[] = 'type_id'; |
153 | + $this->_ignoredAttributeTypes[] = 'gallery'; |
154 | + $this->_ignoredAttributeTypes[] = 'media_image'; |
155 | + } |
156 | + |
157 | + /** |
158 | + * Retrieve attributes from specified attribute set |
159 | + * |
160 | + * @param int $setId |
161 | + * @return array |
162 | + */ |
163 | + public function relations($setId){ |
164 | + $attributes = Mage :: getModel('catalog/product')->getResource()->loadAllAttributes()->getSortedAttributes($setId); |
165 | + $result = array (); |
166 | + foreach ($attributes as $attribute){ |
167 | + $result[] = Array( |
168 | + 'attribute_id' => $attribute->getId() |
169 | + ); |
170 | + } |
171 | + return $result; |
172 | + |
173 | + } |
174 | + public function items($setId) { |
175 | + $attributes = Mage :: getModel('catalog/product')->getResource()->loadAllAttributes()->getSortedAttributes($setId); |
176 | + $result = array (); |
177 | + |
178 | + foreach ($attributes as $attribute) { |
179 | + /* @var $attribute Mage_Catalog_Model_Resource_Eav_Attribute */ |
180 | + if ((!$attribute->getId() || $attribute->isInSet($setId)) && $this->_isAllowedAttribute($attribute)) { |
181 | + |
182 | + if (!$attribute->getId() || $attribute->isScopeGlobal()) { |
183 | + $scope = 'global'; |
184 | + } |
185 | + elseif ($attribute->isScopeWebsite()) { |
186 | + $scope = 'website'; |
187 | + } else { |
188 | + $scope = 'store'; |
189 | + } |
190 | + |
191 | + /*$result[] = array ( |
192 | + 'attribute_id' => $attribute->getId(), |
193 | + 'code' => $attribute->getAttributeCode(), |
194 | + 'type' => $attribute->getFrontendInput(), |
195 | + 'required' => $attribute->getIsRequired(), |
196 | + 'attributeset' => $attribute->getattribute_set_info(), |
197 | + 'scope' => $scope |
198 | + );*/ |
199 | + //Override hooray |
200 | + $attribute['scope'] = $scope; |
201 | + $result[]=$attribute->toArray(); |
202 | + } |
203 | + } |
204 | + |
205 | + return $result; |
206 | + } |
207 | + |
208 | + public function info($attributeId) { |
209 | + try { |
210 | + return 'hello'; |
211 | + $attribute = Mage :: getModel('catalog/product')->getResource()->getAttribute($attributeId); |
212 | + return $attribute->toArray(); |
213 | + } catch (Exception $e) { |
214 | + $this->_fault('not_exists'); |
215 | + } |
216 | + } |
217 | + /** |
218 | + * Retrieve attribute options |
219 | + * |
220 | + * @param int $attributeId |
221 | + * @param string|int $store |
222 | + * @return array |
223 | + */ |
224 | + public function options($attributeId, $store = null) { |
225 | + $storeId = $this->_getStoreId($store); |
226 | + $attribute = Mage :: getModel('catalog/product')->setStoreId($storeId)->getResource()->getAttribute($attributeId)->setStoreId($storeId); |
227 | + |
228 | + /* @var $attribute Mage_Catalog_Model_Entity_Attribute */ |
229 | + if (!$attribute) { |
230 | + $this->_fault('not_exists'); |
231 | + } |
232 | + |
233 | + $options = array (); |
234 | + foreach ($attribute->getSource()->getAllOptions() as $optionId => $optionValue) { |
235 | + if (is_array($optionValue)) { |
236 | + $options[] = $optionValue; |
237 | + } |
238 | + else { |
239 | + $options[] = array ( |
240 | + 'value' => $optionId, |
241 | + 'label' => $optionValue |
242 | + ); |
243 | + } |
244 | + } |
245 | + return $options; |
246 | + } |
247 | +} |
248 | +?> |
249 | |
250 | === added file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Product/Attributegroup.php' |
251 | --- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Product/Attributegroup.php 1970-01-01 00:00:00 +0000 |
252 | +++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Product/Attributegroup.php 2012-08-10 13:28:19 +0000 |
253 | @@ -0,0 +1,167 @@ |
254 | +<?php |
255 | + |
256 | + |
257 | +/** |
258 | + * @author Sharoon Thomas |
259 | + * Inspired from Dieter's Magento Extender |
260 | + * @copyright 2009 |
261 | + */ |
262 | + |
263 | +class Openlabs_OpenERPConnector_Model_Olcatalog_Product_Attributegroup extends Mage_Catalog_Model_Api_Resource { |
264 | + public function olditems($setId = null) { |
265 | + $groups = Mage :: getModel('eav/entity_attribute_group')->getResourceCollection(); |
266 | + |
267 | + if (!is_null($setId) && !empty ($setId) && is_numeric($setId)) { |
268 | + $groups->setAttributeSetFilter($setId); |
269 | + } |
270 | + |
271 | + $groups->load(); |
272 | + |
273 | + $arrGroups = array (); |
274 | + |
275 | + foreach ($groups as $group) { |
276 | + $arrGroups[] = array ( |
277 | + 'attribute_group_id' => $group->getAttributeGroupId(), |
278 | + 'attribute_set_id' => $group->getAttributeSetId(), |
279 | + 'attribute_group_name' => $group->getAttributeGroupName(), |
280 | + 'sort_order' => $group->getSortOrder(), |
281 | + 'default_id' => $group->getDefaultId() |
282 | + ); |
283 | + } |
284 | + |
285 | + return $arrGroups; |
286 | + } |
287 | + |
288 | + public function items($filters = null) { |
289 | + try { |
290 | + $collection = Mage :: getModel('eav/entity_attribute_group')->getCollection(); |
291 | + } catch (Mage_Core_Exception $e) { |
292 | + $this->_fault('group_not_exists'); |
293 | + } |
294 | + |
295 | + if (is_array($filters)) { |
296 | + try { |
297 | + foreach ($filters as $field => $value) { |
298 | + $collection->addFieldToFilter($field, $value); |
299 | + } |
300 | + } catch (Mage_Core_Exception $e) { |
301 | + $this->_fault('filters_invalid', $e->getMessage()); |
302 | + // If we are adding filter on non-existent attribute |
303 | + } |
304 | + } |
305 | + |
306 | + $result = array (); |
307 | + foreach ($collection as $collection_item) { |
308 | + $result[] = $collection_item->toArray(); |
309 | + } |
310 | + |
311 | + return $result; |
312 | + |
313 | + } |
314 | + /* |
315 | + <param><value><string>cl19t0dqhmheafqc0ccdeejc76</string></value></param> |
316 | + <param><value><string>catalog_product_attribute_group.create</string></value></param> |
317 | + <param> |
318 | + <value> |
319 | + <array> |
320 | + <data> |
321 | + <value><i4>26</i4></value> |
322 | + <value><string>Leonelle</string></value> |
323 | + </data> |
324 | + </array> |
325 | + </value> |
326 | + </param> |
327 | + */ |
328 | + public function create($setId, array $data) { |
329 | + try { |
330 | + // $attrOption = Mage_Eav_Model_Entity_Attribute_Group |
331 | + $attrOption = Mage :: getModel("eav/entity_attribute_group"); |
332 | + |
333 | + $attrOption->addData($data); |
334 | + |
335 | + // check if there already exists a group with the give groupname |
336 | + if ($attrOption->itemExists()) { |
337 | + $this->_fault("group_already_exists"); |
338 | + } |
339 | + |
340 | + $attrOption->save(); |
341 | + |
342 | + return (int) $attrOption->getAttributeGroupId(); |
343 | + } catch (Exception $ex) { |
344 | + return false; |
345 | + } |
346 | + } |
347 | + /* |
348 | + <param><value><string>cl19t0dqhmheafqc0ccdeejc76</string></value></param> |
349 | + <param><value><string>catalog_product_attribute_group.update</string></value></param> |
350 | + <param> |
351 | + <value> |
352 | + <array> |
353 | + <data> |
354 | + <value><i4>85</i4></value> |
355 | + <value><string>Leonelle2</string></value> |
356 | + <value><i4>85</i4></value> |
357 | + <value><i4>85</i4></value> |
358 | + </data> |
359 | + </array> |
360 | + </value> |
361 | + </param> |
362 | + */ |
363 | + public function update(array $data) { |
364 | + try { |
365 | + // $attrOption = Mage_Eav_Model_Entity_Attribute_Group |
366 | + $attrOption = Mage :: getModel("eav/entity_attribute_group"); |
367 | + |
368 | + $attrOption->load($data["attribute_group_id"]); |
369 | + |
370 | + // check if the requested group exists... |
371 | + if (!$attrOption->getAttributeGroupId()) { |
372 | + $this->_fault("group_not_exists"); |
373 | + } |
374 | + |
375 | + $attrOption->addData($data); |
376 | + |
377 | + $attrOption->save(); |
378 | + |
379 | + return true; |
380 | + } catch (Exception $ex) { |
381 | + return false; |
382 | + } |
383 | + } |
384 | + |
385 | + /* |
386 | + <param><value><string>cl19t0dqhmheafqc0ccdeejc76</string></value></param> |
387 | + <param><value><string>catalog_product_attribute_group.delete</string></value></param> |
388 | + <param> |
389 | + <value> |
390 | + <array> |
391 | + <data> |
392 | + <value><i4>85</i4></value> |
393 | + </data> |
394 | + </array> |
395 | + </value> |
396 | + </param> |
397 | + */ |
398 | + public function delete($groupId) { |
399 | + try { |
400 | + // $attrOption = Mage_Eav_Model_Entity_Attribute_Group |
401 | + $attrOption = Mage :: getModel("eav/entity_attribute_group"); |
402 | + |
403 | + $attrOption->load($groupId); |
404 | + |
405 | + // check if the requested group exists... |
406 | + if (!$attrOption->getAttributeGroupId()) { |
407 | + $this->_fault("group_not_exists"); |
408 | + } |
409 | + |
410 | + // save data |
411 | + $attrOption->delete(); |
412 | + |
413 | + return true; |
414 | + } catch (Exception $ex) { |
415 | + return false; |
416 | + } |
417 | + } |
418 | + |
419 | +} |
420 | +?> |
421 | |
422 | === added file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Product/Attributeset.php' |
423 | --- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Product/Attributeset.php 1970-01-01 00:00:00 +0000 |
424 | +++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Product/Attributeset.php 2012-08-10 13:28:19 +0000 |
425 | @@ -0,0 +1,58 @@ |
426 | +<?php |
427 | +/** |
428 | + * Magento |
429 | + * |
430 | + * NOTICE OF LICENSE |
431 | + * |
432 | + * This source file is subject to the Open Software License (OSL 3.0) |
433 | + * that is bundled with this package in the file LICENSE.txt. |
434 | + * It is also available through the world-wide-web at this URL: |
435 | + * http://opensource.org/licenses/osl-3.0.php |
436 | + * If you did not receive a copy of the license and are unable to |
437 | + * obtain it through the world-wide-web, please send an email |
438 | + * to license@magentocommerce.com so we can send you a copy immediately. |
439 | + * |
440 | + * DISCLAIMER |
441 | + * |
442 | + * Do not edit or add to this file if you wish to upgrade Magento to newer |
443 | + * versions in the future. If you wish to customize Magento for your |
444 | + * needs please refer to http://www.magentocommerce.com for more information. |
445 | + * |
446 | + * @category Mage |
447 | + * @package Mage_Catalog |
448 | + * @copyright Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com) |
449 | + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
450 | + */ |
451 | + |
452 | +/** |
453 | + * Catalog product attribute set api |
454 | + * |
455 | + * @category Mage |
456 | + * @package Mage_Catalog |
457 | + * @author Magento Core Team <core@magentocommerce.com> |
458 | + */ |
459 | +class Openlabs_OpenERPConnector_Model_Olcatalog_Product_Attributeset extends Mage_Api_Model_Resource_Abstract |
460 | +{ |
461 | + /** |
462 | + * Retrieve attribute set list |
463 | + * |
464 | + * @return array |
465 | + */ |
466 | + public function items() |
467 | + { |
468 | + $entityType = Mage::getModel('catalog/product')->getResource()->getEntityType(); |
469 | + $collection = Mage::getResourceModel('eav/entity_attribute_set_collection') |
470 | + ->setEntityTypeFilter($entityType->getId()); |
471 | + |
472 | + $result = array(); |
473 | + foreach ($collection as $attributeSet) { |
474 | + $result[] = array( |
475 | + 'attribute_set_id' => $attributeSet->getId(), |
476 | + 'attribute_set_name' => $attributeSet->getAttributeSetName() |
477 | + ); |
478 | + |
479 | + } |
480 | + |
481 | + return $result; |
482 | + } |
483 | +} // Class Mage_Catalog_Model_Product_Attribute_Set_Api End |
484 | \ No newline at end of file |
485 | |
486 | === added file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Product/Tierprice.php' |
487 | --- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Product/Tierprice.php 1970-01-01 00:00:00 +0000 |
488 | +++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Product/Tierprice.php 2012-08-10 13:28:19 +0000 |
489 | @@ -0,0 +1,71 @@ |
490 | +<?php |
491 | + |
492 | +/** |
493 | + * Magento |
494 | + * |
495 | + * NOTICE OF LICENSE |
496 | + * |
497 | + * This source file is subject to the Open Software License (OSL 3.0) |
498 | + * that is bundled with this package in the file LICENSE.txt. |
499 | + * It is also available through the world-wide-web at this URL: |
500 | + * http://opensource.org/licenses/osl-3.0.php |
501 | + * If you did not receive a copy of the license and are unable to |
502 | + * obtain it through the world-wide-web, please send an email |
503 | + * to license@magentocommerce.com so we can send you a copy immediately. |
504 | + * |
505 | + * DISCLAIMER |
506 | + * |
507 | + * Do not edit or add to this file if you wish to upgrade Magento to newer |
508 | + * versions in the future. If you wish to customize Magento for your |
509 | + * needs please refer to http://www.magentocommerce.com for more information. |
510 | + * |
511 | + * @category Mage |
512 | + * @package Mage_Catalog |
513 | + * @copyright Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com) |
514 | + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
515 | + */ |
516 | + |
517 | +/** |
518 | + * Catalog Product tier price api |
519 | + * |
520 | + * @category Mage |
521 | + * @package Mage_Catalog |
522 | + * @author Magento Core Team <core@magentocommerce.com> |
523 | + */ |
524 | +class Openlabs_OpenERPConnector_Model_Olcatalog_Product_Tierprice extends Mage_Catalog_Model_Api_Resource { |
525 | + const ATTRIBUTE_CODE = 'tier_price'; |
526 | + |
527 | + |
528 | + public function items($productIds=null) { |
529 | + if (is_array($productIds)) { |
530 | + $result = array (); |
531 | + foreach ($productIds as $productId) { |
532 | + $product = Mage :: getModel('catalog/product')->load($productId); |
533 | + if (!$product->getId()) { |
534 | + $this->_fault('product_not_exists'); |
535 | + } |
536 | + $tierPrices = $product->getData(self :: ATTRIBUTE_CODE); |
537 | + $result[$productId] = $tierPrices; |
538 | + } |
539 | + } |
540 | + return $result; |
541 | + |
542 | + } |
543 | + |
544 | + public function items2($productIds=null) { |
545 | + $product = Mage :: getModel('catalog/product_attribute_backend_tierprice')->_get_set_go(); |
546 | + if (!$product->getId()) { |
547 | + $this->_fault('product_not_exists'); |
548 | + } |
549 | + |
550 | + $tierPrices = $product->getPriceModel()->getTierPriceCount(); |
551 | + return 'hello'; |
552 | + $result[$productIds] = $tierPrices; |
553 | + |
554 | + |
555 | + return $result; |
556 | + |
557 | + |
558 | + } |
559 | + |
560 | +} |
561 | \ No newline at end of file |
562 | |
563 | === added file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Products.php' |
564 | --- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Products.php 1970-01-01 00:00:00 +0000 |
565 | +++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Products.php 2012-08-10 13:28:19 +0000 |
566 | @@ -0,0 +1,289 @@ |
567 | +<?php |
568 | + |
569 | +class Openlabs_OpenERPConnector_Model_Olcatalog_Products extends Mage_Catalog_Model_Api_Resource |
570 | +{ |
571 | + protected $_filtersMap = array( |
572 | + 'product_id' => 'entity_id', |
573 | + 'set' => 'attribute_set_id', |
574 | + 'type' => 'type_id' |
575 | + ); |
576 | + |
577 | + public function __construct() |
578 | + { |
579 | + $this->_storeIdSessionField = 'product_store_id'; |
580 | + $this->_ignoredAttributeTypes[] = 'gallery'; |
581 | + $this->_ignoredAttributeTypes[] = 'media_image'; |
582 | + } |
583 | + |
584 | + /** |
585 | + * Retrieve list of products with basic info (id, sku, type, set, name) |
586 | + * |
587 | + * @param array $filters |
588 | + * @param string|int $store |
589 | + * @return array |
590 | + */ |
591 | + public function items($filters = null, $store = null) |
592 | + { |
593 | + $collection = Mage::getModel('catalog/product')->getCollection() |
594 | + ->setStoreId($this->_getStoreId($store)) |
595 | + ->addAttributeToSelect('name'); |
596 | + |
597 | + if (is_array($filters)) { |
598 | + try { |
599 | + foreach ($filters as $field => $value) { |
600 | + if (isset($this->_filtersMap[$field])) { |
601 | + $field = $this->_filtersMap[$field]; |
602 | + } |
603 | + |
604 | + $collection->addFieldToFilter($field, $value); |
605 | + } |
606 | + } catch (Mage_Core_Exception $e) { |
607 | + $this->_fault('filters_invalid', $e->getMessage()); |
608 | + } |
609 | + } |
610 | + |
611 | + $result = array(); |
612 | + |
613 | + foreach ($collection as $product) { |
614 | +// $result[] = $product->getData(); |
615 | + $result[] = array( // Basic product data |
616 | + 'product_id' => $product->getId(), |
617 | + 'sku' => $product->getSku(), |
618 | + 'name' => $product->getName(), |
619 | + 'set' => $product->getAttributeSetId(), |
620 | + 'type' => $product->getTypeId(), |
621 | + 'category_ids' => $product->getCategoryIds() |
622 | + ); |
623 | + } |
624 | + |
625 | + return $result; |
626 | + } |
627 | + |
628 | + /** |
629 | + * Retrieve product info |
630 | + * |
631 | + * @param int|string $productId |
632 | + * @param string|int $store |
633 | + * @param array $attributes |
634 | + * @return array |
635 | + */ |
636 | + public function biglist($productId, $store = null, $filters = null) |
637 | + { |
638 | + $collection = Mage::getModel('catalog/product')->getCollection() |
639 | + ->setStoreId($this->_getStoreId($store)) |
640 | + ->addAttributeToSelect('name'); |
641 | + |
642 | + if (is_array($filters)) { |
643 | + try { |
644 | + foreach ($filters as $field => $value) { |
645 | + if (isset($this->_filtersMap[$field])) { |
646 | + $field = $this->_filtersMap[$field]; |
647 | + } |
648 | + |
649 | + $collection->addFieldToFilter($field, $value); |
650 | + } |
651 | + } catch (Mage_Core_Exception $e) { |
652 | + $this->_fault('filters_invalid', $e->getMessage()); |
653 | + } |
654 | + } |
655 | + foreach ($collection as $product) { |
656 | + $data = array(); |
657 | + $data = array( // Basic product data |
658 | + 'product_id' => $product->getId(), |
659 | + 'sku' => $product->getSku(), |
660 | + 'set' => $product->getAttributeSetId(), |
661 | + 'type' => $product->getTypeId(), |
662 | + 'categories' => $product->getCategoryIds(), |
663 | + 'websites' => $product->getWebsiteIds() |
664 | + ); |
665 | + |
666 | + foreach ($product->getTypeInstance(true)->getEditableAttributes($product) as $attribute) { |
667 | + $data[$attribute->getAttributeCode()] = $product->getData($attribute->getAttributeCode()); |
668 | + } |
669 | + $result[]=$data; |
670 | + } |
671 | + return $result; |
672 | + } |
673 | + |
674 | + /** |
675 | + * Create new product. |
676 | + * |
677 | + * @param string $type |
678 | + * @param int $set |
679 | + * @param array $productData |
680 | + * @return int |
681 | + */ |
682 | + public function create($type, $set, $sku, $productData) |
683 | + { |
684 | + if (!$type || !$set || !$sku) { |
685 | + $this->_fault('data_invalid'); |
686 | + } |
687 | + |
688 | + $product = Mage::getModel('catalog/product'); |
689 | + /* @var $product Mage_Catalog_Model_Product */ |
690 | + $product->setStoreId($this->_getStoreId($store)) |
691 | + ->setAttributeSetId($set) |
692 | + ->setTypeId($type) |
693 | + ->setSku($sku); |
694 | + |
695 | + if (isset($productData['website_ids']) && is_array($productData['website_ids'])) { |
696 | + $product->setWebsiteIds($productData['website_ids']); |
697 | + } |
698 | + |
699 | + foreach ($product->getTypeInstance(true)->getEditableAttributes($product) as $attribute) { |
700 | + if ($this->_isAllowedAttribute($attribute) |
701 | + && isset($productData[$attribute->getAttributeCode()])) { |
702 | + $product->setData( |
703 | + $attribute->getAttributeCode(), |
704 | + $productData[$attribute->getAttributeCode()] |
705 | + ); |
706 | + } |
707 | + } |
708 | + |
709 | + $this->_prepareDataForSave($product, $productData); |
710 | + |
711 | + if (is_array($errors = $product->validate())) { |
712 | + $this->_fault('data_invalid', implode("\n", $errors)); |
713 | + } |
714 | + |
715 | + try { |
716 | + $product->save(); |
717 | + } catch (Mage_Core_Exception $e) { |
718 | + $this->_fault('data_invalid', $e->getMessage()); |
719 | + } |
720 | + |
721 | + return $product->getId(); |
722 | + } |
723 | + |
724 | + /** |
725 | + * Update product data |
726 | + * |
727 | + * @param int|string $productId |
728 | + * @param array $productData |
729 | + * @param string|int $store |
730 | + * @return boolean |
731 | + */ |
732 | + public function update($productId, $productData = array(), $store = null) |
733 | + { |
734 | + $product = $this->_getProduct($productId, $store); |
735 | + |
736 | + if (!$product->getId()) { |
737 | + $this->_fault('not_exists'); |
738 | + } |
739 | + |
740 | + if (isset($productData['website_ids']) && is_array($productData['website_ids'])) { |
741 | + $product->setWebsiteIds($productData['website_ids']); |
742 | + } |
743 | + |
744 | + foreach ($product->getTypeInstance(true)->getEditableAttributes($product) as $attribute) { |
745 | + if ($this->_isAllowedAttribute($attribute) |
746 | + && isset($productData[$attribute->getAttributeCode()])) { |
747 | + $product->setData( |
748 | + $attribute->getAttributeCode(), |
749 | + $productData[$attribute->getAttributeCode()] |
750 | + ); |
751 | + } |
752 | + } |
753 | + |
754 | + $this->_prepareDataForSave($product, $productData); |
755 | + |
756 | + try { |
757 | + if (is_array($errors = $product->validate())) { |
758 | + $this->_fault('data_invalid', implode("\n", $errors)); |
759 | + } |
760 | + } catch (Mage_Core_Exception $e) { |
761 | + $this->_fault('data_invalid', $e->getMessage()); |
762 | + } |
763 | + |
764 | + try { |
765 | + $product->save(); |
766 | + } catch (Mage_Core_Exception $e) { |
767 | + $this->_fault('data_invalid', $e->getMessage()); |
768 | + } |
769 | + |
770 | + return true; |
771 | + } |
772 | + |
773 | + /** |
774 | + * Set additional data before product saved |
775 | + * |
776 | + * @param Mage_Catalog_Model_Product $product |
777 | + * @param array $productData |
778 | + * @return object |
779 | + */ |
780 | + protected function _prepareDataForSave ($product, $productData) |
781 | + { |
782 | + if (isset($productData['categories']) && is_array($productData['categories'])) { |
783 | + $product->setCategoryIds($productData['categories']); |
784 | + } |
785 | + |
786 | + if (isset($productData['websites']) && is_array($productData['websites'])) { |
787 | + foreach ($productData['websites'] as &$website) { |
788 | + if (is_string($website)) { |
789 | + try { |
790 | + $website = Mage::app()->getWebsite($website)->getId(); |
791 | + } catch (Exception $e) { } |
792 | + } |
793 | + } |
794 | + $product->setWebsiteIds($productData['websites']); |
795 | + } |
796 | + |
797 | + if (isset($productData['stock_data']) && is_array($productData['stock_data'])) { |
798 | + $product->setStockData($productData['stock_data']); |
799 | + } |
800 | + } |
801 | + |
802 | + /** |
803 | + * Update product special price |
804 | + * |
805 | + * @param int|string $productId |
806 | + * @param float $specialPrice |
807 | + * @param string $fromDate |
808 | + * @param string $toDate |
809 | + * @param string|int $store |
810 | + * @return boolean |
811 | + */ |
812 | + public function setSpecialPrice($productId, $specialPrice = null, $fromDate = null, $toDate = null, $store = null) |
813 | + { |
814 | + return $this->update($productId, array( |
815 | + 'special_price' => $specialPrice, |
816 | + 'special_from_date' => $fromDate, |
817 | + 'special_to_date' => $toDate |
818 | + ), $store); |
819 | + } |
820 | + |
821 | + /** |
822 | + * Retrieve product special price |
823 | + * |
824 | + * @param int|string $productId |
825 | + * @param string|int $store |
826 | + * @return array |
827 | + */ |
828 | + public function getSpecialPrice($productId, $store = null) |
829 | + { |
830 | + return $this->info($productId, $store, array('special_price', 'special_from_date', 'special_to_date')); |
831 | + } |
832 | + |
833 | + /** |
834 | + * Delete product |
835 | + * |
836 | + * @param int|string $productId |
837 | + * @return boolean |
838 | + */ |
839 | + public function delete($productId) |
840 | + { |
841 | + $product = $this->_getProduct($productId); |
842 | + |
843 | + if (!$product->getId()) { |
844 | + $this->_fault('not_exists'); |
845 | + } |
846 | + |
847 | + try { |
848 | + $product->delete(); |
849 | + } catch (Mage_Core_Exception $e) { |
850 | + $this->_fault('not_deleted', $e->getMessage()); |
851 | + } |
852 | + |
853 | + return true; |
854 | + } |
855 | +} // Class Mage_Catalog_Model_Product_Api End |
856 | \ No newline at end of file |
857 | |
858 | === added directory 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcore' |
859 | === added file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcore/Groups.php' |
860 | --- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcore/Groups.php 1970-01-01 00:00:00 +0000 |
861 | +++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcore/Groups.php 2012-08-10 13:28:19 +0000 |
862 | @@ -0,0 +1,142 @@ |
863 | +<?php |
864 | + |
865 | +/** |
866 | + * @author Sharoon Thomas |
867 | + * Inspired from Dieter's Magento Extender |
868 | + * @copyright 2009 |
869 | + */ |
870 | + |
871 | +class Openlabs_OpenERPConnector_Model_Olcore_Groups extends Mage_Catalog_Model_Api_Resource |
872 | +{ |
873 | + public function items($filters=null) |
874 | + { |
875 | + try |
876 | + { |
877 | + $collection = Mage::getModel('core/store_group')->getCollection();//->addAttributeToSelect('*'); |
878 | + } |
879 | + catch (Mage_Core_Exception $e) |
880 | + { |
881 | + $this->_fault('group_not_exists'); |
882 | + } |
883 | + |
884 | + if (is_array($filters)) { |
885 | + try { |
886 | + foreach ($filters as $field => $value) { |
887 | + $collection->addFieldToFilter($field, $value); |
888 | + } |
889 | + } catch (Mage_Core_Exception $e) { |
890 | + $this->_fault('filters_invalid', $e->getMessage()); |
891 | + // If we are adding filter on non-existent attribute |
892 | + } |
893 | + } |
894 | + |
895 | + $result = array(); |
896 | + foreach ($collection as $customer) { |
897 | + $result[] = $customer->toArray(); |
898 | + } |
899 | + |
900 | + return $result; |
901 | + } |
902 | + |
903 | + public function info($groupIds = null) |
904 | + { |
905 | + $groups = array(); |
906 | + |
907 | + if(is_array($groupIds)) |
908 | + { |
909 | + foreach($groupIds as $groupId) |
910 | + { |
911 | + try |
912 | + { |
913 | + $groups[] = Mage::getModel('core/store_group')->load($groupId)->toArray(); |
914 | + } |
915 | + catch (Mage_Core_Exception $e) |
916 | + { |
917 | + $this->_fault('group_not_exists'); |
918 | + } |
919 | + } |
920 | + return $groups; |
921 | + } |
922 | + elseif(is_numeric($groupIds)) |
923 | + { |
924 | + try |
925 | + { |
926 | + return Mage::getModel('core/store_group')->load($groupIds)->toArray(); |
927 | + } |
928 | + catch (Mage_Core_Exception $e) |
929 | + { |
930 | + $this->_fault('group_not_exists'); |
931 | + } |
932 | + |
933 | + } |
934 | + |
935 | + } |
936 | + |
937 | + public function create($groupdata) |
938 | + { |
939 | + try |
940 | + { |
941 | + $group = Mage::getModel('core/store_group') |
942 | + ->setData($groupdata) |
943 | + ->save(); |
944 | + |
945 | + } |
946 | + catch (Magento_Core_Exception $e) |
947 | + { |
948 | + $this->_fault('data_invalid',$e->getMessage()); |
949 | + } |
950 | + catch (Exception $e) |
951 | + { |
952 | + $this->_fault('data_invalid',$e->getMessage()); |
953 | + } |
954 | + return $group->getId(); |
955 | + } |
956 | + |
957 | + public function update($groupid,$groupdata) |
958 | + { |
959 | + try |
960 | + { |
961 | + $group = Mage::getModel('core/store_group') |
962 | + ->load($groupid); |
963 | + if (!$group->getId()) |
964 | + { |
965 | + $this->_fault('group_not_exists'); |
966 | + } |
967 | + $group->addData($groupdata)->save(); |
968 | + } |
969 | + catch (Magento_Core_Exception $e) |
970 | + { |
971 | + $this->_fault('data_invalid',$e->getMessage()); |
972 | + } |
973 | + catch (Exception $e) |
974 | + { |
975 | + $this->_fault('data_invalid',$e->getMessage()); |
976 | + } |
977 | + return true; |
978 | + } |
979 | + |
980 | + public function delete($groupid) |
981 | + { |
982 | + try |
983 | + { |
984 | + $group = Mage::getModel('core/store_group') |
985 | + ->load($groupid); |
986 | + if (!$group->getId()) |
987 | + { |
988 | + $this->_fault('group_not_exists'); |
989 | + } |
990 | + $group->delete(); |
991 | + |
992 | + } |
993 | + catch (Magento_Core_Exception $e) |
994 | + { |
995 | + $this->_fault('data_invalid',$e->getMessage()); |
996 | + } |
997 | + catch (Exception $e) |
998 | + { |
999 | + $this->_fault('data_invalid',$e->getMessage()); |
1000 | + } |
1001 | + return true; |
1002 | + } |
1003 | +} |
1004 | +?> |
1005 | |
1006 | === added file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcore/Storeviews.php' |
1007 | --- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcore/Storeviews.php 1970-01-01 00:00:00 +0000 |
1008 | +++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcore/Storeviews.php 2012-08-10 13:28:19 +0000 |
1009 | @@ -0,0 +1,142 @@ |
1010 | +<?php |
1011 | + |
1012 | +/** |
1013 | + * @author Sharoon Thomas |
1014 | + * Inspired from Dieter's Magento Extender |
1015 | + * @copyright 2009 |
1016 | + */ |
1017 | + |
1018 | +class Openlabs_OpenERPConnector_Model_Olcore_Storeviews extends Mage_Catalog_Model_Api_Resource |
1019 | +{ |
1020 | + public function items($filters=null) |
1021 | + { |
1022 | + try |
1023 | + { |
1024 | + $collection = Mage::getModel('core/store')->getCollection();//->addAttributeToSelect('*'); |
1025 | + } |
1026 | + catch (Mage_Core_Exception $e) |
1027 | + { |
1028 | + $this->_fault('store_not_exists'); |
1029 | + } |
1030 | + |
1031 | + if (is_array($filters)) { |
1032 | + try { |
1033 | + foreach ($filters as $field => $value) { |
1034 | + $collection->addFieldToFilter($field, $value); |
1035 | + } |
1036 | + } catch (Mage_Core_Exception $e) { |
1037 | + $this->_fault('filters_invalid', $e->getMessage()); |
1038 | + // If we are adding filter on non-existent attribute |
1039 | + } |
1040 | + } |
1041 | + |
1042 | + $result = array(); |
1043 | + foreach ($collection as $customer) { |
1044 | + $result[] = $customer->toArray(); |
1045 | + } |
1046 | + |
1047 | + return $result; |
1048 | + } |
1049 | + |
1050 | + public function info($storeIds = null) |
1051 | + { |
1052 | + $stores = array(); |
1053 | + |
1054 | + if(is_array($storeIds)) |
1055 | + { |
1056 | + foreach($storeIds as $storeId) |
1057 | + { |
1058 | + try |
1059 | + { |
1060 | + $stores[] = Mage::getModel('core/store')->load($storeId)->toArray(); |
1061 | + } |
1062 | + catch (Mage_Core_Exception $e) |
1063 | + { |
1064 | + $this->_fault('store_not_exists'); |
1065 | + } |
1066 | + } |
1067 | + return $stores; |
1068 | + } |
1069 | + elseif(is_numeric($storeIds)) |
1070 | + { |
1071 | + try |
1072 | + { |
1073 | + return Mage::getModel('core/store')->load($storeIds)->toArray(); |
1074 | + } |
1075 | + catch (Mage_Core_Exception $e) |
1076 | + { |
1077 | + $this->_fault('store_not_exists'); |
1078 | + } |
1079 | + |
1080 | + } |
1081 | + |
1082 | + } |
1083 | + |
1084 | + public function create($storedata) |
1085 | + { |
1086 | + try |
1087 | + { |
1088 | + $store = Mage::getModel('core/store') |
1089 | + ->setData($storedata) |
1090 | + ->save(); |
1091 | + |
1092 | + } |
1093 | + catch (Magento_Core_Exception $e) |
1094 | + { |
1095 | + $this->_fault('data_invalid',$e->getMessage()); |
1096 | + } |
1097 | + catch (Exception $e) |
1098 | + { |
1099 | + $this->_fault('data_invalid',$e->getMessage()); |
1100 | + } |
1101 | + return $store->getId(); |
1102 | + } |
1103 | + |
1104 | + public function update($storeid,$storedata) |
1105 | + { |
1106 | + try |
1107 | + { |
1108 | + $store = Mage::getModel('core/store') |
1109 | + ->load($storeid); |
1110 | + if (!$store->getId()) |
1111 | + { |
1112 | + $this->_fault('store_not_exists'); |
1113 | + } |
1114 | + $store->addData($storedata)->save(); |
1115 | + } |
1116 | + catch (Magento_Core_Exception $e) |
1117 | + { |
1118 | + $this->_fault('data_invalid',$e->getMessage()); |
1119 | + } |
1120 | + catch (Exception $e) |
1121 | + { |
1122 | + $this->_fault('data_invalid',$e->getMessage()); |
1123 | + } |
1124 | + return true; |
1125 | + } |
1126 | + |
1127 | + public function delete($storeid) |
1128 | + { |
1129 | + try |
1130 | + { |
1131 | + $store = Mage::getModel('core/store') |
1132 | + ->load($storeid); |
1133 | + if (!$store->getId()) |
1134 | + { |
1135 | + $this->_fault('store_not_exists'); |
1136 | + } |
1137 | + $store->delete(); |
1138 | + |
1139 | + } |
1140 | + catch (Magento_Core_Exception $e) |
1141 | + { |
1142 | + $this->_fault('data_invalid',$e->getMessage()); |
1143 | + } |
1144 | + catch (Exception $e) |
1145 | + { |
1146 | + $this->_fault('data_invalid',$e->getMessage()); |
1147 | + } |
1148 | + return true; |
1149 | + } |
1150 | +} |
1151 | +?> |
1152 | |
1153 | === added file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcore/Website.php' |
1154 | --- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcore/Website.php 1970-01-01 00:00:00 +0000 |
1155 | +++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcore/Website.php 2012-08-10 13:28:19 +0000 |
1156 | @@ -0,0 +1,171 @@ |
1157 | +<?php |
1158 | + |
1159 | +/** |
1160 | + * @author Sharoon Thomas |
1161 | + * Inspired from Dieter's Magento Extender |
1162 | + * @copyright 2009 |
1163 | + */ |
1164 | + |
1165 | +class Openlabs_OpenERPConnector_Model_Olcore_Website extends Mage_Catalog_Model_Api_Resource |
1166 | +{ |
1167 | + |
1168 | + public function items($filters=null) |
1169 | + { |
1170 | + try |
1171 | + { |
1172 | + $collection = Mage::getModel('core/website')->getCollection();//->addAttributeToSelect('*'); |
1173 | + } |
1174 | + catch (Mage_Core_Exception $e) |
1175 | + { |
1176 | + $this->_fault('store_not_exists'); |
1177 | + } |
1178 | + |
1179 | + if (is_array($filters)) { |
1180 | + try { |
1181 | + foreach ($filters as $field => $value) { |
1182 | + $collection->addFieldToFilter($field, $value); |
1183 | + } |
1184 | + } catch (Mage_Core_Exception $e) { |
1185 | + $this->_fault('filters_invalid', $e->getMessage()); |
1186 | + // If we are adding filter on non-existent attribute |
1187 | + } |
1188 | + } |
1189 | + |
1190 | + $result = array(); |
1191 | + foreach ($collection as $customer) { |
1192 | + $result[] = $customer->toArray(); |
1193 | + } |
1194 | + |
1195 | + return $result; |
1196 | + } |
1197 | + |
1198 | + public function info($storeIds = null) |
1199 | + { |
1200 | + $stores = array(); |
1201 | + |
1202 | + if(is_array($storeIds)) |
1203 | + { |
1204 | + foreach($storeIds as $storeId) |
1205 | + { |
1206 | + try |
1207 | + { |
1208 | + $stores[] = Mage::getModel('core/website')->load($storeId)->toArray(); |
1209 | + } |
1210 | + catch (Mage_Core_Exception $e) |
1211 | + { |
1212 | + $this->_fault('store_not_exists'); |
1213 | + } |
1214 | + } |
1215 | + return $stores; |
1216 | + } |
1217 | + elseif(is_numeric($storeIds)) |
1218 | + { |
1219 | + try |
1220 | + { |
1221 | + return Mage::getModel('core/website')->load($storeIds)->toArray(); |
1222 | + } |
1223 | + catch (Mage_Core_Exception $e) |
1224 | + { |
1225 | + $this->_fault('store_not_exists'); |
1226 | + } |
1227 | + |
1228 | + } |
1229 | + |
1230 | + } |
1231 | + //This is a protected function used by items & info for fetching website information |
1232 | + |
1233 | + public function create($websitedata) |
1234 | + { |
1235 | + try |
1236 | + { |
1237 | + $website = Mage::getModel('core/website') |
1238 | + ->setData($websitedata) |
1239 | + ->save(); |
1240 | + |
1241 | + } |
1242 | + catch (Magento_Core_Exception $e) |
1243 | + { |
1244 | + $this->_fault('data_invalid',$e->getMessage()); |
1245 | + } |
1246 | + catch (Exception $e) |
1247 | + { |
1248 | + $this->_fault('data_invalid',$e->getMessage()); |
1249 | + } |
1250 | + return $website->getId(); |
1251 | + } |
1252 | + |
1253 | + public function update($websiteid,$websitedata) |
1254 | + { |
1255 | + try |
1256 | + { |
1257 | + $website = Mage::getModel('core/website') |
1258 | + ->load($websiteid); |
1259 | + if (!$website->getId()) |
1260 | + { |
1261 | + $this->_fault('website_not_exists'); |
1262 | + } |
1263 | + $website->addData($websitedata)->save(); |
1264 | + } |
1265 | + catch (Magento_Core_Exception $e) |
1266 | + { |
1267 | + $this->_fault('data_invalid',$e->getMessage()); |
1268 | + } |
1269 | + catch (Exception $e) |
1270 | + { |
1271 | + $this->_fault('data_invalid',$e->getMessage()); |
1272 | + } |
1273 | + return true; |
1274 | + } |
1275 | + |
1276 | + public function delete($websiteid) |
1277 | + { |
1278 | + try |
1279 | + { |
1280 | + $website = Mage::getModel('core/website') |
1281 | + ->load($websiteid); |
1282 | + if (!$website->getId()) |
1283 | + { |
1284 | + $this->_fault('website_not_exists'); |
1285 | + } |
1286 | + $website->delete(); |
1287 | + |
1288 | + } |
1289 | + catch (Magento_Core_Exception $e) |
1290 | + { |
1291 | + $this->_fault('data_invalid',$e->getMessage()); |
1292 | + } |
1293 | + catch (Exception $e) |
1294 | + { |
1295 | + $this->_fault('data_invalid',$e->getMessage()); |
1296 | + } |
1297 | + return true; |
1298 | + } |
1299 | + |
1300 | + public function tree() |
1301 | + { |
1302 | + $tree = array(); |
1303 | + |
1304 | + $websites = $this->websites(); |
1305 | + |
1306 | + foreach($websites as $website) |
1307 | + { |
1308 | + $groups = $this->groups($website['group_ids']); |
1309 | + $tree[$website['code']] = $website; |
1310 | + foreach($groups as $group) |
1311 | + { |
1312 | + $stores = $this->stores($group["store_ids"]); |
1313 | + |
1314 | + $tree[$website['code']]['groups']['group_'.$group['group_id']] = $group; |
1315 | + |
1316 | + foreach($stores as $store) |
1317 | + { |
1318 | + $tree[$website['code']]['groups']['group_'.$group['group_id']]['stores'][$store['code']] = $store; |
1319 | + } |
1320 | + } |
1321 | + } |
1322 | + |
1323 | + return $tree; |
1324 | + } |
1325 | + |
1326 | +} |
1327 | +?> |
1328 | \ No newline at end of file |
1329 | |
1330 | === added directory 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcustomer' |
1331 | === added file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcustomer/Address.php' |
1332 | --- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcustomer/Address.php 1970-01-01 00:00:00 +0000 |
1333 | +++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcustomer/Address.php 2012-08-10 13:28:19 +0000 |
1334 | @@ -0,0 +1,241 @@ |
1335 | +<?php |
1336 | +/** |
1337 | + * Magento |
1338 | + * |
1339 | + * NOTICE OF LICENSE |
1340 | + * |
1341 | + * This source file is subject to the Open Software License (OSL 3.0) |
1342 | + * that is bundled with this package in the file LICENSE.txt. |
1343 | + * It is also available through the world-wide-web at this URL: |
1344 | + * http://opensource.org/licenses/osl-3.0.php |
1345 | + * If you did not receive a copy of the license and are unable to |
1346 | + * obtain it through the world-wide-web, please send an email |
1347 | + * to license@magentocommerce.com so we can send you a copy immediately. |
1348 | + * |
1349 | + * DISCLAIMER |
1350 | + * |
1351 | + * Do not edit or add to this file if you wish to upgrade Magento to newer |
1352 | + * versions in the future. If you wish to customize Magento for your |
1353 | + * needs please refer to http://www.magentocommerce.com for more information. |
1354 | + * |
1355 | + * @category Mage |
1356 | + * @package Mage_Customer |
1357 | + * @copyright Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com) |
1358 | + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
1359 | + */ |
1360 | + |
1361 | +/** |
1362 | + * Customer address api |
1363 | + * |
1364 | + * @category Mage |
1365 | + * @package Mage_Customer |
1366 | + * @author Magento Core Team <core@magentocommerce.com> |
1367 | + */ |
1368 | +class Openlabs_OpenERPConnector_Model_Olcustomer_Address extends Mage_Customer_Model_Api_Resource |
1369 | +{ |
1370 | + protected $_mapAttributes = array( |
1371 | + 'customer_id' => 'entity_id' |
1372 | + ); |
1373 | + |
1374 | + public function __construct() |
1375 | + { |
1376 | + $this->_ignoredAttributeCodes[] = 'parent_id'; |
1377 | + } |
1378 | + |
1379 | + /** |
1380 | + * Retrive customer addresses list |
1381 | + * |
1382 | + * @param int $customerId |
1383 | + * @return array |
1384 | + */ |
1385 | + public function items($customerId) |
1386 | + { |
1387 | + $customer = Mage::getModel('customer/customer') |
1388 | + ->load($customerId); |
1389 | + /* @var $customer Mage_Customer_Model_Customer */ |
1390 | + |
1391 | + if (!$customer->getId()) { |
1392 | + $this->_fault('customer_not_exists'); |
1393 | + } |
1394 | + |
1395 | + $result = array(); |
1396 | + foreach ($customer->getAddresses() as $address) { |
1397 | + $data = $address->toArray(); |
1398 | + $data['default_billing'] = $customer->getDefaultBilling() == $address->getId(); |
1399 | + $data['default_shipping'] = $customer->getDefaultShipping() == $address->getId(); |
1400 | + $result[] = $data; |
1401 | + /*$data = $address->toArray(); |
1402 | + $row = array(); |
1403 | + |
1404 | + foreach ($this->_mapAttributes as $attributeAlias => $attributeCode) { |
1405 | + $row[$attributeAlias] = isset($data[$attributeCode]) ? $data[$attributeCode] : null; |
1406 | + } |
1407 | + |
1408 | + foreach ($this->getAllowedAttributes($address) as $attributeCode => $attribute) { |
1409 | + if (isset($data[$attributeCode])) { |
1410 | + $row[$attributeCode] = $data[$attributeCode]; |
1411 | + } |
1412 | + } |
1413 | + |
1414 | + $row['is_default_billing'] = $customer->getDefaultBillingAddress() == $address->getId(); |
1415 | + $row['is_default_shipping'] = $customer->getDefaultShippingAddress() == $address->getId(); |
1416 | + |
1417 | + $result[] = $row;*/ |
1418 | + |
1419 | + } |
1420 | + |
1421 | + return $result; |
1422 | + } |
1423 | + |
1424 | + /** |
1425 | + * Create new address for customer |
1426 | + * |
1427 | + * @param int $customerId |
1428 | + * @param array $addressData |
1429 | + * @return int |
1430 | + */ |
1431 | + public function create($customerId, $addressData) |
1432 | + { |
1433 | + $customer = Mage::getModel('customer/customer') |
1434 | + ->load($customerId); |
1435 | + /* @var $customer Mage_Customer_Model_Customer */ |
1436 | + |
1437 | + if (!$customer->getId()) { |
1438 | + $this->_fault('customer_not_exists'); |
1439 | + } |
1440 | + |
1441 | + $address = Mage::getModel('customer/address'); |
1442 | + |
1443 | + foreach ($this->getAllowedAttributes($address) as $attributeCode=>$attribute) { |
1444 | + if (isset($addressData[$attributeCode])) { |
1445 | + $address->setData($attributeCode, $addressData[$attributeCode]); |
1446 | + } |
1447 | + } |
1448 | + |
1449 | + if (isset($addressData['is_default_billing'])) { |
1450 | + $address->setIsDefaultBilling($addressData['is_default_billing']); |
1451 | + } |
1452 | + |
1453 | + if (isset($addressData['is_default_shipping'])) { |
1454 | + $address->setIsDefaultShipping($addressData['is_default_shipping']); |
1455 | + } |
1456 | + |
1457 | + $address->setCustomerId($customer->getId()); |
1458 | + |
1459 | + $valid = $address->validate(); |
1460 | + |
1461 | + if (is_array($valid)) { |
1462 | + $this->_fault('data_invalid', implode("\n", $valid)); |
1463 | + } |
1464 | + |
1465 | + try { |
1466 | + $address->save(); |
1467 | + } catch (Mage_Core_Exception $e) { |
1468 | + $this->_fault('data_invalid', $e->getMessage()); |
1469 | + } |
1470 | + |
1471 | + return $address->getId(); |
1472 | + } |
1473 | + |
1474 | + /** |
1475 | + * Retrieve address data |
1476 | + * |
1477 | + * @param int $addressId |
1478 | + * @return array |
1479 | + */ |
1480 | + public function info($addressId) |
1481 | + { |
1482 | + $address = Mage::getModel('customer/address') |
1483 | + ->load($addressId); |
1484 | + |
1485 | + if (!$address->getId()) { |
1486 | + $this->_fault('not_exists'); |
1487 | + } |
1488 | + |
1489 | + $result = array(); |
1490 | + |
1491 | + foreach ($this->_mapAttributes as $attributeAlias => $attributeCode) { |
1492 | + $result[$attributeAlias] = $address->getData($attributeCode); |
1493 | + } |
1494 | + |
1495 | + foreach ($this->getAllowedAttributes($address) as $attributeCode => $attribute) { |
1496 | + $result[$attributeCode] = $address->getData($attributeCode); |
1497 | + } |
1498 | + |
1499 | + |
1500 | + if ($customer = $address->getCustomer()) { |
1501 | + $result['is_default_billing'] = $customer->getDefaultBillingAddress() == $address->getId(); |
1502 | + $result['is_default_shipping'] = $customer->getDefaultShippingAddress() == $address->getId(); |
1503 | + } |
1504 | + |
1505 | + return $result; |
1506 | + } |
1507 | + |
1508 | + /** |
1509 | + * Update address data |
1510 | + * |
1511 | + * @param int $addressId |
1512 | + * @param array $addressData |
1513 | + * @return boolean |
1514 | + */ |
1515 | + public function update($addressId, $addressData) |
1516 | + { |
1517 | + $address = Mage::getModel('customer/address') |
1518 | + ->load($addressId); |
1519 | + |
1520 | + if (!$address->getId()) { |
1521 | + $this->_fault('not_exists'); |
1522 | + } |
1523 | + |
1524 | + foreach ($this->getAllowedAttributes($address) as $attributeCode=>$attribute) { |
1525 | + if (isset($addressData[$attributeCode])) { |
1526 | + $address->setData($attributeCode, $addressData[$attributeCode]); |
1527 | + } |
1528 | + } |
1529 | + |
1530 | + if (isset($addressData['is_default_billing'])) { |
1531 | + $address->setIsDefaultBilling($addressData['is_default_billing']); |
1532 | + } |
1533 | + |
1534 | + if (isset($addressData['is_default_shipping'])) { |
1535 | + $address->setIsDefaultShipping($addressData['is_default_shipping']); |
1536 | + } |
1537 | + |
1538 | + $valid = $address->validate(); |
1539 | + if (is_array($valid)) { |
1540 | + $this->_fault('data_invalid', implode("\n", $valid)); |
1541 | + } |
1542 | + |
1543 | + try { |
1544 | + $address->save(); |
1545 | + } catch (Mage_Core_Exception $e) { |
1546 | + $this->_fault('data_invalid', $e->getMessage()); |
1547 | + } |
1548 | + |
1549 | + return true; |
1550 | + } |
1551 | + |
1552 | + /** |
1553 | + * Delete address |
1554 | + * |
1555 | + * @param int $addressId |
1556 | + * @return boolean |
1557 | + */ |
1558 | + public function delete($addressId) |
1559 | + { |
1560 | + $address = Mage::getModel('customer/address') |
1561 | + ->load($addressId); |
1562 | + |
1563 | + if (!$address->getId()) { |
1564 | + $this->_fault('not_exists'); |
1565 | + } |
1566 | + |
1567 | + try { |
1568 | + $address->delete(); |
1569 | + } catch (Mage_Core_Exception $e) { |
1570 | + $this->_fault('not_deleted', $e->getMessage()); |
1571 | + } |
1572 | + |
1573 | + return true; |
1574 | + } |
1575 | +} // Class Mage_Customer_Model_Address_Api End |
1576 | \ No newline at end of file |
1577 | |
1578 | === added file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcustomer/Customer.php' |
1579 | --- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcustomer/Customer.php 1970-01-01 00:00:00 +0000 |
1580 | +++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcustomer/Customer.php 2012-08-10 13:28:19 +0000 |
1581 | @@ -0,0 +1,142 @@ |
1582 | +<?php |
1583 | + |
1584 | +/** |
1585 | + * @author Sharoon Thomas |
1586 | + * Inspired from Dieter's Magento Extender |
1587 | + * @copyright 2009 |
1588 | + */ |
1589 | + |
1590 | +class Openlabs_OpenERPConnector_Model_Olcustomer_Customer extends Mage_Catalog_Model_Api_Resource |
1591 | +{ |
1592 | + public function items($filters=null) |
1593 | + { |
1594 | + try |
1595 | + { |
1596 | + $collection = Mage::getModel('customer')->getCollection();//->addAttributeToSelect('*'); |
1597 | + } |
1598 | + catch (Mage_Core_Exception $e) |
1599 | + { |
1600 | + $this->_fault('customer_not_exists'); |
1601 | + } |
1602 | + |
1603 | + if (is_array($filters)) { |
1604 | + try { |
1605 | + foreach ($filters as $field => $value) { |
1606 | + $collection->addFieldToFilter($field, $value); |
1607 | + } |
1608 | + } catch (Mage_Core_Exception $e) { |
1609 | + $this->_fault('filters_invalid', $e->getMessage()); |
1610 | + // If we are adding filter on non-existent attribute |
1611 | + } |
1612 | + } |
1613 | + |
1614 | + $result = array(); |
1615 | + foreach ($collection as $customer) { |
1616 | + $result[] = $customer->toArray(); |
1617 | + } |
1618 | + |
1619 | + return $result; |
1620 | + } |
1621 | + |
1622 | + public function info($groupIds = null) |
1623 | + { |
1624 | + $groups = array(); |
1625 | + |
1626 | + if(is_array($groupIds)) |
1627 | + { |
1628 | + foreach($groupIds as $groupId) |
1629 | + { |
1630 | + try |
1631 | + { |
1632 | + $groups[] = Mage::getModel('customer')->load($groupId)->toArray(); |
1633 | + } |
1634 | + catch (Mage_Core_Exception $e) |
1635 | + { |
1636 | + $this->_fault('customer_not_exists'); |
1637 | + } |
1638 | + } |
1639 | + return $groups; |
1640 | + } |
1641 | + elseif(is_numeric($groupIds)) |
1642 | + { |
1643 | + try |
1644 | + { |
1645 | + return Mage::getModel('customer')->load($groupIds)->toArray(); |
1646 | + } |
1647 | + catch (Mage_Core_Exception $e) |
1648 | + { |
1649 | + $this->_fault('customer_not_exists'); |
1650 | + } |
1651 | + |
1652 | + } |
1653 | + |
1654 | + } |
1655 | + |
1656 | + public function create($groupdata) |
1657 | + { |
1658 | + try |
1659 | + { |
1660 | + $group = Mage::getModel('customer') |
1661 | + ->setData($groupdata) |
1662 | + ->save(); |
1663 | + |
1664 | + } |
1665 | + catch (Magento_Core_Exception $e) |
1666 | + { |
1667 | + $this->_fault('data_invalid',$e->getMessage()); |
1668 | + } |
1669 | + catch (Exception $e) |
1670 | + { |
1671 | + $this->_fault('data_invalid',$e->getMessage()); |
1672 | + } |
1673 | + return $group->getId(); |
1674 | + } |
1675 | + |
1676 | + public function update($groupid,$groupdata) |
1677 | + { |
1678 | + try |
1679 | + { |
1680 | + $group = Mage::getModel('customer') |
1681 | + ->load($groupid); |
1682 | + if (!$group->getId()) |
1683 | + { |
1684 | + $this->_fault('customer_not_exists'); |
1685 | + } |
1686 | + $group->addData($groupdata)->save(); |
1687 | + } |
1688 | + catch (Magento_Core_Exception $e) |
1689 | + { |
1690 | + $this->_fault('data_invalid',$e->getMessage()); |
1691 | + } |
1692 | + catch (Exception $e) |
1693 | + { |
1694 | + $this->_fault('data_invalid',$e->getMessage()); |
1695 | + } |
1696 | + return true; |
1697 | + } |
1698 | + |
1699 | + public function delete($groupid) |
1700 | + { |
1701 | + try |
1702 | + { |
1703 | + $group = Mage::getModel('customer') |
1704 | + ->load($groupid); |
1705 | + if (!$group->getId()) |
1706 | + { |
1707 | + $this->_fault('customer_not_exists'); |
1708 | + } |
1709 | + $group->delete(); |
1710 | + |
1711 | + } |
1712 | + catch (Magento_Core_Exception $e) |
1713 | + { |
1714 | + $this->_fault('data_invalid',$e->getMessage()); |
1715 | + } |
1716 | + catch (Exception $e) |
1717 | + { |
1718 | + $this->_fault('data_invalid',$e->getMessage()); |
1719 | + } |
1720 | + return true; |
1721 | + } |
1722 | +} |
1723 | +?> |
1724 | |
1725 | === added file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcustomer/Group.php' |
1726 | --- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcustomer/Group.php 1970-01-01 00:00:00 +0000 |
1727 | +++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcustomer/Group.php 2012-08-10 13:28:19 +0000 |
1728 | @@ -0,0 +1,142 @@ |
1729 | +<?php |
1730 | + |
1731 | +/** |
1732 | + * @author Sharoon Thomas |
1733 | + * Inspired from Dieter's Magento Extender |
1734 | + * @copyright 2009 |
1735 | + */ |
1736 | + |
1737 | +class Openlabs_OpenERPConnector_Model_Olcustomer_Group extends Mage_Catalog_Model_Api_Resource |
1738 | +{ |
1739 | + public function items($filters=null) |
1740 | + { |
1741 | + try |
1742 | + { |
1743 | + $collection = Mage::getModel('customer/group')->getCollection();//->addAttributeToSelect('*'); |
1744 | + } |
1745 | + catch (Mage_Core_Exception $e) |
1746 | + { |
1747 | + $this->_fault('group_not_exists'); |
1748 | + } |
1749 | + |
1750 | + if (is_array($filters)) { |
1751 | + try { |
1752 | + foreach ($filters as $field => $value) { |
1753 | + $collection->addFieldToFilter($field, $value); |
1754 | + } |
1755 | + } catch (Mage_Core_Exception $e) { |
1756 | + $this->_fault('filters_invalid', $e->getMessage()); |
1757 | + // If we are adding filter on non-existent attribute |
1758 | + } |
1759 | + } |
1760 | + |
1761 | + $result = array(); |
1762 | + foreach ($collection as $customer) { |
1763 | + $result[] = $customer->toArray(); |
1764 | + } |
1765 | + |
1766 | + return $result; |
1767 | + } |
1768 | + |
1769 | + public function info($groupIds = null) |
1770 | + { |
1771 | + $groups = array(); |
1772 | + |
1773 | + if(is_array($groupIds)) |
1774 | + { |
1775 | + foreach($groupIds as $groupId) |
1776 | + { |
1777 | + try |
1778 | + { |
1779 | + $groups[] = Mage::getModel('customer/group')->load($groupId)->toArray(); |
1780 | + } |
1781 | + catch (Mage_Core_Exception $e) |
1782 | + { |
1783 | + $this->_fault('group_not_exists'); |
1784 | + } |
1785 | + } |
1786 | + return $groups; |
1787 | + } |
1788 | + elseif(is_numeric($groupIds)) |
1789 | + { |
1790 | + try |
1791 | + { |
1792 | + return Mage::getModel('customer/group')->load($groupIds)->toArray(); |
1793 | + } |
1794 | + catch (Mage_Core_Exception $e) |
1795 | + { |
1796 | + $this->_fault('group_not_exists'); |
1797 | + } |
1798 | + |
1799 | + } |
1800 | + |
1801 | + } |
1802 | + |
1803 | + public function create($groupdata) |
1804 | + { |
1805 | + try |
1806 | + { |
1807 | + $group = Mage::getModel('customer/group') |
1808 | + ->setData($groupdata) |
1809 | + ->save(); |
1810 | + |
1811 | + } |
1812 | + catch (Magento_Core_Exception $e) |
1813 | + { |
1814 | + $this->_fault('data_invalid',$e->getMessage()); |
1815 | + } |
1816 | + catch (Exception $e) |
1817 | + { |
1818 | + $this->_fault('data_invalid',$e->getMessage()); |
1819 | + } |
1820 | + return $group->getId(); |
1821 | + } |
1822 | + |
1823 | + public function update($groupid,$groupdata) |
1824 | + { |
1825 | + try |
1826 | + { |
1827 | + $group = Mage::getModel('customer/group') |
1828 | + ->load($groupid); |
1829 | + if (!$group->getId()) |
1830 | + { |
1831 | + $this->_fault('group_not_exists'); |
1832 | + } |
1833 | + $group->addData($groupdata)->save(); |
1834 | + } |
1835 | + catch (Magento_Core_Exception $e) |
1836 | + { |
1837 | + $this->_fault('data_invalid',$e->getMessage()); |
1838 | + } |
1839 | + catch (Exception $e) |
1840 | + { |
1841 | + $this->_fault('data_invalid',$e->getMessage()); |
1842 | + } |
1843 | + return true; |
1844 | + } |
1845 | + |
1846 | + public function delete($groupid) |
1847 | + { |
1848 | + try |
1849 | + { |
1850 | + $group = Mage::getModel('customer/group') |
1851 | + ->load($groupid); |
1852 | + if (!$group->getId()) |
1853 | + { |
1854 | + $this->_fault('group_not_exists'); |
1855 | + } |
1856 | + $group->delete(); |
1857 | + |
1858 | + } |
1859 | + catch (Magento_Core_Exception $e) |
1860 | + { |
1861 | + $this->_fault('data_invalid',$e->getMessage()); |
1862 | + } |
1863 | + catch (Exception $e) |
1864 | + { |
1865 | + $this->_fault('data_invalid',$e->getMessage()); |
1866 | + } |
1867 | + return true; |
1868 | + } |
1869 | +} |
1870 | +?> |
1871 | |
1872 | === added file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcustomer/Subscriber.php' |
1873 | --- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcustomer/Subscriber.php 1970-01-01 00:00:00 +0000 |
1874 | +++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcustomer/Subscriber.php 2012-08-10 13:28:19 +0000 |
1875 | @@ -0,0 +1,163 @@ |
1876 | +<?php |
1877 | +/** |
1878 | + * Magento |
1879 | + * |
1880 | + * NOTICE OF LICENSE |
1881 | + * |
1882 | + * This source file is subject to the Open Software License (OSL 3.0) |
1883 | + * that is bundled with this package in the file LICENSE.txt. |
1884 | + * It is also available through the world-wide-web at this URL: |
1885 | + * http://opensource.org/licenses/osl-3.0.php |
1886 | + * If you did not receive a copy of the license and are unable to |
1887 | + * obtain it through the world-wide-web, please send an email |
1888 | + * to license@magentocommerce.com so we can send you a copy immediately. |
1889 | + * |
1890 | + * DISCLAIMER |
1891 | + * |
1892 | + * Do not edit or add to this file if you wish to upgrade Magento to newer |
1893 | + * versions in the future. If you wish to customize Magento for your |
1894 | + * needs please refer to http://www.magentocommerce.com for more information. |
1895 | + * |
1896 | + * @category Mage |
1897 | + * @package Mage_Customer |
1898 | + * @copyright Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com) |
1899 | + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
1900 | + */ |
1901 | + |
1902 | +/** |
1903 | + * Customer address api |
1904 | + * |
1905 | + * @category Mage |
1906 | + * @package Mage_Customer |
1907 | + * @author Magento Core Team <core@magentocommerce.com> |
1908 | + */ |
1909 | +class Openlabs_OpenERPConnector_Model_Olcustomer_Subscriber extends Mage_Customer_Model_Api_Resource |
1910 | +{ |
1911 | + protected $_mapAttributes = array( |
1912 | + 'customer_id' => 'entity_id' |
1913 | + ); |
1914 | + |
1915 | + public function __construct() |
1916 | + { |
1917 | + $this->_ignoredAttributeCodes[] = 'parent_id'; |
1918 | + } |
1919 | + |
1920 | + /** |
1921 | + * Retrive subscriber list |
1922 | + * |
1923 | + * @param int $filters |
1924 | + * @return array |
1925 | + */ |
1926 | + public function items($filters=null) |
1927 | + { |
1928 | + $collection = Mage::getModel('customer/customer')->getCollection() |
1929 | + ->addAttributeToSelect('*'); |
1930 | + |
1931 | + |
1932 | + if (is_array($filters)) { |
1933 | + try { |
1934 | + foreach ($filters as $field => $value) { |
1935 | + $collection->addFieldToFilter($field, $value); |
1936 | + } |
1937 | + } catch (Mage_Core_Exception $e) { |
1938 | + $this->_fault('filters_invalid', $e->getMessage()); |
1939 | + // If we are adding filter on non-existent attribute |
1940 | + } |
1941 | + } |
1942 | + |
1943 | + $result = array(); |
1944 | + |
1945 | + foreach ($collection as $customer) { |
1946 | + $subscriber = Mage::getModel('newsletter/subscriber')->loadByEmail($customer['email']); |
1947 | + if($subscriber->getId()) |
1948 | + $result[] = $subscriber->getId(); |
1949 | + } |
1950 | + |
1951 | + return $result; |
1952 | + } |
1953 | + |
1954 | + /** |
1955 | + * Create new address for customer |
1956 | + * |
1957 | + * @param int $customerId |
1958 | + * @param array $email |
1959 | + * @return int |
1960 | + */ |
1961 | + public function create($customerId,$email) |
1962 | + { |
1963 | + if($customerId && $email): |
1964 | + $customer = Mage::getModel("newsletter/subscriber"); |
1965 | + |
1966 | + $customer->setCustomerId($customerId); |
1967 | + $customer->setEmail($email); |
1968 | + $customer->subscriber_status = "1"; |
1969 | + |
1970 | + $customer->save(); |
1971 | + |
1972 | + return $customer->getId(); |
1973 | + else: |
1974 | + return False; |
1975 | + endif; |
1976 | + } |
1977 | + |
1978 | + /** |
1979 | + * Retrieve subscriber data |
1980 | + * |
1981 | + * @param int $subscriberId |
1982 | + * @return array |
1983 | + */ |
1984 | + public function info($subscriberId) |
1985 | + { |
1986 | + $subscriber = Mage::getModel('newsletter/subscriber')->load($subscriberId); |
1987 | + |
1988 | + if($subscriber->getId()): |
1989 | + $result[] = $subscriber->toArray(); |
1990 | + endif; |
1991 | + |
1992 | + return $result; |
1993 | + } |
1994 | + |
1995 | + /** |
1996 | + * Update subscriber data (subscriber) |
1997 | + * |
1998 | + * @param $email |
1999 | + * @return boolean |
2000 | + */ |
2001 | + public function update($email) |
2002 | + { |
2003 | + if($email): |
2004 | + $subscriber = Mage::getModel('newsletter/subscriber')->loadByEmail($email); |
2005 | + |
2006 | + if($subscriber->getId()): |
2007 | + $customer = Mage::getModel("newsletter/subscriber")->load($subscriber->getId()); |
2008 | + $customer->subscriber_status = "1"; |
2009 | + $customer->save(); |
2010 | + endif; |
2011 | + |
2012 | + return $subscriber->getId(); |
2013 | + else: |
2014 | + return False; |
2015 | + endif; |
2016 | + } |
2017 | + |
2018 | + /** |
2019 | + * Delete subscriber (unsubscriber) |
2020 | + * |
2021 | + * @param $email |
2022 | + * @return boolean |
2023 | + */ |
2024 | + public function delete($email) |
2025 | + { |
2026 | + if($email): |
2027 | + $subscriber = Mage::getModel('newsletter/subscriber')->loadByEmail($email); |
2028 | + |
2029 | + if($subscriber->getId()): |
2030 | + Mage::getModel('newsletter/subscriber')->load($subscriber->getId())->unsubscribe(); |
2031 | + endif; |
2032 | + |
2033 | + return $subscriber->getId(); |
2034 | + else: |
2035 | + return False; |
2036 | + endif; |
2037 | + } |
2038 | +} // Class Mage_Customer_Model_Address_Api End |
2039 | |
2040 | === added directory 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/etc' |
2041 | === added file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/etc/api.xml' |
2042 | --- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/etc/api.xml 1970-01-01 00:00:00 +0000 |
2043 | +++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/etc/api.xml 2012-08-10 13:28:19 +0000 |
2044 | @@ -0,0 +1,493 @@ |
2045 | + |
2046 | +<config> |
2047 | + <api> |
2048 | + <resources> |
2049 | + <ol_websites translate="title" module="core"> |
2050 | + <title>Website Management</title> |
2051 | + <model>openerpconnector/olcore_website</model> |
2052 | + <acl>core/store</acl> |
2053 | + <methods> |
2054 | + <list translate="title" module="core"> |
2055 | + <title>Enumerate websites</title> |
2056 | + <method>items</method> |
2057 | + </list> |
2058 | + <create translate="title" module="core"> |
2059 | + <title>Create Websites</title> |
2060 | + <!--Parameters are code,name,is_default,sort_order,default_group_id,group_ids--> |
2061 | + <method>create</method> |
2062 | + </create> |
2063 | + <info translate="title" module="core"> |
2064 | + <title>Fetch detail of websites</title> |
2065 | + <method>info</method> |
2066 | + </info> |
2067 | + <update translate="title" module="core"> |
2068 | + <title>Update websites info</title> |
2069 | + <method>update</method> |
2070 | + </update> |
2071 | + <delete translate="title" module="core"> |
2072 | + <title>Delete websites</title> |
2073 | + <method>delete</method> |
2074 | + </delete> |
2075 | + </methods> |
2076 | + <faults module="core"> |
2077 | + <website_not_exists> |
2078 | + <code>101</code> |
2079 | + <message>Requested website not found.</message> |
2080 | + </website_not_exists> |
2081 | + <data_invalid> |
2082 | + <code>102</code> |
2083 | + <message>Website creation failed due to invalid data.</message> |
2084 | + </data_invalid> |
2085 | + </faults> |
2086 | + </ol_websites> |
2087 | + <ol_groups translate="title" module="core"> |
2088 | + <title>Groups Management</title> |
2089 | + <model>openerpconnector/olcore_groups</model> |
2090 | + <acl>core/store</acl> |
2091 | + <methods> |
2092 | + <list translate="title" module="core"> |
2093 | + <title>Enumerate groups</title> |
2094 | + <method>items</method> |
2095 | + </list> |
2096 | + <create translate="title" module="core"> |
2097 | + <title>Create groups</title> |
2098 | + <!--Parameters are code,name,is_default,sort_order,default_group_id,group_ids--> |
2099 | + <method>create</method> |
2100 | + </create> |
2101 | + <info translate="title" module="core"> |
2102 | + <title>Fetch detail of groups</title> |
2103 | + <method>info</method> |
2104 | + </info> |
2105 | + <update translate="title" module="core"> |
2106 | + <title>Update groups info</title> |
2107 | + <method>update</method> |
2108 | + </update> |
2109 | + <delete translate="title" module="core"> |
2110 | + <title>Delete groups</title> |
2111 | + <method>delete</method> |
2112 | + </delete> |
2113 | + </methods> |
2114 | + <faults module="core"> |
2115 | + <group_not_exists> |
2116 | + <code>101</code> |
2117 | + <message>Requested group not found.</message> |
2118 | + </group_not_exists> |
2119 | + <data_invalid> |
2120 | + <code>102</code> |
2121 | + <message>group creation failed due to invalid data.</message> |
2122 | + </data_invalid> |
2123 | + <filters_invalid> |
2124 | + <code>103</code> |
2125 | + <message>Invalid data fetch filter.</message> |
2126 | + </filters_invalid> |
2127 | + </faults> |
2128 | + </ol_groups> |
2129 | + <ol_storeviews translate="title" module="core"> |
2130 | + <title>Stores Management</title> |
2131 | + <model>openerpconnector/olcore_storeviews</model> |
2132 | + <acl>core/store</acl> |
2133 | + <methods> |
2134 | + <list translate="title" module="core"> |
2135 | + <title>Enumerate stores</title> |
2136 | + <method>items</method> |
2137 | + </list> |
2138 | + <create translate="title" module="core"> |
2139 | + <title>Create stores</title> |
2140 | + <!--Parameters are code,name,is_default,sort_order,default_group_id,group_ids--> |
2141 | + <method>create</method> |
2142 | + </create> |
2143 | + <info translate="title" module="core"> |
2144 | + <title>Fetch detail of stores</title> |
2145 | + <method>info</method> |
2146 | + </info> |
2147 | + <update translate="title" module="core"> |
2148 | + <title>Update stores info</title> |
2149 | + <method>update</method> |
2150 | + </update> |
2151 | + <delete translate="title" module="core"> |
2152 | + <title>Delete stores</title> |
2153 | + <method>delete</method> |
2154 | + </delete> |
2155 | + </methods> |
2156 | + <faults module="core"> |
2157 | + <store_not_exists> |
2158 | + <code>101</code> |
2159 | + <message>Requested store not found.</message> |
2160 | + </store_not_exists> |
2161 | + <data_invalid> |
2162 | + <code>102</code> |
2163 | + <message>Store creation failed due to invalid data.</message> |
2164 | + </data_invalid> |
2165 | + <filters_invalid> |
2166 | + <code>103</code> |
2167 | + <message>Invalid data fetch filter.</message> |
2168 | + </filters_invalid> |
2169 | + </faults> |
2170 | + </ol_storeviews> |
2171 | + <ol_catalog_category_media translate="title" module="catalog"> |
2172 | + <title>Product Images API</title> |
2173 | + <model>openerpconnector/olcatalog_categories</model> |
2174 | + <acl>catalog/category</acl> |
2175 | + <methods> |
2176 | + <list translate="title" module="catalog"> |
2177 | + <title>Retrieve product image list</title> |
2178 | + <method>items</method> |
2179 | + </list> |
2180 | + <info translate="title" module="catalog"> |
2181 | + <title>Retrieve product category image</title> |
2182 | + </info> |
2183 | + <types translate="title" module="catalog"> |
2184 | + <title>Retrieve product category image types</title> |
2185 | + </types> |
2186 | + <create translate="title" module="catalog"> |
2187 | + <title>Upload new product category image </title> |
2188 | + <acl>catalog/product/media/create</acl> |
2189 | + </create> |
2190 | + <update translate="title" module="catalog"> |
2191 | + <title>Update product category image</title> |
2192 | + <acl>catalog/product/media/update</acl> |
2193 | + </update> |
2194 | + <remove translate="title" module="catalog"> |
2195 | + <title>Remove product category image</title> |
2196 | + <acl>catalog/product/media/remove</acl> |
2197 | + </remove> |
2198 | + </methods> |
2199 | + <faults module="catalog"> |
2200 | + <create_failure> |
2201 | + <code>100</code> |
2202 | + <message>Could not create file, check permissions.</message> |
2203 | + </create_failure> |
2204 | + <category_not_exists> |
2205 | + <code>101</code> |
2206 | + <message>Product not exists.</message> |
2207 | + </category_not_exists> |
2208 | + <data_invalid> |
2209 | + <code>102</code> |
2210 | + <message>Invalid data given. Details in error message.</message> |
2211 | + </data_invalid> |
2212 | + <not_exists> |
2213 | + <code>103</code> |
2214 | + <message>Requested image not exists in product images' gallery.</message> |
2215 | + </not_exists> |
2216 | + <not_created> |
2217 | + <code>104</code> |
2218 | + <message>Image creation failed. Details in error message.</message> |
2219 | + </not_created> |
2220 | + <not_updated> |
2221 | + <code>105</code> |
2222 | + <message>Image not updated. Details in error message.</message> |
2223 | + </not_updated> |
2224 | + <not_removed> |
2225 | + <code>106</code> |
2226 | + <message>Image not removed. Details in error message.</message> |
2227 | + </not_removed> |
2228 | + <not_media> |
2229 | + <code>107</code> |
2230 | + <message>Error in opening image file</message> |
2231 | + </not_media> |
2232 | + <filters_invalid> |
2233 | + <code>108</code> |
2234 | + <message>Invalid data fetch filter.</message> |
2235 | + </filters_invalid> |
2236 | + </faults> |
2237 | + </ol_catalog_category_media> |
2238 | + <ol_catalog_product_attribute translate="title" module="catalog"> |
2239 | + <title>Product Images API</title> |
2240 | + <model>openerpconnector/olcatalog_product_attribute</model> |
2241 | + <acl>catalog/category</acl> |
2242 | + <methods> |
2243 | + <list translate="title" module="catalog"> |
2244 | + <title>Retrieve attribute list</title> |
2245 | + <method>items</method> |
2246 | + </list> |
2247 | + <relations translate="title" module="catalog"> |
2248 | + <title>Retrieve attribute sets attribute ids</title> |
2249 | + <method>relations</method> |
2250 | + </relations> |
2251 | + <info translate="title" module="catalog"> |
2252 | + <title>Retrieve full attribute details</title> |
2253 | + <method>info</method> |
2254 | + </info> |
2255 | + <options translate="title" module="catalog"> |
2256 | + <title>Retrieve options of attributes</title> |
2257 | + <method>options</method> |
2258 | + </options> |
2259 | + </methods> |
2260 | + <faults> |
2261 | + </faults> |
2262 | + </ol_catalog_product_attribute> |
2263 | + <ol_catalog_product_attribute_group translate="title" module="catalog"> |
2264 | + <title>Product Images API</title> |
2265 | + <model>openerpconnector/olcatalog_product_attributegroup</model> |
2266 | + <acl>catalog/category</acl> |
2267 | + <methods> |
2268 | + <list translate="title" module="catalog"> |
2269 | + <title>Retrieve attribute group list</title> |
2270 | + <method>items</method> |
2271 | + </list> |
2272 | + <info translate="title" module="catalog"> |
2273 | + <title>Retrieve full attribute details</title> |
2274 | + <method>info</method> |
2275 | + </info> |
2276 | + </methods> |
2277 | + <faults> |
2278 | + </faults> |
2279 | + </ol_catalog_product_attribute_group> |
2280 | + <ol_customer_groups translate="title" module="core"> |
2281 | + <title>Groups Management</title> |
2282 | + <model>openerpconnector/olcustomer_group</model> |
2283 | + <acl>customer/group</acl> |
2284 | + <methods> |
2285 | + <list translate="title" module="core"> |
2286 | + <title>Enumerate groups</title> |
2287 | + <method>items</method> |
2288 | + </list> |
2289 | + <create translate="title" module="core"> |
2290 | + <title>Create groups</title> |
2291 | + <method>create</method> |
2292 | + </create> |
2293 | + <info translate="title" module="core"> |
2294 | + <title>Fetch detail of groups</title> |
2295 | + <method>info</method> |
2296 | + </info> |
2297 | + <update translate="title" module="core"> |
2298 | + <title>Update groups info</title> |
2299 | + <method>update</method> |
2300 | + </update> |
2301 | + <delete translate="title" module="core"> |
2302 | + <title>Delete groups</title> |
2303 | + <method>delete</method> |
2304 | + </delete> |
2305 | + </methods> |
2306 | + <faults module="core"> |
2307 | + <group_not_exists> |
2308 | + <code>101</code> |
2309 | + <message>Requested group not found.</message> |
2310 | + </group_not_exists> |
2311 | + <data_invalid> |
2312 | + <code>102</code> |
2313 | + <message>group creation failed due to invalid data.</message> |
2314 | + </data_invalid> |
2315 | + <filters_invalid> |
2316 | + <code>103</code> |
2317 | + <message>Invalid data fetch filter.</message> |
2318 | + </filters_invalid> |
2319 | + </faults> |
2320 | + </ol_customer_groups> |
2321 | + <ol_customer_address translate="title" module="core"> |
2322 | + <title>Address Management</title> |
2323 | + <model>openerpconnector/olcustomer_address</model> |
2324 | + <acl>customer/group</acl> |
2325 | + <methods> |
2326 | + <list translate="title" module="core"> |
2327 | + <title>Enumerate groups</title> |
2328 | + <method>items</method> |
2329 | + </list> |
2330 | + <create translate="title" module="core"> |
2331 | + <title>Create groups</title> |
2332 | + <method>create</method> |
2333 | + </create> |
2334 | + <info translate="title" module="core"> |
2335 | + <title>Fetch detail of groups</title> |
2336 | + <method>info</method> |
2337 | + </info> |
2338 | + <update translate="title" module="core"> |
2339 | + <title>Update groups info</title> |
2340 | + <method>update</method> |
2341 | + </update> |
2342 | + <delete translate="title" module="core"> |
2343 | + <title>Delete groups</title> |
2344 | + <method>delete</method> |
2345 | + </delete> |
2346 | + </methods> |
2347 | + <faults module="core"> |
2348 | + <customer_not_exists> |
2349 | + <code>101</code> |
2350 | + <message>Requested Customer not found.</message> |
2351 | + </customer_not_exists> |
2352 | + <data_invalid> |
2353 | + <code>102</code> |
2354 | + <message>group creation failed due to invalid data.</message> |
2355 | + </data_invalid> |
2356 | + <filters_invalid> |
2357 | + <code>103</code> |
2358 | + <message>Invalid data fetch filter.</message> |
2359 | + </filters_invalid> |
2360 | + </faults> |
2361 | + </ol_customer_address> |
2362 | + <ol_customer_subscriber translate="title" module="core"> |
2363 | + <title>Subscriber Management</title> |
2364 | + <model>openerpconnector/olcustomer_subscriber</model> |
2365 | + <acl>customer/group</acl> |
2366 | + <methods> |
2367 | + <list translate="title" module="core"> |
2368 | + <title>Enumerate subscriber</title> |
2369 | + <method>items</method> |
2370 | + </list> |
2371 | + <create translate="title" module="core"> |
2372 | + <title>Create subscriber</title> |
2373 | + <method>create</method> |
2374 | + </create> |
2375 | + <info translate="title" module="core"> |
2376 | + <title>Fetch detail of subscriber</title> |
2377 | + <method>info</method> |
2378 | + </info> |
2379 | + <update translate="title" module="core"> |
2380 | + <title>Update subscriber info</title> |
2381 | + <method>update</method> |
2382 | + </update> |
2383 | + <delete translate="title" module="core"> |
2384 | + <title>Delete subscriber</title> |
2385 | + <method>delete</method> |
2386 | + </delete> |
2387 | + </methods> |
2388 | + <faults module="core"> |
2389 | + <customer_not_exists> |
2390 | + <code>101</code> |
2391 | + <message>Requested Customer not found.</message> |
2392 | + </customer_not_exists> |
2393 | + <data_invalid> |
2394 | + <code>102</code> |
2395 | + <message>group creation failed due to invalid data.</message> |
2396 | + </data_invalid> |
2397 | + <filters_invalid> |
2398 | + <code>103</code> |
2399 | + <message>Invalid data fetch filter.</message> |
2400 | + </filters_invalid> |
2401 | + </faults> |
2402 | + </ol_customer_subscriber> |
2403 | + <ol_customer translate="title" module="core"> |
2404 | + <title>Customers Management</title> |
2405 | + <model>openerpconnector/olcustomer_customer</model> |
2406 | + <acl>customer/group</acl> |
2407 | + <methods> |
2408 | + <list translate="title" module="core"> |
2409 | + <title>Enumerate Customers</title> |
2410 | + <method>items</method> |
2411 | + </list> |
2412 | + <create translate="title" module="core"> |
2413 | + <title>Create Customers</title> |
2414 | + <method>create</method> |
2415 | + </create> |
2416 | + <info translate="title" module="core"> |
2417 | + <title>Fetch detail of customers</title> |
2418 | + <method>info</method> |
2419 | + </info> |
2420 | + <update translate="title" module="core"> |
2421 | + <title>Update customers info</title> |
2422 | + <method>update</method> |
2423 | + </update> |
2424 | + <delete translate="title" module="core"> |
2425 | + <title>Delete customers</title> |
2426 | + <method>delete</method> |
2427 | + </delete> |
2428 | + </methods> |
2429 | + <faults module="core"> |
2430 | + <customer_not_exists> |
2431 | + <code>101</code> |
2432 | + <message>Requested customer not found.</message> |
2433 | + </customer_not_exists> |
2434 | + <data_invalid> |
2435 | + <code>102</code> |
2436 | + <message>Customer creation failed due to invalid data.</message> |
2437 | + </data_invalid> |
2438 | + <filters_invalid> |
2439 | + <code>103</code> |
2440 | + <message>Invalid data fetch filter.</message> |
2441 | + </filters_invalid> |
2442 | + </faults> |
2443 | + </ol_customer> |
2444 | + <ol_catalog_product_tierprice translate="title" module="catalog"> |
2445 | + <title>Product Tier Price API</title> |
2446 | + <model>openerpconnector/olcatalog_product_tierprice</model> |
2447 | + <acl>catalog/category</acl> |
2448 | + <methods> |
2449 | + <list translate="title" module="catalog"> |
2450 | + <title>Retrieve attribute list</title> |
2451 | + <method>items</method> |
2452 | + </list> |
2453 | + <items2 translate="title" module="catalog"> |
2454 | + <title>Retrieve attribute list</title> |
2455 | + <method>items2</method> |
2456 | + </items2> |
2457 | + </methods> |
2458 | + <faults> |
2459 | + <product_not_exists> |
2460 | + <code>101</code> |
2461 | + <message>Requested product not found.</message> |
2462 | + </product_not_exists> |
2463 | + <filters_invalid> |
2464 | + <code>103</code> |
2465 | + <message>Invalid data fetch filter.</message> |
2466 | + </filters_invalid> |
2467 | + </faults> |
2468 | + </ol_catalog_product_tierprice> |
2469 | + <ol_catalog_product translate="title" module="core"> |
2470 | + <title>Address Management</title> |
2471 | + <model>openerpconnector/olcatalog_products</model> |
2472 | + <acl>catalog/product</acl> |
2473 | + <methods> |
2474 | + <list translate="title" module="core"> |
2475 | + <title>Enumerate Products</title> |
2476 | + <method>items</method> |
2477 | + </list> |
2478 | + <create translate="title" module="core"> |
2479 | + <title>Create Products</title> |
2480 | + <method>create</method> |
2481 | + </create> |
2482 | + <biglist translate="title" module="core"> |
2483 | + <title>Fetch detail of products</title> |
2484 | + <method>biglist</method> |
2485 | + </biglist> |
2486 | + <update translate="title" module="core"> |
2487 | + <title>Update groups info</title> |
2488 | + <method>update</method> |
2489 | + </update> |
2490 | + <delete translate="title" module="core"> |
2491 | + <title>Delete groups</title> |
2492 | + <method>delete</method> |
2493 | + </delete> |
2494 | + </methods> |
2495 | + <faults module="core"> |
2496 | + <customer_not_exists> |
2497 | + <code>101</code> |
2498 | + <message>Requested Customer not found.</message> |
2499 | + </customer_not_exists> |
2500 | + <data_invalid> |
2501 | + <code>102</code> |
2502 | + <message>group creation failed due to invalid data.</message> |
2503 | + </data_invalid> |
2504 | + <filters_invalid> |
2505 | + <code>103</code> |
2506 | + <message>Invalid data fetch filter.</message> |
2507 | + </filters_invalid> |
2508 | + </faults> |
2509 | + </ol_catalog_product> |
2510 | + <ol_catalog_product_attributeset translate="title" module="core"> |
2511 | + <title>Attribute Set Management</title> |
2512 | + <model>openerpconnector/olcatalog_product_attributeset</model> |
2513 | + <acl>catalog/product</acl> |
2514 | + <methods> |
2515 | + <list translate="title" module="core"> |
2516 | + <title>Enumerate Attribute sets</title> |
2517 | + <method>items</method> |
2518 | + </list> |
2519 | + </methods> |
2520 | + <faults module="core"> |
2521 | + <customer_not_exists> |
2522 | + <code>101</code> |
2523 | + <message>Requested Customer not found.</message> |
2524 | + </customer_not_exists> |
2525 | + <data_invalid> |
2526 | + <code>102</code> |
2527 | + <message>group creation failed due to invalid data.</message> |
2528 | + </data_invalid> |
2529 | + <filters_invalid> |
2530 | + <code>103</code> |
2531 | + <message>Invalid data fetch filter.</message> |
2532 | + </filters_invalid> |
2533 | + </faults> |
2534 | + </ol_catalog_product_attributeset> |
2535 | + </resources> |
2536 | + </api> |
2537 | +</config> |
2538 | |
2539 | === added file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/etc/config.xml' |
2540 | --- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/etc/config.xml 1970-01-01 00:00:00 +0000 |
2541 | +++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/etc/config.xml 2012-08-10 13:28:19 +0000 |
2542 | @@ -0,0 +1,45 @@ |
2543 | +<?xml version="1.0"?> |
2544 | +<config> |
2545 | + <!--<modules> |
2546 | + <Openlabs_OpenERPConnector> |
2547 | + <version>0.0.1</version> |
2548 | + </Openlabs_OpenERPConnector> |
2549 | + </modules>--> |
2550 | + <global> |
2551 | + <models> |
2552 | + <openerpconnector> |
2553 | + <class>Openlabs_OpenERPConnector_Model</class> |
2554 | + </openerpconnector> |
2555 | + </models> |
2556 | + <resources> |
2557 | + <openerpconnector_setup> |
2558 | + <setup> |
2559 | + <module>Openlabs_OpenERPConnector</module> |
2560 | + </setup> |
2561 | + <connection> |
2562 | + <use>core_setup</use> |
2563 | + </connection> |
2564 | + </openerpconnector_setup> |
2565 | + <openerpconnector_write> |
2566 | + <connection> |
2567 | + <use>core_write</use> |
2568 | + </connection> |
2569 | + </openerpconnector_write> |
2570 | + <openerpconnector_read> |
2571 | + <connection> |
2572 | + <use>core_read</use> |
2573 | + </connection> |
2574 | + </openerpconnector_read> |
2575 | + </resources> |
2576 | + <blocks> |
2577 | + <openerpconnector> |
2578 | + <class>Openlabs_OpenERPConnector_Block</class> |
2579 | + </openerpconnector> |
2580 | + </blocks> |
2581 | + <helpers> |
2582 | + <openerpconnector> |
2583 | + <class>Openlabs_OpenERPConnector_Helper</class> |
2584 | + </openerpconnector> |
2585 | + </helpers> |
2586 | + </global> |
2587 | +</config> |
2588 | \ No newline at end of file |
2589 | |
2590 | === added directory 'Openlabs_OpenERPConnector-1.1.0/app' |
2591 | === added directory 'Openlabs_OpenERPConnector-1.1.0/app/etc' |
2592 | === added directory 'Openlabs_OpenERPConnector-1.1.0/app/etc/modules' |
2593 | === added file 'Openlabs_OpenERPConnector-1.1.0/app/etc/modules/Openlabs_OpenERPConnector.xml' |
2594 | --- Openlabs_OpenERPConnector-1.1.0/app/etc/modules/Openlabs_OpenERPConnector.xml 1970-01-01 00:00:00 +0000 |
2595 | +++ Openlabs_OpenERPConnector-1.1.0/app/etc/modules/Openlabs_OpenERPConnector.xml 2012-08-10 13:28:19 +0000 |
2596 | @@ -0,0 +1,41 @@ |
2597 | +<?xml version="1.0"?> |
2598 | + |
2599 | +<!-- |
2600 | +############################################################################## |
2601 | +# |
2602 | +# OpenERP, Open Source Management Solution |
2603 | +# Copyright (C) 2004-2008 Tiny SPRL (<http://tiny.be>). All Rights Reserved |
2604 | +# Sharoon Thomas |
2605 | +# |
2606 | +# This program is free software: you can redistribute it and/or modify |
2607 | +# it under the terms of the GNU General Public License as published by |
2608 | +# the Free Software Foundation, either version 3 of the License, or |
2609 | +# (at your option) any later version. |
2610 | +# |
2611 | +# This program is distributed in the hope that it will be useful, |
2612 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
2613 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2614 | +# GNU General Public License for more details. |
2615 | +# |
2616 | +# You should have received a copy of the GNU General Public License |
2617 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
2618 | +# |
2619 | +############################################################################## |
2620 | +# * @category Community |
2621 | +# * @package |
2622 | +# * @copyright Copyright (c) 2009 Sharoon Thomas, openlabs.co.in |
2623 | +# * @license GPL-3 |
2624 | +# */ |
2625 | +--> |
2626 | +<config> |
2627 | + <modules> |
2628 | + <Openlabs_OpenERPConnector> |
2629 | + <codePool>community</codePool> |
2630 | + <active>true</active> |
2631 | + <depends> |
2632 | + <Mage_Api /> |
2633 | + <Mage_Catalog /> |
2634 | + </depends> |
2635 | + </Openlabs_OpenERPConnector> |
2636 | + </modules> |
2637 | +</config> |
2638 | |
2639 | === added directory 'Savoirfairelinux_Claim' |
2640 | === added directory 'Savoirfairelinux_Claim/app' |
2641 | === added directory 'Savoirfairelinux_Claim/app/code' |
2642 | === added directory 'Savoirfairelinux_Claim/app/code/local' |
2643 | === added directory 'Savoirfairelinux_Claim/app/code/local/Savoirfairelinux' |
2644 | === added directory 'Savoirfairelinux_Claim/app/code/local/Savoirfairelinux/Claim' |
2645 | === added directory 'Savoirfairelinux_Claim/app/code/local/Savoirfairelinux/Claim/Block' |
2646 | === added file 'Savoirfairelinux_Claim/app/code/local/Savoirfairelinux/Claim/Block/Form.php' |
2647 | --- Savoirfairelinux_Claim/app/code/local/Savoirfairelinux/Claim/Block/Form.php 1970-01-01 00:00:00 +0000 |
2648 | +++ Savoirfairelinux_Claim/app/code/local/Savoirfairelinux/Claim/Block/Form.php 2012-08-10 13:28:19 +0000 |
2649 | @@ -0,0 +1,160 @@ |
2650 | +<?php |
2651 | +/** |
2652 | + * Magento |
2653 | + * |
2654 | + * NOTICE OF LICENSE |
2655 | + * |
2656 | + * Savoirfairelinux_Claim |
2657 | + * Copyright (C) 2012 Savoir-faire Linux |
2658 | + * |
2659 | + * This program is free software: you can redistribute it and/or modify |
2660 | + * it under the terms of the GNU General Public License as published by |
2661 | + * the Free Software Foundation, either version 3 of the License, or |
2662 | + * (at your option) any later version. |
2663 | + * |
2664 | + * This program is distributed in the hope that it will be useful, |
2665 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2666 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2667 | + * GNU General Public License for more details. |
2668 | + * |
2669 | + * You should have received a copy of the GNU General Public License |
2670 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2671 | + * |
2672 | + * DISCLAIMER |
2673 | + * |
2674 | + * Do not edit or add to this file if you wish to upgrade Magento to newer |
2675 | + * versions in the future. If you wish to customize Magento for your |
2676 | + * needs please refer to http://www.magentocommerce.com for more information. |
2677 | + * |
2678 | + * @category Savoirfairelinux |
2679 | + * @package Savoirfairelinux_Claim |
2680 | + * @copyright Copyright (c) 2012 Savoir-faire Linux. (http://www.savoirfairelinux.com) |
2681 | + * @license http://www.gnu.org/licenses/gpl.html General Public License (GPLv3) |
2682 | + */ |
2683 | + |
2684 | +/** |
2685 | + * Customer Complains block |
2686 | + * |
2687 | + * @category Savoirfairelinux |
2688 | + * @package Savoirfairelinux_Claim |
2689 | + * @author Joao Alfredo Gama Batista <joao.gama@savoirfairelinux.com> |
2690 | + */ |
2691 | +class Savoirfairelinux_Claim_Block_Form extends Mage_Customer_Block_Account_Dashboard |
2692 | +{ |
2693 | + |
2694 | + protected $_collection; |
2695 | + |
2696 | + const XML_PATH_ENABLED = 'claim/claim/enabled'; |
2697 | + const XML_PATH_OPENERP_URL = 'claim/settings/openerp_url'; |
2698 | + const XML_PATH_OPENERP_LOGIN = 'claim/settings/openerp_login'; |
2699 | + const XML_PATH_OPENERP_PASSWORD = 'claim/settings/openerp_password'; |
2700 | + const XML_PATH_OPENERP_DATABASE = 'claim/settings/openerp_database'; |
2701 | + const XML_PATH_OPENERP_CLAIM_REF = 'claim/settings/openerp_claim_ref'; |
2702 | + const XML_PATH_OPENERP_CLAIM_REF_PREFIX = 'claim/settings/openerp_claim_ref_prefix'; |
2703 | + |
2704 | + /* protected function _construct() */ |
2705 | + /* { */ |
2706 | + /* /\* $this->_collection = Mage::getModel('review/review')->getProductCollection(); *\/ */ |
2707 | + /* /\* $this->_collection *\/ */ |
2708 | + /* /\* ->addStoreFilter(Mage::app()->getStore()->getId()) *\/ */ |
2709 | + /* /\* ->addCustomerFilter(Mage::getSingleton('customer/session')->getCustomerId()) *\/ */ |
2710 | + /* /\* ->setDateOrder(); *\/ */ |
2711 | + |
2712 | + /* $this->partner_name = Mage::helper('contacts')->getUserName(); */ |
2713 | + /* $this->partner_email = Mage::helper('contacts')->getUserEmail(); */ |
2714 | + |
2715 | + /* $this->openerp = new Savoirfairelinux_Claim_Openerpclient */ |
2716 | + /* (Mage::getStoreConfig(self::XML_PATH_OPENERP_LOGIN), */ |
2717 | + /* Mage::helper('core')->decrypt(Mage::getStoreConfig(self::XML_PATH_OPENERP_PASSWORD)), */ |
2718 | + /* Mage::getStoreConfig(self::XML_PATH_OPENERP_DATABASE), */ |
2719 | + /* Mage::getStoreConfig(self::XML_PATH_OPENERP_URL), */ |
2720 | + /* Mage::getStoreConfig(self::XML_PATH_OPENERP_CLAIM_REF), */ |
2721 | + /* Mage::getStoreConfig(self::XML_PATH_OPENERP_CLAIM_REF_PREFIX) */ |
2722 | + /* ); */ |
2723 | + /* parent::__construct(); */ |
2724 | + |
2725 | + /* } */ |
2726 | + |
2727 | + public function isPartner() |
2728 | + { |
2729 | + $this->partner_name = Mage::helper('contacts')->getUserName(); |
2730 | + $this->partner_email = Mage::helper('contacts')->getUserEmail(); |
2731 | + |
2732 | + if( $this->openerp->isPartner($this->partner_name, $this->partner_email) ) |
2733 | + return True; |
2734 | + else |
2735 | + return False; |
2736 | + |
2737 | + } |
2738 | + |
2739 | + public function isConnected() |
2740 | + { |
2741 | + try { |
2742 | + $this->openerp = new Savoirfairelinux_Claim_Openerpclient |
2743 | + (Mage::getStoreConfig(self::XML_PATH_OPENERP_LOGIN), |
2744 | + Mage::helper('core')->decrypt(Mage::getStoreConfig(self::XML_PATH_OPENERP_PASSWORD)), |
2745 | + Mage::getStoreConfig(self::XML_PATH_OPENERP_DATABASE), |
2746 | + Mage::getStoreConfig(self::XML_PATH_OPENERP_URL), |
2747 | + Mage::getStoreConfig(self::XML_PATH_OPENERP_CLAIM_REF), |
2748 | + Mage::getStoreConfig(self::XML_PATH_OPENERP_CLAIM_REF_PREFIX)); |
2749 | + |
2750 | + } catch (Exception $e) { |
2751 | + return False; |
2752 | + } |
2753 | + |
2754 | + return True; |
2755 | + } |
2756 | + |
2757 | + public function count() |
2758 | + { |
2759 | + return $this->_collection->getSize(); |
2760 | + } |
2761 | + |
2762 | + public function getToolbarHtml() |
2763 | + { |
2764 | + return $this->getChildHtml('toolbar'); |
2765 | + } |
2766 | + |
2767 | + /* protected function _prepareLayout() */ |
2768 | + /* { */ |
2769 | + /* $toolbar = $this->getLayout()->createBlock('page/html_pager', 'customer_review_list.toolbar') */ |
2770 | + /* ->setCollection($this->_getCollection()); */ |
2771 | + |
2772 | + /* $this->setChild('toolbar', $toolbar); */ |
2773 | + /* return parent::_prepareLayout(); */ |
2774 | + /* } */ |
2775 | + |
2776 | + protected function _getCollection() |
2777 | + { |
2778 | + return $this->_collection; |
2779 | + } |
2780 | + |
2781 | + public function getCollection() |
2782 | + { |
2783 | + return $this->_getCollection(); |
2784 | + } |
2785 | + |
2786 | + public function getReviewLink() |
2787 | + { |
2788 | + return Mage::getUrl('review/customer/view/'); |
2789 | + } |
2790 | + |
2791 | + public function getProductLink() |
2792 | + { |
2793 | + return Mage::getUrl('catalog/product/view/'); |
2794 | + } |
2795 | + |
2796 | + public function dateFormat($date) |
2797 | + { |
2798 | + return $this->formatDate($date, Mage_Core_Model_Locale::FORMAT_TYPE_SHORT); |
2799 | + } |
2800 | + |
2801 | + /* protected function _beforeToHtml() */ |
2802 | + /* { */ |
2803 | + /* $this->_getCollection() */ |
2804 | + /* ->load() */ |
2805 | + /* ->addReviewSummary(); */ |
2806 | + /* return parent::_beforeToHtml(); */ |
2807 | + /* } */ |
2808 | + |
2809 | +} |
2810 | |
2811 | === added directory 'Savoirfairelinux_Claim/app/code/local/Savoirfairelinux/Claim/Helper' |
2812 | === added file 'Savoirfairelinux_Claim/app/code/local/Savoirfairelinux/Claim/Helper/Data.php' |
2813 | --- Savoirfairelinux_Claim/app/code/local/Savoirfairelinux/Claim/Helper/Data.php 1970-01-01 00:00:00 +0000 |
2814 | +++ Savoirfairelinux_Claim/app/code/local/Savoirfairelinux/Claim/Helper/Data.php 2012-08-10 13:28:19 +0000 |
2815 | @@ -0,0 +1,74 @@ |
2816 | +<?php |
2817 | +/** |
2818 | + * Magento |
2819 | + * |
2820 | + * NOTICE OF LICENSE |
2821 | + * |
2822 | + * Savoirfairelinux_Claim |
2823 | + * Copyright (C) 2012 Savoir-faire Linux |
2824 | + * |
2825 | + * This program is free software: you can redistribute it and/or modify |
2826 | + * it under the terms of the GNU General Public License as published by |
2827 | + * the Free Software Foundation, either version 3 of the License, or |
2828 | + * (at your option) any later version. |
2829 | + * |
2830 | + * This program is distributed in the hope that it will be useful, |
2831 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2832 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2833 | + * GNU General Public License for more details. |
2834 | + * |
2835 | + * You should have received a copy of the GNU General Public License |
2836 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2837 | + * |
2838 | + * DISCLAIMER |
2839 | + * |
2840 | + * Do not edit or add to this file if you wish to upgrade Magento to newer |
2841 | + * versions in the future. If you wish to customize Magento for your |
2842 | + * needs please refer to http://www.magentocommerce.com for more information. |
2843 | + * |
2844 | + * @category Savoirfairelinux |
2845 | + * @package Savoirfairelinux_Claim |
2846 | + * @copyright Copyright (c) 2012 Savoir-faire Linux. (http://www.savoirfairelinux.com) |
2847 | + * @license http://www.gnu.org/licenses/gpl.html General Public License (GPLv3) |
2848 | + */ |
2849 | + |
2850 | +/** |
2851 | + * Default claim helper |
2852 | + * |
2853 | + * @author Joao Alfredo Gama Batista <joao.gama@savoirfairelinux.com> |
2854 | + */ |
2855 | +class Savoirfairelinux_Claim_Helper_Data extends Mage_Core_Helper_Abstract |
2856 | +{ |
2857 | + |
2858 | + const XML_PATH_ENABLED = 'claim/claim/enabled'; |
2859 | + |
2860 | + public function getOrdersHtmlSelect() |
2861 | + { |
2862 | + if (Mage::getSingleton('customer/session')->isLoggedIn()) { |
2863 | + $options = array(); |
2864 | + |
2865 | + $orders = Mage::getResourceModel('sales/order_collection') |
2866 | + ->addFieldToSelect('*') |
2867 | + ->addFieldToFilter('customer_id', Mage::getSingleton('customer/session')->getCustomer()->getId()) |
2868 | + ->addFieldToFilter('state', array('in' => Mage::getSingleton('sales/order_config')->getVisibleOnFrontStates())) |
2869 | + ->setOrder('created_at', 'desc') |
2870 | + ; |
2871 | + |
2872 | + foreach ($orders as $order) { |
2873 | + $options[] = array('value' => $order->getRealOrderId(), |
2874 | + 'label' => $order->getRealOrderId()); |
2875 | + } |
2876 | + $select = $this->getLayout()->createBlock('core/html_select') |
2877 | + ->setName('order') |
2878 | + ->setId('order') |
2879 | + ->setTitle(Mage::helper('claim')->__('Order')) |
2880 | + ->setClass('validate-select') |
2881 | + ->setValue() |
2882 | + ->setOptions($options); |
2883 | + |
2884 | + return $select->getHtml(); |
2885 | + } |
2886 | + return ''; |
2887 | + } |
2888 | + |
2889 | +} |
2890 | |
2891 | === added directory 'Savoirfairelinux_Claim/app/code/local/Savoirfairelinux/Claim/Model' |
2892 | === added directory 'Savoirfairelinux_Claim/app/code/local/Savoirfairelinux/Claim/Model/System' |
2893 | === added directory 'Savoirfairelinux_Claim/app/code/local/Savoirfairelinux/Claim/Model/System/Config' |
2894 | === added directory 'Savoirfairelinux_Claim/app/code/local/Savoirfairelinux/Claim/Model/System/Config/Backend' |
2895 | === added file 'Savoirfairelinux_Claim/app/code/local/Savoirfairelinux/Claim/Model/System/Config/Backend/Links.php' |
2896 | --- Savoirfairelinux_Claim/app/code/local/Savoirfairelinux/Claim/Model/System/Config/Backend/Links.php 1970-01-01 00:00:00 +0000 |
2897 | +++ Savoirfairelinux_Claim/app/code/local/Savoirfairelinux/Claim/Model/System/Config/Backend/Links.php 2012-08-10 13:28:19 +0000 |
2898 | @@ -0,0 +1,48 @@ |
2899 | +<?php |
2900 | +/** |
2901 | + * Magento |
2902 | + * |
2903 | + * NOTICE OF LICENSE |
2904 | + * |
2905 | + * Savoirfairelinux_Claim |
2906 | + * Copyright (C) 2012 Savoir-faire Linux |
2907 | + * |
2908 | + * This program is free software: you can redistribute it and/or modify |
2909 | + * it under the terms of the GNU General Public License as published by |
2910 | + * the Free Software Foundation, either version 3 of the License, or |
2911 | + * (at your option) any later version. |
2912 | + * |
2913 | + * This program is distributed in the hope that it will be useful, |
2914 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2915 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2916 | + * GNU General Public License for more details. |
2917 | + * |
2918 | + * You should have received a copy of the GNU General Public License |
2919 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2920 | + * |
2921 | + * DISCLAIMER |
2922 | + * |
2923 | + * Do not edit or add to this file if you wish to upgrade Magento to newer |
2924 | + * versions in the future. If you wish to customize Magento for your |
2925 | + * needs please refer to http://www.magentocommerce.com for more information. |
2926 | + * |
2927 | + * @category Savoirfairelinux |
2928 | + * @package Savoirfairelinux_Claim |
2929 | + * @copyright Copyright (c) 2012 Savoir-faire Linux. (http://www.savoirfairelinux.com) |
2930 | + * @license http://www.gnu.org/licenses/gpl.html General Public License (GPLv3) |
2931 | + */ |
2932 | + |
2933 | +/** |
2934 | + * Cache cleaner backend model |
2935 | + * |
2936 | + */ |
2937 | +class Savoirfairelinux_Claim_Model_System_Config_Backend_Links extends Mage_Adminhtml_Model_System_Config_Backend_Cache |
2938 | +{ |
2939 | + /** |
2940 | + * Cache tags to clean |
2941 | + * |
2942 | + * @var array |
2943 | + */ |
2944 | + protected $_cacheTags = array(Mage_Core_Model_Store::CACHE_TAG, Mage_Cms_Model_Block::CACHE_TAG); |
2945 | + |
2946 | +} |
2947 | |
2948 | === added directory 'Savoirfairelinux_Claim/app/code/local/Savoirfairelinux/Claim/controllers' |
2949 | === added file 'Savoirfairelinux_Claim/app/code/local/Savoirfairelinux/Claim/controllers/IndexController.php' |
2950 | --- Savoirfairelinux_Claim/app/code/local/Savoirfairelinux/Claim/controllers/IndexController.php 1970-01-01 00:00:00 +0000 |
2951 | +++ Savoirfairelinux_Claim/app/code/local/Savoirfairelinux/Claim/controllers/IndexController.php 2012-08-10 13:28:19 +0000 |
2952 | @@ -0,0 +1,360 @@ |
2953 | +<?php |
2954 | +/** |
2955 | + * Magento |
2956 | + * |
2957 | + * NOTICE OF LICENSE |
2958 | + * |
2959 | + * Savoirfairelinux_Claim |
2960 | + * Copyright (C) 2012 Savoir-faire Linux |
2961 | + * |
2962 | + * This program is free software: you can redistribute it and/or modify |
2963 | + * it under the terms of the GNU General Public License as published by |
2964 | + * the Free Software Foundation, either version 3 of the License, or |
2965 | + * (at your option) any later version. |
2966 | + * |
2967 | + * This program is distributed in the hope that it will be useful, |
2968 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2969 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2970 | + * GNU General Public License for more details. |
2971 | + * |
2972 | + * You should have received a copy of the GNU General Public License |
2973 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2974 | + * |
2975 | + * DISCLAIMER |
2976 | + * |
2977 | + * Do not edit or add to this file if you wish to upgrade Magento to newer |
2978 | + * versions in the future. If you wish to customize Magento for your |
2979 | + * needs please refer to http://www.magentocommerce.com for more information. |
2980 | + * |
2981 | + * @category Savoirfairelinux |
2982 | + * @package Savoirfairelinux_Claim |
2983 | + * @copyright Copyright (c) 2012 Savoir-faire Linux. (http://www.savoirfairelinux.com) |
2984 | + * @license http://www.gnu.org/licenses/gpl.html General Public License (GPLv3) |
2985 | + */ |
2986 | + |
2987 | +/** |
2988 | + * Claim index controller |
2989 | + * |
2990 | + * @category Savoirfairelinux |
2991 | + * @package Savoirfairelinux_Claim |
2992 | + * @author Joao Alfredo Gama Batista <joao.gama@savoirfairelinux.com> |
2993 | + */ |
2994 | + |
2995 | +class Savoirfairelinux_Claim_IndexController extends Mage_Core_Controller_Front_Action |
2996 | +{ |
2997 | + |
2998 | + const XML_PATH_ENABLED = 'claim/claim/enabled'; |
2999 | + const XML_PATH_OPENERP_URL = 'claim/settings/openerp_url'; |
3000 | + const XML_PATH_OPENERP_LOGIN = 'claim/settings/openerp_login'; |
3001 | + const XML_PATH_OPENERP_PASSWORD = 'claim/settings/openerp_password'; |
3002 | + const XML_PATH_OPENERP_DATABASE = 'claim/settings/openerp_database'; |
3003 | + const XML_PATH_OPENERP_CLAIM_REF = 'claim/settings/openerp_claim_ref'; |
3004 | + const XML_PATH_OPENERP_CLAIM_REF_PREFIX = 'claim/settings/openerp_claim_ref_prefix'; |
3005 | + |
3006 | + public function preDispatch() |
3007 | + { |
3008 | + parent::preDispatch(); |
3009 | + $translate = Mage::getSingleton('core/translate'); |
3010 | + |
3011 | + if( !Mage::getStoreConfigFlag(self::XML_PATH_ENABLED) ) { |
3012 | + $this->norouteAction(); |
3013 | + } |
3014 | + |
3015 | + if( !Mage::getSingleton('customer/session')->authenticate($this) ) { |
3016 | + $this->setFlag('', self::FLAG_NO_DISPATCH, true); |
3017 | + } |
3018 | + |
3019 | + $this->partner_name = Mage::helper('contacts')->getUserName(); |
3020 | + |
3021 | + $this->partner_email = Mage::helper('contacts')->getUserEmail(); |
3022 | + |
3023 | + return; |
3024 | + } |
3025 | + |
3026 | + public function indexAction() |
3027 | + { |
3028 | + $this->loadLayout(); |
3029 | + |
3030 | + $this->getLayout()->getBlock('claimForm') |
3031 | + ->setFormAction( Mage::getUrl('*/*/post') ) |
3032 | + ->setRefererUrl($this->_getRefererUrl()); |
3033 | + |
3034 | + if ($navigationBlock = $this->getLayout()->getBlock('customer_account_navigation')) { |
3035 | + $navigationBlock->setActive('claim'); |
3036 | + } |
3037 | + |
3038 | + $this->_initLayoutMessages('customer/session'); |
3039 | + $this->_initLayoutMessages('catalog/session'); |
3040 | + $this->renderLayout(); |
3041 | + } |
3042 | + |
3043 | + public function postAction() |
3044 | + { |
3045 | + |
3046 | + $post = $this->getRequest()->getPost(); |
3047 | + if ( $post ) { |
3048 | + $translate = Mage::getSingleton('core/translate'); |
3049 | + /* @var $translate Mage_Core_Model_Translate */ |
3050 | + $translate->setTranslateInline(false); |
3051 | + try { |
3052 | + $postObject = new Varien_Object(); |
3053 | + $postObject->setData($post); |
3054 | + |
3055 | + $error = false; |
3056 | + |
3057 | + If (!Zend_Validate::is(trim($post['subject']) , 'NotEmpty')) { |
3058 | + $error = true; |
3059 | + } |
3060 | + |
3061 | + if ($error) { |
3062 | + throw new Exception(); |
3063 | + } |
3064 | + |
3065 | + $this->openerp = new Savoirfairelinux_Claim_Openerpclient |
3066 | + (Mage::getStoreConfig(self::XML_PATH_OPENERP_LOGIN), |
3067 | + Mage::helper('core')->decrypt(Mage::getStoreConfig(self::XML_PATH_OPENERP_PASSWORD)), |
3068 | + Mage::getStoreConfig(self::XML_PATH_OPENERP_DATABASE), |
3069 | + Mage::getStoreConfig(self::XML_PATH_OPENERP_URL), |
3070 | + Mage::getStoreConfig(self::XML_PATH_OPENERP_CLAIM_REF), |
3071 | + Mage::getStoreConfig(self::XML_PATH_OPENERP_CLAIM_REF_PREFIX) |
3072 | + ); |
3073 | + |
3074 | + /* $openerp->connect(); */ |
3075 | + $partner_id = $this->openerp->getPartnerId($this->partner_name, |
3076 | + $this->partner_email); |
3077 | + $partner_contact_id = $this->openerp->getPartnerContactId($partner_id); |
3078 | + $order_id = $this->openerp->getOrderId(trim($post['order'])); |
3079 | + $this->openerp->createClaim($partner_id, |
3080 | + $partner_contact_id, |
3081 | + $order_id, |
3082 | + trim($post['subject']), |
3083 | + trim($post['claim'])); |
3084 | + |
3085 | + |
3086 | + $translate->setTranslateInline(true); |
3087 | + |
3088 | + Mage::getSingleton('customer/session')->addSuccess(Mage::helper('claim')->__('Your complaint was submitted and will be responded to as soon as possible. Thank you for contacting us.')); |
3089 | + $this->_redirect('*/*/'); |
3090 | + |
3091 | + return; |
3092 | + } catch (Exception $e) { |
3093 | + $translate->setTranslateInline(true); |
3094 | + |
3095 | + Mage::getSingleton('customer/session')->addError(Mage::helper('claim')->__('Unable to submit your complaint. Please, try again later.')); |
3096 | + $this->_redirect('*/*/'); |
3097 | + return; |
3098 | + } |
3099 | + |
3100 | + } else { |
3101 | + $this->_redirect('*/*/'); |
3102 | + } |
3103 | + } |
3104 | + |
3105 | +} |
3106 | + |
3107 | +class Savoirfairelinux_Claim_Openerpclient |
3108 | +{ |
3109 | + |
3110 | + function __construct($usr, $pass, $db, $server, $claim_ref, $claim_ref_prefix) |
3111 | + { |
3112 | + |
3113 | + $ExternalLibPath=Mage::getModuleDir('', 'Savoirfairelinux_Claim').DS.'lib'.DS.'xmlrpc.inc'; |
3114 | + require_once ($ExternalLibPath); |
3115 | + |
3116 | + $this->user = $usr; |
3117 | + $this->password = $pass; |
3118 | + $this->database = $db; |
3119 | + $this->services = $server; |
3120 | + $this->claim_ref = $claim_ref; |
3121 | + $this->claim_ref_prefix = $claim_ref_prefix; |
3122 | + |
3123 | + $this->client = new xmlrpc_client($this->services.'common'); |
3124 | + |
3125 | + $this->msg = new xmlrpcmsg('login'); |
3126 | + $this->msg->addParam(new xmlrpcval($this->database, "string")); |
3127 | + $this->msg->addParam(new xmlrpcval($this->user, "string")); |
3128 | + $this->msg->addParam(new xmlrpcval($this->password, "string")); |
3129 | + |
3130 | + $this->res = &$this->client->send($this->msg); |
3131 | + |
3132 | + if(!$this->res->faultCode()){ |
3133 | + $this->userid = $this->res->value()->scalarval(); |
3134 | + } |
3135 | + else { |
3136 | + Mage::log("Unable to login ".$this->res->faultString()); |
3137 | + throw new Exception(); |
3138 | + exit; |
3139 | + } |
3140 | + } |
3141 | + |
3142 | + public function getPartnerId($partner, $email) |
3143 | + { |
3144 | + Mage::log('getPartnerId: '.$partner); |
3145 | + |
3146 | + $key = array(new xmlrpcval(array(new xmlrpcval("name" , "string"), |
3147 | + new xmlrpcval("=","string"), |
3148 | + new xmlrpcval($partner, "string")),"array"), |
3149 | + ); |
3150 | + |
3151 | + $ids = $this->search('res.partner', $key); |
3152 | + if(sizeof($ids) == 0) { |
3153 | + $id = -1; |
3154 | + } elseif(sizeof($ids) == 1) { |
3155 | + $id = $ids[0]->scalarval(); |
3156 | + } elseif( sizeof($ids) > 1) { |
3157 | + foreach( $ids as $v ) { |
3158 | + $m = $this->getPartnerEmail($v); |
3159 | + if( $m == $email ) |
3160 | + $id = $v->scalarval(); |
3161 | + } |
3162 | + } |
3163 | + /* return $ids; */ |
3164 | + Mage::log('getPartnerId: '.$id); |
3165 | + return $id; |
3166 | + } |
3167 | + |
3168 | + public function isPartner($name, $email) |
3169 | + { |
3170 | + $partner_id = $this->getPartnerId($name, $email); |
3171 | + if( $partner_id == -1 ) |
3172 | + $ret = False; |
3173 | + else |
3174 | + $ret = True; |
3175 | + |
3176 | + return $ret; |
3177 | + } |
3178 | + |
3179 | + public function getPartnerContactId($partner_id) |
3180 | + { |
3181 | + Mage::log('getPartnerContactId: '.$partner_id); |
3182 | + |
3183 | + $key = array(new xmlrpcval(array(new xmlrpcval("partner_id" , "string"), |
3184 | + new xmlrpcval("=","string"), |
3185 | + new xmlrpcval($partner_id, "int")),"array")); |
3186 | + |
3187 | + $ids = $this->search('res.partner.address', $key); |
3188 | + /* return $ids; */ |
3189 | + Mage::log('getpartnerContactId: '.$ids[0]->scalarval()); |
3190 | + return $ids[0]->scalarval(); |
3191 | + } |
3192 | + |
3193 | + public function getOrderId($order) |
3194 | + { |
3195 | + |
3196 | + $key = array(new xmlrpcval(array(new xmlrpcval("name" , "string"), |
3197 | + new xmlrpcval("=","string"), |
3198 | + new xmlrpcval($this->claim_ref_prefix.$order, "string")),"array"), |
3199 | + ); |
3200 | + |
3201 | + $ids = $this->search($this->claim_ref, $key); |
3202 | + if( sizeof($ids) > 1 ) { |
3203 | + Mage::log('Duplicated orders error!!'); |
3204 | + throw new Exception(); |
3205 | + } |
3206 | + |
3207 | + /* return $ids; */ |
3208 | + Mage::log('Order_id: '.$ids[0]->scalarval()); |
3209 | + return $ids[0]->scalarval(); |
3210 | + } |
3211 | + |
3212 | + public function createClaim($partner, |
3213 | + $partner_address, |
3214 | + $order, |
3215 | + $subject, |
3216 | + $description) |
3217 | + { |
3218 | + $arrayVal = array( |
3219 | + 'name'=>new xmlrpcval($subject, "string") , |
3220 | + 'description'=>new xmlrpcval($description, "string"), |
3221 | + 'partner_id'=>new xmlrpcval($partner, "int"), |
3222 | + 'partner_address_id'=>new xmlrpcval($partner_address, "int"), |
3223 | + 'ref'=>new xmlrpcval('sale.order,'.$order, 'string') |
3224 | + ); |
3225 | + |
3226 | + $this->client = new xmlrpc_client($this->services."object"); |
3227 | + |
3228 | + $this->msg = new xmlrpcmsg('execute'); |
3229 | + $this->msg->addParam(new xmlrpcval($this->database, "string")); |
3230 | + $this->msg->addParam(new xmlrpcval($this->userid, "int")); |
3231 | + $this->msg->addParam(new xmlrpcval($this->password, "string")); |
3232 | + $this->msg->addParam(new xmlrpcval("crm.claim", "string")); |
3233 | + $this->msg->addParam(new xmlrpcval("create", "string")); |
3234 | + $this->msg->addParam(new xmlrpcval($arrayVal, "struct")); |
3235 | + |
3236 | + $this->resp = $this->client->send($this->msg); |
3237 | + |
3238 | + if ($this->resp->faultCode()) |
3239 | + Mage::log('Error: '.$this->resp->faultString()); |
3240 | + else |
3241 | + Mage::log('Claim '.$this->resp->value()->scalarval().' created !'); |
3242 | + |
3243 | + } |
3244 | + |
3245 | + public function getPartnerEmail($partner_id) |
3246 | + { |
3247 | + Mage::log('getPartnerEmail: '.$partner_id->scalarval()); |
3248 | + |
3249 | + $ids = array($partner_id); |
3250 | + $fields = array(new xmlrpcval('email', 'string')); |
3251 | + |
3252 | + $ids = $this->read('res.partner', $ids, $fields); |
3253 | + |
3254 | + $id = $ids[0]->scalarval(); |
3255 | + Mage::log('getPartnerEmail: '.$id['email']->scalarval()); |
3256 | + return $id['email']->scalarval(); |
3257 | + } |
3258 | + |
3259 | + public function search($relation, $key) |
3260 | + { |
3261 | + Mage::log('search: '.$relation); |
3262 | + $this->client = new xmlrpc_client($this->services.'object'); |
3263 | + |
3264 | + $this->msg = new xmlrpcmsg('execute'); |
3265 | + $this->msg->addParam(new xmlrpcval($this->database, "string")); |
3266 | + $this->msg->addParam(new xmlrpcval($this->userid, "int")); |
3267 | + $this->msg->addParam(new xmlrpcval($this->password, "string")); |
3268 | + $this->msg->addParam(new xmlrpcval($relation, "string")); |
3269 | + $this->msg->addParam(new xmlrpcval("search", "string")); |
3270 | + $this->msg->addParam(new xmlrpcval($key, "array")); |
3271 | + |
3272 | + $this->resp = $this->client->send($this->msg); |
3273 | + |
3274 | + if ($this->resp->faultCode()) { |
3275 | + Mage::log('Search error: '.$this->resp->faultString()); |
3276 | + $id = ''; |
3277 | + } else { |
3278 | + Mage::log('Search '.$relation.' succeded !'); |
3279 | + $id = $this->resp->value()->scalarval(); |
3280 | + } |
3281 | + |
3282 | + return $id; |
3283 | + } |
3284 | + |
3285 | + public function read($relation, $ids, $fields) |
3286 | + { |
3287 | + Mage::log('read: '.$relation); |
3288 | + $this->client = new xmlrpc_client($this->services.'object'); |
3289 | + |
3290 | + $this->msg = new xmlrpcmsg('execute'); |
3291 | + $this->msg->addParam(new xmlrpcval($this->database, "string")); |
3292 | + $this->msg->addParam(new xmlrpcval($this->userid, "int")); |
3293 | + $this->msg->addParam(new xmlrpcval($this->password, "string")); |
3294 | + $this->msg->addParam(new xmlrpcval($relation, "string")); |
3295 | + $this->msg->addParam(new xmlrpcval("read", "string")); |
3296 | + $this->msg->addParam(new xmlrpcval($ids, "array")); |
3297 | + $this->msg->addParam(new xmlrpcval($fields, "array")); |
3298 | + |
3299 | + $this->resp = $this->client->send($this->msg); |
3300 | + |
3301 | + if ($this->resp->faultCode()) { |
3302 | + Mage::log('Read error: '.$this->resp->faultString()); |
3303 | + $id = ''; |
3304 | + } else { |
3305 | + Mage::log('Read '.$relation.' succeded !'); |
3306 | + $id = $this->resp->value()->scalarval(); |
3307 | + } |
3308 | + |
3309 | + return $id; |
3310 | + } |
3311 | + |
3312 | +} |
3313 | |
3314 | === added directory 'Savoirfairelinux_Claim/app/code/local/Savoirfairelinux/Claim/etc' |
3315 | === added file 'Savoirfairelinux_Claim/app/code/local/Savoirfairelinux/Claim/etc/adminhtml.xml' |
3316 | --- Savoirfairelinux_Claim/app/code/local/Savoirfairelinux/Claim/etc/adminhtml.xml 1970-01-01 00:00:00 +0000 |
3317 | +++ Savoirfairelinux_Claim/app/code/local/Savoirfairelinux/Claim/etc/adminhtml.xml 2012-08-10 13:28:19 +0000 |
3318 | @@ -0,0 +1,22 @@ |
3319 | +<?xml version="1.0" encoding="utf-8"?> |
3320 | +<config> |
3321 | + <acl> |
3322 | + <resources> |
3323 | + <admin> |
3324 | + <children> |
3325 | + <system> |
3326 | + <children> |
3327 | + <config> |
3328 | + <children> |
3329 | + <claim translate="title" module="claim"> |
3330 | + <title>Complaints Settings</title> |
3331 | + </claim> |
3332 | + </children> |
3333 | + </config> |
3334 | + </children> |
3335 | + </system> |
3336 | + </children> |
3337 | + </admin> |
3338 | + </resources> |
3339 | + </acl> |
3340 | +</config> |
3341 | \ No newline at end of file |
3342 | |
3343 | === added file 'Savoirfairelinux_Claim/app/code/local/Savoirfairelinux/Claim/etc/config.xml' |
3344 | --- Savoirfairelinux_Claim/app/code/local/Savoirfairelinux/Claim/etc/config.xml 1970-01-01 00:00:00 +0000 |
3345 | +++ Savoirfairelinux_Claim/app/code/local/Savoirfairelinux/Claim/etc/config.xml 2012-08-10 13:28:19 +0000 |
3346 | @@ -0,0 +1,117 @@ |
3347 | +<?xml version="1.0"?> |
3348 | +<!-- |
3349 | +/** |
3350 | + * Magento |
3351 | + * |
3352 | + * NOTICE OF LICENSE |
3353 | + * |
3354 | + * Savoirfairelinux_Claim |
3355 | + * Copyright (C) 2012 Savoir-faire Linux |
3356 | + * |
3357 | + * This program is free software: you can redistribute it and/or modify |
3358 | + * it under the terms of the GNU General Public License as published by |
3359 | + * the Free Software Foundation, either version 3 of the License, or |
3360 | + * (at your option) any later version. |
3361 | + * |
3362 | + * This program is distributed in the hope that it will be useful, |
3363 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
3364 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3365 | + * GNU General Public License for more details. |
3366 | + * |
3367 | + * You should have received a copy of the GNU General Public License |
3368 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
3369 | + * |
3370 | + * DISCLAIMER |
3371 | + * |
3372 | + * Do not edit or add to this file if you wish to upgrade Magento to newer |
3373 | + * versions in the future. If you wish to customize Magento for your |
3374 | + * needs please refer to http://www.magentocommerce.com for more information. |
3375 | + * |
3376 | + * @category Savoirfairelinux |
3377 | + * @package Savoirfairelinux_Claim |
3378 | + * @copyright Copyright (c) 2012 Savoir-faire Linux (http://www.savoirfairelinux.com) |
3379 | + * @license http://www.gnu.org/licenses/gpl.html General Public License (GPLv3) |
3380 | + */ |
3381 | +--> |
3382 | +<config> |
3383 | + <modules> |
3384 | + <Savoirfairelinux_Claim> |
3385 | + <version>0.1.1</version> |
3386 | + </Savoirfairelinux_Claim> |
3387 | + </modules> |
3388 | + <global> |
3389 | + <!-- <resources> --> |
3390 | + <!-- <claim_setup> --> |
3391 | + <!-- <setup> --> |
3392 | + <!-- <module>Savoirfairelinux_Claim</module> --> |
3393 | + <!-- </setup> --> |
3394 | + <!-- </claim_setup> --> |
3395 | + <!-- </resources> --> |
3396 | + <helpers> |
3397 | + <claim> |
3398 | + <class>Savoirfairelinux_Claim_Helper</class> |
3399 | + </claim> |
3400 | + </helpers> |
3401 | + |
3402 | + <blocks> |
3403 | + <claim> |
3404 | + <class>Savoirfairelinux_Claim_Block</class> |
3405 | + </claim> |
3406 | + </blocks> |
3407 | + |
3408 | + </global> |
3409 | + |
3410 | + <adminhtml> |
3411 | + <translate> |
3412 | + <modules> |
3413 | + <Savoirfairelinux_Claim> |
3414 | + <files> |
3415 | + <default>Savoirfairelinux_Claim.csv</default> |
3416 | + </files> |
3417 | + </Savoirfairelinux_Claim> |
3418 | + </modules> |
3419 | + </translate> |
3420 | + </adminhtml> |
3421 | + <frontend> |
3422 | + <routers> |
3423 | + <claim> |
3424 | + <use>standard</use> |
3425 | + <args> |
3426 | + <module>Savoirfairelinux_Claim</module> |
3427 | + <frontName>claim</frontName> |
3428 | + </args> |
3429 | + </claim> |
3430 | + </routers> |
3431 | + <translate> |
3432 | + <modules> |
3433 | + <Savoirfairelinux_Claim> |
3434 | + <files> |
3435 | + <default>Savoirfairelinux_Claim.csv</default> |
3436 | + </files> |
3437 | + </Savoirfairelinux_Claim> |
3438 | + </modules> |
3439 | + </translate> |
3440 | + <layout> |
3441 | + <updates> |
3442 | + <claim> |
3443 | + <file>savoirfairelinux_claim.xml</file> |
3444 | + </claim> |
3445 | + </updates> |
3446 | + </layout> |
3447 | + </frontend> |
3448 | + <default> |
3449 | + <claim> |
3450 | + <claim> |
3451 | + <enabled>1</enabled> |
3452 | + </claim> |
3453 | + <settings> |
3454 | + <openerp_url>http://localhost:8069/xmlrpc/</openerp_url> |
3455 | + <openerp_database>test</openerp_database> |
3456 | + <openerp_login>admin</openerp_login> |
3457 | + <openerp_password>admin123</openerp_password> |
3458 | + <openerp_claim_ref>sale.order</openerp_claim_ref> |
3459 | + <openerp_claim_ref_prefix>mag_</openerp_claim_ref_prefix> |
3460 | + </settings> |
3461 | + </claim> |
3462 | + </default> |
3463 | +</config> |
3464 | |
3465 | === added directory 'Savoirfairelinux_Claim/app/code/local/Savoirfairelinux/Claim/etc/modules' |
3466 | === added file 'Savoirfairelinux_Claim/app/code/local/Savoirfairelinux/Claim/etc/modules/Savoirfairelinux_Claim.xml' |
3467 | --- Savoirfairelinux_Claim/app/code/local/Savoirfairelinux/Claim/etc/modules/Savoirfairelinux_Claim.xml 1970-01-01 00:00:00 +0000 |
3468 | +++ Savoirfairelinux_Claim/app/code/local/Savoirfairelinux/Claim/etc/modules/Savoirfairelinux_Claim.xml 2012-08-10 13:28:19 +0000 |
3469 | @@ -0,0 +1,9 @@ |
3470 | +<?xml version="1.0" encoding="utf-8"?> |
3471 | +<config> |
3472 | + <modules> |
3473 | + <Savoirfairelinux_Claim> |
3474 | + <active>true</active> |
3475 | + <codePool>local</codePool> |
3476 | + </Savoirfairelinux_Claim> |
3477 | + </modules> |
3478 | +</config> |
3479 | |
3480 | === added file 'Savoirfairelinux_Claim/app/code/local/Savoirfairelinux/Claim/etc/system.xml' |
3481 | --- Savoirfairelinux_Claim/app/code/local/Savoirfairelinux/Claim/etc/system.xml 1970-01-01 00:00:00 +0000 |
3482 | +++ Savoirfairelinux_Claim/app/code/local/Savoirfairelinux/Claim/etc/system.xml 2012-08-10 13:28:19 +0000 |
3483 | @@ -0,0 +1,114 @@ |
3484 | +<?xml version="1.0" encoding="utf-8"?> |
3485 | +<config> |
3486 | + <sections> |
3487 | + <claim translate="label" module="claim"> |
3488 | + <label>Complaints</label> |
3489 | + <tab>customer</tab> |
3490 | + <frontend_type>text</frontend_type> |
3491 | + <sort_order>990</sort_order> |
3492 | + <show_in_default>1</show_in_default> |
3493 | + <show_in_website>1</show_in_website> |
3494 | + <show_in_store>1</show_in_store> |
3495 | + <groups> |
3496 | + <claim translate="label"> |
3497 | + <label>Claim</label> |
3498 | + <frontend_type>text</frontend_type> |
3499 | + <sort_order>20</sort_order> |
3500 | + <show_in_default>1</show_in_default> |
3501 | + <show_in_website>1</show_in_website> |
3502 | + <show_in_store>1</show_in_store> |
3503 | + <fields> |
3504 | + <enabled translate="label"> |
3505 | + <label>Enabled</label> |
3506 | + <frontend_type>select</frontend_type> |
3507 | + <source_model>adminhtml/system_config_source_yesno</source_model> |
3508 | + <!-- <backend_model>claim/system_config_backend_links</backend_model> --> |
3509 | + <sort_order>4</sort_order> |
3510 | + <show_in_default>1</show_in_default> |
3511 | + <show_in_website>1</show_in_website> |
3512 | + <show_in_store>1</show_in_store> |
3513 | + </enabled> |
3514 | + |
3515 | + <!-- <enabled translate="label"> --> |
3516 | + <!-- <label>Enabled</label> --> |
3517 | + <!-- <frontend_type>select</frontend_type> --> |
3518 | + <!-- <source_model>adminhtml/system_config_source_yesno</source_model> --> |
3519 | + <!-- <backend_model>savoirfairelinux_claim/system_config_backend_links</backend_model> --> |
3520 | + <!-- <sort_order>1</sort_order> --> |
3521 | + <!-- <show_in_default>1</show_in_default> --> |
3522 | + <!-- <show_in_website>1</show_in_website> --> |
3523 | + <!-- <show_in_store>1</show_in_store> --> |
3524 | + <!-- </enabled> --> |
3525 | + </fields> |
3526 | + </claim> |
3527 | + <settings translate="label"> |
3528 | + <label>OpenERP Settings</label> |
3529 | + <frontend_type>text</frontend_type> |
3530 | + <sort_order>20</sort_order> |
3531 | + <show_in_default>1</show_in_default> |
3532 | + <show_in_website>1</show_in_website> |
3533 | + <show_in_store>1</show_in_store> |
3534 | + <fields> |
3535 | + <openerp_url translate="label,comment"> |
3536 | + <label>OpenERP server URL</label> |
3537 | + <comment><![CDATA[]]></comment> |
3538 | + <frontend_type>text</frontend_type> |
3539 | + <sort_order>1</sort_order> |
3540 | + <show_in_default>1</show_in_default> |
3541 | + <show_in_website>1</show_in_website> |
3542 | + <show_in_store>1</show_in_store> |
3543 | + </openerp_url> |
3544 | + <openerp_database translate="label,comment"> |
3545 | + <label>OpenERP database name</label> |
3546 | + <comment><![CDATA[]]></comment> |
3547 | + <frontend_type>text</frontend_type> |
3548 | + <sort_order>1</sort_order> |
3549 | + <show_in_default>1</show_in_default> |
3550 | + <show_in_website>1</show_in_website> |
3551 | + <show_in_store>1</show_in_store> |
3552 | + </openerp_database> |
3553 | + |
3554 | + <openerp_login translate="label"> |
3555 | + <label>OpenERP login</label> |
3556 | + <frontend_type>text</frontend_type> |
3557 | + <sort_order>2</sort_order> |
3558 | + <show_in_default>1</show_in_default> |
3559 | + <show_in_website>1</show_in_website> |
3560 | + <show_in_store>1</show_in_store> |
3561 | + </openerp_login> |
3562 | + <openerp_password translate="label,comment"> |
3563 | + <label>OpenERP password</label> |
3564 | + <comment></comment> |
3565 | + <backend_model>adminhtml/system_config_backend_encrypted</backend_model> |
3566 | + <frontend_type>obscure</frontend_type> |
3567 | + <sort_order>3</sort_order> |
3568 | + <show_in_default>1</show_in_default> |
3569 | + <show_in_website>1</show_in_website> |
3570 | + <show_in_store>1</show_in_store> |
3571 | + </openerp_password> |
3572 | + <openerp_claim_ref translate="label,comment"> |
3573 | + <label>OpenERP Reference field entity</label> |
3574 | + <comment></comment> |
3575 | + <frontend_type>text</frontend_type> |
3576 | + <sort_order>4</sort_order> |
3577 | + <show_in_default>1</show_in_default> |
3578 | + <show_in_website>1</show_in_website> |
3579 | + <show_in_store>1</show_in_store> |
3580 | + </openerp_claim_ref> |
3581 | + <openerp_claim_ref_prefix translate="label,comment"> |
3582 | + <label>OpenERP Reference field prefix</label> |
3583 | + <comment></comment> |
3584 | + <frontend_type>text</frontend_type> |
3585 | + <sort_order>5</sort_order> |
3586 | + <show_in_default>1</show_in_default> |
3587 | + <show_in_website>1</show_in_website> |
3588 | + <show_in_store>1</show_in_store> |
3589 | + </openerp_claim_ref_prefix> |
3590 | + </fields> |
3591 | + </settings> |
3592 | + </groups> |
3593 | + </claim> |
3594 | + </sections> |
3595 | +</config> |
3596 | + |
3597 | + |
3598 | \ No newline at end of file |
3599 | |
3600 | === added directory 'Savoirfairelinux_Claim/app/code/local/Savoirfairelinux/Claim/lib' |
3601 | === added file 'Savoirfairelinux_Claim/app/code/local/Savoirfairelinux/Claim/lib/xmlrpc.inc' |
3602 | --- Savoirfairelinux_Claim/app/code/local/Savoirfairelinux/Claim/lib/xmlrpc.inc 1970-01-01 00:00:00 +0000 |
3603 | +++ Savoirfairelinux_Claim/app/code/local/Savoirfairelinux/Claim/lib/xmlrpc.inc 2012-08-10 13:28:19 +0000 |
3604 | @@ -0,0 +1,3776 @@ |
3605 | +<?php |
3606 | +// by Edd Dumbill (C) 1999-2002 |
3607 | +// <edd@usefulinc.com> |
3608 | +// $Id: xmlrpc.inc,v 1.174 2009/03/16 19:36:38 ggiunta Exp $ |
3609 | + |
3610 | +// Copyright (c) 1999,2000,2002 Edd Dumbill. |
3611 | +// All rights reserved. |
3612 | +// |
3613 | +// Redistribution and use in source and binary forms, with or without |
3614 | +// modification, are permitted provided that the following conditions |
3615 | +// are met: |
3616 | +// |
3617 | +// * Redistributions of source code must retain the above copyright |
3618 | +// notice, this list of conditions and the following disclaimer. |
3619 | +// |
3620 | +// * Redistributions in binary form must reproduce the above |
3621 | +// copyright notice, this list of conditions and the following |
3622 | +// disclaimer in the documentation and/or other materials provided |
3623 | +// with the distribution. |
3624 | +// |
3625 | +// * Neither the name of the "XML-RPC for PHP" nor the names of its |
3626 | +// contributors may be used to endorse or promote products derived |
3627 | +// from this software without specific prior written permission. |
3628 | +// |
3629 | +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
3630 | +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
3631 | +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
3632 | +// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
3633 | +// REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
3634 | +// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
3635 | +// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
3636 | +// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
3637 | +// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
3638 | +// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
3639 | +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED |
3640 | +// OF THE POSSIBILITY OF SUCH DAMAGE. |
3641 | + |
3642 | + if(!function_exists('xml_parser_create')) |
3643 | + { |
3644 | + // For PHP 4 onward, XML functionality is always compiled-in on windows: |
3645 | + // no more need to dl-open it. It might have been compiled out on *nix... |
3646 | + if(strtoupper(substr(PHP_OS, 0, 3) != 'WIN')) |
3647 | + { |
3648 | + dl('xml.so'); |
3649 | + } |
3650 | + } |
3651 | + |
3652 | + // G. Giunta 2005/01/29: declare global these variables, |
3653 | + // so that xmlrpc.inc will work even if included from within a function |
3654 | + // Milosch: 2005/08/07 - explicitly request these via $GLOBALS where used. |
3655 | + $GLOBALS['xmlrpcI4']='i4'; |
3656 | + $GLOBALS['xmlrpcInt']='int'; |
3657 | + $GLOBALS['xmlrpcBoolean']='boolean'; |
3658 | + $GLOBALS['xmlrpcDouble']='double'; |
3659 | + $GLOBALS['xmlrpcString']='string'; |
3660 | + $GLOBALS['xmlrpcDateTime']='dateTime.iso8601'; |
3661 | + $GLOBALS['xmlrpcBase64']='base64'; |
3662 | + $GLOBALS['xmlrpcArray']='array'; |
3663 | + $GLOBALS['xmlrpcStruct']='struct'; |
3664 | + $GLOBALS['xmlrpcValue']='undefined'; |
3665 | + |
3666 | + $GLOBALS['xmlrpcTypes']=array( |
3667 | + $GLOBALS['xmlrpcI4'] => 1, |
3668 | + $GLOBALS['xmlrpcInt'] => 1, |
3669 | + $GLOBALS['xmlrpcBoolean'] => 1, |
3670 | + $GLOBALS['xmlrpcString'] => 1, |
3671 | + $GLOBALS['xmlrpcDouble'] => 1, |
3672 | + $GLOBALS['xmlrpcDateTime'] => 1, |
3673 | + $GLOBALS['xmlrpcBase64'] => 1, |
3674 | + $GLOBALS['xmlrpcArray'] => 2, |
3675 | + $GLOBALS['xmlrpcStruct'] => 3 |
3676 | + ); |
3677 | + |
3678 | + $GLOBALS['xmlrpc_valid_parents'] = array( |
3679 | + 'VALUE' => array('MEMBER', 'DATA', 'PARAM', 'FAULT'), |
3680 | + 'BOOLEAN' => array('VALUE'), |
3681 | + 'I4' => array('VALUE'), |
3682 | + 'INT' => array('VALUE'), |
3683 | + 'STRING' => array('VALUE'), |
3684 | + 'DOUBLE' => array('VALUE'), |
3685 | + 'DATETIME.ISO8601' => array('VALUE'), |
3686 | + 'BASE64' => array('VALUE'), |
3687 | + 'MEMBER' => array('STRUCT'), |
3688 | + 'NAME' => array('MEMBER'), |
3689 | + 'DATA' => array('ARRAY'), |
3690 | + 'ARRAY' => array('VALUE'), |
3691 | + 'STRUCT' => array('VALUE'), |
3692 | + 'PARAM' => array('PARAMS'), |
3693 | + 'METHODNAME' => array('METHODCALL'), |
3694 | + 'PARAMS' => array('METHODCALL', 'METHODRESPONSE'), |
3695 | + 'FAULT' => array('METHODRESPONSE'), |
3696 | + 'NIL' => array('VALUE'), // only used when extension activated |
3697 | + 'EX:NIL' => array('VALUE') // only used when extension activated |
3698 | + ); |
3699 | + |
3700 | + // define extra types for supporting NULL (useful for json or <NIL/>) |
3701 | + $GLOBALS['xmlrpcNull']='null'; |
3702 | + $GLOBALS['xmlrpcTypes']['null']=1; |
3703 | + |
3704 | + // Not in use anymore since 2.0. Shall we remove it? |
3705 | + /// @deprecated |
3706 | + $GLOBALS['xmlEntities']=array( |
3707 | + 'amp' => '&', |
3708 | + 'quot' => '"', |
3709 | + 'lt' => '<', |
3710 | + 'gt' => '>', |
3711 | + 'apos' => "'" |
3712 | + ); |
3713 | + |
3714 | + // tables used for transcoding different charsets into us-ascii xml |
3715 | + |
3716 | + $GLOBALS['xml_iso88591_Entities']=array(); |
3717 | + $GLOBALS['xml_iso88591_Entities']['in'] = array(); |
3718 | + $GLOBALS['xml_iso88591_Entities']['out'] = array(); |
3719 | + for ($i = 0; $i < 32; $i++) |
3720 | + { |
3721 | + $GLOBALS['xml_iso88591_Entities']['in'][] = chr($i); |
3722 | + $GLOBALS['xml_iso88591_Entities']['out'][] = '&#'.$i.';'; |
3723 | + } |
3724 | + for ($i = 160; $i < 256; $i++) |
3725 | + { |
3726 | + $GLOBALS['xml_iso88591_Entities']['in'][] = chr($i); |
3727 | + $GLOBALS['xml_iso88591_Entities']['out'][] = '&#'.$i.';'; |
3728 | + } |
3729 | + |
3730 | + /// @todo add to iso table the characters from cp_1252 range, i.e. 128 to 159? |
3731 | + /// These will NOT be present in true ISO-8859-1, but will save the unwary |
3732 | + /// windows user from sending junk (though no luck when reciving them...) |
3733 | + /* |
3734 | + $GLOBALS['xml_cp1252_Entities']=array(); |
3735 | + for ($i = 128; $i < 160; $i++) |
3736 | + { |
3737 | + $GLOBALS['xml_cp1252_Entities']['in'][] = chr($i); |
3738 | + } |
3739 | + $GLOBALS['xml_cp1252_Entities']['out'] = array( |
3740 | + '€', '?', '‚', 'ƒ', |
3741 | + '„', '…', '†', '‡', |
3742 | + 'ˆ', '‰', 'Š', '‹', |
3743 | + 'Œ', '?', 'Ž', '?', |
3744 | + '?', '‘', '’', '“', |
3745 | + '”', '•', '–', '—', |
3746 | + '˜', '™', 'š', '›', |
3747 | + 'œ', '?', 'ž', 'Ÿ' |
3748 | + ); |
3749 | + */ |
3750 | + |
3751 | + $GLOBALS['xmlrpcerr'] = array( |
3752 | + 'unknown_method'=>1, |
3753 | + 'invalid_return'=>2, |
3754 | + 'incorrect_params'=>3, |
3755 | + 'introspect_unknown'=>4, |
3756 | + 'http_error'=>5, |
3757 | + 'no_data'=>6, |
3758 | + 'no_ssl'=>7, |
3759 | + 'curl_fail'=>8, |
3760 | + 'invalid_request'=>15, |
3761 | + 'no_curl'=>16, |
3762 | + 'server_error'=>17, |
3763 | + 'multicall_error'=>18, |
3764 | + 'multicall_notstruct'=>9, |
3765 | + 'multicall_nomethod'=>10, |
3766 | + 'multicall_notstring'=>11, |
3767 | + 'multicall_recursion'=>12, |
3768 | + 'multicall_noparams'=>13, |
3769 | + 'multicall_notarray'=>14, |
3770 | + |
3771 | + 'cannot_decompress'=>103, |
3772 | + 'decompress_fail'=>104, |
3773 | + 'dechunk_fail'=>105, |
3774 | + 'server_cannot_decompress'=>106, |
3775 | + 'server_decompress_fail'=>107 |
3776 | + ); |
3777 | + |
3778 | + $GLOBALS['xmlrpcstr'] = array( |
3779 | + 'unknown_method'=>'Unknown method', |
3780 | + 'invalid_return'=>'Invalid return payload: enable debugging to examine incoming payload', |
3781 | + 'incorrect_params'=>'Incorrect parameters passed to method', |
3782 | + 'introspect_unknown'=>"Can't introspect: method unknown", |
3783 | + 'http_error'=>"Didn't receive 200 OK from remote server.", |
3784 | + 'no_data'=>'No data received from server.', |
3785 | + 'no_ssl'=>'No SSL support compiled in.', |
3786 | + 'curl_fail'=>'CURL error', |
3787 | + 'invalid_request'=>'Invalid request payload', |
3788 | + 'no_curl'=>'No CURL support compiled in.', |
3789 | + 'server_error'=>'Internal server error', |
3790 | + 'multicall_error'=>'Received from server invalid multicall response', |
3791 | + 'multicall_notstruct'=>'system.multicall expected struct', |
3792 | + 'multicall_nomethod'=>'missing methodName', |
3793 | + 'multicall_notstring'=>'methodName is not a string', |
3794 | + 'multicall_recursion'=>'recursive system.multicall forbidden', |
3795 | + 'multicall_noparams'=>'missing params', |
3796 | + 'multicall_notarray'=>'params is not an array', |
3797 | + |
3798 | + 'cannot_decompress'=>'Received from server compressed HTTP and cannot decompress', |
3799 | + 'decompress_fail'=>'Received from server invalid compressed HTTP', |
3800 | + 'dechunk_fail'=>'Received from server invalid chunked HTTP', |
3801 | + 'server_cannot_decompress'=>'Received from client compressed HTTP request and cannot decompress', |
3802 | + 'server_decompress_fail'=>'Received from client invalid compressed HTTP request' |
3803 | + ); |
3804 | + |
3805 | + // The charset encoding used by the server for received messages and |
3806 | + // by the client for received responses when received charset cannot be determined |
3807 | + // or is not supported |
3808 | + $GLOBALS['xmlrpc_defencoding']='UTF-8'; |
3809 | + |
3810 | + // The encoding used internally by PHP. |
3811 | + // String values received as xml will be converted to this, and php strings will be converted to xml |
3812 | + // as if having been coded with this |
3813 | + $GLOBALS['xmlrpc_internalencoding']='ISO-8859-1'; |
3814 | + |
3815 | + $GLOBALS['xmlrpcName']='XML-RPC for PHP'; |
3816 | + $GLOBALS['xmlrpcVersion']='3.0.0.beta'; |
3817 | + |
3818 | + // let user errors start at 800 |
3819 | + $GLOBALS['xmlrpcerruser']=800; |
3820 | + // let XML parse errors start at 100 |
3821 | + $GLOBALS['xmlrpcerrxml']=100; |
3822 | + |
3823 | + // formulate backslashes for escaping regexp |
3824 | + // Not in use anymore since 2.0. Shall we remove it? |
3825 | + /// @deprecated |
3826 | + $GLOBALS['xmlrpc_backslash']=chr(92).chr(92); |
3827 | + |
3828 | + // set to TRUE to enable correct decoding of <NIL/> and <EX:NIL/> values |
3829 | + $GLOBALS['xmlrpc_null_extension']=false; |
3830 | + |
3831 | + // set to TRUE to enable encoding of php NULL values to <EX:NIL/> instead of <NIL/> |
3832 | + $GLOBALS['xmlrpc_null_apache_encoding']=false; |
3833 | + |
3834 | + // used to store state during parsing |
3835 | + // quick explanation of components: |
3836 | + // ac - used to accumulate values |
3837 | + // isf - used to indicate a parsing fault (2) or xmlrpcresp fault (1) |
3838 | + // isf_reason - used for storing xmlrpcresp fault string |
3839 | + // lv - used to indicate "looking for a value": implements |
3840 | + // the logic to allow values with no types to be strings |
3841 | + // params - used to store parameters in method calls |
3842 | + // method - used to store method name |
3843 | + // stack - array with genealogy of xml elements names: |
3844 | + // used to validate nesting of xmlrpc elements |
3845 | + $GLOBALS['_xh']=null; |
3846 | + |
3847 | + /** |
3848 | + * Convert a string to the correct XML representation in a target charset |
3849 | + * To help correct communication of non-ascii chars inside strings, regardless |
3850 | + * of the charset used when sending requests, parsing them, sending responses |
3851 | + * and parsing responses, an option is to convert all non-ascii chars present in the message |
3852 | + * into their equivalent 'charset entity'. Charset entities enumerated this way |
3853 | + * are independent of the charset encoding used to transmit them, and all XML |
3854 | + * parsers are bound to understand them. |
3855 | + * Note that in the std case we are not sending a charset encoding mime type |
3856 | + * along with http headers, so we are bound by RFC 3023 to emit strict us-ascii. |
3857 | + * |
3858 | + * @todo do a bit of basic benchmarking (strtr vs. str_replace) |
3859 | + * @todo make usage of iconv() or recode_string() or mb_string() where available |
3860 | + */ |
3861 | + function xmlrpc_encode_entitites($data, $src_encoding='', $dest_encoding='') |
3862 | + { |
3863 | + if ($src_encoding == '') |
3864 | + { |
3865 | + // lame, but we know no better... |
3866 | + $src_encoding = $GLOBALS['xmlrpc_internalencoding']; |
3867 | + } |
3868 | + |
3869 | + switch(strtoupper($src_encoding.'_'.$dest_encoding)) |
3870 | + { |
3871 | + case 'ISO-8859-1_': |
3872 | + case 'ISO-8859-1_US-ASCII': |
3873 | + $escaped_data = str_replace(array('&', '"', "'", '<', '>'), array('&', '"', ''', '<', '>'), $data); |
3874 | + $escaped_data = str_replace($GLOBALS['xml_iso88591_Entities']['in'], $GLOBALS['xml_iso88591_Entities']['out'], $escaped_data); |
3875 | + break; |
3876 | + case 'ISO-8859-1_UTF-8': |
3877 | + $escaped_data = str_replace(array('&', '"', "'", '<', '>'), array('&', '"', ''', '<', '>'), $data); |
3878 | + $escaped_data = utf8_encode($escaped_data); |
3879 | + break; |
3880 | + case 'ISO-8859-1_ISO-8859-1': |
3881 | + case 'US-ASCII_US-ASCII': |
3882 | + case 'US-ASCII_UTF-8': |
3883 | + case 'US-ASCII_': |
3884 | + case 'US-ASCII_ISO-8859-1': |
3885 | + case 'UTF-8_UTF-8': |
3886 | + //case 'CP1252_CP1252': |
3887 | + $escaped_data = str_replace(array('&', '"', "'", '<', '>'), array('&', '"', ''', '<', '>'), $data); |
3888 | + break; |
3889 | + case 'UTF-8_': |
3890 | + case 'UTF-8_US-ASCII': |
3891 | + case 'UTF-8_ISO-8859-1': |
3892 | + // NB: this will choke on invalid UTF-8, going most likely beyond EOF |
3893 | + $escaped_data = ''; |
3894 | + // be kind to users creating string xmlrpcvals out of different php types |
3895 | + $data = (string) $data; |
3896 | + $ns = strlen ($data); |
3897 | + for ($nn = 0; $nn < $ns; $nn++) |
3898 | + { |
3899 | + $ch = $data[$nn]; |
3900 | + $ii = ord($ch); |
3901 | + //1 7 0bbbbbbb (127) |
3902 | + if ($ii < 128) |
3903 | + { |
3904 | + /// @todo shall we replace this with a (supposedly) faster str_replace? |
3905 | + switch($ii){ |
3906 | + case 34: |
3907 | + $escaped_data .= '"'; |
3908 | + break; |
3909 | + case 38: |
3910 | + $escaped_data .= '&'; |
3911 | + break; |
3912 | + case 39: |
3913 | + $escaped_data .= '''; |
3914 | + break; |
3915 | + case 60: |
3916 | + $escaped_data .= '<'; |
3917 | + break; |
3918 | + case 62: |
3919 | + $escaped_data .= '>'; |
3920 | + break; |
3921 | + default: |
3922 | + $escaped_data .= $ch; |
3923 | + } // switch |
3924 | + } |
3925 | + //2 11 110bbbbb 10bbbbbb (2047) |
3926 | + else if ($ii>>5 == 6) |
3927 | + { |
3928 | + $b1 = ($ii & 31); |
3929 | + $ii = ord($data[$nn+1]); |
3930 | + $b2 = ($ii & 63); |
3931 | + $ii = ($b1 * 64) + $b2; |
3932 | + $ent = sprintf ('&#%d;', $ii); |
3933 | + $escaped_data .= $ent; |
3934 | + $nn += 1; |
3935 | + } |
3936 | + //3 16 1110bbbb 10bbbbbb 10bbbbbb |
3937 | + else if ($ii>>4 == 14) |
3938 | + { |
3939 | + $b1 = ($ii & 15); |
3940 | + $ii = ord($data[$nn+1]); |
3941 | + $b2 = ($ii & 63); |
3942 | + $ii = ord($data[$nn+2]); |
3943 | + $b3 = ($ii & 63); |
3944 | + $ii = ((($b1 * 64) + $b2) * 64) + $b3; |
3945 | + $ent = sprintf ('&#%d;', $ii); |
3946 | + $escaped_data .= $ent; |
3947 | + $nn += 2; |
3948 | + } |
3949 | + //4 21 11110bbb 10bbbbbb 10bbbbbb 10bbbbbb |
3950 | + else if ($ii>>3 == 30) |
3951 | + { |
3952 | + $b1 = ($ii & 7); |
3953 | + $ii = ord($data[$nn+1]); |
3954 | + $b2 = ($ii & 63); |
3955 | + $ii = ord($data[$nn+2]); |
3956 | + $b3 = ($ii & 63); |
3957 | + $ii = ord($data[$nn+3]); |
3958 | + $b4 = ($ii & 63); |
3959 | + $ii = ((((($b1 * 64) + $b2) * 64) + $b3) * 64) + $b4; |
3960 | + $ent = sprintf ('&#%d;', $ii); |
3961 | + $escaped_data .= $ent; |
3962 | + $nn += 3; |
3963 | + } |
3964 | + } |
3965 | + break; |
3966 | +/* |
3967 | + case 'CP1252_': |
3968 | + case 'CP1252_US-ASCII': |
3969 | + $escaped_data = str_replace(array('&', '"', "'", '<', '>'), array('&', '"', ''', '<', '>'), $data); |
3970 | + $escaped_data = str_replace($GLOBALS['xml_iso88591_Entities']['in'], $GLOBALS['xml_iso88591_Entities']['out'], $escaped_data); |
3971 | + $escaped_data = str_replace($GLOBALS['xml_cp1252_Entities']['in'], $GLOBALS['xml_cp1252_Entities']['out'], $escaped_data); |
3972 | + break; |
3973 | + case 'CP1252_UTF-8': |
3974 | + $escaped_data = str_replace(array('&', '"', "'", '<', '>'), array('&', '"', ''', '<', '>'), $data); |
3975 | + /// @todo we could use real UTF8 chars here instead of xml entities... (note that utf_8 encode all allone will NOT convert them) |
3976 | + $escaped_data = str_replace($GLOBALS['xml_cp1252_Entities']['in'], $GLOBALS['xml_cp1252_Entities']['out'], $escaped_data); |
3977 | + $escaped_data = utf8_encode($escaped_data); |
3978 | + break; |
3979 | + case 'CP1252_ISO-8859-1': |
3980 | + $escaped_data = str_replace(array('&', '"', "'", '<', '>'), array('&', '"', ''', '<', '>'), $data); |
3981 | + // we might as well replave all funky chars with a '?' here, but we are kind and leave it to the receiving application layer to decide what to do with these weird entities... |
3982 | + $escaped_data = str_replace($GLOBALS['xml_cp1252_Entities']['in'], $GLOBALS['xml_cp1252_Entities']['out'], $escaped_data); |
3983 | + break; |
3984 | +*/ |
3985 | + default: |
3986 | + $escaped_data = ''; |
3987 | + error_log("Converting from $src_encoding to $dest_encoding: not supported..."); |
3988 | + } |
3989 | + return $escaped_data; |
3990 | + } |
3991 | + |
3992 | + /// xml parser handler function for opening element tags |
3993 | + function xmlrpc_se($parser, $name, $attrs, $accept_single_vals=false) |
3994 | + { |
3995 | + // if invalid xmlrpc already detected, skip all processing |
3996 | + if ($GLOBALS['_xh']['isf'] < 2) |
3997 | + { |
3998 | + // check for correct element nesting |
3999 | + // top level element can only be of 2 types |
4000 | + /// @todo optimization creep: save this check into a bool variable, instead of using count() every time: |
4001 | + /// there is only a single top level element in xml anyway |
4002 | + if (count($GLOBALS['_xh']['stack']) == 0) |
4003 | + { |
4004 | + if ($name != 'METHODRESPONSE' && $name != 'METHODCALL' && ( |
4005 | + $name != 'VALUE' && !$accept_single_vals)) |
4006 | + { |
4007 | + $GLOBALS['_xh']['isf'] = 2; |
4008 | + $GLOBALS['_xh']['isf_reason'] = 'missing top level xmlrpc element'; |
4009 | + return; |
4010 | + } |
4011 | + else |
4012 | + { |
4013 | + $GLOBALS['_xh']['rt'] = strtolower($name); |
4014 | + $GLOBALS['_xh']['rt'] = strtolower($name); |
4015 | + } |
4016 | + } |
4017 | + else |
4018 | + { |
4019 | + // not top level element: see if parent is OK |
4020 | + $parent = end($GLOBALS['_xh']['stack']); |
4021 | + if (!array_key_exists($name, $GLOBALS['xmlrpc_valid_parents']) || !in_array($parent, $GLOBALS['xmlrpc_valid_parents'][$name])) |
4022 | + { |
4023 | + $GLOBALS['_xh']['isf'] = 2; |
4024 | + $GLOBALS['_xh']['isf_reason'] = "xmlrpc element $name cannot be child of $parent"; |
4025 | + return; |
4026 | + } |
4027 | + } |
4028 | + |
4029 | + switch($name) |
4030 | + { |
4031 | + // optimize for speed switch cases: most common cases first |
4032 | + case 'VALUE': |
4033 | + /// @todo we could check for 2 VALUE elements inside a MEMBER or PARAM element |
4034 | + $GLOBALS['_xh']['vt']='value'; // indicator: no value found yet |
4035 | + $GLOBALS['_xh']['ac']=''; |
4036 | + $GLOBALS['_xh']['lv']=1; |
4037 | + $GLOBALS['_xh']['php_class']=null; |
4038 | + break; |
4039 | + case 'I4': |
4040 | + case 'INT': |
4041 | + case 'STRING': |
4042 | + case 'BOOLEAN': |
4043 | + case 'DOUBLE': |
4044 | + case 'DATETIME.ISO8601': |
4045 | + case 'BASE64': |
4046 | + if ($GLOBALS['_xh']['vt']!='value') |
4047 | + { |
4048 | + //two data elements inside a value: an error occurred! |
4049 | + $GLOBALS['_xh']['isf'] = 2; |
4050 | + $GLOBALS['_xh']['isf_reason'] = "$name element following a {$GLOBALS['_xh']['vt']} element inside a single value"; |
4051 | + return; |
4052 | + } |
4053 | + $GLOBALS['_xh']['ac']=''; // reset the accumulator |
4054 | + break; |
4055 | + case 'STRUCT': |
4056 | + case 'ARRAY': |
4057 | + if ($GLOBALS['_xh']['vt']!='value') |
4058 | + { |
4059 | + //two data elements inside a value: an error occurred! |
4060 | + $GLOBALS['_xh']['isf'] = 2; |
4061 | + $GLOBALS['_xh']['isf_reason'] = "$name element following a {$GLOBALS['_xh']['vt']} element inside a single value"; |
4062 | + return; |
4063 | + } |
4064 | + // create an empty array to hold child values, and push it onto appropriate stack |
4065 | + $cur_val = array(); |
4066 | + $cur_val['values'] = array(); |
4067 | + $cur_val['type'] = $name; |
4068 | + // check for out-of-band information to rebuild php objs |
4069 | + // and in case it is found, save it |
4070 | + if (@isset($attrs['PHP_CLASS'])) |
4071 | + { |
4072 | + $cur_val['php_class'] = $attrs['PHP_CLASS']; |
4073 | + } |
4074 | + $GLOBALS['_xh']['valuestack'][] = $cur_val; |
4075 | + $GLOBALS['_xh']['vt']='data'; // be prepared for a data element next |
4076 | + break; |
4077 | + case 'DATA': |
4078 | + if ($GLOBALS['_xh']['vt']!='data') |
4079 | + { |
4080 | + //two data elements inside a value: an error occurred! |
4081 | + $GLOBALS['_xh']['isf'] = 2; |
4082 | + $GLOBALS['_xh']['isf_reason'] = "found two data elements inside an array element"; |
4083 | + return; |
4084 | + } |
4085 | + case 'METHODCALL': |
4086 | + case 'METHODRESPONSE': |
4087 | + case 'PARAMS': |
4088 | + // valid elements that add little to processing |
4089 | + break; |
4090 | + case 'METHODNAME': |
4091 | + case 'NAME': |
4092 | + /// @todo we could check for 2 NAME elements inside a MEMBER element |
4093 | + $GLOBALS['_xh']['ac']=''; |
4094 | + break; |
4095 | + case 'FAULT': |
4096 | + $GLOBALS['_xh']['isf']=1; |
4097 | + break; |
4098 | + case 'MEMBER': |
4099 | + $GLOBALS['_xh']['valuestack'][count($GLOBALS['_xh']['valuestack'])-1]['name']=''; // set member name to null, in case we do not find in the xml later on |
4100 | + //$GLOBALS['_xh']['ac']=''; |
4101 | + // Drop trough intentionally |
4102 | + case 'PARAM': |
4103 | + // clear value type, so we can check later if no value has been passed for this param/member |
4104 | + $GLOBALS['_xh']['vt']=null; |
4105 | + break; |
4106 | + case 'NIL': |
4107 | + case 'EX:NIL': |
4108 | + if ($GLOBALS['xmlrpc_null_extension']) |
4109 | + { |
4110 | + if ($GLOBALS['_xh']['vt']!='value') |
4111 | + { |
4112 | + //two data elements inside a value: an error occurred! |
4113 | + $GLOBALS['_xh']['isf'] = 2; |
4114 | + $GLOBALS['_xh']['isf_reason'] = "$name element following a {$GLOBALS['_xh']['vt']} element inside a single value"; |
4115 | + return; |
4116 | + } |
4117 | + $GLOBALS['_xh']['ac']=''; // reset the accumulator |
4118 | + break; |
4119 | + } |
4120 | + // we do not support the <NIL/> extension, so |
4121 | + // drop through intentionally |
4122 | + default: |
4123 | + /// INVALID ELEMENT: RAISE ISF so that it is later recognized!!! |
4124 | + $GLOBALS['_xh']['isf'] = 2; |
4125 | + $GLOBALS['_xh']['isf_reason'] = "found not-xmlrpc xml element $name"; |
4126 | + break; |
4127 | + } |
4128 | + |
4129 | + // Save current element name to stack, to validate nesting |
4130 | + $GLOBALS['_xh']['stack'][] = $name; |
4131 | + |
4132 | + /// @todo optimization creep: move this inside the big switch() above |
4133 | + if($name!='VALUE') |
4134 | + { |
4135 | + $GLOBALS['_xh']['lv']=0; |
4136 | + } |
4137 | + } |
4138 | + } |
4139 | + |
4140 | + /// Used in decoding xml chunks that might represent single xmlrpc values |
4141 | + function xmlrpc_se_any($parser, $name, $attrs) |
4142 | + { |
4143 | + xmlrpc_se($parser, $name, $attrs, true); |
4144 | + } |
4145 | + |
4146 | + /// xml parser handler function for close element tags |
4147 | + function xmlrpc_ee($parser, $name, $rebuild_xmlrpcvals = true) |
4148 | + { |
4149 | + if ($GLOBALS['_xh']['isf'] < 2) |
4150 | + { |
4151 | + // push this element name from stack |
4152 | + // NB: if XML validates, correct opening/closing is guaranteed and |
4153 | + // we do not have to check for $name == $curr_elem. |
4154 | + // we also checked for proper nesting at start of elements... |
4155 | + $curr_elem = array_pop($GLOBALS['_xh']['stack']); |
4156 | + |
4157 | + switch($name) |
4158 | + { |
4159 | + case 'VALUE': |
4160 | + // This if() detects if no scalar was inside <VALUE></VALUE> |
4161 | + if ($GLOBALS['_xh']['vt']=='value') |
4162 | + { |
4163 | + $GLOBALS['_xh']['value']=$GLOBALS['_xh']['ac']; |
4164 | + $GLOBALS['_xh']['vt']=$GLOBALS['xmlrpcString']; |
4165 | + } |
4166 | + |
4167 | + if ($rebuild_xmlrpcvals) |
4168 | + { |
4169 | + // build the xmlrpc val out of the data received, and substitute it |
4170 | + $temp = new xmlrpcval($GLOBALS['_xh']['value'], $GLOBALS['_xh']['vt']); |
4171 | + // in case we got info about underlying php class, save it |
4172 | + // in the object we're rebuilding |
4173 | + if (isset($GLOBALS['_xh']['php_class'])) |
4174 | + $temp->_php_class = $GLOBALS['_xh']['php_class']; |
4175 | + // check if we are inside an array or struct: |
4176 | + // if value just built is inside an array, let's move it into array on the stack |
4177 | + $vscount = count($GLOBALS['_xh']['valuestack']); |
4178 | + if ($vscount && $GLOBALS['_xh']['valuestack'][$vscount-1]['type']=='ARRAY') |
4179 | + { |
4180 | + $GLOBALS['_xh']['valuestack'][$vscount-1]['values'][] = $temp; |
4181 | + } |
4182 | + else |
4183 | + { |
4184 | + $GLOBALS['_xh']['value'] = $temp; |
4185 | + } |
4186 | + } |
4187 | + else |
4188 | + { |
4189 | + /// @todo this needs to treat correctly php-serialized objects, |
4190 | + /// since std deserializing is done by php_xmlrpc_decode, |
4191 | + /// which we will not be calling... |
4192 | + if (isset($GLOBALS['_xh']['php_class'])) |
4193 | + { |
4194 | + } |
4195 | + |
4196 | + // check if we are inside an array or struct: |
4197 | + // if value just built is inside an array, let's move it into array on the stack |
4198 | + $vscount = count($GLOBALS['_xh']['valuestack']); |
4199 | + if ($vscount && $GLOBALS['_xh']['valuestack'][$vscount-1]['type']=='ARRAY') |
4200 | + { |
4201 | + $GLOBALS['_xh']['valuestack'][$vscount-1]['values'][] = $GLOBALS['_xh']['value']; |
4202 | + } |
4203 | + } |
4204 | + break; |
4205 | + case 'BOOLEAN': |
4206 | + case 'I4': |
4207 | + case 'INT': |
4208 | + case 'STRING': |
4209 | + case 'DOUBLE': |
4210 | + case 'DATETIME.ISO8601': |
4211 | + case 'BASE64': |
4212 | + $GLOBALS['_xh']['vt']=strtolower($name); |
4213 | + /// @todo: optimization creep - remove the if/elseif cycle below |
4214 | + /// since the case() in which we are already did that |
4215 | + if ($name=='STRING') |
4216 | + { |
4217 | + $GLOBALS['_xh']['value']=$GLOBALS['_xh']['ac']; |
4218 | + } |
4219 | + elseif ($name=='DATETIME.ISO8601') |
4220 | + { |
4221 | + if (!preg_match('/^[0-9]{8}T[0-9]{2}:[0-9]{2}:[0-9]{2}$/', $GLOBALS['_xh']['ac'])) |
4222 | + { |
4223 | + error_log('XML-RPC: invalid value received in DATETIME: '.$GLOBALS['_xh']['ac']); |
4224 | + } |
4225 | + $GLOBALS['_xh']['vt']=$GLOBALS['xmlrpcDateTime']; |
4226 | + $GLOBALS['_xh']['value']=$GLOBALS['_xh']['ac']; |
4227 | + } |
4228 | + elseif ($name=='BASE64') |
4229 | + { |
4230 | + /// @todo check for failure of base64 decoding / catch warnings |
4231 | + $GLOBALS['_xh']['value']=base64_decode($GLOBALS['_xh']['ac']); |
4232 | + } |
4233 | + elseif ($name=='BOOLEAN') |
4234 | + { |
4235 | + // special case here: we translate boolean 1 or 0 into PHP |
4236 | + // constants true or false. |
4237 | + // Strings 'true' and 'false' are accepted, even though the |
4238 | + // spec never mentions them (see eg. Blogger api docs) |
4239 | + // NB: this simple checks helps a lot sanitizing input, ie no |
4240 | + // security problems around here |
4241 | + if ($GLOBALS['_xh']['ac']=='1' || strcasecmp($GLOBALS['_xh']['ac'], 'true') == 0) |
4242 | + { |
4243 | + $GLOBALS['_xh']['value']=true; |
4244 | + } |
4245 | + else |
4246 | + { |
4247 | + // log if receiveing something strange, even though we set the value to false anyway |
4248 | + if ($GLOBALS['_xh']['ac']!='0' && strcasecmp($GLOBALS['_xh']['ac'], 'false') != 0) |
4249 | + error_log('XML-RPC: invalid value received in BOOLEAN: '.$GLOBALS['_xh']['ac']); |
4250 | + $GLOBALS['_xh']['value']=false; |
4251 | + } |
4252 | + } |
4253 | + elseif ($name=='DOUBLE') |
4254 | + { |
4255 | + // we have a DOUBLE |
4256 | + // we must check that only 0123456789-.<space> are characters here |
4257 | + // NOTE: regexp could be much stricter than this... |
4258 | + if (!preg_match('/^[+-eE0123456789 \t.]+$/', $GLOBALS['_xh']['ac'])) |
4259 | + { |
4260 | + /// @todo: find a better way of throwing an error than this! |
4261 | + error_log('XML-RPC: non numeric value received in DOUBLE: '.$GLOBALS['_xh']['ac']); |
4262 | + $GLOBALS['_xh']['value']='ERROR_NON_NUMERIC_FOUND'; |
4263 | + } |
4264 | + else |
4265 | + { |
4266 | + // it's ok, add it on |
4267 | + $GLOBALS['_xh']['value']=(double)$GLOBALS['_xh']['ac']; |
4268 | + } |
4269 | + } |
4270 | + else |
4271 | + { |
4272 | + // we have an I4/INT |
4273 | + // we must check that only 0123456789-<space> are characters here |
4274 | + if (!preg_match('/^[+-]?[0123456789 \t]+$/', $GLOBALS['_xh']['ac'])) |
4275 | + { |
4276 | + /// @todo find a better way of throwing an error than this! |
4277 | + error_log('XML-RPC: non numeric value received in INT: '.$GLOBALS['_xh']['ac']); |
4278 | + $GLOBALS['_xh']['value']='ERROR_NON_NUMERIC_FOUND'; |
4279 | + } |
4280 | + else |
4281 | + { |
4282 | + // it's ok, add it on |
4283 | + $GLOBALS['_xh']['value']=(int)$GLOBALS['_xh']['ac']; |
4284 | + } |
4285 | + } |
4286 | + //$GLOBALS['_xh']['ac']=''; // is this necessary? |
4287 | + $GLOBALS['_xh']['lv']=3; // indicate we've found a value |
4288 | + break; |
4289 | + case 'NAME': |
4290 | + $GLOBALS['_xh']['valuestack'][count($GLOBALS['_xh']['valuestack'])-1]['name'] = $GLOBALS['_xh']['ac']; |
4291 | + break; |
4292 | + case 'MEMBER': |
4293 | + //$GLOBALS['_xh']['ac']=''; // is this necessary? |
4294 | + // add to array in the stack the last element built, |
4295 | + // unless no VALUE was found |
4296 | + if ($GLOBALS['_xh']['vt']) |
4297 | + { |
4298 | + $vscount = count($GLOBALS['_xh']['valuestack']); |
4299 | + $GLOBALS['_xh']['valuestack'][$vscount-1]['values'][$GLOBALS['_xh']['valuestack'][$vscount-1]['name']] = $GLOBALS['_xh']['value']; |
4300 | + } else |
4301 | + error_log('XML-RPC: missing VALUE inside STRUCT in received xml'); |
4302 | + break; |
4303 | + case 'DATA': |
4304 | + //$GLOBALS['_xh']['ac']=''; // is this necessary? |
4305 | + $GLOBALS['_xh']['vt']=null; // reset this to check for 2 data elements in a row - even if they're empty |
4306 | + break; |
4307 | + case 'STRUCT': |
4308 | + case 'ARRAY': |
4309 | + // fetch out of stack array of values, and promote it to current value |
4310 | + $curr_val = array_pop($GLOBALS['_xh']['valuestack']); |
4311 | + $GLOBALS['_xh']['value'] = $curr_val['values']; |
4312 | + $GLOBALS['_xh']['vt']=strtolower($name); |
4313 | + if (isset($curr_val['php_class'])) |
4314 | + { |
4315 | + $GLOBALS['_xh']['php_class'] = $curr_val['php_class']; |
4316 | + } |
4317 | + break; |
4318 | + case 'PARAM': |
4319 | + // add to array of params the current value, |
4320 | + // unless no VALUE was found |
4321 | + if ($GLOBALS['_xh']['vt']) |
4322 | + { |
4323 | + $GLOBALS['_xh']['params'][]=$GLOBALS['_xh']['value']; |
4324 | + $GLOBALS['_xh']['pt'][]=$GLOBALS['_xh']['vt']; |
4325 | + } |
4326 | + else |
4327 | + error_log('XML-RPC: missing VALUE inside PARAM in received xml'); |
4328 | + break; |
4329 | + case 'METHODNAME': |
4330 | + $GLOBALS['_xh']['method']=preg_replace('/^[\n\r\t ]+/', '', $GLOBALS['_xh']['ac']); |
4331 | + break; |
4332 | + case 'NIL': |
4333 | + case 'EX:NIL': |
4334 | + if ($GLOBALS['xmlrpc_null_extension']) |
4335 | + { |
4336 | + $GLOBALS['_xh']['vt']='null'; |
4337 | + $GLOBALS['_xh']['value']=null; |
4338 | + $GLOBALS['_xh']['lv']=3; |
4339 | + break; |
4340 | + } |
4341 | + // drop through intentionally if nil extension not enabled |
4342 | + case 'PARAMS': |
4343 | + case 'FAULT': |
4344 | + case 'METHODCALL': |
4345 | + case 'METHORESPONSE': |
4346 | + break; |
4347 | + default: |
4348 | + // End of INVALID ELEMENT! |
4349 | + // shall we add an assert here for unreachable code??? |
4350 | + break; |
4351 | + } |
4352 | + } |
4353 | + } |
4354 | + |
4355 | + /// Used in decoding xmlrpc requests/responses without rebuilding xmlrpc values |
4356 | + function xmlrpc_ee_fast($parser, $name) |
4357 | + { |
4358 | + xmlrpc_ee($parser, $name, false); |
4359 | + } |
4360 | + |
4361 | + /// xml parser handler function for character data |
4362 | + function xmlrpc_cd($parser, $data) |
4363 | + { |
4364 | + // skip processing if xml fault already detected |
4365 | + if ($GLOBALS['_xh']['isf'] < 2) |
4366 | + { |
4367 | + // "lookforvalue==3" means that we've found an entire value |
4368 | + // and should discard any further character data |
4369 | + if($GLOBALS['_xh']['lv']!=3) |
4370 | + { |
4371 | + // G. Giunta 2006-08-23: useless change of 'lv' from 1 to 2 |
4372 | + //if($GLOBALS['_xh']['lv']==1) |
4373 | + //{ |
4374 | + // if we've found text and we're just in a <value> then |
4375 | + // say we've found a value |
4376 | + //$GLOBALS['_xh']['lv']=2; |
4377 | + //} |
4378 | + // we always initialize the accumulator before starting parsing, anyway... |
4379 | + //if(!@isset($GLOBALS['_xh']['ac'])) |
4380 | + //{ |
4381 | + // $GLOBALS['_xh']['ac'] = ''; |
4382 | + //} |
4383 | + $GLOBALS['_xh']['ac'].=$data; |
4384 | + } |
4385 | + } |
4386 | + } |
4387 | + |
4388 | + /// xml parser handler function for 'other stuff', ie. not char data or |
4389 | + /// element start/end tag. In fact it only gets called on unknown entities... |
4390 | + function xmlrpc_dh($parser, $data) |
4391 | + { |
4392 | + // skip processing if xml fault already detected |
4393 | + if ($GLOBALS['_xh']['isf'] < 2) |
4394 | + { |
4395 | + if(substr($data, 0, 1) == '&' && substr($data, -1, 1) == ';') |
4396 | + { |
4397 | + // G. Giunta 2006-08-25: useless change of 'lv' from 1 to 2 |
4398 | + //if($GLOBALS['_xh']['lv']==1) |
4399 | + //{ |
4400 | + // $GLOBALS['_xh']['lv']=2; |
4401 | + //} |
4402 | + $GLOBALS['_xh']['ac'].=$data; |
4403 | + } |
4404 | + } |
4405 | + return true; |
4406 | + } |
4407 | + |
4408 | + class xmlrpc_client |
4409 | + { |
4410 | + var $path; |
4411 | + var $server; |
4412 | + var $port=0; |
4413 | + var $method='http'; |
4414 | + var $errno; |
4415 | + var $errstr; |
4416 | + var $debug=0; |
4417 | + var $username=''; |
4418 | + var $password=''; |
4419 | + var $authtype=1; |
4420 | + var $cert=''; |
4421 | + var $certpass=''; |
4422 | + var $cacert=''; |
4423 | + var $cacertdir=''; |
4424 | + var $key=''; |
4425 | + var $keypass=''; |
4426 | + var $verifypeer=true; |
4427 | + var $verifyhost=1; |
4428 | + var $no_multicall=false; |
4429 | + var $proxy=''; |
4430 | + var $proxyport=0; |
4431 | + var $proxy_user=''; |
4432 | + var $proxy_pass=''; |
4433 | + var $proxy_authtype=1; |
4434 | + var $cookies=array(); |
4435 | + var $extracurlopts=array(); |
4436 | + |
4437 | + /** |
4438 | + * List of http compression methods accepted by the client for responses. |
4439 | + * NB: PHP supports deflate, gzip compressions out of the box if compiled w. zlib |
4440 | + * |
4441 | + * NNB: you can set it to any non-empty array for HTTP11 and HTTPS, since |
4442 | + * in those cases it will be up to CURL to decide the compression methods |
4443 | + * it supports. You might check for the presence of 'zlib' in the output of |
4444 | + * curl_version() to determine wheter compression is supported or not |
4445 | + */ |
4446 | + var $accepted_compression = array(); |
4447 | + /** |
4448 | + * Name of compression scheme to be used for sending requests. |
4449 | + * Either null, gzip or deflate |
4450 | + */ |
4451 | + var $request_compression = ''; |
4452 | + /** |
4453 | + * CURL handle: used for keep-alive connections (PHP 4.3.8 up, see: |
4454 | + * http://curl.haxx.se/docs/faq.html#7.3) |
4455 | + */ |
4456 | + var $xmlrpc_curl_handle = null; |
4457 | + /// Wheter to use persistent connections for http 1.1 and https |
4458 | + var $keepalive = false; |
4459 | + /// Charset encodings that can be decoded without problems by the client |
4460 | + var $accepted_charset_encodings = array(); |
4461 | + /// Charset encoding to be used in serializing request. NULL = use ASCII |
4462 | + var $request_charset_encoding = ''; |
4463 | + /** |
4464 | + * Decides the content of xmlrpcresp objects returned by calls to send() |
4465 | + * valid strings are 'xmlrpcvals', 'phpvals' or 'xml' |
4466 | + */ |
4467 | + var $return_type = 'xmlrpcvals'; |
4468 | + /** |
4469 | + * Sent to servers in http headers |
4470 | + */ |
4471 | + var $user_agent; |
4472 | + |
4473 | + /** |
4474 | + * @param string $path either the complete server URL or the PATH part of the xmlrc server URL, e.g. /xmlrpc/server.php |
4475 | + * @param string $server the server name / ip address |
4476 | + * @param integer $port the port the server is listening on, defaults to 80 or 443 depending on protocol used |
4477 | + * @param string $method the http protocol variant: defaults to 'http', 'https' and 'http11' can be used if CURL is installed |
4478 | + */ |
4479 | + function xmlrpc_client($path, $server='', $port='', $method='') |
4480 | + { |
4481 | + // allow user to specify all params in $path |
4482 | + if($server == '' and $port == '' and $method == '') |
4483 | + { |
4484 | + $parts = parse_url($path); |
4485 | + $server = $parts['host']; |
4486 | + $path = isset($parts['path']) ? $parts['path'] : ''; |
4487 | + if(isset($parts['query'])) |
4488 | + { |
4489 | + $path .= '?'.$parts['query']; |
4490 | + } |
4491 | + if(isset($parts['fragment'])) |
4492 | + { |
4493 | + $path .= '#'.$parts['fragment']; |
4494 | + } |
4495 | + if(isset($parts['port'])) |
4496 | + { |
4497 | + $port = $parts['port']; |
4498 | + } |
4499 | + if(isset($parts['scheme'])) |
4500 | + { |
4501 | + $method = $parts['scheme']; |
4502 | + } |
4503 | + if(isset($parts['user'])) |
4504 | + { |
4505 | + $this->username = $parts['user']; |
4506 | + } |
4507 | + if(isset($parts['pass'])) |
4508 | + { |
4509 | + $this->password = $parts['pass']; |
4510 | + } |
4511 | + } |
4512 | + if($path == '' || $path[0] != '/') |
4513 | + { |
4514 | + $this->path='/'.$path; |
4515 | + } |
4516 | + else |
4517 | + { |
4518 | + $this->path=$path; |
4519 | + } |
4520 | + $this->server=$server; |
4521 | + if($port != '') |
4522 | + { |
4523 | + $this->port=$port; |
4524 | + } |
4525 | + if($method != '') |
4526 | + { |
4527 | + $this->method=$method; |
4528 | + } |
4529 | + |
4530 | + // if ZLIB is enabled, let the client by default accept compressed responses |
4531 | + if(function_exists('gzinflate') || ( |
4532 | + function_exists('curl_init') && (($info = curl_version()) && |
4533 | + ((is_string($info) && strpos($info, 'zlib') !== null) || isset($info['libz_version']))) |
4534 | + )) |
4535 | + { |
4536 | + $this->accepted_compression = array('gzip', 'deflate'); |
4537 | + } |
4538 | + |
4539 | + // keepalives: enabled by default |
4540 | + $this->keepalive = true; |
4541 | + |
4542 | + // by default the xml parser can support these 3 charset encodings |
4543 | + $this->accepted_charset_encodings = array('UTF-8', 'ISO-8859-1', 'US-ASCII'); |
4544 | + |
4545 | + // initialize user_agent string |
4546 | + $this->user_agent = $GLOBALS['xmlrpcName'] . ' ' . $GLOBALS['xmlrpcVersion']; |
4547 | + } |
4548 | + |
4549 | + /** |
4550 | + * Enables/disables the echoing to screen of the xmlrpc responses received |
4551 | + * @param integer $debug values 0, 1 and 2 are supported (2 = echo sent msg too, before received response) |
4552 | + * @access public |
4553 | + */ |
4554 | + function setDebug($in) |
4555 | + { |
4556 | + $this->debug=$in; |
4557 | + } |
4558 | + |
4559 | + /** |
4560 | + * Add some http BASIC AUTH credentials, used by the client to authenticate |
4561 | + * @param string $u username |
4562 | + * @param string $p password |
4563 | + * @param integer $t auth type. See curl_setopt man page for supported auth types. Defaults to CURLAUTH_BASIC (basic auth) |
4564 | + * @access public |
4565 | + */ |
4566 | + function setCredentials($u, $p, $t=1) |
4567 | + { |
4568 | + $this->username=$u; |
4569 | + $this->password=$p; |
4570 | + $this->authtype=$t; |
4571 | + } |
4572 | + |
4573 | + /** |
4574 | + * Add a client-side https certificate |
4575 | + * @param string $cert |
4576 | + * @param string $certpass |
4577 | + * @access public |
4578 | + */ |
4579 | + function setCertificate($cert, $certpass) |
4580 | + { |
4581 | + $this->cert = $cert; |
4582 | + $this->certpass = $certpass; |
4583 | + } |
4584 | + |
4585 | + /** |
4586 | + * Add a CA certificate to verify server with (see man page about |
4587 | + * CURLOPT_CAINFO for more details |
4588 | + * @param string $cacert certificate file name (or dir holding certificates) |
4589 | + * @param bool $is_dir set to true to indicate cacert is a dir. defaults to false |
4590 | + * @access public |
4591 | + */ |
4592 | + function setCaCertificate($cacert, $is_dir=false) |
4593 | + { |
4594 | + if ($is_dir) |
4595 | + { |
4596 | + $this->cacertdir = $cacert; |
4597 | + } |
4598 | + else |
4599 | + { |
4600 | + $this->cacert = $cacert; |
4601 | + } |
4602 | + } |
4603 | + |
4604 | + /** |
4605 | + * Set attributes for SSL communication: private SSL key |
4606 | + * NB: does not work in older php/curl installs |
4607 | + * Thanks to Daniel Convissor |
4608 | + * @param string $key The name of a file containing a private SSL key |
4609 | + * @param string $keypass The secret password needed to use the private SSL key |
4610 | + * @access public |
4611 | + */ |
4612 | + function setKey($key, $keypass) |
4613 | + { |
4614 | + $this->key = $key; |
4615 | + $this->keypass = $keypass; |
4616 | + } |
4617 | + |
4618 | + /** |
4619 | + * Set attributes for SSL communication: verify server certificate |
4620 | + * @param bool $i enable/disable verification of peer certificate |
4621 | + * @access public |
4622 | + */ |
4623 | + function setSSLVerifyPeer($i) |
4624 | + { |
4625 | + $this->verifypeer = $i; |
4626 | + } |
4627 | + |
4628 | + /** |
4629 | + * Set attributes for SSL communication: verify match of server cert w. hostname |
4630 | + * @param int $i |
4631 | + * @access public |
4632 | + */ |
4633 | + function setSSLVerifyHost($i) |
4634 | + { |
4635 | + $this->verifyhost = $i; |
4636 | + } |
4637 | + |
4638 | + /** |
4639 | + * Set proxy info |
4640 | + * @param string $proxyhost |
4641 | + * @param string $proxyport Defaults to 8080 for HTTP and 443 for HTTPS |
4642 | + * @param string $proxyusername Leave blank if proxy has public access |
4643 | + * @param string $proxypassword Leave blank if proxy has public access |
4644 | + * @param int $proxyauthtype set to constant CURLAUTH_NTLM to use NTLM auth with proxy |
4645 | + * @access public |
4646 | + */ |
4647 | + function setProxy($proxyhost, $proxyport, $proxyusername = '', $proxypassword = '', $proxyauthtype = 1) |
4648 | + { |
4649 | + $this->proxy = $proxyhost; |
4650 | + $this->proxyport = $proxyport; |
4651 | + $this->proxy_user = $proxyusername; |
4652 | + $this->proxy_pass = $proxypassword; |
4653 | + $this->proxy_authtype = $proxyauthtype; |
4654 | + } |
4655 | + |
4656 | + /** |
4657 | + * Enables/disables reception of compressed xmlrpc responses. |
4658 | + * Note that enabling reception of compressed responses merely adds some standard |
4659 | + * http headers to xmlrpc requests. It is up to the xmlrpc server to return |
4660 | + * compressed responses when receiving such requests. |
4661 | + * @param string $compmethod either 'gzip', 'deflate', 'any' or '' |
4662 | + * @access public |
4663 | + */ |
4664 | + function setAcceptedCompression($compmethod) |
4665 | + { |
4666 | + if ($compmethod == 'any') |
4667 | + $this->accepted_compression = array('gzip', 'deflate'); |
4668 | + else |
4669 | + $this->accepted_compression = array($compmethod); |
4670 | + } |
4671 | + |
4672 | + /** |
4673 | + * Enables/disables http compression of xmlrpc request. |
4674 | + * Take care when sending compressed requests: servers might not support them |
4675 | + * (and automatic fallback to uncompressed requests is not yet implemented) |
4676 | + * @param string $compmethod either 'gzip', 'deflate' or '' |
4677 | + * @access public |
4678 | + */ |
4679 | + function setRequestCompression($compmethod) |
4680 | + { |
4681 | + $this->request_compression = $compmethod; |
4682 | + } |
4683 | + |
4684 | + /** |
4685 | + * Adds a cookie to list of cookies that will be sent to server. |
4686 | + * NB: setting any param but name and value will turn the cookie into a 'version 1' cookie: |
4687 | + * do not do it unless you know what you are doing |
4688 | + * @param string $name |
4689 | + * @param string $value |
4690 | + * @param string $path |
4691 | + * @param string $domain |
4692 | + * @param int $port |
4693 | + * @access public |
4694 | + * |
4695 | + * @todo check correctness of urlencoding cookie value (copied from php way of doing it...) |
4696 | + */ |
4697 | + function setCookie($name, $value='', $path='', $domain='', $port=null) |
4698 | + { |
4699 | + $this->cookies[$name]['value'] = urlencode($value); |
4700 | + if ($path || $domain || $port) |
4701 | + { |
4702 | + $this->cookies[$name]['path'] = $path; |
4703 | + $this->cookies[$name]['domain'] = $domain; |
4704 | + $this->cookies[$name]['port'] = $port; |
4705 | + $this->cookies[$name]['version'] = 1; |
4706 | + } |
4707 | + else |
4708 | + { |
4709 | + $this->cookies[$name]['version'] = 0; |
4710 | + } |
4711 | + } |
4712 | + |
4713 | + /** |
4714 | + * Directly set cURL options, for extra flexibility |
4715 | + * It allows eg. to bind client to a specific IP interface / address |
4716 | + * @param $options array |
4717 | + */ |
4718 | + function SetCurlOptions( $options ) |
4719 | + { |
4720 | + $this->extracurlopts = $options; |
4721 | + } |
4722 | + |
4723 | + /** |
4724 | + * Set user-agent string that will be used by this client instance |
4725 | + * in http headers sent to the server |
4726 | + */ |
4727 | + function SetUserAgent( $agentstring ) |
4728 | + { |
4729 | + $this->user_agent = $agentstring; |
4730 | + } |
4731 | + |
4732 | + /** |
4733 | + * Send an xmlrpc request |
4734 | + * @param mixed $msg The message object, or an array of messages for using multicall, or the complete xml representation of a request |
4735 | + * @param integer $timeout Connection timeout, in seconds, If unspecified, a platform specific timeout will apply |
4736 | + * @param string $method if left unspecified, the http protocol chosen during creation of the object will be used |
4737 | + * @return xmlrpcresp |
4738 | + * @access public |
4739 | + */ |
4740 | + function& send($msg, $timeout=0, $method='') |
4741 | + { |
4742 | + // if user deos not specify http protocol, use native method of this client |
4743 | + // (i.e. method set during call to constructor) |
4744 | + if($method == '') |
4745 | + { |
4746 | + $method = $this->method; |
4747 | + } |
4748 | + |
4749 | + if(is_array($msg)) |
4750 | + { |
4751 | + // $msg is an array of xmlrpcmsg's |
4752 | + $r = $this->multicall($msg, $timeout, $method); |
4753 | + return $r; |
4754 | + } |
4755 | + elseif(is_string($msg)) |
4756 | + { |
4757 | + $n = new xmlrpcmsg(''); |
4758 | + $n->payload = $msg; |
4759 | + $msg = $n; |
4760 | + } |
4761 | + |
4762 | + // where msg is an xmlrpcmsg |
4763 | + $msg->debug=$this->debug; |
4764 | + |
4765 | + if($method == 'https') |
4766 | + { |
4767 | + $r =& $this->sendPayloadHTTPS( |
4768 | + $msg, |
4769 | + $this->server, |
4770 | + $this->port, |
4771 | + $timeout, |
4772 | + $this->username, |
4773 | + $this->password, |
4774 | + $this->authtype, |
4775 | + $this->cert, |
4776 | + $this->certpass, |
4777 | + $this->cacert, |
4778 | + $this->cacertdir, |
4779 | + $this->proxy, |
4780 | + $this->proxyport, |
4781 | + $this->proxy_user, |
4782 | + $this->proxy_pass, |
4783 | + $this->proxy_authtype, |
4784 | + $this->keepalive, |
4785 | + $this->key, |
4786 | + $this->keypass |
4787 | + ); |
4788 | + } |
4789 | + elseif($method == 'http11') |
4790 | + { |
4791 | + $r =& $this->sendPayloadCURL( |
4792 | + $msg, |
4793 | + $this->server, |
4794 | + $this->port, |
4795 | + $timeout, |
4796 | + $this->username, |
4797 | + $this->password, |
4798 | + $this->authtype, |
4799 | + null, |
4800 | + null, |
4801 | + null, |
4802 | + null, |
4803 | + $this->proxy, |
4804 | + $this->proxyport, |
4805 | + $this->proxy_user, |
4806 | + $this->proxy_pass, |
4807 | + $this->proxy_authtype, |
4808 | + 'http', |
4809 | + $this->keepalive |
4810 | + ); |
4811 | + } |
4812 | + else |
4813 | + { |
4814 | + $r =& $this->sendPayloadHTTP10( |
4815 | + $msg, |
4816 | + $this->server, |
4817 | + $this->port, |
4818 | + $timeout, |
4819 | + $this->username, |
4820 | + $this->password, |
4821 | + $this->authtype, |
4822 | + $this->proxy, |
4823 | + $this->proxyport, |
4824 | + $this->proxy_user, |
4825 | + $this->proxy_pass, |
4826 | + $this->proxy_authtype |
4827 | + ); |
4828 | + } |
4829 | + |
4830 | + return $r; |
4831 | + } |
4832 | + |
4833 | + /** |
4834 | + * @access private |
4835 | + */ |
4836 | + function &sendPayloadHTTP10($msg, $server, $port, $timeout=0, |
4837 | + $username='', $password='', $authtype=1, $proxyhost='', |
4838 | + $proxyport=0, $proxyusername='', $proxypassword='', $proxyauthtype=1) |
4839 | + { |
4840 | + if($port==0) |
4841 | + { |
4842 | + $port=80; |
4843 | + } |
4844 | + |
4845 | + // Only create the payload if it was not created previously |
4846 | + if(empty($msg->payload)) |
4847 | + { |
4848 | + $msg->createPayload($this->request_charset_encoding); |
4849 | + } |
4850 | + |
4851 | + $payload = $msg->payload; |
4852 | + // Deflate request body and set appropriate request headers |
4853 | + if(function_exists('gzdeflate') && ($this->request_compression == 'gzip' || $this->request_compression == 'deflate')) |
4854 | + { |
4855 | + if($this->request_compression == 'gzip') |
4856 | + { |
4857 | + $a = @gzencode($payload); |
4858 | + if($a) |
4859 | + { |
4860 | + $payload = $a; |
4861 | + $encoding_hdr = "Content-Encoding: gzip\r\n"; |
4862 | + } |
4863 | + } |
4864 | + else |
4865 | + { |
4866 | + $a = @gzcompress($payload); |
4867 | + if($a) |
4868 | + { |
4869 | + $payload = $a; |
4870 | + $encoding_hdr = "Content-Encoding: deflate\r\n"; |
4871 | + } |
4872 | + } |
4873 | + } |
4874 | + else |
4875 | + { |
4876 | + $encoding_hdr = ''; |
4877 | + } |
4878 | + |
4879 | + // thanks to Grant Rauscher <grant7@firstworld.net> for this |
4880 | + $credentials=''; |
4881 | + if($username!='') |
4882 | + { |
4883 | + $credentials='Authorization: Basic ' . base64_encode($username . ':' . $password) . "\r\n"; |
4884 | + if ($authtype != 1) |
4885 | + { |
4886 | + error_log('XML-RPC: '.__METHOD__.': warning. Only Basic auth is supported with HTTP 1.0'); |
4887 | + } |
4888 | + } |
4889 | + |
4890 | + $accepted_encoding = ''; |
4891 | + if(is_array($this->accepted_compression) && count($this->accepted_compression)) |
4892 | + { |
4893 | + $accepted_encoding = 'Accept-Encoding: ' . implode(', ', $this->accepted_compression) . "\r\n"; |
4894 | + } |
4895 | + |
4896 | + $proxy_credentials = ''; |
4897 | + if($proxyhost) |
4898 | + { |
4899 | + if($proxyport == 0) |
4900 | + { |
4901 | + $proxyport = 8080; |
4902 | + } |
4903 | + $connectserver = $proxyhost; |
4904 | + $connectport = $proxyport; |
4905 | + $uri = 'http://'.$server.':'.$port.$this->path; |
4906 | + if($proxyusername != '') |
4907 | + { |
4908 | + if ($proxyauthtype != 1) |
4909 | + { |
4910 | + error_log('XML-RPC: '.__METHOD__.': warning. Only Basic auth to proxy is supported with HTTP 1.0'); |
4911 | + } |
4912 | + $proxy_credentials = 'Proxy-Authorization: Basic ' . base64_encode($proxyusername.':'.$proxypassword) . "\r\n"; |
4913 | + } |
4914 | + } |
4915 | + else |
4916 | + { |
4917 | + $connectserver = $server; |
4918 | + $connectport = $port; |
4919 | + $uri = $this->path; |
4920 | + } |
4921 | + |
4922 | + // Cookie generation, as per rfc2965 (version 1 cookies) or |
4923 | + // netscape's rules (version 0 cookies) |
4924 | + $cookieheader=''; |
4925 | + if (count($this->cookies)) |
4926 | + { |
4927 | + $version = ''; |
4928 | + foreach ($this->cookies as $name => $cookie) |
4929 | + { |
4930 | + if ($cookie['version']) |
4931 | + { |
4932 | + $version = ' $Version="' . $cookie['version'] . '";'; |
4933 | + $cookieheader .= ' ' . $name . '="' . $cookie['value'] . '";'; |
4934 | + if ($cookie['path']) |
4935 | + $cookieheader .= ' $Path="' . $cookie['path'] . '";'; |
4936 | + if ($cookie['domain']) |
4937 | + $cookieheader .= ' $Domain="' . $cookie['domain'] . '";'; |
4938 | + if ($cookie['port']) |
4939 | + $cookieheader .= ' $Port="' . $cookie['port'] . '";'; |
4940 | + } |
4941 | + else |
4942 | + { |
4943 | + $cookieheader .= ' ' . $name . '=' . $cookie['value'] . ";"; |
4944 | + } |
4945 | + } |
4946 | + $cookieheader = 'Cookie:' . $version . substr($cookieheader, 0, -1) . "\r\n"; |
4947 | + } |
4948 | + |
4949 | + $op= 'POST ' . $uri. " HTTP/1.0\r\n" . |
4950 | + 'User-Agent: ' . $this->user_agent . "\r\n" . |
4951 | + 'Host: '. $server . ':' . $port . "\r\n" . |
4952 | + $credentials . |
4953 | + $proxy_credentials . |
4954 | + $accepted_encoding . |
4955 | + $encoding_hdr . |
4956 | + 'Accept-Charset: ' . implode(',', $this->accepted_charset_encodings) . "\r\n" . |
4957 | + $cookieheader . |
4958 | + 'Content-Type: ' . $msg->content_type . "\r\nContent-Length: " . |
4959 | + strlen($payload) . "\r\n\r\n" . |
4960 | + $payload; |
4961 | + |
4962 | + if($this->debug > 1) |
4963 | + { |
4964 | + print "<PRE>\n---SENDING---\n" . htmlentities($op) . "\n---END---\n</PRE>"; |
4965 | + // let the client see this now in case http times out... |
4966 | + flush(); |
4967 | + } |
4968 | + |
4969 | + if($timeout>0) |
4970 | + { |
4971 | + $fp=@fsockopen($connectserver, $connectport, $this->errno, $this->errstr, $timeout); |
4972 | + } |
4973 | + else |
4974 | + { |
4975 | + $fp=@fsockopen($connectserver, $connectport, $this->errno, $this->errstr); |
4976 | + } |
4977 | + if($fp) |
4978 | + { |
4979 | + if($timeout>0 && function_exists('stream_set_timeout')) |
4980 | + { |
4981 | + stream_set_timeout($fp, $timeout); |
4982 | + } |
4983 | + } |
4984 | + else |
4985 | + { |
4986 | + $this->errstr='Connect error: '.$this->errstr; |
4987 | + $r=new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['http_error'], $this->errstr . ' (' . $this->errno . ')'); |
4988 | + return $r; |
4989 | + } |
4990 | + |
4991 | + if(!fputs($fp, $op, strlen($op))) |
4992 | + { |
4993 | + fclose($fp); |
4994 | + $this->errstr='Write error'; |
4995 | + $r=new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['http_error'], $this->errstr); |
4996 | + return $r; |
4997 | + } |
4998 | + else |
4999 | + { |
5000 | + // reset errno and errstr on succesful socket connection |