Mage_Core_Modules - Version 1.7.0.1

Version Notes

1.7.0.1

Download this release

Release Info

Developer Magento Core Team
Extension Mage_Core_Modules
Version 1.7.0.1
Comparing to
See all releases


Code changes from version 1.7.0.0 to 1.7.0.1

Files changed (44) hide show
  1. RELEASE_NOTES.txt +22 -0
  2. app/Mage.php +1 -1
  3. app/code/core/Mage/Api/Helper/Data.php +86 -1
  4. app/code/core/Mage/Api/etc/wsdl2.xml +1 -7
  5. app/code/core/Mage/Api/etc/wsi.xml +1 -1
  6. app/code/core/Mage/Api2/Model/Request/Interpreter/Xml.php +4 -0
  7. app/code/core/Mage/Authorizenet/etc/system.xml +1 -1
  8. app/code/core/Mage/Catalog/Model/Product/Api.php +12 -18
  9. app/code/core/Mage/Catalog/Model/Product/Api/V2.php +0 -60
  10. app/code/core/Mage/Customer/Model/Customer/Api.php +12 -21
  11. app/code/core/Mage/Customer/Model/Customer/Api/V2.php +0 -60
  12. app/code/core/Mage/Install/Model/Installer/Console.php +3 -1
  13. app/code/core/Mage/Paygate/etc/system.xml +1 -1
  14. app/code/core/Mage/Payment/etc/system.xml +6 -6
  15. app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Field/Country.php +127 -0
  16. app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Field/Hidden.php +48 -0
  17. app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Fieldset/Expanded.php +52 -0
  18. app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Fieldset/Global.php +1 -0
  19. app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Fieldset/Group.php +77 -0
  20. app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Fieldset/Hint.php +51 -1
  21. app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Fieldset/Location.php +353 -0
  22. app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Fieldset/Payment.php +128 -0
  23. app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Payflowlink/Advanced.php +1 -1
  24. app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Payflowlink/Info.php +5 -3
  25. app/code/core/Mage/Paypal/Model/Api/Nvp.php +5 -1
  26. app/code/core/Mage/Paypal/Model/Config.php +36 -21
  27. app/code/core/Mage/Paypal/Model/Ipn.php +8 -6
  28. app/code/core/Mage/Paypal/Model/Observer.php +38 -0
  29. app/code/core/Mage/Paypal/Model/Payflowadvanced.php +7 -0
  30. app/code/core/Mage/Paypal/Model/Payflowlink.php +112 -2
  31. app/code/core/Mage/Paypal/Model/Payflowpro.php +6 -2
  32. app/code/core/Mage/Paypal/Model/System/Config/Source/UrlMethod.php +44 -0
  33. app/code/core/Mage/Paypal/etc/config.xml +30 -2
  34. app/code/core/Mage/Paypal/etc/system.xml +3242 -1877
  35. app/code/core/Mage/Sales/Model/Api/Resource.php +4 -2
  36. app/code/core/Mage/Sales/Model/Order/Api.php +44 -56
  37. app/code/core/Mage/Sales/Model/Order/Api/V2.php +0 -97
  38. app/code/core/Mage/Sales/Model/Order/Creditmemo/Api.php +18 -19
  39. app/code/core/Mage/Sales/Model/Order/Creditmemo/Api/V2.php +1 -0
  40. app/code/core/Mage/Sales/Model/Order/Invoice/Api.php +29 -42
  41. app/code/core/Mage/Sales/Model/Order/Invoice/Api/V2.php +20 -87
  42. app/code/core/Mage/Sales/Model/Order/Shipment/Api.php +15 -20
  43. app/code/core/Mage/Sales/Model/Order/Shipment/Api/V2.php +4 -59
  44. package.xml +5 -5
RELEASE_NOTES.txt CHANGED
@@ -1,3 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ==== 1.7.0.0 ====
2
 
3
  === Major Highlights ===
1
+ ==== 1.7.0.1 ====
2
+
3
+ === Major Highlights ===
4
+ Improved the backend configuration UI for PayPal payment solutions
5
+
6
+ === Improvements ===
7
+ Added the functionality for creating nested field sets in the System configuration
8
+ Implemented the support for the extended and shared configuration fields
9
+ Added the ability to define dependencies between fields from different field sets
10
+
11
+ === Changes ===
12
+ Moved PayPal configuration to the Payment Methods menu
13
+ Set the default value of the cUrl VERIFYPEER option to TRUE for PayPal and added the ability to change this value
14
+ Changed the design and position of the configuration field tooltips
15
+
16
+ === Fixes ===
17
+ Fixed: Inability of SOAP v2 API use in non WS-I compatible mode in the applications written in languages with strong typing
18
+ Fixed: In some cases comments history tab on order does not contain information about customer notifications
19
+ Fixed: Several potential security vulnerabilities
20
+
21
+
22
+
23
  ==== 1.7.0.0 ====
24
 
25
  === Major Highlights ===
app/Mage.php CHANGED
@@ -170,7 +170,7 @@ final class Mage
170
  'major' => '1',
171
  'minor' => '7',
172
  'revision' => '0',
173
- 'patch' => '0',
174
  'stability' => '',
175
  'number' => '',
176
  );
170
  'major' => '1',
171
  'minor' => '7',
172
  'revision' => '0',
173
+ 'patch' => '1',
174
  'stability' => '',
175
  'number' => '',
176
  );
app/code/core/Mage/Api/Helper/Data.php CHANGED
@@ -250,4 +250,89 @@ class Mage_Api_Helper_Data extends Mage_Core_Helper_Abstract
250
  }
251
  }
252
  }
253
- } // Class Mage_Api_Helper_Data End
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
250
  }
251
  }
252
  }
253
+
254
+ /**
255
+ * Parse filters and format them to be applicable for collection filtration
256
+ *
257
+ * @param null|object|array $filters
258
+ * @param array $fieldsMap Map of field names in format: array('field_name_in_filter' => 'field_name_in_db')
259
+ * @return array
260
+ */
261
+ public function parseFilters($filters, $fieldsMap = null)
262
+ {
263
+ // if filters are used in SOAP they must be represented in array format to be used for collection filtration
264
+ if (is_object($filters)) {
265
+ $parsedFilters = array();
266
+ // parse simple filter
267
+ if (isset($filters->filter) && is_array($filters->filter)) {
268
+ foreach ($filters->filter as $field => $value) {
269
+ if (is_object($value) && isset($value->key) && isset($value->value)) {
270
+ $parsedFilters[$value->key] = $value->value;
271
+ } else {
272
+ $parsedFilters[$field] = $value;
273
+ }
274
+ }
275
+ }
276
+ // parse complex filter
277
+ if (isset($filters->complex_filter) && is_array($filters->complex_filter)) {
278
+ if ($this->isComplianceWSI()) {
279
+ // WS-I compliance mode
280
+ foreach ($filters->complex_filter as $fieldName => $condition) {
281
+ if (is_object($condition) && isset($condition->key) && isset($condition->value)) {
282
+ $conditionName = $condition->key;
283
+ $conditionValue = $condition->value;
284
+ $this->formatFilterConditionValue($conditionName, $conditionValue);
285
+ $parsedFilters[$fieldName] = array($conditionName => $conditionValue);
286
+ }
287
+ }
288
+ } else {
289
+ // non WS-I compliance mode
290
+ foreach ($filters->complex_filter as $value) {
291
+ if (is_object($value) && isset($value->key) && isset($value->value)) {
292
+ $fieldName = $value->key;
293
+ $condition = $value->value;
294
+ if (is_object($condition) && isset($condition->key) && isset($condition->value)) {
295
+ $this->formatFilterConditionValue($condition->key, $condition->value);
296
+ $parsedFilters[$fieldName] = array($condition->key => $condition->value);
297
+ }
298
+ }
299
+ }
300
+ }
301
+ }
302
+ $filters = $parsedFilters;
303
+ }
304
+ // make sure that method result is always array
305
+ if (!is_array($filters)) {
306
+ $filters = array();
307
+ }
308
+ // apply fields mapping
309
+ if (isset($fieldsMap) && is_array($fieldsMap)) {
310
+ foreach ($filters as $field => $value) {
311
+ if (isset($fieldsMap[$field])) {
312
+ unset($filters[$field]);
313
+ $field = $fieldsMap[$field];
314
+ $filters[$field] = $value;
315
+ }
316
+ }
317
+ }
318
+ return $filters;
319
+ }
320
+
321
+ /**
322
+ * Convert condition value from the string into the array
323
+ * for the condition operators that require value to be an array.
324
+ * Condition value is changed by reference
325
+ *
326
+ * @param string $conditionOperator
327
+ * @param string $conditionValue
328
+ */
329
+ public function formatFilterConditionValue($conditionOperator, &$conditionValue)
330
+ {
331
+ if (is_string($conditionOperator) && in_array($conditionOperator, array('in', 'nin', 'finset'))
332
+ && is_string($conditionValue)
333
+ ) {
334
+ $delimiter = ',';
335
+ $conditionValue = explode($delimiter, $conditionValue);
336
+ }
337
+ }
338
+ }
app/code/core/Mage/Api/etc/wsdl2.xml CHANGED
@@ -31,12 +31,6 @@
31
  </restriction>
