Temando_Installer - Version 1.0.4

Version Notes

- Compare version of Temando in a correct way

Download this release

Release Info

Developer Temando
Extension Temando_Installer
Version 1.0.4
Comparing to
See all releases


Code changes from version 1.0.3 to 1.0.4

app/code/community/Temando/Installer/Block/Adminhtml/Installer.php CHANGED
@@ -1,5 +1,10 @@
1
  <?php
2
-
 
 
 
 
 
3
  class Temando_Installer_Block_Adminhtml_Installer extends Mage_Adminhtml_Block_Widget_Grid_Container
4
  {
5
  public function __construct()
@@ -7,7 +12,7 @@ class Temando_Installer_Block_Adminhtml_Installer extends Mage_Adminhtml_Block_W
7
  $this->_blockGroup = 'temandoinstaller';
8
  $this->_controller = 'adminhtml_installer';
9
  $this->_headerText = $this->__('Manage Temando');
10
- $this->_addButtonLabel = $this->__('Install Temando');
11
  // if (Mage::helper('temandoinstaller')->getTemandoVersionNumber()) {
12
  // $this->_addButton('connectionSettings', array(
13
  // 'label' => $this->__('Test Connection Settings'),
@@ -23,5 +28,3 @@ class Temando_Installer_Block_Adminhtml_Installer extends Mage_Adminhtml_Block_W
23
  }
24
  }
25
  }
26
-
27
-
1
  <?php
2
+ /**
3
+ * Adminhtml Installer
4
+ *
5
+ * @package Temando_Installer
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
  class Temando_Installer_Block_Adminhtml_Installer extends Mage_Adminhtml_Block_Widget_Grid_Container
9
  {
10
  public function __construct()
12
  $this->_blockGroup = 'temandoinstaller';
13
  $this->_controller = 'adminhtml_installer';
14
  $this->_headerText = $this->__('Manage Temando');
15
+ $this->_addButtonLabel = $this->__('Install Temando');
16
  // if (Mage::helper('temandoinstaller')->getTemandoVersionNumber()) {
17
  // $this->_addButton('connectionSettings', array(
18
  // 'label' => $this->__('Test Connection Settings'),
28
  }
29
  }
30
  }
 
 
app/code/community/Temando/Installer/Block/Adminhtml/Installer/Grid.php CHANGED
@@ -1,71 +1,81 @@
1
  <?php
2
-
3
- class Temando_Installer_Block_Adminhtml_Installer_Grid extends Mage_Adminhtml_Block_Widget_Grid {
4
-
 
 
 
 
 
5
  public function _construct()
6
  {
7
- parent::_construct();
8
- $this->setDefaultSort('id');
9
  $this->setDefaultDir('DESC');
10
- $this->setSaveParametersInSession(true);
11
  }
12
 
13
- protected function _prepareCollection() {
14
- $collection = Mage::getModel('temandoinstaller/installer')->getCollection();
15
- $this->setCollection($collection);
16
- parent::_prepareCollection();
 
17
  }
18
 
19
- protected function _prepareColumns() {
20
- $this->addColumn('name', array(
21
- 'header' => Mage::helper('temandoinstaller')->__('Name'),
22
- 'index' => 'name',
23
- ));
24
-
25
- $this->addColumn('version', array(
26
- 'header' => Mage::helper('temandoinstaller')->__('Version'),
27
- 'index' => 'version',
28
- ));
29
- $this->addColumn('token', array(
30
- 'header' => Mage::helper('temandoinstaller')->__('Token'),
31
- 'index' => 'token',
32
- ));
33
-
34
- $this->addColumn('install_date', array(
35
- 'header' => Mage::helper('temandoinstaller')->__('Install date'),
36
- 'type' => 'datetime',
37
- 'index' => 'install_date',
38
- ));
39
-
40
- $this->addColumn('update_date', array(
41
- 'header' => Mage::helper('temandoinstaller')->__('Update date'),
42
  'type' => 'datetime',
43
- 'index' => 'update_date',
44
- ));
45
 
46
- $this->addColumn('update_details', array(
47
- 'header' => Mage::helper('temandoinstaller')->__('Update available'),
48
- 'index' => 'update_details',
 
 
 
 
 
 
49
  'filter' => false,
50
- ));
51
-
52
- parent::_prepareColumns();
53
  }
54
 
55
- public function _prepareMassaction() {
56
- parent::_prepareMassaction();
57
- $this->getMassactionBlock()->addItem('uninstall', array(
58
- 'label'=> Mage::helper('temandoinstaller')->__('Uninstall'),
59
- 'url' => $this->getUrl('*/*/uninstall'),
60
- 'confirm' => Mage::helper('temandoinstaller')->__('Are you sure you want to uninstall the Temando module?'),
 
61
  ));
62
- $this->getMassactionBlock()->addItem('update', array(
63
- 'label' => Mage::helper('temandoinstaller')->__('Update'),
64
- 'url' => $this->getUrl('*/*/update'),
 
65
  'confirm' => Mage::helper('temandoinstaller')->__('Are you sure you want to update the Temando module?'),
66
- ));
67
- $this->setMassactionIdField('id');
68
- $this->getMassactionBlock()->setUseSelectAll(false);
 
69
  return $this;
70
  }
71
 
@@ -73,6 +83,4 @@ class Temando_Installer_Block_Adminhtml_Installer_Grid extends Mage_Adminhtml_Bl
73
  {
74
  return;
75
  }
76
-
77
-
78
  }
1
  <?php
2
+ /**
3
+ * Adminhtml Installer Grid
4
+ *
5
+ * @package Temando_Installer
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Installer_Block_Adminhtml_Installer_Grid extends Mage_Adminhtml_Block_Widget_Grid
9
+ {
10
  public function _construct()
11
  {
12
+ parent::_construct();
13
+ $this->setDefaultSort('id');
14
  $this->setDefaultDir('DESC');
15
+ $this->setSaveParametersInSession(true);
16
  }
17
 
18
+ protected function _prepareCollection()
19
+ {
20
+ $collection = Mage::getModel('temandoinstaller/installer')->getCollection();
21
+ $this->setCollection($collection);
22
+ parent::_prepareCollection();
23
  }
24
 
25
+ protected function _prepareColumns()
26
+ {
27
+ $this->addColumn('name', array(
28
+ 'header' => Mage::helper('temandoinstaller')->__('Name'),
29
+ 'index' => 'name',
30
+ ));
31
+
32
+ $this->addColumn('version', array(
33
+ 'header' => Mage::helper('temandoinstaller')->__('Version'),
34
+ 'index' => 'version',
35
+ ));
36
+ $this->addColumn('token', array(
37
+ 'header' => Mage::helper('temandoinstaller')->__('Token'),
38
+ 'index' => 'token',
39
+ ));
40
+
41
+ $this->addColumn('install_date', array(
42
+ 'header' => Mage::helper('temandoinstaller')->__('Install date'),
 
 
 
 
 
43
  'type' => 'datetime',
44
+ 'index' => 'install_date',
45
+ ));
46
 
47
+ $this->addColumn('update_date', array(
48
+ 'header' => Mage::helper('temandoinstaller')->__('Update date'),
49
+ 'type' => 'datetime',
50
+ 'index' => 'update_date',
51
+ ));
52
+
53
+ $this->addColumn('update_details', array(
54
+ 'header' => Mage::helper('temandoinstaller')->__('Update available'),
55
+ 'index' => 'update_details',
56
  'filter' => false,
57
+ ));
58
+
59
+ parent::_prepareColumns();
60
  }
61
 
62
+ public function _prepareMassaction()
63
+ {
64
+ parent::_prepareMassaction();
65
+ $this->getMassactionBlock()->addItem('uninstall', array(
66
+ 'label'=> Mage::helper('temandoinstaller')->__('Uninstall'),
67
+ 'url' => $this->getUrl('*/*/uninstall'),
68
+ 'confirm' => Mage::helper('temandoinstaller')->__('Are you sure you want to uninstall the Temando module?'),
69
  ));
70
+
71
+ $this->getMassactionBlock()->addItem('update', array(
72
+ 'label' => Mage::helper('temandoinstaller')->__('Update'),
73
+ 'url' => $this->getUrl('*/*/update'),
74
  'confirm' => Mage::helper('temandoinstaller')->__('Are you sure you want to update the Temando module?'),
75
+ ));
76
+
77
+ $this->setMassactionIdField('id');
78
+ $this->getMassactionBlock()->setUseSelectAll(false);
79
  return $this;
80
  }
81
 
83
  {
84
  return;
85
  }
 
 
86
  }
app/code/community/Temando/Installer/Block/Adminhtml/Notifications.php CHANGED
@@ -1,5 +1,10 @@
1
  <?php
2
-
 
 
 
 
 
3
  class Temando_Installer_Block_Adminhtml_Notifications extends Mage_Adminhtml_Block_Template
4
  {
5
  public function getModuleNotifications()
@@ -10,5 +15,3 @@ class Temando_Installer_Block_Adminhtml_Notifications extends Mage_Adminhtml_Blo
10
  return $installerModules;
11
  }
12
  }
13
-
14
-
1
  <?php
2
+ /**
3
+ * Adminhtml Notifications
4
+ *
5
+ * @package Temando_Installer
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
  class Temando_Installer_Block_Adminhtml_Notifications extends Mage_Adminhtml_Block_Template
9
  {
10
  public function getModuleNotifications()
15
  return $installerModules;
16
  }
17
  }
 
 
app/code/community/Temando/Installer/Block/Adminhtml/System/Config/Form/Button/Manage.php CHANGED
@@ -1,8 +1,15 @@
1
  <?php
 
 
 
 
 
 
 
 
2
 
3
- class Temando_Installer_Block_Adminhtml_System_Config_Form_Button_Manage extends Mage_Adminhtml_Block_System_Config_Form_Field {
4
-
5
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) {
6
  $this->setElement($element);
7
  $html = $this->getLayout()
8
  ->createBlock('adminhtml/widget_button')
@@ -13,5 +20,4 @@ class Temando_Installer_Block_Adminhtml_System_Config_Form_Button_Manage extends
13
  ->toHtml();
14
  return $html;
15
  }
16
-
17
  }
1
  <?php
2
+ /**
3
+ * Adminhtml System Config Form Button Manage
4
+ *
5
+ * @package Temando_Installer
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Installer_Block_Adminhtml_System_Config_Form_Button_Manage
9
+ extends Mage_Adminhtml_Block_System_Config_Form_Field {
10
 
11
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
12
+ {
 
13
  $this->setElement($element);
14
  $html = $this->getLayout()
15
  ->createBlock('adminhtml/widget_button')
20
  ->toHtml();
21
  return $html;
22
  }
 
23
  }
app/code/community/Temando/Installer/Helper/Data.php CHANGED
@@ -1,17 +1,21 @@
1
  <?php
 
 
 
 
 
 
 
 
2
 
3
- class Temando_Installer_Helper_Data extends Mage_Core_Helper_Abstract {
4
-
5
- const TMD_VERSION_STARTER = '1.0.0';
6
  const TMD_VERSION_PROFFESIONAL = '2.0.0';
7
- const TMD_VERSION_BUSINESS = '3.0.0';
8
  const TMD_VERSION_ENTERPRISE = '4.0.0';
9
-
10
  const TEMANDO_VERSION_STARTER = 'magento-starter';
11
  const TEMANDO_VERSION_PROFESSIONAL = 'magento-professional';
12
  const TEMANDO_VERSION_BUSINESS = 'magento-business';
13
  const TEMANDO_VERSION_ENTERPRISE = 'magento-enterprise';
14
-
15
  const TMD_MODULE_NAME = 'Temando_Temando';
16
 
17
  protected $_tmdVersion = null;
@@ -23,30 +27,30 @@ class Temando_Installer_Helper_Data extends Mage_Core_Helper_Abstract {
23
  */
24
  public function getTemandoVersion()
