Easy_CEM - Version 1.0.5

Version Notes

Derived from MageParts CEM

Download this release

Release Info

Developer Magento Core Team
Extension Easy_CEM
Version 1.0.5
Comparing to
See all releases


Version 1.0.5

Files changed (55) hide show
  1. app/code/community/Easy/CEM/Block/Adminhtml/Licenses/Edit.php +46 -0
  2. app/code/community/Easy/CEM/Block/Adminhtml/Licenses/Edit/Form.php +35 -0
  3. app/code/community/Easy/CEM/Block/Adminhtml/Licenses/Edit/Tab/LostCem.php +82 -0
  4. app/code/community/Easy/CEM/Block/Adminhtml/Licenses/Edit/Tab/LostLicense.php +82 -0
  5. app/code/community/Easy/CEM/Block/Adminhtml/Licenses/Edit/Tabs.php +57 -0
  6. app/code/community/Easy/CEM/Block/Adminhtml/Packages.php +49 -0
  7. app/code/community/Easy/CEM/Block/Adminhtml/Packages/Edit.php +125 -0
  8. app/code/community/Easy/CEM/Block/Adminhtml/Packages/Grid.php +114 -0
  9. app/code/community/Easy/CEM/Block/Adminhtml/Packages/Grid/Renderer/UpdateAvailable.php +42 -0
  10. app/code/community/Easy/CEM/Helper/Data.php +24 -0
  11. app/code/community/Easy/CEM/Model/Licenses.php +78 -0
  12. app/code/community/Easy/CEM/Model/Mysql4/Licenses.php +60 -0
  13. app/code/community/Easy/CEM/Model/Mysql4/Licenses/Collection.php +32 -0
  14. app/code/community/Easy/CEM/Model/Mysql4/Packages.php +93 -0
  15. app/code/community/Easy/CEM/Model/Mysql4/Packages/Collection.php +111 -0
  16. app/code/community/Easy/CEM/Model/Mysql4/Services.php +125 -0
  17. app/code/community/Easy/CEM/Model/Mysql4/Services/Collection.php +44 -0
  18. app/code/community/Easy/CEM/Model/Observer.php +81 -0
  19. app/code/community/Easy/CEM/Model/Packages.php +479 -0
  20. app/code/community/Easy/CEM/Model/Services.php +32 -0
  21. app/code/community/Easy/CEM/Model/Soap.php +155 -0
  22. app/code/community/Easy/CEM/Model/Soap/class.nusoap_base.php +984 -0
  23. app/code/community/Easy/CEM/Model/Soap/class.soap_fault.php +90 -0
  24. app/code/community/Easy/CEM/Model/Soap/class.soap_parser.php +639 -0
  25. app/code/community/Easy/CEM/Model/Soap/class.soap_server.php +1073 -0
  26. app/code/community/Easy/CEM/Model/Soap/class.soap_transport_http.php +1305 -0
  27. app/code/community/Easy/CEM/Model/Soap/class.soap_val.php +107 -0
  28. app/code/community/Easy/CEM/Model/Soap/class.soapclient.php +977 -0
  29. app/code/community/Easy/CEM/Model/Soap/class.wsdl.php +1904 -0
  30. app/code/community/Easy/CEM/Model/Soap/class.wsdlcache.php +209 -0
  31. app/code/community/Easy/CEM/Model/Soap/class.xmlschema.php +938 -0
  32. app/code/community/Easy/CEM/Model/Soap/nusoap.php +7993 -0
  33. app/code/community/Easy/CEM/Model/Soap/nusoapmime.php +501 -0
  34. app/code/community/Easy/CEM/Model/System/Config/Source/CEM/Frequency.php +33 -0
  35. app/code/community/Easy/CEM/controllers/Adminhtml/LicensesController.php +281 -0
  36. app/code/community/Easy/CEM/controllers/Adminhtml/PackagesController.php +259 -0
  37. app/code/community/Easy/CEM/controllers/IndexController.php +53 -0
  38. app/code/community/Easy/CEM/etc/config.xml +171 -0
  39. app/code/community/Easy/CEM/etc/system.xml +56 -0
  40. app/code/community/Easy/CEM/sql/cem_setup/mysql4-install-1.0.0.php +93 -0
  41. app/design/adminhtml/default/default/layout/cem.xml +42 -0
  42. app/design/adminhtml/default/default/template/cem/licenses/lostcem.phtml +156 -0
  43. app/design/adminhtml/default/default/template/cem/licenses/lostlicense.phtml +112 -0
  44. app/design/adminhtml/default/default/template/cem/packages/install.phtml +204 -0
  45. app/design/adminhtml/default/default/template/cem/packages/register.phtml +117 -0
  46. app/etc/modules/Easy_CEM.xml +29 -0
  47. app/locale/cs_CZ/Easy_CEM.csv +101 -0
  48. app/locale/en_US/Easy_CEM.csv +99 -0
  49. package.xml +30 -0
  50. skin/adminhtml/default/default/cem/i/extension_icon.gif +0 -0
  51. skin/adminhtml/default/default/cem/i/key_icon.gif +0 -0
  52. skin/adminhtml/default/default/cem/i/lost_key_icon.gif +0 -0
  53. skin/adminhtml/default/default/cem/i/notify_icon.gif +0 -0
  54. skin/adminhtml/default/default/cem/i/package_add_icon.gif +0 -0
  55. skin/adminhtml/default/default/cem/style.css +83 -0