32
  </complexContent>
33
  </complexType>
34
- <complexType name="associativeAnyTypeEntity">
35
- <all>
36
- <element name="key" type="xsd:string" />
37
- <element name="value" type="typens:anyType" />
38
- </all>
39
- </complexType>
40
  <complexType name="filters">
41
  <all>
42
  <element name="filter" type="typens:associativeArray" minOccurs="0" />
@@ -53,7 +47,7 @@
53
  <complexType name="complexFilter">
54
  <all>
55
  <element name="key" type="xsd:string" />
56
- <element name="value" type="typens:associativeAnyTypeEntity" />
57
  </all>
58
  </complexType>
59
  <complexType name="ArrayOfString">
31
  </restriction>
32
  </complexContent>
33
  </complexType>
 
 
 
 
 
 
34
  <complexType name="filters">
35
  <all>
36
  <element name="filter" type="typens:associativeArray" minOccurs="0" />
47
  <complexType name="complexFilter">
48
  <all>
49
  <element name="key" type="xsd:string" />
50
+ <element name="value" type="typens:associativeEntity" />
51
  </all>
52
  </complexType>
53
  <complexType name="ArrayOfString">
app/code/core/Mage/Api/etc/wsi.xml CHANGED
@@ -33,7 +33,7 @@
33
  <xsd:complexType name="complexFilter">
34
  <xsd:sequence>
35
  <xsd:element name="key" type="xsd:string" />
36
- <xsd:element name="value" type="typens:associativeMultiEntity" />
37
  </xsd:sequence>
38
  </xsd:complexType>
39
  <xsd:complexType name="complexFilterArray">
33
  <xsd:complexType name="complexFilter">
34
  <xsd:sequence>
35
  <xsd:element name="key" type="xsd:string" />
36
+ <xsd:element name="value" type="typens:associativeEntity" />
37
  </xsd:sequence>
38
  </xsd:complexType>
39
  <xsd:complexType name="complexFilterArray">
app/code/core/Mage/Api2/Model/Request/Interpreter/Xml.php CHANGED
@@ -61,9 +61,13 @@ class Mage_Api2_Model_Request_Interpreter_Xml implements Mage_Api2_Model_Request
61
  }
62
  $body = false !== strpos($body, '<?xml') ? $body : '<?xml version="1.0"?>' . PHP_EOL . $body;
63
 
 
 
64
  set_error_handler(array($this, '_loadErrorHandler')); // Warnings and errors are suppressed
65
  $config = simplexml_load_string($body);
66
  restore_error_handler();
 
 
67
 
68
  // Check if there was a error while loading file
69
  if ($this->_loadErrorStr !== null) {
61
  }
62
  $body = false !== strpos($body, '<?xml') ? $body : '<?xml version="1.0"?>' . PHP_EOL . $body;
63
 
64
+ // disable external entity loading to prevent possible vulnerability
65
+ libxml_disable_entity_loader(true);
66
  set_error_handler(array($this, '_loadErrorHandler')); // Warnings and errors are suppressed
67
  $config = simplexml_load_string($body);
68
  restore_error_handler();
69
+ // restore default behavior to make possible to load external entities
70
+ libxml_disable_entity_loader(false);
71
 
72
  // Check if there was a error while loading file
73
  if ($this->_loadErrorStr !== null) {
app/code/core/Mage/Authorizenet/etc/system.xml CHANGED
@@ -32,7 +32,7 @@
32
  <authorizenet_directpost translate="label" module="authorizenet">
33
  <label>Authorize.net Direct Post</label>
34
  <frontend_type>text</frontend_type>
35
- <sort_order>10</sort_order>
36
  <show_in_default>1</show_in_default>
37
  <show_in_website>1</show_in_website>
38
  <show_in_store>1</show_in_store>
32
  <authorizenet_directpost translate="label" module="authorizenet">
33
  <label>Authorize.net Direct Post</label>
34
  <frontend_type>text</frontend_type>
35
+ <sort_order>34</sort_order>
36
  <show_in_default>1</show_in_default>
37
  <show_in_website>1</show_in_website>
38
  <show_in_store>1</show_in_store>
app/code/core/Mage/Catalog/Model/Product/Api.php CHANGED
@@ -83,7 +83,7 @@ class Mage_Catalog_Model_Product_Api extends Mage_Catalog_Model_Api_Resource
83
  /**
84
  * Retrieve list of products with basic info (id, sku, type, set, name)
85
  *
86
- * @param array $filters
87
  * @param string|int $store
88
  * @return array
89
  */
@@ -93,34 +93,28 @@ class Mage_Catalog_Model_Product_Api extends Mage_Catalog_Model_Api_Resource
93
  ->addStoreFilter($this->_getStoreId($store))
94
  ->addAttributeToSelect('name');
95
 
96
- if (is_array($filters)) {
97
- try {
98
- foreach ($filters as $field => $value) {
99
- if (isset($this->_filtersMap[$field])) {
100
- $field = $this->_filtersMap[$field];
101
- }
102
-
103
- $collection->addFieldToFilter($field, $value);
104
- }
105
- } catch (Mage_Core_Exception $e) {
106
- $this->_fault('filters_invalid', $e->getMessage());
107
  }
 
 
108
  }
109
-
110
  $result = array();
111
-
112
  foreach ($collection as $product) {
113
- // $result[] = $product->getData();
114
- $result[] = array( // Basic product data
115
  'product_id' => $product->getId(),
116
  'sku' => $product->getSku(),
117
  'name' => $product->getName(),
118
  'set' => $product->getAttributeSetId(),
119
  'type' => $product->getTypeId(),
120
- 'category_ids' => $product->getCategoryIds()
 
121
  );
122
  }
123
-
124
  return $result;
125
  }
126
 
83
  /**
84
  * Retrieve list of products with basic info (id, sku, type, set, name)
85
  *
86
+ * @param null|object|array $filters
87
  * @param string|int $store
88
  * @return array
89
  */