25
  {
26
- if (!$this->_tmdVersion) {
27
- $version = (string) Mage::getConfig()->getNode()->modules->Temando_Temando->version;
28
- if(version_compare($version, self::TMD_VERSION_PROFFESIONAL, '<')) {
29
- //anything less than 2.0.0
30
- $this->_tmdVersion = self::TMD_VERSION_STARTER;
31
- }
32
- if(version_compare($version, self::TMD_VERSION_PROFFESIONAL, '>=')
33
- && version_compare($version, self::TMD_VERSION_BUSINESS, '<')) {
34
- //equals or greater than 2.0.0 but less then 3.0.0
35
- $this->_tmdVersion = self::TMD_VERSION_PROFFESIONAL;
36
- }
37
- if(version_compare($version, self::TMD_VERSION_BUSINESS, '>=')
38
- && version_compare($version, self::TMD_VERSION_ENTERPRISE, '<')) {
39
- //equals or greater than 2.0.0 but less then 3.0.0
40
- $this->_tmdVersion = self::TMD_VERSION_BUSINESS;
41
- }
42
- if(version_compare($version, self::TMD_VERSION_ENTERPRISE, '>=')) {
43
- $this->_tmdVersion = self::TMD_VERSION_ENTERPRISE;
44
- }
45
- if(!$version) {
46
- $this->_tmdVersion = null;
47
  }
48
- }
49
- return $this->_tmdVersion;
 
 
 
 
 
 
50
  }
51
 
52
  /**
@@ -54,21 +58,22 @@ class Temando_Installer_Helper_Data extends Mage_Core_Helper_Abstract {
54
  *
55
  * @param string $field
56
  */
57
- public function getConfigData($field) {
58
- $path = 'temandoinstaller/' . $field;
59
- return Mage::getStoreConfig($path);
 
60
  }
61
 
62
  public function getTemandoVersionName()
63
  {
64
- $versionName = null;
65
  switch ($this->getTemandoVersion()) {
66
- case self::TMD_VERSION_STARTER:
67
  $versionName = 'starter';
68
- break;
69
- case self::TMD_VERSION_PROFFESIONAL:
70
  $versionName = 'professional';
71
- break;
72
  case self::TMD_VERSION_BUSINESS:
73
  $versionName = 'business';
74
  break;
@@ -76,15 +81,14 @@ class Temando_Installer_Helper_Data extends Mage_Core_Helper_Abstract {
76
  $versionName = 'enterprise';
77
  break;
78
  }
79
-
80
  return $versionName;
81
  }
82
 
83
- public function getVersions()
84
  {
85
  return array(
86
- self::TEMANDO_VERSION_STARTER,
87
- self::TEMANDO_VERSION_PROFESSIONAL,
88
  self::TEMANDO_VERSION_BUSINESS,
89
  self::TEMANDO_VERSION_ENTERPRISE);
90
  }
@@ -109,7 +113,7 @@ class Temando_Installer_Helper_Data extends Mage_Core_Helper_Abstract {
109
 
110
  public function getTemandoModuleName()
111
  {
112
- return self::TMD_MODULE_NAME;
113
  }
114
 
115
  public function getTemandoToken()
@@ -117,17 +121,18 @@ class Temando_Installer_Helper_Data extends Mage_Core_Helper_Abstract {
117
  return $this->getConfigData('general/token');
118
  }
119
 
120
- public function getTemandoWarehouses()
121
  {
122
  return Mage::getResourceModel('temando/warehouse_collection');
123
  }
124
 
125
- public function getTemandoRules()
126
  {
127
  return Mage::getResourceModel('temando/rule_collection');
128
  }
129
 
130
- public function testAccountDetails() {
 
131
  try {
132
  $api = $this->connect();
133
  $result = $api->getLocations(array('clientId' => Mage::helper('temando')->getClientId()));
@@ -169,16 +174,18 @@ class Temando_Installer_Helper_Data extends Mage_Core_Helper_Abstract {
169
  public function loadCheapestQuote()
170
  {
171
  //get first origin location
172
- $origins = $this->getTemandoWarehouses();
173
  foreach ($origins as $origin) {
174
  continue;
175
  }
176
 
177
- if(!$origin) { return null; }
178
- /* @var $origin Temando_Temando_Model_Warehouse */
 
 
179
  $allowed_carriers = explode(',', Mage::getStoreConfig('carriers/temando/allowed_methods'));
180
- $request = Mage::getModel('temando/api_request');
181
- /* @var $request Temando_Temando_Model_Api_Request */
182
 
183
  switch ($this->getTemandoVersion()) {
184
  case self::TMD_VERSION_BUSINESS:
@@ -192,20 +199,22 @@ class Temando_Installer_Helper_Data extends Mage_Core_Helper_Abstract {
192
  break;
193
  }
194
 
195
- $request
196
  ->setMagentoQuoteId(100000000 + mt_rand(0, 100000))
197
  ->setDestination(
198
  'AU',
199
  '2000',
200
  'SYDNEY',
201
- '123 Pitt Street')
202
- ->setOrigin($origin->getName())
 
 
203
  ->setItems($this->getTestBox())
204
  ->setReady()
205
  ->setAllowedCarriers($allowed_carriers);
206
 
207
- $quotes = $request->getQuotes()->getItems();
208
- return Mage::helper('temando/functions')->getCheapestQuote($quotes);
209
  }
210
 
211
  /**
@@ -232,7 +241,7 @@ class Temando_Installer_Helper_Data extends Mage_Core_Helper_Abstract {
232
  return array($box);
233
  }
234
 
235
- protected function getTemandoProfile()
236
  {
237
  return array(
238
  'sandbox' => Mage::helper('temando')->getConfigData('general/sandbox'),
@@ -240,7 +249,6 @@ class Temando_Installer_Helper_Data extends Mage_Core_Helper_Abstract {
240
  'username' => Mage::helper('temando')->getConfigData('general/username'),
241
  'password' => Mage::helper('temando')->getConfigData('general/password'),
242
  'payment' => Mage::helper('temando')->getConfigData('general/payment_type'),
243
- );
244
  }
245
-
246
- }
1
  <?php
2
+ /**
3
+ * Helper Data
4
+ *
5
+ * @package Temando_Installer
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Installer_Helper_Data extends Mage_Core_Helper_Abstract
9
+ {
10
 
11
+ const TMD_VERSION_STARTER = '1.0.0';
 
 
12
  const TMD_VERSION_PROFFESIONAL = '2.0.0';
13
+ const TMD_VERSION_BUSINESS = '3.0.0';
14
  const TMD_VERSION_ENTERPRISE = '4.0.0';
 
15
  const TEMANDO_VERSION_STARTER = 'magento-starter';
16
  const TEMANDO_VERSION_PROFESSIONAL = 'magento-professional';
17
  const TEMANDO_VERSION_BUSINESS = 'magento-business';
18
  const TEMANDO_VERSION_ENTERPRISE = 'magento-enterprise';
 
19
  const TMD_MODULE_NAME = 'Temando_Temando';
20
 
21
  protected $_tmdVersion = null;
27
  */
28
  public function getTemandoVersion()
29
  {
30
+ if (!$this->_tmdVersion) {
31
+ $version = (string) Mage::getConfig()->getNode()->modules->Temando_Temando->version;
32
+ if (version_compare($version, self::TMD_VERSION_PROFFESIONAL, '<')) {
33
+ //anything less than 2.0.0
34
+ $this->_tmdVersion = self::TMD_VERSION_STARTER;
35
+ }
36
+ if (version_compare($version, self::TMD_VERSION_PROFFESIONAL, '>=')
37
+ && version_compare($version, self::TMD_VERSION_BUSINESS, '<')) {
38
+ //equals or greater than 2.0.0 but less then 3.0.0
39
+ $this->_tmdVersion = self::TMD_VERSION_PROFFESIONAL;
40
+ }
41
+ if (version_compare($version, self::TMD_VERSION_BUSINESS, '>=')
42
+ && version_compare($version, self::TMD_VERSION_ENTERPRISE, '<')) {
43
+ //equals or greater than 2.0.0 but less then 3.0.0
44
+ $this->_tmdVersion = self::TMD_VERSION_BUSINESS;
 
 
 
 
 
 
45
  }
46
+ if (version_compare($version, self::TMD_VERSION_ENTERPRISE, '>=')) {
47
+ $this->_tmdVersion = self::TMD_VERSION_ENTERPRISE;
48
+ }
49
+ if (!$version) {
50
+ $this->_tmdVersion = null;
51
+ }
52
+ }
53
+ return $this->_tmdVersion;
54
  }
55
 
56
  /**
58
  *
59
  * @param string $field
60
  */
61
+ public function getConfigData($field)
62
+ {
63
+ $path = 'temandoinstaller/' . $field;
64
+ return Mage::getStoreConfig($path);
65
  }
66
 
67
  public function getTemandoVersionName()
68
  {
69
+ $versionName = null;
70
  switch ($this->getTemandoVersion()) {
71
+ case self::TMD_VERSION_STARTER:
72
  $versionName = 'starter';
73
+ break;
74
+ case self::TMD_VERSION_PROFFESIONAL:
75
  $versionName = 'professional';
76
+ break;
77
  case self::TMD_VERSION_BUSINESS:
78
  $versionName = 'business';
79
  break;
81
  $versionName = 'enterprise';
82
  break;
83
  }
 
84
  return $versionName;
85
  }
86
 
87
+ public function getVersions()
88
  {
89
  return array(
90
+ self::TEMANDO_VERSION_STARTER,
91
+ self::TEMANDO_VERSION_PROFESSIONAL,
92
  self::TEMANDO_VERSION_BUSINESS,
93
  self::TEMANDO_VERSION_ENTERPRISE);
94
  }
113
 
114
  public function getTemandoModuleName()
115
  {
116
+ return self::TMD_MODULE_NAME;
117
  }
118
 
119
  public function getTemandoToken()
121
  return $this->getConfigData('general/token');
122
  }
123
 
124
+ public function getTemandoWarehouses()
125
  {
126
  return Mage::getResourceModel('temando/warehouse_collection');
127
  }
128
 
129
+ public function getTemandoRules()
130
  {
131
  return Mage::getResourceModel('temando/rule_collection');
132
  }
133
 
134
+ public function testAccountDetails()
135
+ {
136
  try {
137
  $api = $this->connect();
138
  $result = $api->getLocations(array('clientId' => Mage::helper('temando')->getClientId()));
174
  public function loadCheapestQuote()
175
  {
176
  //get first origin location
177
+ $origins = $this->getTemandoWarehouses();
178
  foreach ($origins as $origin) {
179
  continue;
180
  }
181
 
182
+ if (!$origin) {
183
+ return null;
184
+ }
185
+ /* @var $origin Temando_Temando_Model_Warehouse */
186
  $allowed_carriers = explode(',', Mage::getStoreConfig('carriers/temando/allowed_methods'));
187
+ $request = Mage::getModel('temando/api_request');
188
+ /* @var $request Temando_Temando_Model_Api_Request */
189
 
190
  switch ($this->getTemandoVersion()) {
191
  case self::TMD_VERSION_BUSINESS:
199
  break;
200
  }
201
 
202
+ $request
203
  ->setMagentoQuoteId(100000000 + mt_rand(0, 100000))
204
  ->setDestination(
205
  'AU',
206
  '2000',
207
  'SYDNEY',
208
+ '123 Pitt Street'
209
+ )
210
+
211
+ ->setOrigin($origin->getName())
212
  ->setItems($this->getTestBox())
213
  ->setReady()
214
  ->setAllowedCarriers($allowed_carriers);
215
 
216
+ $quotes = $request->getQuotes()->getItems();
217
+ return Mage::helper('temando/functions')->getCheapestQuote($quotes);
218
  }
219
 
220
  /**
241
  return array($box);
242
  }
243
 
244
+ protected function getTemandoProfile()
245
  {
246
  return array(
247
  'sandbox' => Mage::helper('temando')->getConfigData('general/sandbox'),
249
  'username' => Mage::helper('temando')->getConfigData('general/username'),
250
  'password' => Mage::helper('temando')->getConfigData('general/password'),
251
  'payment' => Mage::helper('temando')->getConfigData('general/payment_type'),
252
+ );
253
  }
254
+ }
 
app/code/community/Temando/Installer/Model/Api/Rest/Client.php CHANGED
@@ -1,8 +1,12 @@
1
  <?php
2
  /**
 
 
 
 
3
  * @method StdClass getLastResponse()
4
  */
5
- class Temando_Installer_Model_Api_Rest_Client
6
  extends Mage_Core_Model_Abstract {
7
 
8
  /**
@@ -27,55 +31,55 @@ class Temando_Installer_Model_Api_Rest_Client
27
  public function _construct()
28
  {
29
  parent::_construct();
30
- $this->_prepareClient();
31
  }
32
 
33
 
34
  public function getService($request, $jsonDecode = true)
35
  {
36
- if (!$this->_validate($request)) {
37
- return false;
38
- }
39
- try {
40
  if ($jsonDecode) {
41
  $this->_client
42
  ->setHeaders(array('Authorization' => 'Bearer ' . $this->_token))
43
  ->setUri($this->_uri);
44
  } else {
45
- $this->_client
46
  ->setUri($this->_uri . '?access_token=' . $this->_token);
47
  }
48
 
49
- /**
50
- * Getting response via raw body and decoding coz of a bug in Zend yielding
51
- * exception when ->getBody() is used to decode and return response
52
- */
53
 
54
- $rawBody = $this->_client->request(Varien_Http_Client::GET)->getRawBody();
55
-
56
  if ($jsonDecode) {
57
  $response = Mage::helper('core')->jsonDecode($rawBody, Zend_Json::TYPE_OBJECT);
58
  } else {
59
  $response = $rawBody;
60
  }
61
 
62
- if ($this->_client->getLastResponse()->getStatus() == 200 && count($response)) {
63
  //all good
64
- } else {
65
- Mage::logException(new Exception($this->_client->getLastResponse()));
66
  Mage::log($this->_client->getLastRequest(), null, 'tmd-http-request.log', true);
67
  Mage::log($this->_client->getLastResponse(), null, 'tmd-http-response.log', true);
68
- }
69
- return $response;
70
-
71
- } catch (Exception $e) {
72
- Mage::logException($e);
73
- if (!$this->_sandbox) {
74
- Mage::log($this->_client->getLastRequest(), null, 'tmd-http-request.log', true);
75
- Mage::log($this->_client->getLastResponse(), null, 'tmd-http-response.log', true);
76
- }
77
- return false;
78
- }
79
  }
80
 
81
  /**
@@ -85,18 +89,18 @@ class Temando_Installer_Model_Api_Rest_Client
85
  */
86
  protected function _validate($request)
87
  {
88
- if (!$this->_uri) {
89
- $this->_uri = $request['uri'];
90
- }
91
  if (!$this->_uri) {
92
- Mage::logException(new Exception(__CLASS__.': missing request url.'));
93
- return false;
94
- }
 
 
 
95
  if (!$this->_token) {
96
- Mage::logException(new Exception(__CLASS__.': missing authorisation token.'));
97
- return false;
98
- }
99
- return true;
100
  }
101
 
102
  /**
@@ -106,13 +110,12 @@ class Temando_Installer_Model_Api_Rest_Client
106
  */
107
  protected function _prepareClient()
108
  {
109
- if(!$this->_client) {
110
- $this->_client = new Varien_Http_Client();
111
- }
112
- if(!$this->_token) {
113
  $this->_token = Mage::helper('temandoinstaller')->getTemandoToken();
114
  }
115
- return $this;
116
  }
117
-
118
- }
1
  <?php
2
  /**
3
+ * Api Rest Client
4
+ *
5
+ * @package Temando_Installer
6
+ * @author Temando Magento Team <marketing@temando.com>
7
  * @method StdClass getLastResponse()
8
  */
9
+ class Temando_Installer_Model_Api_Rest_Client
10
  extends Mage_Core_Model_Abstract {
11
 
12
  /**
31
  public function _construct()
32
  {
33
  parent::_construct();
34
+ $this->_prepareClient();
35
  }
36
 
37
 
38
  public function getService($request, $jsonDecode = true)
39
  {
40
+ if (!$this->_validate($request)) {
41
+ return false;
42
+ }
43
+ try {
44
  if ($jsonDecode) {
45
  $this->_client
46
  ->setHeaders(array('Authorization' => 'Bearer ' . $this->_token))
47
  ->setUri($this->_uri);
48
  } else {
49
+ $this->_client
50
  ->setUri($this->_uri . '?access_token=' . $this->_token);
51
  }
52
 
53
+ /**
54
+ * Getting response via raw body and decoding coz of a bug in Zend yielding
55
+ * exception when ->getBody() is used to decode and return response
56
+ */
57
 
58
+ $rawBody = $this->_client->request(Varien_Http_Client::GET)->getRawBody();
59
+
60
  if ($jsonDecode) {
61
  $response = Mage::helper('core')->jsonDecode($rawBody, Zend_Json::TYPE_OBJECT);
62
  } else {
63
  $response = $rawBody;
64
  }
65
 
66
+ if ($this->_client->getLastResponse()->getStatus() == 200 && count($response)) {
67
  //all good
68
+ } else {
69
+ Mage::logException(new Exception($this->_client->getLastResponse()));
70
  Mage::log($this->_client->getLastRequest(), null, 'tmd-http-request.log', true);
71
  Mage::log($this->_client->getLastResponse(), null, 'tmd-http-response.log', true);
72
+ }
73
+ return $response;
74
+
75
+ } catch (Exception $e) {
76
+ Mage::logException($e);
77
+ if (!$this->_sandbox) {
78
+ Mage::log($this->_client->getLastRequest(), null, 'tmd-http-request.log', true);
79
+ Mage::log($this->_client->getLastResponse(), null, 'tmd-http-response.log', true);
80
+ }
81
+ return false;
82
+ }
83
  }
84
 
85
  /**
89
  */
90
  protected function _validate($request)
91
  {
 
 
 
92
  if (!$this->_uri) {
93
+ $this->_uri = $request['uri'];
94
+ }
95
+ if (!$this->_uri) {
96
+ Mage::logException(new Exception(__CLASS__.': missing request url.'));
97
+ return false;
98
+ }
99
  if (!$this->_token) {
100
+ Mage::logException(new Exception(__CLASS__.': missing authorisation token.'));
101
+ return false;
102
+ }
103
+ return true;
104
  }
105
 
106
  /**
110
  */
111
  protected function _prepareClient()
112
  {
113
+ if (!$this->_client) {
114
+ $this->_client = new Varien_Http_Client();
115
+ }
116
+ if (!$this->_token) {
117
  $this->_token = Mage::helper('temandoinstaller')->getTemandoToken();
118
  }
119
+ return $this;
120
  }
121
+ }
 
app/code/community/Temando/Installer/Model/Connect.php CHANGED
@@ -1,13 +1,14 @@
1
  <?php
2
-
3
  /**
 
4
  *
 
 
5
  */
6
  class Temando_Installer_Model_Connect extends Mage_Core_Model_Abstract
7
  {
8
-
9
  protected $_config;
10
- protected $_sconfig;
11
  protected $_frontend;
12
 
13
  const DEFAULT_DOWNLOADER_PATH = "downloader";
@@ -48,9 +49,8 @@ class Temando_Installer_Model_Connect extends Mage_Core_Model_Abstract
48
  }
49
  Mage::register('temandoinstaller_errors', $errors);
50
  return false;
51
- }
52
  return true;
53
-
54
  }
55
 
56
  public function uninstall($module)
@@ -61,12 +61,9 @@ class Temando_Installer_Model_Connect extends Mage_Core_Model_Abstract
61
  $cmd->setSconfig($this->_sconfig);
62
  $cmd->setConfigObject($this->_config);
63
  $cmd->setFrontendObject($this->_frontend);
64
-
65
  $package = $this->_sconfig->getPackageObject('community', $module);
66
  $contents = $package->getContents();
67
-
68
  $params = array('community', $module);
69
-
70
  $cmd->run('uninstall', array(), $params);
71
  } catch (Exception $ex) {
72
  Mage::register('temandoinstaller_errors', array('There was an error uninstalling'));
@@ -80,8 +77,7 @@ class Temando_Installer_Model_Connect extends Mage_Core_Model_Abstract
80
  }