app/code/community/Easy/CEM/Block/Adminhtml/Licenses/Edit.php ADDED
@@ -0,0 +1,46 @@
1
+ <?php
2
+ /**
3
+ * MageParts
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category MageParts
16
+ * @package MageParts_Adminhtml
17
+ * @copyright Copyright (c) 2009 MageParts (http://www.mageparts.com/)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ class Easy_CEM_Block_Adminhtml_Licenses_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
22
+ {
23
+
24
+ /**
25
+ * Constructor
26
+ */
27
+ public function __construct()
28
+ {
29
+ $this->_objectId = 'id';
30
+ $this->_blockGroup = 'cem';
31
+ $this->_controller = 'adminhtml_licenses';
32
+ parent::__construct();
33
+ }
34
+
35
+
36
+ /**
37
+ * Get header text
38
+ *
39
+ * @return string
40
+ */
41
+ public function getHeaderText()
42
+ {
43
+ return Mage::helper('cem')->__('License Management');
44
+ }
45
+
46
+ }
app/code/community/Easy/CEM/Block/Adminhtml/Licenses/Edit/Form.php ADDED
@@ -0,0 +1,35 @@
1
+ <?php
2
+ /**
3
+ * MageParts
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category MageParts
16
+ * @package MageParts_Adminhtml
17
+ * @copyright Copyright (c) 2009 MageParts (http://www.mageparts.com/)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ class Easy_CEM_Block_Adminhtml_Licenses_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
22
+ {
23
+
24
+ /**
25
+ * Prepares the form html, the form html elements can be found in the tabs
26
+ */
27
+ protected function _prepareForm()
28
+ {
29
+ $form = new Varien_Data_Form(array('id' => 'edit_form'));
30
+ $form->setUseContainer(true);
31
+ $this->setForm($form);
32
+ return parent::_prepareForm();
33
+ }
34
+
35
+ }
app/code/community/Easy/CEM/Block/Adminhtml/Licenses/Edit/Tab/LostCem.php ADDED
@@ -0,0 +1,82 @@
1
+ <?php
2
+ /**
3
+ * MageParts
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category MageParts
16
+ * @package MageParts_Adminhtml
17
+ * @copyright Copyright (c) 2009 MageParts (http://www.mageparts.com/)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ class Easy_CEM_Block_Adminhtml_Licenses_Edit_Tab_LostCem extends Mage_Adminhtml_Block_Widget_Form
22
+ {
23
+
24
+ /**
25
+ * Constructor
26
+ */
27
+ public function __construct()
28
+ {
29
+ parent::__construct();
30
+ $this->setTemplate('cem/licenses/lostcem.phtml');
31
+ }
32
+
33
+
34
+ /**
35
+ * Prepare layout
36
+ */
37
+ protected function _prepareLayout()
38
+ {
39
+ $this->setChild('lostCemKeyButton',
40
+ $this->getLayout()->createBlock('adminhtml/widget_button')
41
+ ->setData(array(
42
+ 'label' => Mage::helper('cem')->__('OK'),
43
+ 'onclick' => 'lostCem.install();',
44
+ 'class' => 'save f-right'
45
+ ))
46
+ );
47
+
48
+ $this->setChild('backButton',
49
+ $this->getLayout()->createBlock('adminhtml/widget_button')
50
+ ->setData(array(
51
+ 'label' => Mage::helper('cem')->__('Back'),
52
+ 'onclick' => "setLocation('{$this->getUrl('*/*/')}')",
53
+ 'class' => 'back f-right'
54
+ ))
55
+ );
56
+
57
+ return parent::_prepareLayout();
58
+ }
59
+
60
+
61
+ /**
62
+ * Get lost CEM key button (declared in _prepareLayout)
63
+ *
64
+ * @return Mage_Adminhtml_Block_Widget_Button
65
+ */
66
+ public function getLostCemKeyButtonHtml()
67
+ {
68
+ return $this->getChildHtml('lostCemKeyButton');
69
+ }
70
+
71
+
72
+ /**
73
+ * Get backbutton (declared in _prepareLayout)
74
+ *
75
+ * @return Mage_Adminhtml_Block_Widget_Button
76
+ */
77
+ public function getBackButtonHtml()
78
+ {
79
+ return $this->getChildHtml('backButton');
80
+ }
81
+
82
+ }
app/code/community/Easy/CEM/Block/Adminhtml/Licenses/Edit/Tab/LostLicense.php ADDED
@@ -0,0 +1,82 @@
1
+ <?php
2
+ /**
3
+ * MageParts
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category MageParts
16
+ * @package MageParts_Adminhtml
17
+ * @copyright Copyright (c) 2009 MageParts (http://www.mageparts.com/)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ class Easy_CEM_Block_Adminhtml_Licenses_Edit_Tab_LostLicense extends Mage_Adminhtml_Block_Widget_Form
22
+ {
23
+
24
+ /**
25
+ * Constructor
26
+ */
27
+ public function __construct()
28
+ {
29
+ parent::__construct();
30
+ $this->setTemplate('cem/licenses/lostlicense.phtml');
31
+ }
32
+
33
+
34
+ /**
35
+ * Prepare layout
36
+ */
37
+ protected function _prepareLayout()
38
+ {
39
+ $this->setChild('lostLicenseKeyButton',
40
+ $this->getLayout()->createBlock('adminhtml/widget_button')
41
+ ->setData(array(
42
+ 'label' => Mage::helper('cem')->__('OK'),
43
+ 'onclick' => 'lostLicenses.install();',
44
+ 'class' => 'save f-right'
45
+ ))
46
+ );
47
+
48
+ $this->setChild('backButton',
49
+ $this->getLayout()->createBlock('adminhtml/widget_button')
50
+ ->setData(array(
51
+ 'label' => Mage::helper('cem')->__('Back'),
52
+ 'onclick' => "setLocation('{$this->getUrl('*/*/')}')",
53
+ 'class' => 'back f-right'
54
+ ))
55
+ );
56
+
57
+ return parent::_prepareLayout();
58
+ }
59
+
60
+
61
+ /**
62
+ * Get lost License key button (declared in _prepareLayout)
63
+ *
64
+ * @return Mage_Adminhtml_Block_Widget_Button
65
+ */
66
+ public function getLostLicenseKeyButtonHtml()
67
+ {
68
+ return $this->getChildHtml('lostLicenseKeyButton');
69
+ }
70
+
71
+
72
+ /**
73
+ * Get backbutton (declared in _prepareLayout)
74
+ *
75
+ * @return Mage_Adminhtml_Block_Widget_Button
76
+ */
77
+ public function getBackButtonHtml()
78
+ {
79
+ return $this->getChildHtml('backButton');
80
+ }
81
+
82
+ }
app/code/community/Easy/CEM/Block/Adminhtml/Licenses/Edit/Tabs.php ADDED
@@ -0,0 +1,57 @@
1
+ <?php
2
+ /**
3
+ * MageParts
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category MageParts
16
+ * @package MageParts_Adminhtml
17
+ * @copyright Copyright (c) 2009 MageParts (http://www.mageparts.com/)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ class Easy_CEM_Block_Adminhtml_Licenses_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
22
+ {
23
+
24
+ /**
25
+ * Constructor
26
+ */
27
+ public function __construct()
28
+ {
29
+ parent::__construct();
30
+ $this->setId('cem_licenses_tabs');
31
+ $this->setDestElementId('edit_form');
32
+ $this->setTitle(Mage::helper('cem')->__('License Management'));
33
+ }
34
+
35
+
36
+ /**
37
+ * Add tabs before writing HTML tabs
38
+ */
39
+ protected function _beforeToHtml()
40
+ {
41
+ $this->addTab('lost_cem_section', array(
42
+ 'label' => Mage::helper('cem')->__('Lost CEM Key'),
43
+ 'title' => Mage::helper('cem')->__('Lost CEM Key'),
44
+ 'content' => $this->getLayout()->createBlock('cem/adminhtml_licenses_edit_tab_lostCem')->toHtml(),
45
+ 'active' => true
46
+ ));
47
+
48
+ $this->addTab('lost_license_section', array(
49
+ 'label' => Mage::helper('cem')->__('Lost License Key'),
50
+ 'title' => Mage::helper('cem')->__('Lost License Key'),
51
+ 'content' => $this->getLayout()->createBlock('cem/adminhtml_licenses_edit_tab_lostLicense')->toHtml()
52
+ ));
53
+
54
+ return parent::_beforeToHtml();
55
+ }
56
+
57
+ }
app/code/community/Easy/CEM/Block/Adminhtml/Packages.php ADDED
@@ -0,0 +1,49 @@
1
+ <?php
2
+ /**
3
+ * MageParts
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category MageParts
16
+ * @package MageParts_Adminhtml
17
+ * @copyright Copyright (c) 2009 MageParts (http://www.mageparts.com/)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ class Easy_CEM_Block_Adminhtml_Packages extends Mage_Adminhtml_Block_Widget_Grid_Container
22
+ {
23
+
24
+ /**
25
+ * Constructor
26
+ */
27
+ public function __construct()
28
+ {
29
+ $this->_controller = 'adminhtml_packages';
30
+ $this->_blockGroup = 'cem';
31
+ $this->_headerText = Mage::helper('cem')->__('Manage Extensions <span class="powered"><a href="http://www.mageparts.com" target="_blank">Powered by MageParts.com</a></span>');
32
+ $this->_addButtonLabel = Mage::helper('cem')->__('Install New Extension');
33
+
34
+ $this->_addButton('license_management', array(
35
+ 'label' => Mage::helper('cem')->__('License Management'),
36
+ 'onclick' => "setLocation('".$this->getUrl('*/*/licenseManagement')."')",
37
+ 'class' => '',
38
+ ));
39
+
40
+ $this->_addButton('update', array(
41
+ 'label' => Mage::helper('cem')->__('Update Extensions'),
42
+ 'onclick' => "setLocation('".$this->getUrl('*/*/update')."')",
43
+ 'class' => '',
44
+ ));
45
+
46
+ parent::__construct();
47
+ }
48
+
49
+ }
app/code/community/Easy/CEM/Block/Adminhtml/Packages/Edit.php ADDED
@@ -0,0 +1,125 @@
1
+ <?php
2
+ /**
3
+ * MageParts
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category MageParts
16
+ * @package MageParts_Adminhtml
17
+ * @copyright Copyright (c) 2009 MageParts (http://www.mageparts.com/)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ class Easy_CEM_Block_Adminhtml_Packages_Edit extends Mage_Adminhtml_Block_Template
22
+ {
23
+
24
+ /**
25
+ * Constructor
26
+ */
27
+ public function __construct()
28
+ {
29
+ $this->_controller = 'adminhtml_packages';
30
+ $this->_blockGroup = 'cem';
31
+
32
+ parent::__construct();
33
+
34
+ $this->setTemplate('cem/packages/install.phtml');
35
+ }
36
+
37
+
38
+ public function getHeaderText()
39
+ {
40
+ $package = Mage::registry('cem_package');
41
+ if ($package->getPackageId()) {
42
+ return Mage::helper('cem')->__("Update Extension '%s'", $this->htmlEscape($package->getIdentifier()));
43
+ }
44
+ else {
45
+ return Mage::helper('cem')->__('Install New Extension');
46
+ }
47
+ }
48
+
49
+
50
+ /**
51
+ * Retrieve install url
52
+ */
53
+ public function getInstallUrl()
54
+ {
55
+ return $this->getUrl('*/*/install');
56
+ }
57
+
58
+
59
+ /**
60
+ * Retrieve update url
61
+ */
62
+ public function getUpdateUrl()
63
+ {
64
+ return $this->getUrl('*/*/update');
65
+ }
66
+
67
+
68
+ /**
69
+ * Retrieve package id
70
+ */
71
+ public function getPackageId()
72
+ {
73
+ return Mage::registry('cem_package')->getPackageId();
74
+ }
75
+
76
+
77
+ /**
78
+ * Retrieve package service url
79
+ */
80
+ public function getPackageServiceUrl()
81
+ {
82
+ return Mage::getModel('cem/services')
83
+ ->load(Mage::registry('cem_package')->getServiceId())
84
+ ->getUrl();
85
+ }
86
+
87
+
88
+ /**
89
+ * Retrieve package license key
90
+ */
91
+ public function getPackageLicenseKey()
92
+ {
93
+ return Mage::getModel('cem/licenses')
94
+ ->load(Mage::registry('cem_package')->getLicenseId())
95
+ ->getLicenseKey();
96
+ }
97
+
98
+
99
+ /**
100
+ * Retrieve package identifier
101
+ */
102
+ public function getPackageIdentifier()
103
+ {
104
+ return Mage::registry('cem_package')->getIdentifier();
105
+ }
106
+
107
+
108
+ /**
109
+ * Retrieve rollback identifier
110
+ */
111
+ public function getIdentifierRollback()
112
+ {
113
+ return Mage::registry('cem_package')->getIdentifierRollback();
114
+ }
115
+
116
+
117
+ /**
118
+ * Get package auto update
119
+ */
120
+ public function getPackageAutoUpdate()
121
+ {
122
+ return Mage::registry('cem_package')->getAutoUpdate();
123
+ }
124
+
125
+ }
app/code/community/Easy/CEM/Block/Adminhtml/Packages/Grid.php ADDED
@@ -0,0 +1,114 @@
1
+ <?php
2
+ /**
3
+ * MageParts
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category MageParts
16
+ * @package MageParts_Adminhtml
17
+ * @copyright Copyright (c) 2009 MageParts (http://www.mageparts.com/)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ class Easy_CEM_Block_Adminhtml_Packages_Grid extends Mage_Adminhtml_Block_Widget_Grid
22
+ {
23
+
24
+ /**
25
+ * Constructor
26
+ */
27
+ public function __construct()
28
+ {
29
+ if(!Mage::getModel('cem/packages')->checkCemEmail()) {
30
+ $this->setTemplate('cem/packages/register.phtml');
31
+ }
32
+ else {
33
+ parent::__construct();
34
+ $this->setId('cemPackagesGrid');
35
+ $this->setDefaultSort('title');
36
+ $this->setDefaultDir('ASC');
37
+ }
38
+ }
39
+
40
+
41
+ /**
42
+ * Prepare collection
43
+ */
44
+ protected function _prepareCollection()
45
+ {
46
+ $collection = Mage::getModel('cem/packages')->getCollection();
47
+ /* @var $collection Easy_CEM_Model_Mysql4_Packages_Collection */
48
+ $this->setCollection($collection);
49
+
50
+ return parent::_prepareCollection();
51
+ }
52
+
53
+
54
+ /**
55
+ * Prepare columns
56
+ */
57
+ protected function _prepareColumns()
58
+ {
59
+ // Title column
60
+ $this->addColumn('title', array(
61
+ 'header' => Mage::helper('cms')->__('Title'),
62
+ 'index' => 'title',
63
+ ));
64
+
65
+ // Title column
66
+ $this->addColumn('version', array(
67
+ 'header' => Mage::helper('cem')->__('Version'),
68
+ 'width' => '100px',
69
+ 'index' => 'version',
70
+ ));
71
+
72
+ // Last update date column
73
+ $this->addColumn('last_update', array(
74
+ 'header' => Mage::helper('cem')->__('Updated at'),
75
+ 'width' => '160px',
76
+ 'index' => 'last_update',
77
+ 'type' => 'datetime',
78
+ 'gmtoffset' => true,
79
+ 'default' => ' ---- '
80
+ ));
81
+
82
+ // Has updates
83
+ $this->addColumn('update_available', array(
84
+ 'header' => Mage::helper('cem')->__('Updates Available'),
85
+ 'index' => 'update_available',
86
+ 'width' => '20px',
87
+ 'renderer' => 'cem/adminhtml_packages_grid_renderer_updateAvailable'
88
+ ));
89
+
90
+ return parent::_prepareColumns();
91
+ }
92
+
93
+
94
+ /**
95
+ * Fires after collection has been loaded
96
+ */
97
+ protected function _afterLoadCollection()
98
+ {
99
+ $this->getCollection()->walk('afterLoad');
100
+ parent::_afterLoadCollection();
101
+ }
102
+
103
+
104
+ /**
105
+ * Row click url
106
+ *
107
+ * @return string
108
+ */
109
+ public function getRowUrl($row)
110
+ {
111
+ return $this->getUrl('*/*/edit', array('package_id' => $row->getPackageId()));
112
+ }
113
+
114
+ }
app/code/community/Easy/CEM/Block/Adminhtml/Packages/Grid/Renderer/UpdateAvailable.php ADDED
@@ -0,0 +1,42 @@
1
+ <?php
2
+ /**
3
+ * MageParts
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category MageParts
16
+ * @package MageParts_Adminhtml
17
+ * @copyright Copyright (c) 2009 MageParts (http://www.mageparts.com/)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ class Easy_CEM_Block_Adminhtml_Packages_Grid_Renderer_UpdateAvailable
22
+ extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
23
+ {
24
+ /**
25
+ * Renders grid column
26
+ *
27
+ * @param Varien_Object $row
28
+ * @return string
29
+ */
30
+ public function render(Varien_Object $row)
31
+ {
32
+ switch ($row->getData($this->getColumn()->getIndex())) {
33
+ case 1:
34
+ $class = 'yes';
35
+ break;
36
+ case 0:
37
+ $class = 'no';
38
+ break;
39
+ }
40
+ return '<div class="grid-update-available-' . $class . '"></div>';
41
+ }
42
+ }
app/code/community/Easy/CEM/Helper/Data.php ADDED
@@ -0,0 +1,24 @@
1
+ <?php
2
+ /**
3
+ * MageParts
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category MageParts
16
+ * @package Easy_CEM
17
+ * @copyright Copyright (c) 2009 MageParts (http://www.mageparts.com/)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ class Easy_CEM_Helper_Data extends Mage_Core_Helper_Abstract
22
+ {
23
+
24
+ }
app/code/community/Easy/CEM/Model/Licenses.php ADDED
@@ -0,0 +1,78 @@
1
+ <?php
2
+ /**
3
+ * MageParts
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category MageParts
16
+ * @package Easy_CEM
17
+ * @copyright Copyright (c) 2009 MageParts (http://www.mageparts.com/)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ class Easy_CEM_Model_Licenses extends Mage_Core_Model_Abstract
22
+ {
23
+
24
+ /**
25
+ * Constructor
26
+ */
27
+ protected function _construct()
28
+ {
29
+ $this->_init('cem/licenses');
30
+ }
31
+
32
+
33
+ /**
34
+ * Validate a email address
35
+ *
36
+ * @param string $email
37
+ * @return boolean
38
+ */
39
+ public function validateEmail( $email )
40
+ {
41
+ // First, we check that there's one @ symbol,
42
+ // and that the lengths are right.
43
+ if (!ereg("^[^@]{1,64}@[^@]{1,255}quot;, $email)) {
44
+ // Email invalid because wrong number of characters
45
+ // in one section or wrong number of @ symbols.
46
+ return false;
47
+ }
48
+
49
+ // Split it into sections to make life easier
50
+ $email_array = explode("@", $email);
51
+ $local_array = explode(".", $email_array[0]);
52
+
53
+ for ($i = 0; $i < sizeof($local_array); $i++) {
54
+ if(!ereg("^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%&'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))quot;,$local_array[$i])) {
55
+ return false;
56
+ }
57
+ }
58
+
59
+ // Check if domain is IP. If not,
60
+ // it should be valid domain name
61
+ if (!ereg("^\[?[0-9\.]+\]?quot;, $email_array[1])) {
62
+ $domain_array = explode(".", $email_array[1]);
63
+
64
+ if (sizeof($domain_array) < 2) {
65
+ return false; // Not enough parts to domain
66
+ }
67
+
68
+ for ($i = 0; $i < sizeof($domain_array); $i++) {
69
+ if(!ereg("^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|([A-Za-z0-9]+))quot;,$domain_array[$i])) {
70
+ return false;
71
+ }
72
+ }
73
+ }
74
+
75
+ return true;
76
+ }
77
+
78
+ }
app/code/community/Easy/CEM/Model/Mysql4/Licenses.php ADDED
@@ -0,0 +1,60 @@
1
+ <?php
2
+ /**
3
+ * MageParts
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category MageParts
16
+ * @package Easy_CEM
17
+ * @copyright Copyright (c) 2009 MageParts (http://www.mageparts.com/)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ class Easy_CEM_Model_Mysql4_Licenses extends Mage_Core_Model_Mysql4_Abstract
22
+ {
23
+
24
+ /**
25
+ * Constructor
26
+ */
27
+ protected function _construct()
28
+ {
29
+ $this->_init('cem/licenses', 'license_id');
30
+ }
31
+
32
+
33
+ /**
34
+ * Check if a license key already exist
35
+ *
36
+ * @param string $licenseKey
37
+ * @return array
38
+ */
39
+ public function licenseKeyExists( $licenseKey )
40
+ {
41
+ // Read adapter
42
+ $read = $this->_getReadAdapter();
43
+
44
+ // Select
45
+ $select = $read->select()
46
+ ->from($this->getMainTable())
47
+ ->where("license_key='{$licenseKey}'")
48
+ ->limit(1);
49
+
50
+ // Fetch row
51
+ $row = $read->fetchRow($select);
52
+
53
+ if(isset($row['license_id']) && !empty($row['license_id'])) {
54
+ return $row['license_id'];
55
+ }
56
+
57
+ return false;
58
+ }
59
+
60
+ }
app/code/community/Easy/CEM/Model/Mysql4/Licenses/Collection.php ADDED
@@ -0,0 +1,32 @@
1
+ <?php
2
+ /**
3
+ * MageParts
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category MageParts
16
+ * @package Easy_CEM
17
+ * @copyright Copyright (c) 2009 MageParts (http://www.mageparts.com/)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ class Easy_CEM_Model_Mysql4_Licenses_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
22
+ {
23
+
24
+ /**
25
+ * Constructor
26
+ */
27
+ protected function _construct()
28
+ {
29
+ $this->_init('cem/licenses');
30
+ }
31
+
32
+ }
app/code/community/Easy/CEM/Model/Mysql4/Packages.php ADDED
@@ -0,0 +1,93 @@
1
+ <?php
2
+ /**
3
+ * MageParts
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category MageParts
16
+ * @package Easy_CEM
17
+ * @copyright Copyright (c) 2009 MageParts (http://www.mageparts.com/)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ class Easy_CEM_Model_Mysql4_Packages extends Mage_Core_Model_Mysql4_Abstract
22
+ {
23
+
24
+ /**
25
+ * Constructor
26
+ */
27
+ protected function _construct()
28
+ {
29
+ $this->_init('cem/packages', 'package_id');
30
+ }
31
+
32
+
33
+ /**
34
+ * Check if a license key already has been used
35
+ *
36
+ * @param int $packageId [optional]
37
+ * @return array
38
+ */
39
+ public function licenseUsed( $licenseId, $packageId=0 )
40
+ {
41
+ // Read adapter
42
+ $read = $this->_getReadAdapter();
43
+
44
+ // Select
45
+ $select = $read->select()
46
+ ->from($this->getMainTable())
47
+ ->where("license_id=?",$licenseId)
48
+ ->limit(1);
49
+
50
+ // Package exception
51
+ if(!empty($packageId)) {
52
+ $select->where("package_id != ?",$packageId);
53
+ }
54
+
55
+ // Fetch row
56
+ $row = $read->fetchRow($select);
57
+
58
+ if(isset($row['package_id']) && !empty($row['package_id'])) {
59
+ return true;
60
+ }
61
+
62
+ return false;
63
+ }
64
+
65
+
66
+ /**
67
+ * Check if a package already is installed
68
+ *
69
+ * @param string $identifier
70
+ * @return array
71
+ */
72
+ public function packageIsInstalled( $identifier )
73
+ {
74
+ // Read adapter
75
+ $read = $this->_getReadAdapter();
76
+
77
+ // Select
78
+ $select = $read->select()
79
+ ->from($this->getMainTable())
80
+ ->where("identifier='{$identifier}'")
81
+ ->limit(1);
82
+
83
+ // Fetch row
84
+ $row = $read->fetchRow($select);
85
+
86
+ if(isset($row['package_id']) && !empty($row['package_id'])) {
87
+ return true;
88
+ }
89
+
90
+ return false;
91
+ }
92
+
93
+ }
app/code/community/Easy/CEM/Model/Mysql4/Packages/Collection.php ADDED
@@ -0,0 +1,111 @@
1
+ <?php
2
+ /**
3
+ * MageParts
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category MageParts
16
+ * @package Easy_CEM
17
+ * @copyright Copyright (c) 2009 MageParts (http://www.mageparts.com/)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ class Easy_CEM_Model_Mysql4_Packages_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
22
+ {
23
+
24
+ /**
25
+ * Constructor
26
+ */
27
+ protected function _construct()
28
+ {
29
+ $this->_init('cem/packages');
30
+ }
31
+
32
+
33
+ /**
34
+ * Filter by package identifier
35
+ *
36
+ * @param string $identifier [optional]
37
+ * @return Easy_CEM_Model_Mysql4_Packages_Collection
38
+ */
39
+ public function setIdentifierFilter( $identifier='' )
40
+ {
41
+ if(!empty($identifier)) {
42
+ $this->getSelect()->where('identifier = ?',$identifier);
43
+ }
44
+ return $this;
45
+ }
46
+
47
+
48
+ /**
49
+ * Filter by package id
50
+ *
51
+ * @param int $id [optional]
52
+ * @return Easy_CEM_Model_Mysql4_Packages_Collection
53
+ */
54
+ public function setIdFilter( $id )
55
+ {
56
+ if(!empty($id)) {
57
+ $this->getSelect()->where('package_id= ?',$id);
58
+ }
59
+ return $this;
60
+ }
61
+
62
+
63
+ /**
64
+ * Filter by package auto update option
65
+ *
66
+ * @param int $autoUpdate [optional]
67
+ * @return Easy_CEM_Model_Mysql4_Packages_Collection
68
+ */
69
+ public function setAutoUpdateFilter( $autoUpdate=1 )
70
+ {
71
+ $this->getSelect()->where('auto_update = ?',$autoUpdate);
72
+ return $this;
73
+ }
74
+
75
+
76
+ /**
77
+ * Filter by package module
78
+ *
79
+ * @param int $moduleId [optional]
80
+ * @return Easy_CEM_Model_Mysql4_Packages_Collection
81
+ */
82
+ public function setModuleFilter( $module=0 )
83
+ {
84
+ if(!empty($module)) {
85
+ $this->getSelect()->where('module_id = ?',$module);
86
+ }
87
+ return $this;
88
+ }
89
+
90
+
91
+ /**
92
+ * Include service and license information
93
+ */
94
+ public function joinTables()
95
+ {
96
+ $this->getSelect()->join(
97
+ array('services' => $this->getTable('cem/services')),
98
+ 'main_table.service_id=services.service_id',
99
+ '*'
100
+ );
101
+
102
+ $this->getSelect()->join(
103
+ array('licenses' => $this->getTable('cem/licenses')),
104
+ 'main_table.license_id=licenses.license_id',
105
+ '*'
106
+ );
107
+
108
+ return $this;
109
+ }
110
+
111
+ }
app/code/community/Easy/CEM/Model/Mysql4/Services.php ADDED
@@ -0,0 +1,125 @@
1
+ <?php
2
+ /**
3
+ * MageParts
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category MageParts
16
+ * @package Easy_CEM
17
+ * @copyright Copyright (c) 2009 MageParts (http://www.mageparts.com/)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ class Easy_CEM_Model_Mysql4_Services extends Mage_Core_Model_Mysql4_Abstract
22
+ {
23
+
24
+ /**
25
+ * Constructor
26
+ */
27
+ protected function _construct()
28
+ {
29
+ $this->_init('cem/services', 'service_id');
30
+ }
31
+
32
+
33
+ /**
34
+ * Check if a service url already exists
35
+ *
36
+ * @param string $url
37
+ * @return array
38
+ */
39
+ public function urlExists( $url )
40
+ {
41
+ // Read adapter
42
+ $read = $this->_getReadAdapter();
43
+
44
+ // Select
45
+ $select = $read->select()
46
+ ->from($this->getMainTable())
47
+ ->where("url='{$url}'")
48
+ ->limit(1);
49
+
50
+ // Fetch row
51
+ $row = $read->fetchRow($select);
52
+
53
+ if(isset($row['service_id']) && !empty($row['service_id'])) {
54
+ return $row['service_id'];
55
+ }
56
+
57
+ return false;
58
+ }
59
+
60
+
61
+ /**
62
+ * Retrieve CEM key
63
+ *
64
+ * @param int $serviceId
65
+ * @return string
66
+ */
67
+ public function getCemKey( $serviceId )
68
+ {
69
+ // Read adapter
70
+ $read = $this->_getReadAdapter();
71
+
72
+ // Select
73
+ $select = $read->select()
74
+ ->from($this->getTable("cem/service_keys"))
75
+ ->where("service_id = ?",$serviceId)
76
+ ->limit(1);
77
+
78
+ // Fetch row
79
+ $row = $read->fetchRow($select);
80
+
81
+ if(isset($row['key']) && !empty($row['key'])) {
82
+ return $row['key'];
83
+ }
84
+
85
+ return false;
86
+ }
87
+
88
+
89
+ /**
90
+ * Retrieve CEM key
91
+ *
92
+ * @param array $data
93
+ * @return boolean
94
+ */
95
+ public function addCemKey( array $data )
96
+ {
97
+ // Read adapter
98
+ $read = $this->_getReadAdapter();
99
+
100
+ // Select
101
+ $select = $read->select()
102
+ ->from($this->getTable("cem/service_keys"))
103
+ ->where("service_id = ?",$data['service_id'])
104
+ ->limit(1);
105
+
106
+ // Fetch row
107
+ $row = $read->fetchRow($select);
108
+
109
+ if($data) {
110
+ if(isset($row['key'])) {
111
+ if($this->_getWriteAdapter()->update($this->getTable('cem/service_keys'), $data, "service_id={$data['service_id']}")) {
112
+ return true;
113
+ }
114
+ }
115
+ else {
116
+ if($this->_getWriteAdapter()->insert($this->getTable('cem/service_keys'), $data)) {
117
+ return true;
118
+ }
119
+ }
120
+ }
121
+
122
+ return false;
123
+ }
124
+
125
+ }
app/code/community/Easy/CEM/Model/Mysql4/Services/Collection.php ADDED
@@ -0,0 +1,44 @@
1
+ <?php
2
+ /**
3
+ * MageParts
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category MageParts
16
+ * @package Easy_CEM
17
+ * @copyright Copyright (c) 2009 MageParts (http://www.mageparts.com/)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ class Easy_CEM_Model_Mysql4_Services_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
22
+ {
23
+
24
+ /**
25
+ * Constructor
26
+ */
27
+ protected function _construct()
28
+ {
29
+ $this->_init('cem/services');
30
+ }
31
+
32
+
33
+ /**
34
+ * Filter services by url
35
+ *
36
+ * @param string $url
37
+ * @return Easy_CEM_Model_Mysql4_Services_Collection
38
+ */
39
+ public function setUrlFilter( $url )
40
+ {
41
+ $this->getSelect()->where('url = ?',$url);
42
+ return $this;
43
+ }
44
+ }
app/code/community/Easy/CEM/Model/Observer.php ADDED
@@ -0,0 +1,81 @@
1
+ <?php
2
+ /**
3
+ * MageParts
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category MageParts
16
+ * @package Easy_CEM
17
+ * @copyright Copyright (c) 2009 MageParts (http://www.mageparts.com/)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ class Easy_CEM_Model_Observer
22
+ {
23
+
24
+ const XML_FREQUENCY_PATH = 'system/cem/frequency';
25
+
26
+ public function checkUpdate( $schedule )
27
+ {
28
+ if (($this->getFrequency() + $this->getLastUpdate()) > time()) {
29
+ return $this;
30
+ }
31
+
32
+ // Get package module
33
+ $packageModel = Mage::getModel('cem/packages');
34
+
35
+ // Get package collection
36
+ $packages = $packageModel->getCollection()
37
+ ->joinTables();
38
+
39
+ // Update packages
40
+ $update = $packageModel->update($packages);
41
+
42
+ $this->setLastUpdate();
43
+
44
+ return $this;
45
+ }
46
+
47
+
48
+ /**
49
+ * Retrieve Update Frequency
50
+ *
51
+ * @return int
52
+ */
53
+ public function getFrequency()
54
+ {
55
+ return Mage::getStoreConfig(self::XML_FREQUENCY_PATH) * 3600;
56
+ }
57
+
58
+
59
+ /**
60
+ * Retrieve Last update time
61
+ *
62
+ * @return int
63
+ */
64
+ public function getLastUpdate()
65
+ {
66
+ return Mage::app()->loadCache('cem_update_lastcheck');
67
+ }
68
+
69
+
70
+ /**
71
+ * Set last update time (now)
72
+ *
73
+ * @return Easy_CEM_Model_Observer
74
+ */
75
+ public function setLastUpdate()
76
+ {
77
+ Mage::app()->saveCache(time(), 'cem_update_lastcheck');
78
+ return $this;
79
+ }
80
+
81
+ }
app/code/community/Easy/CEM/Model/Packages.php ADDED
@@ -0,0 +1,479 @@
1
+ <?php
2
+ /**
3
+ * MageParts
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category MageParts
16
+ * @package Easy_CEM
17
+ * @copyright Copyright (c) 2009 MageParts (http://www.mageparts.com/)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ /**
22
+ * Error reporting, don't logg any strict errors here it gives us problems with the PEAR & NuSOAP classes
23
+ */
24
+ //error_reporting(E_ALL);
25
+
26
+ if(!@class_exists("Archive_Tar")) {
27
+ // We need to add the include path to make sure that the file will be loaded properly
28
+ set_include_path((Mage::getBaseDir('base') . DS . 'downloader' . DS . 'pearlib' . DS . 'php') . PS . get_include_path());
29
+ $archiveFile = Mage::getBaseDir('base') . DS . 'downloader' . DS . 'pearlib' . DS . 'php' . DS . 'Archive' . DS . 'Tar.php';
30
+
31
+ if(file_exists($archiveFile)) {
32
+ require_once $archiveFile;
33
+ }
34
+ }
35
+
36
+ class Easy_CEM_Model_Packages extends Mage_Core_Model_Abstract
37
+ {
38
+
39
+ protected $_downloadDir = null;
40
+
41
+
42
+ /**
43
+ * Constructor
44
+ */
45
+ protected function _construct()
46
+ {
47
+ $this->_init('cem/packages');
48
+ }
49
+
50
+
51
+ /**
52
+ * Install a new extension
53
+ *
54
+ * @param string $packageIdentifier
55
+ * @param string $licenseKey
56
+ * @param string $serviceUrl
57
+ * @param boolean $autoUpdate
58
+ * @param int $updatePackageId [optional]
59
+ * @return unknown
60
+ */
61
+ public function install( $packageIdentifier, $licenseKey, $serviceUrl, $autoUpdate, $updatePackageId=0 )
62
+ {
63
+ $tmpFile = '';
64
+
65
+ try {
66
+ // 1. We need these values
67
+ if(!empty($serviceUrl) && !empty($packageIdentifier) && !empty($licenseKey)) {
68
+ // 2. Save new license key or load existsing one
69
+ $licenseModel = Mage::getModel('cem/licenses');
70
+ $newLicenseKey = false;
71
+
72
+ if(!$licenseId = Mage::getResourceModel('cem/licenses')->licenseKeyExists($licenseKey)) {
73
+ // Save new
74
+ if(!$licenseModel->setLicenseKey($licenseKey)->save()) {
75
+ throw new Exception(Mage::helper('cem')->__("Unable to save package information, please try again"));
76
+ }
77
+ $licenseId = $licenseModel->getLicenseId();
78
+ $newLicenseKey = true;
79
+ }
80
+ else {
81
+ // Load existing
82
+ $licenseModel->load($licenseId);
83
+ }
84
+
85
+ // 3. Save new service url or load existing one
86
+ $serviceModel = Mage::getModel('cem/services');
87
+ $newService = false;
88
+
89
+ if(!$serviceId = Mage::getResourceModel('cem/services')->urlExists($serviceUrl)) {
90
+ // Save new
91
+ if(!$serviceModel->setUrl($serviceUrl)->save()) {
92
+ throw new Exception(Mage::helper('cem')->__("Unable to save package information, please try again"));
93
+ }
94
+ $serviceId = $serviceModel->getServiceId();
95
+ $newService = true;
96
+ }
97
+ else {
98
+ // Load existing
99
+ $serviceModel->load($serviceId);
100
+ }
101
+
102
+ // 4. Chck if url exists
103
+ if(!@fopen($serviceUrl,'r')) {
104
+ throw new Exception(Mage::helper('cem')->__("The provided service url is either invalid or unreachable. Make sure that the service url you provided is correct and try again in a few minutes. If the problem consists we advise you to contact your software retailer for assistance."));
105
+ }
106
+
107
+ // 6. Retrieve or create a new CEM key from the repository
108
+ $cem_key = '';
109
+
110
+ if(!$cem_key = Mage::getResourceModel('cem/services')->getCemKey($serviceId)) {
111
+ // Soap call: create new CEM key
112
+ $cemKeyCall = Mage::getModel('cem/soap')->call(
113
+ 'createCemKey',
114
+ array(
115
+ 'email' => Mage::getStoreConfig('system/cem/email'),
116
+ 'clientHostname' => Mage::getStoreConfig('web/unsecure/base_url')
117
+ ),
118
+ $serviceUrl
119
+ );
120
+
121
+ $cem_key = $cemKeyCall->getResults();
122
+
123
+ // Check for soap errors
124
+ if(is_null($cem_key)) {
125
+ if(trim($cemKeyCall->getErrorMessage())=='') {
126
+ throw new Exception(Mage::helper('cem')->__("An unknown SOAP error occurred while the new CEM key was created. Please contact your retailer for assistance."));
127
+ }
128
+ throw new Exception(Mage::helper('cem')->__($cemKeyCall->getErrorMessage()));
129
+ }
130
+
131
+ // Save new CEM key
132
+ if(!empty($cem_key)) {
133
+ if(!Mage::getResourceModel('cem/services')->addCemKey(array('service_id' => $serviceId, 'key' => $cem_key))) {
134
+ throw new Exception(Mage::helper('cem')->__("Unable to save CEM key, please contact your software retailer"));
135
+ }
136
+ }
137
+ else {
138
+ throw new Exception(Mage::helper('cem')->__("CEM key is empty, please contact your retailer"));
139
+ }
140
+ }
141
+
142
+ // 7. Retrieve package information from service repository
143
+ $call = Mage::getModel('cem/soap')->call(
144
+ 'install',
145
+ array(
146
+ 'packageIdentifier' => $packageIdentifier,
147
+ 'licenseKey' => $licenseKey,
148
+ 'cemKey' => $cem_key,
149
+ 'clientHostname' => Mage::getStoreConfig('web/unsecure/base_url')
150
+ ),
151
+ $serviceUrl
152
+ );
153
+
154
+ $response = $call->getResults();
155
+
156
+ if(is_null($response)) {
157
+ if(trim($call->getErrorMessage())=='') {
158
+ throw new Exception(Mage::helper('cem')->__("An unknown SOAP error occurred while installing the extension. Please contact your retailer for assistance."));
159
+ }
160
+ throw new Exception(Mage::helper('cem')->__($call->getErrorMessage()));
161
+ }
162
+
163
+ // 8. Minimum core version checkup
164
+ if(!empty($response['min_core_version']) && (floatval(Mage::getVersion()) < floatval($response['min_core_version']))) {
165
+ $minVersion = number_format($response['min_core_version'],2);
166
+ $maxVersion = number_format($response['max_core_version'],2);
167
+
168
+ if(!empty($response['max_core_version']) && $maxVersion > 0.0) {
169
+ throw new Exception(Mage::helper('cem')->__("The version of your Magento installation is too old to support the requested version of this extension. The minimum required version of Magento is %s, the maximum allowed is %s. The currently installed version of Magento is %s. Please upgrade your Magento installation to meet these requirements and try again. If you require any further assistance we advise you to contact your software retailer.",$minVersion,$maxVersion,Mage::getVersion()));
170
+ }
171
+
172
+ throw new Exception(Mage::helper('cem')->__("The version of your Magento installation is too old to support the requested version of this extension. The minimum required version of Magento is %s. The currently installed version of Magento is %s. Please upgrade your Magento installation to meet these requirements and try again. If you any require further assistance we advise you to contact your software retailer.",$minVersion,Mage::getVersion()));
173
+ }
174
+
175
+
176
+ // 9. Maximum core version checkup
177
+ if(!empty($response['max_core_version']) && (floatval(Mage::getVersion()) > floatval($response['max_core_version']))) {
178
+ $maxVersion = number_format($response['max_core_version'],2);
179
+ $minVersion = number_format($response['min_core_version'],2);
180
+
181
+ if(!empty($response['min_core_version']) && $minVersion > 0.0) {
182
+ throw new Exception(Mage::helper('cem')->__("The version of your Magento installation is too new to support the requested version of this extension. You can not use this extension version togheter with a Magento installation with a version above %s or below %s. The currently installed version of Magento is %s. Please downgrade your Magento installation to meet these requirements and try again. If you any require further assistance we advise you to contact your software retailer.",$maxVersion,$minVersion,Mage::getVersion()));
183
+ }
184
+
185
+ throw new Exception(Mage::helper('cem')->__("The version of your Magento installation is too new to support the requested version of this extension. You can not use this extension version togheter with a Magento installation with a version higher then %s. The currently installed version of Magento is %s. Please downgrade your Magento installation to meet these requirements and try again. If you any require further assistance we advise you to contact your software retailer.",$maxVersion,Mage::getVersion()));
186
+ }
187
+
188
+ // 10. Check writable paths
189
+ $unwritablePaths = array();
190
+
191
+ if(!empty($response['writable_paths'])) {
192
+ foreach (explode(',',$response['writable_paths']) as $p) {
193
+ $path = Mage::getBaseDir('base') . DS . $p;
194
+
195
+ if(!is_writable($path) && !@chmod($path,777)) {
196
+ // This path was not writable
197
+ $unwritablePaths[] = $path;
198
+ }
199
+ }
200
+ }
201
+
202
+ // If there were any paths which weren't writable throw a new exception
203
+ if(!empty($unwritablePaths)) {
204
+ throw new Exception(Mage::helper('cem')->__("Unable to install extension, the following paths needs to be writable: \n\n".implode("\n\n",$unwritablePaths)));
205
+ }
206
+
207
+ // 11. Check if a package of the same type as the retrieved module already exists
208
+ $moduleExists = $this->getCollection()
209
+ ->setModuleFilter($response['module_id']);
210
+
211
+ $data = $moduleExists->getSize()>0 ? $moduleExists->getFirstItem()->getData() : null;
212
+
213
+ if($data) {
214
+ $updatePackageId = $data['package_id'];
215
+ }
216
+
217
+ // 12. Check if the package is already installed
218
+ if(Mage::getResourceModel('cem/packages')->packageIsInstalled($packageIdentifier)) {
219
+ // Get package
220
+ $package = $this->getCollection()
221
+ ->setIdentifierFilter($packageIdentifier)
222
+ ->getFirstItem();
223
+
224
+ // Save auto update option
225
+ $this->load($package->getPackageId())
226
+ ->setAutoUpdate($autoUpdate)
227
+ ->save();
228
+
229
+ // throw exception
230
+ throw new Exception(Mage::helper('cem')->__("This package is already installed"));
231
+ }
232
+
233
+ // 13. Get local download directory
234
+ if(!$dir = $this->getDownloadDirectory()) {
235
+ throw new Exception(Mage::helper('cem')->__("Unable to create / locate temp download directory. Your Magento folder might not have sufficient write permissions, which this web based downloader requires. Please make sure that your permissions are correct and try again. If you need further assistance, please contact your server administrator."));
236
+ }
237
+
238
+ // 14. Make sure that the download directory is writable
239
+ if(!is_writable($dir)) {
240
+ throw new Exception(Mage::helper('cem')->__("Unable to install the requested extension. Your var/tmp directory needs to be writable. If you are not sure how to make the directory writable we suggest that you contact your webadministrator for technical support."));
241
+ }
242
+
243
+ // 15. Save package information if package doesn't exists
244
+ if(empty($updatePackageId)) {
245
+ $this->setLicenseId($licenseModel->getLicenseId())
246
+ ->setServiceId($serviceModel->getServiceId())
247
+ ->setIdentifier($response['identifier'])
248
+ ->setTitle($response['title'])
249
+ ->setAutoUpdate($autoUpdate)
250
+ ->setModuleId($response['module_id'])
251
+ ->setVersion($response['version'])
252
+ ->save();
253
+ }
254
+
255
+ // 16. Download remote package
256
+ $file = file_get_contents($response['url']);
257
+
258
+ $tmpFile = $dir . DS . $packageIdentifier . '.tar.gz';
259
+
260
+ if($fp = fopen($tmpFile,'w')) {
261
+ fwrite($fp,$file);
262
+ }
263
+ else {
264
+ throw new Exception(Mage::helper('cem')->__("An error occurred while completing the download of the source package file. Your Magento folder might not have sufficient write permissions, which this web based downloader requires. Please make sure that your permissions are correct and try again. If you need further assistance, please contact your server administrator."));
265
+ }
266
+
267
+ fclose($fp);
268
+
269
+ // 17. Install downloaded package
270
+
271
+ // Make sure the PEAR class exists, otherwise we can't extract nothing
272
+ if(!@class_exists("PEAR")) {
273
+ throw new Exception(Mage::helper('cem')->__("PEAR has not been loaded. Unable to extract installation file."));
274
+ }
275
+
276
+ // Make sure the Archive_Tar class exists, otherwise we can't extract nothing
277
+ if(!@class_exists("Archive_Tar")) {
278
+ throw new Exception(Mage::helper('cem')->__("Archive_Tar has not been loaded. Unable to extract installation file."));
279
+ }
280
+
281
+ if($tar = new Archive_Tar($tmpFile,true)) {
282
+ if(!$tar->extract(Mage::getBaseDir('base'))) {
283
+ throw new Exception(Mage::helper('cem')->__("Unable to install package. Your Magento folder might not have sufficient write permissions, which this web based downloader requires. Please make sure that your permissions are correct and try again. If you need further assistance, please contact your server administrator."));
284
+ }
285
+ }
286
+ else {
287
+ throw new Exception(Mage::helper('cem')->__("Unable to install package. Your Magento folder might not have sufficient write permissions, which this web based downloader requires. Please make sure that your permissions are correct and try again. If you need further assistance, please contact your server administrator."));
288
+ }
289
+
290
+ // 18. Update package information if it already exists
291
+ if(!empty($updatePackageId)) {
292
+ $packageModel = $this->load($updatePackageId);
293
+ $packageModel->setTitle($response['title'])
294
+ ->setIdentifierRollback($packageModel->getIdentifier())
295
+ ->setIdentifier($response['identifier'])
296
+ ->setVersion($response['version'])
297
+ ->setAutoUpdate($autoUpdate)
298
+ ->setUpdateAvailable(0)
299
+ ->setLastUpdate(date("Y-m-d H:i:s",time()))
300
+ ->save();
301
+ }
302
+
303
+ // 19. Report the successfull installation to the repository
304
+ $installCompleted = Mage::getModel('cem/soap')->call(
305
+ 'installCompleted',
306
+ array(
307
+ 'licenseKey' => $licenseKey
308
+ ),
309
+ $serviceUrl
310
+ );
311
+
312
+ // 20. Clear the cache
313
+ if(!Mage::app()->cleanCache()) {
314
+ throw new Exception(Mage::helper('cem')->__("Unable to refresh cache, please refresh the cache manually."));
315
+ }
316
+
317
+ // 21. Delete local install file
318
+ if(!@unlink($tmpFile)) {
319
+ throw new Exception(Mage::helper('cem')->__("The installation was successfull but unable to cleanup installation files. Please make sure that your Magento directory has read and write permissions to avoid this problem in the future."));
320
+ }
321
+
322
+ // 22. Installation complete
323
+ return true;
324
+ }
325
+ }
326
+ catch (Exception $e) {
327
+ // Clean the database tables
328
+ if($newLicenseKey) {
329
+ $licenseModel->delete();
330
+ }
331
+
332
+ // Clean the database tables
333
+ /*if($newService) {
334
+ $serviceModel->delete();
335
+ }*/
336
+
337
+ // Delete temporary downloaded file if any
338
+ if(!empty($tmpFile)) {
339
+ @unlink($tmpFile);
340
+ }
341
+
342
+ // Error
343
+ Mage::unregister('cem_error');
344
+ Mage::register('cem_error',$e->getMessage());
345
+ return;
346
+ }
347
+ }
348
+
349
+
350
+ /**
351
+ * Get information on the latest package in a module
352
+ *
353
+ * @param string $serviceUrl
354
+ * @param int $moduleId
355
+ * @return array
356
+ */
357
+ public function getLatestVersion( $serviceUrl, $moduleId )
358
+ {
359
+ try {
360
+ // Retrieve package information from service repository
361
+ $call = Mage::getModel('cem/soap')->call(
362
+ 'getLatestVersion',
363
+ array(
364
+ 'moduleId' => $moduleId
365
+ ),
366
+ $serviceUrl
367
+ );
368
+
369
+ $response = $call->getResults();
370
+
371
+ // Check for soap errors
372
+ if(is_null($response)) {
373
+ if(trim($call->getErrorMessage())=='') {
374
+ throw new Exception(Mage::helper('cem')->__("An unknown SOAP error occurred while gathering module information. Please contact your retailer for assistance."));
375
+ }
376
+ throw new Exception(Mage::helper('cem')->__($call->getErrorMessage()));
377
+ }
378
+
379
+ return $response[0];
380
+ }
381
+ catch (Exception $e) {
382
+ // Error
383
+ Mage::unregister('cem_error');
384
+ Mage::register('cem_error',$e->getMessage());
385
+ return;
386
+ }
387
+ }
388
+
389
+
390
+ /**
391
+ * Get download directory path
392
+ *
393
+ * @return string
394
+ */
395
+ public function getDownloadDirectory()
396
+ {
397
+ if(is_null($this->_downloadDir)) {
398
+ // Dir
399
+ $dir = Mage::getBaseDir('base') . DS . 'var/tmp';
400
+
401
+ // Does dir exist
402
+ if(!is_dir($dir)) {
403
+ // Attempt to create it
404
+ mkdir($dir,0777);
405
+ }
406
+
407
+ $this->_downloadDir = $dir;
408
+ }
409
+
410
+ return $this->_downloadDir;
411
+ }
412
+
413
+
414
+ /**
415
+ * Set package id
416
+ *
417
+ * @param int $packageId
418
+ * @param boolean $updates
419
+ */
420
+ public function hasUpdates( $packageId, $updates )
421
+ {
422
+ Mage::getModel('cem/packages')
423
+ ->load($packageId)
424
+ ->setUpdateAvailable($updates)
425
+ ->save();
426
+ }
427
+
428
+
429
+ /**
430
+ * Update a list of packages
431
+ *
432
+ * @param Easy_CEM_Model_Mysql4_Packages_Collection $collection
433
+ * @param boolean $force
434
+ * @return int $packagesUpToDate
435
+ */
436
+ public function update( Easy_CEM_Model_Mysql4_Packages_Collection $collection, $force=false )
437
+ {
438
+ $packagesUpToDate = 0;
439
+
440
+ foreach ($collection as $p) {
441
+ $latest = $this->getLatestVersion($p->getUrl(),$p->getModuleId());
442
+
443
+ if($latest['version'] > $p->getVersion()) {
444
+ if($p->getAutoUpdate() || $force) {
445
+ if($this->install($latest['identifier'],$p->getLicenseKey(),$p->getUrl(),$p->getAutoUpdate(),$p->getPackageId())) {
446
+ $packagesUpToDate++;
447
+ }
448
+ else {
449
+ $this->hasUpdates($p->getPackageId(),true);
450
+ $packagesUpToDate++;
451
+ }
452
+ }
453
+ else {
454
+ $this->hasUpdates($p->getPackageId(),true);
455
+ $packagesUpToDate++;
456
+ }
457
+ }
458
+ }
459
+
460
+ return $packagesUpToDate;
461
+ }
462
+
463
+
464
+ /**
465
+ * Check if there is a CEM email in the config already
466
+ */
467
+ public function checkCemEmail()
468
+ {
469
+ $email = Mage::getStoreConfig('system/cem/email');
470
+
471
+ if(!empty($email)) {
472
+ return true;
473
+ }
474
+ else {
475
+ return false;
476
+ }
477
+ }
478
+
479
+ }
app/code/community/Easy/CEM/Model/Services.php ADDED
@@ -0,0 +1,32 @@
1
+ <?php
2
+ /**
3
+ * MageParts
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category MageParts
16
+ * @package Easy_CEM
17
+ * @copyright Copyright (c) 2009 MageParts (http://www.mageparts.com/)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ class Easy_CEM_Model_Services extends Mage_Core_Model_Abstract
22
+ {
23
+
24
+ /**
25
+ * Constructor
26
+ */
27
+ protected function _construct()
28
+ {
29
+ $this->_init('cem/services');
30
+ }
31
+
32
+ }
app/code/community/Easy/CEM/Model/Soap.php ADDED
@@ -0,0 +1,155 @@
1
+ <?php
2
+ /**
3
+ * MageParts
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category MageParts
16
+ * @package Easy_CEM
17
+ * @copyright Copyright (c) 2009 MageParts (http://www.mageparts.com/)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ /**
22
+ * Make sure that WSDL files aren't cached to avoid problems.
23
+ */
24
+ ini_set("soap.wsdl_cache_enabled","0");
25
+
26
+ /**
27
+ * Lets load the NuSOAP library
28
+ */
29
+ require_once('Soap/nusoap.php');
30
+
31
+ class Easy_CEM_Model_Soap extends Mage_Core_Model_Abstract
32
+ {
33
+
34
+ /**
35
+ * WSDL URL
36
+ *
37
+ * @param string
38
+ */
39
+ private $_wsdlUrl = '';
40
+
41
+
42
+ /**
43
+ * Results from SOAP call
44
+ *
45
+ * @var string
46
+ */
47
+ private $_results = null;
48
+
49
+
50
+ /**
51
+ * Error message from SOAP call
52
+ *
53
+ * @var unknown_type
54
+ */
55
+ private $_error = '';
56
+
57
+
58
+ /**
59
+ * SOAP fault
60
+ *
61
+