93
  ->addStoreFilter($this->_getStoreId($store))
94
  ->addAttributeToSelect('name');
95
 
96
+ /** @var $apiHelper Mage_Api_Helper_Data */
97
+ $apiHelper = Mage::helper('api');
98
+ $filters = $apiHelper->parseFilters($filters, $this->_filtersMap);
99
+ try {
100
+ foreach ($filters as $field => $value) {
101
+ $collection->addFieldToFilter($field, $value);
 
 
 
 
 
102
  }
103
+ } catch (Mage_Core_Exception $e) {
104
+ $this->_fault('filters_invalid', $e->getMessage());
105
  }
 
106
  $result = array();
 
107
  foreach ($collection as $product) {
108
+ $result[] = array(
 
109
  'product_id' => $product->getId(),
110
  'sku' => $product->getSku(),
111
  'name' => $product->getName(),
112
  'set' => $product->getAttributeSetId(),
113
  'type' => $product->getTypeId(),
114
+ 'category_ids' => $product->getCategoryIds(),
115
+ 'website_ids' => $product->getWebsiteIds()
116
  );
117
  }
 
118
  return $result;
119
  }
120
 
app/code/core/Mage/Catalog/Model/Product/Api/V2.php CHANGED
@@ -33,66 +33,6 @@
33
  */
34
  class Mage_Catalog_Model_Product_Api_V2 extends Mage_Catalog_Model_Product_Api