81
  Mage::register('temandoinstaller_errors', $errors);
82
  return false;
83
- }
84
-
85
  //clean the directories
86
  $targetPath = rtrim($this->_config->magento_root, "\\/");
87
  foreach ($contents as $file) {
@@ -123,22 +119,22 @@ class Temando_Installer_Model_Connect extends Mage_Core_Model_Abstract
123
 
124
  protected function initialize()
125
  {
126
- if(!$this->_config) {
127
  $this->_config = new Mage_Connect_Config();
128
- $this->_config->magento_root = Mage::getBaseDir().DIRECTORY_SEPARATOR.self::DEFAULT_DOWNLOADER_PATH . DIRECTORY_SEPARATOR.'..';
 
129
  }
130
 
131
  if (!$this->_sconfig) {
132
  $this->_sconfig = new Mage_Connect_Singleconfig(
133
- Mage::getBaseDir() . DIRECTORY_SEPARATOR
134
- . self::DEFAULT_DOWNLOADER_PATH . DIRECTORY_SEPARATOR
135
- . self::DEFAULT_SCONFIG_FILENAME
136
  );
137
  }
138
 
139
- if(!$this->_frontend) {
140
  $this->_frontend = new Mage_Connect_Frontend();
141
  }
142
  }
143
-
144
  }
1
  <?php
 
2
  /**
3
+ * Connect
4
  *
5
+ * @package Temando_Installer
6
+ * @author Temando Magento Team <marketing@temando.com>
7
  */
8
  class Temando_Installer_Model_Connect extends Mage_Core_Model_Abstract
9
  {
 
10
  protected $_config;
11
+ protected $_sconfig;
12
  protected $_frontend;
13
 
14
  const DEFAULT_DOWNLOADER_PATH = "downloader";
49
  }
50
  Mage::register('temandoinstaller_errors', $errors);
51
  return false;
52
+ }
53
  return true;
 
54
  }
55
 
56
  public function uninstall($module)
61
  $cmd->setSconfig($this->_sconfig);
62
  $cmd->setConfigObject($this->_config);
63
  $cmd->setFrontendObject($this->_frontend);
 
64
  $package = $this->_sconfig->getPackageObject('community', $module);
65
  $contents = $package->getContents();
 
66
  $params = array('community', $module);
 
67
  $cmd->run('uninstall', array(), $params);
68
  } catch (Exception $ex) {
69
  Mage::register('temandoinstaller_errors', array('There was an error uninstalling'));
77
  }
78
  Mage::register('temandoinstaller_errors', $errors);
79
  return false;
80
+ }
 
81
  //clean the directories
82
  $targetPath = rtrim($this->_config->magento_root, "\\/");
83
  foreach ($contents as $file) {
119
 
120
  protected function initialize()
121
  {
122
+ if (!$this->_config) {
123
  $this->_config = new Mage_Connect_Config();
124
+ $this->_config->magento_root = Mage::getBaseDir() .
125
+ DIRECTORY_SEPARATOR.self::DEFAULT_DOWNLOADER_PATH . DIRECTORY_SEPARATOR.'..';
126
  }
127
 
128
  if (!$this->_sconfig) {
129
  $this->_sconfig = new Mage_Connect_Singleconfig(
130
+ Mage::getBaseDir() . DIRECTORY_SEPARATOR .
131
+ self::DEFAULT_DOWNLOADER_PATH . DIRECTORY_SEPARATOR .
132
+ self::DEFAULT_SCONFIG_FILENAME
133
  );
134
  }
135
 
136
+ if (!$this->_frontend) {
137
  $this->_frontend = new Mage_Connect_Frontend();
138
  }
139
  }
 
140
  }
app/code/community/Temando/Installer/Model/Cron.php CHANGED
@@ -1,30 +1,31 @@
1
  <?php
