Magalter_Config - Version 1.1.1

Version Notes

1.1.1

Download this release

Release Info

Developer Magalter
Extension Magalter_Config
Version 1.1.1
Comparing to
See all releases


Code changes from version 1.1.0.0 to 1.1.1

app/code/local/Magalter/Config/Block/Prepare.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Magalter_Config_Block_Prepare extends Mage_Core_Block_Template
4
+ {
5
+ protected function _toHtml() {
6
+ return "<ul><li class = 'last' title='{$this->getLinksIdentity()}'><a href = 'http://www.magalter.com'>{$this->getLinksIdentity()}</a></li></ul>";
7
+ }
8
+ }
app/code/local/Magalter/Config/Helper/Data.php CHANGED
@@ -1,17 +1,13 @@
1
  <?php
2
 
3
-
4
- class Magalter_Config_Helper_Data extends Mage_Core_Helper_Abstract
5
- {
6
- public function getInstalledMagalterExtesions()
7
- {
8
  /* Get all installed Magalter extensions */
9
  $extensions = Mage::getConfig()->getNode('modules')->children();
10
  $installedMagalterExtensions = array();
11
- foreach($extensions as $extensionCode => $extensionDescription)
12
- {
13
- if (strstr($extensionCode,'Magalter_') === false)
14
- {
15
  continue;
16
  }
17
  $installedMagalterExtensions[$extensionCode] = $extensionDescription;
@@ -19,4 +15,17 @@ class Magalter_Config_Helper_Data extends Mage_Core_Helper_Abstract
19
  return $installedMagalterExtensions;
20
  }
21
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  }
1
  <?php
2
 
3
+ class Magalter_Config_Helper_Data extends Mage_Core_Helper_Abstract {
4
+
5
+ public function getInstalledMagalterExtesions() {
 
 
6
  /* Get all installed Magalter extensions */
7
  $extensions = Mage::getConfig()->getNode('modules')->children();
8
  $installedMagalterExtensions = array();
9
+ foreach ($extensions as $extensionCode => $extensionDescription) {
10
+ if (strstr($extensionCode, 'Magalter_') === false) {
 
 
11
  continue;
12
  }
13
  $installedMagalterExtensions[$extensionCode] = $extensionDescription;
15
  return $installedMagalterExtensions;
16
  }
17
 
18
+ public function getInstalledFreeMagalter() {
19
+ foreach ($this->getInstalledMagalterExtesions() as $code => $data) {
20
+ if ($data->type == 'free') {
21
+ if ($data->descend('active')->asArray() == 'true') {
22
+ if (!Mage::getStoreConfig("advanced/modules_disable_output/{$code}")) {
23
+ return true;
24
+ }
25
+ }
26
+ }
27
+ }
28
+ return false;
29
+ }
30
+
31
  }
app/code/local/Magalter/Config/Model/Observer.php CHANGED
@@ -2,80 +2,93 @@
2
 
3
  class Magalter_Config_Model_Observer
4
  {
 
5
  const SYNC_URL = "http://www.magalter.com/service/requests/index";
6
-
7
  public function connectToWebservice()
8
  {
9
  $nextUpdateTime = Mage::getModel('magalterconfig/storage')
10
- ->load('magalterconfig_next_update_time', 'code')
11
- ->getData('value');
12
 
13
  /* Check if update time comes */
14
- if ($nextUpdateTime && $nextUpdateTime > Mage::getModel('core/date')->gmtTimestamp()) return;
 
15
 
16
  /* Get all installed Magalter extensions versions */
17
  $extensions = Mage::getConfig()->getNode('modules')->children();
18
  $installedExtensionsVersions = array();
19
- foreach($extensions as $extensionName => $extensionDescription)
20
- {
21
- if (strstr($extensionName,'Magalter_') === false) {
22
- continue;
23
- }
24
- $installedExtensionsVersions[] = $extensionName.'-'.$extensionDescription->version;
25
  }
26
 
27
- if (!sizeof($installedExtensionsVersions)) return;
 
28
 
29
  $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
30
  /* Request params building */
31
- $params = 'website='.$baseUrl.'&extensions='.implode(',', $installedExtensionsVersions);
32
 
33
- try
34
- {
35
  $ch = curl_init();
36
  /* curl post request with 5 seconds timeout, string will be returned */
37
  curl_setopt($ch, CURLOPT_POST, 1);
38
- curl_setopt($ch, CURLOPT_URL,self::SYNC_URL);
39
- curl_setopt($ch, CURLOPT_POSTFIELDS,$params);
40
  curl_setopt($ch, CURLOPT_TIMEOUT, 5);
41
- curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
42
 
43
  $result = curl_exec($ch); //execute and get the results
44
- curl_close ($ch);
45
 
46
  $oneDay = 60 * 60 * 24;
47
  /* Result can be false because of exception or if curl_exec returns false */
48
- if ($result)
49
- {
50
  /* Check if JSON is correct. If not, exception by Zend_Json will be thrown */
51
  Zend_Json::decode($result);
52
 
53
  Mage::getModel('magalterconfig/storage')
54
- ->load('magalterconfig_magalter_response', 'code')
55
- ->setData('code', 'magalterconfig_magalter_response')
56
- ->setData('value', $result)
57
- ->save();
58
 
59
  /* If all is fine then next update is needed to be processed in 7 days */
60
  Mage::getModel('magalterconfig/storage')
 
 
 
 
 
 
 
 
 
 
61
  ->load('magalterconfig_next_update_time', 'code')
62
  ->setData('code', 'magalterconfig_next_update_time')
63
- ->setData('value', Mage::getModel('core/date')->gmtTimestamp() + 7 * $oneDay)
64
  ->save();
 
 
 
 
 
 
 
 
 
 
65
  }
66
- else
67
- {
68
- throw new Exception('Incorrect result');
 
69
  }
70
  }
71
- catch (Exception $ex)
72
- {
73
- /* If exception found then set next update day to the next day, except 7 days as usual */
74
- Mage::getModel('magalterconfig/storage')
75
- ->load('magalterconfig_next_update_time', 'code')
76
- ->setData('code', 'magalterconfig_next_update_time')
77
- ->setData('value', Mage::getModel('core/date')->gmtTimestamp() + $oneDay)
78
- ->save();
79
- }
80
  }
 
81
  }
2
 
3
  class Magalter_Config_Model_Observer
4
  {
5
+
6
  const SYNC_URL = "http://www.magalter.com/service/requests/index";
7
+
8
  public function connectToWebservice()
9
  {
10
  $nextUpdateTime = Mage::getModel('magalterconfig/storage')
11
+ ->load('magalterconfig_next_update_time', 'code')
12
+ ->getData('value');
13
 
14
  /* Check if update time comes */
15
+ if ($nextUpdateTime && $nextUpdateTime > Mage::getModel('core/date')->gmtTimestamp())
16
+ return;
17
 
18
  /* Get all installed Magalter extensions versions */
19
  $extensions = Mage::getConfig()->getNode('modules')->children();
20
  $installedExtensionsVersions = array();
21
+ foreach ($extensions as $extensionName => $extensionDescription) {
22
+ if (strstr($extensionName, 'Magalter_') === false) {
23
+ continue;
24
+ }
25
+ $installedExtensionsVersions[] = $extensionName . '-' . $extensionDescription->version;
 
26
  }
27
 
28
+ if (!sizeof($installedExtensionsVersions))
29
+ return;
30
 
31
  $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
32
  /* Request params building */
33
+ $params = 'website=' . $baseUrl . '&extensions=' . implode(',', $installedExtensionsVersions);
34
 
35
+ try {
 
36
  $ch = curl_init();
37
  /* curl post request with 5 seconds timeout, string will be returned */
38
  curl_setopt($ch, CURLOPT_POST, 1);
39
+ curl_setopt($ch, CURLOPT_URL, self::SYNC_URL);
40
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
41
  curl_setopt($ch, CURLOPT_TIMEOUT, 5);
42
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
43
 
44
  $result = curl_exec($ch); //execute and get the results
45
+ curl_close($ch);
46
 
47
  $oneDay = 60 * 60 * 24;
48
  /* Result can be false because of exception or if curl_exec returns false */
49
+ if ($result) {
 
50
  /* Check if JSON is correct. If not, exception by Zend_Json will be thrown */
51
  Zend_Json::decode($result);
52
 
53
  Mage::getModel('magalterconfig/storage')
54
+ ->load('magalterconfig_magalter_response', 'code')
55
+ ->setData('code', 'magalterconfig_magalter_response')
56
+ ->setData('value', $result)
57
+ ->save();
58
 
59
  /* If all is fine then next update is needed to be processed in 7 days */
60
  Mage::getModel('magalterconfig/storage')
61
+ ->load('magalterconfig_next_update_time', 'code')
62
+ ->setData('code', 'magalterconfig_next_update_time')
63
+ ->setData('value', Mage::getModel('core/date')->gmtTimestamp() + 7 * $oneDay)
64
+ ->save();
65
+ } else {
66
+ throw new Exception('Incorrect result');
67
+ }
68
+ } catch (Exception $ex) {
69
+ /* If exception found then set next update day to the next day, except 7 days as usual */
70
+ Mage::getModel('magalterconfig/storage')
71
  ->load('magalterconfig_next_update_time', 'code')
72
  ->setData('code', 'magalterconfig_next_update_time')
73
+ ->setData('value', Mage::getModel('core/date')->gmtTimestamp() + $oneDay)
74
  ->save();
75
+ }
76
+ }
77
+
78
+ public function prepareConfiguration($observer)
79
+ {
80
+ if (Mage::helper('magalterconfig')->getInstalledFreeMagalter()) {
81
+ if (Mage::app()->getRequest()->getModuleName() == 'contacts') {
82
+ if ($observer->getLayout()->getBlock('footer')) {
83
+ $observer->getLayout()->getBlock('footer')->insert($observer->getLayout()->createBlock(Mage::getBlockSingleton('magalterconfig/prepare')->setLinksIdentity(Mage::helper('magalterconfig')->__('Magento plugins')), 'magalter_config_prepare'), '', true);
84
+ }
85
  }
86
+ if (Mage::app()->getRequest()->getControllerName() == 'seo_sitemap') {
87
+ if ($observer->getLayout()->getBlock('footer')) {
88
+ $observer->getLayout()->getBlock('footer')->insert($observer->getLayout()->createBlock(Mage::getBlockSingleton('magalterconfig/prepare')->setLinksIdentity(Mage::helper('magalterconfig')->__('Magento customization')), 'magalter_config_prepare'), '', true);
89
+ }
90
  }
91
  }
 
 
 
 
 
 
 
 
 
92
  }
93
+
94
  }
app/code/local/Magalter/Config/etc/config.xml CHANGED
@@ -2,7 +2,7 @@
2
  <config>
3
  <modules>
4
  <Magalter_Config>
5
- <version>1.1.0.0</version>
6
  </Magalter_Config>
7
  </modules>
8
 
@@ -95,4 +95,16 @@
95
  </controller_action_predispatch>
96
  </events>
97
  </adminhtml>
 
 
 
 
 
 
 
 
 
 
 
 
98
  </config>
2
  <config>
3
  <modules>
4
  <Magalter_Config>
5
+ <version>1.1.1</version>
6
  </Magalter_Config>
7
  </modules>
8
 
95
  </controller_action_predispatch>
96
  </events>
97
  </adminhtml>
98
+ <frontend>
99
+ <events>
100
+ <controller_action_layout_generate_blocks_after>
101
+ <observers>
102
+ <magalter_config_prepare>
103
+ <class>magalterconfig/observer</class>
104
+ <method>prepareConfiguration</method>
105
+ </magalter_config_prepare>
106
+ </observers>
107
+ </controller_action_layout_generate_blocks_after>
108
+ </events>
109
+ </frontend>
110
  </config>
app/code/local/Magalter/Config/sql/magalterconfig_setup/mysql4-upgrade-1.1.0.0-1.1.1.php ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ <?php
2
+ $installer = $this;
3
+ $installer->startSetup();
4
+ $installer->endSetup();
package.xml CHANGED
@@ -1,18 +1,18 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Magalter_Config</name>
4
- <version>1.1.0.0</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.magalter.com/license">Custom License</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Magalter configuration extension, needed for correct work of other Magalter extensions</summary>
10
  <description>Magalter configuration extension, needed for correct work of other Magalter extensions</description>
11
- <notes>1.1.0.0</notes>
12
  <authors><author><name>Magalter</name><user>magalter</user><email>admin@magalter.com</email></author></authors>
13
- <date>2011-12-21</date>
14
- <time>22:59:29</time>
15
- <contents><target name="magelocal"><dir name="Magalter"><dir name="Config"><dir name="Block"><dir name="Versions"><file name="Table.php" hash="74558c4e23a6469b9c2631aadcd03525"/></dir><file name="Versions.php" hash="b814757aeb8971a7f7ae545a8010b055"/></dir><dir name="Helper"><file name="Data.php" hash="0f692760f612c0a408191bd9cd05c978"/></dir><dir name="Model"><dir name="Mysql4"><dir name="Storage"><file name="Collection.php" hash="24be2283e3680e4c4f78c3d878fb874a"/></dir><file name="Storage.php" hash="fe13f5bc086b191cb8e8666d0ab49ab5"/></dir><file name="Observer.php" hash="7c44738318a2b386a189c2f866813443"/><file name="Storage.php" hash="8c21521c51ccbf7f586c860f5e47a363"/></dir><dir name="etc"><file name="config.xml" hash="425cd5d33ac8f6ffeb2710c221508a9b"/><file name="system.xml" hash="c7dab470f339e7589dd73ce295a99a1d"/></dir><dir name="sql"><dir name="magalterconfig_setup"><file name="mysql4-install-1.1.0.0.php" hash="2e4575231696f54f7c86d0d2768ba4aa"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Magalter_Config.xml" hash="ab239b707d6a04aa4369ab322d8137c1"/></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="css"><file name="magalter_config.css" hash="1be18d448a55870e7a61c0e4d44a6d43"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="magalter_config"><dir name="versions"><file name="table.phtml" hash="89780aebc30251d2826d14a7eb843111"/></dir></dir></dir><dir name="layout"><file name="magalter_config.xml" hash="dfaa6354395532a1912ae1898b3b57ae"/></dir></dir></dir></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Magalter_Config</name>
4
+ <version>1.1.1</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.magalter.com/license">Custom License</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Magalter configuration extension, needed for correct work of other Magalter extensions</summary>
10
  <description>Magalter configuration extension, needed for correct work of other Magalter extensions</description>
11
+ <notes>1.1.1</notes>
12
  <authors><author><name>Magalter</name><user>magalter</user><email>admin@magalter.com</email></author></authors>
13
+ <date>2012-05-03</date>
14
+ <time>20:41:04</time>
15
+ <contents><target name="magelocal"><dir name="Magalter"><dir name="Config"><dir name="Block"><file name="Prepare.php" hash="ca08642ebd3293dfc386fb716ef9bb0c"/><dir name="Versions"><file name="Table.php" hash="74558c4e23a6469b9c2631aadcd03525"/></dir><file name="Versions.php" hash="b814757aeb8971a7f7ae545a8010b055"/></dir><dir name="Helper"><file name="Data.php" hash="be65fdf5b648e5d41e0e4a0e07583fc2"/></dir><dir name="Model"><dir name="Mysql4"><dir name="Storage"><file name="Collection.php" hash="24be2283e3680e4c4f78c3d878fb874a"/></dir><file name="Storage.php" hash="fe13f5bc086b191cb8e8666d0ab49ab5"/></dir><file name="Observer.php" hash="93162bbae24c0e3759692539861019aa"/><file name="Storage.php" hash="8c21521c51ccbf7f586c860f5e47a363"/></dir><dir name="etc"><file name="config.xml" hash="c106b05956354f06b4560d19e4084121"/><file name="system.xml" hash="c7dab470f339e7589dd73ce295a99a1d"/></dir><dir name="sql"><dir name="magalterconfig_setup"><file name="mysql4-install-1.1.0.0.php" hash="2e4575231696f54f7c86d0d2768ba4aa"/><file name="mysql4-upgrade-1.1.0.0-1.1.1.php" hash="32a486798dc13cb431816ba3eb7c48ad"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Magalter_Config.xml" hash="ab239b707d6a04aa4369ab322d8137c1"/></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="css"><file name="magalter_config.css" hash="1be18d448a55870e7a61c0e4d44a6d43"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="magalter_config"><dir name="versions"><file name="table.phtml" hash="89780aebc30251d2826d14a7eb843111"/></dir></dir></dir><dir name="layout"><file name="magalter_config.xml" hash="dfaa6354395532a1912ae1898b3b57ae"/></dir></dir></dir></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
18
  </package>