35
  {
36
-
37
- /**
38
- * Retrieve list of products with basic info (id, sku, type, set, name)
39
- *
40
- * @param array $filters
41
- * @param string|int $store
42
- * @return array
43
- */
44
- public function items($filters = null, $store = null)
45
- {
46
- $collection = Mage::getModel('catalog/product')->getCollection()
47
- ->addStoreFilter($this->_getStoreId($store))
48
- ->addAttributeToSelect('name');
49
-
50
- $preparedFilters = array();
51
- if (isset($filters->filter)) {
52
- foreach ($filters->filter as $_filter) {
53
- $preparedFilters[$_filter->key] = $_filter->value;
54
- }
55
- }
56
- if (isset($filters->complex_filter)) {
57
- foreach ($filters->complex_filter as $_filter) {
58
- $_value = $_filter->value;
59
- $preparedFilters[$_filter->key] = array(
60
- $_value->key => $_value->value
61
- );
62
- }
63
- }
64
-
65
- if (!empty($preparedFilters)) {
66
- try {
67
- foreach ($preparedFilters as $field => $value) {
68
- if (isset($this->_filtersMap[$field])) {
69
- $field = $this->_filtersMap[$field];
70
- }
71
-
72
- $collection->addFieldToFilter($field, $value);
73
- }
74
- } catch (Mage_Core_Exception $e) {
75
- $this->_fault('filters_invalid', $e->getMessage());
76
- }
77
- }
78
-
79
- $result = array();
80
-
81
- foreach ($collection as $product) {
82
- $result[] = array(
83
- 'product_id' => $product->getId(),
84
- 'sku' => $product->getSku(),
85
- 'name' => $product->getName(),
86
- 'set' => $product->getAttributeSetId(),
87
- 'type' => $product->getTypeId(),
88
- 'category_ids' => $product->getCategoryIds(),
89
- 'website_ids' => $product->getWebsiteIds()
90
- );
91
- }
92
-
93
- return $result;
94
- }
95
-
96
  /**
97
  * Retrieve product info
98
  *
33
  */
34
  class Mage_Catalog_Model_Product_Api_V2 extends Mage_Catalog_Model_Product_Api
35
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  /**
37
  * Retrieve product info
38
  *
app/code/core/Mage/Customer/Model/Customer/Api.php CHANGED
@@ -107,45 +107,36 @@ class Mage_Customer_Model_Customer_Api extends Mage_Customer_Model_Api_Resource
107
  }
108
 
109
  /**
110
- * Retrieve cutomers data
111
  *
112
- * @param array $filters
113
  * @return array
114
  */
115
  public function items($filters)
116
  {
117
- $collection = Mage::getModel('customer/customer')->getCollection()
118
- ->addAttributeToSelect('*');
119
-
120
- if (is_array($filters)) {
121
- try {
122
- foreach ($filters as $field => $value) {
123
- if (isset($this->_mapAttributes[$field])) {
124
- $field = $this->_mapAttributes[$field];
125
- }
126
-
127
- $collection->addFieldToFilter($field, $value);
128
- }
129
- } catch (Mage_Core_Exception $e) {
130
- $this->_fault('filters_invalid', $e->getMessage());
131
  }
 
 
132
  }
133
-
134
  $result = array();
135
  foreach ($collection as $customer) {
136
  $data = $customer->toArray();
137
  $row = array();
138
-
139
  foreach ($this->_mapAttributes as $attributeAlias => $attributeCode) {
140
  $row[$attributeAlias] = (isset($data[$attributeCode]) ? $data[$attributeCode] : null);
141
  }
142
-
143
  foreach ($this->getAllowedAttributes($customer) as $attributeCode => $attribute) {
144
  if (isset($data[$attributeCode])) {
145
  $row[$attributeCode] = $data[$attributeCode];
146
  }
147
  }
148
-
149
  $result[] = $row;
150
  }
151
 
@@ -162,7 +153,7 @@ class Mage_Customer_Model_Customer_Api extends Mage_Customer_Model_Api_Resource
162
  public function update($customerId, $customerData)
163
  {
164
  $customerData = $this->_prepareData($customerData);
165
-
166
  $customer = Mage::getModel('customer/customer')->load($customerId);
167
 
168
  if (!$customer->getId()) {
107
  }
108
 
109
  /**
110
+ * Retrieve customers data
111
  *
112
+ * @param object|array $filters
113
  * @return array
114
  */
115
  public function items($filters)
116
  {
117
+ $collection = Mage::getModel('customer/customer')->getCollection()->addAttributeToSelect('*');
118
+ /** @var $apiHelper Mage_Api_Helper_Data */
119
+ $apiHelper = Mage::helper('api');
120
+ $filters = $apiHelper->parseFilters($filters, $this->_mapAttributes);
121
+ try {
122
+ foreach ($filters as $field => $value) {
123
+ $collection->addFieldToFilter($field, $value);
 
 
 
 
 
 
 
124
  }
125
+ } catch (Mage_Core_Exception $e) {
126
+ $this->_fault('filters_invalid', $e->getMessage());
127
  }
 
128
  $result = array();
129
  foreach ($collection as $customer) {
130
  $data = $customer->toArray();
131
  $row = array();
 
132
  foreach ($this->_mapAttributes as $attributeAlias => $attributeCode) {
133
  $row[$attributeAlias] = (isset($data[$attributeCode]) ? $data[$attributeCode] : null);
134
  }
 
135
  foreach ($this->getAllowedAttributes($customer) as $attributeCode => $attribute) {
136
  if (isset($data[$attributeCode])) {
137
  $row[$attributeCode] = $data[$attributeCode];
138
  }
139
  }
 
140
  $result[] = $row;
141
  }
142
 
153
  public function update($customerId, $customerData)
154
  {
155
  $customerData = $this->_prepareData($customerData);
156
+
157
  $customer = Mage::getModel('customer/customer')->load($customerId);
158
 
159
  if (!$customer->getId()) {
app/code/core/Mage/Customer/Model/Customer/Api/V2.php CHANGED
@@ -47,64 +47,4 @@ class Mage_Customer_Model_Customer_Api_V2 extends Mage_Customer_Model_Customer_A
47
  }
48
  return array();
49
  }
50
-
51
- /**
52
- * Retrieve cutomers data
53
- *
54
- * @param array $filters
55
- * @return array
56
- */
57
- public function items($filters)
58
- {
59
- $collection = Mage::getModel('customer/customer')->getCollection()
60
- ->addAttributeToSelect('*');
61
-
62
- $preparedFilters = array();
63
- if (isset($filters->filter)) {
64
- foreach ($filters->filter as $_filter) {
65
- $preparedFilters[$_filter->key] = $_filter->value;
66
- }
67
- }
68
- if (isset($filters->complex_filter)) {
69
- foreach ($filters->complex_filter as $_filter) {
70
- $_value = $_filter->value;
71
- $preparedFilters[$_filter->key] = array(
72
- $_value->key => $_value->value
73
- );
74
- }
75
- }
76
-
77
- if (!empty($preparedFilters)) {
78
- try {
79
- foreach ($preparedFilters as $field => $value) {
80
- if (isset($this->_mapAttributes[$field])) {
81
- $field = $this->_mapAttributes[$field];
82
- }
83
- $collection->addFieldToFilter($field, $value);
84
- }
85
- } catch (Mage_Core_Exception $e) {
86
- $this->_fault('filters_invalid', $e->getMessage());
87
- }
88
- }
89
-
90
- $result = array();
91
- foreach ($collection as $customer) {
92
- $data = $customer->toArray();
93
- $row = array();
94
-
95
- foreach ($this->_mapAttributes as $attributeAlias => $attributeCode) {
96
- $row[$attributeAlias] = (isset($data[$attributeCode]) ? $data[$attributeCode] : null);
97
- }
98
-
99
- foreach ($this->getAllowedAttributes($customer) as $attributeCode => $attribute) {
100
- if (isset($data[$attributeCode])) {
101
- $row[$attributeCode] = $data[$attributeCode];
102
- }
103
- }
104
-
105
- $result[] = $row;
106
- }
107
-
108
- return $result;
109
- }
110
  }
47
  }
48
  return array();
49
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
  }
app/code/core/Mage/Install/Model/Installer/Console.php CHANGED
@@ -392,7 +392,9 @@ class Mage_Install_Model_Installer_Console extends Mage_Install_Model_Installer_
392
  /**
393
  * Prepare encryption key and validate it
394
  */
395
- $encryptionKey = empty($this->_args['encryption_key']) ? md5(time()) : $this->_args['encryption_key'];
 
 
396
  $this->_getDataModel()->setEncryptionKey($encryptionKey);
397
  $installer->validateEncryptionKey($encryptionKey);
398
 
392
  /**
393
  * Prepare encryption key and validate it
394
  */
395
+ $encryptionKey = empty($this->_args['encryption_key'])
396
+ ? md5(Mage::helper('core')->getRandomString(10))
397
+ : $this->_args['encryption_key'];
398
  $this->_getDataModel()->setEncryptionKey($encryptionKey);
399
  $installer->validateEncryptionKey($encryptionKey);
400
 
app/code/core/Mage/Paygate/etc/system.xml CHANGED
@@ -32,7 +32,7 @@
32
  <authorizenet translate="label" module="paygate">
33
  <label>Authorize.net</label>
34
  <frontend_type>text</frontend_type>
35
- <sort_order>10</sort_order>
36
  <show_in_default>1</show_in_default>
37
  <show_in_website>1</show_in_website>
38
  <show_in_store>1</show_in_store>
32
  <authorizenet translate="label" module="paygate">
33
  <label>Authorize.net</label>
34
  <frontend_type>text</frontend_type>
35
+ <sort_order>34</sort_order>
36
  <show_in_default>1</show_in_default>
37
  <show_in_website>1</show_in_website>
38
  <show_in_store>1</show_in_store>
app/code/core/Mage/Payment/etc/system.xml CHANGED
@@ -39,7 +39,7 @@
39
  <ccsave translate="label">
40
  <label>Saved CC</label>
41
  <frontend_type>text</frontend_type>
42
- <sort_order>1</sort_order>
43
  <show_in_default>1</show_in_default>
44
  <show_in_website>1</show_in_website>
45
  <show_in_store>1</show_in_store>
@@ -173,7 +173,7 @@
173
  <checkmo translate="label">
174
  <label>Check / Money Order</label>
175
  <frontend_type>text</frontend_type>
176
- <sort_order>5</sort_order>
177
  <show_in_default>1</show_in_default>
178
  <show_in_website>1</show_in_website>
179
  <show_in_store>1</show_in_store>
@@ -270,7 +270,7 @@
270
  <free translate="label">
271
  <label>Zero Subtotal Checkout</label>
272
  <frontend_type>text</frontend_type>
273
- <sort_order>5</sort_order>
274
  <show_in_default>1</show_in_default>
275
  <show_in_website>1</show_in_website>
276
  <show_in_store>1</show_in_store>
@@ -366,7 +366,7 @@
366
  <purchaseorder translate="label">
367
  <label>Purchase Order</label>
368
  <frontend_type>text</frontend_type>
369
- <sort_order>7</sort_order>
370
  <show_in_default>1</show_in_default>
371
  <show_in_website>1</show_in_website>
372
  <show_in_store>1</show_in_store>
@@ -448,7 +448,7 @@
448
  <banktransfer translate="label">
449
  <label>Bank Transfer Payment</label>
450
  <frontend_type>text</frontend_type>
451
- <sort_order>5</sort_order>
452
  <show_in_default>1</show_in_default>
453
  <show_in_website>1</show_in_website>
454
  <show_in_store>1</show_in_store>
@@ -535,7 +535,7 @@
535
  <cashondelivery translate="label">
536
  <label>Cash On Delivery Payment</label>
537
  <frontend_type>text</frontend_type>
538
- <sort_order>5</sort_order>
539
  <show_in_default>1</show_in_default>
540
  <show_in_website>1</show_in_website>
541
  <show_in_store>1</show_in_store>
39
  <ccsave translate="label">
40
  <label>Saved CC</label>
41
  <frontend_type>text</frontend_type>
42
+ <sort_order>27</sort_order>
43
  <show_in_default>1</show_in_default>
44
  <show_in_website>1</show_in_website>
45
  <show_in_store>1</show_in_store>
173
  <checkmo translate="label">
174
  <label>Check / Money Order</label>
175
  <frontend_type>text</frontend_type>
176
+ <sort_order>30</sort_order>
177
  <show_in_default>1</show_in_default>
178
  <show_in_website>1</show_in_website>
179
  <show_in_store>1</show_in_store>
270
  <free translate="label">
271
  <label>Zero Subtotal Checkout</label>
272
  <frontend_type>text</frontend_type>
273
+ <sort_order>30</sort_order>
274
  <show_in_default>1</show_in_default>
275
  <show_in_website>1</show_in_website>
276
  <show_in_store>1</show_in_store>
366
  <purchaseorder translate="label">
367
  <label>Purchase Order</label>
368
  <frontend_type>text</frontend_type>
369
+ <sort_order>32</sort_order>
370
  <show_in_default>1</show_in_default>
371
  <show_in_website>1</show_in_website>
372
  <show_in_store>1</show_in_store>
448
  <banktransfer translate="label">
449
  <label>Bank Transfer Payment</label>
450
  <frontend_type>text</frontend_type>
451
+ <sort_order>30</sort_order>
452
  <show_in_default>1</show_in_default>
453
  <show_in_website>1</show_in_website>
454
  <show_in_store>1</show_in_store>
535
  <cashondelivery translate="label">
536
  <label>Cash On Delivery Payment</label>
537
  <frontend_type>text</frontend_type>
538
+ <sort_order>30</sort_order>
539
  <show_in_default>1</show_in_default>
540
  <show_in_website>1</show_in_website>
541
  <show_in_store>1</show_in_store>
app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Field/Country.php ADDED
@@ -0,0 +1,127 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_Paypal
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Field renderer for PayPal merchant country selector
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Paypal
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Paypal_Block_Adminhtml_System_Config_Field_Country
35
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
36
+ {
37
+ /**#@+
38
+ *
39
+ * Request parameters names
40
+ */
41
+ const REQUEST_PARAM_COUNTRY = 'country';
42
+ const REQUEST_PARAM_DEFAULT = 'default_country';
43
+ /**#@-*/
44
+
45
+ /**
46
+ * Country of default scope
47
+ *
48
+ * @var string
49
+ */
50
+ protected $_defaultCountry;
51
+
52
+ /**
53
+ * Render country field considering request parameter
54
+ *
55
+ * @param Varien_Data_Form_Element_Abstract $element
56
+ * @return string
57
+ */
58
+ public function render(Varien_Data_Form_Element_Abstract $element)
59
+ {
60
+ $country = $this->getRequest()->getParam(self::REQUEST_PARAM_COUNTRY);
61
+ if ($country) {
62
+ $element->setValue($country);
63
+ }
64
+
65
+ if ($element->getCanUseDefaultValue()) {
66
+ $defaultConfigNode = Mage::getConfig()->getNode(null, 'default');
67
+ if ($defaultConfigNode) {
68
+ $this->_defaultCountry = (string)$defaultConfigNode->descend('paypal/general/merchant_country');
69
+ }
70
+ if (!$this->_defaultCountry) {
71
+ $this->_defaultCountry = Mage::helper('core')->getDefaultCountry();
72
+ }
73
+ if ($country) {
74
+ $shouldInherit = $country == $this->_defaultCountry
75
+ && $this->getRequest()->getParam(self::REQUEST_PARAM_DEFAULT);
76
+ $element->setInherit($shouldInherit);
77
+ }
78
+ if ($element->getInherit()) {
79
+ $this->_defaultCountry = null;
80
+ }
81
+ }
82
+
83
+ return parent::render($element);
84
+ }
85
+
86
+ /**
87
+ * Get country selector html
88
+ *
89
+ * @param Varien_Data_Form_Element_Abstract $element
90
+ * @return string
91
+ */
92
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
93
+ {
94
+ $configDataModel = Mage::getSingleton('adminhtml/config_data');
95
+ $urlParams = array(
96
+ 'section' => $configDataModel->getSection(),
97
+ 'website' => $configDataModel->getWebsite(),
98
+ 'store' => $configDataModel->getStore(),
99
+ self::REQUEST_PARAM_COUNTRY => '__country__',
100
+ );
101
+ $urlString = $this->helper('core')
102
+ ->jsQuoteEscape(Mage::getModel('adminhtml/url')->getUrl('*/*/*', $urlParams));
103
+ $jsString = '
104
+ $("' . $element->getHtmlId() . '").observe("change", function () {
105
+ location.href = \'' . $urlString . '\'.replace("__country__", this.value);
106
+ });
107
+ ';
108
+
109
+ if ($this->_defaultCountry) {
110
+ $urlParams[self::REQUEST_PARAM_DEFAULT] = '__default__';
111
+ $urlString = $this->helper('core')
112
+ ->jsQuoteEscape(Mage::getModel('adminhtml/url')->getUrl('*/*/*', $urlParams));
113
+ $jsParentCountry = $this->helper('core')->jsQuoteEscape($this->_defaultCountry);
114
+ $jsString .= '
115
+ $("' . $element->getHtmlId() . '_inherit").observe("click", function () {
116
+ if (this.checked) {
117
+ location.href = \'' . $urlString . '\'.replace("__country__", \'' . $jsParentCountry . '\')
118
+ .replace("__default__", "1");
119
+ }
120
+ });
121
+ ';
122
+ }
123
+
124
+ return parent::_getElementHtml($element) . $this->helper('adminhtml/js')
125
+ ->getScript('document.observe("dom:loaded", function() {' . $jsString . '});');
126
+ }
127
+ }
app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Field/Hidden.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_Paypal
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Field renderer for hidden fields
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Paypal
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Paypal_Block_Adminhtml_System_Config_Field_Hidden
35
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
36
+ {
37
+ /**
38
+ * Decorate field row html to be invisible
39
+ *
40
+ * @param Varien_Data_Form_Element_Abstract $element
41
+ * @param string $html
42
+ * @return string
43
+ */
44
+ protected function _decorateRowHtml($element, $html)
45
+ {
46
+ return '<tr id="row_' . $element->getHtmlId() . '" style="display: none;">' . $html . '</tr>';
47
+ }
48
+ }
app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Fieldset/Expanded.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_Paypal
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Fielset renderer which expanded by default
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Paypal
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Paypal_Block_Adminhtml_System_Config_Fieldset_Expanded
35
+ extends Mage_Adminhtml_Block_System_Config_Form_Fieldset
36
+ {
37
+ /**
38
+ * Return collapse state
39
+ *
40
+ * @param Varien_Data_Form_Element_Abstract $element
41
+ * @return bool
42
+ */
43
+ protected function _getCollapseState($element)
44
+ {
45
+ $extra = Mage::getSingleton('admin/session')->getUser()->getExtra();
46
+ if (isset($extra['configState'][$element->getId()])) {
47
+ return $extra['configState'][$element->getId()];
48
+ }
49
+
50
+ return true;
51
+ }
52
+ }
app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Fieldset/Global.php CHANGED
@@ -27,6 +27,7 @@
27
  /**
28
  * Fieldset renderer for PayPal global settings
29
  * @author Magento Core Team <core@magentocommerce.com>
 
30
  */
31
  class Mage_Paypal_Block_Adminhtml_System_Config_Fieldset_Global
32
  extends Mage_Adminhtml_Block_Abstract
27
  /**
28
  * Fieldset renderer for PayPal global settings
29
  * @author Magento Core Team <core@magentocommerce.com>
30
+ * @deprecated since 1.7.0.1
31
  */
32
  class Mage_Paypal_Block_Adminhtml_System_Config_Fieldset_Global
33
  extends Mage_Adminhtml_Block_Abstract
app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Fieldset/Group.php ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_Paypal
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Fieldset renderer for PayPal solutions group
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Paypal
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Paypal_Block_Adminhtml_System_Config_Fieldset_Group
35
+ extends Mage_Adminhtml_Block_System_Config_Form_Fieldset
36
+ {
37
+ /**
38
+ * Return header comment part of html for fieldset
39
+ *
40
+ * @param Varien_Data_Form_Element_Abstract $element
41
+ * @return string
42
+ */
43
+ protected function _getHeaderCommentHtml($element)
44
+ {
45
+ $groupConfig = $this->getGroup($element)->asArray();
46
+
47
+ if (empty($groupConfig['help_url']) || !$element->getComment()) {
48
+ return parent::_getHeaderCommentHtml($element);
49
+ }
50
+
51
+ $html = '<div class="comment">' . $element->getComment()
52
+ . ' <a target="_blank" href="' . $groupConfig['help_url'] . '">'
53
+ . Mage::helper('paypal')->__('Help') . '</a></div>';
54
+
55
+ return $html;
56
+ }
57
+
58
+ /**
59
+ * Return collapse state
60
+ *
61
+ * @param Varien_Data_Form_Element_Abstract $element
62
+ * @return bool
63
+ */
64
+ protected function _getCollapseState($element)
65
+ {
66
+ $extra = Mage::getSingleton('admin/session')->getUser()->getExtra();
67
+ if (isset($extra['configState'][$element->getId()])) {
68
+ return $extra['configState'][$element->getId()];
69
+ }
70
+
71
+ if ($element->getExpanded() !== null) {
72
+ return 1;
73
+ }
74
+
75
+ return false;
76
+ }
77
+ }
app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Fieldset/Hint.php CHANGED
@@ -27,6 +27,7 @@
27
 
28
  /**
29
  * Renderer for PayPal banner in System Configuration
 
30
  * @author Magento Core Team <core@magentocommerce.com>
31
  */
32
  class Mage_Paypal_Block_Adminhtml_System_Config_Fieldset_Hint
@@ -43,6 +44,55 @@ class Mage_Paypal_Block_Adminhtml_System_Config_Fieldset_Hint
43
  */
44
  public function render(Varien_Data_Form_Element_Abstract $element)
45
  {
46
- return $this->toHtml();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47
  }
48
  }
