Copernica_MarketingSoftware - Version 3.0.1

Version Notes

- Several bug fixes which have been discovered by verious users in the last release.

Download this release

Release Info

Developer Cream
Extension Copernica_MarketingSoftware
Version 3.0.1
Comparing to
See all releases


Code changes from version 3.0.0 to 3.0.1

app/code/community/Copernica/MarketingSoftware/Block/Adminhtml/Marketingsoftware/Link.php CHANGED
@@ -1,145 +1,42 @@
1
- <?php
2
- /**
3
- * Copernica Marketing Software
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0).
8
- * It is available through the world-wide-web at this URL:
9
- * http://opensource.org/licenses/osl-3.0.php
10
- * If you are unable to obtain a copy of the license through the
11
- * world-wide-web, please send an email to copernica@support.cream.nl
12
- * so we can send you a copy immediately.
13
- *
14
- * DISCLAIMER
15
- *
16
- * Do not edit or add to this file if you wish to upgrade this software
17
- * to newer versions in the future. If you wish to customize this module
18
- * for your needs please refer to http://www.magento.com/ for more
19
- * information.
20
- *
21
- * @category Copernica
22
- * @package Copernica_MarketingSoftware
23
- * @copyright Copyright (c) 2011-2012 Copernica & Cream. (http://docs.cream.nl/)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
-
27
- /**
28
- * Link Block
29
- *
30
- */
31
- class Copernica_MarketingSoftware_Block_Adminhtml_Marketingsoftware_Link extends Mage_Core_Block_Template
32
- {
33
  /**
34
  * Constructor
35
  *
36
  */
37
- public function __construct()
38
- {
39
- parent::__construct();
40
- $this->setTemplate('marketingsoftware/link.phtml');
41
- }
42
-
43
- /**
44
- * Returns the post URL.
45
- *
46
- * @return string
47
- */
48
- public function getPostUrl()
49
- {
50
- return $this->getUrl('*/*/saveProfilesAndCollections', array('_secure' => true));
51
- }
52
-
53
- /**
54
- * Get supported collection fields
55
- * @param string
56
- * @return array
57
- */
58
- public function getSupportedCollectionFields($collectionType)
59
- {
60
- switch ($collectionType)
61
- {
62
- case 'cartproducts':
63
- return Mage::helper('marketingsoftware')->supportedCartItemFields();
64
- case 'orders':
65
- return Mage::helper('marketingsoftware')->supportedOrderFields();
66
- case 'orderproducts':
67
- return Mage::helper('marketingsoftware')->supportedOrderItemFields();
68
- case 'addresses':
69
- return Mage::helper('marketingsoftware')->supportedAddressFields();
70
- case 'viewedproduct':
71
- return Mage::helper('marketingsoftware')->supportedViewedProductFields();
72
- // if we have non supported collection type, just return empty array
73
- default:
74
- return array();
75
- }
76
- }
77
-
78
- /**
79
- * Below. New Ajax Links
80
- */
81
-
82
- /**
83
- * Get the url to account settings
84
- * @return string
85
- */
86
- public function getAccountSettingsUrl()
87
- {
88
- return $this->getUrl('*/marketingsoftware_settings/index', array('_secure' => true));
89
- }
90
-
91
- /**
92
- * Return Ajax url that will be used to save whole form.
93
- * @return string
94
- */
95
- public function getSaveFormUrl()
96
- {
97
- return $this->getUrl('*/*/saveForm', array('_secure' => true));
98
- }
99
-
100
- /**
101
- * Return Ajax url that will answer AJAX requests about copernica's database repairs.
102
- * @return string
103
- */
104
- public function getAjaxDatabaseValidateUrl()
105
- {
106
- return $this->getUrl('*/marketingsoftware_ajaxdatabase/validate', array('_secure' => true));
107
- }
108
-
109
- /**
110
- * Return Ajax url that will answer AJAX request about copernica's database creations.
111
- * @return string
112
- */
113
- public function getAjaxDatabaseCreateUrl()
114
- {
115
- return $this->getUrl('*/marketingsoftware_ajaxdatabase/create', array('_secure' => true));
116
- }
117
-
118
- /**
119
- * Return Ajax url that can be used to fetch database field
120
- * @return string
121
- */
122
- public function getAjaxDatabaseFetchUrl()
123
- {
124
- return $this->getUrl('*/marketingsoftware_ajaxdatabase/fetchField', array('_secure' => true));
125
- }
126
-
127
- /**
128
- * Rerturn Ajax url that can be used to validate database field
129
- * @return string
130
- */
131
- public function getAjaxDatabaseFieldValidateUrl()
132
- {
133
- return $this->getUrl('*/marketingsoftware_ajaxdatabasefield/validate', array('_secure' => true));
134
- }
135
-
136
- /**
137
- * Return Ajax url that can be used to create database field
138
- * @return string
139
- */
140
- public function getAjaxDatabaseFieldCreateUrl()
141
  {
142
- return $this->getUrl('*/marketingsoftware_ajaxdatabasefield/create', array('_secure' => true));
 
143
  }
144
 
145
  /**
@@ -151,24 +48,6 @@ class Copernica_MarketingSoftware_Block_Adminhtml_Marketingsoftware_Link extends
151
  return $this->getUrl('*/marketingsoftware_ajaxcollection/validate', array('_secure' => true));
152
  }
153
 
154
- /**
155
- * Return Ajax url that can be used to create collection
156
- * @return string
157
- */
158
- public function getAjaxCollectionCreaetUrl()
159
- {
160
- return $this->getUrl('*/marketingsoftware_ajaxcollection/create', array('_secure' => true));
161
- }
162
-
163
- /**
164
- * Return Ajax url that can be used to fetch infromation about collection
165
- * @return string
166
- */
167
- public function getAjaxCollectionInfoUrl()
168
- {
169
- return $this->getUrl('*/marketingsoftware_ajaxcollection/info', array('_secure' => true));
170
- }
171
-
172
  /**
173
  * Return Ajax url that can be used ti fetch information about collection field
174
  * @return string
@@ -177,22 +56,22 @@ class Copernica_MarketingSoftware_Block_Adminhtml_Marketingsoftware_Link extends
177
  {
178
  return $this->getUrl('*/marketingsoftware_ajaxcollection/fetch', array('_secure' => true));
179
  }
180
-
181
  /**
182
- * Return Ajax url that can be used to validate collection fields
183
  * @return string
184
  */
185
- public function getAjaxCollectionFieldValidateUrl()
186
  {
187
- return $this->getUrl('*/marketingsoftware_ajaxcollectionfield/validate', array('_secure' => true));
188
  }
189
 
190
  /**
191
- * Return Ajax url that can be used to create collection fields
192
  * @return string
193
  */
194
- public function getAjaxCollectionFieldCreateUrl()
195
  {
196
- return $this->getUrl('*/marketingsoftware_ajaxcollectionfield/create', array('_secure' => true));
197
- }
198
  }
1
+ <?php
2
+ /**
3
+ * Copernica Marketing Software
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0).
8
+ * It is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ * If you are unable to obtain a copy of the license through the
11
+ * world-wide-web, please send an email to copernica@support.cream.nl
12
+ * so we can send you a copy immediately.
13
+ *
14
+ * DISCLAIMER
15
+ *
16
+ * Do not edit or add to this file if you wish to upgrade this software
17
+ * to newer versions in the future. If you wish to customize this module
18
+ * for your needs please refer to http://www.magento.com/ for more
19
+ * information.
20
+ *
21
+ * @category Copernica
22
+ * @package Copernica_MarketingSoftware
23
+ * @copyright Copyright (c) 2011-2012 Copernica & Cream. (http://docs.cream.nl/)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Link Block
29
+ */
30
+ class Copernica_MarketingSoftware_Block_Adminhtml_Marketingsoftware_Link extends Mage_Core_Block_Template
31
+ {
 
32
  /**
33
  * Constructor
34
  *
35
  */
36
+ public function __construct()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  {
38
+ parent::__construct();
39
+ $this->setTemplate('marketingsoftware/link.phtml');
40
  }
41
 
42
  /**
48
  return $this->getUrl('*/marketingsoftware_ajaxcollection/validate', array('_secure' => true));
49
  }
50
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
  /**
52
  * Return Ajax url that can be used ti fetch information about collection field
53
  * @return string
56
  {
57
  return $this->getUrl('*/marketingsoftware_ajaxcollection/fetch', array('_secure' => true));
58
  }
59
+
60
  /**
61
+ * Return Ajax url that can be used to store collection.
62
  * @return string
63
  */
64
+ public function getAjaxCollectionStoreUrl()
65
  {
66
+ return $this->getUrl('*/marketingsoftware_ajaxcollection/store', array('_secure' => true));
67
  }
68
 
69
  /**
70
+ * Return Ajax url that can be used to create default structure.
71
  * @return string
72
  */
73
+ public function getAjaxCollectionDefaultUrl()
74
  {
75
+ return $this->getUrl('*/marketingsoftware_ajaxcollection/default', array('_secure' => true));
76
+ }
77
  }
app/code/community/Copernica/MarketingSoftware/Helper/ApiBuilder.php CHANGED
@@ -191,12 +191,9 @@ class Copernica_MarketingSoftware_Helper_ApiBuilder extends Copernica_MarketingS
191
  $collectionId = $this->getCollectionIdFromDatabase($databaseName, $collectionName);
192
 
193
  // create the field
194
- $this->request()->post(
195
- 'collection/'.$collectionId.'/fields',
196
- array_merge($fieldDefinition, array(
197
- 'name' => $copernicaName
198
- ))
199
- );
200
  }
201
 
202
  /**
191
  $collectionId = $this->getCollectionIdFromDatabase($databaseName, $collectionName);
192
 
193
  // create the field
194
+ $this->request()->post( 'collection/'.$collectionId.'/fields', array_merge($fieldDefinition, array(
195
+ 'name' => $copernicaName
196
+ )));
 
 
 
197
  }
198
 
199
  /**
app/code/community/Copernica/MarketingSoftware/Helper/ApiValidator.php CHANGED
@@ -39,12 +39,10 @@ class Copernica_MarketingSoftware_Helper_ApiValidator extends Copernica_Marketin
39
  public function validateDatabase($databaseName)
40
  {
41
  // make a request to API to get database structure
42
- $output = $this->request()->get(
43
- 'database/'.urlencode($databaseName)
44
- );
45
 
46
  // check if api say that we have a problem
47
- if (isset($output['error']) || !isset($output['data']))
48
  {
49
  // check if Api tells that database does not exists or something else is wrong
50
  if (strpos($output['error']['message'], 'No database') !== false)
39
  public function validateDatabase($databaseName)
40
  {
41
  // make a request to API to get database structure
42
+ $output = $this->request()->get( 'database/'.urlencode($databaseName) );
 
 
43
 
44
  // check if api say that we have a problem
45
+ if (isset($output['error']) || !isset($output['name']))
46
  {
47
  // check if Api tells that database does not exists or something else is wrong
48
  if (strpos($output['error']['message'], 'No database') !== false)
app/code/community/Copernica/MarketingSoftware/Helper/RESTRequest.php CHANGED
@@ -37,6 +37,21 @@ class Copernica_MarketingSoftware_Helper_RESTRequest
37
  */
38
  protected $multi;
39
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
  /**
41
  * We use normal PHP constructor cause Helpers are not childs of
42
  * Varien_Object class, so no _construct is called.
@@ -122,6 +137,35 @@ class Copernica_MarketingSoftware_Helper_RESTRequest
122
  return '?'.implode('&', $parts);
123
  }
124
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
125
  /**
126
  * Make a GET requst
127
  * @param string Request string
@@ -131,7 +175,7 @@ class Copernica_MarketingSoftware_Helper_RESTRequest
131
  public function get($request, $data = null)
132
  {
133
  // reset curl options
134
- $curl = curl_init();
135
 
136
  // if we have access token then we want to append it to request
137
  if ($this->accessToken) $request.=$this->buildQueryString(array_merge(array(
@@ -175,7 +219,7 @@ class Copernica_MarketingSoftware_Helper_RESTRequest
175
  else $request.='?access_token='.$this->accessToken;
176
 
177
  // create curl
178
- $curl = curl_init();
179
 
180
  // set url that we want to receive
181
  curl_setopt($curl, CURLOPT_URL, $this->hostname.'/'.$request);
@@ -225,7 +269,7 @@ class Copernica_MarketingSoftware_Helper_RESTRequest
225
  else $request.='?access_token='.$this->accessToken;
226
 
227
  // reset curl options
228
- $curl = curl_init();
229
 
230
  // set url that we want to receive
231
  curl_setopt($curl, CURLOPT_URL, $this->hostname.'/'.$request);
@@ -269,7 +313,7 @@ class Copernica_MarketingSoftware_Helper_RESTRequest
269
  public function delete($request, $data = null)
270
  {
271
  // reset curl options
272
- $curl = curl_init();
273
 
274
  // append access token to our request
275
  $request.='?access_token='.$this->accessToken;
37
  */
38
  protected $multi;
39
 
40
+ /**
41
+ * Cipher lists for different crypto libs
42
+ * @var array
43
+ */
44
+ static protected $cipherList = array(
45
+ 'openssl' => "ECDHE-RSA-AES128-SHA256:AES128-GCM-SHA256:RC4:+HIGH",
46
+ 'nss' => "ecdhe_rsa_aes_256_sha:rc4",
47
+ );
48
+
49
+ /**
50
+ * The currently used crypto lib.
51
+ * @var string
52
+ */
53
+ static protected $cryptoLib = null;
54
+
55
  /**
56
  * We use normal PHP constructor cause Helpers are not childs of
57
  * Varien_Object class, so no _construct is called.
137
  return '?'.implode('&', $parts);
138
  }
139
 
140
+ /**
141
+ * Prepare a proper version of curl instance
142
+ * @return resource
143
+ */
144
+ protected function prepareCurl()
145
+ {
146
+ // prepare curl instance
147
+ $curl = curl_init();
148
+
149
+ // well, should we make some detective work?
150
+ if (is_null(self::$cryptoLib))
151
+ {
152
+ // get curl version
153
+ $version = curl_version();
154
+
155
+ // are we using nss?
156
+ if (strpos($version['ssl_version'], 'NSS') !== false) self::$cryptoLib = 'nss';
157
+
158
+ // ssl engines should work with open ssl cipher names
159
+ else self::$cryptoLib = 'openssl';
160
+ }
161
+
162
+ // set curl option
163
+ curl_setopt($curl, CURLOPT_SSL_CIPHER_LIST, self::$cipherList[self::$cryptoLib]);
164
+
165
+ // return prepared curl instance
166
+ return $curl;
167
+ }
168
+
169
  /**
170
  * Make a GET requst
171
  * @param string Request string
175
  public function get($request, $data = null)
176
  {
177
  // reset curl options
178
+ $curl = $this->prepareCurl();
179
 
180
  // if we have access token then we want to append it to request
181
  if ($this->accessToken) $request.=$this->buildQueryString(array_merge(array(
219
  else $request.='?access_token='.$this->accessToken;
220
 
221
  // create curl
222
+ $curl = $this->prepareCurl();
223
 
224
  // set url that we want to receive
225
  curl_setopt($curl, CURLOPT_URL, $this->hostname.'/'.$request);
269
  else $request.='?access_token='.$this->accessToken;
270
 
271
  // reset curl options
272
+ $curl = $this->prepareCurl();
273
 
274
  // set url that we want to receive
275
  curl_setopt($curl, CURLOPT_URL, $this->hostname.'/'.$request);
313
  public function delete($request, $data = null)
314
  {
315
  // reset curl options
316
+ $curl = $this->prepareCurl();
317
 
318
  // append access token to our request
319
  $request.='?access_token='.$this->accessToken;
app/code/community/Copernica/MarketingSoftware/Model/Observer.php CHANGED
@@ -221,7 +221,7 @@ class Copernica_MarketingSoftware_Model_Observer
221
  )))
222
  ->setCustomer($customerId)
223
  ->setAction('remove')
224
- ->serName('quote')
225
  ->setEntityId($quote->getId())
226
  ->save();
227
  }
221
  )))
222
  ->setCustomer($customerId)
223
  ->setAction('remove')
224
+ ->setName('quote')
225
  ->setEntityId($quote->getId())
226
  ->save();
227
  }
app/code/community/Copernica/MarketingSoftware/controllers/Adminhtml/Marketingsoftware/AjaxcollectionController.php CHANGED
@@ -38,43 +38,79 @@ class Copernica_MarketingSoftware_Adminhtml_Marketingsoftware_AjaxcollectionCont
38
  // get POST variables
39
  $post = $this->getRequest()->getPost();
40
 
41
- try
42
- {
43
- // if we don't have a database name we want to tell user that he should provide us with one
44
- if (!isset($post['databaseName'])) throw Mage::exception('Copernica_MarketingSoftware', 'No valid database', Copernica_MarketingSoftware_Exception::DATABASE_NOT_EXISTS);
45
 
46
- // if we don't have collection name we want to tell user that his input was wrong
47
- if (!isset($post['collectionName']) || !isset($post['collectionType'])) throw Mage::exception('Copernica_MarketingSoftware', 'Invalid input', Copernica_MarketingSoftware_Exception::INVALID_INPUT);
48
 
49
- // try to valdiate collection
50
- $this->validateCollection($post['databaseName'], $post['collectionName'], $post['collectionType']);
51
-
52
- // if we are here then everything is just dandy
53
- $this->setResponse('Collection is valid');
54
- }
55
- /**
56
- * All important to us errors will be reported as custom exceptions.
57
- * We can handle them here.
58
- */
59
- catch (Copernica_MarketingSoftware_Exception $copernicaException)
60
  {
61
- // determine if we have a fix for problem
62
- switch ($copernicaException->getCode())
63
  {
64
- case Copernica_MarketingSoftware_Exception::COLLECTION_NOT_EXISTS:
65
- $fix = 'create';
66
- break;
67
- case Copernica_MarketingSoftware_Exception::DATABASE_NOT_EXISTS:
68
- $fix = 'create database';
69
- break;
70
- default:
71
- $fix = '';
72
- break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
73
  }
74
-
75
- // set response for user
76
- $this->setResponse($copernicaException->getMessage(), true, $fix);
77
  }
 
78
  /**
79
  * General exceptions should not happen but, just in case we want to
80
  * handle them here.
@@ -85,240 +121,343 @@ class Copernica_MarketingSoftware_Adminhtml_Marketingsoftware_AjaxcollectionCont
85
  Mage::logException($exception);
86
 
87
  // we have an critical error
88
- $this->setResponse('Critical error. Check error logs form more info.', true);
89
  }
 
 
 
90
  }
91
 
92
- /**
93
- * Action that can be used to create collections
94
  */
95
- public function createAction()
96
  {
97
- // get POST variables
98
  $post = $this->getRequest()->getPost();
99
 
100
- try
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
101
  {
102
- // if we don't have a database name we want to tell user that he should provide us with one
103
- if (!isset($post['databaseName'])) throw Mage::exception('Copernica_MarketingSoftware', 'No valid database', Copernica_MarketingSoftware_Exception::DATABASE_NOT_EXISTS);
 
 
 
 
104
 
105
- // if we don't have collection name we want to tell user that his input was wrong
106
- if (!isset($post['collectionName']) || !isset($post['collectionType'])) throw Mage::exception('Copernica_MarketingSoftware', 'Invalid input', Copernica_MarketingSoftware_Exception::INVALID_INPUT);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
107
 
108
- // create collection
109
- $this->createCollection($post['databaseName'], $post['collectionName'], $post['collectionType']);
 
 
 
 
110
 
111
- // we are good
112
- $this->setResponse('Collection was created');
 
 
 
 
113
  }
114
- /**
115
- * All relevant errors will be reported as exception. We can handle
116
- * them here.
117
- */
118
- catch (Copernica_MarketingSoftware_Exception $copernicaException)
 
119
  {
120
- $this->setResponse($copernicaException->getMessage(), true);
 
 
 
 
121
  }
122
- /**
123
- * All general exception can be just logged by magento.
124
- */
125
- catch (Exception $exception)
126
- {
127
- // tell mageton to log exception
128
- Mage::logException($exception);
129
 
130
- // tell user that we didn't anything due to critical error
131
- $this->setResponse('Critical error. Check error logs for more info.', true);
132
- }
 
 
 
 
133
  }
134
 
135
  /**
136
- * Action that can be used to get information about collection
 
 
 
137
  */
138
- public function infoAction()
139
  {
140
- // get POST variables
141
- $post = $this->getRequest()->getPost();
142
-
143
- // get response instance
144
- $response = $this->getResponse();
145
-
146
- // Ajax response should be encoded with json
147
- $response->setHeader('Content-Type', 'application/json');
148
 
149
- // check if we have collection type?
150
- if (!$post['collectionType'])
151
  {
152
- // clear response body
153
- $response->clearBody();
154
-
155
- // send nice response
156
- $response->setBody(json_encode(array(
157
- 'error' => 1,
158
- 'message' => 'invalid input'
159
- )));
160
-
161
- // we are done here
162
- return;
163
- }
164
-
165
- // get proper collection name
166
- switch ($post['collectionType']) {
167
- case 'cartproducts':
168
- $collectionName = Mage::helper('marketingsoftware/config')->getCartItemsCollectionName();
169
  break;
170
- case 'orders':
171
- $collectionName = Mage::helper('marketingsoftware/config')->getOrdersCollectionName();
172
  break;
173
- case 'orderproducts':
174
- $collectionName = Mage::helper('marketingsoftware/config')->getOrderItemsCollectionName();
175
  break;
176
- case 'addresses':
177
- $collectionName = Mage::helper('marketingsoftware/config')->getAddressCollectionName();
178
  break;
179
- case 'viewedproduct':
180
- $collectionName = Mage::helper('marketingsoftware/config')->getViewedProductCollectionName();
181
  break;
182
  default:
183
- $collectionName = '';
184
  break;
185
  }
186
-
187
- // set the response
188
- $response->setBody(json_encode(array(
189
- 'error' => 0,
190
- 'collectionName' => $collectionName
191
- )));
192
  }
193
 
194
  /**
195
- * This ajax call can be used to fetch information about certain field in collection
196
  */
197
- public function fetchAction()
198
  {
199
- // get post variables
200
  $post = $this->getRequest()->getPost();
201
 
202
- // prepare ajax response
203
- $this->prepareAjaxResponse();
 
204
 
205
- // get response instance into local scope
206
- $response = $this->getResponse();
 
 
 
 
 
207
 
208
- // check if we have all required parameters
209
- if (!isset($post['collectionType']) || !isset($post['magentoField'])) {
210
- $response->setBody(json_encode(array(
211
- 'message' => 'Invalid input',
212
- 'error' => 1
213
- )));
214
- }
215
 
216
- // get collection linked fields
217
- $collectionLinkedField = $this->getLinkedFieldByCollectionType($post['collectionType']);
218
 
219
- // check if we have any linked field
220
- if (empty($collectionLinkedField))
221
- {
222
- $response->setBody(json_encode(array(
223
- 'message' => 'Invalid collection',
224
- 'error' => 1
225
- )));
226
 
227
- // we are done here
228
- return;
229
- }
230
 
231
- // check if we have desired field in supported fields
232
- if (!array_key_exists($post['magentoField'], $collectionLinkedField))
233
- {
234
- $response->setBody(json_encode(array(
235
- 'message' => 'Invalid field',
236
- 'error' => 1
237
- )));
238
 
239
- // we are done here
240
- return;
241
- }
242
 
243
- // set proper response body
244
- $response->setBody(json_encode(array(
245
- 'message' => 'Field data fetched',
246
- 'fieldData' => $collectionLinkedField[$post['magentoField']],
247
- 'error' => 0
248
- )));
249
- }
250
 
251
- /**
252
- * Get all linked field of collection by it's type
253
- * @param string collection type
254
- * @return array
255
- */
256
- private function getLinkedFieldByCollectionType($collectionType)
257
- {
258
- switch ($collectionType) {
259
- case 'cartproducts': return Mage::helper('marketingsoftware/config')->getLinkedCartItemFields();
260
- case 'orders': return Mage::helper('marketingsoftware/config')->getLinkedOrderFields();
261
- case 'orderproducts': return Mage::helper('marketingsoftware/config')->getLinkedOrderItemFields();
262
- case 'addresses': return Mage::helper('marketingsoftware/config')->getLinkedAddressFields();
263
- case 'viewedproduct': return Mage::helper('marketingsoftware/config')->getLinkedViewedProductFields();
264
- default: return array();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
265
  }
266
  }
267
 
268
  /**
269
- * Validate collection.
270
- * @param string database name
271
- * @param string collection name
272
- * @param string collection type
273
  */
274
- private function validateCollection($databaseName, $collectionName, $collectionType)
275
  {
276
- // tell helper to validata collection
277
- Mage::helper('marketingsoftware/ApiValidator')->validateCollection($databaseName, $collectionName, $collectionType);
278
- }
279
 
280
- /**
281
- * Create collection
282
- * @param string database name
283
- * @param string collection name
284
- * @param string collection type
285
- */
286
- private function createCollection($databaseName, $collectionName, $collectionType)
287
- {
288
- // tell helper to create collection
289
- Mage::helper('marketingsoftware/ApiBuilder')->createCollection($databaseName, $collectionName, $collectionType);
290
- }
291
 
292
- /**
293
- * Prepare response object to fix Ajax communication.
294
- */
295
- private function prepareAjaxResponse()
296
- {
297
- // get response instance
298
- $response = $this->getResponse();
299
 
300
- // clear current response body
301
- $response->clearBody();
 
 
 
 
 
 
 
 
 
302
 
303
- // all Ajax responses should be encoded with JSON
304
- $response->setHeader('Content-Type', 'application/json');
305
- }
 
 
 
 
 
 
 
 
 
 
306
 
307
- /**
308
- * @param string Message for user
309
- * @param bool It's an error?
310
- * @param string Do we have an fix for error?
311
- */
312
- private function setResponse($message, $error = false, $fix = '')
313
- {
314
- // prepare response
315
- $this->prepareAjaxResponse();
316
-
317
- // assign response
318
- $this->getResponse()->setBody(json_encode(array(
319
- 'message' => $message,
320
- 'error' => $error ? 1 : 0,
321
- 'fix' => ucfirst($fix)
322
- )));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
323
  }
324
  }
38
  // get POST variables
39
  $post = $this->getRequest()->getPost();
40
 
41
+ // get config helper
42
+ $config = Mage::helper('marketingsoftware/config');
43
+ $validator = Mage::helper('marketingsoftware/ApiValidator');
 
44
 
45
+ // list of problems
46
+ $problems = array();
47
 
48
+ try
 
 
 
 
 
 
 
 
 
 
49
  {
50
+ if ($post['type'] == 'main')
 
51
  {
52
+ try
53
+ {
54
+ // validate database
55
+ $validator->validateDatabase($post['name']);
56
+ }
57
+ catch (Copernica_MarketingSoftware_Exception $exception)
58
+ {
59
+ array_push($problems, $exception->getMessage());
60
+ }
61
+
62
+ // iterate over all fields
63
+ foreach ($post['fields'] as $field)
64
+ {
65
+ // get field magento and copernica name
66
+ list($magento, $copernica) = explode(',', $field);
67
+
68
+ try
69
+ {
70
+ // validate database field
71
+ $validator->validateDatabaseField($post['name'], $copernica, $magento);
72
+ }
73
+ catch (Copernica_MarketingSoftware_Exception $exception)
74
+ {
75
+ array_push($problems, $magento.','.$exception->getMessage());
76
+ }
77
+ }
78
+ }
79
+ else
80
+ {
81
+ // get database name
82
+ $databaseName = $config->getDatabaseName();
83
+
84
+ try
85
+ {
86
+ // validates collection
87
+ $validator->validateCollection($databaseName, $post['name'], $post['type']);
88
+ }
89
+ catch (Copernica_MarketingSoftware_Exception $exception)
90
+ {
91
+ array_push($problems, $exception->getMessage());
92
+ }
93
+
94
+
95
+ // iterate over all fields
96
+ foreach ($post['fields'] as $field)
97
+ {
98
+ // get field magento and copernica name
99
+ list($magento, $copernica) = explode(',', $field);
100
+
101
+ try
102
+ {
103
+ // validate collection field
104
+ $validator->validateCollectionField($databaseName, $post['name'], $post['type'], $copernica, $magento);
105
+ }
106
+ catch (Copernica_MarketingSoftware_Exception $exception)
107
+ {
108
+ array_push($problems, $magento.','.$exception->getMessage());
109
+ }
110
+ }
111
  }
 
 
 
112
  }
113
+
114
  /**
115
  * General exceptions should not happen but, just in case we want to
116
  * handle them here.
121
  Mage::logException($exception);
122
 
123
  // we have an critical error
124
+ $this->getResponse()->setBody('Critical error. Check error logs form more info.');
125
  }
126
+
127
+ // set the response
128
+ $this->getResponse()->setBody(json_encode($problems));
129
  }
130
 
131
+ /**
132
+ * This ajax call can be used to fetch information about certain field in collection
133
  */
134
+ public function fetchAction()
135
  {
136
+ // get post variables
137
  $post = $this->getRequest()->getPost();
138
 
139
+ // get response
140
+ $response = $this->getResponse();
141
+
142
+ // check if we have a required name property
143
+ if (!isset($post['name'])) return $response->setBody(json_encode(array(
144
+ 'message' => 'Invalid input'
145
+ )));
146
+
147
+ // get config and data to local scope
148
+ $config = Mage::helper('marketingsoftware/config');
149
+ $data = Mage::helper('marketingsoftware/data');
150
+
151
+ // get stored database name
152
+ $database = $config->getDatabaseName();
153
+
154
+ // check if we have a database to communicate
155
+ if (empty($database) && $post['name'] != 'main') return $response->setBody(json_encode(array(
156
+ 'error' => 'no database'
157
+ )));
158
+
159
+ // placeholder for linked name
160
+ $linkedName = '';
161
+
162
+ // placeholders
163
+ $linkedFields = array();
164
+ $supportedFields = array();
165
+ $linkedFields = array();
166
+
167
+ // get the collection name
168
+ switch ($post['name'])
169
  {
170
+ case 'main':
171
+ $linkedName = $config->getDatabaseName();
172
+ $supportedFields = $data->supportedCustomerFields();
173
+ $linkedFields = $config->getLinkedCustomerFields();
174
+ $label = 'Database';
175
+ break;
176
 
177
+ case 'orders':
178
+ $linkedName = $config->getOrdersCollectionName();
179
+ $supportedFields = $data->supportedOrderFields();
180
+ $linkedFields = $config->getLinkedOrderFields();
181
+ $label = 'Orders collection';
182
+ break;
183
+
184
+ case 'orderproducts':
185
+ $linkedName = $config->getOrderItemsCollectionName();
186
+ $supportedFields = $data->supportedOrderItemFields();
187
+ $linkedFields = $config->getLinkedOrderItemFields();
188
+ $label = 'Orders items collection';
189
+ break;
190
+
191
+ case 'addresses':
192
+ $linkedName = $config->getAddressesCollectionName();
193
+ $supportedFields = $data->supportedAddressFields();
194
+ $linkedFields = $config->getLinkedAddressFields();
195
+ $label = 'Addresses collection';
196
+ break;
197
 
198
+ case 'viewedproducts':
199
+ $linkedName = $config->getViewedProductCollectionName();
200
+ $supportedFields = $data->supportedViewedProductFields();
201
+ $linkedFields = $config->getLinkedViewedProductFields();
202
+ $label = 'Viewed products collection';
203
+ break;
204
 
205
+ case 'cartproducts':
206
+ $linkedName = $config->getCartItemsCollectionName();
207
+ $supportedFields = $data->supportedCartItemFields();
208
+ $linkedFields = $config->getLinkedCartItemFields();
209
+ $label = 'Cart items collection';
210
+ break;
211
  }
212
+
213
+ // placeholder for fields
214
+ $fields = array();
215
+
216
+ // iterate over supported fields and construct overall fields
217
+ foreach ($supportedFields as $fieldName => $fieldLabel)
218
  {
219
+ $fields[] = array (
220
+ 'magento' => $fieldName,
221
+ 'label' => $fieldLabel,
222
+ 'copernica' => $linkedFields[$fieldName]
223
+ );
224
  }
 
 
 
 
 
 
 
225
 
226
+ // set response body
227
+ $response->setBody(json_encode(array(
228
+ 'name' => $post['name'],
229
+ 'linkedName' => $linkedName,
230
+ 'label' => $label,
231
+ 'fields' => $fields,
232
+ )));
233
  }
234
 
235
  /**
236
+ * Create field inside given database.
237
+ * @param string the name of the database that will be used
238
+ * @param string the name of the field
239
+ * @param string the magento field
240
  */
241
+ private function createDatabaseField($databaseName, $fieldName, $magentoField)
242
  {
243
+ // get api builder
244
+ $builder = Mage::helper('marketingsoftware/ApiBuilder');
 
 
 
 
 
 
245
 
246
+ // check what kind of field we want to create
247
+ switch ($magentoField)
248
  {
249
+ case 'email':
250
+ $builder->createDatabaseEmailField($databaseName, $fieldName);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
251
  break;
252
+ case 'newsletter' :
253
+ $builder->createDatabaseNewsletterField($databaseName, $fieldName);
254
  break;
255
+ case 'birthdate' :
256
+ $builder->createDatabaseDateField($databaseName, $fieldName);
257
  break;
258
+ case 'storeView':
259
+ $builder->createDatabaseField($databaseName, $fieldName, array( 'length' => 100 ));
260
  break;
261
+ case 'registrationDate' :
262
+ $builder->createDatabaseDatetimeField($databaseName, $fieldName);
263
  break;
264
  default:
265
+ $builder->createDatabaseField($databaseName, $fieldName);
266
  break;
267
  }
 
 
 
 
 
 
268
  }
269
 
270
  /**
271
+ * This ajax call can be used to store information about certain collection
272
  */
273
+ public function storeAction()
274
  {
275
+ // get post data
276
  $post = $this->getRequest()->getPost();
277
 
278
+ // get builder and config
279
+ $builder = Mage::helper('marketingsoftware/ApiBuilder');
280
+ $config = Mage::helper('marketingsoftware/Config');
281
 
282
+ // what collection we are doing?
283
+ switch ($post['type'])
284
+ {
285
+ // are we making 'main' (database) collection?
286
+ case 'main':
287
+ // create database
288
+ $builder->createDatabase($post['name']);
289
 
290
+ // save database name
291
+ $config->setDatabaseName($post['name']);
 
 
 
 
 
292
 
293
+ // fields that we are linking
294
+ $fields = array();
295
 
296
+ // iterate over fields and create proper fields
297
+ foreach ($post['fields'] as $field)
298
+ {
299
+ // get magneto and copernica name
300
+ list($magento, $copernica) = explode(',', $field);
 
 
301
 
302
+ // insert next field
303
+ $fields[$magento] = $copernica;
 
304
 
305
+ // create database field
306
+ $this->createDatabaseField($post['name'], $copernica, $magento);
307
+ }
 
 
 
 
308
 
309
+ // store linked fields
310
+ $config->setLinkedCustomerFields($fields);
 
311
 
312
+ break;
 
 
 
 
 
 
313
 
314
+ // are we dealing with normal collection
315
+ default:
316
+ // create collection
317
+ $databaseName = Mage::helper('marketingsoftware/config')->getDatabaseName();
318
+ $builder->createCollection($databaseName, $post['name'], $post['type']);
319
+
320
+ // placeholder for fields
321
+ $fields = array();
322
+
323
+ // iterate over fields and create proper ones
324
+ foreach ($post['fields'] as $field)
325
+ {
326
+ // get magento and copernica name
327
+ list($magento, $copernica) = explode(',', $field);
328
+
329
+ // assign field linking
330
+ $fields[$magento] = $copernica;
331
+
332
+ // create field
333
+ $builder->createCollectionField($databaseName, $post['name'], $post['type'], $copernica, $magento);
334
+ }
335
+
336
+ switch ($post['type'])
337
+ {
338
+ case 'orders':
339
+ $config->setOrdersCollectionName($post['name']);
340
+ $config->setLinkedOrderFields($fields);
341
+ break;
342
+ case 'orderproducts':
343
+ $config->setOrderItemsCollectionName($post['name']);
344
+ $config->setLinkedOrderItemFields($fields);
345
+ break;
346
+ case 'addresses':
347
+ $config->setAddressesCollectionName($post['name']);
348
+ $config->setLinkedAddressFields($fields);
349
+ break;
350
+ case 'viewedproducts':
351
+ $config->setViewedProductCollectionName($post['name']);
352
+ $config->setLinkedViewedProductFields($fields);
353
+ break;
354
+ case 'cartproducts':
355
+ $config->setCartItemsCollectionName($post['name']);
356
+ $config->setLinkedCartItemFields($fields);
357
+ break;
358
+ }
359
+
360
+ break;
361
  }
362
  }
363
 
364
  /**
365
+ * Make default structure.
 
 
 
366
  */
367
+ public function defaultAction()
368
  {
369
+ // assign database name
370
+ $databaseName = 'Magento';
 
371
 
372
+ // get builder
373
+ $builder = Mage::helper('marketingsoftware/ApiBuilder');
374
+ $config = Mage::helper('marketingsoftware/config');
375
+ $data = Mage::helper('marketingsoftware/data');
 
 
 
 
 
 
 
376
 
377
+ // create database
378
+ $builder->createDatabase($databaseName);
379
+ $config->setDatabaseName($databaseName);
 
 
 
 
380
 
381
+ /*
382
+ * Create database fields
383
+ */
384
+ $supportedFields = $data->supportedCustomerFields();
385
+ $linkedFields = array();
386
+ foreach ($supportedFields as $name => $label)
387
+ {
388
+ $this->createDatabaseField($databaseName, $name, $name);
389
+ $linkedFields[$name] = $name;
390
+ }
391
+ $config->setLinkedCustomerFields($linkedFields);
392
 
393
+ /*
394
+ * Create cart items collection
395
+ */
396
+ $builder->createCollection($databaseName, 'Cart_Items' ,'cartproducts');
397
+ $config->setCartItemsCollectionName('Cart_Items');
398
+ $supportedFields = $data->supportedCartItemFields();
399
+ $linkedFields = array();
400
+ foreach ($supportedFields as $name => $label)
401
+ {
402
+ $builder->createCollectionField($databaseName, 'Cart_Items', 'cartproducts', $name, $name);
403
+ $linkedFields[$name] = $name;
404
+ }
405
+ $config->setLinkedCartItemFields($linkedFields);
406
 
407
+ /*
408
+ * Orders collection
409
+ */
410
+ $builder->createCollection($databaseName, 'Orders' ,'orders');
411
+ $config->setOrdersCollectionName('Orders');
412
+ $supportedFields = $data->supportedOrderFields();
413
+ $linkedFields = array();
414
+ foreach ($supportedFields as $name => $label)
415
+ {
416
+ $builder->createCollectionField($databaseName, 'Orders', 'orders', $name, $name);
417
+ $linkedFields[$name] = $name;
418
+ }
419
+ $config->setLinkedOrderFields($linkedFields);
420
+
421
+ /*
422
+ * Orders items collection
423
+ */
424
+ $builder->createCollection($databaseName, 'Orders_Items' ,'orderproducts');
425
+ $config->setOrderItemsCollectionName('Orders_Items');
426
+ $supportedFields = $data->supportedOrderItemFields();
427
+ $linkedFields = array();
428
+ foreach ($supportedFields as $name => $label)
429
+ {
430
+ $builder->createCollectionField($databaseName, 'Orders_Items', 'orderproducts', $name, $name);
431
+ $linkedFields[$name] = $name;
432
+ }
433
+ $config->setLinkedOrderItemFields($linkedFields);
434
+
435
+ /*
436
+ * Addresses collection
437
+ */
438
+ $builder->createCollection($databaseName, 'Addresses' ,'addresses');
439
+ $config->setAddressesCollectionName('Addresses');
440
+ $supportedFields = $data->supportedAddressFields();
441
+ $linkedFields = array();
442
+ foreach ($supportedFields as $name => $label)
443
+ {
444
+ $builder->createCollectionField($databaseName, 'Addresses', 'addresses', $name, $name);
445
+ $linkedFields[$name] = $name;
446
+ }
447
+ $config->setLinkedAddressFields($linkedFields);
448
+
449
+ /*
450
+ * Viewed products collection
451
+ */
452
+ $builder->createCollection($databaseName, 'Viewed_Products' ,'viewedproducts');
453
+ $config->setViewedProductCollectionName('Viewed_Products');
454
+ $supportedFields = $data->supportedViewedProductFields();
455
+ $linkedFields = array();
456
+ foreach ($supportedFields as $name => $label)
457
+ {
458
+ $builder->createCollectionField($databaseName, 'Viewed_Products', 'viewedproducts', $name, $name);
459
+ $linkedFields[$name] = $name;
460
+ }
461
+ $config->setLinkedViewedProductFields($linkedFields);
462
  }
463
  }
