Version Notes
- Changes to adminhtml controllers for security update SUPEE-6788
Download this release
Release Info
Developer | Temando |
Extension | Temando_Installer |
Version | 1.0.3 |
Comparing to | |
See all releases |
Code changes from version 1.0.2 to 1.0.3
- app/code/community/Temando/Installer/Block/Adminhtml/Installer.php +27 -27
- app/code/community/Temando/Installer/Block/Adminhtml/Installer/Grid.php +78 -78
- app/code/community/Temando/Installer/Block/Adminhtml/Notifications.php +14 -14
- app/code/community/Temando/Installer/Block/Adminhtml/System/Config/Form/Button/Manage.php +17 -17
- app/code/community/Temando/Installer/Helper/Data.php +245 -245
- app/code/community/Temando/Installer/Model/Api/Rest/Client.php +117 -117
- app/code/community/Temando/Installer/Model/Connect.php +144 -144
- app/code/community/Temando/Installer/Model/Cron.php +66 -66
- app/code/community/Temando/Installer/Model/Installer.php +209 -209
- app/code/community/Temando/Installer/Model/Mysql4/Installer.php +11 -11
- app/code/community/Temando/Installer/Model/Mysql4/Installer/Collection.php +12 -12
- app/code/community/Temando/Installer/Model/Tester.php +104 -104
- app/code/community/Temando/Installer/controllers/Adminhtml/{InstallerController.php → Temandoinstaller/InstallerController.php} +266 -266
- app/code/community/Temando/Installer/data/temandoinstaller_setup/data-install-1.0.0.php +30 -30
- app/code/community/Temando/Installer/data/temandoinstaller_setup/data-upgrade-1.0.2-1.0.3.php +27 -0
- app/code/community/Temando/Installer/etc/adminhtml.xml +40 -40
- app/code/community/Temando/Installer/etc/config.xml +92 -93
- app/code/community/Temando/Installer/etc/system.xml +43 -43
- app/code/community/Temando/Installer/sql/temandoinstaller_setup/mysql4-install-1.0.0.php +30 -30
- app/design/adminhtml/default/default/layout/temandoinstaller.xml +15 -15
- app/design/adminhtml/default/default/template/temando/installer/notifications.phtml +16 -16
- app/etc/modules/Temando_Installer.xml +8 -8
- app/locale/fr_FR/Temando_Installer.csv +44 -44
- package.xml +5 -10
app/code/community/Temando/Installer/Block/Adminhtml/Installer.php
CHANGED
@@ -1,27 +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('
|
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 |
-
|
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('adminhtml/temandoinstaller_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
CHANGED
@@ -1,78 +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 |
-
}
|
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
CHANGED
@@ -1,14 +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 |
-
|
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
CHANGED
@@ -1,17 +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(Mage::helper('temandoinstaller')->__('Manage Temando Installation'))
|
11 |
-
->setOnClick('setLocation(\'' . $this->getUrl('
|
12 |
-
->setTitle(Mage::helper('temandoinstaller')->__('Manage Temando Installation'))
|
13 |
-
->toHtml();
|
14 |
-
return $html;
|
15 |
-
}
|
16 |
-
|
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(Mage::helper('temandoinstaller')->__('Manage Temando Installation'))
|
11 |
+
->setOnClick('setLocation(\'' . $this->getUrl('adminhtml/temandoinstaller_installer') .'\')')
|
12 |
+
->setTitle(Mage::helper('temandoinstaller')->__('Manage Temando Installation'))
|
13 |
+
->toHtml();
|
14 |
+
return $html;
|
15 |
+
}
|
16 |
+
|
17 |
+
}
|
app/code/community/Temando/Installer/Helper/Data.php
CHANGED
@@ -1,246 +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 |
}
|
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
CHANGED
@@ -1,118 +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 |
}
|
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
CHANGED
@@ -1,144 +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 |
-
}
|
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
CHANGED
@@ -1,66 +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 |
-
}
|
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
CHANGED
@@ -1,209 +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 |
-
}
|
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
CHANGED
@@ -1,11 +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 |
-
}
|
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
CHANGED
@@ -1,12 +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 |
-
}
|
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
CHANGED
@@ -1,104 +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(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 |
-
}
|
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 |
-
}
|
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(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 |
+
}
|
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 → Temandoinstaller/InstallerController.php}
RENAMED
@@ -1,266 +1,266 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
class
|
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 |
+
|
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 |
+
|
app/code/community/Temando/Installer/data/temandoinstaller_setup/data-install-1.0.0.php
CHANGED
@@ -1,30 +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();
|
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/data/temandoinstaller_setup/data-upgrade-1.0.2-1.0.3.php
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
set_time_limit(0);
|
4 |
+
|
5 |
+
$installer = $this;
|
6 |
+
$installer->startSetup();
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Remove unused files from the Adminhtml controller directory
|
10 |
+
*
|
11 |
+
* This is because of Magento security patch SUPEE-6788
|
12 |
+
* Supresses errors when trying to delete.
|
13 |
+
*/
|
14 |
+
$temandoFiles = array (
|
15 |
+
'InstallerController',
|
16 |
+
);
|
17 |
+
|
18 |
+
foreach ($temandoFiles as $temandoFile) {
|
19 |
+
$directory = Mage::getModuleDir('controllers', 'Temando_Installer').DS.'Adminhtml';
|
20 |
+
$filename = $directory.DS.$temandoFile.'.php';
|
21 |
+
if (!file_exists($filename)) {
|
22 |
+
continue;
|
23 |
+
}
|
24 |
+
@unlink($filename);
|
25 |
+
}
|
26 |
+
|
27 |
+
$installer->endSetup();
|
app/code/community/Temando/Installer/etc/adminhtml.xml
CHANGED
@@ -1,40 +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>
|
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>
|
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>adminhtml/temandoinstaller_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
CHANGED
@@ -1,93 +1,92 @@
|
|
1 |
-
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
-
<config>
|
3 |
-
<modules>
|
4 |
-
<Temando_Installer>
|
5 |
-
<version>1.0.
|
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 |
-
<
|
56 |
-
<
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
</args>
|
61 |
-
</
|
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 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
<
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
</config>
|
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>
|
|
app/code/community/Temando/Installer/etc/system.xml
CHANGED
@@ -1,43 +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://sso.temando.com/signup/" 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>
|
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://sso.temando.com/signup/" 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
CHANGED
@@ -1,30 +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();
|
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
CHANGED
@@ -1,15 +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 |
-
<
|
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 |
-
</
|
15 |
-
</layout>
|
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 |
+
<adminhtml_temandoinstaller_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 |
+
</adminhtml_temandoinstaller_installer_index>
|
15 |
+
</layout>
|
app/design/adminhtml/default/default/template/temando/installer/notifications.phtml
CHANGED
@@ -1,16 +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('
|
11 |
-
<a href="<?php echo $this->getUrl('
|
12 |
-
</span>
|
13 |
-
|
14 |
-
<strong class="label"
|
15 |
-
</div>
|
16 |
-
<?php endforeach; ?>
|
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('adminhtml/temandoinstaller_installer', array('_secure' => Mage::app()->getStore()->isCurrentlySecure())); ?>">Update</a> |
|
11 |
+
<a href="<?php echo $this->getUrl('adminhtml/temandoinstaller_installer/dismissUpdate', array('id' => $module->getId(), '_secure' => Mage::app()->getStore()->isCurrentlySecure())); ?>">Dismiss</a>
|
12 |
+
</span>
|
13 |
+
|
14 |
+
<strong class="label"><?php echo Mage::helper('temandoinstaller')->__('Temando Message:'); ?></strong> <?php echo $module->getUpdateDetails(); ?>
|
15 |
+
</div>
|
16 |
+
<?php endforeach; ?>
|
app/etc/modules/Temando_Installer.xml
CHANGED
@@ -1,9 +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>
|
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>
|
app/locale/fr_FR/Temando_Installer.csv
CHANGED
@@ -1,44 +1,44 @@
|
|
1 |
-
"Manage Temando","Gérer Temando"
|
2 |
-
"Install Temando","Installer Temando"
|
3 |
-
"Test Connection Settings","Test des paramètres de connexion"
|
4 |
-
"Name","Nom"
|
5 |
-
"Version","Version"
|
6 |
-
"Token","Ticket"
|
7 |
-
"Install date","Date d'installation"
|
8 |
-
"Update","Mise à jour"
|
9 |
-
"Update date","Date de mise à jour"
|
10 |
-
"Update available","Mise à jour disponible"
|
11 |
-
"Uninstall","Désinstaller"
|
12 |
-
"Are you sure you want to uninstall the Temando module?","Voulez-vous vraiment désinstaller le module Temando ?"
|
13 |
-
"Are you sure you want to update the Temando module?","Voulez-vous vraiment mettre à jour le module Temando ?"
|
14 |
-
"Could not find latest release.","Impossible de trouver la dernière version."
|
15 |
-
"Package successfully installed.","Le module a été installé avec succès."
|
16 |
-
"No modules selected for update.","Vous n'avez sélectionné aucun module à mettre à jour."
|
17 |
-
"Could not find valid service.","Impossible de trouver un service valide."
|
18 |
-
"Current version is greater than or equal to the latest release.","La version actuelle est plus récente ou similaire à la dernière version disponible."
|
19 |
-
"Package successfully updated.","Le module a été mis à jour avec succès."
|
20 |
-
"No modules selected for removal.","Vous n'avez sélectionné aucun module à supprimer."
|
21 |
-
"Package successfully uninstalled.","Le module a été désinstallé."
|
22 |
-
"Modules does not exist.","Le module n'existe pas."
|
23 |
-
"Temando update has been dismissed.","La mise à jour Temando a été rejetée."
|
24 |
-
"Manage Temando Installation","Gérer l'installation de Temando"
|
25 |
-
"SOAP is not enabled on this server. Please enable SOAP to use the Temando plugin.","SOAP n'est pas activé sur ce serveur. Il est nécessaire de l'activer pour utiliser le plugin Temando"
|
26 |
-
"The community channel cannot be found. Please install the community channel for Magento Connect.","Impossible d'accéder au "community channel". Veuillez installer le "community channel" dans Magento Connect."
|
27 |
-
"Note: if you have any customisations relating to your Temando extension, upgrading your Temando extension will remove these. Contact your Temando representative for guidance.","Attention, si vous avez des modifications sur votre extension Temando, le changement de version les supprimera. Contactez votre responsable Temando si vous avez besoin d'aide."
|
28 |
-
"Note: if upgrading from the Starter Extension to a Business Extension, please re-index your products.","Note : Si vous passez de la version Starter à la version Business, vous devez réindexer votre base produit"
|
29 |
-
"Temando is already installed.","Temando est déjà installé. "
|
30 |
-
"Could not find valid subscription.","Impossible de trouver un abonnement valide."
|
31 |
-
"Error downloading file.","Erreur lors du téléchargement du fichier."
|
32 |
-
"There was an error uninstalling the current module.","Une erreur s'est produite lors de la désinstallation du module actuel."
|
33 |
-
"Could not complete get quotes test.","Le test de requête d'offres de transport (GetQuote) a échoué."
|
34 |
-
"Cheapest quote: %s","Offre la moins chère : %s"
|
35 |
-
"Error connecting to the api: %s","Erreur lors de la connexion à l'API : %s"
|
36 |
-
"API Connection successful!","La connection à l'API a réussi."
|
37 |
-
"Please add a warehouse to locations.","Veuillez ajouter un entrepôt aux lieux"
|
38 |
-
"Warehouses: %s","Entrepôts : %s"
|
39 |
-
"Please add a rule to the rule engine.","Veuillez ajouter une règle au moteur de règles"
|
40 |
-
"Rules: %s","Règles : %s"
|
41 |
-
"<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://sso.temando.com/signup/"" target=""_blank"">Sign Up</a> immediately.</div>","<div style=""padding:10px;background-color:#fff;border:1px solid #ddd;margin-bottom:7px;"">Si vous n'avez pas de compte Temando, vous pouvez <a href=""https://sso.temando.com/signup/"" target=""_blank"">vous inscrire</a>.</div>"
|
42 |
-
"General","Générales"
|
43 |
-
"Access Token","Accéder au ticket d'accés"
|
44 |
-
"Temando Installer","Programme d'installation Temando"
|
1 |
+
"Manage Temando","Gérer Temando"
|
2 |
+
"Install Temando","Installer Temando"
|
3 |
+
"Test Connection Settings","Test des paramètres de connexion"
|
4 |
+
"Name","Nom"
|
5 |
+
"Version","Version"
|
6 |
+
"Token","Ticket"
|
7 |
+
"Install date","Date d'installation"
|
8 |
+
"Update","Mise à jour"
|
9 |
+
"Update date","Date de mise à jour"
|
10 |
+
"Update available","Mise à jour disponible"
|
11 |
+
"Uninstall","Désinstaller"
|
12 |
+
"Are you sure you want to uninstall the Temando module?","Voulez-vous vraiment désinstaller le module Temando ?"
|
13 |
+
"Are you sure you want to update the Temando module?","Voulez-vous vraiment mettre à jour le module Temando ?"
|
14 |
+
"Could not find latest release.","Impossible de trouver la dernière version."
|
15 |
+
"Package successfully installed.","Le module a été installé avec succès."
|
16 |
+
"No modules selected for update.","Vous n'avez sélectionné aucun module à mettre à jour."
|
17 |
+
"Could not find valid service.","Impossible de trouver un service valide."
|
18 |
+
"Current version is greater than or equal to the latest release.","La version actuelle est plus récente ou similaire à la dernière version disponible."
|
19 |
+
"Package successfully updated.","Le module a été mis à jour avec succès."
|
20 |
+
"No modules selected for removal.","Vous n'avez sélectionné aucun module à supprimer."
|
21 |
+
"Package successfully uninstalled.","Le module a été désinstallé."
|
22 |
+
"Modules does not exist.","Le module n'existe pas."
|
23 |
+
"Temando update has been dismissed.","La mise à jour Temando a été rejetée."
|
24 |
+
"Manage Temando Installation","Gérer l'installation de Temando"
|
25 |
+
"SOAP is not enabled on this server. Please enable SOAP to use the Temando plugin.","SOAP n'est pas activé sur ce serveur. Il est nécessaire de l'activer pour utiliser le plugin Temando"
|
26 |
+
"The community channel cannot be found. Please install the community channel for Magento Connect.","Impossible d'accéder au "community channel". Veuillez installer le "community channel" dans Magento Connect."
|
27 |
+
"Note: if you have any customisations relating to your Temando extension, upgrading your Temando extension will remove these. Contact your Temando representative for guidance.","Attention, si vous avez des modifications sur votre extension Temando, le changement de version les supprimera. Contactez votre responsable Temando si vous avez besoin d'aide."
|
28 |
+
"Note: if upgrading from the Starter Extension to a Business Extension, please re-index your products.","Note : Si vous passez de la version Starter à la version Business, vous devez réindexer votre base produit"
|
29 |
+
"Temando is already installed.","Temando est déjà installé. "
|
30 |
+
"Could not find valid subscription.","Impossible de trouver un abonnement valide."
|
31 |
+
"Error downloading file.","Erreur lors du téléchargement du fichier."
|
32 |
+
"There was an error uninstalling the current module.","Une erreur s'est produite lors de la désinstallation du module actuel."
|
33 |
+
"Could not complete get quotes test.","Le test de requête d'offres de transport (GetQuote) a échoué."
|
34 |
+
"Cheapest quote: %s","Offre la moins chère : %s"
|
35 |
+
"Error connecting to the api: %s","Erreur lors de la connexion à l'API : %s"
|
36 |
+
"API Connection successful!","La connection à l'API a réussi."
|
37 |
+
"Please add a warehouse to locations.","Veuillez ajouter un entrepôt aux lieux"
|
38 |
+
"Warehouses: %s","Entrepôts : %s"
|
39 |
+
"Please add a rule to the rule engine.","Veuillez ajouter une règle au moteur de règles"
|
40 |
+
"Rules: %s","Règles : %s"
|
41 |
+
"<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://sso.temando.com/signup/"" target=""_blank"">Sign Up</a> immediately.</div>","<div style=""padding:10px;background-color:#fff;border:1px solid #ddd;margin-bottom:7px;"">Si vous n'avez pas de compte Temando, vous pouvez <a href=""https://sso.temando.com/signup/"" target=""_blank"">vous inscrire</a>.</div>"
|
42 |
+
"General","Générales"
|
43 |
+
"Access Token","Accéder au ticket d'accés"
|
44 |
+
"Temando Installer","Programme d'installation Temando"
|
package.xml
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Temando_Installer</name>
|
4 |
-
<version>1.0.
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">Open Software Licence</license>
|
7 |
<channel>community</channel>
|
@@ -10,17 +10,12 @@
|
|
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 |
-

|
14 |
-
Supporting French Language
|
15 |
</description>
|
16 |
-
<notes>
|
17 |
-
Temando Installer
|
18 |
-

|
19 |
-
- Updated notices</notes>
|
20 |
<authors><author><name>Temando</name><user>Temando</user><email>marketing@temando.com</email></author></authors>
|
21 |
-
<date>2015-
|
22 |
-
<time>01:
|
23 |
-
<contents><target name="mageetc"><dir name="modules"><file name="Temando_Installer.xml" hash="
|
24 |
<compatible/>
|
25 |
<dependencies><required><php><min>5.2.13</min><max>6.0.0</max></php></required></dependencies>
|
26 |
</package>
|
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>
|
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>- 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>
|