27
 
28
  /**
29
  * Renderer for PayPal banner in System Configuration
30
+ *
31
  * @author Magento Core Team <core@magentocommerce.com>
32
  */
33
  class Mage_Paypal_Block_Adminhtml_System_Config_Fieldset_Hint
44
  */
45
  public function render(Varien_Data_Form_Element_Abstract $element)
46
  {
47
+ $elementOriginalData = $element->getOriginalData();
48
+ if (isset($elementOriginalData['help_link'])) {
49
+ $this->setHelpLink($elementOriginalData['help_link']);
50
+ }
51
+ $js = '
52
+ paypalToggleSolution = function(id, url) {
53
+ var doScroll = false;
54
+ Fieldset.toggleCollapse(id, url);
55
+ if ($(this).hasClassName("open")) {
56
+ $$(".with-button button.button").each(function(anotherButton) {
57
+ if (anotherButton != this && $(anotherButton).hasClassName("open")) {
58
+ $(anotherButton).click();
59
+ doScroll = true;
60
+ }
61
+ }.bind(this));
62
+ }
63
+ if (doScroll) {
64
+ var pos = Element.cumulativeOffset($(this));
65
+ window.scrollTo(pos[0], pos[1] - 45);
66
+ }
67
+ }
68
+
69
+ togglePaypalSolutionConfigureButton = function(button, enable) {
70
+ var $button = $(button);
71
+ $button.disabled = !enable;
72
+ if ($button.hasClassName("disabled") && enable) {
73
+ $button.removeClassName("disabled");
74
+ } else if (!$button.hasClassName("disabled") && !enable) {
75
+ $button.addClassName("disabled");
76
+ }
77
+ }
78
+
79
+ // check store-view disabling Express Checkout
80
+ document.observe("dom:loaded", function() {
81
+ var ecButton = $$(".pp-method-express button.button")[0];
82
+ var ecEnabler = $$(".paypal-ec-enabler")[0];
83
+ if (typeof ecButton == "undefined" || typeof ecEnabler != "undefined") {
84
+ return;
85
+ }
86
+ var $ecButton = $(ecButton);
87
+ $$(".with-button button.button").each(function(configureButton) {
88
+ if (configureButton != ecButton && !configureButton.disabled
89
+ && !$(configureButton).hasClassName("paypal-ec-separate")
90
+ ) {
91
+ togglePaypalSolutionConfigureButton(ecButton, false);
92
+ }
93
+ });
94
+ });
95
+ ';
96
+ return $this->toHtml() . $this->helper('adminhtml/js')->getScript($js);
97
  }
