Version Notes
v1.0.0
Temando Installer
- Installs Temando extension based on access token
- U.S. Release
- Includes Endicia Integration
Download this release
Release Info
Developer | Temando |
Extension | Temando_Installer |
Version | 1.0.0 |
Comparing to | |
See all releases |
Version 1.0.0
- app/code/community/Temando/Installer/Block/Adminhtml/Installer.php +27 -0
- app/code/community/Temando/Installer/Block/Adminhtml/Installer/Grid.php +78 -0
- app/code/community/Temando/Installer/Block/Adminhtml/Notifications.php +14 -0
- app/code/community/Temando/Installer/Block/Adminhtml/System/Config/Form/Button/Manage.php +17 -0
- app/code/community/Temando/Installer/Helper/Data.php +246 -0
- app/code/community/Temando/Installer/Model/Api/Rest/Client.php +118 -0
- app/code/community/Temando/Installer/Model/Connect.php +144 -0
- app/code/community/Temando/Installer/Model/Cron.php +66 -0
- app/code/community/Temando/Installer/Model/Installer.php +209 -0
- app/code/community/Temando/Installer/Model/Mysql4/Installer.php +11 -0
- app/code/community/Temando/Installer/Model/Mysql4/Installer/Collection.php +12 -0
- app/code/community/Temando/Installer/Model/Tester.php +104 -0
- app/code/community/Temando/Installer/controllers/Adminhtml/InstallerController.php +262 -0
- app/code/community/Temando/Installer/data/temandoinstaller_setup/data-install-1.0.0.php +30 -0
- app/code/community/Temando/Installer/etc/adminhtml.xml +40 -0
- app/code/community/Temando/Installer/etc/config.xml +93 -0
- app/code/community/Temando/Installer/etc/system.xml +43 -0
- app/code/community/Temando/Installer/sql/temandoinstaller_setup/mysql4-install-1.0.0.php +30 -0
- app/design/adminhtml/default/default/layout/temandoinstaller.xml +15 -0
- app/design/adminhtml/default/default/template/temando/installer/notifications.phtml +16 -0
- app/etc/modules/Temando_Installer.xml +9 -0
- package.xml +26 -0
app/code/community/Temando/Installer/Block/Adminhtml/Installer.php
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Temando_Installer_Block_Adminhtml_Installer extends Mage_Adminhtml_Block_Widget_Grid_Container
|
4 |
+
{
|
5 |
+
public function __construct()
|
6 |
+
{
|
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'),
|
14 |
+
// 'id' => 'connectionSettings',
|
15 |
+
// 'onclick' => "window.location = '" . $this->getUrl('temandoinstaller/adminhtml_installer/testConnectionSettings') . "'",
|
16 |
+
// 'value' => '',
|
17 |
+
// 'class' => 'go',
|
18 |
+
// ));
|
19 |
+
// }
|
20 |
+
parent::__construct();
|
21 |
+
if (Mage::helper('temandoinstaller')->getTemandoVersionNumber()) {
|
22 |
+
$this->removeButton('add');
|
23 |
+
}
|
24 |
+
}
|
25 |
+
}
|
26 |
+
|
27 |
+
|
app/code/community/Temando/Installer/Block/Adminhtml/Installer/Grid.php
ADDED
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
|
72 |
+
public function getRowUrl($row)
|
73 |
+
{
|
74 |
+
return;
|
75 |
+
}
|
76 |
+
|
77 |
+
|
78 |
+
}
|
app/code/community/Temando/Installer/Block/Adminhtml/Notifications.php
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Temando_Installer_Block_Adminhtml_Notifications extends Mage_Adminhtml_Block_Template
|
4 |
+
{
|
5 |
+
public function getModuleNotifications()
|
6 |
+
{
|
7 |
+
$installerModules = Mage::getModel('temandoinstaller/installer')->getCollection();
|
8 |
+
$installerModules->addFieldToFilter('update_dismissed', false);
|
9 |
+
$installerModules->addFieldToFilter('update_available', true);
|
10 |
+
return $installerModules;
|
11 |
+
}
|
12 |
+
}
|
13 |
+
|
14 |
+
|
app/code/community/Temando/Installer/Block/Adminhtml/System/Config/Form/Button/Manage.php
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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')
|
9 |
+
->setType('button')->setClass('scalable go')
|
10 |
+
->setLabel('Manage Temando Installation')
|
11 |
+
->setOnClick('setLocation(\'' . $this->getUrl('temandoinstaller/adminhtml_installer') .'\')')
|
12 |
+
->setTitle('Manage Temando Installation')
|
13 |
+
->toHtml();
|
14 |
+
return $html;
|
15 |
+
}
|
16 |
+
|
17 |
+
}
|
app/code/community/Temando/Installer/Helper/Data.php
ADDED
@@ -0,0 +1,246 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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;
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Gets version of main Temando_Temando extension
|
21 |
+
*
|
22 |
+
* @return string
|
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 |
+
/**
|
53 |
+
* Retrieves an element from the module configuration data.
|
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;
|
75 |
+
case self::TMD_VERSION_ENTERPRISE:
|
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 |
+
}
|
91 |
+
|
92 |
+
public function getVersionNameFromSlug($slug)
|
93 |
+
{
|
94 |
+
$strippedSlug = substr($slug, 0, -3);
|
95 |
+
$names = array(
|
96 |
+
self::TEMANDO_VERSION_STARTER => 'Temando Starter',
|
97 |
+
self::TEMANDO_VERSION_PROFESSIONAL => 'Temando Professional',
|
98 |
+
self::TEMANDO_VERSION_BUSINESS => 'Temando Business',
|
99 |
+
self::TEMANDO_VERSION_ENTERPRISE => 'Temando Enterprise'
|
100 |
+
);
|
101 |
+
return $names[$strippedSlug];
|
102 |
+
}
|
103 |
+
|
104 |
+
public function getTemandoVersionNumber()
|
105 |
+
{
|
106 |
+
$version = (string) Mage::getConfig()->getNode()->modules->Temando_Temando->version;
|
107 |
+
return $version;
|
108 |
+
}
|
109 |
+
|
110 |
+
public function getTemandoModuleName()
|
111 |
+
{
|
112 |
+
return self::TMD_MODULE_NAME;
|
113 |
+
}
|
114 |
+
|
115 |
+
public function getTemandoToken()
|
116 |
+
{
|
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()));
|
134 |
+
if (!$result) {
|
135 |
+
return 'Could not connect to the api';
|
136 |
+
}
|
137 |
+
} catch (Exception $e) {
|
138 |
+
return $e->getMessage();
|
139 |
+
}
|
140 |
+
return false;
|
141 |
+
}
|
142 |
+
|
143 |
+
/**
|
144 |
+
* @return Temando_Temando_Model_Api_Client
|
145 |
+
*/
|
146 |
+
public function connect()
|
147 |
+
{
|
148 |
+
$api = Mage::getModel('temando/api_client');
|
149 |
+
switch ($this->getTemandoVersion()) {
|
150 |
+
case self::TMD_VERSION_BUSINESS:
|
151 |
+
$api = $api->connect($this->getTemandoProfile());
|
152 |
+
break;
|
153 |
+
default:
|
154 |
+
$api = $api->connect(
|
155 |
+
Mage::helper('temando')->getConfigData('general/username'),
|
156 |
+
Mage::helper('temando')->getConfigData('general/password'),
|
157 |
+
Mage::helper('temando')->getConfigData('general/sandbox')
|
158 |
+
);
|
159 |
+
break;
|
160 |
+
}
|
161 |
+
return $api;
|
162 |
+
}
|
163 |
+
|
164 |
+
/**
|
165 |
+
* Returns cheapest available quote for dummy order
|
166 |
+
*
|
167 |
+
* @return null|Temando_Temando_Model_Quote
|
168 |
+
*/
|
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:
|
185 |
+
$request->setConnectionParams($origin->getTemandoProfile());
|
186 |
+
break;
|
187 |
+
default:
|
188 |
+
$request
|
189 |
+
->setUsername(Mage::helper('temando')->getConfigData('general/username'))
|
190 |
+
->setPassword(Mage::helper('temando')->getConfigData('general/password'))
|
191 |
+
->setSandbox(Mage::helper('temando')->getConfigData('general/sandbox'));
|
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 |
+
/**
|
212 |
+
* Creates a test box
|
213 |
+
* @return array
|
214 |
+
*/
|
215 |
+
public function getTestBox()
|
216 |
+
{
|
217 |
+
$box = Mage::getModel('temando/box');
|
218 |
+
/* @var $box Temando_Temando_Model_Box */
|
219 |
+
$box
|
220 |
+
->setComment('My Package')
|
221 |
+
->setQty('1')
|
222 |
+
->setValue('10')
|
223 |
+
->setLength('10')
|
224 |
+
->setWidth('10')
|
225 |
+
->setHeight('10')
|
226 |
+
->setMeasureUnit(Temando_Temando_Model_System_Config_Source_Unit_Measure::CENTIMETRES)
|
227 |
+
->setWeight('100')
|
228 |
+
->setWeightUnit(Temando_Temando_Model_System_Config_Source_Unit_Weight::GRAMS)
|
229 |
+
->setPackaging(Temando_Temando_Model_System_Config_Source_Shipment_Packaging::BOX);
|
230 |
+
//->setFragile($package['fragile'])
|
231 |
+
//->setArticles($package['articles']);
|
232 |
+
return array($box);
|
233 |
+
}
|
234 |
+
|
235 |
+
protected function getTemandoProfile()
|
236 |
+
{
|
237 |
+
return array(
|
238 |
+
'sandbox' => Mage::helper('temando')->getConfigData('general/sandbox'),
|
239 |
+
'clientid' => Mage::helper('temando')->getConfigData('general/client'),
|
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 |
+
}
|
app/code/community/Temando/Installer/Model/Api/Rest/Client.php
ADDED
@@ -0,0 +1,118 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @method StdClass getLastResponse()
|
4 |
+
*/
|
5 |
+
class Temando_Installer_Model_Api_Rest_Client
|
6 |
+
extends Mage_Core_Model_Abstract {
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Auth token
|
10 |
+
* @var string
|
11 |
+
*/
|
12 |
+
protected $_token = null;
|
13 |
+
|
14 |
+
/**
|
15 |
+
* The HTTP Client
|
16 |
+
* @var Varien_Http_Client
|
17 |
+
*/
|
18 |
+
protected $_client = null;
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Service Uri
|
22 |
+
* @var string
|
23 |
+
*/
|
24 |
+
protected $_uri = null;
|
25 |
+
|
26 |
+
|
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 |
+
/**
|
82 |
+
* Validate data before sending request
|
83 |
+
*
|
84 |
+
* @return boolean
|
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 |
+
/**
|
103 |
+
* Initializes http client to communicate with Temando REST Api
|
104 |
+
*
|
105 |
+
* @return \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 |
+
}
|
app/code/community/Temando/Installer/Model/Connect.php
ADDED
@@ -0,0 +1,144 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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";
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Default single config filename
|
17 |
+
*
|
18 |
+
* 'cache.cfg'
|
19 |
+
*/
|
20 |
+
const DEFAULT_SCONFIG_FILENAME = 'cache.cfg';
|
21 |
+
|
22 |
+
public function _construct()
|
23 |
+
{
|
24 |
+
parent::_construct();
|
25 |
+
$this->initialize();
|
26 |
+
|
27 |
+
}
|
28 |
+
|
29 |
+
public function install($file)
|
30 |
+
{
|
31 |
+
try {
|
32 |
+
Mage_Connect_Command::getCommands();
|
33 |
+
$cmd = Mage_Connect_Command::getInstance('install-file');
|
34 |
+
$cmd->setSconfig($this->_sconfig);
|
35 |
+
$cmd->setConfigObject($this->_config);
|
36 |
+
$cmd->setFrontendObject($this->_frontend);
|
37 |
+
$params = array($file);
|
38 |
+
$cmd->run('install-file', array(), $params);
|
39 |
+
} catch (Exception $ex) {
|
40 |
+
Mage::register('temandoinstaller_errors', array('There was an error installing'));
|
41 |
+
return false;
|
42 |
+
}
|
43 |
+
|
44 |
+
if ($cmd->ui()->hasErrors()) {
|
45 |
+
$errors = array();
|
46 |
+
foreach ($cmd->ui()->getErrors() as $error) {
|
47 |
+
$errors[] = $error[1];
|
48 |
+
}
|
49 |
+
Mage::register('temandoinstaller_errors', $errors);
|
50 |
+
return false;
|
51 |
+
}
|
52 |
+
return true;
|
53 |
+
|
54 |
+
}
|
55 |
+
|
56 |
+
public function uninstall($module)
|
57 |
+
{
|
58 |
+
try {
|
59 |
+
Mage_Connect_Command::getCommands();
|
60 |
+
$cmd = Mage_Connect_Command::getInstance('uninstall');
|
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'));
|
73 |
+
return false;
|
74 |
+
}
|
75 |
+
|
76 |
+
if ($cmd->ui()->hasErrors()) {
|
77 |
+
$errors = array();
|
78 |
+
foreach ($cmd->ui()->getErrors() as $error) {
|
79 |
+
$errors[] = $error[1];
|
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) {
|
88 |
+
$fileName = basename($file);
|
89 |
+
$filePath = dirname($file);
|
90 |
+
$dest = $targetPath . DIRECTORY_SEPARATOR . $filePath . DIRECTORY_SEPARATOR . $fileName;
|
91 |
+
$this->removeEmptyDirectory(dirname($dest));
|
92 |
+
|
93 |
+
}
|
94 |
+
return true;
|
95 |
+
|
96 |
+
}
|
97 |
+
|
98 |
+
/**
|
99 |
+
* Return the single config class
|
100 |
+
* @return Mage_Connect_Singleconfig
|
101 |
+
*/
|
102 |
+
public function getSingleConfig()
|
103 |
+
{
|
104 |
+
return $this->_sconfig;
|
105 |
+
}
|
106 |
+
|
107 |
+
/**
|
108 |
+
* Remove empty directories recursively up
|
109 |
+
*
|
110 |
+
* @param string $dir
|
111 |
+
* @param Mage_Connect_Ftp $ftp
|
112 |
+
*/
|
113 |
+
protected function removeEmptyDirectory($dir)
|
114 |
+
{
|
115 |
+
try {
|
116 |
+
if (@rmdir($dir)) {
|
117 |
+
$this->removeEmptyDirectory(dirname($dir));
|
118 |
+
}
|
119 |
+
} catch (Exception $ex) {
|
120 |
+
|
121 |
+
}
|
122 |
+
}
|
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 |
+
}
|
app/code/community/Temando/Installer/Model/Cron.php
ADDED
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|
31 |
+
if (!isset($currentService->links->software_latest_release->version)) {
|
32 |
+
return;
|
33 |
+
}
|
34 |
+
//compare the current version
|
35 |
+
if ($this->_helper->getTemandoVersionNumber() >= $currentService->links->software_latest_release->version) {
|
36 |
+
//if the release version isn't higher than the current version return as there is no update available
|
37 |
+
return;
|
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);
|
47 |
+
$installerModules->addFieldToFilter('update_dismissed', false);
|
48 |
+
foreach ($installerModules as $module) {
|
49 |
+
/* @var $module Temando_Installer_Model_Installer */
|
50 |
+
$module
|
51 |
+
->setUpdateAvailable(true)
|
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 |
+
}
|
app/code/community/Temando/Installer/Model/Installer.php
ADDED
@@ -0,0 +1,209 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
{
|
12 |
+
parent::_construct();
|
13 |
+
$this->_init('temandoinstaller/installer');
|
14 |
+
}
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Gets the highest available service and returns it
|
18 |
+
* @return boolean|object
|
19 |
+
*/
|
20 |
+
public function getCurrentService()
|
21 |
+
{
|
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();
|
29 |
+
$response = $api->getService($request);
|
30 |
+
if (!isset($response->subscriptions)) {
|
31 |
+
return false;
|
32 |
+
}
|
33 |
+
$services = array();
|
34 |
+
foreach ($response->subscriptions as $subscription) {
|
35 |
+
if (!isset($subscription->links->service->href)) {
|
36 |
+
continue;
|
37 |
+
}
|
38 |
+
if (!$subscription->active) {
|
39 |
+
continue;
|
40 |
+
}
|
41 |
+
//collect available services
|
42 |
+
$services[] = $this->getService($subscription->links->service->href);
|
43 |
+
}
|
44 |
+
$currentService = null;
|
45 |
+
foreach ($versions as $version) {
|
46 |
+
foreach ($services as $service) {
|
47 |
+
if (substr($service->slug, 0, -3) == $version) {
|
48 |
+
$currentService = $service;
|
49 |
+
}
|
50 |
+
}
|
51 |
+
}
|
52 |
+
return $currentService;
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Downloads the package
|
57 |
+
* @param object $service
|
58 |
+
* @return string|boolean
|
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 |
+
|
70 |
+
$package = $this->getPackage($latestRelease->raw_url);
|
71 |
+
if (!$package) {
|
72 |
+
return false;
|
73 |
+
}
|
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 {
|
81 |
+
//everything is awesome
|
82 |
+
return $fileTemp;
|
83 |
+
}
|
84 |
+
}
|
85 |
+
|
86 |
+
/**
|
87 |
+
* Gets the package
|
88 |
+
* @param string $uri
|
89 |
+
*/
|
90 |
+
public function getPackage($uri)
|
91 |
+
{
|
92 |
+
$serviceApi = Mage::getModel('temandoinstaller/api_rest_client');
|
93 |
+
/* @var $serviceApi Temando_Installer_Model_Api_Rest_Client */
|
94 |
+
$packageRequest = array();
|
95 |
+
$packageRequest['uri'] = $uri;
|
96 |
+
$packageResponse = $serviceApi->getService($packageRequest, false);
|
97 |
+
//validate the download here
|
98 |
+
return $packageResponse;
|
99 |
+
}
|
100 |
+
|
101 |
+
/**
|
102 |
+
* Gets the service object
|
103 |
+
* @param string $uri
|
104 |
+
* @return object
|
105 |
+
*/
|
106 |
+
public function getService($uri)
|
107 |
+
{
|
108 |
+
$serviceApi = Mage::getModel('temandoinstaller/api_rest_client');
|
109 |
+
/* @var $serviceApi Temando_Installer_Model_Api_Rest_Client */
|
110 |
+
$serviceRequest = array();
|
111 |
+
$serviceRequest['uri'] = $uri;
|
112 |
+
$serviceResponse = $serviceApi->getService($serviceRequest);
|
113 |
+
if(!isset($serviceResponse->services)) {
|
114 |
+
return;
|
115 |
+
}
|
116 |
+
return $serviceResponse->services;
|
117 |
+
}
|
118 |
+
|
119 |
+
/**
|
120 |
+
* Returns the product object
|
121 |
+
* @param string $uri
|
122 |
+
* @return object
|
123 |
+
*/
|
124 |
+
public function getProduct($uri)
|
125 |
+
{
|
126 |
+
$serviceApi = Mage::getModel('temandoinstaller/api_rest_client');
|
127 |
+
/* @var $serviceApi Temando_Installer_Model_Api_Rest_Client */
|
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;
|
135 |
+
}
|
136 |
+
|
137 |
+
/**
|
138 |
+
* Returns the latest release object
|
139 |
+
* @param string $uri
|
140 |
+
* @return object
|
141 |
+
*/
|
142 |
+
public function getLatestRelease($uri)
|
143 |
+
{
|
144 |
+
$serviceApi = Mage::getModel('temandoinstaller/api_rest_client');
|
145 |
+
/* @var $serviceApi Temando_Installer_Model_Api_Rest_Client */
|
146 |
+
$releaseRequest = array();
|
147 |
+
$releaseRequest['uri'] = $uri;
|
148 |
+
$releaseResponse = $serviceApi->getService($releaseRequest);
|
149 |
+
if(!isset($releaseResponse->release)) {
|
150 |
+
return;
|
151 |
+
}
|
152 |
+
return $releaseResponse->release;
|
153 |
+
}
|
154 |
+
|
155 |
+
/**
|
156 |
+
* Returns the service slug name
|
157 |
+
* @param string $uri
|
158 |
+
* @return string
|
159 |
+
*/
|
160 |
+
public function getServiceSlug($uri)
|
161 |
+
{
|
162 |
+
$serviceApi = Mage::getModel('temandoinstaller/api_rest_client');
|
163 |
+
/* @var $serviceApi Temando_Installer_Model_Api_Rest_Client */
|
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;
|
171 |
+
}
|
172 |
+
|
173 |
+
/**
|
174 |
+
* Gets the latest version of the service
|
175 |
+
* @param string $uri
|
176 |
+
* @return string
|
177 |
+
*/
|
178 |
+
public function getServiceLatestVersion($uri)
|
179 |
+
{
|
180 |
+
$serviceApi = Mage::getModel('temandoinstaller/api_rest_client');
|
181 |
+
/* @var $serviceApi Temando_Installer_Model_Api_Rest_Client */
|
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;
|
189 |
+
}
|
190 |
+
|
191 |
+
/**
|
192 |
+
* Returns the latest version uri
|
193 |
+
* @param string $uri
|
194 |
+
* @return string
|
195 |
+
*/
|
196 |
+
public function getServiceLatestVersionUri($uri)
|
197 |
+
{
|
198 |
+
$serviceApi = Mage::getModel('temandoinstaller/api_rest_client');
|
199 |
+
/* @var $serviceApi Temando_Installer_Model_Api_Rest_Client */
|
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 |
+
}
|
app/code/community/Temando/Installer/Model/Mysql4/Installer.php
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
}
|
app/code/community/Temando/Installer/Model/Mysql4/Installer/Collection.php
ADDED
@@ -0,0 +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();
|
9 |
+
$this->_init('temandoinstaller/installer');
|
10 |
+
}
|
11 |
+
|
12 |
+
}
|
app/code/community/Temando/Installer/Model/Tester.php
ADDED
@@ -0,0 +1,104 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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()
|
19 |
+
{
|
20 |
+
$tables = $this->checkTemandoSchema();
|
21 |
+
$details = $this->testClientDetails();
|
22 |
+
|
23 |
+
if(!$tables || !$details) {
|
24 |
+
Mage::getSingleton('adminhtml/session')->addError('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('Cheapest quote: ' . $result->getDescription());
|
36 |
+
}
|
37 |
+
} catch (Exception $e) {
|
38 |
+
Mage::getSingleton('adminhtml/session')->addError('Error connecting to the api: ' . $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('API Connection successful!');
|
47 |
+
return true;
|
48 |
+
} else {
|
49 |
+
Mage::getSingleton('adminhtml/session')->addError('Error connecting to the api: ' . $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('Please add a warehouse to locations.');
|
60 |
+
$tableError++;
|
61 |
+
} else {
|
62 |
+
Mage::getSingleton('adminhtml/session')->addSuccess('Warehouses: ' . $this->checkTemandoWarehouse());
|
63 |
+
}
|
64 |
+
if(!$this->checkTemandoRule()) {
|
65 |
+
Mage::getSingleton('adminhtml/session')->addNotice('Please add a rule to the rule engine.');
|
66 |
+
$tableError++;
|
67 |
+
} else {
|
68 |
+
Mage::getSingleton('adminhtml/session')->addSuccess('Rules: ' . $this->checkTemandoRule());
|
69 |
+
}
|
70 |
+
if($tableError == 0) {
|
71 |
+
return true;
|
72 |
+
} else {
|
73 |
+
return false;
|
74 |
+
}
|
75 |
+
}
|
76 |
+
|
77 |
+
public function checkTemandoWarehouse()
|
78 |
+
{
|
79 |
+
$warehouses = 0;
|
80 |
+
$warehouseCollection = $this->_helper->getTemandoWarehouses();
|
81 |
+
foreach ($warehouseCollection as $warehouse) {
|
82 |
+
$warehouses++;
|
83 |
+
}
|
84 |
+
return $warehouses;
|
85 |
+
}
|
86 |
+
|
87 |
+
public function checkTemandoRule()
|
88 |
+
{
|
89 |
+
$rules = 0;
|
90 |
+
$ruleCollection = $this->_helper->getTemandoRules();
|
91 |
+
foreach ($ruleCollection as $rule) {
|
92 |
+
$rules++;
|
93 |
+
}
|
94 |
+
return $rules;
|
95 |
+
}
|
96 |
+
|
97 |
+
protected function initialize()
|
98 |
+
{
|
99 |
+
if(!$this->_helper) {
|
100 |
+
$this->_helper = Mage::helper('temandoinstaller');
|
101 |
+
}
|
102 |
+
}
|
103 |
+
|
104 |
+
}
|
app/code/community/Temando/Installer/controllers/Adminhtml/InstallerController.php
ADDED
@@ -0,0 +1,262 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
class Temando_Installer_Adminhtml_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 |
+
|
9 |
+
public function indexAction()
|
10 |
+
{
|
11 |
+
$communityChannel = Mage::getModel('temandoinstaller/connect')->getSingleConfig()->isChannel('community');
|
12 |
+
if (!$communityChannel) {
|
13 |
+
Mage::getSingleton('adminhtml/session')->addNotice(self::NOTICE_NO_COMMUNITY);
|
14 |
+
}
|
15 |
+
if ($this->checkSoap()) {
|
16 |
+
Mage::getSingleton('adminhtml/session')->addError(self::ERR_NO_SOAP);
|
17 |
+
return $this->getResponse()->setRedirect($this->getRequest()->getServer('HTTP_REFERER'));
|
18 |
+
} else {
|
19 |
+
$this->loadLayout()->renderLayout();
|
20 |
+
}
|
21 |
+
}
|
22 |
+
|
23 |
+
public function newAction()
|
24 |
+
{
|
25 |
+
$this->_forward('install');
|
26 |
+
}
|
27 |
+
|
28 |
+
public function installAction()
|
29 |
+
{
|
30 |
+
|
31 |
+
$helper = Mage::helper('temandoinstaller');
|
32 |
+
/* @var $helper Temando_Installer_Helper_Data */
|
33 |
+
|
34 |
+
$installer = Mage::getModel('temandoinstaller/installer');
|
35 |
+
/* @var $installer Temando_Installer_Model_Installer */
|
36 |
+
|
37 |
+
|
38 |
+
if ($helper->getTemandoVersion()) {
|
39 |
+
Mage::getSingleton('adminhtml/session')->addError('Temando is already installed.');
|
40 |
+
$this->_redirect('*/*/');
|
41 |
+
return;
|
42 |
+
}
|
43 |
+
|
44 |
+
//check token
|
45 |
+
$currentService = $installer->getCurrentService();
|
46 |
+
if(!$currentService) {
|
47 |
+
Mage::getSingleton('adminhtml/session')->addError('Could not find valid subscription.');
|
48 |
+
$this->_redirect('*/*/');
|
49 |
+
return;
|
50 |
+
}
|
51 |
+
//check the latest release
|
52 |
+
if (!isset($currentService->links->software_latest_release->version)) {
|
53 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('temandoinstaller')->__('Could not find latest release.'));
|
54 |
+
$this->_redirect('*/*/');
|
55 |
+
return;
|
56 |
+
}
|
57 |
+
|
58 |
+
//check file
|
59 |
+
$file = $installer->downloadPackage($currentService);
|
60 |
+
|
61 |
+
if(!$file) {
|
62 |
+
Mage::getSingleton('adminhtml/session')->addError('Error downloading file.');
|
63 |
+
$this->_redirect('*/*/');
|
64 |
+
return;
|
65 |
+
}
|
66 |
+
|
67 |
+
$command = Mage::getModel('temandoinstaller/connect');
|
68 |
+
if($command->install($file)) {
|
69 |
+
|
70 |
+
//clean the cache
|
71 |
+
Mage::app()->cleanCache(array('CONFIG'));
|
72 |
+
|
73 |
+
$installer
|
74 |
+
->setName('Temando')
|
75 |
+
->setToken($helper->getTemandoToken())
|
76 |
+
->setVersion($currentService->links->software_latest_release->version)
|
77 |
+
->setModule(Temando_Installer_Helper_Data::TMD_MODULE_NAME)
|
78 |
+
->setInstallDate(date('Y-m-d H:i:s'))
|
79 |
+
->setUpdateDate(date('Y-m-d H:i:s'))
|
80 |
+
->setUpdateAvailable(false)
|
81 |
+
->setUpdateDismissed(false)
|
82 |
+
->setUpdateDetails(NULL)
|
83 |
+
->setStatus(1)
|
84 |
+
->save();
|
85 |
+
}
|
86 |
+
|
87 |
+
//delete file
|
88 |
+
@unlink($file);
|
89 |
+
|
90 |
+
if(Mage::registry('temandoinstaller_errors')) {
|
91 |
+
foreach (Mage::registry('temandoinstaller_errors') as $error) {
|
92 |
+
Mage::getSingleton('adminhtml/session')->addError($error);
|
93 |
+
}
|
94 |
+
} else {
|
95 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('temandoinstaller')->__('Package successfully installed.'));
|
96 |
+
}
|
97 |
+
|
98 |
+
$this->_redirect('*/*/');
|
99 |
+
return;
|
100 |
+
}
|
101 |
+
|
102 |
+
public function updateAction()
|
103 |
+
{
|
104 |
+
$helper = Mage::helper('temandoinstaller');
|
105 |
+
/* @var $helper Temando_Installer_Helper_Data */
|
106 |
+
|
107 |
+
$installer = Mage::getModel('temandoinstaller/installer');
|
108 |
+
/* @var $installer Temando_Installer_Model_Installer */
|
109 |
+
|
110 |
+
$params = $this->getRequest()->getParams();
|
111 |
+
if (!isset($params['massaction']) || !is_array($params['massaction']) || empty($params['massaction'])) {
|
112 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('temandoinstaller')->__('No modules selected for update.'));
|
113 |
+
$this->_redirect('*/*/');
|
114 |
+
return;
|
115 |
+
}
|
116 |
+
|
117 |
+
//check token
|
118 |
+
$currentService = $installer->getCurrentService();
|
119 |
+
if (!$currentService) {
|
120 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('temandoinstaller')->__('Could not find valid service.'));
|
121 |
+
$this->_redirect('*/*/');
|
122 |
+
return;
|
123 |
+
}
|
124 |
+
//check the latest release
|
125 |
+
if (!isset($currentService->links->software_latest_release->version)) {
|
126 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('temandoinstaller')->__('Could not find latest release.'));
|
127 |
+
$this->_redirect('*/*/');
|
128 |
+
return;
|
129 |
+
}
|
130 |
+
//compare the current version
|
131 |
+
if ($helper->getTemandoVersionNumber() >= $currentService->links->software_latest_release->version) {
|
132 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('temandoinstaller')->__('Current version is greater than or equal to the latest release.'));
|
133 |
+
$this->_redirect('*/*/');
|
134 |
+
return;
|
135 |
+
}
|
136 |
+
|
137 |
+
$installerIds = $params['massaction'];
|
138 |
+
|
139 |
+
//at the moment only one product will be on the grid - the mass action has been added for future use
|
140 |
+
foreach ($installerIds as $id) {
|
141 |
+
//check file
|
142 |
+
$file = $installer->downloadPackage($currentService);
|
143 |
+
|
144 |
+
if(!$file) {
|
145 |
+
Mage::getSingleton('adminhtml/session')->addError('Error downloading file.');
|
146 |
+
$this->_redirect('*/*/');
|
147 |
+
return;
|
148 |
+
}
|
149 |
+
|
150 |
+
$installer->load($id);
|
151 |
+
$command = Mage::getModel('temandoinstaller/connect');
|
152 |
+
if(!$command->uninstall($installer->getModule())) {
|
153 |
+
Mage::getSingleton('adminhtml/session')->addError('There was an error uninstalling the current module.');
|
154 |
+
$this->_redirect('*/*/');
|
155 |
+
return;
|
156 |
+
}
|
157 |
+
//clean cache before installing new module
|
158 |
+
Mage::app()->cleanCache(array('CONFIG'));
|
159 |
+
if($command->install($file)) {
|
160 |
+
//clean the cache after installing new module
|
161 |
+
Mage::app()->cleanCache(array('CONFIG'));
|
162 |
+
$installer
|
163 |
+
->setName('Temando')
|
164 |
+
->setToken($helper->getTemandoToken())
|
165 |
+
->setVersion($currentService->links->software_latest_release->version)
|
166 |
+
->setModule(Temando_Installer_Helper_Data::TMD_MODULE_NAME)
|
167 |
+
->setUpdateDate(date('Y-m-d H:i:s'))
|
168 |
+
->setUpdateAvailable(false)
|
169 |
+
->setUpdateDismissed(false)
|
170 |
+
->setUpdateDetails(NULL)
|
171 |
+
->setStatus(1)
|
172 |
+
->save();
|
173 |
+
}
|
174 |
+
|
175 |
+
//delete file
|
176 |
+
@unlink($file);
|
177 |
+
}
|
178 |
+
|
179 |
+
if(Mage::registry('temandoinstaller_errors')) {
|
180 |
+
foreach (Mage::registry('temandoinstaller_errors') as $error) {
|
181 |
+
Mage::getSingleton('adminhtml/session')->addError($error);
|
182 |
+
}
|
183 |
+
} else {
|
184 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('temandoinstaller')->__('Package successfully updated.'));
|
185 |
+
}
|
186 |
+
|
187 |
+
$this->_redirect('*/*/');
|
188 |
+
}
|
189 |
+
|
190 |
+
public function uninstallAction()
|
191 |
+
{
|
192 |
+
$helper = Mage::helper('temandoinstaller');
|
193 |
+
/* @var $helper Temando_Installer_Helper_Data */
|
194 |
+
|
195 |
+
$params = $this->getRequest()->getParams();
|
196 |
+
if (!isset($params['massaction']) || !is_array($params['massaction']) || empty($params['massaction'])) {
|
197 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('temandoinstaller')->__('No modules selected for removal.'));
|
198 |
+
$this->_redirect('*/*/');
|
199 |
+
}
|
200 |
+
|
201 |
+
//uninstall does not require token checks
|
202 |
+
|
203 |
+
$installerIds = $params['massaction'];
|
204 |
+
|
205 |
+
foreach ($installerIds as $id) {
|
206 |
+
$installer = Mage::getModel('temandoinstaller/installer')->load($id);
|
207 |
+
$command = Mage::getModel('temandoinstaller/connect');
|
208 |
+
if($command->uninstall($installer->getModule())) {
|
209 |
+
$installer->delete();
|
210 |
+
}
|
211 |
+
}
|
212 |
+
|
213 |
+
if(Mage::registry('temandoinstaller_errors')) {
|
214 |
+
foreach (Mage::registry('temandoinstaller_errors') as $error) {
|
215 |
+
Mage::getSingleton('adminhtml/session')->addError($error);
|
216 |
+
}
|
217 |
+
} else {
|
218 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('temandoinstaller')->__('Package successfully uninstalled.'));
|
219 |
+
}
|
220 |
+
|
221 |
+
Mage::app()->cleanCache(array('CONFIG'));
|
222 |
+
$this->_redirect('*/*/');
|
223 |
+
return;
|
224 |
+
}
|
225 |
+
|
226 |
+
public function testConnectionSettingsAction()
|
227 |
+
{
|
228 |
+
Mage::getModel('temandoinstaller/tester')->testSettings();
|
229 |
+
return $this->getResponse()->setRedirect($this->getRequest()->getServer('HTTP_REFERER'));
|
230 |
+
}
|
231 |
+
|
232 |
+
public function dismissUpdateAction()
|
233 |
+
{
|
234 |
+
$module_id = $this->getRequest()->getParam('id');
|
235 |
+
$module = Mage::getModel('temandoinstaller/installer')->load($module_id);
|
236 |
+
/* @var $module Temando_Installer_Model_Installer */
|
237 |
+
|
238 |
+
if (!$module->getId()) {
|
239 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('temandoinstaller')->__('Modules does not exist.'));
|
240 |
+
} else {
|
241 |
+
$module
|
242 |
+
->setUpdateDismissed(true)
|
243 |
+
->save();
|
244 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('temandoinstaller')->__('Temando update has been dismissed.'));
|
245 |
+
}
|
246 |
+
return $this->getResponse()->setRedirect($this->getRequest()->getServer('HTTP_REFERER'));
|
247 |
+
}
|
248 |
+
|
249 |
+
/**
|
250 |
+
* Checks to see if the SOAP extension is loaded
|
251 |
+
* @return boolean
|
252 |
+
*/
|
253 |
+
public function checkSoap() {
|
254 |
+
if (!extension_loaded('soap')) {
|
255 |
+
return true;
|
256 |
+
} else {
|
257 |
+
return false;
|
258 |
+
}
|
259 |
+
}
|
260 |
+
|
261 |
+
}
|
262 |
+
|
app/code/community/Temando/Installer/data/temandoinstaller_setup/data-install-1.0.0.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
set_time_limit(0);
|
4 |
+
|
5 |
+
/* @var $this Mage_Eav_Model_Entity_Setup */
|
6 |
+
/* @var $installer Mage_Eav_Model_Entity_Setup */
|
7 |
+
|
8 |
+
$installer = $this;
|
9 |
+
$installer->startSetup();
|
10 |
+
|
11 |
+
$helper = Mage::helper('temandoinstaller');
|
12 |
+
/* @var $helper Temando_Installer_Helper_Data */
|
13 |
+
|
14 |
+
//check if Temando is already installed and add a record of the current module if it is
|
15 |
+
if ($helper->getTemandoVersion()) {
|
16 |
+
|
17 |
+
$versionNumber = (string) Mage::getConfig()->getNode()->modules->Temando_Temando->version;
|
18 |
+
$versionName = 'Temando ' . ucfirst($helper->getTemandoVersionName());
|
19 |
+
//because there is no record of when it was originally installed/updated we will enter todays date
|
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();
|
app/code/community/Temando/Installer/etc/adminhtml.xml
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<menu>
|
4 |
+
<system>
|
5 |
+
<children>
|
6 |
+
<extensions translate="title" module="connect">
|
7 |
+
<children>
|
8 |
+
<return translate="title" module="connect">
|
9 |
+
<title>Temando Installer Manager</title>
|
10 |
+
<sort_order>998</sort_order>
|
11 |
+
<action>temandoinstaller/adminhtml_installer</action>
|
12 |
+
</return>
|
13 |
+
</children>
|
14 |
+
</extensions>
|
15 |
+
</children>
|
16 |
+
</system>
|
17 |
+
</menu>
|
18 |
+
<acl>
|
19 |
+
<resources>
|
20 |
+
<all>
|
21 |
+
<title>Allow Everything</title>
|
22 |
+
</all>
|
23 |
+
<admin>
|
24 |
+
<children>
|
25 |
+
<system>
|
26 |
+
<children>
|
27 |
+
<config>
|
28 |
+
<children>
|
29 |
+
<temandoinstaller>
|
30 |
+
<title>Temando Installer</title>
|
31 |
+
</temandoinstaller>
|
32 |
+
</children>
|
33 |
+
</config>
|
34 |
+
</children>
|
35 |
+
</system>
|
36 |
+
</children>
|
37 |
+
</admin>
|
38 |
+
</resources>
|
39 |
+
</acl>
|
40 |
+
</config>
|
app/code/community/Temando/Installer/etc/config.xml
ADDED
@@ -0,0 +1,93 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Temando_Installer>
|
5 |
+
<version>1.0.0</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 |
+
<temandoinstaller>
|
56 |
+
<use>admin</use>
|
57 |
+
<args>
|
58 |
+
<module>Temando_Installer</module>
|
59 |
+
<frontName>temandoinstaller</frontName>
|
60 |
+
</args>
|
61 |
+
</temandoinstaller>
|
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 |
+
-->
|
83 |
+
</adminhtml>
|
84 |
+
<crontab>
|
85 |
+
<jobs>
|
86 |
+
<temandoinstaller_daily_update_check>
|
87 |
+
<!-- Daily at 11pm -->
|
88 |
+
<schedule><cron_expr>0 23 * * *</cron_expr></schedule>
|
89 |
+
<run><model>temandoinstaller/cron::checkReleases</model></run>
|
90 |
+
</temandoinstaller_daily_update_check>
|
91 |
+
</jobs>
|
92 |
+
</crontab>
|
93 |
+
</config>
|
app/code/community/Temando/Installer/etc/system.xml
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<sections>
|
4 |
+
<temandoinstaller>
|
5 |
+
<label>Temando Installer</label>
|
6 |
+
<tab>sales</tab>
|
7 |
+
<frontend_type>text</frontend_type>
|
8 |
+
<sort_order>322</sort_order>
|
9 |
+
<show_in_default>1</show_in_default>
|
10 |
+
<show_in_website>0</show_in_website>
|
11 |
+
<show_in_store>0</show_in_store>
|
12 |
+
<groups>
|
13 |
+
<general translate="label">
|
14 |
+
<label>General</label>
|
15 |
+
<sort_order>10</sort_order>
|
16 |
+
<show_in_default>1</show_in_default>
|
17 |
+
<show_in_website>1</show_in_website>
|
18 |
+
<show_in_store>1</show_in_store>
|
19 |
+
<comment><![CDATA[<div style="padding:10px;background-color:#fff;border:1px solid #ddd;margin-bottom:7px;">If you don't have a Temando account, you can <a href="https://www.temando.com/register/" target="_blank">Sign Up</a> immediately.</div>]]></comment>
|
20 |
+
<fields>
|
21 |
+
<token>
|
22 |
+
<label>Access Token</label>
|
23 |
+
<frontend_type>text</frontend_type>
|
24 |
+
<sort_order>10</sort_order>
|
25 |
+
<show_in_default>1</show_in_default>
|
26 |
+
<show_in_website>1</show_in_website>
|
27 |
+
<show_in_store>1</show_in_store>
|
28 |
+
</token>
|
29 |
+
<manage_button translate="label">
|
30 |
+
<label></label>
|
31 |
+
<frontend_model>temandoinstaller/adminhtml_system_config_form_button_manage</frontend_model>
|
32 |
+
<frontend_type>button</frontend_type>
|
33 |
+
<sort_order>20</sort_order>
|
34 |
+
<show_in_default>1</show_in_default>
|
35 |
+
<show_in_website>1</show_in_website>
|
36 |
+
<show_in_store>1</show_in_store>
|
37 |
+
</manage_button>
|
38 |
+
</fields>
|
39 |
+
</general>
|
40 |
+
</groups>
|
41 |
+
</temandoinstaller>
|
42 |
+
</sections>
|
43 |
+
</config>
|
app/code/community/Temando/Installer/sql/temandoinstaller_setup/mysql4-install-1.0.0.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
set_time_limit(0);
|
4 |
+
|
5 |
+
/* @var $this Mage_Eav_Model_Entity_Setup */
|
6 |
+
/* @var $installer Mage_Eav_Model_Entity_Setup */
|
7 |
+
|
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();
|
app/design/adminhtml/default/default/layout/temandoinstaller.xml
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<layout>
|
3 |
+
<default>
|
4 |
+
<reference name="notifications">
|
5 |
+
<block type="temandoinstaller/adminhtml_notifications" name="temando_installer_notifications" template="temando/installer/notifications.phtml"/>
|
6 |
+
</reference>
|
7 |
+
</default>
|
8 |
+
<temandoinstaller_adminhtml_installer_index>
|
9 |
+
<reference name="content">
|
10 |
+
<block type="temandoinstaller/adminhtml_installer" name="temando_installer">
|
11 |
+
<block type="temandoinstaller/adminhtml_installer_grid" name="temando_installer_grid" />
|
12 |
+
</block>
|
13 |
+
</reference>
|
14 |
+
</temandoinstaller_adminhtml_installer_index>
|
15 |
+
</layout>
|
app/design/adminhtml/default/default/template/temando/installer/notifications.phtml
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/* @var $this Temando_Installer_Block_Adminhtml_Notifications */
|
4 |
+
?>
|
5 |
+
<?php foreach ($this->getModuleNotifications() as $module):
|
6 |
+
/* @var $module Temando_Installer_Model_Installer */ ?>
|
7 |
+
<div class="notification-global notification-global-notice">
|
8 |
+
|
9 |
+
<span class="f-right">
|
10 |
+
<a href="<?php echo $this->getUrl('temandoinstaller/adminhtml_installer', array('_secure' => Mage::app()->getStore()->isCurrentlySecure())); ?>">Update</a> |
|
11 |
+
<a href="<?php echo $this->getUrl('temandoinstaller/adminhtml_installer/dismissUpdate', array('id' => $module->getId(), '_secure' => Mage::app()->getStore()->isCurrentlySecure())); ?>">Dismiss</a>
|
12 |
+
</span>
|
13 |
+
|
14 |
+
<strong class="label">Temando Message:</strong> <?php echo $module->getUpdateDetails(); ?>
|
15 |
+
</div>
|
16 |
+
<?php endforeach; ?>
|
app/etc/modules/Temando_Installer.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Temando_Installer>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>community</codePool>
|
7 |
+
</Temando_Installer>
|
8 |
+
</modules>
|
9 |
+
</config>
|
package.xml
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>Temando_Installer</name>
|
4 |
+
<version>1.0.0</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license uri="http://opensource.org/licenses/osl-3.0.php">Open Software Licence</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>The Temando installer will install the latest version of Temando’s Magento Extension on your Magento site.</summary>
|
10 |
+
<description>Temando is a powerful multi-carrier fulfilment platform which gives retailers the ability to manage the shipping experience from the shopping cart to delivery and all the processes in between.
|
11 |
+

|
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.
|
13 |
+
</description>
|
14 |
+
<notes>v1.0.0
|
15 |
+
Temando Installer
|
16 |
+

|
17 |
+
- Installs Temando extension based on access token
|
18 |
+
- U.S. Release
|
19 |
+
- Includes Endicia Integration</notes>
|
20 |
+
<authors><author><name>Temando</name><user>Temando</user><email>marketing@temando.com</email></author></authors>
|
21 |
+
<date>2015-01-28</date>
|
22 |
+
<time>23:32:38</time>
|
23 |
+
<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="c75798c169cc2c4c9042bde02ea2f4f9"/><file name="Notifications.php" hash="1af33eec059097349d4481c197958d5e"/><dir name="System"><dir name="Config"><dir name="Form"><dir name="Button"><file name="Manage.php" hash="e2af14400e2da1d94d07ff9c7efbac7c"/></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="0e420baf94cb7e4ababf56940648b420"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="InstallerController.php" hash="3e8edc957bcafd383ac5f011009a7da9"/></dir></dir><dir name="data"><dir name="temandoinstaller_setup"><file name="data-install-1.0.0.php" hash="3f06f83993f9eecb7a22e57ac807968a"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="b2094638aea7fe73f45176883d104985"/><file name="config.xml" hash="408e2924d7858a2de690e5e9592479f8"/><file name="system.xml" hash="f7a5b44eeeef33e720777c245d7cc2d0"/></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="6e3b298dd6a26124246228c8b1d15c0c"/></dir><dir name="template"><dir name="temando"><dir name="installer"><file name="notifications.phtml" hash="8e850625e3698ac30c18602abbd6625a"/></dir></dir></dir></dir></dir></dir></target></contents>
|
24 |
+
<compatible/>
|
25 |
+
<dependencies><required><php><min>5.2.13</min><max>6.0.0</max></php></required></dependencies>
|
26 |
+
</package>
|