app/code/community/Copernica/MarketingSoftware/controllers/Adminhtml/Marketingsoftware/AjaxcollectionfieldController.php DELETED
@@ -1,167 +0,0 @@
1
- <?php
2
- /**
3
- * Copernica Marketing Software
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0).
8
- * It is available through the world-wide-web at this URL:
9
- * http://opensource.org/licenses/osl-3.0.php
10
- * If you are unable to obtain a copy of the license through the
11
- * world-wide-web, please send an email to copernica@support.cream.nl
12
- * so we can send you a copy immediately.
13
- *
14
- * DISCLAIMER
15
- *
16
- * Do not edit or add to this file if you wish to upgrade this software
17
- * to newer versions in the future. If you wish to customize this module
18
- * for your needs please refer to http://www.magento.com/ for more
19
- * information.
20
- *
21
- * @category Copernica
22
- * @package Copernica_MarketingSoftware
23
- * @copyright Copyright (c) 2011-2012 Copernica & Cream. (http://docs.cream.nl/)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
-
27
- class Copernica_MarketingSoftware_Adminhtml_Marketingsoftware_AjaxcollectionfieldController extends Mage_Adminhtml_Controller_Action
28
- {
29
- /**
30
- * Validata collection field
31
- */
32
- public function validateAction()
33
- {
34
- // get Post variables
35
- $post = $this->getRequest()->getPost();
36
-
37
- try
38
- {
39
- // check if all required parameters are in place
40
- if (!isset($post['databaseName']) || !isset($post['collectionName']) || !isset($post['collectionType']) || !isset($post['copernicaName']) || !isset($post['magentoName']))
41
- throw Mage::exception('Copernica_MarketingSoftware', 'Invalid input', Copernica_MarketingSoftware_Exception::INVALID_INPUT);
42
-
43
- // validate field
44
- Mage::helper('marketingsoftware/ApiValidator')->validateCollectionField($post['databaseName'], $post['collectionName'], $post['collectionType'], $post['magentoName'], $post['copernicaName']);
45
-
46
- // if we are here that means field is valid
47
- $this->setResponse('Field valid');
48
- }
49
- /**
50
- * All errors from validation will be reported as exceptions. We will
51
- * just take care of them here.
52
- */
53
- catch (Copernica_MarketingSoftware_Exception $copernicaException)
54
- {
55
- // check if we have a fix for error
56
- switch ($copernicaException->getCode())
57
- {
58
- case Copernica_MarketingSoftware_Exception::FIELD_NOT_EXISTS:
59
- $fix = 'create';
60
- break;
61
- case Copernica_MarketingSoftware_Exception::DATABASE_NOT_EXISTS:
62
- $fix = 'Create database';
63
- break;
64
- default:
65
- $fix = '';
66
- }
67
-
68
- // set response
69
- $this->setResponse($copernicaException->getMessage(), true, $fix);
70
-
71
- // we are done with this function
72
- return;
73
- }
74
- /**
75
- * General exception should not happen, but just to be sure we will
76
- * handle them here. We want to present a proper response to user.
77
- */
78
- catch (Exception $exception)
79
- {
80
- // tell magento to log exception
81
- Mage::logException($exception);
82
-
83
- // set response
84
- $this->setResponse('Critical error. Check error logs for more info', true);
85
- }
86
- }
87
-
88
- /**
89
- * Create collection field
90
- */
91
- public function createAction()
92
- {
93
- // createCollectionField($databaseName, $collectionName, $collectionType, $copernicaName, $magentoName)
94
-
95
- $post = $this->getRequest()->getPost();
96
-
97
- try {
98
- // check if we have all required data
99
- if (!isset($post['databaseName']) || !isset($post['collectionName']) || !isset($post['collectionType']) || !isset($post['copernicaName']) || !isset($post['magentoName']))
100
- throw Mage::exception('Copernica_MarketingSoftware', 'Invalid input', Copernica_MarketingSoftware_Exception::INVALID_INPUT);
101
-
102
- // create field
103
- Mage::helper('marketingsoftware/ApiBuilder')->createCollectionField($post['databaseName'], $post['collectionName'], $post['collectionType'], $post['copernicaName'], $post['magentoName']);
104
-
105
- // set success message
106
- $this->setResponse('Field was created');
107
- }
108
- /**
109
- * All errors from creation will be reported as customer exception.
110
- * We can handle all errors here.
111
- */
112
- catch (Copernica_MarketingSoftware_Exception $copernicaException)
113
- {
114
- // set response
115
- $this->setResponse($copernicaException->getMessage(), true);
116
-
117
- // we are done with this function
118
- return;
119
- }
120
- /**
121
- * General exceptions should not happen, but we want to be safe. We will
122
- * catch them here and tell user that critical one occured.
123
- */
124
- catch (Exception $exception)
125
- {
126
- // tell magento to log exception
127
- Mage::logException($exception);
128
-
129
- // set nice response
130
- $this->setResponse('Critical error. Check error logs for more info', true);
131
- }
132
- }
133
-
134
- /**
135
- * Prepare response objrect to be used with AJAX
136
- */
137
- private function prepareAjaxResponse()
138
- {
139
- // get response instance
140
- $response = $this->getResponse();
141
-
142
- // clear current response body
143
- $response->clearBody();
144
-
145
- // all Ajax responses are encoded in JSON
146
- $response->setHeader('Content-Type', 'application/json');
147
- }
148
-
149
- /**
150
- * Set ajax response.
151
- * @param string the message for user
152
- * @param bool is it an error?
153
- * @param string the fix for error
154
- */
155
- private function setResponse($message, $error = false, $fix = '')
156
- {
157
- // prepare response to be used along ajax
158
- $this->prepareAjaxResponse();
159
-
160
- // set response body
161
- $this->getResponse()->setBody(json_encode(array(
162
- 'message' => $message,
163
- 'error' => $error ? 1 : 0,
164
- 'fix' => ucfirst($fix)
165
- )));
166
- }
167
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Copernica/MarketingSoftware/controllers/Adminhtml/Marketingsoftware/AjaxdatabaseController.php DELETED
@@ -1,271 +0,0 @@
1
- <?php
2
- /**
3
- * Copernica Marketing Software
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0).
8
- * It is available through the world-wide-web at this URL:
9
- * http://opensource.org/licenses/osl-3.0.php
10
- * If you are unable to obtain a copy of the license through the
11
- * world-wide-web, please send an email to copernica@support.cream.nl
12
- * so we can send you a copy immediately.
13
- *
14
- * DISCLAIMER
15
- *
16
- * Do not edit or add to this file if you wish to upgrade this software
17
- * to newer versions in the future. If you wish to customize this module
18
- * for your needs please refer to http://www.magento.com/ for more
19
- * information.
20
- *
21
- * @category Copernica
22
- * @package Copernica_MarketingSoftware
23
- * @copyright Copyright (c) 2011-2012 Copernica & Cream. (http://docs.cream.nl/)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
-
27
- /**
28
- * This class will answer any Ajax call that is asking info about Copernica
29
- * database.
30
- */
31
- class Copernica_MarketingSoftware_Adminhtml_Marketingsoftware_AjaxdatabaseController extends Mage_Adminhtml_Controller_Action
32
- {
33
- /**
34
- * This action should be called when we want to get current info about certain
35
- * magento field that we can sync with copernica's customer.
36
- *
37
- * This function does not return any value. Instead it does modify respone
38
- * instance. Response instance will hold all relevant data that we will
39
- * pass to browser.
40
- */
41
- public function fetchFieldAction()
42
- {
43
- // get post variables
44
- $post = $this->getRequest()->getPost();
45
-
46
- // check if we have a name for field
47
- if (!isset($post['name']))
48
- {
49
- // just notify user about error
50
- $this->setResponse('Invalid input', true);
51
-
52
- // we are done here
53
- return;
54
- }
55
-
56
- // get linked fields
57
- $customerFields = Mage::helper('marketingsoftware/config')->getLinkedCustomerFields();
58
-
59
- // check if we have gived field name in linked ones
60
- if (!array_key_exists($post['name'], $customerFields) || strlen($customerFields[$post['name']]) == 0)
61
- {
62
- // it's not really an error, so just notify
63
- $this->setResponse('Field not linked');
64
-
65
- // we are done here
66
- return;
67
- }
68
-
69
- // we have a field, so we can return it's data to user
70
- $this->setFieldResponse('Field is valid', array(
71
- 'magentoName' => $post['name'],
72
- 'copernicaName' => $customerFields[$post['name']]
73
- ));
74
- }
75
-
76
- /**
77
- * Set response to provide data about database field
78
- * @param string message about the field
79
- * @param array field data
80
- * @param bool do we have an error?
81
- * @param string do we have a fix for error?
82
- */
83
- private function setFieldResponse($message, $fieldData, $error = false, $fix = '')
84
- {
85
- // prepare response for ajax
86
- $this->prepareAjaxResponse();
87
-
88
- // set response data
89
- $this->getResponse()->setBody(json_encode(Array(
90
- 'message' => $message,
91
- 'error' => $error ? 1 : 0,
92
- 'fix' => ucfirst($fix),
93
- 'data' => $fieldData
94
- )));
95
- }
96
-
97
- /**
98
- * This action should be called when Ajax is asking to validate database.
99
- *
100
- * This function does not return any value. Instead it does modify respone
101
- * instance. Response instance will hold all relevant data that we will
102
- * pass to browser.
103
- */
104
- public function validateAction()
105
- {
106
- // get post variables
107
- $post = $this->getRequest()->getPost();
108
-
109
- // errors will be reported as exceptions
110
- try
111
- {
112
- // check if we have proper input
113
- if (!isset($post['name'])) throw Mage::exception('Copernica_MarketingSoftware', 'Missing input', Copernica_MarketingSoftware_Exception::INVALID_INPUT);
114
-
115
- // validate database by it's name
116
- $this->validateDatabase($post['name']);
117
-
118
- // at this point we should be just dandy
119
- $this->setResponse('Database is valid');
120
- }
121
- /*
122
- * Any relevant for us erros should be thrown an custom exception. We
123
- * can handle them here.
124
- */
125
- catch (Copernica_MarketingSoftware_Exception $copernicaException)
126
- {
127
- // check if we have a simple fix
128
- switch ($copernicaException->getCode())
129
- {
130
- case Copernica_MarketingSoftware_Exception::DATABASE_NOT_EXISTS:
131
- $fix = 'create';
132
- break;
133
- case Copernica_MarketingSoftware_Exception::API_ERROR:
134
- $fix = 'Fix account';
135
- break;
136
- default:
137
- $fix = '';
138
- }
139
-
140
- // set the response
141
- $this->setResponse($copernicaException->getMessage(), true, $fix);
142
- }
143
- /*
144
- * We don't really expect general exceptions here, but better be safe
145
- * than sorry. We will handle general exception, but we will tell
146
- * magento to log them and just move along.
147
- */
148
- catch (Exception $exception)
149
- {
150
- // tell magento to log the exception
151
- Mage::logException($exception);
152
-
153
- // tell user that we have a critical error. Admin can check error
154
- // logs to get more info what just happend
155
- $this->setResponse('Critical error. Check error log', true);
156
- }
157
- }
158
-
159
- /**
160
- * Validate database
161
- * @param string the name of the database that will be validated
162
- * @throws Copernica_MarketingSoftware_Exception
163
- */
164
- private function validateDatabase($databaseName)
165
- {
166
- Mage::helper('marketingsoftware/ApiValidator')->validateDatabase($databaseName);
167
- }
168
-
169
- /**
170
- * This action should be called when we Ajax is asking for repair.
171
- *
172
- * This function does not return any value. Instead it does modify respone
173
- * instance. Response instance will hold all relevant data that we will
174
- * pass to browser.
175
- */
176
- public function createAction()
177
- {
178
- // get post variables
179
- $post = $this->getRequest()->getPost();
180
-
181
- // errors will be reported as exceptions, so we want to handle them here
182
- try
183
- {
184
- // check if we have database name
185
- if(!isset($post['name'])) throw Mage::exception('Copernica_MarketingSoftware', 'Missing input', Copernica_MarketingSoftware_Exception::INVALID_INPUT);
186
-
187
- // create database
188
- $this->createDatabase($post['name']);
189
-
190
- // we should be good here
191
- $this->setResponse('Database created');
192
- }
193
- /*
194
- * Any relevant for us erros should be thrown an custom exception. We
195
- * can handle them here.
196
- */
197
- catch (Copernica_MarketingSoftware_Exception $copernicaException)
198
- {
199
- // check if we can repair this situation
200
- switch ($copernicaException->getCode())
201
- {
202
- case Copernica_MarketingSoftware_Exception::API_ERROR:
203
- $fix = 'Fix account';
204
- break;
205
- default:
206
- $fix = '';
207
- }
208
-
209
- // set sesponse for browser
210
- $this->setResponse($copernicaException->getMessage(), true, $fix);
211
- }
212
- /*
213
- * We don't really expect general exceptions here, but better be safe
214
- * than sorry. We will handle general exception, but we will tell
215
- * magento to log them and just move along.
216
- */
217
- catch (Exception $exception)
218
- {
219
- // tell magento to log exception
220
- Mage::logException($exception);
221
-
222
- // tell user that we have a critical error.
223
- $this->setResponse('Critical error. Check error log.', true);
224
- }
225
- }
226
-
227
- /**
228
- * Tell Api to create a database
229
- * @param string the database name that will be used
230
- */
231
- private function createDatabase($databaseName)
232
- {
233
- Mage::helper('marketingsoftware/ApiBuilder')->createDatabase($databaseName);
234
- }
235
-
236
- /**
237
- * Set response that we will sent to browser.
238
- * Note that this method will SET response. It will override/discard all
239
- * previous changes and will build up response from scratch.
240
- * @param string message to show
241
- * @param bool did we have an error?
242
- * @param string fix type for error
243
- */
244
- private function setResponse($message, $error = false, $fix = '')
245
- {
246
- // prepare response for ajax
247
- $this->prepareAjaxResponse();
248
-
249
- // set response data
250
- $this->getResponse()->setBody(json_encode(Array(
251
- 'message' => $message,
252
- 'error' => $error ? 1 : 0,
253
- 'fix' => ucfirst($fix)
254
- )));
255
- }
256
-
257
- /**
258
- * This method will prepare Ajax response
259
- */
260
- private function prepareAjaxResponse()
261
- {
262
- // get the response
263
- $response = $this->getResponse();
264
-
265
- // clear response body
266
- $response->clearBody();
267
-
268
- // all Ajax responses are encoded in JSON
269
- $response->setHeader('Content-Type', 'application/json');
270
- }
271
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Copernica/MarketingSoftware/controllers/Adminhtml/Marketingsoftware/AjaxdatabasefieldController.php DELETED
@@ -1,192 +0,0 @@
1
- <?php
2
- /**
3
- * Copernica Marketing Software
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0).
8
- * It is available through the world-wide-web at this URL:
9
- * http://opensource.org/licenses/osl-3.0.php
10
- * If you are unable to obtain a copy of the license through the
11
- * world-wide-web, please send an email to copernica@support.cream.nl
12
- * so we can send you a copy immediately.
13
- *
14
- * DISCLAIMER
15
- *
16
- * Do not edit or add to this file if you wish to upgrade this software
17
- * to newer versions in the future. If you wish to customize this module
18
- * for your needs please refer to http://www.magento.com/ for more
19
- * information.
20
- *
21
- * @category Copernica
22
- * @package Copernica_MarketingSoftware
23
- * @copyright Copyright (c) 2011-2012 Copernica & Cream. (http://docs.cream.nl/)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
-
27
- class Copernica_MarketingSoftware_Adminhtml_Marketingsoftware_AjaxdatabasefieldController extends Mage_Adminhtml_Controller_Action
28
- {
29
- /**
30
- * This action should be called when we want to validate database field
31
- */
32
- public function validateAction()
33
- {
34
- // get POST variables
35
- $post = $this->getRequest()->getPost();
36
-
37
- try
38
- {
39
- // if we don't have database name or field name, we can not validate
40
- if (!isset($post['databaseName']) || !isset($post['fieldName']) || !isset($post['magentoField'])) throw Mage::exception('Copernica_MarketingSoftware', 'Invalid input', Copernica_MarketingSoftware_Exception::INVALID_INPUT);
41
-
42
- // validate field
43
- $this->validateField($post['databaseName'], $post['fieldName'], $post['magentoField']);
44
-
45
- // field should be valid
46
- $this->setResponse('Field is valid');
47
- }
48
- /*
49
- * Any error during validation will be thrown as exception. We can handle
50
- * them here.
51
- */
52
- catch (Copernica_MarketingSoftware_Exception $copernicaException)
53
- {
54
- // check if can fix the current problem with field
55
- switch ($copernicaException->getCode())
56
- {
57
- case Copernica_MarketingSoftware_Exception::FIELD_NOT_EXISTS:
58
- $fix = 'create';
59
- break;
60
- case Copernica_MarketingSoftware_Exception::DATABASE_NOT_EXISTS:
61
- $fix = 'Create database';
62
- break;
63
- default:
64
- $fix = '';
65
- }
66
-
67
- // tell user what is wrong
68
- $this->setResponse($copernicaException->getMessage(), true, $fix);
69
- }
70
- /**
71
- * We don't really expect any general errors here, but just in case
72
- * we want to catch them and tell magento to log them
73
- */
74
- catch (Exception $exception)
75
- {
76
- // tell magento to log exception
77
- Mage::logException($exception);
78
-
79
- // we have an error
80
- $this->setResponse('Critical error. Check logs for more information.', true);
81
- }
82
- }
83
-
84
- /**
85
- * Validata field
86
- * @param string database name
87
- * @param string field name
88
- * @param string magento field name
89
- */
90
- private function validateField($databaseName, $fieldName, $magentoField)
91
- {
92
- Mage::helper('marketingsoftware/ApiValidator')->validateDatabaseField($databaseName, $fieldName, $magentoField);
93
- }
94
-
95
- /**
96
- * This action should be called when we want to create database field
97
- */
98
- public function createAction()
99
- {
100
- // get POST variables
101
- $post = $this->getRequest()->getPost();
102
-
103
- try
104
- {
105
- // check if we have required input
106
- if (!isset($post['databaseName']) || !isset($post['fieldName']) || !isset($post['magentoField'])) throw Mage::exception('Copernica_MarketingSoftware', 'Invalid input', Copernica_MarketingSoftware_Exception::INVALID_INPUT);
107
-
108
- // create field
109
- $this->createField($post['databaseName'], $post['fieldName'], $post['magentoField']);
110
-
111
- // set the response
112
- $this->setResponse('Field was created');
113
- }
114
- /**
115
- * All errors will be returned as exceptions. We can handle them here
116
- */
117
- catch (Copernica_MarketingSoftware_Exception $copernicaException)
118
- {
119
- $this->setResponse($copernicaException->getMessage(), true);
120
- }
121
- /**
122
- * Just to be safe we want to handle all general exceptions here. We
123
- * will just tell magento to log them and notify user that we did encounter
124
- * a critical error
125
- */
126
- catch (Exception $exception)
127
- {
128
- // tell magento to log exception
129
- Mage::logException($exception);
130
-
131
- // notify user that we did encounted a critical error
132
- $this->setResponse('Critical error. Check logs for more information', true);
133
- }
134
- }
135
-
136
- /**
137
- * Create field inside given database.
138
- * @param string the name of the database that will be used
139
- * @param string the name of the field
140
- * @param string the magento field
141
- */
142
- private function createField($databaseName, $fieldName, $magentoField)
143
- {
144
- // check what kind of field we want to create
145
- switch ($magentoField)
146
- {
147
- case 'email': Mage::helper('marketingsoftware/ApiBuilder')->createDatabaseEmailField($databaseName, $fieldName);
148
- break;
149
- case 'newsletter' : Mage::helper('marketingsoftware/ApiBuilder')->createDatabaseNewsletterField($databaseName, $fieldName);
150
- break;
151
- case 'birthdate' : Mage::helper('marketingsoftware/ApiBuilder')->createDatabaseDateField($databaseName, $fieldName);
152
- break;
153
- case 'storeView': Mage::helper('marketingsoftware/ApiBuilder')->createDatabaseField($databaseName, $fieldName, array( 'length' => 100 ));
154
- break;
155
- case 'registrationDate' : Mage::helper('marketingsoftware/ApiBuilder')->createDatabaseDatetimeField($databaseName, $fieldName);
156
- break;
157
- default: Mage::helper('marketingsoftware/ApiBuilder')->createDatabaseField($databaseName, $fieldName);
158
- break;
159
- }
160
- }
161
-
162
- /**
163
- * Helper method to prepare response for Ajax
164
- */
165
- private function prepareAjaxResponse()
166
- {
167
- // get response instance
168
- $response = $this->getResponse();
169
-
170
- // clear response body
171
- $response->clearBody();
172
-
173
- // all AJAX responsens should be json encoded
174
- $response->setHeader('Content-Type', 'application/json');
175
- }
176
-
177
- /**
178
- * Helper method to set response
179
- */
180
- private function setResponse($message, $error = false, $fix = '')
181
- {
182
- // prepare response for AJAX
183
- $this->prepareAjaxResponse();
184
-
185
- // set response body
186
- $this->getResponse()->setBody(json_encode(Array (
187
- 'message' => $message,
188
- 'error' => $error ? 1 : 0,
189
- 'fix' => ucfirst($fix)
190
- )));
191
- }
192
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Copernica/MarketingSoftware/controllers/Adminhtml/Marketingsoftware/SettingsController.php CHANGED
@@ -97,7 +97,7 @@ class Copernica_MarketingSoftware_Adminhtml_Marketingsoftware_SettingsController
97
  if ($accessToken === false)
98
  {
99
  // store error message as json inside session
100
- Mage::getSingleton('core/session')->setErrorMessage(json_encode($output['error']));
101
 
102
  // well, we have an error and we have to tell the user that we have an
103
  // error
@@ -195,12 +195,21 @@ class Copernica_MarketingSoftware_Adminhtml_Marketingsoftware_SettingsController
195
  // get all post values from the request
196
  $post = $this->getRequest()->getPost();
197
 
198
- // check if we have a client key
199
- if (!isset($post['cp_client_key'])) return $this->_redirect('*/*');
200
-
201
  // get config to local scope
202
  $config = Mage::helper('marketingsoftware/config');
203
 
 
 
 
 
 
 
 
 
 
 
 
 
204
  // set client key inside config file
205
  $config->setClientKey($post['cp_client_key']);
206
 
97
  if ($accessToken === false)
98
  {
99
  // store error message as json inside session
100
+ Mage::getSingleton('core/session')->setErrorMessage(json_encode($output['error']['message']));
101
 
102
  // well, we have an error and we have to tell the user that we have an
103
  // error
195
  // get all post values from the request
196
  $post = $this->getRequest()->getPost();
197
 
 
 
 
198
  // get config to local scope
199
  $config = Mage::helper('marketingsoftware/config');
200
 
201
+ // get current client key
202
+ $clientKey = $config->getClientKey();
203
+
204
+ // get current client secret
205
+ $clientSecret = $config->getClientSecret();
206
+
207
+ // if client key and secret does not change there is no point in doing anything
208
+ if ($clientKey == $post['cp_client_key'] && $clientSecret == $post['cp_client_secret']) return $this->_redirect('*/*');
209
+
210
+ // check if we have a client key
211
+ if (!isset($post['cp_client_key'])) return $this->_redirect('*/*');
212
+
213
  // set client key inside config file
214
  $config->setClientKey($post['cp_client_key']);
215
 
app/code/community/Copernica/MarketingSoftware/etc/config.xml CHANGED
@@ -2,7 +2,7 @@
2
  <config>
3
  <modules>
4
  <Copernica_MarketingSoftware>
5
- <version>3.0.0</version>
6
  </Copernica_MarketingSoftware>
7
  </modules>
8
  <global>
2
  <config>
3
  <modules>
4
  <Copernica_MarketingSoftware>
5
+ <version>3.0.1</version>
6
  </Copernica_MarketingSoftware>
7
  </modules>
8
  <global>
app/design/adminhtml/default/default/template/marketingsoftware/link.phtml CHANGED
@@ -1,215 +1,98 @@
1
  <?php
2
  /**
3
- * View for Link controller
4
- * Copernica Marketing Software v 1.2.0
5
- * March 2011
6
- * http://www.copernica.com/
7
  */
8
- $_helper = Mage::helper('marketingsoftware');
9
- $_config = Mage::helper('marketingsoftware/config');
10
-
11
- // collection names with title
12
- $collections = array(
13
- array('name' => 'cartproducts', 'title' => 'Cart items collection'),
14
- array('name' => 'orders', 'title' => 'Orders collection'),
15
- array('name' => 'orderproducts', 'title' => 'Order products collection'),
16
- array('name' => 'addresses', 'title' => 'Address collection'),
17
- array('name' => 'viewedproduct', 'title' => 'Viewed product collection'),
18
- );
19
-
20
- // get current controller
21
- $currentController = $this->getAction();
22
-
23
  ?>
24
 
25
  <div class="content-header">
26
  <h3 class="icon-head head-system-account">Copernica Marketing Software : Link Fields</h3>
27
  <p class="content-buttons">
 
28
  <button type="button" id="save">Save</button>
29
  </p>
30
  </div>
31
 
32
- <!-- Start of status box -->
33
- <?php if (count($currentController->getErrors()) or count($currentController->getWarnings())) { ?>
34
- <div class="entry-edit">
35
- <div class="entry-edit-head collapsable">
36
- <h4>Current status</h4>
37
- </div>
38
- <div class="fieldset collapsable">
39
- <ul>
40
- <?php foreach ($currentController->getErrors() as $error) { ?>
41
- <li><?php echo $error ?></li>
42
- <?php } ?>
43
- <?php foreach ($currentController->getWarnings() as $warning) { ?>
44
- <li><?php echo $warning ?></li>
45
- <?php } ?>
46
- </ul>
47
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
  </div>
49
- <?php } ?>
50
- <!-- End of status box -->
51
-
52
- <div class="entry-edit">
53
-
54
- <!-- fields linking form. -->
55
- <form action="<?php echo $this->getPostUrl(); ?>" method="post" name="cp_profile_collection" id="cp_profile_collection">
56
- <?php echo $this->getBlockHtml('formkey'); ?>
57
-
58
- <!-- database checker section. -->
59
- <div class="entry-edit-head">
60
- <h4 class="icon-head head-edit-form fieldset-legend">Database</h4>
61
- <a href="#" onclick ="document.getElementById('database_help').style.display='block'; return false;" id="page-help-link" style="float: right; line-height:18px;">More information</a>
62
- </div>
63
- <div class="fieldset">
64
- <div class="hor-scroll">
65
- <table cellspacing="0" class="form-list">
66
- <tbody>
67
- <tr>
68
- <td class="value">Name</td>
69
- <td class="value">Status</td>
70
- </tr>
71
- <tr>
72
- <td class="value">
73
- <input type="text" class="input-text" value="<?php echo(htmlspecialchars($_config->getDatabaseName())); ?>" name="db_input" id="db_input"/>
74
- </td>
75
- <td class="value">
76
- <span style="display:none;" id="db_check_result"></span>
77
- <b style="display:none;" id="db_check_repair"></b>
78
- </td>
79
- </tr>
80
- </tbody>
81
- </table>
82
- </div>
83
- </div>
84
- <!-- end of database checker section. -->
85
 
86
- <!-- first section: customer profiles. -->
87
- <div class="entry-edit-head">
88
- <h4 class="icon-head head-edit-form fieldset-legend" id="customers_profiles_label" name="customers_profiles_label">Customers Profiles</h4>
89
- <a href="#" onclick ="document.getElementById('profiles_help').style.display='block'; return false;" id="page-help-link" style="float: right; line-height:18px;">More information</a>
90
- </div>
91
-
92
- <div class="fieldset">
93
- <div class="hor-scroll">
94
- <table cellspacing="0" class="form-list">
95
- <tbody id ="customer_fields">
96
- <tr>
97
- <td class="value">Magento field</td>
98
- <td class="value">Copernica field</td>
99
- <td class="value">Status</td>
100
- </tr>
101
- <?php foreach ($_helper->supportedCustomerFields() as $field => $label) { ?>
102
- <tr class="customer_field">
103
- <td class="value magento-field">
104
- <input type="text" disabled="disabled" class="input-text disabled magento-field-label" value="<?php echo $label;?>">
105
- <input type="hidden" disabled="disabled" class="magento-field-system" value="<?php echo $field; ?>">
106
- </td>
107
- <td class="value copernica-field"></td>
108
- <td class="value field-status"></td>
109
- </tr>
110
- <?php } ?>
111
- </tbody>
112
- </table>
113
- </div>
114
- </div>
115
- <!-- end of first section. -->
116
-
117
- <?php foreach($collections as $collection) { ?>
118
- <div class="collection">
119
- <input type="hidden" name="collection" value="<?php echo $collection['name']; ?>">
120
- <div class="entry-edit-head">
121
- <h4 class="icon-head head-edit-form fieldset-legend">
122
- <?php echo $collection['title']; ?>
123
- </h4>
124
- </div>
125
- <div class="fieldset collection-container collection-<?php echo $collection['name']; ?>">
126
- <div class="hor-scroll">
127
- <table cellspacing="0" class="form-list">
128
- <tbody>
129
- <tr>
130
- <td class="value">
131
- Collection name
132
- </td>
133
- </tr>
134
- <tr>
135
- <td class="value field-name">
136
- <input type="text" class="input-text" title="<?php echo $collection['title']; ?>">
137
- </td>
138
- <td class="value field-status">
139
- </td>
140
- </tr>
141
- </tbody>
142
- </table>
143
- </div>
144
- </div>
145
- <div class="fieldset collection-fields collection-<?php echo $collection['name']; ?>">
146
- <div class="hor-scroll">
147
- <table cellspacing="0" class="form-list">
148
- <tbody>
149
- <tr>
150
- <td class="value">
151
- Magento field
152
- </td>
153
- <td class="value">
154
- Copernica field
155
- </td>
156
- <td class="value">
157
- Status
158
- </td>
159
- </tr>
160
- <?php foreach ($this->getSupportedCollectionFields($collection['name']) as $name => $label) { ?>
161
- <tr class="field">
162
- <td class="value field-magento">
163
- <input type="text" class="input-text disabled" value="<?php echo $label; ?>" disabled="disabled">
164
- <input type="hidden" value="<?php echo $name; ?>">
165
- </td>
166
- <td class="value field-copernica">
167
- </td>
168
- <td class="value field-status">
169
- </td>
170
- </tr>
171
- <?php } ?>
172
- </tbody>
173
- </table>
174
- </div>
175
- </div>
176
- </div>
177
- <?php } ?>
178
- </form>
179
  </div>
180
 
181
- <script type="text/javascript">
182
- // we want to be nice and use js namespacing trick
183
  var Copernica = Copernica || {};
184
 
185
  // We want to pass relevant ajax urls to js file. To do that we will create
186
  // a namespace object that will hold urls. This way we can still keep generating
187
  // urls in controller and actual usage will be in js file.
188
  Copernica.ajaxUrls = {
189
- save: '<?php echo $this->getSaveFormUrl(); ?>',
190
- database: {
191
- validate: '<?php echo $this->getAjaxDatabaseValidateUrl(); ?>',
192
- create: '<?php echo $this->getAjaxDatabaseCreateUrl(); ?>',
193
- fetch: '<?php echo $this->getAjaxDatabaseFetchUrl(); ?>'
194
- },
195
- databaseField: {
196
- validate: '<?php echo $this->getAjaxDatabaseFieldValidateUrl(); ?>',
197
- create: '<?php echo $this->getAjaxDatabaseFieldCreateUrl(); ?>'
198
- },
199
  collection: {
200
- validate: '<?php echo $this->getAjaxCollectionValidateUrl(); ?>',
201
- create: '<?php echo $this->getAjaxCollectionCreaetUrl(); ?>',
202
- info: '<?php echo $this->getAjaxCollectionInfoUrl(); ?>',
203
- fetch: '<?php echo $this->getAjaxCollectionFetchUrl(); ?>'
204
- },
205
- collectionField: {
206
- validate: '<?php echo $this->getAjaxCollectionFieldValidateUrl(); ?>',
207
- create: '<?php echo $this->getAjaxCollectionFieldCreateUrl(); ?>'
208
  }
209
  };
210
 
211
- Copernica.pageUrls = {
212
- accountSettings: '<?php echo $this->getAccountSettingsUrl(); ?>'
213
- }
214
-
215
- </script>
1
  <?php
2
  /**
3
+ * link.phtml
4
+ * Copernica Marketing Software
 
 
5
  */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  ?>
7
 
8
  <div class="content-header">
9
  <h3 class="icon-head head-system-account">Copernica Marketing Software : Link Fields</h3>
10
  <p class="content-buttons">
11
+ <button type="button" id="validate">Validate</button>
12
  <button type="button" id="save">Save</button>
13
  </p>
14
  </div>
15
 
16
+ <div id="linking-view" class="columns">
17
+ <div class="side-col">
18
+ <h3>
19
+ Copernica structure
20
+ </h3>
21
+ <ul id="collection_list" class="tabs">
22
+ <li data-target="main">
23
+ <a class="tab-item-link">
24
+ <span>
25
+ Database
26
+ </span>
27
+ </a>
28
+ </li>
29
+ <li data-target="cartproducts">
30
+ <a class="tab-item-link">
31
+ <span>
32
+ Cart items collection
33
+ </span>
34
+ </a>
35
+ </li>
36
+ <li data-target="orders">
37
+ <a class="tab-item-link">
38
+ <span>
39
+ Orders collection
40
+ </span>
41
+ </a>
42
+ </li>
43
+ <li data-target="orderproducts">
44
+ <a class="tab-item-link">
45
+ <span>
46
+ Order products collection
47
+ </span>
48
+ </a>
49
+ </li>
50
+ <li data-target="addresses">
51
+ <a class="tab-item-link">
52
+ <span>
53
+ Address collection
54
+ </span>
55
+ </a>
56
+ </li>
57
+ <li data-target="viewedproducts">
58
+ <a class="tab-item-link">
59
+ <span>
60
+ Viewed products collection
61
+ </span>
62
+ </a>
63
+ </li>
64
+ <li data-target="default">
65
+ <a class="tab-item-link">
66
+ <span>
67
+ Default structure
68
+ </span>
69
+ </a>
70
+ </li>
71
+ </ul>
72
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
73
 
74
+ <div id="collection_view" class="main-col">
75
+
76
+ </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
  </div>
78
 
79
+ <script>
80
+ // create Copernica namespace
81
  var Copernica = Copernica || {};
82
 
83
  // We want to pass relevant ajax urls to js file. To do that we will create
84
  // a namespace object that will hold urls. This way we can still keep generating
85
  // urls in controller and actual usage will be in js file.
86
  Copernica.ajaxUrls = {
 
 
 
 
 
 
 
 
 
 
87
  collection: {
88
+ fetch: '<?php echo $this->getAjaxCollectionFetchUrl(); ?>',
89
+ store: '<?php echo $this->getAjaxCollectionStoreUrl(); ?>',
90
+ default: '<?php echo $this->getAjaxCollectionDefaultUrl(); ?>',
91
+ validate: '<?php echo $this->getAjaxCollectionValidateUrl(); ?>'
 
 
 
 
92
  }
93
  };
94
 
95
+ // create view instance
96
+ var view = new Copernica.MainView($('linking-view'));
97
+
98
+ </script>
 
app/design/adminhtml/default/default/template/marketingsoftware/settings.phtml CHANGED
@@ -70,9 +70,6 @@ function init() {
70
  <h3 class="icon-head head-system-account">
71
  Copernica Marketing Software : Settings
72
  </h3>
73
- <p class="form-buttons">
74
- <button type="button" name="cp_save" id="cp_save">Save connection settings</button>
75
- </p>
76
  </div>
77
 
78
  <!-- Start of status box -->
@@ -177,6 +174,9 @@ function init() {
177
  </tr>
178
  <?php } ?>
179
  <tr>
 
 
 
180
  <td>
181
  <a href="https://www.copernica.com/en/support/rest/register-your-app-on-copernica-com" target="_blank">How to obtain key and secret?</a>
182
  </td>
70
  <h3 class="icon-head head-system-account">
71
  Copernica Marketing Software : Settings
72
  </h3>
 
 
 
73
  </div>
74
 
75
  <!-- Start of status box -->
174
  </tr>
175
  <?php } ?>
176
  <tr>
177
+ <td class="label">
178
+ <button type="button" name="cp_save" id="cp_save">Save connection settings</button>
179
+ </td>
180
  <td>
181
  <a href="https://www.copernica.com/en/support/rest/register-your-app-on-copernica-com" target="_blank">How to obtain key and secret?</a>
182
  </td>
js/copernica/marketingsoftware/link.js CHANGED
@@ -1,885 +1,345 @@
1
  /**
2
  * Javascript code for link.phtml template.
3
- * Copernica Marketing Software v 2.4.5
4
- * September 2014
5
- * http://www.copernica.com/
6
  */
7
 
 
8
  var Copernica = Copernica || {};
9
 
10
  /**
11
- * Helper function to check if given name is valid
12
- * @parma string
13
- * @return boolean
14
  */
15
- function isValidName(name) {
16
- return /^[a-z0-9\_]+$/i.test(name);
17
- }
18
 
19
- /**
20
- * Helper function to create database with current data
21
- */
22
- function createDatabase() {
 
23
 
24
- // database name input value (trimmed)
25
- var databaseNameValue = $('db_input').value.trim();
 
 
 
26
 
27
- // check if database has proper name
28
- if (!isValidName(databaseNameValue)) {
29
- // if database name is something that should not happen we want to inform used about it
30
- $('db_check_result').textContent = 'Database name should be composed from alphanumeric characters without spaces. "_" characters are also allowed.';
31
- $('db_check_result').style.display = 'inline';
32
 
33
- // we are don with this function
34
- return;
35
- }
 
36
 
37
- new Ajax.Request(
38
- Copernica.ajaxUrls.database.create,
39
- {
40
- method: 'post',
41
- parameters: { name: databaseNameValue },
42
- requestHeaders: { Accept: 'application/json' },
43
- onLoading: function () {
44
- // we don't want that loader thingy
45
- $('loading-mask', 'loading_mask_loader').invoke('hide');
46
-
47
- // show proper status
48
- $('db_check_result').textContent = 'Creating database...';
49
- $('db_check_result').style.display = 'inline';
50
-
51
- // hide repair button
52
- $('db_check_repair').textContent = '';
53
- $('db_check_repair').onclick = null;
54
- $('db_check_repair').style.display = 'none';
55
- },
56
- onComplete: function (response) {
57
- // get the answer
58
- var answer = response.responseText.evalJSON();
59
 
60
- // reset result
61
- $('db_check_result').textContent = answer.message;
62
- $('db_check_result').style.display = 'inline';
63
 
64
- // reset repair
65
- $('db_check_repair').textContent = '';
66
- $('db_check_repair').onclick = null;
67
- $('db_check_repair').style.display = 'none';
68
 
69
- // check if we have an error
70
- if (answer.error) {
71
- // do we have a fix for error?
72
- if (answer.fix != '') {
73
- $('db_check_repair').textContent = answer.fix;
74
- $('db_check_repair').style.display = 'inline';
75
-
76
- // if the fix is to fix account then we have to go to
77
- // another page for that
78
- if (answer.fix == 'Fix account') $('db_check_repair').onclick = function (event) {
79
- goToAccountSettings();
80
- };
81
- }
82
- }
83
- else {
84
- // we want to validate database after creation
85
- validateDatabase();
86
- }
87
- }
88
- }
89
- );
90
- }
91
 
92
- /**
93
- * Helper function to valdiate database
94
- */
95
- function validateDatabase() {
96
- // database name field value
97
- var databaseNameValue = $('db_input').value.trim();
98
-
99
- // check if database has proper name
100
- if (!isValidName(databaseNameValue)) {
101
- // if database name is something that should not happen we want to inform used about it
102
- $('db_check_result').textContent = 'Database name should be composed from alphanumeric characters without spaces. "_" characters are also allowed.';
103
- $('db_check_result').style.display = 'inline';
104
-
105
- // we are don with this function
106
- return;
107
- }
108
-
109
- new Ajax.Request(
110
- Copernica.ajaxUrls.database.validate,
111
- {
112
- method: 'post',
113
- parameters: { name: databaseNameValue },
114
- requestHeaders: { Accept: 'application/json' },
115
- onLoading: function () {
116
- // we don't want that loader thingy
117
- $('loading-mask', 'loading_mask_loader').invoke('hide');
118
-
119
- // show proper status
120
- $('db_check_result').textContent = 'Checking database...';
121
- $('db_check_result').style.display = 'inline';
122
-
123
- // hide repair button
124
- $('db_check_repair').textContent = '';
125
- $('db_check_repair').onclick = null;
126
- $('db_check_repair').style.display = 'none';
127
- },
128
- onComplete: function (response) {
129
- // get the answer
130
- var answer = response.responseText.evalJSON();
131
-
132
- // we are just fine
133
- $('db_check_result').textContent = answer.message;
134
- $('db_check_result').style.display = 'inline';
135
- $('db_check_repair').textContent = '';
136
- $('db_check_repair').onclick = null;
137
- $('db_check_repair').style.display = 'inline';
138
-
139
- // check if we have an answer
140
- if (answer.error && answer.fix != '') {
141
- // set the repair element and show it
142
- $('db_check_repair').textContent = answer.fix;
143
- $('db_check_repair').style.display = 'inline';
144
-
145
- // if we can create database we can show the repair button
146
- if (answer.fix == 'Create') $('db_check_repair').onclick = createDatabase;
147
-
148
- // if the fix is to fix account then we have to go to
149
- // another page for that
150
- if (answer.fix == 'Fix account') $('db_check_repair').onclick = function (event) {
151
- goToAccountSettings();
152
- };
153
- }
154
- }
155
- }
156
- );
157
- }
158
-
159
- /**
160
- * Fetch database fields
161
- */
162
- function fetchDatabaseFields() {
163
- // we want to fetch data for all database fields
164
- $('customer_fields').select('.customer_field').map(function(row){
165
- // get magento field name
166
- var magentoField = row.select('.magento-field-system')[0].value;
167
-
168
- // get status field
169
- var statusField = row.select('.field-status')[0];
170
-
171
- // get copernica field
172
- var copernicaField = row.select('.copernica-field')[0];
173
-
174
- // make an ajax call so we can get info about field
175
- new Ajax.Request(Copernica.ajaxUrls.database.fetch, {
176
- method: 'post',
177
- parameters: { name: magentoField },
178
- requestHeaders: { Accept: 'application/json' },
179
- onLoading: function() {
180
- // we don't want that loader thingy
181
- $('loading-mask', 'loading_mask_loader').invoke('hide');
182
-
183
- // we want to set the status as 'in progress'
184
- statusField.textContent = 'Fetching field data...';
185
- },
186
- onComplete: function (response) {
187
- // get the answer
188
- var answer = response.responseText.evalJSON();
189
-
190
- // set the message
191
- statusField.textContent = answer.message;
192
-
193
- // create copernica field name input
194
- var copernicaName = new Element('input', { class: 'input-text', type: 'text' });
195
 
196
- // insert copernica field name input
197
- copernicaField.insert(copernicaName);
198
 
199
- // if we have data about field we can set it right now
200
- if (answer.data) {
201
- // set copernica name
202
- copernicaName.value = answer.data.copernicaName;
203
-
204
- // when we have data stored in magento we want to check if
205
- // that info is valid
206
- validateDatabaseField(magentoField);
207
- }
208
-
209
- // whenever user is done with field edition we want to validate
210
- // that field and present current field status
211
- copernicaName.onblur = function (event) {
212
- validateDatabaseField(magentoField);
213
- }
214
- }
215
- });
216
  });
217
- }
218
 
219
- /**
220
- * Validate database field.
221
- * @paaram string name of them magento field
222
- */
223
- function validateDatabaseField(magentoField) {
224
- // get the row where field is
225
- var row = $('customer_fields').select('.magento-field-system[value='+magentoField+']')[0].up('.customer_field');
226
-
227
- // fetch status field
228
- var statusField = row.select('.field-status')[0];
229
-
230
- // get copernica field value
231
- var copernicaFieldValue = row.select('.copernica-field input')[0].value.trim();
232
-
233
- // check if database field name is valid
234
- if (!isValidName(copernicaFieldValue)){
235
- // inform user about wrong database field name
236
- statusField.textContent = 'Field name should be composed from alphanumeric characters without spaces. "_" characters are also allowed.';
237
- statusField.style.display = 'inline';
238
-
239
- // we are done here
240
- return;
241
- }
242
-
243
- // make the ajax call to validate database field
244
- new Ajax.Request( Copernica.ajaxUrls.databaseField.validate, {
245
- method: 'post',
246
- parameters: {
247
- databaseName: $('db_input').value.trim(),
248
- fieldName: copernicaFieldValue,
249
- magentoField: magentoField
250
- },
251
- requestHeaders: { Accept: 'application/json' },
252
- onLoading: function () {
253
- // we don't want that loader thingy
254
- $('loading-mask', 'loading_mask_loader').invoke('hide');
255
-
256
- // we want to set the status as 'in progreass'
257
- statusField.textContent = 'Checking field...';
258
- },
259
- onComplete: function (response) {
260
- // get the answer
261
- var answer = response.responseText.evalJSON();
262
-
263
- // get the status cell
264
- statusField.innerHTML = '';
265
-
266
- // create new status message element
267
- var message = new Element('span');
268
- message.textContent = answer.message;
269
- statusField.insert(message);
270
-
271
- // do we have an error and an fix for it?
272
- if (answer.fix) {
273
- // create new fix button
274
- var fix = new Element('b');
275
- fix.textContent = answer.fix;
276
-
277
- // if fix is to create a field we can attach a onclick event
278
- if (answer.fix == 'Create') {
279
- fix.onclick = function (event) {
280
- createDatabaseField(magentoField);
281
- }
282
- }
283
 
284
- // we don't have a database...
285
- if (answer.fix == 'Create database') {
286
- fix.onclick = function (event) {
287
- scrollToDatabase();
288
- }
289
- }
290
 
291
- // insert fix button
292
- statusField.insert(fix);
293
- }
294
- }
295
  });
296
- }
297
 
298
- /**
299
- * Create database field.
300
- */
301
- function createDatabaseField(magentoField) {
302
- // get the row where field is
303
- var row = $('customer_fields').select('.magento-field-system[value='+magentoField+']')[0].up('.customer_field');
304
-
305
- // fetch status field
306
- var statusField = row.select('.field-status')[0];
307
-
308
- // get copernica field value (trimmed)
309
- var copernicaFieldValue = row.select('.copernica-field input')[0].value.trim();
310
-
311
- // check if database field name is valid
312
- if (!isValidName(copernicaFieldValue)){
313
- // inform user about wrong database field name
314
- statusField.textContent = 'Field name should be composed from alphanumeric characters without spaces. "_" characters are also allowed.';
315
- statusField.style.display = 'inline';
316
-
317
- // we are done here
318
- return;
319
- }
320
-
321
- // make new AJAX request
322
- new Ajax.Request ( Copernica.ajaxUrls.databaseField.create, {
323
- method: 'post',
324
- parameters: {
325
- databaseName: $('db_input').value.trim(),
326
- fieldName: copernicaFieldValue,
327
- magentoField: row.select('.magento-field-system')[0].value
328
- },
329
- requestHeaders: { Accept: 'application/json' },
330
- onLoading: function () {
331
- // we don't want that loader thingy
332
- $('loading-mask', 'loading_mask_loader').invoke('hide');
333
-
334
- // change the status field
335
- row.select('.field-status')[0].textContent = 'Creating database field...';
336
- },
337
- onComplete: function (response) {
338
- // get the answer
339
- var answer = response.responseText.evalJSON();
340
-
341
- // get the status cell
342
- var statusCell = row.select('.field-status')[0];
343
-
344
- // create new status message element
345
- var statusMessage = new Element('span');
346
- statusMessage.textContent = answer.message;
347
-
348
- // clear the status cell and insert new message
349
- statusCell.innerHTML = '';
350
- statusCell.insert(statusMessage);
351
-
352
- // after creation we want to validate field once more
353
- validateDatabaseField(magentoField);
354
- }
355
  });
356
- }
357
 
358
  /**
359
- * Validate collection
 
360
  */
361
- function validateCollection(collectionName, collectionType) {
362
- // get the status field
363
- var statusField = $$('.collection-'+collectionType+' .field-status')[0];
364
-
365
- // check if collection name is valid
366
- if (!isValidName(collectionName)) {
367
- // infrom user about wrong collection name
368
- statusField.textContent = 'Collection name should be composed from alphanumeric characters without spaces. "_" characters are also allowed.';
369
- statusField.style.display = 'inline';
370
-
371
- // we are done in this function
372
- return;
373
- }
374
-
375
- // make new Ajax request
376
- new Ajax.Request( Copernica.ajaxUrls.collection.validate, {
377
- method: 'post',
378
- parameters: {
379
- databaseName: $('db_input').value.trim(),
380
- collectionName: collectionName,
381
- collectionType: collectionType
382
- },
383
- requestHeaders: { Accept: 'application/json' },
384
- onLoading: function () {
385
- // we don't want that loader thingy
386
- $('loading-mask', 'loading_mask_loader').invoke('hide');
387
-
388
- // set status field to 'in progress'
389
- statusField.textContent = 'Checking collection...';
390
- },
391
- onComplete: function (response) {
392
- // we want answer as object
393
- var answer = response.responseText.evalJSON();
394
-
395
- // create new message element
396
- var message = new Element('span');
397
- message.textContent = answer.message;
398
-
399
- // reset status field inner HTML
400
- statusField.innerHTML = '';
401
-
402
- // insert message element into status field
403
- statusField.insert(message);
404
-
405
- // check if we have a fix for error
406
- if (answer.fix)
407
- {
408
- // create fix button and insert it into status field
409
- var fix = new Element('b');
410
- fix.textContent = answer.fix;
411
- statusField.insert(fix);
412
-
413
- // can we create collection to solve the problem?
414
- if (answer.fix == 'Create') {
415
- fix.onclick = function (event) {
416
- createCollection(collectionName, collectionType);
417
- }
418
- }
419
-
420
- // can we create database to solve the problem?
421
- if (answer.fix == ' Create database') {
422
- fix.onclick = function (event) {
423
- scrollToDatabase();
424
- }
425
- }
426
  }
427
- }
428
  });
429
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
430
 
431
  /**
432
- * Create collection
433
- * @param string name of the collection
434
- * @param string type of the collection
435
  */
436
- function createCollection(collectionName, collectionType) {
437
- // get the status field
438
- var statusField = $$('.collection-'+collectionType+' .field-status')[0];
439
-
440
- // check if collection name is valid
441
- if (!isValidName(collectionName)) {
442
- // infrom user about wrong collection name
443
- statusField.textContent = 'Collection name should be composed from alphanumeric characters without spaces. "_" characters are also allowed.';
444
- statusField.style.display = 'inline';
445
-
446
- // we are done in this function
447
- return;
448
- }
449
-
450
- // make ajax request
451
- new Ajax.Request(Copernica.ajaxUrls.collection.create, {
452
- method: 'post',
453
- parameters: {
454
- databaseName: $('db_input').value.trim(),
455
- collectionName: collectionName,
456
- collectionType: collectionType
457
- },
458
- requsetHeaders: { Accept: 'application/json' },
459
- onLoading: function () {
460
- // we don't want that loader thingy
461
- $('loading-mask', 'loading_mask_loader').invoke('hide');
462
-
463
- // change to 'in progress'
464
- statusField.textContent = 'Creating collection...';
465
- },
466
- onComplete: function (response) {
467
- // we want answer as object
468
- var answer = response.responseText.evalJSON();
469
-
470
- // reset status field
471
- statusField.innerHTML = '';
472
-
473
- // create message
474
- var message = new Element('span');
475
- message.textContent = answer.message;
476
-
477
- // insert message
478
- statusField.insert(message);
479
-
480
- // after creation we want to revalidate collection
481
- validateCollection(collectionName, collectionType);
482
  }
483
- });
484
- }
485
 
 
 
486
 
487
- /**
488
- * Fetch all collections fields.
489
- */
490
- function fetchCollectionsFields() {
491
- // iterate over all collections
492
- $$('.collection input[name="collection"]').map(function (collectionTypeElem){
493
- // fetch fields for given collection
494
- fetchCollectionFields(collectionTypeElem.value);
495
- });
496
- }
497
 
498
- /**
499
- * Fetch collection fields
500
- * @param string
501
- */
502
- function fetchCollectionFields(collectionType) {
503
- // get collection fields container
504
- var collectionFieldsContainer = $$('.collection .collection-fields.collection-'+collectionType)[0];
505
 
506
- // iterate over all collection rows
507
- collectionFieldsContainer.select('.field').map(function (fieldRow){
508
- // get magento field name
509
- var magentoField = fieldRow.select('.field-magento input[type="hidden"]')[0].value;
 
 
 
 
510
 
511
- // get status field
512
- var statusField = fieldRow.select('.field-status')[0];
513
-
514
- // get the current collection name
515
- var collectionName = $$('.collection .collection-container.collection-'+collectionType+' input')[0].value;
516
-
517
- // make ajax request
518
- new Ajax.Request( Copernica.ajaxUrls.collection.fetch, {
519
  method: 'post',
520
  requestHeaders: { Accept: 'application/json' },
521
- parameters: {
522
- databaseName: $('db_input').value.trim(),
523
- collectionName: collectionName,
524
- collectionType: collectionType,
525
- magentoField: magentoField
526
- },
527
- onLoading: function () {
528
- // we don't want that loader thingy
529
- $('loading-mask', 'loading_mask_loader').invoke('hide');
530
-
531
- // change to 'in progress' text
532
- statusField.textContent = 'Fetching field...';
533
- },
534
- onComplete: function (response) {
535
- // get answer as object
536
- var answer = response.responseText.evalJSON();
537
 
538
- // reset status field
539
- statusField.innerHTML = '';
540
 
541
- // create new element that will hold answer message
542
- var message = new Element('span');
543
- message.textContent = answer.message;
544
 
545
- // insert message to status field
546
- statusField.appendChild(message);
 
 
 
547
 
548
- // create input field
549
- var inputField = new Element('input', { type: 'text', class: 'input-text' });
550
 
551
- // install handler on blur event
552
- inputField.onblur = function (event) {
553
- validateCollectionField(collectionType, magentoField);
554
  }
 
 
 
555
 
556
- // get copernica field cell
557
- var copernicaField = fieldRow.select('.field-copernica')[0];
 
 
558
 
559
- // insert input field into copernica cell
560
- copernicaField.insert(inputField);
 
 
 
561
 
562
- // we have an error
563
- if (answer.error) {
564
- // @todo error handling ?
565
- }
566
- else
567
- {
568
- inputField.value = answer.fieldData;
569
 
570
- validateCollectionField(collectionType, magentoField);
571
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
572
  }
573
  });
574
- });
575
- }
 
 
 
 
 
 
 
 
 
576
 
577
- /**
578
- * Validate collection field
579
- */
580
- function validateCollectionField(collectionType, magentoFieldName) {
581
- // get magento field
582
- var magentoField = $$('.collection-fields.collection-'+collectionType+' .field-magento input[value="'+magentoFieldName+'"]')[0];
583
-
584
- // get field row
585
- var fieldRow = magentoField.up('.field', 0);
586
-
587
- // get copernica field
588
- var copernicaField = fieldRow.select('.field-copernica input')[0];
589
-
590
- // get status cell
591
- var statusField = fieldRow.select('.field-status')[0];
592
-
593
- // get copernica field value (trimmed)
594
- var copernicaFieldValue = copernicaField.value.trim();
595
-
596
- // check if collection field name is valid
597
- if (copernicaFieldValue.length && !isValidName(copernicaFieldValue)) {
598
- // tell used about mistake
599
- statusField.textContent = 'Collection field should be composed from alphanumeric characters without spaces. "_" characters are also allowed.';
600
- statusField.style.display = 'inline';
601
-
602
- // we are done in this function
603
- return;
604
- }
605
-
606
- // get collection name
607
- var collectionName = fieldRow.up('.collection', 0).select('.collection-container .field-name input')[0].value;
608
-
609
- // make ajax request
610
- new Ajax.Request( Copernica.ajaxUrls.collectionField.validate, {
611
- method: 'post',
612
- requestHeaders: { Accept: 'application/json' },
613
- parameters: {
614
- databaseName: $('db_input').value.trim(),
615
- collectionType: collectionType,
616
- collectionName: collectionName,
617
- magentoName: magentoFieldName,
618
- copernicaName: copernicaFieldValue
619
- },
620
- onLoading: function () {
621
- // we don't want that loader thingy
622
- $('loading-mask', 'loading_mask_loader').invoke('hide');
623
-
624
- // change status to 'in progress'
625
- statusField.textContent = 'Checking field...';
626
- },
627
- onComplete: function (response) {
628
- var answer = response.responseText.evalJSON();
629
-
630
- // create message element
631
- var message = new Element('span');
632
- message.textContent = answer.message;
633
-
634
- // clear status field
635
- statusField.innerHTML = '';
636
-
637
- // insert message to status field
638
- statusField.insert(message);
639
-
640
- // check if we have a fix for error
641
- if (answer.fix) {
642
- // create fix element
643
- var fix = new Element('b');
644
- fix.textContent = answer.fix;
645
-
646
- // insert fix element into status field
647
- statusField.insert(fix);
648
-
649
- if (answer.fix == 'Create') {
650
- fix.onclick = function (event) {
651
- createCollectionField(collectionType, magentoFieldName);
652
- }
653
- }
654
- }
655
- }
656
- });
657
- }
658
 
659
- /**
660
- * Create collection field
661
- */
662
- function createCollectionField(collectionType, magentoFieldName) {
663
- // get magento field
664
- var magentoField = $$('.collection-fields.collection-'+collectionType+' .field-magento input[value="'+magentoFieldName+'"]')[0];
665
-
666
- // get field row
667
- var fieldRow = magentoField.up('.field', 0);
668
-
669
- // get copernica field
670
- var copernicaField = fieldRow.select('.field-copernica input')[0];
671
-
672
- // get status cell
673
- var statusField = fieldRow.select('.field-status')[0];
674
-
675
- // get copernica field value
676
- var copernicaFieldValue = copernicaField.value.trim();
677
-
678
- // check if collection field name is valid
679
- if (!isValidName(copernicaFieldValue)) {
680
- // tell used about mistake
681
- statusField.textContent = 'Collection field should be composed from alphanumeric characters without spaces. "_" characters are also allowed.';
682
- statusField.style.display = 'inline';
683
-
684
- // we are done in this function
685
- return;
686
- }
687
-
688
- // get collection name
689
- var collectionName = fieldRow.up('.collection', 0).select('.collection-container .field-name input')[0].value;
690
-
691
- new Ajax.Request( Copernica.ajaxUrls.collectionField.create, {
692
- method: 'post',
693
- requestHeaders: { Accept: 'application/json' },
694
- parameters: {
695
- databaseName: $('db_input').value.trim(),
696
- collectionType: collectionType,
697
- collectionName: collectionName,
698
- magentoName: magentoFieldName,
699
- copernicaName: copernicaFieldValue
700
- },
701
- onLoading: function () {
702
- // we don't want that loader thingy
703
- $('loading-mask', 'loading_mask_loader').invoke('hide');
704
-
705
- // change status to 'in progress'
706
- statusField.textContent = 'Creating field...';
707
-
708
- },
709
- onComplete: function (response) {
710
- var answer = response.responseText.evalJSON();
711
-
712
- // check if we have an error
713
- if (answer.error == 0) {
714
- statusField.innerHTML = '';
715
-
716
- // change status field text
717
- statusField.textContent = answer.message;
718
-
719
- // we want to validata created field
720
- validateCollectionField(collectionType, magentoFieldName);
721
- }
722
- else
723
- {
724
- // create message element
725
- var message = new Element('span');
726
- message.textContent = answer.message;
727
 
728
- // clear up the status field
729
- statusField.innerHTML = '';
730
 
731
- // insert message
732
- statusField.insert(message);
733
- }
734
- }
735
- });
736
- }
737
 
738
- /**
739
- * Scroll to database input
740
- */
741
- function scrollToDatabase() {
742
- $('db_input').up('form', 0).scrollTo();
743
- }
744
 
745
- /**
746
- * Go to account settings
747
- */
748
- function goToAccountSettings() {
749
- window.location.href = Copernica.pageUrls.accountSettings;
750
- }
751
 
752
- /**
753
- * Helper function to save whole form in correct format
754
- */
755
- function saveForm() {
756
- // prepare data for AJAX
757
- var formData = {};
758
- formData.database = { name: '', fields: {} };
759
- formData.collections = {};
760
-
761
- // check if we are setting database
762
- if ($('db_input').value.trim().length) {
763
- formData.database.name = $('db_input').value.trim();
764
- }
765
-
766
- // iterater over all customer fields rows
767
- $('customer_fields').select('.customer_field').map(function(row){
768
- // get magento and copernica name
769
- var magentoName = row.select('.magento-field-system')[0].value.trim();
770
- var copernicaName = row.select('.copernica-field input')[0].value.trim();
771
-
772
- // check if magento and copernica name are set
773
- formData.database.fields[magentoName] = copernicaName;
774
- });
775
 
776
- // iterater over all collections
777
- $$('.collection').map(function (collectionContainer) {
778
- // get the collection type
779
- var collectionType = collectionContainer.select('input[name="collection"]')[0].value.trim();
780
 
781
- // get collection name
782
- var collectionName = collectionContainer.select('.collection-container input')[0].value.trim();
 
783
 
784
- // we don't have a collection name
785
- if (collectionName.length == 0) return;
 
786
 
787
- // store collection name
788
- formData.collections[collectionType] = { name: collectionName };
 
789
 
790
- // make an empty object for collection fields
791
- formData.collections[collectionType].fields = { };
 
792
 
793
- // iterate over all collection fields
794
- collectionContainer.select('.collection-fields .field').map(function(fieldRow){
795
- // fetch copernica and magento field values
796
- var copernicaField = fieldRow.select('.field-copernica input')[0].value.trim();
797
- var magentoField = fieldRow.select('.field-magento input[type="hidden"]')[0].value.trim();
798
 
799
- // assign proper values to collection fields property
800
- formData.collections[collectionType].fields[magentoField] = copernicaField;
801
- });
802
- });
803
 
804
- // we can make proper Ajax request
805
- new Ajax.Request( Copernica.ajaxUrls.save, {
806
- method: 'post',
807
- parameters: { data: Object.toJSON(formData) },
808
- requestHeaders: { Accept: 'application/json' },
809
- onLoading: function () {
810
- // now! we want that loader thingy
811
- $('loading-mask', 'loading_mask_loader').invoke('show');
812
- },
813
- onComplete: function (response) {
814
- // we don't want that loader thingy
815
- $('loading-mask', 'loading_mask_loader').invoke('hide');
816
-
817
- // get the answer from server
818
- var answer = response.responseText.evalJSON();
819
- }
820
- });
821
- }
822
 
823
- /*
824
- * Initialize logic after full DOM is loaded.
825
- */
826
- document.observe('dom:loaded', function(){
827
- // when user is finish with typing database name we want to validate it
828
- $('db_input').onblur = function (event) {
829
- validateDatabase();
830
- }
831
-
832
- // when save button is clicked we want to save all info
833
- $('save').onclick = function (event) {
834
- saveForm();
835
- }
836
-
837
- // we want to initialize all collections
838
- $$('.collection').map(function(container) {
839
- var collectionNameField = container.select('.collection-container input')[0];
840
-
841
- // get collection type element
842
- var collectionTypeElem = collectionNameField.up('.collection',0).select('input[name="collection"]')[0];
843
-
844
- // we we do loose focus on input field we want to validate collection
845
- collectionNameField.onblur = function (event) {
846
- // validate collection
847
- validateCollection(collectionNameField.value, collectionTypeElem.value);
848
- };
849
 
850
- // get status field
851
- var collectionStatusField = container.select('.collection-container .field-status')[0];
 
852
 
853
- // do ajax call to get info about collection
854
- new Ajax.Request(Copernica.ajaxUrls.collection.info, {
855
- method: 'post',
856
- requestHeaders: { Accept: 'application/json' },
857
- parameters: { collectionType: collectionTypeElem.value },
858
- onLoading: function () {
859
- // now! we want that loader thingy
860
- $('loading-mask', 'loading_mask_loader').invoke('hide');
861
-
862
- // change to 'in progress' status
863
- collectionStatusField.textContent = 'Fetching collection info...';
864
- },
865
- onComplete: function (response) {
866
- var answer = response.responseText.evalJSON();
867
 
868
- // clear status field text
869
- collectionStatusField.textContent = '';
 
 
870
 
871
- // basically we will ignore error
872
- if (answer.error == 1) return;
873
-
874
- // assign name
875
- collectionNameField.value = answer.collectionName;
876
- }
877
- });
878
- });
879
 
880
- // fetch database fields data
881
- fetchDatabaseFields();
 
882
 
883
- // fetch all collections fields data
884
- fetchCollectionsFields();
885
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  /**
2
  * Javascript code for link.phtml template.
3
+ * links.js
4
+ * Copernica Marketing Software
 
5
  */
6
 
7
+ // ensure namespace
8
  var Copernica = Copernica || {};
9
 
10
  /**
11
+ * This class will take care of linking page view.
12
+ * @param object The root element of the view
 
13
  */
14
+ Copernica.MainView = function (rootElement) {
 
 
15
 
16
+ /**
17
+ * Current view object.
18
+ * @var object
19
+ */
20
+ var currentView;
21
 
22
+ /**
23
+ * Currently viewed collection.
24
+ * @var string
25
+ */
26
+ var current;
27
 
28
+ // install on lick handler on collection list
29
+ rootElement.select('#collection_list')[0].observe('click', function (event) {
 
 
 
30
 
31
+ // change active tab
32
+ var active = rootElement.select('#collection_list .active');
33
+ for (var i = 0; i < active.length; i++) active[i].removeClassName('active');
34
+ (event.target.match('a') ? event.target : event.target.up('a')).addClassName('active');
35
 
36
+ // get the name of the collection that we want to show
37
+ var name = event.target.up('li').readAttribute('data-target');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
 
39
+ // if picked name is the same as current collection we don't do anything special
40
+ if (name == current) return;
 
41
 
42
+ // assign picked collection as current one
43
+ current = name;
 
 
44
 
45
+ // clean collection view element
46
+ $('collection_view').innerHTML = '';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47
 
48
+ // should we show the default structure view?
49
+ if (name == 'default') currentView = new Copernica.DefaultView($('collection_view'));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
 
51
+ // change to selected collection
52
+ else currentView = new Copernica.CollectionView($('collection_view'), name);
53
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
  });
 
55
 
56
+ // chanage collection to main database collection (the database)
57
+ rootElement.select('#collection_list [data-target="main"] a')[0].click();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
 
59
+ // install on click handler on save button
60
+ $('save').observe('click', function (event) {
 
 
 
 
61
 
62
+ // store currently viewed collection
63
+ currentView.store();
 
 
64
  });
 
65
 
66
+ // install on click handler on validate button
67
+ $('validate').observe('click', function (event) {
68
+
69
+ // store currently viewed collection
70
+ currentView.validate();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71
  });
72
+ };
73
 
74
  /**
75
+ * This class will handle a default structure view.
76
+ * @param object The root element that will show the view
77
  */
78
+ Copernica.DefaultView = function (rootElement) {
79
+ // create new info elements
80
+ rootElement.insert(new Element('p').update("If it's not needed to customize what kind of data is send to Copernica, it's possible to create whole database structure by clicking below button."));
81
+ rootElement.insert(new Element('p').update("Be aware that this process can take long time (event 10 minutes). Do not close you browser in the middle of the process."));
82
+
83
+ // create button
84
+ var button = new Element('button').update('Create default structure').observe('click', function () {
85
+ new Ajax.Request(Copernica.ajaxUrls.collection.default, {
86
+ method: 'post',
87
+ requestHeaders: { Accept: 'application/json' },
88
+ parameters: { name: name },
89
+ onComplete: function (response) {
90
+ window.location.reload();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
91
  }
92
+ });
93
  });
94
+
95
+ // insert button
96
+ rootElement.insert(button);
97
+
98
+ /**
99
+ * Store default view
100
+ */
101
+ this.store = function () {
102
+ // it's ok
103
+ };
104
+
105
+ /**
106
+ * Validate default view
107
+ */
108
+ this.validate = function () {
109
+ // it's ok
110
+ };
111
+ };
112
 
113
  /**
114
+ * This class will handle collection view.
115
+ * @param object The root element that will show the collection
116
+ * @param string Name of the collection
117
  */
118
+ Copernica.CollectionView = function (rootElement, name) {
119
+
120
+ /**
121
+ * Element that will hold validation results.
122
+ */
123
+ var validateElem;
124
+
125
+ /**
126
+ * Validate collection
127
+ */
128
+ var validateAll = function () {
129
+
130
+ // initialize validate data
131
+ var validateData = {
132
+ name: rootElement.select('form input[name="collection_name"]')[0].value,
133
+ type: name,
134
+ fields: []
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
135
  }
 
 
136
 
137
+ // get inputs
138
+ var inputs = rootElement.select('form #fields_list input');
139
 
140
+ // placeholder for fields
141
+ var fields = [];
 
 
 
 
 
 
 
 
142
 
143
+ // prepare fields data
144
+ for (var i = 0; i < inputs.length; i++) if (inputs[i].value) fields.push(inputs[i].readAttribute('name')+','+inputs[i].value);
 
 
 
 
 
145
 
146
+ /**
147
+ * This is just silly. Since all data that is send by prototype and received
148
+ * by magento is encoded in form-multipart type, we can not create more
149
+ * complex data structures. The '[]' is a PHP only hack that will allow
150
+ * to create an array server side. Well, it seems that it's the best that
151
+ * we can do here.
152
+ */
153
+ validateData['fields[]'] = fields;
154
 
155
+ new Ajax.Request(Copernica.ajaxUrls.collection.validate, {
 
 
 
 
 
 
 
156
  method: 'post',
157
  requestHeaders: { Accept: 'application/json' },
158
+ parameters: validateData,
159
+ onComplete: function ( response ) {
160
+
161
+ validateElem.show();
162
+ validateElem.innerHTML = '';
 
 
 
 
 
 
 
 
 
 
 
163
 
164
+ // get object
165
+ var answer = response.responseText.evalJSON();
166
 
167
+ if (answer.length == 0) validateElem.insert((new Element('p')).update('Collection is perfectly valid'));
 
 
168
 
169
+ // iterate over problems
170
+ for(var i = 0; i < answer.length; i++)
171
+ {
172
+ var problem = new Element('p');
173
+ validateElem.insert(problem);
174
 
175
+ var parts = answer[i].split(',');
 
176
 
177
+ if (parts.length > 1) problem.update('Field '+parts[0]+': '+parts[1]);
178
+ else problem.update('Collection '+parts[0]);
 
179
  }
180
+ }
181
+ });
182
+ };
183
 
184
+ /**
185
+ * Store collection name
186
+ */
187
+ var storeAll = function () {
188
 
189
+ // set collection info
190
+ var data = {
191
+ name: rootElement.select('form input[name="collection_name"]')[0].value,
192
+ type: name
193
+ };
194
 
195
+ // get inputs
196
+ var inputs = rootElement.select('form #fields_list input');
 
 
 
 
 
197
 
198
+ // placeholder for fields
199
+ var fields = [];
200
+
201
+ // prepare fields data
202
+ for (var i = 0; i < inputs.length; i++) fields.push(inputs[i].readAttribute('name')+','+inputs[i].value);
203
+
204
+ /**
205
+ * This is just silly. Since all data that is send by prototype and received
206
+ * by magento is encoded in form-multipart type, we can not create more
207
+ * complex data structures. The '[]' is a PHP only hack that will allow
208
+ * to create an array server side. Well, it seems that it's the best that
209
+ * we can do here.
210
+ */
211
+ data['fields[]'] = fields;
212
+
213
+ // store collection data
214
+ new Ajax.Request(Copernica.ajaxUrls.collection.store, {
215
+ method: 'post',
216
+ requestHeaders: { Accept: 'application/json' },
217
+ parameters: data,
218
+ onComplete: function () {
219
+ // huh?
220
  }
221
  });
222
+ };
223
+
224
+ // we want to make all initializations in private namespace.
225
+ (function () {
226
+
227
+ /**
228
+ * Show main collection
229
+ */
230
+ var showMainCollection = function () {
231
+ $$('#collection_list [data-collection="main"] a')[0].click();
232
+ };
233
 
234
+ // show that we are fetching data
235
+ rootElement.insert("<p>Loading data...</p>");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
236
 
237
+ // make AJAX request to fetch collection data
238
+ new Ajax.Request(Copernica.ajaxUrls.collection.fetch, {
239
+ method: 'post',
240
+ requestHeaders: { Accept: 'application/json' },
241
+ parameters: { name: name },
242
+ onComplete: function (response) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
243
 
244
+ // eval JSON response
245
+ var answer = response.responseText.evalJSON();
246
 
247
+ // check if we have an error
248
+ if (answer.error == 'no database') return showMainCollection();
 
 
 
 
249
 
250
+ // clear root element
251
+ rootElement.innerHTML = '';
 
 
 
 
252
 
253
+ // create form element
254
+ var form = new Element('form');
255
+ rootElement.insert(form);
 
 
 
256
 
257
+ // create entry edit element
258
+ var entryEdit = new Element('div', { class: 'entry-edit'} );
259
+ form.insert(entryEdit);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
260
 
261
+ // create field set with name
262
+ validateElem = new Element('div', { class: 'fieldset fieldset-wide' }).hide();
263
+ entryEdit.insert(validateElem);
 
264
 
265
+ // create field set with name
266
+ var nameFieldSet = new Element('div', { class: 'fieldset fieldset-wide' });
267
+ entryEdit.insert(nameFieldSet);
268
 
269
+ // create name form list
270
+ var nameFormList = new Element('table', { class: 'form-list' });
271
+ nameFieldSet.insert(nameFormList);
272
 
273
+ // create tbody
274
+ var nameTbody = new Element('tbody');
275
+ nameFormList.insert(nameTbody);
276
 
277
+ // create form row
278
+ var tr = new Element('tr');
279
+ nameTbody.insert(tr);
280
 
281
+ // create label cell
282
+ var label = (new Element('td', { class: 'label' })).update( answer.label );
283
+ tr.insert(label);
 
 
284
 
285
+ // create value cell
286
+ var value = (new Element('td', { class: 'value' }));
287
+ tr.insert(value);
 
288
 
289
+ // create input
290
+ var input = new Element('input', { class: 'input-text', name: 'collection_name' }).setValue(answer.linkedName);
291
+ value.insert(input);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
292
 
293
+ // create fieldset
294
+ var fieldSet = new Element('div', { class: 'fieldset fieldset-wide' });
295
+ entryEdit.insert(fieldSet);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
296
 
297
+ // create form list
298
+ var formList = new Element('table', { class: 'form-list', id: 'fields_list' });
299
+ fieldSet.insert(formList);
300
 
301
+ // create tbody
302
+ var tbody = new Element('tbody');
303
+ formList.insert(tbody);
 
 
 
 
 
 
 
 
 
 
 
304
 
305
+ // iterate over all received fields
306
+ for (var f = 0; f < answer.fields.length; f++) {
307
+ // brinf field to local scope
308
+ var field = answer.fields[f];
309
 
310
+ // create tr
311
+ var tr = new Element('tr');
312
+ tbody.insert(tr);
313
+
314
+ // create label
315
+ var label = new Element('td', { class: 'label' });
316
+ tr.insert(label);
317
+ label.update(field.label);
318
 
319
+ // create value
320
+ var value = new Element('td', { class: 'value' });
321
+ tr.insert(value);
322
 
323
+ // create input field
324
+ var input = new Element('input', { class: 'input-text', name: field.magento });
325
+ value.insert(input);
326
+ input.setValue(field.copernica);
327
+ }
328
+ }
329
+ });
330
+ })();
331
+
332
+ /**
333
+ * Store whole collection
334
+ */
335
+ this.store = function () {
336
+ storeAll();
337
+ };
338
+
339
+ /**
340
+ * Validate whole collection
341
+ */
342
+ this.validate = function () {
343
+ validateAll();
344
+ };
345
+ };
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Copernica_MarketingSoftware</name>
4
- <version>3.0.0</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL 3.0)</license>
7
  <channel>community</channel>
@@ -10,14 +10,12 @@
10
  <description>When you install the integration, all contact, order and shop cart data from Magento will be automatically synchronized and stored in Copernica. By synchronizing data between your Magento webshop and Copernica, you are able to set up targeted email campaigns. For example you can consider emailing customers with abandoned shopcarts automatically every week. Your contacts will only receive information relevant to them, which will make them come back to your shop time and again. The available integration is also compatible with the Magento Enterprise edition.&#xD;
11
  &#xD;
12
  Please note that this extension does not work with PHP 5.4.X. and should be run with the Magento system requirements in mind.</description>
13
- <notes>New features:&#xD;
14
- - Uses the new Copernica REST API&#xD;
15
- - Improved performance&#xD;
16
  </notes>
17
  <authors><author><name>Cream</name><user>creaminternet</user><email>info@cream.nl</email></author></authors>
18
- <date>2014-10-02</date>
19
- <time>11:13:32</time>
20
- <contents><target name="magecommunity"><dir name="Copernica"><dir name="MarketingSoftware"><dir name="Block"><dir name="Adminhtml"><dir name="Marketingsoftware"><file name="Export.php" hash="487cc0386e351c908d5bb2a6aa88c6d7"/><file name="Link.php" hash="d7d097ce57888e253b5b96f844358a93"/><file name="Settings.php" hash="105197d4382b03fadfa43b5616894bd4"/><file name="Sync.php" hash="f841cc8adcd5aaab0c339e8c3a4532bc"/></dir></dir></dir><dir name="Controller"><file name="Base.php" hash="5a5b8a0121ca6025fdd4707a76e34911"/></dir><file name="Exception.php" hash="ad3646aad8fcf3c678b7cdfa91d651e1"/><dir name="Helper"><file name="Api.php" hash="e5bb4038213a529f09ef8e51812b7877"/><file name="ApiBase.php" hash="58cdf8255a33bf8fb78060afc74430a8"/><file name="ApiBuilder.php" hash="48bb3e55621d68e00de14017c4bfef57"/><file name="ApiValidator.php" hash="641d7ae8665562a07cd3df90df4ddf00"/><file name="Config.php" hash="029fa7e372c67e6ad2d9cf97c4784782"/><file name="Data.php" hash="b6cdfe5ddbc2f467b446690511435727"/><file name="DataWriter.php" hash="af3bba3409fba39320f99e83a34fc44c"/><file name="Profile.php" hash="bb6ab328045fb12319de467ce9c7b2ae"/><file name="RESTRequest.php" hash="681bf285022846a64f5aa845fa81bc2a"/></dir><dir name="Model"><file name="AbandonedCart.php" hash="51f3f1478a89de28ee253d9f94b3196c"/><file name="AbandonedCartsProcessor.php" hash="9cc44c9eaedabe38ef7860945d46c062"/><dir name="Abstraction"><file name="Address.php" hash="57e6404f732bb0b831e1498f28ac464c"/><file name="Attributes.php" hash="ac06dfb53f78e5210e12bc1f68cbb18e"/><file name="Customer.php" hash="e84dc90ae63c296641ed30119537a489"/><file name="Name.php" hash="a2edffc4a77440e2b7df7cefb0b43583"/><dir name="Order"><dir name="Item"><file name="Options.php" hash="806711e5c0303cedfc724ce02868c85d"/></dir><file name="Item.php" hash="366055e71f98f47ec329b070aacfe518"/></dir><file name="Order.php" hash="7cff6f7e9c3aebac647e35d2ebb99c66"/><file name="Price.php" hash="e48a7323579b230cf6dd487041784e08"/><file name="Product.php" hash="556476f42785f5554698da09567581c0"/><dir name="Quote"><dir name="Item"><file name="Options.php" hash="f836a70b98c345975ad8d91e6ef88d3f"/></dir><file name="Item.php" hash="c56b80f5bfb17051b42eff127b58b94d"/></dir><file name="Quote.php" hash="8df90763d3685b755a080691b06bca7d"/><file name="Storeview.php" hash="68664c1717bc95ff41765f94f48610d2"/><file name="Subscription.php" hash="7b163f295803d391557c22572ff81850"/><file name="Viewedproduct.php" hash="1a29f985c6e53d5188639d1a09c24344"/></dir><file name="Config.php" hash="d64086db5762e020049e309062e128f5"/><dir name="Copernica"><file name="Abstract.php" hash="31d026df826a9c8d716bd51388eda480"/><dir name="Address"><file name="Subprofile.php" hash="23367765c877ea7968c6b5d58cc21ea9"/></dir><dir name="Cartitem"><file name="Subprofile.php" hash="2cb3eb3f6add77dbd75f69787a9953fb"/></dir><dir name="Entity"><file name="Address.php" hash="0ae0020f4319fc112ddce2d14ceda209"/><file name="CartItem.php" hash="3fcffafcc80de592d81db7a5bfb2317e"/><file name="Customer.php" hash="e846a04aca3b2c81135379d0c2916b4a"/><file name="Item.php" hash="9c6c516a448bde9d36e2dee534a9a9da"/><file name="Order.php" hash="ce02b453677a27b5e65cb8544c7364fa"/><file name="Product.php" hash="feecd138d77c1ccf0bf32d89149fd16b"/><file name="Quote.php" hash="027d60b614f2b4b20a512776b588e853"/><file name="Subscription.php" hash="c58dae96eb1b9e2122fedd8581aad638"/></dir><file name="Entity.php" hash="e3cd012a331f11f0ec984c0937717a0e"/><dir name="Order"><file name="Subprofile.php" hash="3219e6835cccc7be482259576d64a9d4"/></dir><dir name="Orderitem"><file name="Subprofile.php" hash="ee7f2ab5e04fdca847c419b321639333"/></dir><file name="Profile.php" hash="506544ea302cbccd649d82844cb11375"/><file name="Profilecustomer.php" hash="14c61e3e7e4dad65a9f2f62de725c90c"/><file name="Profileorder.php" hash="f3fcf68822e87816b982b9a867503726"/><file name="Profilequote.php" hash="18f8ed2114886bc32911dbe772297f88"/><file name="Profilesubscription.php" hash="67a5d3404363c39b127e23dc9d7b2834"/><dir name="Viewedproduct"><file name="Subprofile.php" hash="b8b9ae88df26d3e18438e17147f77235"/></dir></dir><file name="ErrorQueue.php" hash="c85c754ce859704717913c9f8e9c8588"/><dir name="Mysql4"><dir name="AbandonedCart"><file name="Collection.php" hash="e72b2d443f5c009c29a86cf90ff53421"/></dir><file name="AbandonedCart.php" hash="ec9371ec8c58d550927f31ed1d565d68"/><dir name="Config"><file name="Collection.php" hash="ef43ccb80fd1b415c9a42ee133f80530"/></dir><file name="Config.php" hash="f71bbcca4066b9092700b5f8581cebfd"/><dir name="ErrorQueue"><file name="Collection.php" hash="ca34b0d7540914ae17951722adfa565c"/></dir><file name="ErrorQueue.php" hash="802920824d781f0aec913ef451b8393d"/><dir name="ProfileCache"><file name="Collection.php" hash="593426fd7ca9db0a8ae0e2093a89e2aa"/></dir><file name="ProfileCache.php" hash="a7236486592fe28548a0a30b0bfa6060"/><dir name="Queue"><file name="Collection.php" hash="529d1a0b0f741b5502cee205b6a974e6"/></dir><file name="Queue.php" hash="6290f87f7fbb03155665e237a50176c3"/><dir name="SyncProfile"><file name="Collection.php" hash="33e76bc39467b0093a7a77da44eef966"/></dir><file name="SyncProfile.php" hash="1ac7cbd0ea721dd80b7f35b864f6dc0a"/></dir><file name="Observer.php" hash="011610aef7ddd7f551f9355d3262fbe5"/><file name="ProfileCache.php" hash="6f228e87a3d430b654d1337285317083"/><file name="Queue.php" hash="48a6eeafa120dfdb39e5fb0601f15270"/><dir name="QueueEvent"><file name="Abstract.php" hash="666e449669bde675a77ebe27f38edb28"/><file name="Checkout.php" hash="524edeac5cb4023e105660992913f638"/><file name="Customer.php" hash="26f501661ad98905dc6fb6eee61612cd"/><file name="CustomerAdd.php" hash="1754e3cb0ef651fc33b7708daf25dc96"/><file name="CustomerFull.php" hash="36708490c408197fefbd1971ea7c1e37"/><file name="CustomerModify.php" hash="fcaec6161ce09f2548fd55f950d4b374"/><file name="CustomerRemove.php" hash="f65b6eb43b1340758fc190d06feabb7a"/><file name="CustomerUpgrade.php" hash="4af755a621195c0ef0dacf6eab88436c"/><file name="Factory.php" hash="a98bde41d9d3666573d4ded6d4143ed7"/><file name="Item.php" hash="b1271f745ee5b249d036881eddb10021"/><file name="Order.php" hash="bba1f7fe5457a4d0ddacb6656b687076"/><file name="OrderAdd.php" hash="34f2af84d5a1dbe2cded9c04b9ebed8d"/><file name="OrderModify.php" hash="2a8d3aeb200d22455aff15ad41f4b4aa"/><file name="Quote.php" hash="e8fec3ebe3264b0b0ee2da62fb90b2ce"/><file name="QuoteItem.php" hash="fc4bd84522a3d581ad5fde799748b9a2"/><file name="QuoteItemAdd.php" hash="ebcce56922150d281d02c41440bf0222"/><file name="QuoteItemModify.php" hash="113a7edee4d41ac1a6d2a0d4b9128850"/><file name="QuoteItemRemove.php" hash="d6c7fa98a137b7b13837214ae2e4132c"/><file name="QuoteModify.php" hash="9f6cc8bf0cb6679cab8c7121f1fbf7a2"/><file name="StartSync.php" hash="1c6fdb53acaf8e4729978f3bbe18536a"/><file name="Subscription.php" hash="09eba1cffe0b0fe341b2d6a67e444ee0"/><file name="SubscriptionAdd.php" hash="c9609ae3f3bbd03a842ff28175ecc5fe"/><file name="SubscriptionModify.php" hash="d61f5c0d8c15ffe377c0e3cd99db61a0"/><file name="SubscriptionRemove.php" hash="c6d79f1748025edf714d25128f299937"/><file name="View.php" hash="ae2e7e3e7638793779a275dc8a525d09"/><file name="ViewedProductAdd.php" hash="822e17d7fc86e65c3d107e6df1aaecba"/></dir><file name="QueueProcessor.php" hash="03ad8614260b2620209bfc742cea88ba"/><dir name="REST"><file name="Address.php" hash="8f189ab2e708e652adf6b1c3b61ab2b7"/><file name="CartItem.php" hash="4b8ac947cf1bdc9157499f722c881ef2"/><file name="Customer.php" hash="a76b90a87373b79ac87c0323ec4d3aa2"/><file name="Item.php" hash="9c3fc8c093bb11ea1efe386f63eeac8a"/><file name="Order.php" hash="f16add67f9bbc0ab26da435c8c3cf611"/><file name="Product.php" hash="f1a9e7bd1f0ed441db70177dd625d198"/><file name="Quote.php" hash="5fc78607e82f4696f1b8233af38ecc49"/><file name="Subscription.php" hash="dadd94f50786f597e85bb95b3cae6d0c"/></dir><file name="REST.php" hash="ec324f180c9e55ab0881d3393ff5aee3"/><file name="SyncProfile.php" hash="e1a9b4f71fea54b6c16a56b95f00ab4f"/><file name="SyncStatus.php" hash="365118aa88448b87a7b9c3253e5368e6"/></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Marketingsoftware"><file name="AjaxcollectionController.php" hash="b346c7b377c564801ed62a209f4cc05d"/><file name="AjaxcollectionfieldController.php" hash="139113a8ee7921990d76073d5ecae2a8"/><file name="AjaxdatabaseController.php" hash="b9652b5eb2a5487d291128179ff27cc8"/><file name="AjaxdatabasefieldController.php" hash="64486d84a6ca182b18eb5911be91cc9f"/><file name="ExportController.php" hash="2deaf4c0184548b968f07d9e85aa3b16"/><file name="LinkController.php" hash="a7a42801f55dd644a9aa8521219c94cd"/><file name="SettingsController.php" hash="97b7d0a6c25cbf22776bcfcfb7ba0e85"/><file name="SyncController.php" hash="cd978f2fa07a5dd164c60ca2b20b1eec"/></dir></dir><file name="ProductController.php" hash="e4143728ae23fc9eddc88340fb67a604"/><file name="UnsubscribeController.php" hash="894d93a2d1abed032a38c0460ceff3a5"/></dir><dir name="cron"><file name="clearCopernicaDatabase.php" hash="8c4241ffab642db16749281d51314564"/><file name="detectAbandonedCarts.php" hash="b5d2243d2ac84a1b51572a087f9ddeb7"/><file name="fullSync.php" hash="5c578a08ad40e9a01794ef69dbc16c01"/><file name="processQueue.php" hash="05ddb7bf941860b01b307a5fdf164925"/></dir><dir name="data"><dir name="marketingsoftware_setup"><file name="data-upgrade-3.4.0-3.4.1.php" hash="efa8cff5993e7fdc9675dd1f4bfa7610"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="2d8b3fa480311b7784152bcfaeb47c40"/><file name="config.xml" hash="28fd9f5d20a16e365353013833ae5962"/></dir><dir name="sql"><dir name="marketingsoftware_setup"><file name="mysql4-install-1.2.0.php" hash="edaa8a4c29da5a0bb4f5c06e92c4a6e5"/><file name="mysql4-upgrade-1.1.5-1.1.6.php" hash="4902356c13309b6415e1a61c3fcc805c"/><file name="mysql4-upgrade-1.1.6-1.1.7.php" hash="1bfa357933494cbded4c32f4d1d0a45c"/><file name="mysql4-upgrade-1.1.7-1.1.8.php" hash="860e3ce11771bd8e6f7c755f2afa8805"/><file name="mysql4-upgrade-1.1.8-1.2.0.php" hash="42db3d71333deb7430cdbbafb56e80c1"/><file name="mysql4-upgrade-2.0.1-2.0.2.php" hash="5374760e8bee6edb033475cd0cf8fd0a"/><file name="mysql4-upgrade-2.1.0.1-2.2.0.php" hash="83135bd0c7a7d9f15496654b0374d2bb"/><file name="mysql4-upgrade-2.2.0.1-2.3.0.php" hash="c7e1e82357c9e12a553e8adead231a48"/><file name="mysql4-upgrade-2.3.0-2.3.1.php" hash="8b50dd866977ee4f356ded37a2d2b3c3"/><file name="mysql4-upgrade-2.3.1-2.3.2.php" hash="b575862a68ab89511759c193e16200ba"/><file name="mysql4-upgrade-2.3.2-2.3.3.php" hash="d3c0e021d677d4d76d55760ae323e6af"/><file name="mysql4-upgrade-2.3.3-2.3.4.php" hash="5594882bfddb009d097ce00080df5a05"/><file name="mysql4-upgrade-2.3.4-2.3.5.php" hash="ac7c8e8d2b8d9d1c6a6398815aa4218b"/><file name="mysql4-upgrade-2.3.8-2.4.0.php" hash="a1ec382dba74745c7410b4243507e86f"/><file name="mysql4-upgrade-2.4.0-2.4.1.php" hash="589e40f7456b2f86558808e2c0b41ee9"/><file name="mysql4-upgrade-2.4.1-2.4.2.php" hash="87e94e7504bed6bae3065b78dc6c70bf"/><file name="mysql4-upgrade-2.4.2-2.4.3.php" hash="4a3de330af01de1deb618a0adab4ea8f"/><file name="mysql4-upgrade-2.4.3-2.4.4.php" hash="d24bbe6f6cc4b36fccee6461eb9f3d19"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Copernica_MarketingSoftware.xml" hash="1d3e901ef934e74a837d779f815882d0"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="marketingsoftware"><file name="export.phtml" hash="8b32b8e0098fa4d469fff888cbc269ea"/><file name="link.phtml" hash="082b2cd50664248f9fc0e03089268604"/><file name="settings.phtml" hash="c7186b4f1ad83e27d61997400bb43c7f"/><file name="sync.phtml" hash="ec3749674fab02f124bbc55d618a28e8"/></dir></dir></dir></dir></dir></target><target name="mageweb"><dir name="js"><dir name="copernica"><dir name="marketingsoftware"><file name="link.js" hash="ff7769cc28e6f1220b52321ec8ffb5a3"/></dir></dir></dir></target></contents>
21
  <compatible/>
22
  <dependencies><required><php><min>5.2.0</min><max>5.4.99</max></php><extension><name>PDO</name><min></min><max></max></extension></required></dependencies>
23
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Copernica_MarketingSoftware</name>
4
+ <version>3.0.1</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL 3.0)</license>
7
  <channel>community</channel>
10
  <description>When you install the integration, all contact, order and shop cart data from Magento will be automatically synchronized and stored in Copernica. By synchronizing data between your Magento webshop and Copernica, you are able to set up targeted email campaigns. For example you can consider emailing customers with abandoned shopcarts automatically every week. Your contacts will only receive information relevant to them, which will make them come back to your shop time and again. The available integration is also compatible with the Magento Enterprise edition.&#xD;
11
  &#xD;
12
  Please note that this extension does not work with PHP 5.4.X. and should be run with the Magento system requirements in mind.</description>
13
+ <notes>- Several bug fixes which have been discovered by verious users in the last release. &#xD;
 
 
14
  </notes>
15
  <authors><author><name>Cream</name><user>creaminternet</user><email>info@cream.nl</email></author></authors>
16
+ <date>2014-11-03</date>
17
+ <time>22:26:13</time>
18
+ <contents><target name="magecommunity"><dir name="Copernica"><dir name="MarketingSoftware"><dir name="Block"><dir name="Adminhtml"><dir name="Marketingsoftware"><file name="Export.php" hash="487cc0386e351c908d5bb2a6aa88c6d7"/><file name="Link.php" hash="d9e39fd2b3bb17017d0ede766fe4c857"/><file name="Settings.php" hash="105197d4382b03fadfa43b5616894bd4"/><file name="Sync.php" hash="f841cc8adcd5aaab0c339e8c3a4532bc"/></dir></dir></dir><dir name="Controller"><file name="Base.php" hash="5a5b8a0121ca6025fdd4707a76e34911"/></dir><file name="Exception.php" hash="ad3646aad8fcf3c678b7cdfa91d651e1"/><dir name="Helper"><file name="Api.php" hash="e5bb4038213a529f09ef8e51812b7877"/><file name="ApiBase.php" hash="58cdf8255a33bf8fb78060afc74430a8"/><file name="ApiBuilder.php" hash="632f066c5664299cc1a4c4e37231f743"/><file name="ApiValidator.php" hash="3e1db1fdbbf9a1e59b9f0222325209ed"/><file name="Config.php" hash="029fa7e372c67e6ad2d9cf97c4784782"/><file name="Data.php" hash="b6cdfe5ddbc2f467b446690511435727"/><file name="DataWriter.php" hash="af3bba3409fba39320f99e83a34fc44c"/><file name="Profile.php" hash="bb6ab328045fb12319de467ce9c7b2ae"/><file name="RESTRequest.php" hash="3637be80e677c7bf7da8bcc7ffccecf9"/></dir><dir name="Model"><file name="AbandonedCart.php" hash="51f3f1478a89de28ee253d9f94b3196c"/><file name="AbandonedCartsProcessor.php" hash="9cc44c9eaedabe38ef7860945d46c062"/><dir name="Abstraction"><file name="Address.php" hash="57e6404f732bb0b831e1498f28ac464c"/><file name="Attributes.php" hash="ac06dfb53f78e5210e12bc1f68cbb18e"/><file name="Customer.php" hash="e84dc90ae63c296641ed30119537a489"/><file name="Name.php" hash="a2edffc4a77440e2b7df7cefb0b43583"/><dir name="Order"><dir name="Item"><file name="Options.php" hash="806711e5c0303cedfc724ce02868c85d"/></dir><file name="Item.php" hash="366055e71f98f47ec329b070aacfe518"/></dir><file name="Order.php" hash="7cff6f7e9c3aebac647e35d2ebb99c66"/><file name="Price.php" hash="e48a7323579b230cf6dd487041784e08"/><file name="Product.php" hash="556476f42785f5554698da09567581c0"/><dir name="Quote"><dir name="Item"><file name="Options.php" hash="f836a70b98c345975ad8d91e6ef88d3f"/></dir><file name="Item.php" hash="c56b80f5bfb17051b42eff127b58b94d"/></dir><file name="Quote.php" hash="8df90763d3685b755a080691b06bca7d"/><file name="Storeview.php" hash="68664c1717bc95ff41765f94f48610d2"/><file name="Subscription.php" hash="7b163f295803d391557c22572ff81850"/><file name="Viewedproduct.php" hash="1a29f985c6e53d5188639d1a09c24344"/></dir><file name="Config.php" hash="d64086db5762e020049e309062e128f5"/><dir name="Copernica"><file name="Abstract.php" hash="31d026df826a9c8d716bd51388eda480"/><dir name="Address"><file name="Subprofile.php" hash="23367765c877ea7968c6b5d58cc21ea9"/></dir><dir name="Cartitem"><file name="Subprofile.php" hash="2cb3eb3f6add77dbd75f69787a9953fb"/></dir><dir name="Entity"><file name="Address.php" hash="0ae0020f4319fc112ddce2d14ceda209"/><file name="CartItem.php" hash="3fcffafcc80de592d81db7a5bfb2317e"/><file name="Customer.php" hash="e846a04aca3b2c81135379d0c2916b4a"/><file name="Item.php" hash="9c6c516a448bde9d36e2dee534a9a9da"/><file name="Order.php" hash="ce02b453677a27b5e65cb8544c7364fa"/><file name="Product.php" hash="feecd138d77c1ccf0bf32d89149fd16b"/><file name="Quote.php" hash="027d60b614f2b4b20a512776b588e853"/><file name="Subscription.php" hash="c58dae96eb1b9e2122fedd8581aad638"/></dir><file name="Entity.php" hash="e3cd012a331f11f0ec984c0937717a0e"/><dir name="Order"><file name="Subprofile.php" hash="3219e6835cccc7be482259576d64a9d4"/></dir><dir name="Orderitem"><file name="Subprofile.php" hash="ee7f2ab5e04fdca847c419b321639333"/></dir><file name="Profile.php" hash="506544ea302cbccd649d82844cb11375"/><file name="Profilecustomer.php" hash="14c61e3e7e4dad65a9f2f62de725c90c"/><file name="Profileorder.php" hash="f3fcf68822e87816b982b9a867503726"/><file name="Profilequote.php" hash="18f8ed2114886bc32911dbe772297f88"/><file name="Profilesubscription.php" hash="67a5d3404363c39b127e23dc9d7b2834"/><dir name="Viewedproduct"><file name="Subprofile.php" hash="b8b9ae88df26d3e18438e17147f77235"/></dir></dir><file name="ErrorQueue.php" hash="c85c754ce859704717913c9f8e9c8588"/><dir name="Mysql4"><dir name="AbandonedCart"><file name="Collection.php" hash="e72b2d443f5c009c29a86cf90ff53421"/></dir><file name="AbandonedCart.php" hash="ec9371ec8c58d550927f31ed1d565d68"/><dir name="Config"><file name="Collection.php" hash="ef43ccb80fd1b415c9a42ee133f80530"/></dir><file name="Config.php" hash="f71bbcca4066b9092700b5f8581cebfd"/><dir name="ErrorQueue"><file name="Collection.php" hash="ca34b0d7540914ae17951722adfa565c"/></dir><file name="ErrorQueue.php" hash="802920824d781f0aec913ef451b8393d"/><dir name="ProfileCache"><file name="Collection.php" hash="593426fd7ca9db0a8ae0e2093a89e2aa"/></dir><file name="ProfileCache.php" hash="a7236486592fe28548a0a30b0bfa6060"/><dir name="Queue"><file name="Collection.php" hash="529d1a0b0f741b5502cee205b6a974e6"/></dir><file name="Queue.php" hash="6290f87f7fbb03155665e237a50176c3"/><dir name="SyncProfile"><file name="Collection.php" hash="33e76bc39467b0093a7a77da44eef966"/></dir><file name="SyncProfile.php" hash="1ac7cbd0ea721dd80b7f35b864f6dc0a"/></dir><file name="Observer.php" hash="13a25b8f0d91f35ea29d5c0277c2857f"/><file name="ProfileCache.php" hash="6f228e87a3d430b654d1337285317083"/><file name="Queue.php" hash="48a6eeafa120dfdb39e5fb0601f15270"/><dir name="QueueEvent"><file name="Abstract.php" hash="666e449669bde675a77ebe27f38edb28"/><file name="Checkout.php" hash="524edeac5cb4023e105660992913f638"/><file name="Customer.php" hash="26f501661ad98905dc6fb6eee61612cd"/><file name="CustomerAdd.php" hash="1754e3cb0ef651fc33b7708daf25dc96"/><file name="CustomerFull.php" hash="36708490c408197fefbd1971ea7c1e37"/><file name="CustomerModify.php" hash="fcaec6161ce09f2548fd55f950d4b374"/><file name="CustomerRemove.php" hash="f65b6eb43b1340758fc190d06feabb7a"/><file name="CustomerUpgrade.php" hash="4af755a621195c0ef0dacf6eab88436c"/><file name="Factory.php" hash="a98bde41d9d3666573d4ded6d4143ed7"/><file name="Item.php" hash="b1271f745ee5b249d036881eddb10021"/><file name="Order.php" hash="bba1f7fe5457a4d0ddacb6656b687076"/><file name="OrderAdd.php" hash="34f2af84d5a1dbe2cded9c04b9ebed8d"/><file name="OrderModify.php" hash="2a8d3aeb200d22455aff15ad41f4b4aa"/><file name="Quote.php" hash="e8fec3ebe3264b0b0ee2da62fb90b2ce"/><file name="QuoteItem.php" hash="fc4bd84522a3d581ad5fde799748b9a2"/><file name="QuoteItemAdd.php" hash="ebcce56922150d281d02c41440bf0222"/><file name="QuoteItemModify.php" hash="113a7edee4d41ac1a6d2a0d4b9128850"/><file name="QuoteItemRemove.php" hash="d6c7fa98a137b7b13837214ae2e4132c"/><file name="QuoteModify.php" hash="9f6cc8bf0cb6679cab8c7121f1fbf7a2"/><file name="StartSync.php" hash="1c6fdb53acaf8e4729978f3bbe18536a"/><file name="Subscription.php" hash="09eba1cffe0b0fe341b2d6a67e444ee0"/><file name="SubscriptionAdd.php" hash="c9609ae3f3bbd03a842ff28175ecc5fe"/><file name="SubscriptionModify.php" hash="d61f5c0d8c15ffe377c0e3cd99db61a0"/><file name="SubscriptionRemove.php" hash="c6d79f1748025edf714d25128f299937"/><file name="View.php" hash="ae2e7e3e7638793779a275dc8a525d09"/><file name="ViewedProductAdd.php" hash="822e17d7fc86e65c3d107e6df1aaecba"/></dir><file name="QueueProcessor.php" hash="03ad8614260b2620209bfc742cea88ba"/><dir name="REST"><file name="Address.php" hash="8f189ab2e708e652adf6b1c3b61ab2b7"/><file name="CartItem.php" hash="4b8ac947cf1bdc9157499f722c881ef2"/><file name="Customer.php" hash="a76b90a87373b79ac87c0323ec4d3aa2"/><file name="Item.php" hash="9c3fc8c093bb11ea1efe386f63eeac8a"/><file name="Order.php" hash="f16add67f9bbc0ab26da435c8c3cf611"/><file name="Product.php" hash="f1a9e7bd1f0ed441db70177dd625d198"/><file name="Quote.php" hash="5fc78607e82f4696f1b8233af38ecc49"/><file name="Subscription.php" hash="dadd94f50786f597e85bb95b3cae6d0c"/></dir><file name="REST.php" hash="ec324f180c9e55ab0881d3393ff5aee3"/><file name="SyncProfile.php" hash="e1a9b4f71fea54b6c16a56b95f00ab4f"/><file name="SyncStatus.php" hash="365118aa88448b87a7b9c3253e5368e6"/></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Marketingsoftware"><file name="AjaxcollectionController.php" hash="b423ee19fc7b4c91baa03e34654de730"/><file name="ExportController.php" hash="2deaf4c0184548b968f07d9e85aa3b16"/><file name="LinkController.php" hash="a7a42801f55dd644a9aa8521219c94cd"/><file name="SettingsController.php" hash="0a925ef070eb1e18d330bd29baf62cc0"/><file name="SyncController.php" hash="cd978f2fa07a5dd164c60ca2b20b1eec"/></dir></dir><file name="ProductController.php" hash="e4143728ae23fc9eddc88340fb67a604"/><file name="UnsubscribeController.php" hash="894d93a2d1abed032a38c0460ceff3a5"/></dir><dir name="cron"><file name="clearCopernicaDatabase.php" hash="8c4241ffab642db16749281d51314564"/><file name="detectAbandonedCarts.php" hash="b5d2243d2ac84a1b51572a087f9ddeb7"/><file name="fullSync.php" hash="5c578a08ad40e9a01794ef69dbc16c01"/><file name="processQueue.php" hash="05ddb7bf941860b01b307a5fdf164925"/></dir><dir name="data"><dir name="marketingsoftware_setup"><file name="data-upgrade-3.4.0-3.4.1.php" hash="efa8cff5993e7fdc9675dd1f4bfa7610"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="2d8b3fa480311b7784152bcfaeb47c40"/><file name="config.xml" hash="9c014d99c3fb49a30b564e7ab9a860ef"/></dir><dir name="sql"><dir name="marketingsoftware_setup"><file name="mysql4-install-1.2.0.php" hash="edaa8a4c29da5a0bb4f5c06e92c4a6e5"/><file name="mysql4-upgrade-1.1.5-1.1.6.php" hash="4902356c13309b6415e1a61c3fcc805c"/><file name="mysql4-upgrade-1.1.6-1.1.7.php" hash="1bfa357933494cbded4c32f4d1d0a45c"/><file name="mysql4-upgrade-1.1.7-1.1.8.php" hash="860e3ce11771bd8e6f7c755f2afa8805"/><file name="mysql4-upgrade-1.1.8-1.2.0.php" hash="42db3d71333deb7430cdbbafb56e80c1"/><file name="mysql4-upgrade-2.0.1-2.0.2.php" hash="5374760e8bee6edb033475cd0cf8fd0a"/><file name="mysql4-upgrade-2.1.0.1-2.2.0.php" hash="83135bd0c7a7d9f15496654b0374d2bb"/><file name="mysql4-upgrade-2.2.0.1-2.3.0.php" hash="c7e1e82357c9e12a553e8adead231a48"/><file name="mysql4-upgrade-2.3.0-2.3.1.php" hash="8b50dd866977ee4f356ded37a2d2b3c3"/><file name="mysql4-upgrade-2.3.1-2.3.2.php" hash="b575862a68ab89511759c193e16200ba"/><file name="mysql4-upgrade-2.3.2-2.3.3.php" hash="d3c0e021d677d4d76d55760ae323e6af"/><file name="mysql4-upgrade-2.3.3-2.3.4.php" hash="5594882bfddb009d097ce00080df5a05"/><file name="mysql4-upgrade-2.3.4-2.3.5.php" hash="ac7c8e8d2b8d9d1c6a6398815aa4218b"/><file name="mysql4-upgrade-2.3.8-2.4.0.php" hash="a1ec382dba74745c7410b4243507e86f"/><file name="mysql4-upgrade-2.4.0-2.4.1.php" hash="589e40f7456b2f86558808e2c0b41ee9"/><file name="mysql4-upgrade-2.4.1-2.4.2.php" hash="87e94e7504bed6bae3065b78dc6c70bf"/><file name="mysql4-upgrade-2.4.2-2.4.3.php" hash="4a3de330af01de1deb618a0adab4ea8f"/><file name="mysql4-upgrade-2.4.3-2.4.4.php" hash="d24bbe6f6cc4b36fccee6461eb9f3d19"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Copernica_MarketingSoftware.xml" hash="1d3e901ef934e74a837d779f815882d0"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="marketingsoftware"><file name="export.phtml" hash="8b32b8e0098fa4d469fff888cbc269ea"/><file name="link.phtml" hash="6a3bbaddb22ca3faba0ae04669a52725"/><file name="settings.phtml" hash="771ab56739000d1a2376b7ca418037ec"/><file name="sync.phtml" hash="ec3749674fab02f124bbc55d618a28e8"/></dir></dir></dir></dir></dir></target><target name="mageweb"><dir name="js"><dir name="copernica"><dir name="marketingsoftware"><file name="link.js" hash="26d1c1d662c24abf913f4ed31b8b3871"/></dir></dir></dir></target></contents>
19
  <compatible/>
20
  <dependencies><required><php><min>5.2.0</min><max>5.4.99</max></php><extension><name>PDO</name><min></min><max></max></extension></required></dependencies>
21
  </package>