98
  }
app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Fieldset/Location.php ADDED
@@ -0,0 +1,353 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_Paypal
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Fieldset renderer for PayPal Merchant Location fieldset
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Paypal
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Paypal_Block_Adminhtml_System_Config_Fieldset_Location
35
+ extends Mage_Adminhtml_Block_System_Config_Form_Fieldset
36
+ {
37
+ /**
38
+ * Add conflicts resolution js code to the fieldset
39
+ *
40
+ * @param Varien_Data_Form_Element_Abstract $element
41
+ * @param bool $tooltipsExist Init tooltips observer or not
42
+ * @return string
43
+ */
44
+ protected function _getExtraJs($element, $tooltipsExist = false)
45
+ {
46
+ $js = '
47
+ document.observe("dom:loaded", function() {
48
+ $$(".with-button button.button").each(function(configureButton) {
49
+ togglePaypalSolutionConfigureButton(configureButton, true);
50
+ });
51
+ var paypalConflictsObject = {
52
+ "isConflict": false,
53
+ "ecMissed": false,
54
+ sharePayflowEnabling: function(enabler, isEvent) {
55
+ var ecPayflowEnabler = $$(".paypal-ec-payflow-enabler")[0];
56
+ if (typeof ecPayflowEnabler == "undefined") {
57
+ return;
58
+ }
59
+ var ecPayflowScopeElement = adminSystemConfig.getScopeElement(ecPayflowEnabler);
60
+
61
+ if (!enabler.enablerObject.ecPayflow) {
62
+ if ((!ecPayflowScopeElement || !ecPayflowScopeElement.checked) && isEvent
63
+ && enabler.value == 1
64
+ ) {
65
+ ecPayflowEnabler.value = 0;
66
+ fireEvent(ecPayflowEnabler, "change");
67
+ }
68
+ return;
69
+ }
70
+
71
+ var enablerScopeElement = adminSystemConfig.getScopeElement(enabler);
72
+ if (enablerScopeElement && ecPayflowScopeElement
73
+ && enablerScopeElement.checked != ecPayflowScopeElement.checked
74
+ && (isEvent || ecPayflowScopeElement.checked)
75
+ ) {
76
+ $(ecPayflowScopeElement).click();
77
+ }
78
+
79
+ var ecEnabler = $$(".paypal-ec-enabler")[0];
80
+ if (ecPayflowEnabler.value != enabler.value && (isEvent || enabler.value == 1)) {
81
+ ecPayflowEnabler.value = enabler.value;
82
+ fireEvent(ecPayflowEnabler, "change");
83
+ if (ecPayflowEnabler.value == 1) {
84
+ if (typeof ecEnabler != "undefined") {
85
+ var ecEnablerScopeElement = adminSystemConfig.getScopeElement(ecEnabler);
86
+ ecEnabler.value = 1;
87
+ if (ecEnablerScopeElement && ecEnablerScopeElement.checked) {
88
+ paypalConflictsObject.checklessEventAction(ecEnablerScopeElement, false);
89
+ }
90
+ paypalConflictsObject.checklessEventAction(ecEnabler, true);
91
+ }
92
+ }
93
+ }
94
+ if (!isEvent && ecPayflowEnabler.value == 1 && typeof ecEnabler != "undefined") {
95
+ var ecSolution = $$(".pp-method-express")[0];
96
+ if (typeof ecSolution != "undefined" && !$(ecSolution).hasClassName("enabled")) {
97
+ ecSolution.addClassName("enabled");
98
+ }
99
+ }
100
+ },
101
+ onChangeEnabler: function(event) {
102
+ paypalConflictsObject.checkPaymentConflicts($(Event.element(event)), "change");
103
+ },
104
+ onClickEnablerScope: function(event) {
105
+ paypalConflictsObject.checkPaymentConflicts(
106
+ $(adminSystemConfig.getUpTr($(Event.element(event))).select(".paypal-enabler")[0]),
107
+ "click"
108
+ );
109
+ },
110
+ getSharedElements: function(element) {
111
+ var sharedElements = [];
112
+ adminSystemConfig.mapClasses(element, true, function(elementClassName) {
113
+ $$("." + elementClassName).each(function(sharedElement) {
114
+ if (sharedElements.indexOf(sharedElement) == -1) {
115
+ sharedElements.push(sharedElement);
116
+ }
117
+ });
118
+ });
119
+ if (sharedElements.length == 0) {
120
+ sharedElements.push(element);
121
+ }
122
+ return sharedElements;
123
+ },
124
+ checklessEventAction: function(element, isChange) {
125
+ var action = isChange ? "change" : "click";
126
+ var handler = isChange
127
+ ? paypalConflictsObject.onChangeEnabler
128
+ : paypalConflictsObject.onClickEnablerScope;
129
+ paypalConflictsObject.getSharedElements(element).each(function(sharedElement) {
130
+ Event.stopObserving(sharedElement, action, handler);
131
+ if (isChange) {
132
+ sharedElement.value = element.value;
133
+ if ($(sharedElement).requiresObj) {
134
+ $(sharedElement).requiresObj.indicateEnabled();
135
+ }
136
+ }
137
+ });
138
+ if (isChange) {
139
+ fireEvent(element, "change");
140
+ } else {
141
+ $(element).click();
142
+ }
143
+ paypalConflictsObject.getSharedElements(element).each(function(sharedElement) {
144
+ Event.observe(sharedElement, action, handler);
145
+ });
146
+ },
147
+ ecCheckAvailability: function() {
148
+ var ecButton = $$(".pp-method-express button.button")[0];
149
+ if (typeof ecButton == "undefined") {
150
+ return;
151
+ }
152
+ var couldBeConfigured = true;
153
+ $$(".paypal-enabler").each(function(enabler) {
154
+ if (enabler.enablerObject.ecEnabler || enabler.enablerObject.ecConflicts
155
+ || enabler.enablerObject.ecSeparate
156
+ ) {
157
+ return;
158
+ }
159
+ if (enabler.value == 1) {
160
+ couldBeConfigured = false;
161
+ }
162
+ });
163
+ if (couldBeConfigured) {
164
+ togglePaypalSolutionConfigureButton(ecButton, true);
165
+ } else {
166
+ togglePaypalSolutionConfigureButton(ecButton, false);
167
+ }
168
+ },
169
+ // type could be "initial", "change", "click"
170
+ checkPaymentConflicts: function(enabler, type) {
171
+ var isEvent = (type != "initial");
172
+ var ecEnabler = $$(".paypal-ec-enabler")[0];
173
+
174
+ if (enabler.value == 0) {
175
+ if (!enabler.enablerObject.ecIndependent && type == "change") {
176
+ if (typeof ecEnabler != "undefined" && ecEnabler.value == 1) {
177
+ var ecEnablerScopeElement = adminSystemConfig.getScopeElement(ecEnabler);
178
+ if (!ecEnablerScopeElement || !ecEnablerScopeElement.checked) {
179
+ ecEnabler.value = 0;
180
+ paypalConflictsObject.checklessEventAction(ecEnabler, true);
181
+ }
182
+ }
183
+ }
184
+ paypalConflictsObject.ecCheckAvailability();
185
+ paypalConflictsObject.sharePayflowEnabling(enabler, isEvent);
186
+ return;
187
+ }
188
+
189
+ var confirmationApproved = isEvent;
190
+ var confirmationShowed = false;
191
+ // check other solutions
192
+ $$(".paypal-enabler").each(function(anotherEnabler) {
193
+ var anotherEnablerScopeElement = adminSystemConfig.getScopeElement(anotherEnabler);
194
+ if (!confirmationApproved && isEvent || $(anotherEnabler) == enabler
195
+ || anotherEnabler.value == 0
196
+ && (!anotherEnablerScopeElement || !anotherEnablerScopeElement.checked)
197
+ ) {
198
+ return;
199
+ }
200
+ var conflict = enabler.enablerObject.ecConflicts && anotherEnabler.enablerObject.ecEnabler
201
+ || enabler.enablerObject.ecEnabler && anotherEnabler.enablerObject.ecConflicts
202
+ || !enabler.enablerObject.ecIndependent && anotherEnabler.enablerObject.ecConflicts
203
+ || !enabler.enablerObject.ecEnabler && !anotherEnabler.enablerObject.ecEnabler;
204
+
205
+ if (conflict && !confirmationShowed && anotherEnabler.value == 1) {
206
+ if (isEvent) {
207
+ confirmationApproved = confirm(\'' . $this->helper('core')->jsQuoteEscape($this->__('There is already another PayPal solution enabled. Enable this solution instead?')) . '\');
208
+ } else {
209
+ paypalConflictsObject.isConflict = true;
210
+ }
211
+ confirmationShowed = true;
212
+ }
213
+ if (conflict && confirmationApproved) {
214
+ anotherEnabler.value = 0;
215
+ if (anotherEnablerScopeElement && anotherEnablerScopeElement.checked && isEvent) {
216
+ paypalConflictsObject.checklessEventAction(anotherEnablerScopeElement, false);
217
+ }
218
+ paypalConflictsObject.checklessEventAction(anotherEnabler, true);
219
+ }
220
+ });
221
+
222
+ if (!enabler.enablerObject.ecIndependent) {
223
+ if (!isEvent && (typeof ecEnabler == "undefined" || ecEnabler.value == 0)) {
224
+ if (!enabler.enablerObject.ecPayflow) {
225
+ paypalConflictsObject.ecMissed = true;
226
+ }
227
+ } else if (isEvent && typeof ecEnabler != "undefined" && confirmationApproved) {
228
+ var ecEnablerScopeElement = adminSystemConfig.getScopeElement(ecEnabler);
229
+ if (ecEnablerScopeElement && ecEnablerScopeElement.checked) {
230
+ paypalConflictsObject.checklessEventAction(ecEnablerScopeElement, false);
231
+ }
232
+ if (ecEnabler.value == 0) {
233
+ ecEnabler.value = 1;
234
+ paypalConflictsObject.checklessEventAction(ecEnabler, true);
235
+ }
236
+ }
237
+ }
238
+
239
+ if (!confirmationApproved && isEvent) {
240
+ enabler.value = 0;
241
+ paypalConflictsObject.checklessEventAction(enabler, true);
242
+ }
243
+ paypalConflictsObject.ecCheckAvailability();
244
+ paypalConflictsObject.sharePayflowEnabling(enabler, isEvent);
245
+ }
246
+ };
247
+
248
+ // fill enablers with conflict data
249
+ $$(".paypal-enabler").each(function(enablerElement) {
250
+ var enablerObj = {
251
+ ecIndependent: false,
252
+ ecConflicts: false,
253
+ ecEnabler: false,
254
+ ecSeparate: false,
255
+ ecPayflow: false
256
+ };
257
+ $(enablerElement).classNames().each(function(className) {
258
+ switch (className) {
259
+ case "paypal-ec-conflicts":
260
+ enablerObj.ecConflicts = true;
261
+ case "paypal-ec-independent":
262
+ enablerObj.ecIndependent = true;
263
+ break;
264
+ case "paypal-ec-enabler":
265
+ enablerObj.ecEnabler = true;
266
+ enablerObj.ecIndependent = true;
267
+ break;
268
+ case "paypal-ec-separate":
269
+ enablerObj.ecSeparate = true;
270
+ enablerObj.ecIndependent = true;
271
+ break;
272
+ case "paypal-ec-pe":
273
+ enablerObj.ecPayflow = true;
274
+ break;
275
+ }
276
+ });
277
+ enablerElement.enablerObject = enablerObj;
278
+
279
+ Event.observe(enablerElement, "change", paypalConflictsObject.onChangeEnabler);
280
+ var enablerScopeElement = adminSystemConfig.getScopeElement(enablerElement);
281
+ if (enablerScopeElement) {
282
+ Event.observe(enablerScopeElement, "click", paypalConflictsObject.onClickEnablerScope);
283
+ }
284
+ });
285
+
286
+ // initially uncheck payflow
287
+ var ecPayflowEnabler = $$(".paypal-ec-payflow-enabler")[0];
288
+ if (typeof ecPayflowEnabler != "undefined") {
289
+ if (ecPayflowEnabler.value == 1) {
290
+ ecPayflowEnabler.value = 0;
291
+ fireEvent(ecPayflowEnabler, "change");
292
+ }
293
+
294
+ var ecPayflowScopeElement = adminSystemConfig.getScopeElement(ecPayflowEnabler);
295
+ if (ecPayflowScopeElement && !ecPayflowScopeElement.checked) {
296
+ $(ecPayflowScopeElement).click();
297
+ }
298
+ }
299
+
300
+ $$(".paypal-enabler").each(function(enablerElement) {
301
+ paypalConflictsObject.checkPaymentConflicts(enablerElement, "initial");
302
+ });
303
+ if (paypalConflictsObject.isConflict || paypalConflictsObject.ecMissed) {
304
+ var notification = \'' . $this->helper('core')->jsQuoteEscape($this->__('The following error(s) occured:')) . '\';
305
+ if (paypalConflictsObject.isConflict) {
306
+ notification += "\\n " + \'' . $this->helper('core')->jsQuoteEscape($this->__('Some PayPal solutions conflict.')) . '\';
307
+ }
308
+ if (paypalConflictsObject.ecMissed) {
309
+ notification += "\\n " + \'' . $this->helper('core')->jsQuoteEscape($this->__('PayPal Express Checkout is not enabled.')) . '\';
310
+ }
311
+ notification += "\\n" + \'' . $this->helper('core')->jsQuoteEscape($this->__('Please re-enable the previously enabled payment solutions.')) . '\';
312
+ setTimeout(function() {
313
+ alert(notification);
314
+ }, 1);
315
+ }
316
+
317
+ $$(".requires").each(function(dependent) {
318
+ var $dependent = $(dependent);
319
+ if ($dependent.hasClassName("paypal-ec-enabler")) {
320
+ $dependent.requiresObj.callback = function(required) {
321
+ if ($(required).hasClassName("paypal-enabler") && required.value == 0) {
322
+ $dependent.disable();
323
+ }
324
+ }
325
+ $dependent.requiresObj.requires.each(function(required) {
326
+ $dependent.requiresObj.callback(required);
327
+ });
328
+ }
329
+ });
330
+
331
+ var originalFormValidation = configForm.validator.options.onFormValidate;
332
+ configForm.validator.options.onFormValidate = function(result, form) {
333
+ originalFormValidation(result, form);
334
+ if (result) {
335
+ var ecPayflowEnabler = $$(".paypal-ec-payflow-enabler")[0];
336
+ if (typeof ecPayflowEnabler == "undefined") {
337
+ return;
338
+ }
339
+ var ecPayflowScopeElement = adminSystemConfig.getScopeElement(ecPayflowEnabler);
340
+ if ((typeof ecPayflowScopeElement == "undefined" || !ecPayflowScopeElement.checked)
341
+ && ecPayflowEnabler.value == 1
342
+ ) {
343
+ $$(".paypal-ec-enabler").each(function(ecEnabler) {
344
+ ecEnabler.value = 0;
345
+ });
346
+ }
347
+ }
348
+ }
349
+ });
350
+ ';
351
+ return parent::_getExtraJs($element, $tooltipsExist) . $this->helper('adminhtml/js')->getScript($js);
352
+ }
353
+ }
app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Fieldset/Payment.php ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_Paypal
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Fieldset renderer for PayPal solution
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Paypal
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Paypal_Block_Adminhtml_System_Config_Fieldset_Payment
35
+ extends Mage_Adminhtml_Block_System_Config_Form_Fieldset
36
+ {
37
+ /**
38
+ * Add custom css class
39
+ *
40
+ * @param Varien_Data_Form_Element_Abstract $element
41
+ * @return string
42
+ */
43
+ protected function _getFrontendClass($element)
44
+ {
45
+ return parent::_getFrontendClass($element) . ' with-button '
46
+ . ($this->_isPaymentEnabled($element) ? ' enabled' : '');
47
+ }
48
+
49
+ /**
50
+ * Check whether current payment method is enabled
51
+ *
52
+ * @param Varien_Data_Form_Element_Abstract $element
53
+ * @return bool
54
+ */
55
+ protected function _isPaymentEnabled($element)
56
+ {
57
+ $groupConfig = $this->getGroup($element)->asArray();
58
+ $activityPath = isset($groupConfig['activity_path']) ? $groupConfig['activity_path'] : '';
59
+
60
+ if (empty($activityPath)) {
61
+ return false;
62
+ }
63
+
64
+ $isPaymentEnabled = (string)Mage::getSingleton('adminhtml/config_data')->getConfigDataValue($activityPath);
65
+
66
+ return (bool)$isPaymentEnabled;
67
+ }
68
+
69
+ /**
70
+ * Return header title part of html for payment solution
71
+ *
72
+ * @param Varien_Data_Form_Element_Abstract $element
73
+ * @return string
74
+ */
75
+ protected function _getHeaderTitleHtml($element)
76
+ {
77
+ $html = '<div class="config-heading" ><div class="heading"><strong>' . $element->getLegend();
78
+
79
+ $groupConfig = $this->getGroup($element)->asArray();
80
+ if (!empty($groupConfig['learn_more_link'])) {
81
+ $html .= '<a class="link-more" href="' . $groupConfig['learn_more_link'] . '" target="_blank">'
82
+ . $this->__('Learn More') . '</a>';
83
+ }
84
+ if (!empty($groupConfig['demo_link'])) {
85
+ $html .= '<a class="link-demo" href="' . $groupConfig['demo_link'] . '" target="_blank">'
86
+ . $this->__('View Demo') . '</a>';
87
+ }
88
+ $html .= '</strong>';
89
+
90
+ if ($element->getComment()) {
91
+ $html .= '<span class="heading-intro">' . $element->getComment() . '</span>';
92
+ }
93
+ $html .= '</div>';
94
+
95
+ $html .= '<div class="button-container"><button type="button"'
96
+ . ($this->_isPaymentEnabled($element) ? '' : ' disabled="disabled"') . ' class="button'
97
+ . (empty($groupConfig['paypal_ec_separate']) ? '' : ' paypal-ec-separate')
98
+ . ($this->_isPaymentEnabled($element) ? '' : ' disabled') . '" id="' . $element->getHtmlId()
99
+ . '-head" onclick="paypalToggleSolution.call(this, \'' . $element->getHtmlId() . '\', \''
100
+ . $this->getUrl('*/*/state') . '\'); return false;"><span class="state-closed">'
101
+ . $this->__('Configure') . '</span><span class="state-opened">'
102
+ . $this->__('Close') . '</span></button></div></div>';
103
+
104
+ return $html;
105
+ }
106
+
107
+ /**
108
+ * Return header comment part of html for payment solution
109
+ *
110
+ * @param Varien_Data_Form_Element_Abstract $element
111
+ * @return string
112
+ */
113