2
-
3
  /**
 
 
 
 
 
4
  * Cron job currently for checking updates on the main Temando module
5
  */
6
  class Temando_Installer_Model_Cron extends Mage_Core_Model_Abstract
7
  {
8
-
9
  protected $_helper;
10
 
11
  public function _construct()
12
  {
13
  parent::_construct();
14
  $this->initialize();
15
-
16
  }
17
 
18
  public function checkReleases()
19
  {
20
  $module = Temando_Installer_Helper_Data::TMD_MODULE_NAME;
21
-
22
  $installer = Mage::getModel('temandoinstaller/installer');
23
  /* @var $installer Temando_Installer_Model_Installer */
24
 
25
  //check token
26
  $currentService = $installer->getCurrentService();
27
- if(!$currentService) {
28
  return;
29
  }
30
  //check the latest release
@@ -38,9 +39,7 @@ class Temando_Installer_Model_Cron extends Mage_Core_Model_Abstract
38
  }
39
 
40
  $versionNumber = $currentService->links->software_latest_release->version;
41
-
42
- $updateDetails = 'Temando v' . $versionNumber . ' is available.';
43
-
44
  $installerModules = Mage::getModel('temandoinstaller/installer')->getCollection();
45
  $installerModules->addFieldToFilter('module', $module);
46
  $installerModules->addFieldToFilter('update_available', false);
@@ -52,15 +51,12 @@ class Temando_Installer_Model_Cron extends Mage_Core_Model_Abstract
52
  ->setUpdateDetails($updateDetails)
53
  ->save();
54
  }
55
-
56
  }
57
 
58
  protected function initialize()
59
  {
60
- if(!$this->_helper) {
61
  $this->_helper = Mage::helper('temandoinstaller');
62
  }
63
-
64
  }
65
-
66
  }
1
  <?php
 
2
  /**
3
+ * Cron
4
+ *
5
+ * @package Temando_Installer
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ *
8
  * Cron job currently for checking updates on the main Temando module
9
  */
10
  class Temando_Installer_Model_Cron extends Mage_Core_Model_Abstract
11
  {
 
12
  protected $_helper;
13
 
14
  public function _construct()
15
  {
16
  parent::_construct();
17
  $this->initialize();
 
18
  }
19
 
20
  public function checkReleases()
21
  {
22
  $module = Temando_Installer_Helper_Data::TMD_MODULE_NAME;
 
23
  $installer = Mage::getModel('temandoinstaller/installer');
24
  /* @var $installer Temando_Installer_Model_Installer */
25
 
26
  //check token
27
  $currentService = $installer->getCurrentService();
28
+ if (!$currentService) {
29
  return;
30
  }
31
  //check the latest release
39
  }
40
 
41
  $versionNumber = $currentService->links->software_latest_release->version;
42
+ $updateDetails = 'Temando v' . $versionNumber . ' is available.';
 
 
43
  $installerModules = Mage::getModel('temandoinstaller/installer')->getCollection();
44
  $installerModules->addFieldToFilter('module', $module);
45
  $installerModules->addFieldToFilter('update_available', false);
51
  ->setUpdateDetails($updateDetails)
52
  ->save();
53
  }
 
54
  }
55
 
56
  protected function initialize()
57
  {
58
+ if (!$this->_helper) {
59
  $this->_helper = Mage::helper('temandoinstaller');
60
  }
 
61
  }
 
62
  }
app/code/community/Temando/Installer/Model/Installer.php CHANGED
@@ -1,11 +1,13 @@
1
  <?php
2
-
3
  /**
 
4
  *
 
 
5
  */
6
  class Temando_Installer_Model_Installer extends Mage_Core_Model_Abstract
7
  {
8
- const TEMANDO_FINANCE_API = 'https://finance.temando.com/api/v1/user/subscriptions';
9
 
10
  public function _construct()
11
  {
@@ -22,7 +24,7 @@ class Temando_Installer_Model_Installer extends Mage_Core_Model_Abstract
22
  $request = array();
23
  $request['uri'] = self::TEMANDO_FINANCE_API;
24
  $helper = Mage::helper('temandoinstaller');
25
- /* @var $helper Temando_Installer_Helper_Data */
26
  $api = Mage::getModel('temandoinstaller/api_rest_client');
27
  /* @var $api Temando_Installer_Model_Api_Rest_Client */
28
  $versions = $helper->getVersions();
@@ -59,11 +61,11 @@ class Temando_Installer_Model_Installer extends Mage_Core_Model_Abstract
59
  */
60
  public function downloadPackage($service)
61
  {
62
- if(!isset($service->links->software_latest_release->href)) {
63
  return false;
64
  }
65
  $latestRelease = $this->getLatestRelease($service->links->software_latest_release->href);
66
- if(!isset($latestRelease->raw_url)) {
67
  return false;
68
  }
69
 
@@ -74,7 +76,7 @@ class Temando_Installer_Model_Installer extends Mage_Core_Model_Abstract
74
  $file = 'Temando_Temando.tgz';
75
  $fileTemp = Mage::getBaseDir() . DS . "var/" . uniqid() . $file;
76
 
77
- if(!file_put_contents ($fileTemp, $package)) {
78
  //there is an error saving the file on disk
79
  return false;
80
  } else {
@@ -110,7 +112,7 @@ class Temando_Installer_Model_Installer extends Mage_Core_Model_Abstract
110
  $serviceRequest = array();
111
  $serviceRequest['uri'] = $uri;
112
  $serviceResponse = $serviceApi->getService($serviceRequest);
113
- if(!isset($serviceResponse->services)) {
114
  return;
115
  }
116
  return $serviceResponse->services;
@@ -128,7 +130,7 @@ class Temando_Installer_Model_Installer extends Mage_Core_Model_Abstract
128
  $productRequest = array();
129
  $productRequest['uri'] = $uri;
130
  $productResponse = $serviceApi->getService($productRequest);
131
- if(!isset($productResponse->softwares->software)) {
132
  return;
133
  }
134
  return $productResponse->softwares->software;
@@ -146,7 +148,7 @@ class Temando_Installer_Model_Installer extends Mage_Core_Model_Abstract
146
  $releaseRequest = array();
147
  $releaseRequest['uri'] = $uri;
148
  $releaseResponse = $serviceApi->getService($releaseRequest);
149
- if(!isset($releaseResponse->release)) {
150
  return;
151
  }
152
  return $releaseResponse->release;
@@ -164,7 +166,7 @@ class Temando_Installer_Model_Installer extends Mage_Core_Model_Abstract
164
  $serviceRequest = array();
165
  $serviceRequest['uri'] = $uri;
166
  $serviceResponse = $serviceApi->getService($serviceRequest);
167
- if(!isset($serviceResponse->services->slug)) {
168
  return;
169
  }
170
  return $serviceResponse->services->slug;
@@ -182,7 +184,7 @@ class Temando_Installer_Model_Installer extends Mage_Core_Model_Abstract
182
  $serviceRequest = array();
183
  $serviceRequest['uri'] = $uri;
184
  $serviceResponse = $serviceApi->getService($serviceRequest);
185
- if(!isset($serviceResponse->services->links->software_latest_release->version)) {
186
  return;
187
  }
188
  return $serviceResponse->services->links->software_latest_release->version;
@@ -200,10 +202,9 @@ class Temando_Installer_Model_Installer extends Mage_Core_Model_Abstract
200
  $serviceRequest = array();
201
  $serviceRequest['uri'] = $uri;
202
  $serviceResponse = $serviceApi->getService($serviceRequest);
203
- if(!isset($serviceResponse->services->links->software_latest_release->href)) {
204
  return;
205
  }
206
  return $serviceResponse->services->links->software_latest_release->href;
207
  }
208
-
209
  }
1
  <?php
 
2
  /**
3
+ * Installer
4
  *
5
+ * @package Temando_Installer
6
+ * @author Temando Magento Team <marketing@temando.com>
7
  */
8
  class Temando_Installer_Model_Installer extends Mage_Core_Model_Abstract
9
  {
10
+ const TEMANDO_FINANCE_API = 'https://finance.temando.com/api/v1/user/subscriptions';
11
 
12
  public function _construct()
13
  {
24
  $request = array();
25
  $request['uri'] = self::TEMANDO_FINANCE_API;
26
  $helper = Mage::helper('temandoinstaller');
27
+ /* @var $helper Temando_Installer_Helper_Data */
28
  $api = Mage::getModel('temandoinstaller/api_rest_client');
29
  /* @var $api Temando_Installer_Model_Api_Rest_Client */
30
  $versions = $helper->getVersions();
61
  */
62
  public function downloadPackage($service)
63
  {
64
+ if (!isset($service->links->software_latest_release->href)) {
65
  return false;
66
  }
67
  $latestRelease = $this->getLatestRelease($service->links->software_latest_release->href);
68
+ if (!isset($latestRelease->raw_url)) {
69
  return false;
70
  }
71
 
76
  $file = 'Temando_Temando.tgz';
77
  $fileTemp = Mage::getBaseDir() . DS . "var/" . uniqid() . $file;
78
 
79
+ if (!file_put_contents($fileTemp, $package)) {
80
  //there is an error saving the file on disk
81
  return false;
82
  } else {
112
  $serviceRequest = array();
113
  $serviceRequest['uri'] = $uri;
114
  $serviceResponse = $serviceApi->getService($serviceRequest);
115
+ if (!isset($serviceResponse->services)) {
116
  return;
117
  }
118
  return $serviceResponse->services;
130
  $productRequest = array();
131
  $productRequest['uri'] = $uri;
132
  $productResponse = $serviceApi->getService($productRequest);
133
+ if (!isset($productResponse->softwares->software)) {
134
  return;
135
  }
136
  return $productResponse->softwares->software;
148
  $releaseRequest = array();
149
  $releaseRequest['uri'] = $uri;
150
  $releaseResponse = $serviceApi->getService($releaseRequest);
151
+ if (!isset($releaseResponse->release)) {
152
  return;
153
  }
154
  return $releaseResponse->release;
166
  $serviceRequest = array();
167
  $serviceRequest['uri'] = $uri;
168
  $serviceResponse = $serviceApi->getService($serviceRequest);
169
+ if (!isset($serviceResponse->services->slug)) {
170
  return;
171
  }
172
  return $serviceResponse->services->slug;
184
  $serviceRequest = array();
185
  $serviceRequest['uri'] = $uri;
186
  $serviceResponse = $serviceApi->getService($serviceRequest);
187
+ if (!isset($serviceResponse->services->links->software_latest_release->version)) {
188
  return;
189
  }
190
  return $serviceResponse->services->links->software_latest_release->version;
202
  $serviceRequest = array();
203
  $serviceRequest['uri'] = $uri;
204
  $serviceResponse = $serviceApi->getService($serviceRequest);
205
+ if (!isset($serviceResponse->services->links->software_latest_release->href)) {
206
  return;
207
  }
208
  return $serviceResponse->services->links->software_latest_release->href;
209
  }
 
210
  }
app/code/community/Temando/Installer/Model/Mysql4/Installer.php CHANGED
@@ -1,11 +1,14 @@
1
  <?php
2
-
 
 
 
 
 
3
  class Temando_Installer_Model_Mysql4_Installer extends Mage_Core_Model_Mysql4_Abstract
4
  {
5
-
6
  public function _construct()
7
  {
8
  $this->_init('temandoinstaller/installer', 'id');
9
  }
10
-
11
  }
1
  <?php
2
+ /**
3
+ * Mysql4 Installer
4
+ *
5
+ * @package Temando_Installer
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
  class Temando_Installer_Model_Mysql4_Installer extends Mage_Core_Model_Mysql4_Abstract
9
  {
 
10
  public function _construct()
11
  {
12
  $this->_init('temandoinstaller/installer', 'id');
13
  }
 
14
  }
app/code/community/Temando/Installer/Model/Mysql4/Installer/Collection.php CHANGED
@@ -1,8 +1,12 @@
1
  <?php
2
-
 
 
 
 
 
3
  class Temando_Installer_Model_Mysql4_Installer_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
4
  {
5
-
6
  public function _construct()
7
  {
8
  parent::_construct();
1
  <?php
2
+ /**
3
+ * Mysql4 Installer Collection
4
+ *
5
+ * @package Temando_Installer
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
  class Temando_Installer_Model_Mysql4_Installer_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
9
  {
 
10
  public function _construct()
11
  {
12
  parent::_construct();
app/code/community/Temando/Installer/Model/Tester.php CHANGED
@@ -1,18 +1,18 @@
1
  <?php
2
-
3
  /**
 
4
  *
 
 
5
  */
6
  class Temando_Installer_Model_Tester extends Mage_Core_Model_Abstract
7
  {
8
-
9
  protected $_helper;
10
 
11
  public function _construct()
12
  {
13
  parent::_construct();
14
  $this->initialize();
15
-
16
  }
17
 
18
  public function testSettings()
@@ -20,56 +20,75 @@ class Temando_Installer_Model_Tester extends Mage_Core_Model_Abstract
20
  $tables = $this->checkTemandoSchema();
21
  $details = $this->testClientDetails();
22
 
23
- if(!$tables || !$details) {
24
- Mage::getSingleton('adminhtml/session')->addError(Mage::helper('temandoinstaller')->__('Could not complete get quotes test.'));
 
 
25
  } else {
26
  $quotes = $this->testGetQuotes();
27
  }
28
  return;
29
  }
30
 
31
- protected function testGetQuotes() {
 
32
  try {
33
- $result = $this->_helper->loadCheapestQuote();
34
- if($result) {
35
- Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('temandoinstaller')->__('Cheapest quote: %s', $result->getDescription()));
 
 
36
  }
37
  } catch (Exception $e) {
38
- Mage::getSingleton('adminhtml/session')->addError(Mage::helper('temandoinstaller')->__('Error connecting to the api: %s', $e->getMessage()));
 
 
39
  }
40
  return;
41
  }
42
 
43
- public function testClientDetails() {
 
44
  $result = $this->_helper->testAccountDetails();
45
- if(!$result) {
46
- Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('temandoinstaller')->__('API Connection successful!'));
 
 
47
  return true;
48
  } else {
49
- Mage::getSingleton('adminhtml/session')->addError(Mage::helper('temandoinstaller')->__('Error connecting to the api: %s', $result));
 
 
50
  return false;
51
  }
52
-
53
  }
54
 
55
  public function checkTemandoSchema()
56
  {
57
  $tableError = 0;
58
- if(!$this->checkTemandoWarehouse()) {
59
- Mage::getSingleton('adminhtml/session')->addNotice(Mage::helper('temandoinstaller')->__('Please add a warehouse to locations.'));
 
 
60
  $tableError++;
61
  } else {
62
- Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('temandoinstaller')->__('Warehouses: %s', $this->checkTemandoWarehouse()));
 
 
63
  }
64
- if(!$this->checkTemandoRule()) {
65
- Mage::getSingleton('adminhtml/session')->addNotice(Mage::helper('temandoinstaller')->__('Please add a rule to the rule engine.'));
 
 
66
  $tableError++;
67
  } else {
68
- Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('temandoinstaller')->__('Rules: %s', $this->checkTemandoRule()));
 
 
69
  }
70
- if($tableError == 0) {
71
  return true;
72
- } else {
73
  return false;
74
  }
75
  }
