Merge lp:~magentoerpconnect-community/magentoerpconnect/magento-module-with-crm_claim-integration into lp:~magentoerpconnect-core-editors/magentoerpconnect/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
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.

Description of the change

This Magento module enables Magento users to create a claim (crm_claim) in OpenERP from Magento using OpenERP API.

To post a comment you must log in.
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

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added directory 'Openlabs_OpenERPConnector-1.1.0'
=== added directory 'Openlabs_OpenERPConnector-1.1.0/Openlabs'
=== added directory 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector'
=== added directory 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Helper'
=== added file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Helper/Data.php'
--- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Helper/Data.php 1970-01-01 00:00:00 +0000
+++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Helper/Data.php 2012-08-10 13:28:19 +0000
@@ -0,0 +1,6 @@
1<?php
2class Openlabs_OpenERPConnector_Helper_Data extends Mage_Core_Helper_Abstract
3{
4 //Linux4ever_MagentoXtender_Model_Api
5}
6?>
0\ No newline at end of file7\ No newline at end of file
18
=== added directory 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model'
=== added directory 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog'
=== added file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Categories.php'
--- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Categories.php 1970-01-01 00:00:00 +0000
+++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Categories.php 2012-08-10 13:28:19 +0000
@@ -0,0 +1,111 @@
1<?php
2
3
4/**
5 * @author Sharoon Thomas
6 * Inspired from Dieter's Magento Extender
7 * @copyright 2009
8 */
9
10class Openlabs_OpenERPConnector_Model_Olcatalog_Categories extends Mage_Catalog_Model_Api_Resource
11{
12 public function items($filters = null) {
13 try {
14 $collection = Mage :: getModel('catalog/category/attribute')->getCollection()->addAttributeToSelect('image');
15 } catch (Mage_Core_Exception $e) {
16 $this->_fault('category_not_exists');
17 }
18 if (is_array($filters)) {
19 try {
20 foreach ($filters as $field => $value) {
21 $collection->addFieldToFilter($field, $value);
22 }
23 } catch (Mage_Core_Exception $e) {
24 $this->_fault('filters_invalid', $e->getMessage());
25 // If we are adding filter on non-existent attribute
26 }
27 }
28 $result = array ();
29 foreach ($collection as $category) {
30 //$result[] = $customer->toArray();
31 $result[] = array (
32 'category_id' => $category->getId(),
33 'image' => $category->getImage(),
34 );
35 }
36 return $result;
37 }
38
39 public function info($categoryId = null) {
40 if (is_numeric($categoryId)) {
41 try {
42 $collection = Mage :: getModel('catalog/category/attribute')->load($categoryId)->getCollection()->addAttributeToSelect('image');
43 $result = array ();
44 foreach ($collection as $category) {
45 //$result[] = $customer->toArray();
46 if ($category->getId() == $categoryId) {
47 $image = $category->getImage();
48 if ($image) {
49 $path = Mage :: getBaseDir('media') . DS . 'catalog' . DS . 'category' . DS;
50 $fullpath = $path . $image;
51 try {
52 $fp = fopen($fullpath, "rb");
53 $imagebin = fread($fp, filesize($fullpath));
54 $img_data = base64_encode($imagebin);
55 fclose($fp);
56 } catch (Exception $e) {
57 $this->_fault('not_media');
58 }
59 }
60 $result[] = array (
61 'category_id' => $category->getId(),
62 'image' => $category->getImage(),
63 'image_data' => $img_data
64 );
65 }
66 }
67
68 return $result;
69
70 } catch (Mage_Core_Exception $e) {
71 $this->_fault('group_not_exists');
72 }
73
74 }
75
76 }
77
78public function create($filename,$imgdata) {
79 if ($filename)
80 {
81 $path = Mage :: getBaseDir('media') . DS . 'catalog' . DS . 'category' . DS;
82 $fullpath = $path . $filename;
83 try
84 {
85 $fp = fopen($fullpath, "w");
86 if ($fp==false)
87 {
88 return "Error in file creation";
89 }
90 $img_data = base64_decode($imgdata);
91 $imagebin = fwrite($fp,$img_data);
92 fclose($fp);
93 return $imagebin;
94 }
95 catch (Exception $e)
96 {
97 $this->_fault('not_created');
98 }
99 return False;
100 }
101}
102public function update($something=null)
103{
104 return "Not implemented yet";
105}
106public function remove($something=null)
107{
108 return "Not implemented yet";
109}
110}
111?>
0112
=== added directory 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Product'
=== added file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Product/Attribute.php'
--- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Product/Attribute.php 1970-01-01 00:00:00 +0000
+++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Product/Attribute.php 2012-08-10 13:28:19 +0000
@@ -0,0 +1,109 @@
1<?php
2
3
4/**
5 * @author Sharoon Thomas
6 * Inspired from Dieter's Magento Extender
7 * @copyright 2009
8 */
9
10class Openlabs_OpenERPConnector_Model_Olcatalog_Product_Attribute extends Mage_Catalog_Model_Api_Resource {
11 public function __construct() {
12 $this->_storeIdSessionField = 'product_store_id';
13 $this->_ignoredAttributeCodes[] = 'type_id';
14 $this->_ignoredAttributeTypes[] = 'gallery';
15 $this->_ignoredAttributeTypes[] = 'media_image';
16 }
17
18 /**
19 * Retrieve attributes from specified attribute set
20 *
21 * @param int $setId
22 * @return array
23 */
24 public function relations($setId){
25 $attributes = Mage :: getModel('catalog/product')->getResource()->loadAllAttributes()->getSortedAttributes($setId);
26 $result = array ();
27 foreach ($attributes as $attribute){
28 $result[] = Array(
29 'attribute_id' => $attribute->getId()
30 );
31 }
32 return $result;
33
34 }
35 public function items($setId) {
36 $attributes = Mage :: getModel('catalog/product')->getResource()->loadAllAttributes()->getSortedAttributes($setId);
37 $result = array ();
38
39 foreach ($attributes as $attribute) {
40 /* @var $attribute Mage_Catalog_Model_Resource_Eav_Attribute */
41 if ((!$attribute->getId() || $attribute->isInSet($setId)) && $this->_isAllowedAttribute($attribute)) {
42
43 if (!$attribute->getId() || $attribute->isScopeGlobal()) {
44 $scope = 'global';
45 }
46 elseif ($attribute->isScopeWebsite()) {
47 $scope = 'website';
48 } else {
49 $scope = 'store';
50 }
51
52 /*$result[] = array (
53 'attribute_id' => $attribute->getId(),
54 'code' => $attribute->getAttributeCode(),
55 'type' => $attribute->getFrontendInput(),
56 'required' => $attribute->getIsRequired(),
57 'attributeset' => $attribute->getattribute_set_info(),
58 'scope' => $scope
59 );*/
60 //Override hooray
61 $attribute['scope'] = $scope;
62 $result[]=$attribute->toArray();
63 }
64 }
65
66 return $result;
67 }
68
69 public function info($attributeId) {
70 try {
71 return 'hello';
72 $attribute = Mage :: getModel('catalog/product')->getResource()->getAttribute($attributeId);
73 return $attribute->toArray();
74 } catch (Exception $e) {
75 $this->_fault('not_exists');
76 }
77 }
78 /**
79 * Retrieve attribute options
80 *
81 * @param int $attributeId
82 * @param string|int $store
83 * @return array
84 */
85 public function options($attributeId, $store = null) {
86 $storeId = $this->_getStoreId($store);
87 $attribute = Mage :: getModel('catalog/product')->setStoreId($storeId)->getResource()->getAttribute($attributeId)->setStoreId($storeId);
88
89 /* @var $attribute Mage_Catalog_Model_Entity_Attribute */
90 if (!$attribute) {
91 $this->_fault('not_exists');
92 }
93
94 $options = array ();
95 foreach ($attribute->getSource()->getAllOptions() as $optionId => $optionValue) {
96 if (is_array($optionValue)) {
97 $options[] = $optionValue;
98 }
99 else {
100 $options[] = array (
101 'value' => $optionId,
102 'label' => $optionValue
103 );
104 }
105 }
106 return $options;
107 }
108}
109?>
0110
=== added file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Product/Attributegroup.php'
--- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Product/Attributegroup.php 1970-01-01 00:00:00 +0000
+++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Product/Attributegroup.php 2012-08-10 13:28:19 +0000
@@ -0,0 +1,167 @@
1<?php
2
3
4/**
5 * @author Sharoon Thomas
6 * Inspired from Dieter's Magento Extender
7 * @copyright 2009
8 */
9
10class Openlabs_OpenERPConnector_Model_Olcatalog_Product_Attributegroup extends Mage_Catalog_Model_Api_Resource {
11 public function olditems($setId = null) {
12 $groups = Mage :: getModel('eav/entity_attribute_group')->getResourceCollection();
13
14 if (!is_null($setId) && !empty ($setId) && is_numeric($setId)) {
15 $groups->setAttributeSetFilter($setId);
16 }
17
18 $groups->load();
19
20 $arrGroups = array ();
21
22 foreach ($groups as $group) {
23 $arrGroups[] = array (
24 'attribute_group_id' => $group->getAttributeGroupId(),
25 'attribute_set_id' => $group->getAttributeSetId(),
26 'attribute_group_name' => $group->getAttributeGroupName(),
27 'sort_order' => $group->getSortOrder(),
28 'default_id' => $group->getDefaultId()
29 );
30 }
31
32 return $arrGroups;
33 }
34
35 public function items($filters = null) {
36 try {
37 $collection = Mage :: getModel('eav/entity_attribute_group')->getCollection();
38 } catch (Mage_Core_Exception $e) {
39 $this->_fault('group_not_exists');
40 }
41
42 if (is_array($filters)) {
43 try {
44 foreach ($filters as $field => $value) {
45 $collection->addFieldToFilter($field, $value);
46 }
47 } catch (Mage_Core_Exception $e) {
48 $this->_fault('filters_invalid', $e->getMessage());
49 // If we are adding filter on non-existent attribute
50 }
51 }
52
53 $result = array ();
54 foreach ($collection as $collection_item) {
55 $result[] = $collection_item->toArray();
56 }
57
58 return $result;
59
60 }
61 /*
62 <param><value><string>cl19t0dqhmheafqc0ccdeejc76</string></value></param>
63 <param><value><string>catalog_product_attribute_group.create</string></value></param>
64 <param>
65 <value>
66 <array>
67 <data>
68 <value><i4>26</i4></value>
69 <value><string>Leonelle</string></value>
70 </data>
71 </array>
72 </value>
73 </param>
74 */
75 public function create($setId, array $data) {
76 try {
77 // $attrOption = Mage_Eav_Model_Entity_Attribute_Group
78 $attrOption = Mage :: getModel("eav/entity_attribute_group");
79
80 $attrOption->addData($data);
81
82 // check if there already exists a group with the give groupname
83 if ($attrOption->itemExists()) {
84 $this->_fault("group_already_exists");
85 }
86
87 $attrOption->save();
88
89 return (int) $attrOption->getAttributeGroupId();
90 } catch (Exception $ex) {
91 return false;
92 }
93 }
94 /*
95 <param><value><string>cl19t0dqhmheafqc0ccdeejc76</string></value></param>
96 <param><value><string>catalog_product_attribute_group.update</string></value></param>
97 <param>
98 <value>
99 <array>
100 <data>
101 <value><i4>85</i4></value>
102 <value><string>Leonelle2</string></value>
103 <value><i4>85</i4></value>
104 <value><i4>85</i4></value>
105 </data>
106 </array>
107 </value>
108 </param>
109 */
110 public function update(array $data) {
111 try {
112 // $attrOption = Mage_Eav_Model_Entity_Attribute_Group
113 $attrOption = Mage :: getModel("eav/entity_attribute_group");
114
115 $attrOption->load($data["attribute_group_id"]);
116
117 // check if the requested group exists...
118 if (!$attrOption->getAttributeGroupId()) {
119 $this->_fault("group_not_exists");
120 }
121
122 $attrOption->addData($data);
123
124 $attrOption->save();
125
126 return true;
127 } catch (Exception $ex) {
128 return false;
129 }
130 }
131
132 /*
133 <param><value><string>cl19t0dqhmheafqc0ccdeejc76</string></value></param>
134 <param><value><string>catalog_product_attribute_group.delete</string></value></param>
135 <param>
136 <value>
137 <array>
138 <data>
139 <value><i4>85</i4></value>
140 </data>
141 </array>
142 </value>
143 </param>
144 */
145 public function delete($groupId) {
146 try {
147 // $attrOption = Mage_Eav_Model_Entity_Attribute_Group
148 $attrOption = Mage :: getModel("eav/entity_attribute_group");
149
150 $attrOption->load($groupId);
151
152 // check if the requested group exists...
153 if (!$attrOption->getAttributeGroupId()) {
154 $this->_fault("group_not_exists");
155 }
156
157 // save data
158 $attrOption->delete();
159
160 return true;
161 } catch (Exception $ex) {
162 return false;
163 }
164 }
165
166}
167?>
0168
=== added file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Product/Attributeset.php'
--- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Product/Attributeset.php 1970-01-01 00:00:00 +0000
+++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Product/Attributeset.php 2012-08-10 13:28:19 +0000
@@ -0,0 +1,58 @@
1<?php
2/**
3 * Magento
4 *
5 * NOTICE OF LICENSE
6 *
7 * This source file is subject to the Open Software License (OSL 3.0)
8 * that is bundled with this package in the file LICENSE.txt.
9 * It is also available through the world-wide-web at this URL:
10 * http://opensource.org/licenses/osl-3.0.php
11 * If you did not receive a copy of the license and are unable to
12 * obtain it through the world-wide-web, please send an email
13 * to license@magentocommerce.com so we can send you a copy immediately.
14 *
15 * DISCLAIMER
16 *
17 * Do not edit or add to this file if you wish to upgrade Magento to newer
18 * versions in the future. If you wish to customize Magento for your
19 * needs please refer to http://www.magentocommerce.com for more information.
20 *
21 * @category Mage
22 * @package Mage_Catalog
23 * @copyright Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
24 * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25 */
26
27/**
28 * Catalog product attribute set api
29 *
30 * @category Mage
31 * @package Mage_Catalog
32 * @author Magento Core Team <core@magentocommerce.com>
33 */
34class Openlabs_OpenERPConnector_Model_Olcatalog_Product_Attributeset extends Mage_Api_Model_Resource_Abstract
35{
36 /**
37 * Retrieve attribute set list
38 *
39 * @return array
40 */
41 public function items()
42 {
43 $entityType = Mage::getModel('catalog/product')->getResource()->getEntityType();
44 $collection = Mage::getResourceModel('eav/entity_attribute_set_collection')
45 ->setEntityTypeFilter($entityType->getId());
46
47 $result = array();
48 foreach ($collection as $attributeSet) {
49 $result[] = array(
50 'attribute_set_id' => $attributeSet->getId(),
51 'attribute_set_name' => $attributeSet->getAttributeSetName()
52 );
53
54 }
55
56 return $result;
57 }
58} // Class Mage_Catalog_Model_Product_Attribute_Set_Api End
0\ No newline at end of file59\ No newline at end of file
160
=== added file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Product/Tierprice.php'
--- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Product/Tierprice.php 1970-01-01 00:00:00 +0000
+++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Product/Tierprice.php 2012-08-10 13:28:19 +0000
@@ -0,0 +1,71 @@
1<?php
2
3/**
4 * Magento
5 *
6 * NOTICE OF LICENSE
7 *
8 * This source file is subject to the Open Software License (OSL 3.0)
9 * that is bundled with this package in the file LICENSE.txt.
10 * It is also available through the world-wide-web at this URL:
11 * http://opensource.org/licenses/osl-3.0.php
12 * If you did not receive a copy of the license and are unable to
13 * obtain it through the world-wide-web, please send an email
14 * to license@magentocommerce.com so we can send you a copy immediately.
15 *
16 * DISCLAIMER
17 *
18 * Do not edit or add to this file if you wish to upgrade Magento to newer
19 * versions in the future. If you wish to customize Magento for your
20 * needs please refer to http://www.magentocommerce.com for more information.
21 *
22 * @category Mage
23 * @package Mage_Catalog
24 * @copyright Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
25 * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
26 */
27
28/**
29 * Catalog Product tier price api
30 *
31 * @category Mage
32 * @package Mage_Catalog
33 * @author Magento Core Team <core@magentocommerce.com>
34 */
35class Openlabs_OpenERPConnector_Model_Olcatalog_Product_Tierprice extends Mage_Catalog_Model_Api_Resource {
36 const ATTRIBUTE_CODE = 'tier_price';
37
38
39 public function items($productIds=null) {
40 if (is_array($productIds)) {
41 $result = array ();
42 foreach ($productIds as $productId) {
43 $product = Mage :: getModel('catalog/product')->load($productId);
44 if (!$product->getId()) {
45 $this->_fault('product_not_exists');
46 }
47 $tierPrices = $product->getData(self :: ATTRIBUTE_CODE);
48 $result[$productId] = $tierPrices;
49 }
50 }
51 return $result;
52
53 }
54
55 public function items2($productIds=null) {
56 $product = Mage :: getModel('catalog/product_attribute_backend_tierprice')->_get_set_go();
57 if (!$product->getId()) {
58 $this->_fault('product_not_exists');
59 }
60
61 $tierPrices = $product->getPriceModel()->getTierPriceCount();
62 return 'hello';
63 $result[$productIds] = $tierPrices;
64
65
66 return $result;
67
68
69 }
70
71}
0\ No newline at end of file72\ No newline at end of file
173
=== added file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Products.php'
--- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Products.php 1970-01-01 00:00:00 +0000
+++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Products.php 2012-08-10 13:28:19 +0000
@@ -0,0 +1,289 @@
1<?php
2
3class Openlabs_OpenERPConnector_Model_Olcatalog_Products extends Mage_Catalog_Model_Api_Resource
4{
5 protected $_filtersMap = array(
6 'product_id' => 'entity_id',
7 'set' => 'attribute_set_id',
8 'type' => 'type_id'
9 );
10
11 public function __construct()
12 {
13 $this->_storeIdSessionField = 'product_store_id';
14 $this->_ignoredAttributeTypes[] = 'gallery';
15 $this->_ignoredAttributeTypes[] = 'media_image';
16 }
17
18 /**
19 * Retrieve list of products with basic info (id, sku, type, set, name)
20 *
21 * @param array $filters
22 * @param string|int $store
23 * @return array
24 */
25 public function items($filters = null, $store = null)
26 {
27 $collection = Mage::getModel('catalog/product')->getCollection()
28 ->setStoreId($this->_getStoreId($store))
29 ->addAttributeToSelect('name');
30
31 if (is_array($filters)) {
32 try {
33 foreach ($filters as $field => $value) {
34 if (isset($this->_filtersMap[$field])) {
35 $field = $this->_filtersMap[$field];
36 }
37
38 $collection->addFieldToFilter($field, $value);
39 }
40 } catch (Mage_Core_Exception $e) {
41 $this->_fault('filters_invalid', $e->getMessage());
42 }
43 }
44
45 $result = array();
46
47 foreach ($collection as $product) {
48// $result[] = $product->getData();
49 $result[] = array( // Basic product data
50 'product_id' => $product->getId(),
51 'sku' => $product->getSku(),
52 'name' => $product->getName(),
53 'set' => $product->getAttributeSetId(),
54 'type' => $product->getTypeId(),
55 'category_ids' => $product->getCategoryIds()
56 );
57 }
58
59 return $result;
60 }
61
62 /**
63 * Retrieve product info
64 *
65 * @param int|string $productId
66 * @param string|int $store
67 * @param array $attributes
68 * @return array
69 */
70 public function biglist($productId, $store = null, $filters = null)
71 {
72 $collection = Mage::getModel('catalog/product')->getCollection()
73 ->setStoreId($this->_getStoreId($store))
74 ->addAttributeToSelect('name');
75
76 if (is_array($filters)) {
77 try {
78 foreach ($filters as $field => $value) {
79 if (isset($this->_filtersMap[$field])) {
80 $field = $this->_filtersMap[$field];
81 }
82
83 $collection->addFieldToFilter($field, $value);
84 }
85 } catch (Mage_Core_Exception $e) {
86 $this->_fault('filters_invalid', $e->getMessage());
87 }
88 }
89 foreach ($collection as $product) {
90 $data = array();
91 $data = array( // Basic product data
92 'product_id' => $product->getId(),
93 'sku' => $product->getSku(),
94 'set' => $product->getAttributeSetId(),
95 'type' => $product->getTypeId(),
96 'categories' => $product->getCategoryIds(),
97 'websites' => $product->getWebsiteIds()
98 );
99
100 foreach ($product->getTypeInstance(true)->getEditableAttributes($product) as $attribute) {
101 $data[$attribute->getAttributeCode()] = $product->getData($attribute->getAttributeCode());
102 }
103 $result[]=$data;
104 }
105 return $result;
106 }
107
108 /**
109 * Create new product.
110 *
111 * @param string $type
112 * @param int $set
113 * @param array $productData
114 * @return int
115 */
116 public function create($type, $set, $sku, $productData)
117 {
118 if (!$type || !$set || !$sku) {
119 $this->_fault('data_invalid');
120 }
121
122 $product = Mage::getModel('catalog/product');
123 /* @var $product Mage_Catalog_Model_Product */
124 $product->setStoreId($this->_getStoreId($store))
125 ->setAttributeSetId($set)
126 ->setTypeId($type)
127 ->setSku($sku);
128
129 if (isset($productData['website_ids']) && is_array($productData['website_ids'])) {
130 $product->setWebsiteIds($productData['website_ids']);
131 }
132
133 foreach ($product->getTypeInstance(true)->getEditableAttributes($product) as $attribute) {
134 if ($this->_isAllowedAttribute($attribute)
135 && isset($productData[$attribute->getAttributeCode()])) {
136 $product->setData(
137 $attribute->getAttributeCode(),
138 $productData[$attribute->getAttributeCode()]
139 );
140 }
141 }
142
143 $this->_prepareDataForSave($product, $productData);
144
145 if (is_array($errors = $product->validate())) {
146 $this->_fault('data_invalid', implode("\n", $errors));
147 }
148
149 try {
150 $product->save();
151 } catch (Mage_Core_Exception $e) {
152 $this->_fault('data_invalid', $e->getMessage());
153 }
154
155 return $product->getId();
156 }
157
158 /**
159 * Update product data
160 *
161 * @param int|string $productId
162 * @param array $productData
163 * @param string|int $store
164 * @return boolean
165 */
166 public function update($productId, $productData = array(), $store = null)
167 {
168 $product = $this->_getProduct($productId, $store);
169
170 if (!$product->getId()) {
171 $this->_fault('not_exists');
172 }
173
174 if (isset($productData['website_ids']) && is_array($productData['website_ids'])) {
175 $product->setWebsiteIds($productData['website_ids']);
176 }
177
178 foreach ($product->getTypeInstance(true)->getEditableAttributes($product) as $attribute) {
179 if ($this->_isAllowedAttribute($attribute)
180 && isset($productData[$attribute->getAttributeCode()])) {
181 $product->setData(
182 $attribute->getAttributeCode(),
183 $productData[$attribute->getAttributeCode()]
184 );
185 }
186 }
187
188 $this->_prepareDataForSave($product, $productData);
189
190 try {
191 if (is_array($errors = $product->validate())) {
192 $this->_fault('data_invalid', implode("\n", $errors));
193 }
194 } catch (Mage_Core_Exception $e) {
195 $this->_fault('data_invalid', $e->getMessage());
196 }
197
198 try {
199 $product->save();
200 } catch (Mage_Core_Exception $e) {
201 $this->_fault('data_invalid', $e->getMessage());
202 }
203
204 return true;
205 }
206
207 /**
208 * Set additional data before product saved
209 *
210 * @param Mage_Catalog_Model_Product $product
211 * @param array $productData
212 * @return object
213 */
214 protected function _prepareDataForSave ($product, $productData)
215 {
216 if (isset($productData['categories']) && is_array($productData['categories'])) {
217 $product->setCategoryIds($productData['categories']);
218 }
219
220 if (isset($productData['websites']) && is_array($productData['websites'])) {
221 foreach ($productData['websites'] as &$website) {
222 if (is_string($website)) {
223 try {
224 $website = Mage::app()->getWebsite($website)->getId();
225 } catch (Exception $e) { }
226 }
227 }
228 $product->setWebsiteIds($productData['websites']);
229 }
230
231 if (isset($productData['stock_data']) && is_array($productData['stock_data'])) {
232 $product->setStockData($productData['stock_data']);
233 }
234 }
235
236 /**
237 * Update product special price
238 *
239 * @param int|string $productId
240 * @param float $specialPrice
241 * @param string $fromDate
242 * @param string $toDate
243 * @param string|int $store
244 * @return boolean
245 */
246 public function setSpecialPrice($productId, $specialPrice = null, $fromDate = null, $toDate = null, $store = null)
247 {
248 return $this->update($productId, array(
249 'special_price' => $specialPrice,
250 'special_from_date' => $fromDate,
251 'special_to_date' => $toDate
252 ), $store);
253 }
254
255 /**
256 * Retrieve product special price
257 *
258 * @param int|string $productId
259 * @param string|int $store
260 * @return array
261 */
262 public function getSpecialPrice($productId, $store = null)
263 {
264 return $this->info($productId, $store, array('special_price', 'special_from_date', 'special_to_date'));
265 }
266
267 /**
268 * Delete product
269 *
270 * @param int|string $productId
271 * @return boolean
272 */
273 public function delete($productId)
274 {
275 $product = $this->_getProduct($productId);
276
277 if (!$product->getId()) {
278 $this->_fault('not_exists');
279 }
280
281 try {
282 $product->delete();
283 } catch (Mage_Core_Exception $e) {
284 $this->_fault('not_deleted', $e->getMessage());
285 }
286
287 return true;
288 }
289} // Class Mage_Catalog_Model_Product_Api End
0\ No newline at end of file290\ No newline at end of file
1291
=== added directory 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcore'
=== added file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcore/Groups.php'
--- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcore/Groups.php 1970-01-01 00:00:00 +0000
+++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcore/Groups.php 2012-08-10 13:28:19 +0000
@@ -0,0 +1,142 @@
1<?php
2
3/**
4 * @author Sharoon Thomas
5 * Inspired from Dieter's Magento Extender
6 * @copyright 2009
7 */
8
9class Openlabs_OpenERPConnector_Model_Olcore_Groups extends Mage_Catalog_Model_Api_Resource
10{
11 public function items($filters=null)
12 {
13 try
14 {
15 $collection = Mage::getModel('core/store_group')->getCollection();//->addAttributeToSelect('*');
16 }
17 catch (Mage_Core_Exception $e)
18 {
19 $this->_fault('group_not_exists');
20 }
21
22 if (is_array($filters)) {
23 try {
24 foreach ($filters as $field => $value) {
25 $collection->addFieldToFilter($field, $value);
26 }
27 } catch (Mage_Core_Exception $e) {
28 $this->_fault('filters_invalid', $e->getMessage());
29 // If we are adding filter on non-existent attribute
30 }
31 }
32
33 $result = array();
34 foreach ($collection as $customer) {
35 $result[] = $customer->toArray();
36 }
37
38 return $result;
39 }
40
41 public function info($groupIds = null)
42 {
43 $groups = array();
44
45 if(is_array($groupIds))
46 {
47 foreach($groupIds as $groupId)
48 {
49 try
50 {
51 $groups[] = Mage::getModel('core/store_group')->load($groupId)->toArray();
52 }
53 catch (Mage_Core_Exception $e)
54 {
55 $this->_fault('group_not_exists');
56 }
57 }
58 return $groups;
59 }
60 elseif(is_numeric($groupIds))
61 {
62 try
63 {
64 return Mage::getModel('core/store_group')->load($groupIds)->toArray();
65 }
66 catch (Mage_Core_Exception $e)
67 {
68 $this->_fault('group_not_exists');
69 }
70
71 }
72
73 }
74
75 public function create($groupdata)
76 {
77 try
78 {
79 $group = Mage::getModel('core/store_group')
80 ->setData($groupdata)
81 ->save();
82
83 }
84 catch (Magento_Core_Exception $e)
85 {
86 $this->_fault('data_invalid',$e->getMessage());
87 }
88 catch (Exception $e)
89 {
90 $this->_fault('data_invalid',$e->getMessage());
91 }
92 return $group->getId();
93 }
94
95 public function update($groupid,$groupdata)
96 {
97 try
98 {
99 $group = Mage::getModel('core/store_group')
100 ->load($groupid);
101 if (!$group->getId())
102 {
103 $this->_fault('group_not_exists');
104 }
105 $group->addData($groupdata)->save();
106 }
107 catch (Magento_Core_Exception $e)
108 {
109 $this->_fault('data_invalid',$e->getMessage());
110 }
111 catch (Exception $e)
112 {
113 $this->_fault('data_invalid',$e->getMessage());
114 }
115 return true;
116 }
117
118 public function delete($groupid)
119 {
120 try
121 {
122 $group = Mage::getModel('core/store_group')
123 ->load($groupid);
124 if (!$group->getId())
125 {
126 $this->_fault('group_not_exists');
127 }
128 $group->delete();
129
130 }
131 catch (Magento_Core_Exception $e)
132 {
133 $this->_fault('data_invalid',$e->getMessage());
134 }
135 catch (Exception $e)
136 {
137 $this->_fault('data_invalid',$e->getMessage());
138 }
139 return true;
140 }
141}
142?>
0143
=== added file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcore/Storeviews.php'
--- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcore/Storeviews.php 1970-01-01 00:00:00 +0000
+++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcore/Storeviews.php 2012-08-10 13:28:19 +0000
@@ -0,0 +1,142 @@
1<?php
2
3/**
4 * @author Sharoon Thomas
5 * Inspired from Dieter's Magento Extender
6 * @copyright 2009
7 */
8
9class Openlabs_OpenERPConnector_Model_Olcore_Storeviews extends Mage_Catalog_Model_Api_Resource
10{
11 public function items($filters=null)
12 {
13 try
14 {
15 $collection = Mage::getModel('core/store')->getCollection();//->addAttributeToSelect('*');
16 }
17 catch (Mage_Core_Exception $e)
18 {
19 $this->_fault('store_not_exists');
20 }
21
22 if (is_array($filters)) {
23 try {
24 foreach ($filters as $field => $value) {
25 $collection->addFieldToFilter($field, $value);
26 }
27 } catch (Mage_Core_Exception $e) {
28 $this->_fault('filters_invalid', $e->getMessage());
29 // If we are adding filter on non-existent attribute
30 }
31 }
32
33 $result = array();
34 foreach ($collection as $customer) {
35 $result[] = $customer->toArray();
36 }
37
38 return $result;
39 }
40
41 public function info($storeIds = null)
42 {
43 $stores = array();
44
45 if(is_array($storeIds))
46 {
47 foreach($storeIds as $storeId)
48 {
49 try
50 {
51 $stores[] = Mage::getModel('core/store')->load($storeId)->toArray();
52 }
53 catch (Mage_Core_Exception $e)
54 {
55 $this->_fault('store_not_exists');
56 }
57 }
58 return $stores;
59 }
60 elseif(is_numeric($storeIds))
61 {
62 try
63 {
64 return Mage::getModel('core/store')->load($storeIds)->toArray();
65 }
66 catch (Mage_Core_Exception $e)
67 {
68 $this->_fault('store_not_exists');
69 }
70
71 }
72
73 }
74
75 public function create($storedata)
76 {
77 try
78 {
79 $store = Mage::getModel('core/store')
80 ->setData($storedata)
81 ->save();
82
83 }
84 catch (Magento_Core_Exception $e)
85 {
86 $this->_fault('data_invalid',$e->getMessage());
87 }
88 catch (Exception $e)
89 {
90 $this->_fault('data_invalid',$e->getMessage());
91 }
92 return $store->getId();
93 }
94
95 public function update($storeid,$storedata)
96 {
97 try
98 {
99 $store = Mage::getModel('core/store')
100 ->load($storeid);
101 if (!$store->getId())
102 {
103 $this->_fault('store_not_exists');
104 }
105 $store->addData($storedata)->save();
106 }
107 catch (Magento_Core_Exception $e)
108 {
109 $this->_fault('data_invalid',$e->getMessage());
110 }
111 catch (Exception $e)
112 {
113 $this->_fault('data_invalid',$e->getMessage());
114 }
115 return true;
116 }
117
118 public function delete($storeid)
119 {
120 try
121 {
122 $store = Mage::getModel('core/store')
123 ->load($storeid);
124 if (!$store->getId())
125 {
126 $this->_fault('store_not_exists');
127 }
128 $store->delete();
129
130 }
131 catch (Magento_Core_Exception $e)
132 {
133 $this->_fault('data_invalid',$e->getMessage());
134 }
135 catch (Exception $e)
136 {
137 $this->_fault('data_invalid',$e->getMessage());
138 }
139 return true;
140 }
141}
142?>
0143
=== added file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcore/Website.php'
--- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcore/Website.php 1970-01-01 00:00:00 +0000
+++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcore/Website.php 2012-08-10 13:28:19 +0000
@@ -0,0 +1,171 @@
1<?php
2
3/**
4 * @author Sharoon Thomas
5 * Inspired from Dieter's Magento Extender
6 * @copyright 2009
7 */
8
9class Openlabs_OpenERPConnector_Model_Olcore_Website extends Mage_Catalog_Model_Api_Resource
10{
11
12 public function items($filters=null)
13 {
14 try
15 {
16 $collection = Mage::getModel('core/website')->getCollection();//->addAttributeToSelect('*');
17 }
18 catch (Mage_Core_Exception $e)
19 {
20 $this->_fault('store_not_exists');
21 }
22
23 if (is_array($filters)) {
24 try {
25 foreach ($filters as $field => $value) {
26 $collection->addFieldToFilter($field, $value);
27 }
28 } catch (Mage_Core_Exception $e) {
29 $this->_fault('filters_invalid', $e->getMessage());
30 // If we are adding filter on non-existent attribute
31 }
32 }
33
34 $result = array();
35 foreach ($collection as $customer) {
36 $result[] = $customer->toArray();
37 }
38
39 return $result;
40 }
41
42 public function info($storeIds = null)
43 {
44 $stores = array();
45
46 if(is_array($storeIds))
47 {
48 foreach($storeIds as $storeId)
49 {
50 try
51 {
52 $stores[] = Mage::getModel('core/website')->load($storeId)->toArray();
53 }
54 catch (Mage_Core_Exception $e)
55 {
56 $this->_fault('store_not_exists');
57 }
58 }
59 return $stores;
60 }
61 elseif(is_numeric($storeIds))
62 {
63 try
64 {
65 return Mage::getModel('core/website')->load($storeIds)->toArray();
66 }
67 catch (Mage_Core_Exception $e)
68 {
69 $this->_fault('store_not_exists');
70 }
71
72 }
73
74 }
75 //This is a protected function used by items & info for fetching website information
76
77 public function create($websitedata)
78 {
79 try
80 {
81 $website = Mage::getModel('core/website')
82 ->setData($websitedata)
83 ->save();
84
85 }
86 catch (Magento_Core_Exception $e)
87 {
88 $this->_fault('data_invalid',$e->getMessage());
89 }
90 catch (Exception $e)
91 {
92 $this->_fault('data_invalid',$e->getMessage());
93 }
94 return $website->getId();
95 }
96
97 public function update($websiteid,$websitedata)
98 {
99 try
100 {
101 $website = Mage::getModel('core/website')
102 ->load($websiteid);
103 if (!$website->getId())
104 {
105 $this->_fault('website_not_exists');
106 }
107 $website->addData($websitedata)->save();
108 }
109 catch (Magento_Core_Exception $e)
110 {
111 $this->_fault('data_invalid',$e->getMessage());
112 }
113 catch (Exception $e)
114 {
115 $this->_fault('data_invalid',$e->getMessage());
116 }
117 return true;
118 }
119
120 public function delete($websiteid)
121 {
122 try
123 {
124 $website = Mage::getModel('core/website')
125 ->load($websiteid);
126 if (!$website->getId())
127 {
128 $this->_fault('website_not_exists');
129 }
130 $website->delete();
131
132 }
133 catch (Magento_Core_Exception $e)
134 {
135 $this->_fault('data_invalid',$e->getMessage());
136 }
137 catch (Exception $e)
138 {
139 $this->_fault('data_invalid',$e->getMessage());
140 }
141 return true;
142 }
143
144 public function tree()
145 {
146 $tree = array();
147
148 $websites = $this->websites();
149
150 foreach($websites as $website)
151 {
152 $groups = $this->groups($website['group_ids']);
153 $tree[$website['code']] = $website;
154 foreach($groups as $group)
155 {
156 $stores = $this->stores($group["store_ids"]);
157
158 $tree[$website['code']]['groups']['group_'.$group['group_id']] = $group;
159
160 foreach($stores as $store)
161 {
162 $tree[$website['code']]['groups']['group_'.$group['group_id']]['stores'][$store['code']] = $store;
163 }
164 }
165 }
166
167 return $tree;
168 }
169
170}
171?>
0\ No newline at end of file172\ No newline at end of file
1173
=== added directory 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcustomer'
=== added file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcustomer/Address.php'
--- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcustomer/Address.php 1970-01-01 00:00:00 +0000
+++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcustomer/Address.php 2012-08-10 13:28:19 +0000
@@ -0,0 +1,241 @@
1<?php
2/**
3 * Magento
4 *
5 * NOTICE OF LICENSE
6 *
7 * This source file is subject to the Open Software License (OSL 3.0)
8 * that is bundled with this package in the file LICENSE.txt.
9 * It is also available through the world-wide-web at this URL:
10 * http://opensource.org/licenses/osl-3.0.php
11 * If you did not receive a copy of the license and are unable to
12 * obtain it through the world-wide-web, please send an email
13 * to license@magentocommerce.com so we can send you a copy immediately.
14 *
15 * DISCLAIMER
16 *
17 * Do not edit or add to this file if you wish to upgrade Magento to newer
18 * versions in the future. If you wish to customize Magento for your
19 * needs please refer to http://www.magentocommerce.com for more information.
20 *
21 * @category Mage
22 * @package Mage_Customer
23 * @copyright Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
24 * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25 */
26
27/**
28 * Customer address api
29 *
30 * @category Mage
31 * @package Mage_Customer
32 * @author Magento Core Team <core@magentocommerce.com>
33 */
34class Openlabs_OpenERPConnector_Model_Olcustomer_Address extends Mage_Customer_Model_Api_Resource
35{
36 protected $_mapAttributes = array(
37 'customer_id' => 'entity_id'
38 );
39
40 public function __construct()
41 {
42 $this->_ignoredAttributeCodes[] = 'parent_id';
43 }
44
45 /**
46 * Retrive customer addresses list
47 *
48 * @param int $customerId
49 * @return array
50 */
51 public function items($customerId)
52 {
53 $customer = Mage::getModel('customer/customer')
54 ->load($customerId);
55 /* @var $customer Mage_Customer_Model_Customer */
56
57 if (!$customer->getId()) {
58 $this->_fault('customer_not_exists');
59 }
60
61 $result = array();
62 foreach ($customer->getAddresses() as $address) {
63 $data = $address->toArray();
64 $data['default_billing'] = $customer->getDefaultBilling() == $address->getId();
65 $data['default_shipping'] = $customer->getDefaultShipping() == $address->getId();
66 $result[] = $data;
67 /*$data = $address->toArray();
68 $row = array();
69
70 foreach ($this->_mapAttributes as $attributeAlias => $attributeCode) {
71 $row[$attributeAlias] = isset($data[$attributeCode]) ? $data[$attributeCode] : null;
72 }
73
74 foreach ($this->getAllowedAttributes($address) as $attributeCode => $attribute) {
75 if (isset($data[$attributeCode])) {
76 $row[$attributeCode] = $data[$attributeCode];
77 }
78 }
79
80 $row['is_default_billing'] = $customer->getDefaultBillingAddress() == $address->getId();
81 $row['is_default_shipping'] = $customer->getDefaultShippingAddress() == $address->getId();
82
83 $result[] = $row;*/
84
85 }
86
87 return $result;
88 }
89
90 /**
91 * Create new address for customer
92 *
93 * @param int $customerId
94 * @param array $addressData
95 * @return int
96 */
97 public function create($customerId, $addressData)
98 {
99 $customer = Mage::getModel('customer/customer')
100 ->load($customerId);
101 /* @var $customer Mage_Customer_Model_Customer */
102
103 if (!$customer->getId()) {
104 $this->_fault('customer_not_exists');
105 }
106
107 $address = Mage::getModel('customer/address');
108
109 foreach ($this->getAllowedAttributes($address) as $attributeCode=>$attribute) {
110 if (isset($addressData[$attributeCode])) {
111 $address->setData($attributeCode, $addressData[$attributeCode]);
112 }
113 }
114
115 if (isset($addressData['is_default_billing'])) {
116 $address->setIsDefaultBilling($addressData['is_default_billing']);
117 }
118
119 if (isset($addressData['is_default_shipping'])) {
120 $address->setIsDefaultShipping($addressData['is_default_shipping']);
121 }
122
123 $address->setCustomerId($customer->getId());
124
125 $valid = $address->validate();
126
127 if (is_array($valid)) {
128 $this->_fault('data_invalid', implode("\n", $valid));
129 }
130
131 try {
132 $address->save();
133 } catch (Mage_Core_Exception $e) {
134 $this->_fault('data_invalid', $e->getMessage());
135 }
136
137 return $address->getId();
138 }
139
140 /**
141 * Retrieve address data
142 *
143 * @param int $addressId
144 * @return array
145 */
146 public function info($addressId)
147 {
148 $address = Mage::getModel('customer/address')
149 ->load($addressId);
150
151 if (!$address->getId()) {
152 $this->_fault('not_exists');
153 }
154
155 $result = array();
156
157 foreach ($this->_mapAttributes as $attributeAlias => $attributeCode) {
158 $result[$attributeAlias] = $address->getData($attributeCode);
159 }
160
161 foreach ($this->getAllowedAttributes($address) as $attributeCode => $attribute) {
162 $result[$attributeCode] = $address->getData($attributeCode);
163 }
164
165
166 if ($customer = $address->getCustomer()) {
167 $result['is_default_billing'] = $customer->getDefaultBillingAddress() == $address->getId();
168 $result['is_default_shipping'] = $customer->getDefaultShippingAddress() == $address->getId();
169 }
170
171 return $result;
172 }
173
174 /**
175 * Update address data
176 *
177 * @param int $addressId
178 * @param array $addressData
179 * @return boolean
180 */
181 public function update($addressId, $addressData)
182 {
183 $address = Mage::getModel('customer/address')
184 ->load($addressId);
185
186 if (!$address->getId()) {
187 $this->_fault('not_exists');
188 }
189
190 foreach ($this->getAllowedAttributes($address) as $attributeCode=>$attribute) {
191 if (isset($addressData[$attributeCode])) {
192 $address->setData($attributeCode, $addressData[$attributeCode]);
193 }
194 }
195
196 if (isset($addressData['is_default_billing'])) {
197 $address->setIsDefaultBilling($addressData['is_default_billing']);
198 }
199
200 if (isset($addressData['is_default_shipping'])) {
201 $address->setIsDefaultShipping($addressData['is_default_shipping']);
202 }
203
204 $valid = $address->validate();
205 if (is_array($valid)) {
206 $this->_fault('data_invalid', implode("\n", $valid));
207 }
208
209 try {
210 $address->save();
211 } catch (Mage_Core_Exception $e) {
212 $this->_fault('data_invalid', $e->getMessage());
213 }
214
215 return true;
216 }
217
218 /**
219 * Delete address
220 *
221 * @param int $addressId
222 * @return boolean
223 */
224 public function delete($addressId)
225 {
226 $address = Mage::getModel('customer/address')
227 ->load($addressId);
228
229 if (!$address->getId()) {
230 $this->_fault('not_exists');
231 }
232
233 try {
234 $address->delete();
235 } catch (Mage_Core_Exception $e) {
236 $this->_fault('not_deleted', $e->getMessage());
237 }
238
239 return true;
240 }
241} // Class Mage_Customer_Model_Address_Api End
0\ No newline at end of file242\ No newline at end of file
1243
=== added file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcustomer/Customer.php'
--- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcustomer/Customer.php 1970-01-01 00:00:00 +0000
+++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcustomer/Customer.php 2012-08-10 13:28:19 +0000
@@ -0,0 +1,142 @@
1<?php
2
3/**
4 * @author Sharoon Thomas
5 * Inspired from Dieter's Magento Extender
6 * @copyright 2009
7 */
8
9class Openlabs_OpenERPConnector_Model_Olcustomer_Customer extends Mage_Catalog_Model_Api_Resource
10{
11 public function items($filters=null)
12 {
13 try
14 {
15 $collection = Mage::getModel('customer')->getCollection();//->addAttributeToSelect('*');
16 }
17 catch (Mage_Core_Exception $e)
18 {
19 $this->_fault('customer_not_exists');
20 }
21
22 if (is_array($filters)) {
23 try {
24 foreach ($filters as $field => $value) {
25 $collection->addFieldToFilter($field, $value);
26 }
27 } catch (Mage_Core_Exception $e) {
28 $this->_fault('filters_invalid', $e->getMessage());
29 // If we are adding filter on non-existent attribute
30 }
31 }
32
33 $result = array();
34 foreach ($collection as $customer) {
35 $result[] = $customer->toArray();
36 }
37
38 return $result;
39 }
40
41 public function info($groupIds = null)
42 {
43 $groups = array();
44
45 if(is_array($groupIds))
46 {
47 foreach($groupIds as $groupId)
48 {
49 try
50 {
51 $groups[] = Mage::getModel('customer')->load($groupId)->toArray();
52 }
53 catch (Mage_Core_Exception $e)
54 {
55 $this->_fault('customer_not_exists');
56 }
57 }
58 return $groups;
59 }
60 elseif(is_numeric($groupIds))
61 {
62 try
63 {
64 return Mage::getModel('customer')->load($groupIds)->toArray();
65 }
66 catch (Mage_Core_Exception $e)
67 {
68 $this->_fault('customer_not_exists');
69 }
70
71 }
72
73 }
74
75 public function create($groupdata)
76 {
77 try
78 {
79 $group = Mage::getModel('customer')
80 ->setData($groupdata)
81 ->save();
82
83 }
84 catch (Magento_Core_Exception $e)
85 {
86 $this->_fault('data_invalid',$e->getMessage());
87 }
88 catch (Exception $e)
89 {
90 $this->_fault('data_invalid',$e->getMessage());
91 }
92 return $group->getId();
93 }
94
95 public function update($groupid,$groupdata)
96 {
97 try
98 {
99 $group = Mage::getModel('customer')
100 ->load($groupid);
101 if (!$group->getId())
102 {
103 $this->_fault('customer_not_exists');
104 }
105 $group->addData($groupdata)->save();
106 }
107 catch (Magento_Core_Exception $e)
108 {
109 $this->_fault('data_invalid',$e->getMessage());
110 }
111 catch (Exception $e)
112 {
113 $this->_fault('data_invalid',$e->getMessage());
114 }
115 return true;
116 }
117
118 public function delete($groupid)
119 {
120 try
121 {
122 $group = Mage::getModel('customer')
123 ->load($groupid);
124 if (!$group->getId())
125 {
126 $this->_fault('customer_not_exists');
127 }
128 $group->delete();
129
130 }
131 catch (Magento_Core_Exception $e)
132 {
133 $this->_fault('data_invalid',$e->getMessage());
134 }
135 catch (Exception $e)
136 {
137 $this->_fault('data_invalid',$e->getMessage());
138 }
139 return true;
140 }
141}
142?>
0143
=== added file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcustomer/Group.php'
--- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcustomer/Group.php 1970-01-01 00:00:00 +0000
+++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcustomer/Group.php 2012-08-10 13:28:19 +0000
@@ -0,0 +1,142 @@
1<?php
2
3/**
4 * @author Sharoon Thomas
5 * Inspired from Dieter's Magento Extender
6 * @copyright 2009
7 */
8
9class Openlabs_OpenERPConnector_Model_Olcustomer_Group extends Mage_Catalog_Model_Api_Resource
10{
11 public function items($filters=null)
12 {
13 try
14 {
15 $collection = Mage::getModel('customer/group')->getCollection();//->addAttributeToSelect('*');
16 }
17 catch (Mage_Core_Exception $e)
18 {
19 $this->_fault('group_not_exists');
20 }
21
22 if (is_array($filters)) {
23 try {
24 foreach ($filters as $field => $value) {
25 $collection->addFieldToFilter($field, $value);
26 }
27 } catch (Mage_Core_Exception $e) {
28 $this->_fault('filters_invalid', $e->getMessage());
29 // If we are adding filter on non-existent attribute
30 }
31 }
32
33 $result = array();
34 foreach ($collection as $customer) {
35 $result[] = $customer->toArray();
36 }
37
38 return $result;
39 }
40
41 public function info($groupIds = null)
42 {
43 $groups = array();
44
45 if(is_array($groupIds))
46 {
47 foreach($groupIds as $groupId)
48 {
49 try
50 {
51 $groups[] = Mage::getModel('customer/group')->load($groupId)->toArray();
52 }
53 catch (Mage_Core_Exception $e)
54 {
55 $this->_fault('group_not_exists');
56 }
57 }
58 return $groups;
59 }
60 elseif(is_numeric($groupIds))
61 {
62 try
63 {
64 return Mage::getModel('customer/group')->load($groupIds)->toArray();
65 }
66 catch (Mage_Core_Exception $e)
67 {
68 $this->_fault('group_not_exists');
69 }
70
71 }
72
73 }
74
75 public function create($groupdata)
76 {
77 try
78 {
79 $group = Mage::getModel('customer/group')
80 ->setData($groupdata)
81 ->save();
82
83 }
84 catch (Magento_Core_Exception $e)
85 {
86 $this->_fault('data_invalid',$e->getMessage());
87 }
88 catch (Exception $e)
89 {
90 $this->_fault('data_invalid',$e->getMessage());
91 }
92 return $group->getId();
93 }
94
95 public function update($groupid,$groupdata)
96 {
97 try
98 {
99 $group = Mage::getModel('customer/group')
100 ->load($groupid);
101 if (!$group->getId())
102 {
103 $this->_fault('group_not_exists');
104 }
105 $group->addData($groupdata)->save();
106 }
107 catch (Magento_Core_Exception $e)
108 {
109 $this->_fault('data_invalid',$e->getMessage());
110 }
111 catch (Exception $e)
112 {
113 $this->_fault('data_invalid',$e->getMessage());
114 }
115 return true;
116 }
117
118 public function delete($groupid)
119 {
120 try
121 {
122 $group = Mage::getModel('customer/group')
123 ->load($groupid);
124 if (!$group->getId())
125 {
126 $this->_fault('group_not_exists');
127 }
128 $group->delete();
129
130 }
131 catch (Magento_Core_Exception $e)
132 {
133 $this->_fault('data_invalid',$e->getMessage());
134 }
135 catch (Exception $e)
136 {
137 $this->_fault('data_invalid',$e->getMessage());
138 }
139 return true;
140 }
141}
142?>
0143
=== added file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcustomer/Subscriber.php'
--- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcustomer/Subscriber.php 1970-01-01 00:00:00 +0000
+++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcustomer/Subscriber.php 2012-08-10 13:28:19 +0000
@@ -0,0 +1,163 @@
1<?php
2/**
3 * Magento
4 *
5 * NOTICE OF LICENSE
6 *
7 * This source file is subject to the Open Software License (OSL 3.0)
8 * that is bundled with this package in the file LICENSE.txt.
9 * It is also available through the world-wide-web at this URL:
10 * http://opensource.org/licenses/osl-3.0.php
11 * If you did not receive a copy of the license and are unable to
12 * obtain it through the world-wide-web, please send an email
13 * to license@magentocommerce.com so we can send you a copy immediately.
14 *
15 * DISCLAIMER
16 *
17 * Do not edit or add to this file if you wish to upgrade Magento to newer
18 * versions in the future. If you wish to customize Magento for your
19 * needs please refer to http://www.magentocommerce.com for more information.
20 *
21 * @category Mage
22 * @package Mage_Customer
23 * @copyright Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
24 * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25 */
26
27/**
28 * Customer address api
29 *
30 * @category Mage
31 * @package Mage_Customer
32 * @author Magento Core Team <core@magentocommerce.com>
33 */
34class Openlabs_OpenERPConnector_Model_Olcustomer_Subscriber extends Mage_Customer_Model_Api_Resource
35{
36 protected $_mapAttributes = array(
37 'customer_id' => 'entity_id'
38 );
39
40 public function __construct()
41 {
42 $this->_ignoredAttributeCodes[] = 'parent_id';
43 }
44
45 /**
46 * Retrive subscriber list
47 *
48 * @param int $filters
49 * @return array
50 */
51 public function items($filters=null)
52 {
53 $collection = Mage::getModel('customer/customer')->getCollection()
54 ->addAttributeToSelect('*');
55
56
57 if (is_array($filters)) {
58 try {
59 foreach ($filters as $field => $value) {
60 $collection->addFieldToFilter($field, $value);
61 }
62 } catch (Mage_Core_Exception $e) {
63 $this->_fault('filters_invalid', $e->getMessage());
64 // If we are adding filter on non-existent attribute
65 }
66 }
67
68 $result = array();
69
70 foreach ($collection as $customer) {
71 $subscriber = Mage::getModel('newsletter/subscriber')->loadByEmail($customer['email']);
72 if($subscriber->getId())
73 $result[] = $subscriber->getId();
74 }
75
76 return $result;
77 }
78
79 /**
80 * Create new address for customer
81 *
82 * @param int $customerId
83 * @param array $email
84 * @return int
85 */
86 public function create($customerId,$email)
87 {
88 if($customerId && $email):
89 $customer = Mage::getModel("newsletter/subscriber");
90
91 $customer->setCustomerId($customerId);
92 $customer->setEmail($email);
93 $customer->subscriber_status = "1";
94
95 $customer->save();
96
97 return $customer->getId();
98 else:
99 return False;
100 endif;
101 }
102
103 /**
104 * Retrieve subscriber data
105 *
106 * @param int $subscriberId
107 * @return array
108 */
109 public function info($subscriberId)
110 {
111 $subscriber = Mage::getModel('newsletter/subscriber')->load($subscriberId);
112
113 if($subscriber->getId()):
114 $result[] = $subscriber->toArray();
115 endif;
116
117 return $result;
118 }
119
120 /**
121 * Update subscriber data (subscriber)
122 *
123 * @param $email
124 * @return boolean
125 */
126 public function update($email)
127 {
128 if($email):
129 $subscriber = Mage::getModel('newsletter/subscriber')->loadByEmail($email);
130
131 if($subscriber->getId()):
132 $customer = Mage::getModel("newsletter/subscriber")->load($subscriber->getId());
133 $customer->subscriber_status = "1";
134 $customer->save();
135 endif;
136
137 return $subscriber->getId();
138 else:
139 return False;
140 endif;
141 }
142
143 /**
144 * Delete subscriber (unsubscriber)
145 *
146 * @param $email
147 * @return boolean
148 */
149 public function delete($email)
150 {
151 if($email):
152 $subscriber = Mage::getModel('newsletter/subscriber')->loadByEmail($email);
153
154 if($subscriber->getId()):
155 Mage::getModel('newsletter/subscriber')->load($subscriber->getId())->unsubscribe();
156 endif;
157
158 return $subscriber->getId();
159 else:
160 return False;
161 endif;
162 }
163} // Class Mage_Customer_Model_Address_Api End
0164
=== added directory 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/etc'
=== added file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/etc/api.xml'
--- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/etc/api.xml 1970-01-01 00:00:00 +0000
+++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/etc/api.xml 2012-08-10 13:28:19 +0000
@@ -0,0 +1,493 @@
1
2<config>
3 <api>
4 <resources>
5 <ol_websites translate="title" module="core">
6 <title>Website Management</title>
7 <model>openerpconnector/olcore_website</model>
8 <acl>core/store</acl>
9 <methods>
10 <list translate="title" module="core">
11 <title>Enumerate websites</title>
12 <method>items</method>
13 </list>
14 <create translate="title" module="core">
15 <title>Create Websites</title>
16 <!--Parameters are code,name,is_default,sort_order,default_group_id,group_ids-->
17 <method>create</method>
18 </create>
19 <info translate="title" module="core">
20 <title>Fetch detail of websites</title>
21 <method>info</method>
22 </info>
23 <update translate="title" module="core">
24 <title>Update websites info</title>
25 <method>update</method>
26 </update>
27 <delete translate="title" module="core">
28 <title>Delete websites</title>
29 <method>delete</method>
30 </delete>
31 </methods>
32 <faults module="core">
33 <website_not_exists>
34 <code>101</code>
35 <message>Requested website not found.</message>
36 </website_not_exists>
37 <data_invalid>
38 <code>102</code>
39 <message>Website creation failed due to invalid data.</message>
40 </data_invalid>
41 </faults>
42 </ol_websites>
43 <ol_groups translate="title" module="core">
44 <title>Groups Management</title>
45 <model>openerpconnector/olcore_groups</model>
46 <acl>core/store</acl>
47 <methods>
48 <list translate="title" module="core">
49 <title>Enumerate groups</title>
50 <method>items</method>
51 </list>
52 <create translate="title" module="core">
53 <title>Create groups</title>
54 <!--Parameters are code,name,is_default,sort_order,default_group_id,group_ids-->
55 <method>create</method>
56 </create>
57 <info translate="title" module="core">
58 <title>Fetch detail of groups</title>
59 <method>info</method>
60 </info>
61 <update translate="title" module="core">
62 <title>Update groups info</title>
63 <method>update</method>
64 </update>
65 <delete translate="title" module="core">
66 <title>Delete groups</title>
67 <method>delete</method>
68 </delete>
69 </methods>
70 <faults module="core">
71 <group_not_exists>
72 <code>101</code>
73 <message>Requested group not found.</message>
74 </group_not_exists>
75 <data_invalid>
76 <code>102</code>
77 <message>group creation failed due to invalid data.</message>
78 </data_invalid>
79 <filters_invalid>
80 <code>103</code>
81 <message>Invalid data fetch filter.</message>
82 </filters_invalid>
83 </faults>
84 </ol_groups>
85 <ol_storeviews translate="title" module="core">
86 <title>Stores Management</title>
87 <model>openerpconnector/olcore_storeviews</model>
88 <acl>core/store</acl>
89 <methods>
90 <list translate="title" module="core">
91 <title>Enumerate stores</title>
92 <method>items</method>
93 </list>
94 <create translate="title" module="core">
95 <title>Create stores</title>
96 <!--Parameters are code,name,is_default,sort_order,default_group_id,group_ids-->
97 <method>create</method>
98 </create>
99 <info translate="title" module="core">
100 <title>Fetch detail of stores</title>
101 <method>info</method>
102 </info>
103 <update translate="title" module="core">
104 <title>Update stores info</title>
105 <method>update</method>
106 </update>
107 <delete translate="title" module="core">
108 <title>Delete stores</title>
109 <method>delete</method>
110 </delete>
111 </methods>
112 <faults module="core">
113 <store_not_exists>
114 <code>101</code>
115 <message>Requested store not found.</message>
116 </store_not_exists>
117 <data_invalid>
118 <code>102</code>
119 <message>Store creation failed due to invalid data.</message>
120 </data_invalid>
121 <filters_invalid>
122 <code>103</code>
123 <message>Invalid data fetch filter.</message>
124 </filters_invalid>
125 </faults>
126 </ol_storeviews>
127 <ol_catalog_category_media translate="title" module="catalog">
128 <title>Product Images API</title>
129 <model>openerpconnector/olcatalog_categories</model>
130 <acl>catalog/category</acl>
131 <methods>
132 <list translate="title" module="catalog">
133 <title>Retrieve product image list</title>
134 <method>items</method>
135 </list>
136 <info translate="title" module="catalog">
137 <title>Retrieve product category image</title>
138 </info>
139 <types translate="title" module="catalog">
140 <title>Retrieve product category image types</title>
141 </types>
142 <create translate="title" module="catalog">
143 <title>Upload new product category image </title>
144 <acl>catalog/product/media/create</acl>
145 </create>
146 <update translate="title" module="catalog">
147 <title>Update product category image</title>
148 <acl>catalog/product/media/update</acl>
149 </update>
150 <remove translate="title" module="catalog">
151 <title>Remove product category image</title>
152 <acl>catalog/product/media/remove</acl>
153 </remove>
154 </methods>
155 <faults module="catalog">
156 <create_failure>
157 <code>100</code>
158 <message>Could not create file, check permissions.</message>
159 </create_failure>
160 <category_not_exists>
161 <code>101</code>
162 <message>Product not exists.</message>
163 </category_not_exists>
164 <data_invalid>
165 <code>102</code>
166 <message>Invalid data given. Details in error message.</message>
167 </data_invalid>
168 <not_exists>
169 <code>103</code>
170 <message>Requested image not exists in product images' gallery.</message>
171 </not_exists>
172 <not_created>
173 <code>104</code>
174 <message>Image creation failed. Details in error message.</message>
175 </not_created>
176 <not_updated>
177 <code>105</code>
178 <message>Image not updated. Details in error message.</message>
179 </not_updated>
180 <not_removed>
181 <code>106</code>
182 <message>Image not removed. Details in error message.</message>
183 </not_removed>
184 <not_media>
185 <code>107</code>
186 <message>Error in opening image file</message>
187 </not_media>
188 <filters_invalid>
189 <code>108</code>
190 <message>Invalid data fetch filter.</message>
191 </filters_invalid>
192 </faults>
193 </ol_catalog_category_media>
194 <ol_catalog_product_attribute translate="title" module="catalog">
195 <title>Product Images API</title>
196 <model>openerpconnector/olcatalog_product_attribute</model>
197 <acl>catalog/category</acl>
198 <methods>
199 <list translate="title" module="catalog">
200 <title>Retrieve attribute list</title>
201 <method>items</method>
202 </list>
203 <relations translate="title" module="catalog">
204 <title>Retrieve attribute sets attribute ids</title>
205 <method>relations</method>
206 </relations>
207 <info translate="title" module="catalog">
208 <title>Retrieve full attribute details</title>
209 <method>info</method>
210 </info>
211 <options translate="title" module="catalog">
212 <title>Retrieve options of attributes</title>
213 <method>options</method>
214 </options>
215 </methods>
216 <faults>
217 </faults>
218 </ol_catalog_product_attribute>
219 <ol_catalog_product_attribute_group translate="title" module="catalog">
220 <title>Product Images API</title>
221 <model>openerpconnector/olcatalog_product_attributegroup</model>
222 <acl>catalog/category</acl>
223 <methods>
224 <list translate="title" module="catalog">
225 <title>Retrieve attribute group list</title>
226 <method>items</method>
227 </list>
228 <info translate="title" module="catalog">
229 <title>Retrieve full attribute details</title>
230 <method>info</method>
231 </info>
232 </methods>
233 <faults>
234 </faults>
235 </ol_catalog_product_attribute_group>
236 <ol_customer_groups translate="title" module="core">
237 <title>Groups Management</title>
238 <model>openerpconnector/olcustomer_group</model>
239 <acl>customer/group</acl>
240 <methods>
241 <list translate="title" module="core">
242 <title>Enumerate groups</title>
243 <method>items</method>
244 </list>
245 <create translate="title" module="core">
246 <title>Create groups</title>
247 <method>create</method>
248 </create>
249 <info translate="title" module="core">
250 <title>Fetch detail of groups</title>
251 <method>info</method>
252 </info>
253 <update translate="title" module="core">
254 <title>Update groups info</title>
255 <method>update</method>
256 </update>
257 <delete translate="title" module="core">
258 <title>Delete groups</title>
259 <method>delete</method>
260 </delete>
261 </methods>
262 <faults module="core">
263 <group_not_exists>
264 <code>101</code>
265 <message>Requested group not found.</message>
266 </group_not_exists>
267 <data_invalid>
268 <code>102</code>
269 <message>group creation failed due to invalid data.</message>
270 </data_invalid>
271 <filters_invalid>
272 <code>103</code>
273 <message>Invalid data fetch filter.</message>
274 </filters_invalid>
275 </faults>
276 </ol_customer_groups>
277 <ol_customer_address translate="title" module="core">
278 <title>Address Management</title>
279 <model>openerpconnector/olcustomer_address</model>
280 <acl>customer/group</acl>
281 <methods>
282 <list translate="title" module="core">
283 <title>Enumerate groups</title>
284 <method>items</method>
285 </list>
286 <create translate="title" module="core">
287 <title>Create groups</title>
288 <method>create</method>
289 </create>
290 <info translate="title" module="core">
291 <title>Fetch detail of groups</title>
292 <method>info</method>
293 </info>
294 <update translate="title" module="core">
295 <title>Update groups info</title>
296 <method>update</method>
297 </update>
298 <delete translate="title" module="core">
299 <title>Delete groups</title>
300 <method>delete</method>
301 </delete>
302 </methods>
303 <faults module="core">
304 <customer_not_exists>
305 <code>101</code>
306 <message>Requested Customer not found.</message>
307 </customer_not_exists>
308 <data_invalid>
309 <code>102</code>
310 <message>group creation failed due to invalid data.</message>
311 </data_invalid>
312 <filters_invalid>
313 <code>103</code>
314 <message>Invalid data fetch filter.</message>
315 </filters_invalid>
316 </faults>
317 </ol_customer_address>
318 <ol_customer_subscriber translate="title" module="core">
319 <title>Subscriber Management</title>
320 <model>openerpconnector/olcustomer_subscriber</model>
321 <acl>customer/group</acl>
322 <methods>
323 <list translate="title" module="core">
324 <title>Enumerate subscriber</title>
325 <method>items</method>
326 </list>
327 <create translate="title" module="core">
328 <title>Create subscriber</title>
329 <method>create</method>
330 </create>
331 <info translate="title" module="core">
332 <title>Fetch detail of subscriber</title>
333 <method>info</method>
334 </info>
335 <update translate="title" module="core">
336 <title>Update subscriber info</title>
337 <method>update</method>
338 </update>
339 <delete translate="title" module="core">
340 <title>Delete subscriber</title>
341 <method>delete</method>
342 </delete>
343 </methods>
344 <faults module="core">
345 <customer_not_exists>
346 <code>101</code>
347 <message>Requested Customer not found.</message>
348 </customer_not_exists>
349 <data_invalid>
350 <code>102</code>
351 <message>group creation failed due to invalid data.</message>
352 </data_invalid>
353 <filters_invalid>
354 <code>103</code>
355 <message>Invalid data fetch filter.</message>
356 </filters_invalid>
357 </faults>
358 </ol_customer_subscriber>
359 <ol_customer translate="title" module="core">
360 <title>Customers Management</title>
361 <model>openerpconnector/olcustomer_customer</model>
362 <acl>customer/group</acl>
363 <methods>
364 <list translate="title" module="core">
365 <title>Enumerate Customers</title>
366 <method>items</method>
367 </list>
368 <create translate="title" module="core">
369 <title>Create Customers</title>
370 <method>create</method>
371 </create>
372 <info translate="title" module="core">
373 <title>Fetch detail of customers</title>
374 <method>info</method>
375 </info>
376 <update translate="title" module="core">
377 <title>Update customers info</title>
378 <method>update</method>
379 </update>
380 <delete translate="title" module="core">
381 <title>Delete customers</title>
382 <method>delete</method>
383 </delete>
384 </methods>
385 <faults module="core">
386 <customer_not_exists>
387 <code>101</code>
388 <message>Requested customer not found.</message>
389 </customer_not_exists>
390 <data_invalid>
391 <code>102</code>
392 <message>Customer creation failed due to invalid data.</message>
393 </data_invalid>
394 <filters_invalid>
395 <code>103</code>
396 <message>Invalid data fetch filter.</message>
397 </filters_invalid>
398 </faults>
399 </ol_customer>
400 <ol_catalog_product_tierprice translate="title" module="catalog">
401 <title>Product Tier Price API</title>
402 <model>openerpconnector/olcatalog_product_tierprice</model>
403 <acl>catalog/category</acl>
404 <methods>
405 <list translate="title" module="catalog">
406 <title>Retrieve attribute list</title>
407 <method>items</method>
408 </list>
409 <items2 translate="title" module="catalog">
410 <title>Retrieve attribute list</title>
411 <method>items2</method>
412 </items2>
413 </methods>
414 <faults>
415 <product_not_exists>
416 <code>101</code>
417 <message>Requested product not found.</message>
418 </product_not_exists>
419 <filters_invalid>
420 <code>103</code>
421 <message>Invalid data fetch filter.</message>
422 </filters_invalid>
423 </faults>
424 </ol_catalog_product_tierprice>
425 <ol_catalog_product translate="title" module="core">
426 <title>Address Management</title>
427 <model>openerpconnector/olcatalog_products</model>
428 <acl>catalog/product</acl>
429 <methods>
430 <list translate="title" module="core">
431 <title>Enumerate Products</title>
432 <method>items</method>
433 </list>
434 <create translate="title" module="core">
435 <title>Create Products</title>
436 <method>create</method>
437 </create>
438 <biglist translate="title" module="core">
439 <title>Fetch detail of products</title>
440 <method>biglist</method>
441 </biglist>
442 <update translate="title" module="core">
443 <title>Update groups info</title>
444 <method>update</method>
445 </update>
446 <delete translate="title" module="core">
447 <title>Delete groups</title>
448 <method>delete</method>
449 </delete>
450 </methods>
451 <faults module="core">
452 <customer_not_exists>
453 <code>101</code>
454 <message>Requested Customer not found.</message>
455 </customer_not_exists>
456 <data_invalid>
457 <code>102</code>
458 <message>group creation failed due to invalid data.</message>
459 </data_invalid>
460 <filters_invalid>
461 <code>103</code>
462 <message>Invalid data fetch filter.</message>
463 </filters_invalid>
464 </faults>
465 </ol_catalog_product>
466 <ol_catalog_product_attributeset translate="title" module="core">
467 <title>Attribute Set Management</title>
468 <model>openerpconnector/olcatalog_product_attributeset</model>
469 <acl>catalog/product</acl>
470 <methods>
471 <list translate="title" module="core">
472 <title>Enumerate Attribute sets</title>
473 <method>items</method>
474 </list>
475 </methods>
476 <faults module="core">
477 <customer_not_exists>
478 <code>101</code>
479 <message>Requested Customer not found.</message>
480 </customer_not_exists>
481 <data_invalid>
482 <code>102</code>
483 <message>group creation failed due to invalid data.</message>
484 </data_invalid>
485 <filters_invalid>
486 <code>103</code>
487 <message>Invalid data fetch filter.</message>
488 </filters_invalid>
489 </faults>
490 </ol_catalog_product_attributeset>
491 </resources>
492 </api>
493</config>
0494
=== added file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/etc/config.xml'
--- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/etc/config.xml 1970-01-01 00:00:00 +0000
+++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/etc/config.xml 2012-08-10 13:28:19 +0000
@@ -0,0 +1,45 @@
1<?xml version="1.0"?>
2<config>
3 <!--<modules>
4 <Openlabs_OpenERPConnector>
5 <version>0.0.1</version>
6 </Openlabs_OpenERPConnector>
7 </modules>-->
8 <global>
9 <models>
10 <openerpconnector>
11 <class>Openlabs_OpenERPConnector_Model</class>
12 </openerpconnector>
13 </models>
14 <resources>
15 <openerpconnector_setup>
16 <setup>
17 <module>Openlabs_OpenERPConnector</module>
18 </setup>
19 <connection>
20 <use>core_setup</use>
21 </connection>
22 </openerpconnector_setup>
23 <openerpconnector_write>
24 <connection>
25 <use>core_write</use>
26 </connection>
27 </openerpconnector_write>
28 <openerpconnector_read>
29 <connection>
30 <use>core_read</use>
31 </connection>
32 </openerpconnector_read>
33 </resources>
34 <blocks>
35 <openerpconnector>
36 <class>Openlabs_OpenERPConnector_Block</class>
37 </openerpconnector>
38 </blocks>
39 <helpers>
40 <openerpconnector>
41 <class>Openlabs_OpenERPConnector_Helper</class>
42 </openerpconnector>
43 </helpers>
44 </global>
45</config>
0\ No newline at end of file46\ No newline at end of file
147
=== added directory 'Openlabs_OpenERPConnector-1.1.0/app'
=== added directory 'Openlabs_OpenERPConnector-1.1.0/app/etc'
=== added directory 'Openlabs_OpenERPConnector-1.1.0/app/etc/modules'
=== added file 'Openlabs_OpenERPConnector-1.1.0/app/etc/modules/Openlabs_OpenERPConnector.xml'
--- Openlabs_OpenERPConnector-1.1.0/app/etc/modules/Openlabs_OpenERPConnector.xml 1970-01-01 00:00:00 +0000
+++ Openlabs_OpenERPConnector-1.1.0/app/etc/modules/Openlabs_OpenERPConnector.xml 2012-08-10 13:28:19 +0000
@@ -0,0 +1,41 @@
1<?xml version="1.0"?>
2
3<!--
4##############################################################################
5#
6# OpenERP, Open Source Management Solution
7# Copyright (C) 2004-2008 Tiny SPRL (<http://tiny.be>). All Rights Reserved
8# Sharoon Thomas
9#
10# This program is free software: you can redistribute it and/or modify
11# it under the terms of the GNU General Public License as published by
12# the Free Software Foundation, either version 3 of the License, or
13# (at your option) any later version.
14#
15# This program is distributed in the hope that it will be useful,
16# but WITHOUT ANY WARRANTY; without even the implied warranty of
17# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18# GNU General Public License for more details.
19#
20# You should have received a copy of the GNU General Public License
21# along with this program. If not, see <http://www.gnu.org/licenses/>.
22#
23##############################################################################
24# * @category Community
25# * @package
26# * @copyright Copyright (c) 2009 Sharoon Thomas, openlabs.co.in
27# * @license GPL-3
28# */
29-->
30<config>
31 <modules>
32 <Openlabs_OpenERPConnector>
33 <codePool>community</codePool>
34 <active>true</active>
35 <depends>
36 <Mage_Api />
37 <Mage_Catalog />
38 </depends>
39 </Openlabs_OpenERPConnector>
40 </modules>
41</config>
042
=== added directory 'Savoirfairelinux_Claim'
=== added directory 'Savoirfairelinux_Claim/app'
=== added directory 'Savoirfairelinux_Claim/app/code'
=== added directory 'Savoirfairelinux_Claim/app/code/local'
=== added directory 'Savoirfairelinux_Claim/app/code/local/Savoirfairelinux'
=== added directory 'Savoirfairelinux_Claim/app/code/local/Savoirfairelinux/Claim'
=== added directory 'Savoirfairelinux_Claim/app/code/local/Savoirfairelinux/Claim/Block'
=== added file 'Savoirfairelinux_Claim/app/code/local/Savoirfairelinux/Claim/Block/Form.php'
--- Savoirfairelinux_Claim/app/code/local/Savoirfairelinux/Claim/Block/Form.php 1970-01-01 00:00:00 +0000
+++ Savoirfairelinux_Claim/app/code/local/Savoirfairelinux/Claim/Block/Form.php 2012-08-10 13:28:19 +0000
@@ -0,0 +1,160 @@
1<?php
2/**
3 * Magento
4 *
5 * NOTICE OF LICENSE
6 *
7 * Savoirfairelinux_Claim
8 * Copyright (C) 2012 Savoir-faire Linux
9 *
10 * This program is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation, either version 3 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 *
23 * DISCLAIMER
24 *
25 * Do not edit or add to this file if you wish to upgrade Magento to newer
26 * versions in the future. If you wish to customize Magento for your
27 * needs please refer to http://www.magentocommerce.com for more information.
28 *
29 * @category Savoirfairelinux
30 * @package Savoirfairelinux_Claim
31 * @copyright Copyright (c) 2012 Savoir-faire Linux. (http://www.savoirfairelinux.com)
32 * @license http://www.gnu.org/licenses/gpl.html General Public License (GPLv3)
33 */
34
35/**
36 * Customer Complains block
37 *
38 * @category Savoirfairelinux
39 * @package Savoirfairelinux_Claim
40 * @author Joao Alfredo Gama Batista <joao.gama@savoirfairelinux.com>
41 */
42class Savoirfairelinux_Claim_Block_Form extends Mage_Customer_Block_Account_Dashboard
43{
44
45 protected $_collection;
46
47 const XML_PATH_ENABLED = 'claim/claim/enabled';
48 const XML_PATH_OPENERP_URL = 'claim/settings/openerp_url';
49 const XML_PATH_OPENERP_LOGIN = 'claim/settings/openerp_login';
50 const XML_PATH_OPENERP_PASSWORD = 'claim/settings/openerp_password';
51 const XML_PATH_OPENERP_DATABASE = 'claim/settings/openerp_database';
52 const XML_PATH_OPENERP_CLAIM_REF = 'claim/settings/openerp_claim_ref';
53 const XML_PATH_OPENERP_CLAIM_REF_PREFIX = 'claim/settings/openerp_claim_ref_prefix';
54
55 /* protected function _construct() */
56 /* { */
57 /* /\* $this->_collection = Mage::getModel('review/review')->getProductCollection(); *\/ */
58 /* /\* $this->_collection *\/ */
59 /* /\* ->addStoreFilter(Mage::app()->getStore()->getId()) *\/ */
60 /* /\* ->addCustomerFilter(Mage::getSingleton('customer/session')->getCustomerId()) *\/ */
61 /* /\* ->setDateOrder(); *\/ */
62
63 /* $this->partner_name = Mage::helper('contacts')->getUserName(); */
64 /* $this->partner_email = Mage::helper('contacts')->getUserEmail(); */
65
66 /* $this->openerp = new Savoirfairelinux_Claim_Openerpclient */
67 /* (Mage::getStoreConfig(self::XML_PATH_OPENERP_LOGIN), */
68 /* Mage::helper('core')->decrypt(Mage::getStoreConfig(self::XML_PATH_OPENERP_PASSWORD)), */
69 /* Mage::getStoreConfig(self::XML_PATH_OPENERP_DATABASE), */
70 /* Mage::getStoreConfig(self::XML_PATH_OPENERP_URL), */
71 /* Mage::getStoreConfig(self::XML_PATH_OPENERP_CLAIM_REF), */
72 /* Mage::getStoreConfig(self::XML_PATH_OPENERP_CLAIM_REF_PREFIX) */
73 /* ); */
74 /* parent::__construct(); */
75
76 /* } */
77
78 public function isPartner()
79 {
80 $this->partner_name = Mage::helper('contacts')->getUserName();
81 $this->partner_email = Mage::helper('contacts')->getUserEmail();
82
83 if( $this->openerp->isPartner($this->partner_name, $this->partner_email) )
84 return True;
85 else
86 return False;
87
88 }
89
90 public function isConnected()
91 {
92 try {
93 $this->openerp = new Savoirfairelinux_Claim_Openerpclient
94 (Mage::getStoreConfig(self::XML_PATH_OPENERP_LOGIN),
95 Mage::helper('core')->decrypt(Mage::getStoreConfig(self::XML_PATH_OPENERP_PASSWORD)),
96 Mage::getStoreConfig(self::XML_PATH_OPENERP_DATABASE),
97 Mage::getStoreConfig(self::XML_PATH_OPENERP_URL),
98 Mage::getStoreConfig(self::XML_PATH_OPENERP_CLAIM_REF),
99 Mage::getStoreConfig(self::XML_PATH_OPENERP_CLAIM_REF_PREFIX));
100
101 } catch (Exception $e) {
102 return False;
103 }
104
105 return True;
106 }
107
108 public function count()
109 {
110 return $this->_collection->getSize();
111 }
112
113 public function getToolbarHtml()
114 {
115 return $this->getChildHtml('toolbar');
116 }
117
118 /* protected function _prepareLayout() */
119 /* { */
120 /* $toolbar = $this->getLayout()->createBlock('page/html_pager', 'customer_review_list.toolbar') */
121 /* ->setCollection($this->_getCollection()); */
122
123 /* $this->setChild('toolbar', $toolbar); */
124 /* return parent::_prepareLayout(); */
125 /* } */
126
127 protected function _getCollection()
128 {
129 return $this->_collection;
130 }
131
132 public function getCollection()
133 {
134 return $this->_getCollection();
135 }
136
137 public function getReviewLink()
138 {
139 return Mage::getUrl('review/customer/view/');
140 }
141
142 public function getProductLink()
143 {
144 return Mage::getUrl('catalog/product/view/');
145 }
146
147 public function dateFormat($date)
148 {
149 return $this->formatDate($date, Mage_Core_Model_Locale::FORMAT_TYPE_SHORT);
150 }
151
152 /* protected function _beforeToHtml() */
153 /* { */
154 /* $this->_getCollection() */
155 /* ->load() */
156 /* ->addReviewSummary(); */
157 /* return parent::_beforeToHtml(); */
158 /* } */
159
160}
0161
=== added directory 'Savoirfairelinux_Claim/app/code/local/Savoirfairelinux/Claim/Helper'
=== added file 'Savoirfairelinux_Claim/app/code/local/Savoirfairelinux/Claim/Helper/Data.php'
--- Savoirfairelinux_Claim/app/code/local/Savoirfairelinux/Claim/Helper/Data.php 1970-01-01 00:00:00 +0000
+++ Savoirfairelinux_Claim/app/code/local/Savoirfairelinux/Claim/Helper/Data.php 2012-08-10 13:28:19 +0000
@@ -0,0 +1,74 @@
1<?php
2/**
3 * Magento
4 *
5 * NOTICE OF LICENSE
6 *
7 * Savoirfairelinux_Claim
8 * Copyright (C) 2012 Savoir-faire Linux
9 *
10 * This program is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation, either version 3 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 *
23 * DISCLAIMER
24 *
25 * Do not edit or add to this file if you wish to upgrade Magento to newer
26 * versions in the future. If you wish to customize Magento for your
27 * needs please refer to http://www.magentocommerce.com for more information.
28 *
29 * @category Savoirfairelinux
30 * @package Savoirfairelinux_Claim
31 * @copyright Copyright (c) 2012 Savoir-faire Linux. (http://www.savoirfairelinux.com)
32 * @license http://www.gnu.org/licenses/gpl.html General Public License (GPLv3)
33 */
34
35/**
36 * Default claim helper
37 *
38 * @author Joao Alfredo Gama Batista <joao.gama@savoirfairelinux.com>
39 */
40class Savoirfairelinux_Claim_Helper_Data extends Mage_Core_Helper_Abstract
41{
42
43 const XML_PATH_ENABLED = 'claim/claim/enabled';
44
45 public function getOrdersHtmlSelect()
46 {
47 if (Mage::getSingleton('customer/session')->isLoggedIn()) {
48 $options = array();
49
50 $orders = Mage::getResourceModel('sales/order_collection')
51 ->addFieldToSelect('*')
52 ->addFieldToFilter('customer_id', Mage::getSingleton('customer/session')->getCustomer()->getId())
53 ->addFieldToFilter('state', array('in' => Mage::getSingleton('sales/order_config')->getVisibleOnFrontStates()))
54 ->setOrder('created_at', 'desc')
55 ;
56
57 foreach ($orders as $order) {
58 $options[] = array('value' => $order->getRealOrderId(),
59 'label' => $order->getRealOrderId());
60 }
61 $select = $this->getLayout()->createBlock('core/html_select')
62 ->setName('order')
63 ->setId('order')
64 ->setTitle(Mage::helper('claim')->__('Order'))
65 ->setClass('validate-select')
66 ->setValue()
67 ->setOptions($options);
68
69 return $select->getHtml();
70 }
71 return '';
72 }
73
74}
075
=== added directory 'Savoirfairelinux_Claim/app/code/local/Savoirfairelinux/Claim/Model'
=== added directory 'Savoirfairelinux_Claim/app/code/local/Savoirfairelinux/Claim/Model/System'
=== added directory 'Savoirfairelinux_Claim/app/code/local/Savoirfairelinux/Claim/Model/System/Config'
=== added directory 'Savoirfairelinux_Claim/app/code/local/Savoirfairelinux/Claim/Model/System/Config/Backend'
=== added file 'Savoirfairelinux_Claim/app/code/local/Savoirfairelinux/Claim/Model/System/Config/Backend/Links.php'
--- Savoirfairelinux_Claim/app/code/local/Savoirfairelinux/Claim/Model/System/Config/Backend/Links.php 1970-01-01 00:00:00 +0000
+++ Savoirfairelinux_Claim/app/code/local/Savoirfairelinux/Claim/Model/System/Config/Backend/Links.php 2012-08-10 13:28:19 +0000
@@ -0,0 +1,48 @@
1<?php
2/**
3 * Magento
4 *
5 * NOTICE OF LICENSE
6 *
7 * Savoirfairelinux_Claim
8 * Copyright (C) 2012 Savoir-faire Linux
9 *
10 * This program is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation, either version 3 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 *
23 * DISCLAIMER
24 *
25 * Do not edit or add to this file if you wish to upgrade Magento to newer
26 * versions in the future. If you wish to customize Magento for your
27 * needs please refer to http://www.magentocommerce.com for more information.
28 *
29 * @category Savoirfairelinux
30 * @package Savoirfairelinux_Claim
31 * @copyright Copyright (c) 2012 Savoir-faire Linux. (http://www.savoirfairelinux.com)
32 * @license http://www.gnu.org/licenses/gpl.html General Public License (GPLv3)
33 */
34
35/**
36 * Cache cleaner backend model
37 *
38 */
39class Savoirfairelinux_Claim_Model_System_Config_Backend_Links extends Mage_Adminhtml_Model_System_Config_Backend_Cache
40{
41 /**
42 * Cache tags to clean
43 *
44 * @var array
45 */
46 protected $_cacheTags = array(Mage_Core_Model_Store::CACHE_TAG, Mage_Cms_Model_Block::CACHE_TAG);
47
48}
049
=== added directory 'Savoirfairelinux_Claim/app/code/local/Savoirfairelinux/Claim/controllers'
=== added file 'Savoirfairelinux_Claim/app/code/local/Savoirfairelinux/Claim/controllers/IndexController.php'
--- Savoirfairelinux_Claim/app/code/local/Savoirfairelinux/Claim/controllers/IndexController.php 1970-01-01 00:00:00 +0000
+++ Savoirfairelinux_Claim/app/code/local/Savoirfairelinux/Claim/controllers/IndexController.php 2012-08-10 13:28:19 +0000
@@ -0,0 +1,360 @@
1<?php
2/**
3 * Magento
4 *
5 * NOTICE OF LICENSE
6 *
7 * Savoirfairelinux_Claim
8 * Copyright (C) 2012 Savoir-faire Linux
9 *
10 * This program is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation, either version 3 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 *
23 * DISCLAIMER
24 *
25 * Do not edit or add to this file if you wish to upgrade Magento to newer
26 * versions in the future. If you wish to customize Magento for your
27 * needs please refer to http://www.magentocommerce.com for more information.
28 *
29 * @category Savoirfairelinux
30 * @package Savoirfairelinux_Claim
31 * @copyright Copyright (c) 2012 Savoir-faire Linux. (http://www.savoirfairelinux.com)
32 * @license http://www.gnu.org/licenses/gpl.html General Public License (GPLv3)
33 */
34
35/**
36 * Claim index controller
37 *
38 * @category Savoirfairelinux
39 * @package Savoirfairelinux_Claim
40 * @author Joao Alfredo Gama Batista <joao.gama@savoirfairelinux.com>
41 */
42
43class Savoirfairelinux_Claim_IndexController extends Mage_Core_Controller_Front_Action
44{
45
46 const XML_PATH_ENABLED = 'claim/claim/enabled';
47 const XML_PATH_OPENERP_URL = 'claim/settings/openerp_url';
48 const XML_PATH_OPENERP_LOGIN = 'claim/settings/openerp_login';
49 const XML_PATH_OPENERP_PASSWORD = 'claim/settings/openerp_password';
50 const XML_PATH_OPENERP_DATABASE = 'claim/settings/openerp_database';
51 const XML_PATH_OPENERP_CLAIM_REF = 'claim/settings/openerp_claim_ref';
52 const XML_PATH_OPENERP_CLAIM_REF_PREFIX = 'claim/settings/openerp_claim_ref_prefix';
53
54 public function preDispatch()
55 {
56 parent::preDispatch();
57 $translate = Mage::getSingleton('core/translate');
58
59 if( !Mage::getStoreConfigFlag(self::XML_PATH_ENABLED) ) {
60 $this->norouteAction();
61 }
62
63 if( !Mage::getSingleton('customer/session')->authenticate($this) ) {
64 $this->setFlag('', self::FLAG_NO_DISPATCH, true);
65 }
66
67 $this->partner_name = Mage::helper('contacts')->getUserName();
68
69 $this->partner_email = Mage::helper('contacts')->getUserEmail();
70
71 return;
72 }
73
74 public function indexAction()
75 {
76 $this->loadLayout();
77
78 $this->getLayout()->getBlock('claimForm')
79 ->setFormAction( Mage::getUrl('*/*/post') )
80 ->setRefererUrl($this->_getRefererUrl());
81
82 if ($navigationBlock = $this->getLayout()->getBlock('customer_account_navigation')) {
83 $navigationBlock->setActive('claim');
84 }
85
86 $this->_initLayoutMessages('customer/session');
87 $this->_initLayoutMessages('catalog/session');
88 $this->renderLayout();
89 }
90
91 public function postAction()
92 {
93
94 $post = $this->getRequest()->getPost();
95 if ( $post ) {
96 $translate = Mage::getSingleton('core/translate');
97 /* @var $translate Mage_Core_Model_Translate */
98 $translate->setTranslateInline(false);
99 try {
100 $postObject = new Varien_Object();
101 $postObject->setData($post);
102
103 $error = false;
104
105 If (!Zend_Validate::is(trim($post['subject']) , 'NotEmpty')) {
106 $error = true;
107 }
108
109 if ($error) {
110 throw new Exception();
111 }
112
113 $this->openerp = new Savoirfairelinux_Claim_Openerpclient
114 (Mage::getStoreConfig(self::XML_PATH_OPENERP_LOGIN),
115 Mage::helper('core')->decrypt(Mage::getStoreConfig(self::XML_PATH_OPENERP_PASSWORD)),
116 Mage::getStoreConfig(self::XML_PATH_OPENERP_DATABASE),
117 Mage::getStoreConfig(self::XML_PATH_OPENERP_URL),
118 Mage::getStoreConfig(self::XML_PATH_OPENERP_CLAIM_REF),
119 Mage::getStoreConfig(self::XML_PATH_OPENERP_CLAIM_REF_PREFIX)
120 );
121
122 /* $openerp->connect(); */
123 $partner_id = $this->openerp->getPartnerId($this->partner_name,
124 $this->partner_email);
125 $partner_contact_id = $this->openerp->getPartnerContactId($partner_id);
126 $order_id = $this->openerp->getOrderId(trim($post['order']));
127 $this->openerp->createClaim($partner_id,
128 $partner_contact_id,
129 $order_id,
130 trim($post['subject']),
131 trim($post['claim']));
132
133
134 $translate->setTranslateInline(true);
135
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.'));
137 $this->_redirect('*/*/');
138
139 return;
140 } catch (Exception $e) {
141 $translate->setTranslateInline(true);
142
143 Mage::getSingleton('customer/session')->addError(Mage::helper('claim')->__('Unable to submit your complaint. Please, try again later.'));
144 $this->_redirect('*/*/');
145 return;
146 }
147
148 } else {
149 $this->_redirect('*/*/');
150 }
151 }
152
153}
154
155class Savoirfairelinux_Claim_Openerpclient
156{
157
158 function __construct($usr, $pass, $db, $server, $claim_ref, $claim_ref_prefix)
159 {
160
161 $ExternalLibPath=Mage::getModuleDir('', 'Savoirfairelinux_Claim').DS.'lib'.DS.'xmlrpc.inc';
162 require_once ($ExternalLibPath);
163
164 $this->user = $usr;
165 $this->password = $pass;
166 $this->database = $db;
167 $this->services = $server;
168 $this->claim_ref = $claim_ref;
169 $this->claim_ref_prefix = $claim_ref_prefix;
170
171 $this->client = new xmlrpc_client($this->services.'common');
172
173 $this->msg = new xmlrpcmsg('login');
174 $this->msg->addParam(new xmlrpcval($this->database, "string"));
175 $this->msg->addParam(new xmlrpcval($this->user, "string"));
176 $this->msg->addParam(new xmlrpcval($this->password, "string"));
177
178 $this->res = &$this->client->send($this->msg);
179
180 if(!$this->res->faultCode()){
181 $this->userid = $this->res->value()->scalarval();
182 }
183 else {
184 Mage::log("Unable to login ".$this->res->faultString());
185 throw new Exception();
186 exit;
187 }
188 }
189
190 public function getPartnerId($partner, $email)
191 {
192 Mage::log('getPartnerId: '.$partner);
193
194 $key = array(new xmlrpcval(array(new xmlrpcval("name" , "string"),
195 new xmlrpcval("=","string"),
196 new xmlrpcval($partner, "string")),"array"),
197 );
198
199 $ids = $this->search('res.partner', $key);
200 if(sizeof($ids) == 0) {
201 $id = -1;
202 } elseif(sizeof($ids) == 1) {
203 $id = $ids[0]->scalarval();
204 } elseif( sizeof($ids) > 1) {
205 foreach( $ids as $v ) {
206 $m = $this->getPartnerEmail($v);
207 if( $m == $email )
208 $id = $v->scalarval();
209 }
210 }
211 /* return $ids; */
212 Mage::log('getPartnerId: '.$id);
213 return $id;
214 }
215
216 public function isPartner($name, $email)
217 {
218 $partner_id = $this->getPartnerId($name, $email);
219 if( $partner_id == -1 )
220 $ret = False;
221 else
222 $ret = True;
223
224 return $ret;
225 }
226
227 public function getPartnerContactId($partner_id)
228 {
229 Mage::log('getPartnerContactId: '.$partner_id);
230
231 $key = array(new xmlrpcval(array(new xmlrpcval("partner_id" , "string"),
232 new xmlrpcval("=","string"),
233 new xmlrpcval($partner_id, "int")),"array"));
234
235 $ids = $this->search('res.partner.address', $key);
236 /* return $ids; */
237 Mage::log('getpartnerContactId: '.$ids[0]->scalarval());
238 return $ids[0]->scalarval();
239 }
240
241 public function getOrderId($order)
242 {
243
244 $key = array(new xmlrpcval(array(new xmlrpcval("name" , "string"),
245 new xmlrpcval("=","string"),
246 new xmlrpcval($this->claim_ref_prefix.$order, "string")),"array"),
247 );
248
249 $ids = $this->search($this->claim_ref, $key);
250 if( sizeof($ids) > 1 ) {
251 Mage::log('Duplicated orders error!!');
252 throw new Exception();
253 }
254
255 /* return $ids; */
256 Mage::log('Order_id: '.$ids[0]->scalarval());
257 return $ids[0]->scalarval();
258 }
259
260 public function createClaim($partner,
261 $partner_address,
262 $order,
263 $subject,
264 $description)
265 {
266 $arrayVal = array(
267 'name'=>new xmlrpcval($subject, "string") ,
268 'description'=>new xmlrpcval($description, "string"),
269 'partner_id'=>new xmlrpcval($partner, "int"),
270 'partner_address_id'=>new xmlrpcval($partner_address, "int"),
271 'ref'=>new xmlrpcval('sale.order,'.$order, 'string')
272 );
273
274 $this->client = new xmlrpc_client($this->services."object");
275
276 $this->msg = new xmlrpcmsg('execute');
277 $this->msg->addParam(new xmlrpcval($this->database, "string"));
278 $this->msg->addParam(new xmlrpcval($this->userid, "int"));
279 $this->msg->addParam(new xmlrpcval($this->password, "string"));
280 $this->msg->addParam(new xmlrpcval("crm.claim", "string"));
281 $this->msg->addParam(new xmlrpcval("create", "string"));
282 $this->msg->addParam(new xmlrpcval($arrayVal, "struct"));
283
284 $this->resp = $this->client->send($this->msg);
285
286 if ($this->resp->faultCode())
287 Mage::log('Error: '.$this->resp->faultString());
288 else
289 Mage::log('Claim '.$this->resp->value()->scalarval().' created !');
290
291 }
292
293 public function getPartnerEmail($partner_id)
294 {
295 Mage::log('getPartnerEmail: '.$partner_id->scalarval());
296
297 $ids = array($partner_id);
298 $fields = array(new xmlrpcval('email', 'string'));
299
300 $ids = $this->read('res.partner', $ids, $fields);
301
302 $id = $ids[0]->scalarval();
303 Mage::log('getPartnerEmail: '.$id['email']->scalarval());
304 return $id['email']->scalarval();
305 }
306
307 public function search($relation, $key)
308 {
309 Mage::log('search: '.$relation);
310 $this->client = new xmlrpc_client($this->services.'object');
311
312 $this->msg = new xmlrpcmsg('execute');
313 $this->msg->addParam(new xmlrpcval($this->database, "string"));
314 $this->msg->addParam(new xmlrpcval($this->userid, "int"));
315 $this->msg->addParam(new xmlrpcval($this->password, "string"));
316 $this->msg->addParam(new xmlrpcval($relation, "string"));
317 $this->msg->addParam(new xmlrpcval("search", "string"));
318 $this->msg->addParam(new xmlrpcval($key, "array"));
319
320 $this->resp = $this->client->send($this->msg);
321
322 if ($this->resp->faultCode()) {
323 Mage::log('Search error: '.$this->resp->faultString());
324 $id = '';
325 } else {
326 Mage::log('Search '.$relation.' succeded !');
327 $id = $this->resp->value()->scalarval();
328 }
329
330 return $id;
331 }
332
333 public function read($relation, $ids, $fields)
334 {
335 Mage::log('read: '.$relation);
336 $this->client = new xmlrpc_client($this->services.'object');
337
338 $this->msg = new xmlrpcmsg('execute');
339 $this->msg->addParam(new xmlrpcval($this->database, "string"));
340 $this->msg->addParam(new xmlrpcval($this->userid, "int"));
341 $this->msg->addParam(new xmlrpcval($this->password, "string"));
342 $this->msg->addParam(new xmlrpcval($relation, "string"));
343 $this->msg->addParam(new xmlrpcval("read", "string"));
344 $this->msg->addParam(new xmlrpcval($ids, "array"));
345 $this->msg->addParam(new xmlrpcval($fields, "array"));
346
347 $this->resp = $this->client->send($this->msg);
348
349 if ($this->resp->faultCode()) {
350 Mage::log('Read error: '.$this->resp->faultString());
351 $id = '';
352 } else {
353 Mage::log('Read '.$relation.' succeded !');
354 $id = $this->resp->value()->scalarval();
355 }
356
357 return $id;
358 }
359
360}
0361
=== added directory 'Savoirfairelinux_Claim/app/code/local/Savoirfairelinux/Claim/etc'
=== added file 'Savoirfairelinux_Claim/app/code/local/Savoirfairelinux/Claim/etc/adminhtml.xml'
--- Savoirfairelinux_Claim/app/code/local/Savoirfairelinux/Claim/etc/adminhtml.xml 1970-01-01 00:00:00 +0000
+++ Savoirfairelinux_Claim/app/code/local/Savoirfairelinux/Claim/etc/adminhtml.xml 2012-08-10 13:28:19 +0000
@@ -0,0 +1,22 @@
1<?xml version="1.0" encoding="utf-8"?>
2<config>
3 <acl>
4 <resources>
5 <admin>
6 <children>
7 <system>
8 <children>
9 <config>
10 <children>
11 <claim translate="title" module="claim">
12 <title>Complaints Settings</title>
13 </claim>
14 </children>
15 </config>
16 </children>
17 </system>
18 </children>
19 </admin>
20 </resources>
21 </acl>
22</config>
0\ No newline at end of file23\ No newline at end of file
124
=== added file 'Savoirfairelinux_Claim/app/code/local/Savoirfairelinux/Claim/etc/config.xml'
--- Savoirfairelinux_Claim/app/code/local/Savoirfairelinux/Claim/etc/config.xml 1970-01-01 00:00:00 +0000
+++ Savoirfairelinux_Claim/app/code/local/Savoirfairelinux/Claim/etc/config.xml 2012-08-10 13:28:19 +0000
@@ -0,0 +1,117 @@
1<?xml version="1.0"?>
2<!--
3/**
4 * Magento
5 *
6 * NOTICE OF LICENSE
7 *
8 * Savoirfairelinux_Claim
9 * Copyright (C) 2012 Savoir-faire Linux
10 *
11 * This program is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation, either version 3 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program. If not, see <http://www.gnu.org/licenses/>.
23 *
24 * DISCLAIMER
25 *
26 * Do not edit or add to this file if you wish to upgrade Magento to newer
27 * versions in the future. If you wish to customize Magento for your
28 * needs please refer to http://www.magentocommerce.com for more information.
29 *
30 * @category Savoirfairelinux
31 * @package Savoirfairelinux_Claim
32 * @copyright Copyright (c) 2012 Savoir-faire Linux (http://www.savoirfairelinux.com)
33 * @license http://www.gnu.org/licenses/gpl.html General Public License (GPLv3)
34 */
35-->
36<config>
37 <modules>
38 <Savoirfairelinux_Claim>
39 <version>0.1.1</version>
40 </Savoirfairelinux_Claim>
41 </modules>
42 <global>
43 <!-- <resources> -->
44 <!-- <claim_setup> -->
45 <!-- <setup> -->
46 <!-- <module>Savoirfairelinux_Claim</module> -->
47 <!-- </setup> -->
48 <!-- </claim_setup> -->
49 <!-- </resources> -->
50 <helpers>
51 <claim>
52 <class>Savoirfairelinux_Claim_Helper</class>
53 </claim>
54 </helpers>
55
56 <blocks>
57 <claim>
58 <class>Savoirfairelinux_Claim_Block</class>
59 </claim>
60 </blocks>
61
62 </global>
63
64 <adminhtml>
65 <translate>
66 <modules>
67 <Savoirfairelinux_Claim>
68 <files>
69 <default>Savoirfairelinux_Claim.csv</default>
70 </files>
71 </Savoirfairelinux_Claim>
72 </modules>
73 </translate>
74 </adminhtml>
75 <frontend>
76 <routers>
77 <claim>
78 <use>standard</use>
79 <args>
80 <module>Savoirfairelinux_Claim</module>
81 <frontName>claim</frontName>
82 </args>
83 </claim>
84 </routers>
85 <translate>
86 <modules>
87 <Savoirfairelinux_Claim>
88 <files>
89 <default>Savoirfairelinux_Claim.csv</default>
90 </files>
91 </Savoirfairelinux_Claim>
92 </modules>
93 </translate>
94 <layout>
95 <updates>
96 <claim>
97 <file>savoirfairelinux_claim.xml</file>
98 </claim>
99 </updates>
100 </layout>
101 </frontend>
102 <default>
103 <claim>
104 <claim>
105 <enabled>1</enabled>
106 </claim>
107 <settings>
108 <openerp_url>http://localhost:8069/xmlrpc/</openerp_url>
109 <openerp_database>test</openerp_database>
110 <openerp_login>admin</openerp_login>
111 <openerp_password>admin123</openerp_password>
112 <openerp_claim_ref>sale.order</openerp_claim_ref>
113 <openerp_claim_ref_prefix>mag_</openerp_claim_ref_prefix>
114 </settings>
115 </claim>
116 </default>
117</config>
0118
=== added directory 'Savoirfairelinux_Claim/app/code/local/Savoirfairelinux/Claim/etc/modules'
=== added file 'Savoirfairelinux_Claim/app/code/local/Savoirfairelinux/Claim/etc/modules/Savoirfairelinux_Claim.xml'
--- Savoirfairelinux_Claim/app/code/local/Savoirfairelinux/Claim/etc/modules/Savoirfairelinux_Claim.xml 1970-01-01 00:00:00 +0000
+++ Savoirfairelinux_Claim/app/code/local/Savoirfairelinux/Claim/etc/modules/Savoirfairelinux_Claim.xml 2012-08-10 13:28:19 +0000
@@ -0,0 +1,9 @@
1<?xml version="1.0" encoding="utf-8"?>
2<config>
3 <modules>
4 <Savoirfairelinux_Claim>
5 <active>true</active>
6 <codePool>local</codePool>
7 </Savoirfairelinux_Claim>
8 </modules>
9</config>
010
=== added file 'Savoirfairelinux_Claim/app/code/local/Savoirfairelinux/Claim/etc/system.xml'
--- Savoirfairelinux_Claim/app/code/local/Savoirfairelinux/Claim/etc/system.xml 1970-01-01 00:00:00 +0000
+++ Savoirfairelinux_Claim/app/code/local/Savoirfairelinux/Claim/etc/system.xml 2012-08-10 13:28:19 +0000
@@ -0,0 +1,114 @@
1<?xml version="1.0" encoding="utf-8"?>
2<config>
3 <sections>
4 <claim translate="label" module="claim">
5 <label>Complaints</label>
6 <tab>customer</tab>
7 <frontend_type>text</frontend_type>
8 <sort_order>990</sort_order>
9 <show_in_default>1</show_in_default>
10 <show_in_website>1</show_in_website>
11 <show_in_store>1</show_in_store>
12 <groups>
13 <claim translate="label">
14 <label>Claim</label>
15 <frontend_type>text</frontend_type>
16 <sort_order>20</sort_order>
17 <show_in_default>1</show_in_default>
18 <show_in_website>1</show_in_website>
19 <show_in_store>1</show_in_store>
20 <fields>
21 <enabled translate="label">
22 <label>Enabled</label>
23 <frontend_type>select</frontend_type>
24 <source_model>adminhtml/system_config_source_yesno</source_model>
25 <!-- <backend_model>claim/system_config_backend_links</backend_model> -->
26 <sort_order>4</sort_order>
27 <show_in_default>1</show_in_default>
28 <show_in_website>1</show_in_website>
29 <show_in_store>1</show_in_store>
30 </enabled>
31
32 <!-- <enabled translate="label"> -->
33 <!-- <label>Enabled</label> -->
34 <!-- <frontend_type>select</frontend_type> -->
35 <!-- <source_model>adminhtml/system_config_source_yesno</source_model> -->
36 <!-- <backend_model>savoirfairelinux_claim/system_config_backend_links</backend_model> -->
37 <!-- <sort_order>1</sort_order> -->
38 <!-- <show_in_default>1</show_in_default> -->
39 <!-- <show_in_website>1</show_in_website> -->
40 <!-- <show_in_store>1</show_in_store> -->
41 <!-- </enabled> -->
42 </fields>
43 </claim>
44 <settings translate="label">
45 <label>OpenERP Settings</label>
46 <frontend_type>text</frontend_type>
47 <sort_order>20</sort_order>
48 <show_in_default>1</show_in_default>
49 <show_in_website>1</show_in_website>
50 <show_in_store>1</show_in_store>
51 <fields>
52 <openerp_url translate="label,comment">
53 <label>OpenERP server URL</label>
54 <comment><![CDATA[]]></comment>
55 <frontend_type>text</frontend_type>
56 <sort_order>1</sort_order>
57 <show_in_default>1</show_in_default>
58 <show_in_website>1</show_in_website>
59 <show_in_store>1</show_in_store>
60 </openerp_url>
61 <openerp_database translate="label,comment">
62 <label>OpenERP database name</label>
63 <comment><![CDATA[]]></comment>
64 <frontend_type>text</frontend_type>
65 <sort_order>1</sort_order>
66 <show_in_default>1</show_in_default>
67 <show_in_website>1</show_in_website>
68 <show_in_store>1</show_in_store>
69 </openerp_database>
70
71 <openerp_login translate="label">
72 <label>OpenERP login</label>
73 <frontend_type>text</frontend_type>
74 <sort_order>2</sort_order>
75 <show_in_default>1</show_in_default>
76 <show_in_website>1</show_in_website>
77 <show_in_store>1</show_in_store>
78 </openerp_login>
79 <openerp_password translate="label,comment">
80 <label>OpenERP password</label>
81 <comment></comment>
82 <backend_model>adminhtml/system_config_backend_encrypted</backend_model>
83 <frontend_type>obscure</frontend_type>
84 <sort_order>3</sort_order>
85 <show_in_default>1</show_in_default>
86 <show_in_website>1</show_in_website>
87 <show_in_store>1</show_in_store>
88 </openerp_password>
89 <openerp_claim_ref translate="label,comment">
90 <label>OpenERP Reference field entity</label>
91 <comment></comment>
92 <frontend_type>text</frontend_type>
93 <sort_order>4</sort_order>
94 <show_in_default>1</show_in_default>
95 <show_in_website>1</show_in_website>
96 <show_in_store>1</show_in_store>
97 </openerp_claim_ref>
98 <openerp_claim_ref_prefix translate="label,comment">
99 <label>OpenERP Reference field prefix</label>
100 <comment></comment>
101 <frontend_type>text</frontend_type>
102 <sort_order>5</sort_order>
103 <show_in_default>1</show_in_default>
104 <show_in_website>1</show_in_website>
105 <show_in_store>1</show_in_store>
106 </openerp_claim_ref_prefix>
107 </fields>
108 </settings>
109 </groups>
110 </claim>
111 </sections>
112</config>
113
114
0\ No newline at end of file115\ No newline at end of file
1116
=== added directory 'Savoirfairelinux_Claim/app/code/local/Savoirfairelinux/Claim/lib'
=== added file 'Savoirfairelinux_Claim/app/code/local/Savoirfairelinux/Claim/lib/xmlrpc.inc'
--- Savoirfairelinux_Claim/app/code/local/Savoirfairelinux/Claim/lib/xmlrpc.inc 1970-01-01 00:00:00 +0000
+++ Savoirfairelinux_Claim/app/code/local/Savoirfairelinux/Claim/lib/xmlrpc.inc 2012-08-10 13:28:19 +0000
@@ -0,0 +1,3776 @@
1<?php
2// by Edd Dumbill (C) 1999-2002
3// <edd@usefulinc.com>
4// $Id: xmlrpc.inc,v 1.174 2009/03/16 19:36:38 ggiunta Exp $
5
6// Copyright (c) 1999,2000,2002 Edd Dumbill.
7// All rights reserved.
8//
9// Redistribution and use in source and binary forms, with or without
10// modification, are permitted provided that the following conditions
11// are met:
12//
13// * Redistributions of source code must retain the above copyright
14// notice, this list of conditions and the following disclaimer.
15//
16// * Redistributions in binary form must reproduce the above
17// copyright notice, this list of conditions and the following
18// disclaimer in the documentation and/or other materials provided
19// with the distribution.
20//
21// * Neither the name of the "XML-RPC for PHP" nor the names of its
22// contributors may be used to endorse or promote products derived
23// from this software without specific prior written permission.
24//
25// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
28// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
29// REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
30// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
31// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
32// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
34// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
36// OF THE POSSIBILITY OF SUCH DAMAGE.
37
38 if(!function_exists('xml_parser_create'))
39 {
40 // For PHP 4 onward, XML functionality is always compiled-in on windows:
41 // no more need to dl-open it. It might have been compiled out on *nix...
42 if(strtoupper(substr(PHP_OS, 0, 3) != 'WIN'))
43 {
44 dl('xml.so');
45 }
46 }
47
48 // G. Giunta 2005/01/29: declare global these variables,
49 // so that xmlrpc.inc will work even if included from within a function
50 // Milosch: 2005/08/07 - explicitly request these via $GLOBALS where used.
51 $GLOBALS['xmlrpcI4']='i4';
52 $GLOBALS['xmlrpcInt']='int';
53 $GLOBALS['xmlrpcBoolean']='boolean';
54 $GLOBALS['xmlrpcDouble']='double';
55 $GLOBALS['xmlrpcString']='string';
56 $GLOBALS['xmlrpcDateTime']='dateTime.iso8601';
57 $GLOBALS['xmlrpcBase64']='base64';
58 $GLOBALS['xmlrpcArray']='array';
59 $GLOBALS['xmlrpcStruct']='struct';
60 $GLOBALS['xmlrpcValue']='undefined';
61
62 $GLOBALS['xmlrpcTypes']=array(
63 $GLOBALS['xmlrpcI4'] => 1,
64 $GLOBALS['xmlrpcInt'] => 1,
65 $GLOBALS['xmlrpcBoolean'] => 1,
66 $GLOBALS['xmlrpcString'] => 1,
67 $GLOBALS['xmlrpcDouble'] => 1,
68 $GLOBALS['xmlrpcDateTime'] => 1,
69 $GLOBALS['xmlrpcBase64'] => 1,
70 $GLOBALS['xmlrpcArray'] => 2,
71 $GLOBALS['xmlrpcStruct'] => 3
72 );
73
74 $GLOBALS['xmlrpc_valid_parents'] = array(
75 'VALUE' => array('MEMBER', 'DATA', 'PARAM', 'FAULT'),
76 'BOOLEAN' => array('VALUE'),
77 'I4' => array('VALUE'),
78 'INT' => array('VALUE'),
79 'STRING' => array('VALUE'),
80 'DOUBLE' => array('VALUE'),
81 'DATETIME.ISO8601' => array('VALUE'),
82 'BASE64' => array('VALUE'),
83 'MEMBER' => array('STRUCT'),
84 'NAME' => array('MEMBER'),
85 'DATA' => array('ARRAY'),
86 'ARRAY' => array('VALUE'),
87 'STRUCT' => array('VALUE'),
88 'PARAM' => array('PARAMS'),
89 'METHODNAME' => array('METHODCALL'),
90 'PARAMS' => array('METHODCALL', 'METHODRESPONSE'),
91 'FAULT' => array('METHODRESPONSE'),
92 'NIL' => array('VALUE'), // only used when extension activated
93 'EX:NIL' => array('VALUE') // only used when extension activated
94 );
95
96 // define extra types for supporting NULL (useful for json or <NIL/>)
97 $GLOBALS['xmlrpcNull']='null';
98 $GLOBALS['xmlrpcTypes']['null']=1;
99
100 // Not in use anymore since 2.0. Shall we remove it?
101 /// @deprecated
102 $GLOBALS['xmlEntities']=array(
103 'amp' => '&',
104 'quot' => '"',
105 'lt' => '<',
106 'gt' => '>',
107 'apos' => "'"
108 );
109
110 // tables used for transcoding different charsets into us-ascii xml
111
112 $GLOBALS['xml_iso88591_Entities']=array();
113 $GLOBALS['xml_iso88591_Entities']['in'] = array();
114 $GLOBALS['xml_iso88591_Entities']['out'] = array();
115 for ($i = 0; $i < 32; $i++)
116 {
117 $GLOBALS['xml_iso88591_Entities']['in'][] = chr($i);
118 $GLOBALS['xml_iso88591_Entities']['out'][] = '&#'.$i.';';
119 }
120 for ($i = 160; $i < 256; $i++)
121 {
122 $GLOBALS['xml_iso88591_Entities']['in'][] = chr($i);
123 $GLOBALS['xml_iso88591_Entities']['out'][] = '&#'.$i.';';
124 }
125
126 /// @todo add to iso table the characters from cp_1252 range, i.e. 128 to 159?
127 /// These will NOT be present in true ISO-8859-1, but will save the unwary
128 /// windows user from sending junk (though no luck when reciving them...)
129 /*
130 $GLOBALS['xml_cp1252_Entities']=array();
131 for ($i = 128; $i < 160; $i++)
132 {
133 $GLOBALS['xml_cp1252_Entities']['in'][] = chr($i);
134 }
135 $GLOBALS['xml_cp1252_Entities']['out'] = array(
136 '&#x20AC;', '?', '&#x201A;', '&#x0192;',
137 '&#x201E;', '&#x2026;', '&#x2020;', '&#x2021;',
138 '&#x02C6;', '&#x2030;', '&#x0160;', '&#x2039;',
139 '&#x0152;', '?', '&#x017D;', '?',
140 '?', '&#x2018;', '&#x2019;', '&#x201C;',
141 '&#x201D;', '&#x2022;', '&#x2013;', '&#x2014;',
142 '&#x02DC;', '&#x2122;', '&#x0161;', '&#x203A;',
143 '&#x0153;', '?', '&#x017E;', '&#x0178;'
144 );
145 */
146
147 $GLOBALS['xmlrpcerr'] = array(
148 'unknown_method'=>1,
149 'invalid_return'=>2,
150 'incorrect_params'=>3,
151 'introspect_unknown'=>4,
152 'http_error'=>5,
153 'no_data'=>6,
154 'no_ssl'=>7,
155 'curl_fail'=>8,
156 'invalid_request'=>15,
157 'no_curl'=>16,
158 'server_error'=>17,
159 'multicall_error'=>18,
160 'multicall_notstruct'=>9,
161 'multicall_nomethod'=>10,
162 'multicall_notstring'=>11,
163 'multicall_recursion'=>12,
164 'multicall_noparams'=>13,
165 'multicall_notarray'=>14,
166
167 'cannot_decompress'=>103,
168 'decompress_fail'=>104,
169 'dechunk_fail'=>105,
170 'server_cannot_decompress'=>106,
171 'server_decompress_fail'=>107
172 );
173
174 $GLOBALS['xmlrpcstr'] = array(
175 'unknown_method'=>'Unknown method',
176 'invalid_return'=>'Invalid return payload: enable debugging to examine incoming payload',
177 'incorrect_params'=>'Incorrect parameters passed to method',
178 'introspect_unknown'=>"Can't introspect: method unknown",
179 'http_error'=>"Didn't receive 200 OK from remote server.",
180 'no_data'=>'No data received from server.',
181 'no_ssl'=>'No SSL support compiled in.',
182 'curl_fail'=>'CURL error',
183 'invalid_request'=>'Invalid request payload',
184 'no_curl'=>'No CURL support compiled in.',
185 'server_error'=>'Internal server error',
186 'multicall_error'=>'Received from server invalid multicall response',
187 'multicall_notstruct'=>'system.multicall expected struct',
188 'multicall_nomethod'=>'missing methodName',
189 'multicall_notstring'=>'methodName is not a string',
190 'multicall_recursion'=>'recursive system.multicall forbidden',
191 'multicall_noparams'=>'missing params',
192 'multicall_notarray'=>'params is not an array',
193
194 'cannot_decompress'=>'Received from server compressed HTTP and cannot decompress',
195 'decompress_fail'=>'Received from server invalid compressed HTTP',
196 'dechunk_fail'=>'Received from server invalid chunked HTTP',
197 'server_cannot_decompress'=>'Received from client compressed HTTP request and cannot decompress',
198 'server_decompress_fail'=>'Received from client invalid compressed HTTP request'
199 );
200
201 // The charset encoding used by the server for received messages and
202 // by the client for received responses when received charset cannot be determined
203 // or is not supported
204 $GLOBALS['xmlrpc_defencoding']='UTF-8';
205
206 // The encoding used internally by PHP.
207 // String values received as xml will be converted to this, and php strings will be converted to xml
208 // as if having been coded with this
209 $GLOBALS['xmlrpc_internalencoding']='ISO-8859-1';
210
211 $GLOBALS['xmlrpcName']='XML-RPC for PHP';
212 $GLOBALS['xmlrpcVersion']='3.0.0.beta';
213
214 // let user errors start at 800
215 $GLOBALS['xmlrpcerruser']=800;
216 // let XML parse errors start at 100
217 $GLOBALS['xmlrpcerrxml']=100;
218
219 // formulate backslashes for escaping regexp
220 // Not in use anymore since 2.0. Shall we remove it?
221 /// @deprecated
222 $GLOBALS['xmlrpc_backslash']=chr(92).chr(92);
223
224 // set to TRUE to enable correct decoding of <NIL/> and <EX:NIL/> values
225 $GLOBALS['xmlrpc_null_extension']=false;
226
227 // set to TRUE to enable encoding of php NULL values to <EX:NIL/> instead of <NIL/>
228 $GLOBALS['xmlrpc_null_apache_encoding']=false;
229
230 // used to store state during parsing
231 // quick explanation of components:
232 // ac - used to accumulate values
233 // isf - used to indicate a parsing fault (2) or xmlrpcresp fault (1)
234 // isf_reason - used for storing xmlrpcresp fault string
235 // lv - used to indicate "looking for a value": implements
236 // the logic to allow values with no types to be strings
237 // params - used to store parameters in method calls
238 // method - used to store method name
239 // stack - array with genealogy of xml elements names:
240 // used to validate nesting of xmlrpc elements
241 $GLOBALS['_xh']=null;
242
243 /**
244 * Convert a string to the correct XML representation in a target charset
245 * To help correct communication of non-ascii chars inside strings, regardless
246 * of the charset used when sending requests, parsing them, sending responses
247 * and parsing responses, an option is to convert all non-ascii chars present in the message
248 * into their equivalent 'charset entity'. Charset entities enumerated this way
249 * are independent of the charset encoding used to transmit them, and all XML
250 * parsers are bound to understand them.
251 * Note that in the std case we are not sending a charset encoding mime type
252 * along with http headers, so we are bound by RFC 3023 to emit strict us-ascii.
253 *
254 * @todo do a bit of basic benchmarking (strtr vs. str_replace)
255 * @todo make usage of iconv() or recode_string() or mb_string() where available
256 */
257 function xmlrpc_encode_entitites($data, $src_encoding='', $dest_encoding='')
258 {
259 if ($src_encoding == '')
260 {
261 // lame, but we know no better...
262 $src_encoding = $GLOBALS['xmlrpc_internalencoding'];
263 }
264
265 switch(strtoupper($src_encoding.'_'.$dest_encoding))
266 {
267 case 'ISO-8859-1_':
268 case 'ISO-8859-1_US-ASCII':
269 $escaped_data = str_replace(array('&', '"', "'", '<', '>'), array('&amp;', '&quot;', '&apos;', '&lt;', '&gt;'), $data);
270 $escaped_data = str_replace($GLOBALS['xml_iso88591_Entities']['in'], $GLOBALS['xml_iso88591_Entities']['out'], $escaped_data);
271 break;
272 case 'ISO-8859-1_UTF-8':
273 $escaped_data = str_replace(array('&', '"', "'", '<', '>'), array('&amp;', '&quot;', '&apos;', '&lt;', '&gt;'), $data);
274 $escaped_data = utf8_encode($escaped_data);
275 break;
276 case 'ISO-8859-1_ISO-8859-1':
277 case 'US-ASCII_US-ASCII':
278 case 'US-ASCII_UTF-8':
279 case 'US-ASCII_':
280 case 'US-ASCII_ISO-8859-1':
281 case 'UTF-8_UTF-8':
282 //case 'CP1252_CP1252':
283 $escaped_data = str_replace(array('&', '"', "'", '<', '>'), array('&amp;', '&quot;', '&apos;', '&lt;', '&gt;'), $data);
284 break;
285 case 'UTF-8_':
286 case 'UTF-8_US-ASCII':
287 case 'UTF-8_ISO-8859-1':
288 // NB: this will choke on invalid UTF-8, going most likely beyond EOF
289 $escaped_data = '';
290 // be kind to users creating string xmlrpcvals out of different php types
291 $data = (string) $data;
292 $ns = strlen ($data);
293 for ($nn = 0; $nn < $ns; $nn++)
294 {
295 $ch = $data[$nn];
296 $ii = ord($ch);
297 //1 7 0bbbbbbb (127)
298 if ($ii < 128)
299 {
300 /// @todo shall we replace this with a (supposedly) faster str_replace?
301 switch($ii){
302 case 34:
303 $escaped_data .= '&quot;';
304 break;
305 case 38:
306 $escaped_data .= '&amp;';
307 break;
308 case 39:
309 $escaped_data .= '&apos;';
310 break;
311 case 60:
312 $escaped_data .= '&lt;';
313 break;
314 case 62:
315 $escaped_data .= '&gt;';
316 break;
317 default:
318 $escaped_data .= $ch;
319 } // switch
320 }
321 //2 11 110bbbbb 10bbbbbb (2047)
322 else if ($ii>>5 == 6)
323 {
324 $b1 = ($ii & 31);
325 $ii = ord($data[$nn+1]);
326 $b2 = ($ii & 63);
327 $ii = ($b1 * 64) + $b2;
328 $ent = sprintf ('&#%d;', $ii);
329 $escaped_data .= $ent;
330 $nn += 1;
331 }
332 //3 16 1110bbbb 10bbbbbb 10bbbbbb
333 else if ($ii>>4 == 14)
334 {
335 $b1 = ($ii & 15);
336 $ii = ord($data[$nn+1]);
337 $b2 = ($ii & 63);
338 $ii = ord($data[$nn+2]);
339 $b3 = ($ii & 63);
340 $ii = ((($b1 * 64) + $b2) * 64) + $b3;
341 $ent = sprintf ('&#%d;', $ii);
342 $escaped_data .= $ent;
343 $nn += 2;
344 }
345 //4 21 11110bbb 10bbbbbb 10bbbbbb 10bbbbbb
346 else if ($ii>>3 == 30)
347 {
348 $b1 = ($ii & 7);
349 $ii = ord($data[$nn+1]);
350 $b2 = ($ii & 63);
351 $ii = ord($data[$nn+2]);
352 $b3 = ($ii & 63);
353 $ii = ord($data[$nn+3]);
354 $b4 = ($ii & 63);
355 $ii = ((((($b1 * 64) + $b2) * 64) + $b3) * 64) + $b4;
356 $ent = sprintf ('&#%d;', $ii);
357 $escaped_data .= $ent;
358 $nn += 3;
359 }
360 }
361 break;
362/*
363 case 'CP1252_':
364 case 'CP1252_US-ASCII':
365 $escaped_data = str_replace(array('&', '"', "'", '<', '>'), array('&amp;', '&quot;', '&apos;', '&lt;', '&gt;'), $data);
366 $escaped_data = str_replace($GLOBALS['xml_iso88591_Entities']['in'], $GLOBALS['xml_iso88591_Entities']['out'], $escaped_data);
367 $escaped_data = str_replace($GLOBALS['xml_cp1252_Entities']['in'], $GLOBALS['xml_cp1252_Entities']['out'], $escaped_data);
368 break;
369 case 'CP1252_UTF-8':
370 $escaped_data = str_replace(array('&', '"', "'", '<', '>'), array('&amp;', '&quot;', '&apos;', '&lt;', '&gt;'), $data);
371 /// @todo we could use real UTF8 chars here instead of xml entities... (note that utf_8 encode all allone will NOT convert them)
372 $escaped_data = str_replace($GLOBALS['xml_cp1252_Entities']['in'], $GLOBALS['xml_cp1252_Entities']['out'], $escaped_data);
373 $escaped_data = utf8_encode($escaped_data);
374 break;
375 case 'CP1252_ISO-8859-1':
376 $escaped_data = str_replace(array('&', '"', "'", '<', '>'), array('&amp;', '&quot;', '&apos;', '&lt;', '&gt;'), $data);
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...
378 $escaped_data = str_replace($GLOBALS['xml_cp1252_Entities']['in'], $GLOBALS['xml_cp1252_Entities']['out'], $escaped_data);
379 break;
380*/
381 default:
382 $escaped_data = '';
383 error_log("Converting from $src_encoding to $dest_encoding: not supported...");
384 }
385 return $escaped_data;
386 }
387
388 /// xml parser handler function for opening element tags
389 function xmlrpc_se($parser, $name, $attrs, $accept_single_vals=false)
390 {
391 // if invalid xmlrpc already detected, skip all processing
392 if ($GLOBALS['_xh']['isf'] < 2)
393 {
394 // check for correct element nesting
395 // top level element can only be of 2 types
396 /// @todo optimization creep: save this check into a bool variable, instead of using count() every time:
397 /// there is only a single top level element in xml anyway
398 if (count($GLOBALS['_xh']['stack']) == 0)
399 {
400 if ($name != 'METHODRESPONSE' && $name != 'METHODCALL' && (
401 $name != 'VALUE' && !$accept_single_vals))
402 {
403 $GLOBALS['_xh']['isf'] = 2;
404 $GLOBALS['_xh']['isf_reason'] = 'missing top level xmlrpc element';
405 return;
406 }
407 else
408 {
409 $GLOBALS['_xh']['rt'] = strtolower($name);
410 $GLOBALS['_xh']['rt'] = strtolower($name);
411 }
412 }
413 else
414 {
415 // not top level element: see if parent is OK
416 $parent = end($GLOBALS['_xh']['stack']);
417 if (!array_key_exists($name, $GLOBALS['xmlrpc_valid_parents']) || !in_array($parent, $GLOBALS['xmlrpc_valid_parents'][$name]))
418 {
419 $GLOBALS['_xh']['isf'] = 2;
420 $GLOBALS['_xh']['isf_reason'] = "xmlrpc element $name cannot be child of $parent";
421 return;
422 }
423 }
424
425 switch($name)
426 {
427 // optimize for speed switch cases: most common cases first
428 case 'VALUE':
429 /// @todo we could check for 2 VALUE elements inside a MEMBER or PARAM element
430 $GLOBALS['_xh']['vt']='value'; // indicator: no value found yet
431 $GLOBALS['_xh']['ac']='';
432 $GLOBALS['_xh']['lv']=1;
433 $GLOBALS['_xh']['php_class']=null;
434 break;
435 case 'I4':
436 case 'INT':
437 case 'STRING':
438 case 'BOOLEAN':
439 case 'DOUBLE':
440 case 'DATETIME.ISO8601':
441 case 'BASE64':
442 if ($GLOBALS['_xh']['vt']!='value')
443 {
444 //two data elements inside a value: an error occurred!
445 $GLOBALS['_xh']['isf'] = 2;
446 $GLOBALS['_xh']['isf_reason'] = "$name element following a {$GLOBALS['_xh']['vt']} element inside a single value";
447 return;
448 }
449 $GLOBALS['_xh']['ac']=''; // reset the accumulator
450 break;
451 case 'STRUCT':
452 case 'ARRAY':
453 if ($GLOBALS['_xh']['vt']!='value')
454 {
455 //two data elements inside a value: an error occurred!
456 $GLOBALS['_xh']['isf'] = 2;
457 $GLOBALS['_xh']['isf_reason'] = "$name element following a {$GLOBALS['_xh']['vt']} element inside a single value";
458 return;
459 }
460 // create an empty array to hold child values, and push it onto appropriate stack
461 $cur_val = array();
462 $cur_val['values'] = array();
463 $cur_val['type'] = $name;
464 // check for out-of-band information to rebuild php objs
465 // and in case it is found, save it
466 if (@isset($attrs['PHP_CLASS']))
467 {
468 $cur_val['php_class'] = $attrs['PHP_CLASS'];
469 }
470 $GLOBALS['_xh']['valuestack'][] = $cur_val;
471 $GLOBALS['_xh']['vt']='data'; // be prepared for a data element next
472 break;
473 case 'DATA':
474 if ($GLOBALS['_xh']['vt']!='data')
475 {
476 //two data elements inside a value: an error occurred!
477 $GLOBALS['_xh']['isf'] = 2;
478 $GLOBALS['_xh']['isf_reason'] = "found two data elements inside an array element";
479 return;
480 }
481 case 'METHODCALL':
482 case 'METHODRESPONSE':
483 case 'PARAMS':
484 // valid elements that add little to processing
485 break;
486 case 'METHODNAME':
487 case 'NAME':
488 /// @todo we could check for 2 NAME elements inside a MEMBER element
489 $GLOBALS['_xh']['ac']='';
490 break;
491 case 'FAULT':
492 $GLOBALS['_xh']['isf']=1;
493 break;
494 case 'MEMBER':
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
496 //$GLOBALS['_xh']['ac']='';
497 // Drop trough intentionally
498 case 'PARAM':
499 // clear value type, so we can check later if no value has been passed for this param/member
500 $GLOBALS['_xh']['vt']=null;
501 break;
502 case 'NIL':
503 case 'EX:NIL':
504 if ($GLOBALS['xmlrpc_null_extension'])
505 {
506 if ($GLOBALS['_xh']['vt']!='value')
507 {
508 //two data elements inside a value: an error occurred!
509 $GLOBALS['_xh']['isf'] = 2;
510 $GLOBALS['_xh']['isf_reason'] = "$name element following a {$GLOBALS['_xh']['vt']} element inside a single value";
511 return;
512 }
513 $GLOBALS['_xh']['ac']=''; // reset the accumulator
514 break;
515 }
516 // we do not support the <NIL/> extension, so
517 // drop through intentionally
518 default:
519 /// INVALID ELEMENT: RAISE ISF so that it is later recognized!!!
520 $GLOBALS['_xh']['isf'] = 2;
521 $GLOBALS['_xh']['isf_reason'] = "found not-xmlrpc xml element $name";
522 break;
523 }
524
525 // Save current element name to stack, to validate nesting
526 $GLOBALS['_xh']['stack'][] = $name;
527
528 /// @todo optimization creep: move this inside the big switch() above
529 if($name!='VALUE')
530 {
531 $GLOBALS['_xh']['lv']=0;
532 }
533 }
534 }
535
536 /// Used in decoding xml chunks that might represent single xmlrpc values
537 function xmlrpc_se_any($parser, $name, $attrs)
538 {
539 xmlrpc_se($parser, $name, $attrs, true);
540 }
541
542 /// xml parser handler function for close element tags
543 function xmlrpc_ee($parser, $name, $rebuild_xmlrpcvals = true)
544 {
545 if ($GLOBALS['_xh']['isf'] < 2)
546 {
547 // push this element name from stack
548 // NB: if XML validates, correct opening/closing is guaranteed and
549 // we do not have to check for $name == $curr_elem.
550 // we also checked for proper nesting at start of elements...
551 $curr_elem = array_pop($GLOBALS['_xh']['stack']);
552
553 switch($name)
554 {
555 case 'VALUE':
556 // This if() detects if no scalar was inside <VALUE></VALUE>
557 if ($GLOBALS['_xh']['vt']=='value')
558 {
559 $GLOBALS['_xh']['value']=$GLOBALS['_xh']['ac'];
560 $GLOBALS['_xh']['vt']=$GLOBALS['xmlrpcString'];
561 }
562
563 if ($rebuild_xmlrpcvals)
564 {
565 // build the xmlrpc val out of the data received, and substitute it
566 $temp = new xmlrpcval($GLOBALS['_xh']['value'], $GLOBALS['_xh']['vt']);
567 // in case we got info about underlying php class, save it
568 // in the object we're rebuilding
569 if (isset($GLOBALS['_xh']['php_class']))
570 $temp->_php_class = $GLOBALS['_xh']['php_class'];
571 // check if we are inside an array or struct:
572 // if value just built is inside an array, let's move it into array on the stack
573 $vscount = count($GLOBALS['_xh']['valuestack']);
574 if ($vscount && $GLOBALS['_xh']['valuestack'][$vscount-1]['type']=='ARRAY')
575 {
576 $GLOBALS['_xh']['valuestack'][$vscount-1]['values'][] = $temp;
577 }
578 else
579 {
580 $GLOBALS['_xh']['value'] = $temp;
581 }
582 }
583 else
584 {
585 /// @todo this needs to treat correctly php-serialized objects,
586 /// since std deserializing is done by php_xmlrpc_decode,
587 /// which we will not be calling...
588 if (isset($GLOBALS['_xh']['php_class']))
589 {
590 }
591
592 // check if we are inside an array or struct:
593 // if value just built is inside an array, let's move it into array on the stack
594 $vscount = count($GLOBALS['_xh']['valuestack']);
595 if ($vscount && $GLOBALS['_xh']['valuestack'][$vscount-1]['type']=='ARRAY')
596 {
597 $GLOBALS['_xh']['valuestack'][$vscount-1]['values'][] = $GLOBALS['_xh']['value'];
598 }
599 }
600 break;
601 case 'BOOLEAN':
602 case 'I4':
603 case 'INT':
604 case 'STRING':
605 case 'DOUBLE':
606 case 'DATETIME.ISO8601':
607 case 'BASE64':
608 $GLOBALS['_xh']['vt']=strtolower($name);
609 /// @todo: optimization creep - remove the if/elseif cycle below
610 /// since the case() in which we are already did that
611 if ($name=='STRING')
612 {
613 $GLOBALS['_xh']['value']=$GLOBALS['_xh']['ac'];
614 }
615 elseif ($name=='DATETIME.ISO8601')
616 {
617 if (!preg_match('/^[0-9]{8}T[0-9]{2}:[0-9]{2}:[0-9]{2}$/', $GLOBALS['_xh']['ac']))
618 {
619 error_log('XML-RPC: invalid value received in DATETIME: '.$GLOBALS['_xh']['ac']);
620 }
621 $GLOBALS['_xh']['vt']=$GLOBALS['xmlrpcDateTime'];
622 $GLOBALS['_xh']['value']=$GLOBALS['_xh']['ac'];
623 }
624 elseif ($name=='BASE64')
625 {
626 /// @todo check for failure of base64 decoding / catch warnings
627 $GLOBALS['_xh']['value']=base64_decode($GLOBALS['_xh']['ac']);
628 }
629 elseif ($name=='BOOLEAN')
630 {
631 // special case here: we translate boolean 1 or 0 into PHP
632 // constants true or false.
633 // Strings 'true' and 'false' are accepted, even though the
634 // spec never mentions them (see eg. Blogger api docs)
635 // NB: this simple checks helps a lot sanitizing input, ie no
636 // security problems around here
637 if ($GLOBALS['_xh']['ac']=='1' || strcasecmp($GLOBALS['_xh']['ac'], 'true') == 0)
638 {
639 $GLOBALS['_xh']['value']=true;
640 }
641 else
642 {
643 // log if receiveing something strange, even though we set the value to false anyway
644 if ($GLOBALS['_xh']['ac']!='0' && strcasecmp($GLOBALS['_xh']['ac'], 'false') != 0)
645 error_log('XML-RPC: invalid value received in BOOLEAN: '.$GLOBALS['_xh']['ac']);
646 $GLOBALS['_xh']['value']=false;
647 }
648 }
649 elseif ($name=='DOUBLE')
650 {
651 // we have a DOUBLE
652 // we must check that only 0123456789-.<space> are characters here
653 // NOTE: regexp could be much stricter than this...
654 if (!preg_match('/^[+-eE0123456789 \t.]+$/', $GLOBALS['_xh']['ac']))
655 {
656 /// @todo: find a better way of throwing an error than this!
657 error_log('XML-RPC: non numeric value received in DOUBLE: '.$GLOBALS['_xh']['ac']);
658 $GLOBALS['_xh']['value']='ERROR_NON_NUMERIC_FOUND';
659 }
660 else
661 {
662 // it's ok, add it on
663 $GLOBALS['_xh']['value']=(double)$GLOBALS['_xh']['ac'];
664 }
665 }
666 else
667 {
668 // we have an I4/INT
669 // we must check that only 0123456789-<space> are characters here
670 if (!preg_match('/^[+-]?[0123456789 \t]+$/', $GLOBALS['_xh']['ac']))
671 {
672 /// @todo find a better way of throwing an error than this!
673 error_log('XML-RPC: non numeric value received in INT: '.$GLOBALS['_xh']['ac']);
674 $GLOBALS['_xh']['value']='ERROR_NON_NUMERIC_FOUND';
675 }
676 else
677 {
678 // it's ok, add it on
679 $GLOBALS['_xh']['value']=(int)$GLOBALS['_xh']['ac'];
680 }
681 }
682 //$GLOBALS['_xh']['ac']=''; // is this necessary?
683 $GLOBALS['_xh']['lv']=3; // indicate we've found a value
684 break;
685 case 'NAME':
686 $GLOBALS['_xh']['valuestack'][count($GLOBALS['_xh']['valuestack'])-1]['name'] = $GLOBALS['_xh']['ac'];
687 break;
688 case 'MEMBER':
689 //$GLOBALS['_xh']['ac']=''; // is this necessary?
690 // add to array in the stack the last element built,
691 // unless no VALUE was found
692 if ($GLOBALS['_xh']['vt'])
693 {
694 $vscount = count($GLOBALS['_xh']['valuestack']);
695 $GLOBALS['_xh']['valuestack'][$vscount-1]['values'][$GLOBALS['_xh']['valuestack'][$vscount-1]['name']] = $GLOBALS['_xh']['value'];
696 } else
697 error_log('XML-RPC: missing VALUE inside STRUCT in received xml');
698 break;
699 case 'DATA':
700 //$GLOBALS['_xh']['ac']=''; // is this necessary?
701 $GLOBALS['_xh']['vt']=null; // reset this to check for 2 data elements in a row - even if they're empty
702 break;
703 case 'STRUCT':
704 case 'ARRAY':
705 // fetch out of stack array of values, and promote it to current value
706 $curr_val = array_pop($GLOBALS['_xh']['valuestack']);
707 $GLOBALS['_xh']['value'] = $curr_val['values'];
708 $GLOBALS['_xh']['vt']=strtolower($name);
709 if (isset($curr_val['php_class']))
710 {
711 $GLOBALS['_xh']['php_class'] = $curr_val['php_class'];
712 }
713 break;
714 case 'PARAM':
715 // add to array of params the current value,
716 // unless no VALUE was found
717 if ($GLOBALS['_xh']['vt'])
718 {
719 $GLOBALS['_xh']['params'][]=$GLOBALS['_xh']['value'];
720 $GLOBALS['_xh']['pt'][]=$GLOBALS['_xh']['vt'];
721 }
722 else
723 error_log('XML-RPC: missing VALUE inside PARAM in received xml');
724 break;
725 case 'METHODNAME':
726 $GLOBALS['_xh']['method']=preg_replace('/^[\n\r\t ]+/', '', $GLOBALS['_xh']['ac']);
727 break;
728 case 'NIL':
729 case 'EX:NIL':
730 if ($GLOBALS['xmlrpc_null_extension'])
731 {
732 $GLOBALS['_xh']['vt']='null';
733 $GLOBALS['_xh']['value']=null;
734 $GLOBALS['_xh']['lv']=3;
735 break;
736 }
737 // drop through intentionally if nil extension not enabled
738 case 'PARAMS':
739 case 'FAULT':
740 case 'METHODCALL':
741 case 'METHORESPONSE':
742 break;
743 default:
744 // End of INVALID ELEMENT!
745 // shall we add an assert here for unreachable code???
746 break;
747 }
748 }
749 }
750
751 /// Used in decoding xmlrpc requests/responses without rebuilding xmlrpc values
752 function xmlrpc_ee_fast($parser, $name)
753 {
754 xmlrpc_ee($parser, $name, false);
755 }
756
757 /// xml parser handler function for character data
758 function xmlrpc_cd($parser, $data)
759 {
760 // skip processing if xml fault already detected
761 if ($GLOBALS['_xh']['isf'] < 2)
762 {
763 // "lookforvalue==3" means that we've found an entire value
764 // and should discard any further character data
765 if($GLOBALS['_xh']['lv']!=3)
766 {
767 // G. Giunta 2006-08-23: useless change of 'lv' from 1 to 2
768 //if($GLOBALS['_xh']['lv']==1)
769 //{
770 // if we've found text and we're just in a <value> then
771 // say we've found a value
772 //$GLOBALS['_xh']['lv']=2;
773 //}
774 // we always initialize the accumulator before starting parsing, anyway...
775 //if(!@isset($GLOBALS['_xh']['ac']))
776 //{
777 // $GLOBALS['_xh']['ac'] = '';
778 //}
779 $GLOBALS['_xh']['ac'].=$data;
780 }
781 }
782 }
783
784 /// xml parser handler function for 'other stuff', ie. not char data or
785 /// element start/end tag. In fact it only gets called on unknown entities...
786 function xmlrpc_dh($parser, $data)
787 {
788 // skip processing if xml fault already detected
789 if ($GLOBALS['_xh']['isf'] < 2)
790 {
791 if(substr($data, 0, 1) == '&' && substr($data, -1, 1) == ';')
792 {
793 // G. Giunta 2006-08-25: useless change of 'lv' from 1 to 2
794 //if($GLOBALS['_xh']['lv']==1)
795 //{
796 // $GLOBALS['_xh']['lv']=2;
797 //}
798 $GLOBALS['_xh']['ac'].=$data;
799 }
800 }
801 return true;
802 }
803
804 class xmlrpc_client
805 {
806 var $path;
807 var $server;
808 var $port=0;
809 var $method='http';
810 var $errno;
811 var $errstr;
812 var $debug=0;
813 var $username='';
814 var $password='';
815 var $authtype=1;
816 var $cert='';
817 var $certpass='';
818 var $cacert='';
819 var $cacertdir='';
820 var $key='';
821 var $keypass='';
822 var $verifypeer=true;
823 var $verifyhost=1;
824 var $no_multicall=false;
825 var $proxy='';
826 var $proxyport=0;
827 var $proxy_user='';
828 var $proxy_pass='';
829 var $proxy_authtype=1;
830 var $cookies=array();
831 var $extracurlopts=array();
832
833 /**
834 * List of http compression methods accepted by the client for responses.
835 * NB: PHP supports deflate, gzip compressions out of the box if compiled w. zlib
836 *
837 * NNB: you can set it to any non-empty array for HTTP11 and HTTPS, since
838 * in those cases it will be up to CURL to decide the compression methods
839 * it supports. You might check for the presence of 'zlib' in the output of
840 * curl_version() to determine wheter compression is supported or not
841 */
842 var $accepted_compression = array();
843 /**
844 * Name of compression scheme to be used for sending requests.
845 * Either null, gzip or deflate
846 */
847 var $request_compression = '';
848 /**
849 * CURL handle: used for keep-alive connections (PHP 4.3.8 up, see:
850 * http://curl.haxx.se/docs/faq.html#7.3)
851 */
852 var $xmlrpc_curl_handle = null;
853 /// Wheter to use persistent connections for http 1.1 and https
854 var $keepalive = false;
855 /// Charset encodings that can be decoded without problems by the client
856 var $accepted_charset_encodings = array();
857 /// Charset encoding to be used in serializing request. NULL = use ASCII
858 var $request_charset_encoding = '';
859 /**
860 * Decides the content of xmlrpcresp objects returned by calls to send()
861 * valid strings are 'xmlrpcvals', 'phpvals' or 'xml'
862 */
863 var $return_type = 'xmlrpcvals';
864 /**
865 * Sent to servers in http headers
866 */
867 var $user_agent;
868
869 /**
870 * @param string $path either the complete server URL or the PATH part of the xmlrc server URL, e.g. /xmlrpc/server.php
871 * @param string $server the server name / ip address
872 * @param integer $port the port the server is listening on, defaults to 80 or 443 depending on protocol used
873 * @param string $method the http protocol variant: defaults to 'http', 'https' and 'http11' can be used if CURL is installed
874 */
875 function xmlrpc_client($path, $server='', $port='', $method='')
876 {
877 // allow user to specify all params in $path
878 if($server == '' and $port == '' and $method == '')
879 {
880 $parts = parse_url($path);
881 $server = $parts['host'];
882 $path = isset($parts['path']) ? $parts['path'] : '';
883 if(isset($parts['query']))
884 {
885 $path .= '?'.$parts['query'];
886 }
887 if(isset($parts['fragment']))
888 {
889 $path .= '#'.$parts['fragment'];
890 }
891 if(isset($parts['port']))
892 {
893 $port = $parts['port'];
894 }
895 if(isset($parts['scheme']))
896 {
897 $method = $parts['scheme'];
898 }
899 if(isset($parts['user']))
900 {
901 $this->username = $parts['user'];
902 }
903 if(isset($parts['pass']))
904 {
905 $this->password = $parts['pass'];
906 }
907 }
908 if($path == '' || $path[0] != '/')
909 {
910 $this->path='/'.$path;
911 }
912 else
913 {
914 $this->path=$path;
915 }
916 $this->server=$server;
917 if($port != '')
918 {
919 $this->port=$port;
920 }
921 if($method != '')
922 {
923 $this->method=$method;
924 }
925
926 // if ZLIB is enabled, let the client by default accept compressed responses
927 if(function_exists('gzinflate') || (
928 function_exists('curl_init') && (($info = curl_version()) &&
929 ((is_string($info) && strpos($info, 'zlib') !== null) || isset($info['libz_version'])))
930 ))
931 {
932 $this->accepted_compression = array('gzip', 'deflate');
933 }
934
935 // keepalives: enabled by default
936 $this->keepalive = true;
937
938 // by default the xml parser can support these 3 charset encodings
939 $this->accepted_charset_encodings = array('UTF-8', 'ISO-8859-1', 'US-ASCII');
940
941 // initialize user_agent string
942 $this->user_agent = $GLOBALS['xmlrpcName'] . ' ' . $GLOBALS['xmlrpcVersion'];
943 }
944
945 /**
946 * Enables/disables the echoing to screen of the xmlrpc responses received
947 * @param integer $debug values 0, 1 and 2 are supported (2 = echo sent msg too, before received response)
948 * @access public
949 */
950 function setDebug($in)
951 {
952 $this->debug=$in;
953 }
954
955 /**
956 * Add some http BASIC AUTH credentials, used by the client to authenticate
957 * @param string $u username
958 * @param string $p password
959 * @param integer $t auth type. See curl_setopt man page for supported auth types. Defaults to CURLAUTH_BASIC (basic auth)
960 * @access public
961 */
962 function setCredentials($u, $p, $t=1)
963 {
964 $this->username=$u;
965 $this->password=$p;
966 $this->authtype=$t;
967 }
968
969 /**
970 * Add a client-side https certificate
971 * @param string $cert
972 * @param string $certpass
973 * @access public
974 */
975 function setCertificate($cert, $certpass)
976 {
977 $this->cert = $cert;
978 $this->certpass = $certpass;
979 }
980
981 /**
982 * Add a CA certificate to verify server with (see man page about
983 * CURLOPT_CAINFO for more details
984 * @param string $cacert certificate file name (or dir holding certificates)
985 * @param bool $is_dir set to true to indicate cacert is a dir. defaults to false
986 * @access public
987 */
988 function setCaCertificate($cacert, $is_dir=false)
989 {
990 if ($is_dir)
991 {
992 $this->cacertdir = $cacert;
993 }
994 else
995 {
996 $this->cacert = $cacert;
997 }
998 }
999
1000 /**
1001 * Set attributes for SSL communication: private SSL key
1002 * NB: does not work in older php/curl installs
1003 * Thanks to Daniel Convissor
1004 * @param string $key The name of a file containing a private SSL key
1005 * @param string $keypass The secret password needed to use the private SSL key
1006 * @access public
1007 */
1008 function setKey($key, $keypass)
1009 {
1010 $this->key = $key;
1011 $this->keypass = $keypass;
1012 }
1013
1014 /**
1015 * Set attributes for SSL communication: verify server certificate
1016 * @param bool $i enable/disable verification of peer certificate
1017 * @access public
1018 */
1019 function setSSLVerifyPeer($i)
1020 {
1021 $this->verifypeer = $i;
1022 }
1023
1024 /**
1025 * Set attributes for SSL communication: verify match of server cert w. hostname
1026 * @param int $i
1027 * @access public
1028 */
1029 function setSSLVerifyHost($i)
1030 {
1031 $this->verifyhost = $i;
1032 }
1033
1034 /**
1035 * Set proxy info
1036 * @param string $proxyhost
1037 * @param string $proxyport Defaults to 8080 for HTTP and 443 for HTTPS
1038 * @param string $proxyusername Leave blank if proxy has public access
1039 * @param string $proxypassword Leave blank if proxy has public access
1040 * @param int $proxyauthtype set to constant CURLAUTH_NTLM to use NTLM auth with proxy
1041 * @access public
1042 */
1043 function setProxy($proxyhost, $proxyport, $proxyusername = '', $proxypassword = '', $proxyauthtype = 1)
1044 {
1045 $this->proxy = $proxyhost;
1046 $this->proxyport = $proxyport;
1047 $this->proxy_user = $proxyusername;
1048 $this->proxy_pass = $proxypassword;
1049 $this->proxy_authtype = $proxyauthtype;
1050 }
1051
1052 /**
1053 * Enables/disables reception of compressed xmlrpc responses.
1054 * Note that enabling reception of compressed responses merely adds some standard
1055 * http headers to xmlrpc requests. It is up to the xmlrpc server to return
1056 * compressed responses when receiving such requests.
1057 * @param string $compmethod either 'gzip', 'deflate', 'any' or ''
1058 * @access public
1059 */
1060 function setAcceptedCompression($compmethod)
1061 {
1062 if ($compmethod == 'any')
1063 $this->accepted_compression = array('gzip', 'deflate');
1064 else
1065 $this->accepted_compression = array($compmethod);
1066 }
1067
1068 /**
1069 * Enables/disables http compression of xmlrpc request.
1070 * Take care when sending compressed requests: servers might not support them
1071 * (and automatic fallback to uncompressed requests is not yet implemented)
1072 * @param string $compmethod either 'gzip', 'deflate' or ''
1073 * @access public
1074 */
1075 function setRequestCompression($compmethod)
1076 {
1077 $this->request_compression = $compmethod;
1078 }
1079
1080 /**
1081 * Adds a cookie to list of cookies that will be sent to server.
1082 * NB: setting any param but name and value will turn the cookie into a 'version 1' cookie:
1083 * do not do it unless you know what you are doing
1084 * @param string $name
1085 * @param string $value
1086 * @param string $path
1087 * @param string $domain
1088 * @param int $port
1089 * @access public
1090 *
1091 * @todo check correctness of urlencoding cookie value (copied from php way of doing it...)
1092 */
1093 function setCookie($name, $value='', $path='', $domain='', $port=null)
1094 {
1095 $this->cookies[$name]['value'] = urlencode($value);
1096 if ($path || $domain || $port)
1097 {
1098 $this->cookies[$name]['path'] = $path;
1099 $this->cookies[$name]['domain'] = $domain;
1100 $this->cookies[$name]['port'] = $port;
1101 $this->cookies[$name]['version'] = 1;
1102 }
1103 else
1104 {
1105 $this->cookies[$name]['version'] = 0;
1106 }
1107 }
1108
1109 /**
1110 * Directly set cURL options, for extra flexibility
1111 * It allows eg. to bind client to a specific IP interface / address
1112 * @param $options array
1113 */
1114 function SetCurlOptions( $options )
1115 {
1116 $this->extracurlopts = $options;
1117 }
1118
1119 /**
1120 * Set user-agent string that will be used by this client instance
1121 * in http headers sent to the server
1122 */
1123 function SetUserAgent( $agentstring )
1124 {
1125 $this->user_agent = $agentstring;
1126 }
1127
1128 /**
1129 * Send an xmlrpc request
1130 * @param mixed $msg The message object, or an array of messages for using multicall, or the complete xml representation of a request
1131 * @param integer $timeout Connection timeout, in seconds, If unspecified, a platform specific timeout will apply
1132 * @param string $method if left unspecified, the http protocol chosen during creation of the object will be used
1133 * @return xmlrpcresp
1134 * @access public
1135 */
1136 function& send($msg, $timeout=0, $method='')
1137 {
1138 // if user deos not specify http protocol, use native method of this client
1139 // (i.e. method set during call to constructor)
1140 if($method == '')
1141 {
1142 $method = $this->method;
1143 }
1144
1145 if(is_array($msg))
1146 {
1147 // $msg is an array of xmlrpcmsg's
1148 $r = $this->multicall($msg, $timeout, $method);
1149 return $r;
1150 }
1151 elseif(is_string($msg))
1152 {
1153 $n = new xmlrpcmsg('');
1154 $n->payload = $msg;
1155 $msg = $n;
1156 }
1157
1158 // where msg is an xmlrpcmsg
1159 $msg->debug=$this->debug;
1160
1161 if($method == 'https')
1162 {
1163 $r =& $this->sendPayloadHTTPS(
1164 $msg,
1165 $this->server,
1166 $this->port,
1167 $timeout,
1168 $this->username,
1169 $this->password,
1170 $this->authtype,
1171 $this->cert,
1172 $this->certpass,
1173 $this->cacert,
1174 $this->cacertdir,
1175 $this->proxy,
1176 $this->proxyport,
1177 $this->proxy_user,
1178 $this->proxy_pass,
1179 $this->proxy_authtype,
1180 $this->keepalive,
1181 $this->key,
1182 $this->keypass
1183 );
1184 }
1185 elseif($method == 'http11')
1186 {
1187 $r =& $this->sendPayloadCURL(
1188 $msg,
1189 $this->server,
1190 $this->port,
1191 $timeout,
1192 $this->username,
1193 $this->password,
1194 $this->authtype,
1195 null,
1196 null,
1197 null,
1198 null,
1199 $this->proxy,
1200 $this->proxyport,
1201 $this->proxy_user,
1202 $this->proxy_pass,
1203 $this->proxy_authtype,
1204 'http',
1205 $this->keepalive
1206 );
1207 }
1208 else
1209 {
1210 $r =& $this->sendPayloadHTTP10(
1211 $msg,
1212 $this->server,
1213 $this->port,
1214 $timeout,
1215 $this->username,
1216 $this->password,
1217 $this->authtype,
1218 $this->proxy,
1219 $this->proxyport,
1220 $this->proxy_user,
1221 $this->proxy_pass,
1222 $this->proxy_authtype
1223 );
1224 }
1225
1226 return $r;
1227 }
1228
1229 /**
1230 * @access private
1231 */
1232 function &sendPayloadHTTP10($msg, $server, $port, $timeout=0,
1233 $username='', $password='', $authtype=1, $proxyhost='',
1234 $proxyport=0, $proxyusername='', $proxypassword='', $proxyauthtype=1)
1235 {
1236 if($port==0)
1237 {
1238 $port=80;
1239 }
1240
1241 // Only create the payload if it was not created previously
1242 if(empty($msg->payload))
1243 {
1244 $msg->createPayload($this->request_charset_encoding);
1245 }
1246
1247 $payload = $msg->payload;
1248 // Deflate request body and set appropriate request headers
1249 if(function_exists('gzdeflate') && ($this->request_compression == 'gzip' || $this->request_compression == 'deflate'))
1250 {
1251 if($this->request_compression == 'gzip')
1252 {
1253 $a = @gzencode($payload);
1254 if($a)
1255 {
1256 $payload = $a;
1257 $encoding_hdr = "Content-Encoding: gzip\r\n";
1258 }
1259 }
1260 else
1261 {
1262 $a = @gzcompress($payload);
1263 if($a)
1264 {
1265 $payload = $a;
1266 $encoding_hdr = "Content-Encoding: deflate\r\n";
1267 }
1268 }
1269 }
1270 else
1271 {
1272 $encoding_hdr = '';
1273 }
1274
1275 // thanks to Grant Rauscher <grant7@firstworld.net> for this
1276 $credentials='';
1277 if($username!='')
1278 {
1279 $credentials='Authorization: Basic ' . base64_encode($username . ':' . $password) . "\r\n";
1280 if ($authtype != 1)
1281 {
1282 error_log('XML-RPC: '.__METHOD__.': warning. Only Basic auth is supported with HTTP 1.0');
1283 }
1284 }
1285
1286 $accepted_encoding = '';
1287 if(is_array($this->accepted_compression) && count($this->accepted_compression))
1288 {
1289 $accepted_encoding = 'Accept-Encoding: ' . implode(', ', $this->accepted_compression) . "\r\n";
1290 }
1291
1292 $proxy_credentials = '';
1293 if($proxyhost)
1294 {
1295 if($proxyport == 0)
1296 {
1297 $proxyport = 8080;
1298 }
1299 $connectserver = $proxyhost;
1300 $connectport = $proxyport;
1301 $uri = 'http://'.$server.':'.$port.$this->path;
1302 if($proxyusername != '')
1303 {
1304 if ($proxyauthtype != 1)
1305 {
1306 error_log('XML-RPC: '.__METHOD__.': warning. Only Basic auth to proxy is supported with HTTP 1.0');
1307 }
1308 $proxy_credentials = 'Proxy-Authorization: Basic ' . base64_encode($proxyusername.':'.$proxypassword) . "\r\n";
1309 }
1310 }
1311 else
1312 {
1313 $connectserver = $server;
1314 $connectport = $port;
1315 $uri = $this->path;
1316 }
1317
1318 // Cookie generation, as per rfc2965 (version 1 cookies) or
1319 // netscape's rules (version 0 cookies)
1320 $cookieheader='';
1321 if (count($this->cookies))
1322 {
1323 $version = '';
1324 foreach ($this->cookies as $name => $cookie)
1325 {
1326 if ($cookie['version'])
1327 {
1328 $version = ' $Version="' . $cookie['version'] . '";';
1329 $cookieheader .= ' ' . $name . '="' . $cookie['value'] . '";';
1330 if ($cookie['path'])
1331 $cookieheader .= ' $Path="' . $cookie['path'] . '";';
1332 if ($cookie['domain'])
1333 $cookieheader .= ' $Domain="' . $cookie['domain'] . '";';
1334 if ($cookie['port'])
1335 $cookieheader .= ' $Port="' . $cookie['port'] . '";';
1336 }
1337 else
1338 {
1339 $cookieheader .= ' ' . $name . '=' . $cookie['value'] . ";";
1340 }
1341 }
1342 $cookieheader = 'Cookie:' . $version . substr($cookieheader, 0, -1) . "\r\n";
1343 }
1344
1345 $op= 'POST ' . $uri. " HTTP/1.0\r\n" .
1346 'User-Agent: ' . $this->user_agent . "\r\n" .
1347 'Host: '. $server . ':' . $port . "\r\n" .
1348 $credentials .
1349 $proxy_credentials .
1350 $accepted_encoding .
1351 $encoding_hdr .
1352 'Accept-Charset: ' . implode(',', $this->accepted_charset_encodings) . "\r\n" .
1353 $cookieheader .
1354 'Content-Type: ' . $msg->content_type . "\r\nContent-Length: " .
1355 strlen($payload) . "\r\n\r\n" .
1356 $payload;
1357
1358 if($this->debug > 1)
1359 {
1360 print "<PRE>\n---SENDING---\n" . htmlentities($op) . "\n---END---\n</PRE>";
1361 // let the client see this now in case http times out...
1362 flush();
1363 }
1364
1365 if($timeout>0)
1366 {
1367 $fp=@fsockopen($connectserver, $connectport, $this->errno, $this->errstr, $timeout);
1368 }
1369 else
1370 {
1371 $fp=@fsockopen($connectserver, $connectport, $this->errno, $this->errstr);
1372 }
1373 if($fp)
1374 {
1375 if($timeout>0 && function_exists('stream_set_timeout'))
1376 {
1377 stream_set_timeout($fp, $timeout);
1378 }
1379 }
1380 else
1381 {
1382 $this->errstr='Connect error: '.$this->errstr;
1383 $r=new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['http_error'], $this->errstr . ' (' . $this->errno . ')');
1384 return $r;
1385 }
1386
1387 if(!fputs($fp, $op, strlen($op)))
1388 {
1389 fclose($fp);
1390 $this->errstr='Write error';
1391 $r=new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['http_error'], $this->errstr);
1392 return $r;
1393 }
1394 else
1395 {
1396 // reset errno and errstr on succesful socket connection
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches