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