@@ -96,9 +115,8 @@ class Temando_Installer_Model_Tester extends Mage_Core_Model_Abstract
96
 
97
  protected function initialize()
98
  {
99
- if(!$this->_helper) {
100
  $this->_helper = Mage::helper('temandoinstaller');
101
  }
102
  }
103
-
104
  }
1
  <?php
 
2
  /**
3
+ * Tester
4
  *
5
+ * @package Temando_Installer
6
+ * @author Temando Magento Team <marketing@temando.com>
7
  */
8
  class Temando_Installer_Model_Tester extends Mage_Core_Model_Abstract
9
  {
 
10
  protected $_helper;
11
 
12
  public function _construct()
13
  {
14
  parent::_construct();
15
  $this->initialize();
 
16
  }
17
 
18
  public function testSettings()
20
  $tables = $this->checkTemandoSchema();
21
  $details = $this->testClientDetails();
22
 
23
+ if (!$tables || !$details) {
24
+ Mage::getSingleton('adminhtml/session')->addError(
25
+ Mage::helper('temandoinstaller')->__('Could not complete get quotes test.')
26
+ );
27
  } else {
28
  $quotes = $this->testGetQuotes();
29
  }
30
  return;
31
  }
32
 
33
+ protected function testGetQuotes()
34
+ {
35
  try {
36
+ $result = $this->_helper->loadCheapestQuote();
37
+ if ($result) {
38
+ Mage::getSingleton('adminhtml/session')->addSuccess(
39
+ Mage::helper('temandoinstaller')->__('Cheapest quote: %s', $result->getDescription())
40
+ );
41
  }
42
  } catch (Exception $e) {
43
+ Mage::getSingleton('adminhtml/session')->addError(
44
+ Mage::helper('temandoinstaller')->__('Error connecting to the api: %s', $e->getMessage())
45
+ );
46
  }
47
  return;
48
  }
49
 
50
+ public function testClientDetails()
51
+ {
52
  $result = $this->_helper->testAccountDetails();
53
+ if (!$result) {
54
+ Mage::getSingleton('adminhtml/session')->addSuccess(
55
+ Mage::helper('temandoinstaller')->__('API Connection successful!')
56
+ );
57
  return true;
58
  } else {
59
+ Mage::getSingleton('adminhtml/session')->addError(
60
+ Mage::helper('temandoinstaller')->__('Error connecting to the api: %s', $result)
61
+ );
62
  return false;
63
  }
 
64
  }
65
 
66
  public function checkTemandoSchema()
67
  {
68
  $tableError = 0;
69
+ if (!$this->checkTemandoWarehouse()) {
70
+ Mage::getSingleton('adminhtml/session')->addNotice(
71
+ Mage::helper('temandoinstaller')->__('Please add a warehouse to locations.')
72
+ );
73
  $tableError++;
74
  } else {
75
+ Mage::getSingleton('adminhtml/session')->addSuccess(
76
+ Mage::helper('temandoinstaller')->__('Warehouses: %s', $this->checkTemandoWarehouse())
77
+ );
78
  }
79
+ if (!$this->checkTemandoRule()) {
80
+ Mage::getSingleton('adminhtml/session')->addNotice(
81
+ Mage::helper('temandoinstaller')->__('Please add a rule to the rule engine.')
82
+ );
83
  $tableError++;
84
  } else {
85
+ Mage::getSingleton('adminhtml/session')->addSuccess(
86
+ Mage::helper('temandoinstaller')->__('Rules: %s', $this->checkTemandoRule())
87
+ );
88
  }
89
+ if ($tableError == 0) {
90
  return true;
91
+ } else {
92
  return false;
93
  }
94
  }
115
 
116
  protected function initialize()
117
  {
118
+ if (!$this->_helper) {
119
  $this->_helper = Mage::helper('temandoinstaller');
120
  }
121
  }
 
122
  }
app/code/community/Temando/Installer/controllers/Adminhtml/Temandoinstaller/InstallerController.php CHANGED
@@ -1,266 +1,309 @@
1
- <?php
2
-
3
-
4
- class Temando_Installer_Adminhtml_Temandoinstaller_InstallerController extends Mage_Adminhtml_Controller_Action {
5
-
6
- const ERR_NO_SOAP = 'SOAP is not enabled on this server. Please enable SOAP to use the Temando plugin.';
7
- const NOTICE_NO_COMMUNITY = 'The community channel cannot be found. Please install the community channel for Magento Connect.';
8
- const NOTICE_UPGRADE = 'Note: if you have any customisations relating to your Temando extension, upgrading your Temando extension will remove these. Contact your Temando representative for guidance.';
9
- const NOTICE_ATTRIBUTES = 'Note: if upgrading from the Starter Extension to a Business Extension, please re-index your products.';
10
-
11
- public function indexAction()
12
- {
13
- $communityChannel = Mage::getModel('temandoinstaller/connect')->getSingleConfig()->isChannel('community');
14
- if (!$communityChannel) {
15
- Mage::getSingleton('adminhtml/session')->addNotice(Mage::helper('temandoinstaller')->__(self::NOTICE_NO_COMMUNITY));
16
- }
17
- if ($this->checkSoap()) {
18
- Mage::getSingleton('adminhtml/session')->addError(Mage::helper('temandoinstaller')->__(self::ERR_NO_SOAP));
19
- return $this->getResponse()->setRedirect($this->getRequest()->getServer('HTTP_REFERER'));
20
- } else {
21
- Mage::getSingleton('adminhtml/session')->addNotice(Mage::helper('temandoinstaller')->__(self::NOTICE_UPGRADE));
22
- Mage::getSingleton('adminhtml/session')->addNotice(Mage::helper('temandoinstaller')->__(self::NOTICE_ATTRIBUTES));
23
- $this->loadLayout()->renderLayout();
24
- }
25
- }
26
-
27
- public function newAction()
28
- {
29
- $this->_forward('install');
30
- }
31
-
32
- public function installAction()
33
- {
34
-
35
- $helper = Mage::helper('temandoinstaller');
36
- /* @var $helper Temando_Installer_Helper_Data */
37
-
38
- $installer = Mage::getModel('temandoinstaller/installer');
39
- /* @var $installer Temando_Installer_Model_Installer */
40
-
41
-
42
- if ($helper->getTemandoVersion()) {
43
- Mage::getSingleton('adminhtml/session')->addError(Mage::helper('temandoinstaller')->__('Temando is already installed.'));
44
- $this->_redirect('*/*/');
45
- return;
46
- }
47
-
48
- //check token
49
- $currentService = $installer->getCurrentService();
50
- if(!$currentService) {
51
- Mage::getSingleton('adminhtml/session')->addError(Mage::helper('temandoinstaller')->__('Could not find valid subscription.'));
52
- $this->_redirect('*/*/');
53
- return;
54
- }
55
- //check the latest release
56
- if (!isset($currentService->links->software_latest_release->version)) {
57
- Mage::getSingleton('adminhtml/session')->addError(Mage::helper('temandoinstaller')->__('Could not find latest release.'));
58
- $this->_redirect('*/*/');
59
- return;
60
- }
61
-
62
- //check file
63
- $file = $installer->downloadPackage($currentService);
64
-
65
- if(!$file) {
66
- Mage::getSingleton('adminhtml/session')->addError(Mage::helper('temandoinstaller')->__('Error downloading file.'));
67
- $this->_redirect('*/*/');
68
- return;
69
- }
70
-
71
- $command = Mage::getModel('temandoinstaller/connect');
72
- if($command->install($file)) {
73
-
74
- //clean the cache
75
- Mage::app()->cleanCache(array('CONFIG'));
76
-
77
- $installer
78
- ->setName('Temando')
79
- ->setToken($helper->getTemandoToken())
80
- ->setVersion($currentService->links->software_latest_release->version)
81
- ->setModule(Temando_Installer_Helper_Data::TMD_MODULE_NAME)
82
- ->setInstallDate(date('Y-m-d H:i:s'))
83
- ->setUpdateDate(date('Y-m-d H:i:s'))
84
- ->setUpdateAvailable(false)
85
- ->setUpdateDismissed(false)
86
- ->setUpdateDetails(NULL)
87
- ->setStatus(1)
88
- ->save();
89
- }
90
-
91
- //delete file
92
- @unlink($file);
93
-
94
- if(Mage::registry('temandoinstaller_errors')) {
95
- foreach (Mage::registry('temandoinstaller_errors') as $error) {
96
- Mage::getSingleton('adminhtml/session')->addError($error);
97
- }
98
- } else {
99
- Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('temandoinstaller')->__('Package successfully installed.'));
100
- }
101
-
102
- $this->_redirect('*/*/');
103
- return;
104
- }
105
-
106
- public function updateAction()
107
- {
108
- $helper = Mage::helper('temandoinstaller');
109
- /* @var $helper Temando_Installer_Helper_Data */
110
-
111
- $installer = Mage::getModel('temandoinstaller/installer');
112
- /* @var $installer Temando_Installer_Model_Installer */
113
-
114
- $params = $this->getRequest()->getParams();
115
- if (!isset($params['massaction']) || !is_array($params['massaction']) || empty($params['massaction'])) {
116
- Mage::getSingleton('adminhtml/session')->addError(Mage::helper('temandoinstaller')->__('No modules selected for update.'));
117
- $this->_redirect('*/*/');
118
- return;
119
- }
120
-
121
- //check token
122
- $currentService = $installer->getCurrentService();
123
- if (!$currentService) {
124
- Mage::getSingleton('adminhtml/session')->addError(Mage::helper('temandoinstaller')->__('Could not find valid service.'));
125
- $this->_redirect('*/*/');
126
- return;
127
- }
128
- //check the latest release
129
- if (!isset($currentService->links->software_latest_release->version)) {
130
- Mage::getSingleton('adminhtml/session')->addError(Mage::helper('temandoinstaller')->__('Could not find latest release.'));
131
- $this->_redirect('*/*/');
132
- return;
133
- }
134
- //compare the current version
135
- if ($helper->getTemandoVersionNumber() >= $currentService->links->software_latest_release->version) {
136
- Mage::getSingleton('adminhtml/session')->addError(Mage::helper('temandoinstaller')->__('Current version is greater than or equal to the latest release.'));
137
- $this->_redirect('*/*/');
138
- return;
139
- }
140
-
141
- $installerIds = $params['massaction'];
142
-
143
- //at the moment only one product will be on the grid - the mass action has been added for future use
144
- foreach ($installerIds as $id) {
145
- //check file
146
- $file = $installer->downloadPackage($currentService);
147
-
148
- if(!$file) {
149
- Mage::getSingleton('adminhtml/session')->addError(Mage::helper('temandoinstaller')->__('Error downloading file.'));
150
- $this->_redirect('*/*/');
151
- return;
152
- }
153
-
154
- $installer->load($id);
155
- $command = Mage::getModel('temandoinstaller/connect');
156
- if(!$command->uninstall($installer->getModule())) {
157
- Mage::getSingleton('adminhtml/session')->addError(Mage::helper('temandoinstaller')->__('There was an error uninstalling the current module.'));
158
- $this->_redirect('*/*/');
159
- return;
160
- }
161
- //clean cache before installing new module
162
- Mage::app()->cleanCache(array('CONFIG'));
163
- if($command->install($file)) {
164
- //clean the cache after installing new module
165
- Mage::app()->cleanCache(array('CONFIG'));
166
- $installer
167
- ->setName('Temando')
168
- ->setToken($helper->getTemandoToken())
169
- ->setVersion($currentService->links->software_latest_release->version)
170
- ->setModule(Temando_Installer_Helper_Data::TMD_MODULE_NAME)
171
- ->setUpdateDate(date('Y-m-d H:i:s'))
172
- ->setUpdateAvailable(false)
173
- ->setUpdateDismissed(false)
174
- ->setUpdateDetails(NULL)
175
- ->setStatus(1)
176
- ->save();
177
- }
178
-
179
- //delete file
180
- @unlink($file);
181
- }
182
-
183
- if(Mage::registry('temandoinstaller_errors')) {
184
- foreach (Mage::registry('temandoinstaller_errors') as $error) {
185
- Mage::getSingleton('adminhtml/session')->addError($error);
186
- }
187
- } else {
188
- Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('temandoinstaller')->__('Package successfully updated.'));
189
- }
190
-
191
- $this->_redirect('*/*/');
192
- }
193
-
194
- public function uninstallAction()
195
- {
196
- $helper = Mage::helper('temandoinstaller');
197
- /* @var $helper Temando_Installer_Helper_Data */
198
-
199
- $params = $this->getRequest()->getParams();
200
- if (!isset($params['massaction']) || !is_array($params['massaction']) || empty($params['massaction'])) {
201
- Mage::getSingleton('adminhtml/session')->addError(Mage::helper('temandoinstaller')->__('No modules selected for removal.'));
202
- $this->_redirect('*/*/');
203
- }
204
-
205
- //uninstall does not require token checks
206
-
207
- $installerIds = $params['massaction'];
208
-
209
- foreach ($installerIds as $id) {
210
- $installer = Mage::getModel('temandoinstaller/installer')->load($id);
211
- $command = Mage::getModel('temandoinstaller/connect');
212
- if($command->uninstall($installer->getModule())) {
213
- $installer->delete();
214
- }
215
- }
216
-
217
- if(Mage::registry('temandoinstaller_errors')) {
218
- foreach (Mage::registry('temandoinstaller_errors') as $error) {
219
- Mage::getSingleton('adminhtml/session')->addError($error);
220
- }
221
- } else {
222
- Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('temandoinstaller')->__('Package successfully uninstalled.'));
223
- }
224
-
225
- Mage::app()->cleanCache(array('CONFIG'));
226
- $this->_redirect('*/*/');
227
- return;
228
- }
229
-
230
- public function testConnectionSettingsAction()
231
- {
232
- Mage::getModel('temandoinstaller/tester')->testSettings();
233
- return $this->getResponse()->setRedirect($this->getRequest()->getServer('HTTP_REFERER'));
234
- }
235
-
236
- public function dismissUpdateAction()
237
- {
238
- $module_id = $this->getRequest()->getParam('id');
239
- $module = Mage::getModel('temandoinstaller/installer')->load($module_id);
240
- /* @var $module Temando_Installer_Model_Installer */
241
-
242
- if (!$module->getId()) {
243
- Mage::getSingleton('adminhtml/session')->addError(Mage::helper('temandoinstaller')->__('Modules does not exist.'));
244
- } else {
245
- $module
246
- ->setUpdateDismissed(true)
247
- ->save();
248
- Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('temandoinstaller')->__('Temando update has been dismissed.'));
249
- }
250
- return $this->getResponse()->setRedirect($this->getRequest()->getServer('HTTP_REFERER'));
251
- }
252
-
253
- /**
254
- * Checks to see if the SOAP extension is loaded
255
- * @return boolean
256
- */
257
- public function checkSoap() {
258
- if (!extension_loaded('soap')) {
259
- return true;
260
- } else {
261
- return false;
262
- }
263
- }
264
-
265
- }
266
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Installer Controller
4
+ *
5
+ * @package Temando_Installer
6
+ * @author Temando Magento Team <marketing@temando.com>
7
+ */
8
+ class Temando_Installer_Adminhtml_Temandoinstaller_InstallerController extends Mage_Adminhtml_Controller_Action
9
+ {
10
+ // @codingStandardsIgnoreStart
11
+ const ERR_NO_SOAP = 'SOAP is not enabled on this server. Please enable SOAP to use the Temando plugin.';
12
+ const NOTICE_NO_COMMUNITY = 'The community channel cannot be found. Please install the community channel for Magento Connect.';
13
+ const NOTICE_UPGRADE = 'Note: if you have any customisations relating to your Temando extension, upgrading your Temando extension will remove these. Contact your Temando representative for guidance.';
14
+ const NOTICE_ATTRIBUTES = 'Note: if upgrading from the Starter Extension to a Business Extension, please re-index your products.';
15
+ // @codingStandardsIgnoreEnd
16
+
17
+ public function indexAction()
18
+ {
19
+ $communityChannel = Mage::getModel('temandoinstaller/connect')->getSingleConfig()->isChannel('community');
20
+ if (!$communityChannel) {
21
+ Mage::getSingleton('adminhtml/session')->addNotice(
22
+ Mage::helper('temandoinstaller')->__(self::NOTICE_NO_COMMUNITY)
23
+ );
24
+ }
25
+ if ($this->checkSoap()) {
26
+ Mage::getSingleton('adminhtml/session')->addError(
27
+ Mage::helper('temandoinstaller')->__(self::ERR_NO_SOAP)
28
+ );
29
+
30
+ return $this->getResponse()->setRedirect($this->getRequest()->getServer('HTTP_REFERER'));
31
+ } else {
32
+ Mage::getSingleton('adminhtml/session')->addNotice(
33
+ Mage::helper('temandoinstaller')->__(self::NOTICE_UPGRADE)
34
+ );
35
+
36
+ Mage::getSingleton('adminhtml/session')->addNotice(
37
+ Mage::helper('temandoinstaller')->__(self::NOTICE_ATTRIBUTES)
38
+ );
39
+ $this->loadLayout()->renderLayout();
40
+ }
41
+ }
42
+
43
+ public function newAction()
44
+ {
45
+ $this->_forward('install');
46
+ }
47
+
48
+ public function installAction()
49
+ {
50
+ $helper = Mage::helper('temandoinstaller');
51
+ /* @var $helper Temando_Installer_Helper_Data */
52
+
53
+ $installer = Mage::getModel('temandoinstaller/installer');
54
+ /* @var $installer Temando_Installer_Model_Installer */
55
+
56
+ if ($helper->getTemandoVersion()) {
57
+ Mage::getSingleton('adminhtml/session')->addError(
58
+ Mage::helper('temandoinstaller')->__('Temando is already installed.')
59
+ );
60
+ $this->_redirect('*/*/');
61
+ return;
62
+ }
63
+
64
+ //check token
65
+ $currentService = $installer->getCurrentService();
66
+ if (!$currentService) {
67
+ Mage::getSingleton('adminhtml/session')->addError(
68
+ Mage::helper('temandoinstaller')->__('Could not find valid subscription.')
69
+ );
70
+ $this->_redirect('*/*/');
71
+ return;
72
+ }
73
+ //check the latest release
74
+ if (!isset($currentService->links->software_latest_release->version)) {
75
+ Mage::getSingleton('adminhtml/session')->addError(
76
+ Mage::helper('temandoinstaller')->__('Could not find latest release.')
77
+ );
78
+ $this->_redirect('*/*/');
79
+ return;
80
+ }
81
+
82
+ //check file
83
+ $file = $installer->downloadPackage($currentService);
84
+
85
+ if (!$file) {
86
+ Mage::getSingleton('adminhtml/session')->addError(
87
+ Mage::helper('temandoinstaller')->__('Error downloading file.')
88
+ );
89
+ $this->_redirect('*/*/');
90
+ return;
91
+ }
92
+
93
+ $command = Mage::getModel('temandoinstaller/connect');
94
+ if ($command->install($file)) {
95
+ //clean the cache
96
+ Mage::app()->cleanCache(array('CONFIG'));
97
+ $installer
98
+ ->setName('Temando')
99
+ ->setToken($helper->getTemandoToken())
100
+ ->setVersion($currentService->links->software_latest_release->version)
101
+ ->setModule(Temando_Installer_Helper_Data::TMD_MODULE_NAME)
102
+ ->setInstallDate(date('Y-m-d H:i:s'))
103
+ ->setUpdateDate(date('Y-m-d H:i:s'))
104
+ ->setUpdateAvailable(false)
105
+ ->setUpdateDismissed(false)
106
+ ->setUpdateDetails(null)
107
+ ->setStatus(1)
108
+ ->save();
109
+ }
110
+
111
+ //delete file
112
+ @unlink($file);
113
+
114
+ if (Mage::registry('temandoinstaller_errors')) {
115
+ foreach (Mage::registry('temandoinstaller_errors') as $error) {
116
+ Mage::getSingleton('adminhtml/session')->addError($error);
117
+ }
118
+ } else {
119
+ Mage::getSingleton('adminhtml/session')->addSuccess(
120
+ Mage::helper('temandoinstaller')->__('Package successfully installed.')
121
+ );
122
+ }
123
+
124
+ $this->_redirect('*/*/');
125
+ return;
126
+ }
127
+
128
+ public function updateAction()
129
+ {
130
+ $helper = Mage::helper('temandoinstaller');
131
+ /* @var $helper Temando_Installer_Helper_Data */
132
+
133
+ $installer = Mage::getModel('temandoinstaller/installer');
134
+ /* @var $installer Temando_Installer_Model_Installer */
135
+
136
+ $params = $this->getRequest()->getParams();
137
+ if (!isset($params['massaction']) || !is_array($params['massaction']) || empty($params['massaction'])) {
138
+ Mage::getSingleton('adminhtml/session')->addError(
139
+ Mage::helper('temandoinstaller')->__('No modules selected for update.')
140
+ );
141
+ $this->_redirect('*/*/');
142
+ return;
143
+ }
144
+
145
+ //check token
146
+ $currentService = $installer->getCurrentService();
147
+ if (!$currentService) {
148
+ Mage::getSingleton('adminhtml/session')->addError(
149
+ Mage::helper('temandoinstaller')->__('Could not find valid service.')
150
+ );
151
+ $this->_redirect('*/*/');
152
+ return;
153
+ }
154
+ //check the latest release
155
+ if (!isset($currentService->links->software_latest_release->version)) {
156
+ Mage::getSingleton('adminhtml/session')->addError(
157
+ Mage::helper('temandoinstaller')->__('Could not find latest release.')
158
+ );
159
+ $this->_redirect('*/*/');
160
+ return;
161
+ }
162
+ //compare the current version
163
+ if (version_compare($helper->getTemandoVersionNumber(), $currentService->links->software_latest_release->version) > 0) {
164
+ Mage::getSingleton('adminhtml/session')->addError(
165
+ Mage::helper('temandoinstaller')->__('Current version is greater than or equal to the latest release.')
166
+ );
167
+ $this->_redirect('*/*/');
168
+ return;
169
+ }
170
+
171
+ $installerIds = $params['massaction'];
172
+
173
+ //at the moment only one product will be on the grid - the mass action has been added for future use
174
+ foreach ($installerIds as $id) {
175
+ //check file
176
+ $file = $installer->downloadPackage($currentService);
177
+
178
+ if (!$file) {
179
+ Mage::getSingleton('adminhtml/session')->addError(
180
+ Mage::helper('temandoinstaller')->__('Error downloading file.')
181
+ );
182
+ $this->_redirect('*/*/');
183
+ return;
184
+ }
185
+
186
+ $installer->load($id);
187
+ $command = Mage::getModel('temandoinstaller/connect');
188
+ if (!$command->uninstall($installer->getModule())) {
189
+ Mage::getSingleton('adminhtml/session')->addError(
190
+ Mage::helper('temandoinstaller')->__('There was an error uninstalling the current module.')
191
+ );
192
+ $this->_redirect('*/*/');
193
+ return;
194
+ }
195
+ //clean cache before installing new module
196
+ Mage::app()->cleanCache(array('CONFIG'));
197
+ if ($command->install($file)) {
198
+ //clean the cache after installing new module
199
+ Mage::app()->cleanCache(array('CONFIG'));
200
+ $installer
201
+ ->setName('Temando')
202
+ ->setToken($helper->getTemandoToken())
203
+ ->setVersion($currentService->links->software_latest_release->version)
204
+ ->setModule(Temando_Installer_Helper_Data::TMD_MODULE_NAME)
205
+ ->setUpdateDate(date('Y-m-d H:i:s'))
206
+ ->setUpdateAvailable(false)
207
+ ->setUpdateDismissed(false)
208
+ ->setUpdateDetails(null)
209
+ ->setStatus(1)
210
+ ->save();
211
+ }
212
+
213
+ //delete file
214
+ @unlink($file);
215
+ }
216
+
217
+ if (Mage::registry('temandoinstaller_errors')) {
218
+ foreach (Mage::registry('temandoinstaller_errors') as $error) {
219
+ Mage::getSingleton('adminhtml/session')->addError($error);
220
+ }
221
+ } else {
222
+ Mage::getSingleton('adminhtml/session')->addSuccess(
223
+ Mage::helper('temandoinstaller')->__('Package successfully updated.')
224
+ );
225
+ }
226
+ $this->_redirect('*/*/');
227
+ }
228
+
229
+ public function uninstallAction()
230
+ {
231
+ $helper = Mage::helper('temandoinstaller');
232
+ /* @var $helper Temando_Installer_Helper_Data */
233
+
234
+ $params = $this->getRequest()->getParams();
235
+ if (!isset($params['massaction']) || !is_array($params['massaction']) ||
236
+ empty($params['massaction'])) {
237
+ Mage::getSingleton('adminhtml/session')->addError(
238
+ Mage::helper('temandoinstaller')->__('No modules selected for removal.')
239
+ );
240
+ $this->_redirect('*/*/');
241
+ }
242
+
243
+ //uninstall does not require token checks
244
+
245
+ $installerIds = $params['massaction'];
246
+
247
+ foreach ($installerIds as $id) {
248
+ $installer = Mage::getModel('temandoinstaller/installer')->load($id);
249
+ $command = Mage::getModel('temandoinstaller/connect');
250
+ if ($command->uninstall($installer->getModule())) {
251
+ $installer->delete();
252
+ }
253
+ }
254
+
255
+ if (Mage::registry('temandoinstaller_errors')) {
256
+ foreach (Mage::registry('temandoinstaller_errors') as $error) {
257
+ Mage::getSingleton('adminhtml/session')->addError($error);
258
+ }
259
+ } else {
260
+ Mage::getSingleton('adminhtml/session')->addSuccess(
261
+ Mage::helper('temandoinstaller')->__('Package successfully uninstalled.')
262
+ );
263
+ }
264
+
265
+ Mage::app()->cleanCache(array('CONFIG'));
266
+ $this->_redirect('*/*/');
267
+ return;
268
+ }
269
+
270
+ public function testConnectionSettingsAction()
271
+ {
272
+ Mage::getModel('temandoinstaller/tester')->testSettings();
273
+ return $this->getResponse()->setRedirect($this->getRequest()->getServer('HTTP_REFERER'));
274
+ }
275
+
276
+ public function dismissUpdateAction()
277
+ {
278
+ $module_id = $this->getRequest()->getParam('id');
279
+ $module = Mage::getModel('temandoinstaller/installer')->load($module_id);
280
+ /* @var $module Temando_Installer_Model_Installer */
281
+
282
+ if (!$module->getId()) {
283
+ Mage::getSingleton('adminhtml/session')->addError(
284
+ Mage::helper('temandoinstaller')->__('Modules does not exist.')
285
+ );
286
+ } else {
287
+ $module
288
+ ->setUpdateDismissed(true)
289
+ ->save();
290
+ Mage::getSingleton('adminhtml/session')->addSuccess(
291
+ Mage::helper('temandoinstaller')->__('Temando update has been dismissed.')
292
+ );
293
+ }
294
+ return $this->getResponse()->setRedirect($this->getRequest()->getServer('HTTP_REFERER'));
295
+ }
296
+
297
+ /**
298
+ * Checks to see if the SOAP extension is loaded
299
+ * @return boolean
300
+ */
301
+ public function checkSoap()
302
+ {
303
+ if (!extension_loaded('soap')) {
304
+ return true;
305
+ } else {
306
+ return false;
307
+ }
308
+ }
309
+ }
app/code/community/Temando/Installer/data/temandoinstaller_setup/data-install-1.0.0.php CHANGED
@@ -20,11 +20,12 @@ if ($helper->getTemandoVersion()) {
20
  $installDate = date('Y-m-d H:i:s');
21
  $updateDate = date('Y-m-d H:i:s');
22
 
23
- $installer->run("
24
- INSERT INTO {$this->getTable('temando_installer')} (`name`, `token`, `version`, `module`, `install_date`, `update_date`, `update_available`, `update_dismissed`, `update_details`, `status`) VALUES
25
- ('{$versionName}','Token not set','{$versionNumber}','Temando_Temando','{$installDate}','{$updateDate}',0,0,NULL,1);
26
- ");
27
-
 
28
  }
29
 
30
  $installer->endSetup();
20
  $installDate = date('Y-m-d H:i:s');
21
  $updateDate = date('Y-m-d H:i:s');
22
 
23
+ // @codingStandardsIgnoreStart
24
+ $installer->run(
25
+ "INSERT INTO {$this->getTable('temando_installer')} (`name`, `token`, `version`, `module`, `install_date`, `update_date`, `update_available`, `update_dismissed`, `update_details`, `status`) VALUES
26
+ ('{$versionName}','Token not set','{$versionNumber}','Temando_Temando','{$installDate}','{$updateDate}',0,0,NULL,1);"
27
+ );
28
+ // @codingStandardsIgnoreEnd
29
  }
30
 
31
  $installer->endSetup();
app/code/community/Temando/Installer/etc/config.xml CHANGED
@@ -1,92 +1,92 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <config>
3
- <modules>
4
- <Temando_Installer>
5
- <version>1.0.3</version>
6
- </Temando_Installer>
7
- </modules>
8
- <global>
9
- <models>
10
- <temandoinstaller>
11
- <class>Temando_Installer_Model</class>
12
- <resourceModel>temandoinstaller_mysql4</resourceModel>
13
- </temandoinstaller>
14
- <temandoinstaller_mysql4>
15
- <class>Temando_Installer_Model_Mysql4</class>
16
- <entities>
17
- <installer><table>temando_installer</table></installer>
18
- </entities>
19
- </temandoinstaller_mysql4>
20
- </models>
21
- <blocks>
22
- <temandoinstaller>
23
- <class>Temando_Installer_Block</class>
24
- </temandoinstaller>
25
- </blocks>
26
- <helpers>
27
- <temandoinstaller>
28
- <class>Temando_Installer_Helper</class>
29
- </temandoinstaller>
30
- </helpers>
31
- <resources>
32
- <temandoinstaller_setup>
33
- <setup>
34
- <module>Temando_Installer</module>
35
- <class>Mage_Eav_Model_Entity_Setup</class>
36
- </setup>
37
- <connection>
38
- <use>core_setup</use>
39
- </connection>
40
- </temandoinstaller_setup>
41
- <temandoinstaller_write>
42
- <connection>
43
- <use>core_write</use>
44
- </connection>
45
- </temandoinstaller_write>
46
- <temandoinstaller_read>
47
- <connection>
48
- <use>core_read</use>
49
- </connection>
50
- </temandoinstaller_read>
51
- </resources>
52
- </global>
53
- <admin>
54
- <routers>
55
- <adminhtml>
56
- <args>
57
- <modules>
58
- <temando_installer after="Mage_Adminhtml">Temando_Installer_Adminhtml</temando_installer>
59
- </modules>
60
- </args>
61
- </adminhtml>
62
- </routers>
63
- </admin>
64
- <adminhtml>
65
- <layout>
66
- <updates>
67
- <temandoinstaller>
68
- <file>temandoinstaller.xml</file>
69
- </temandoinstaller>
70
- </updates>
71
- </layout>
72
- <!-- add translation file -->
73
- <translate>
74
- <modules>
75
- <Temando_Installer>
76
- <files>
77
- <default>Temando_Installer.csv</default>
78
- </files>
79
- </Temando_Installer>
80
- </modules>
81
- </translate>
82
- </adminhtml>
83
- <crontab>
84
- <jobs>
85
- <temandoinstaller_daily_update_check>
86
- <!-- Daily at 11pm -->
87
- <schedule><cron_expr>0 23 * * *</cron_expr></schedule>
88
- <run><model>temandoinstaller/cron::checkReleases</model></run>
89
- </temandoinstaller_daily_update_check>
90
- </jobs>
91
- </crontab>
92
- </config>
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <modules>
4
+ <Temando_Installer>
5
+ <version>1.0.4</version>
6
+ </Temando_Installer>
7
+ </modules>
8
+ <global>
9
+ <models>
10
+ <temandoinstaller>
11
+ <class>Temando_Installer_Model</class>
12
+ <resourceModel>temandoinstaller_mysql4</resourceModel>
13
+ </temandoinstaller>
14
+ <temandoinstaller_mysql4>
15
+ <class>Temando_Installer_Model_Mysql4</class>
16
+ <entities>
17
+ <installer><table>temando_installer</table></installer>
18
+ </entities>
19
+ </temandoinstaller_mysql4>
20
+ </models>
21
+ <blocks>
22
+ <temandoinstaller>
23
+ <class>Temando_Installer_Block</class>
24
+ </temandoinstaller>
25
+ </blocks>
26
+ <helpers>
27
+ <temandoinstaller>
28
+ <class>Temando_Installer_Helper</class>
29
+ </temandoinstaller>
30
+ </helpers>
31
+ <resources>
32
+ <temandoinstaller_setup>
33
+ <setup>
34
+ <module>Temando_Installer</module>
35
+ <class>Mage_Eav_Model_Entity_Setup</class>
36
+ </setup>
37
+ <connection>
38
+ <use>core_setup</use>
39
+ </connection>
40
+ </temandoinstaller_setup>
41
+ <temandoinstaller_write>
42
+ <connection>
43
+ <use>core_write</use>
44
+ </connection>
45
+ </temandoinstaller_write>
46
+ <temandoinstaller_read>
47
+ <connection>
48
+ <use>core_read</use>
49
+ </connection>
50
+ </temandoinstaller_read>
51
+ </resources>
52
+ </global>
53
+ <admin>
54
+ <routers>
55
+ <adminhtml>
56
+ <args>
57
+ <modules>
58
+ <temando_installer after="Mage_Adminhtml">Temando_Installer_Adminhtml</temando_installer>
59
+ </modules>
60
+ </args>
61
+ </adminhtml>
62
+ </routers>
63
+ </admin>
64
+ <adminhtml>
65
+ <layout>
66
+ <updates>
67
+ <temandoinstaller>
68
+ <file>temandoinstaller.xml</file>
69
+ </temandoinstaller>
70
+ </updates>
71
+ </layout>
72
+ <!-- add translation file -->
73
+ <translate>
74
+ <modules>
75
+ <Temando_Installer>
76
+ <files>
77
+ <default>Temando_Installer.csv</default>
78
+ </files>
79
+ </Temando_Installer>
80
+ </modules>
81
+ </translate>
82
+ </adminhtml>
83
+ <crontab>
84
+ <jobs>
85
+ <temandoinstaller_daily_update_check>
86
+ <!-- Daily at 11pm -->
87
+ <schedule><cron_expr>0 23 * * *</cron_expr></schedule>
88
+ <run><model>temandoinstaller/cron::checkReleases</model></run>
89
+ </temandoinstaller_daily_update_check>
90
+ </jobs>
91
+ </crontab>
92
+ </config>
app/code/community/Temando/Installer/sql/temandoinstaller_setup/mysql4-install-1.0.0.php CHANGED
@@ -8,23 +8,23 @@ set_time_limit(0);
8
  $installer = $this;
9
  $installer->startSetup();
10
 
11
- $installer->run("
12
- DROP TABLE IF EXISTS {$this->getTable('temando_installer')};
13
- CREATE TABLE {$this->getTable('temando_installer')} (
14
- `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
15
- `name` TEXT NOT NULL,
16
- `token` TEXT NOT NULL,
17
- `version` TEXT NOT NULL,
18
- `module` varchar(50) NOT NULL,
19
- `install_date` DATETIME NULL DEFAULT NULL,
20
- `update_date` DATETIME NULL DEFAULT NULL,
21
- `update_available` tinyint(1) NOT NULL DEFAULT '0',
22
- `update_dismissed` tinyint(1) NOT NULL DEFAULT '0',
23
- `update_details` TEXT,
24
- `status` int(2) NOT NULL DEFAULT '0',
25
- PRIMARY KEY (`id`),
26
- UNIQUE `module` (`module`)
27
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
28
- ");
29
 
30
  $installer->endSetup();
8
  $installer = $this;
9
  $installer->startSetup();
10
 
11
+ $installer->run(
12
+ "DROP TABLE IF EXISTS {$this->getTable('temando_installer')};
13
+ CREATE TABLE {$this->getTable('temando_installer')} (
14
+ `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
15
+ `name` TEXT NOT NULL,
16
+ `token` TEXT NOT NULL,
17
+ `version` TEXT NOT NULL,
18
+ `module` varchar(50) NOT NULL,
19
+ `install_date` DATETIME NULL DEFAULT NULL,
20
+ `update_date` DATETIME NULL DEFAULT NULL,
21
+ `update_available` tinyint(1) NOT NULL DEFAULT '0',
22
+ `update_dismissed` tinyint(1) NOT NULL DEFAULT '0',
23
+ `update_details` TEXT,
24
+ `status` int(2) NOT NULL DEFAULT '0',
25
+ PRIMARY KEY (`id`),
26
+ UNIQUE `module` (`module`)
27
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;"
28
+ );
29
 
30
  $installer->endSetup();
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Temando_Installer</name>
4
- <version>1.0.3</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">Open Software Licence</license>
7
  <channel>community</channel>
@@ -11,11 +11,11 @@
11
  &#xD;
12
  Download the installer and enter your Temando Unique Access Token when prompted. From there, the extension will install the correct version you have signed up for.&#xD;
13
  </description>
14
- <notes>- Changes to adminhtml controllers for security update SUPEE-6788</notes>
15
  <authors><author><name>Temando</name><user>Temando</user><email>marketing@temando.com</email></author></authors>
16
- <date>2015-11-02</date>
17
- <time>01:58:43</time>
18
- <contents><target name="mageetc"><dir name="modules"><file name="Temando_Installer.xml" hash="d3d9fadbc5f6837ca68375f0c3e329f3"/></dir></target><target name="magecommunity"><dir name="Temando"><dir name="Installer"><dir name="Block"><dir name="Adminhtml"><dir name="Installer"><file name="Grid.php" hash="88063f4be3c01a11083e34688faf16bf"/></dir><file name="Installer.php" hash="17826cbc611090e5bb1fc64a5c247584"/><file name="Notifications.php" hash="1af33eec059097349d4481c197958d5e"/><dir name="System"><dir name="Config"><dir name="Form"><dir name="Button"><file name="Manage.php" hash="5bb957554fa2a45adc7df4d1c747b0cf"/></dir></dir></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="abb479ebcb4ca5931b60fea02896223f"/></dir><dir name="Model"><dir name="Api"><dir name="Rest"><file name="Client.php" hash="b37d8ce431da79ff412d06918f5f16b8"/></dir></dir><file name="Connect.php" hash="9426422e679e06f6f87ee6ba8c2f7bab"/><file name="Cron.php" hash="354e4d6c0f2fa02a7127d86ccca68ec8"/><file name="Installer.php" hash="fa74ed6258771553a2300b4da09f42a7"/><dir name="Mysql4"><dir name="Installer"><file name="Collection.php" hash="0df36ef671e60266ae72c64011021ab0"/></dir><file name="Installer.php" hash="648c65a4b10af8b0649d1b450be8cc98"/></dir><file name="Tester.php" hash="24a05bec30b6ab3ff2fc5cae9757b720"/></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Temandoinstaller"><file name="InstallerController.php" hash="bfa5d03cfb14717fab62f5dc5d3edcb6"/></dir></dir></dir><dir name="data"><dir name="temandoinstaller_setup"><file name="data-install-1.0.0.php" hash="3f06f83993f9eecb7a22e57ac807968a"/><file name="data-upgrade-1.0.2-1.0.3.php" hash="ff59e9d5ee2aef46cfefc479a3dbe4f2"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="3c5a9c397fb92a8f1379b65fb4c5011a"/><file name="config.xml" hash="7e939106140ec71699fe35e2f49a0ba2"/><file name="system.xml" hash="03b09a2f7da6bb78952864a9d97c5218"/></dir><dir name="sql"><dir name="temandoinstaller_setup"><file name="mysql4-install-1.0.0.php" hash="4760a0369097a674bf0bf101100925a6"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="temandoinstaller.xml" hash="c82533b46412da5070ad0eef4d60c3ee"/></dir><dir name="template"><dir name="temando"><dir name="installer"><file name="notifications.phtml" hash="efe5ef5112881ece7ee6ddcd81b23f8d"/></dir></dir></dir></dir></dir></dir></target><target name="magelocale"><dir name="fr_FR"><file name="Temando_Installer.csv" hash="66e104316b152632964e6c0e0af635da"/></dir></target></contents>
19
  <compatible/>
20
  <dependencies><required><php><min>5.2.13</min><max>6.0.0</max></php></required></dependencies>
21
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Temando_Installer</name>
4
+ <version>1.0.4</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">Open Software Licence</license>
7
  <channel>community</channel>
11
  &#xD;
12
  Download the installer and enter your Temando Unique Access Token when prompted. From there, the extension will install the correct version you have signed up for.&#xD;
13
  </description>
14
+ <notes>- Compare version of Temando in a correct way</notes>
15
  <authors><author><name>Temando</name><user>Temando</user><email>marketing@temando.com</email></author></authors>
16
+ <date>2016-03-04</date>
17
+ <time>01:42:33</time>
18
+ <contents><target name="mageetc"><dir name="modules"><file name="Temando_Installer.xml" hash="d3d9fadbc5f6837ca68375f0c3e329f3"/></dir></target><target name="magecommunity"><dir name="Temando"><dir name="Installer"><dir name="Block"><dir name="Adminhtml"><dir name="Installer"><file name="Grid.php" hash="30c7ea128ed37706bcc4c9d352a6dacc"/></dir><file name="Installer.php" hash="26742c47a23d7d2e6da7509c2b224d7d"/><file name="Notifications.php" hash="d6fa3d5ba3bc466c7171b681fb4e3784"/><dir name="System"><dir name="Config"><dir name="Form"><dir name="Button"><file name="Manage.php" hash="f04920d9c9821620911a6239540da617"/></dir></dir></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="9b37cc0707a37b6528369de917ff1a93"/></dir><dir name="Model"><dir name="Api"><dir name="Rest"><file name="Client.php" hash="aa71a1f4e4b67d5d15cb910d34d7f9c5"/></dir></dir><file name="Connect.php" hash="292af2d80494f136c3eaeecb147f484b"/><file name="Cron.php" hash="f01e49b6bdbf392a9e3be1a60a41017c"/><file name="Installer.php" hash="4abc7be5f1a96a97d9c9f80aa6b2d076"/><dir name="Mysql4"><dir name="Installer"><file name="Collection.php" hash="35ae772e3e5a6aa37e73718959106e50"/></dir><file name="Installer.php" hash="5d0fa0d3f063a8291470aeff4936467d"/></dir><file name="Tester.php" hash="efbb7d84eb9c45ebb83f8aa949404625"/></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Temandoinstaller"><file name="InstallerController.php" hash="7b7399e343d70b24425b5f38033e5347"/></dir></dir></dir><dir name="data"><dir name="temandoinstaller_setup"><file name="data-install-1.0.0.php" hash="f1f63b190549e00266a14453a7c67430"/><file name="data-upgrade-1.0.2-1.0.3.php" hash="ff59e9d5ee2aef46cfefc479a3dbe4f2"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="3c5a9c397fb92a8f1379b65fb4c5011a"/><file name="config.xml" hash="cf02b750e3f1dda743e6d6198f6553e9"/><file name="system.xml" hash="03b09a2f7da6bb78952864a9d97c5218"/></dir><dir name="sql"><dir name="temandoinstaller_setup"><file name="mysql4-install-1.0.0.php" hash="24729468443b674a5d4ffc33fa6a91bc"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="temandoinstaller.xml" hash="c82533b46412da5070ad0eef4d60c3ee"/></dir><dir name="template"><dir name="temando"><dir name="installer"><file name="notifications.phtml" hash="efe5ef5112881ece7ee6ddcd81b23f8d"/></dir></dir></dir></dir></dir></dir></target><target name="magelocale"><dir name="fr_FR"><file name="Temando_Installer.csv" hash="66e104316b152632964e6c0e0af635da"/></dir></target></contents>
19
  <compatible/>
20
  <dependencies><required><php><min>5.2.13</min><max>6.0.0</max></php></required></dependencies>
21
  </package>