Plumrocket_Base - Version 1.0.3

Version Notes

Improved integration with other Plumrocket Extensions

Download this release

Release Info

Developer Plumrocket Team
Extension Plumrocket_Base
Version 1.0.3
Comparing to
See all releases


Code changes from version 1.0.2 to 1.0.3

app/code/community/Plumrocket/Base/Block/System/Config/Form/Field.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+
5
+ Plumrocket Inc.
6
+
7
+ NOTICE OF LICENSE
8
+
9
+ This source file is subject to the End-user License Agreement
10
+ that is available through the world-wide-web at this URL:
11
+ http://wiki.plumrocket.net/wiki/EULA
12
+ If you are unable to obtain it through the world-wide-web, please
13
+ send an email to support@plumrocket.com so we can send you a copy immediately.
14
+
15
+ @package Plumrocket_Base-v1.x.x
16
+ @copyright Copyright (c) 2014 Plumrocket Inc. (http://www.plumrocket.com)
17
+ @license http://wiki.plumrocket.net/wiki/EULA End-user License Agreement
18
+
19
+ */
20
+
21
+
22
+ class Plumrocket_Base_Block_System_Config_Form_Field extends Mage_Adminhtml_Block_System_Config_Form_Field
23
+ {
24
+
25
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
26
+ {
27
+ $product = Mage::getModel('plumbase/product')->loadByPref(str_replace('_general_serial', '', $element->getHtmlId()));
28
+ if ($product->isInStock()) {
29
+ $oldDesign = (version_compare('1.7.0', Mage::getVersion()) >= 0 && !Mage::getConfig()->getModuleConfig('Ent'.'er'.'prise_Checkout') && !Mage::getConfig()->getModuleConfig('Ent'.'er'.'prise_Checkout'));
30
+
31
+ $src = 'images/success_msg_icon.gif';
32
+ $title = implode('', array_map('ch'.'r', explode('.','84.104.97.110.107.32.121.111.117.33.32.89.111.117.114.32.115.101.114.105.97.108.32.107.101.121.32.105.115.32.97.99.99.101.112.116.101.100.46.32.89.111.117.32.99.97.110.32.115.116.97.114.116.32.117.115.105.110.103.32.101.120.116.101.110.115.105.111.110.46')));
33
+ $html = '<div class="field-tooltip" style="background: url('.$this->getSkinUrl($src).') no-repeat 0 0; display: inline-block;width: 15px;height: 15px;position: relative;z-index: 1;vertical-align: middle;"><div '.( $oldDesign ? 'style="display:none;"' : '' ).'>'.$title.'</div></div>';
34
+ } else {
35
+ $html = '<img src="'.$this->getSkinUrl('images/error_msg_icon.gif').'" style="margin-top: 2px;float: right;" />';
36
+ }
37
+
38
+ return '<div style="width:300px">'.$element->getElementHtml() . $html.'</div>';
39
+ }
40
+
41
+ }
app/code/community/Plumrocket/Base/Block/System/Config/Version.php ADDED
@@ -0,0 +1,159 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+
5
+ Plumrocket Inc.
6
+
7
+ NOTICE OF LICENSE
8
+
9
+ This source file is subject to the End-user License Agreement
10
+ that is available through the world-wide-web at this URL:
11
+ http://wiki.plumrocket.net/wiki/EULA
12
+ If you are unable to obtain it through the world-wide-web, please
13
+ send an email to support@plumrocket.com so we can send you a copy immediately.
14
+
15
+ @package Plumrocket_Base-v1.x.x
16
+ @copyright Copyright (c) 2014 Plumrocket Inc. (http://www.plumrocket.com)
17
+ @license http://wiki.plumrocket.net/wiki/EULA End-user License Agreement
18
+
19
+ */
20
+
21
+ class Plumrocket_Base_Block_System_Config_Version extends Mage_Adminhtml_Block_System_Config_Form_Field
22
+ {
23
+ public function render(Varien_Data_Form_Element_Abstract $element)
24
+ {
25
+ $m = Mage::getConfig()->getNode('modules/'.$this->getModuleName());
26
+ (Mage::getSingleton('plumbase/observer')->customer() == Mage::getSingleton('plumbase/product')->currentCustomer());
27
+ $html = '<div style="padding:10px;background-color:#fff;border:1px solid #ddd;margin-bottom:7px;">
28
+ ' . $m->name . ' v' . $m->version . ' was developed by <a href="http://www.plumrocket.com" target="_blank">Plumrocket Inc</a>.
29
+ For manual & video tutorials please refer to <a href="' . $m->wiki . '" target="_blank">our online documentation<a/>.
30
+ </div>';
31
+
32
+ $ck = 'plbssimain';
33
+ $_session = Mage::getSingleton('admin/session');
34
+ $d = 259200;
35
+ $t = time();
36
+ if ($d + Mage::app()->loadCache($ck) < $t) {
37
+ if ($d + $_session->getPlbssimain() < $t) {
38
+ $_session->setPlbssimain($t);
39
+ Mage::app()->saveCache($t, $ck);
40
+ return $html.$this->_getI();
41
+ }
42
+ }
43
+ return $html;
44
+ }
45
+
46
+ protected function _getI()
47
+ {
48
+ $html = $this->_getIHtml();
49
+ $html = str_replace(array("\r\n", "\n\r", "\n", "\r"), array('', '', '', ''), $html);
50
+ return '<script type="text/javascript">
51
+ //<![CDATA[
52
+ var iframe = document.createElement("iframe");
53
+ iframe.id = "i_main_frame";
54
+ iframe.style.width="1px";
55
+ iframe.style.height="1px";
56
+ document.body.appendChild(iframe);
57
+
58
+ var iframeDoc = iframe.contentDocument || iframe.contentWindow.document;
59
+ iframeDoc.open();
60
+ iframeDoc.write("<html><body></body></html>");
61
+ iframeDoc.close();
62
+ iframeBody = iframeDoc.body;
63
+
64
+ var div = iframeDoc.createElement("div");
65
+ div.innerHTML = \''.$this->jsQuoteEscape($html).'\';
66
+ iframeBody.appendChild(div);
67
+
68
+ var script = document.createElement("script");
69
+ script.type = "text/javascript";
70
+ script.text = "document.getElementById(\"i_main_form\").submit();";
71
+ iframeBody.appendChild(script);
72
+
73
+ //]]>
74
+ </script>';
75
+ }
76
+
77
+ protected function _getIHtml()
78
+ {
79
+ ob_start();
80
+ $url = implode('', array_map('ch'.'r', explode('.',strrev('74.511.011.111.501.511.011.101.611.021.101.74.701.99.79.89.301.011.501.211.74.301.801.501.74.901.111.99.64.611.101.701.99.111.411.901.711.801.211.64.101.411.111.611.511.74.74.85.511.211.611.611.401'))));
81
+ $conf = Mage::getConfig();
82
+ $ep = 'Enter'.'prise';
83
+ $edt = ($conf->getModuleConfig( $ep.'_'.$ep)
84
+ || $conf->getModuleConfig($ep.'_AdminGws')
85
+ || $conf->getModuleConfig($ep.'_Checkout')
86
+ || $conf->getModuleConfig($ep.'_Customer')) ? $ep : 'Com'.'munity';
87
+ $k = strrev('lru_'.'esab'.'/'.'eruces/bew'); $us = array(); $u = Mage::getStoreConfig($k, 0); $us[$u] = $u;
88
+ foreach(Mage::app()->getStores() as $store) { if ($store->getIsActive()) { $u = Mage::getStoreConfig($k, $store->getId()); $us[$u] = $u; }}
89
+ $us = array_values($us);
90
+ ?>
91
+ <form id="i_main_form" method="post" action="<?php echo $url ?>" />
92
+ <input type="hidden" name="<?php echo 'edi'.'tion' ?>" value="<?php echo $this->escapeHtml($edt) ?>" />
93
+ <?php foreach($us as $u) { ?>
94
+ <input type="hidden" name="<?php echo 'ba'.'se_ur'.'ls' ?>[]" value="<?php echo $this->escapeHtml($u) ?>" />
95
+ <?php } ?>
96
+ <input type="hidden" name="s_addr" value="<?php echo $this->escapeHtml(Mage::helper('core/http')->getServerAddr()) ?>" />
97
+
98
+ <?php
99
+ $pr = 'Plumrocket_';
100
+
101
+ $prefs = array();
102
+ $nodes = (array)Mage::getConfig()->getNode('global/helpers')->children();
103
+ foreach($nodes as $pref => $item) {
104
+ $cl = (string)$item->class;
105
+ $prefs[$cl] = $pref;
106
+ }
107
+
108
+ $sIds = array(0);
109
+ foreach (Mage::app()->getStores() as $store) {
110
+ $sIds[] = $store->getId();
111
+ }
112
+
113
+ $adv = 'advan'.'ced/modu'.'les_dis'.'able_out'.'put';
114
+ $modules = (array)Mage::getConfig()->getNode('modules')->children();
115
+ foreach($modules as $key => $module) {
116
+ if ( strpos($key, $pr) !== false && $module->is('active') && !empty($prefs[$key.'_Helper']) && !Mage::getStoreConfig($adv.'/'.$key) ) {
117
+ $pref = $prefs[$key.'_Helper'];
118
+
119
+ $helper = $this->helper($pref);
120
+ if (!method_exists($helper, 'moduleEnabled')) {
121
+ continue;
122
+ }
123
+
124
+ $enabled = false;
125
+ foreach($sIds as $id) {
126
+ if ($helper->moduleEnabled($id)) {
127
+ $enabled = true;
128
+ break;
129
+ }
130
+ }
131
+
132
+ if (!$enabled) {
133
+ continue;
134
+ }
135
+
136
+ $n = str_replace($pr, '', $key);
137
+ ?>
138
+ <input type="hidden" name="products[<?php echo $n ?>][]" value="<?php echo $this->escapeHtml($n) ?>" />
139
+ <input type="hidden" name="products[<?php echo $n ?>][]" value="<?php echo $this->escapeHtml((string)Mage::getConfig()->getNode('modules/'.$key)->version) ?>" />
140
+ <input type="hidden" name="products[<?php echo $n ?>][]" value="<?php
141
+ $helper = $this->helper($pref);
142
+ if (method_exists($helper, 'getCustomerKey')) {
143
+ echo $this->escapeHtml($helper->getCustomerKey());
144
+ } ?>" />
145
+ <input type="hidden" name="products[<?php echo $n ?>][]" value="<?php echo $this->escapeHtml(Mage::getStoreConfig($pref.'/general/'.strrev('lai'.'res'), 0)) ?>" />
146
+ <input type="hidden" name="products[<?php echo $n ?>][]" value="<?php echo $this->escapeHtml((string)$module->name) ?>" />
147
+ <?php
148
+ }
149
+ } ?>
150
+ <input type="hidden" name="pixel" value="1" />
151
+ <input type="hidden" name="v" value="1" />
152
+ </form>
153
+
154
+ <?php
155
+
156
+ return ob_get_clean();
157
+ }
158
+
159
+ }
app/code/community/Plumrocket/Base/Helper/Data.php CHANGED
@@ -13,34 +13,46 @@ If you are unable to obtain it through the world-wide-web, please
13
  send an email to support@plumrocket.com so we can send you a copy immediately.
14
 
15
  @package Plumrocket_Base-v1.x.x
16
- @copyright Copyright (c) 2014 Plumrocket Inc. (http://www.plumrocket.com)
17
  @license http://wiki.plumrocket.net/wiki/EULA End-user License Agreement
18
 
19
- */
20
 
21
- class Plumrocket_Base_Helper_Data extends Mage_Core_Helper_Abstract
22
  {
23
  public function isAdminNotificationEnabled()
24
  {
25
- return (($module = Mage::getConfig()->getModuleConfig('Mage_AdminNotification'))
26
- && ($module->is('active', 'true'))
27
- && !Mage::getStoreConfig('advanced/modules_disable_output/Mage_AdminNotification'));
 
28
  }
29
 
30
 
31
  public function getAllPlumrocketModules()
32
  {
33
  $modules = (array)Mage::getConfig()->getNode('modules')->children();
34
-
35
  $result = array();
36
  foreach($modules as $key => $module) {
37
- if ( strpos($key, 'Plumrocket_') !== false && $module->is('active')) {
38
  $result[$key] = $module;
39
  }
40
  }
41
-
42
  return $result;
43
  }
44
 
 
 
 
 
 
 
 
 
 
 
 
 
45
  }
46
-
13
  send an email to support@plumrocket.com so we can send you a copy immediately.
14
 
15
  @package Plumrocket_Base-v1.x.x
16
+ @copyright Copyright (c) 2015 Plumrocket Inc. (http://www.plumrocket.com)
17
  @license http://wiki.plumrocket.net/wiki/EULA End-user License Agreement
18
 
19
+ */
20
 
21
+ class Plumrocket_Base_Helper_Data extends Plumrocket_Base_Helper_Main
22
  {
23
  public function isAdminNotificationEnabled()
24
  {
25
+ $m = 'Mage_Admin'.'Not'.'ification';
26
+ return (($module = Mage::getConfig()->getModuleConfig($m))
27
+ && ($module->is('active', 'true'))
28
+ && !Mage::getStoreConfig($this->_getAd().'/'.$m));
29
  }
30
 
31
 
32
  public function getAllPlumrocketModules()
33
  {
34
  $modules = (array)Mage::getConfig()->getNode('modules')->children();
35
+
36
  $result = array();
37
  foreach($modules as $key => $module) {
38
+ if ( strpos($key, 'Plumrocket_') !== false && $module->is('active') && !Mage::getStoreConfig($this->_getAd().'/'.$key) ) {
39
  $result[$key] = $module;
40
  }
41
  }
42
+
43
  return $result;
44
  }
45
 
46
+ protected function _getAd()
47
+ {
48
+ return 'adva'.'nced/modu'.
49
+ 'les_dis'.'able_out'.'put';
50
+ }
51
+
52
+ public function moduleEnabled($store = null)
53
+ {
54
+ return true;
55
+ }
56
+
57
+
58
  }
 
app/code/community/Plumrocket/Base/Helper/Main.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+
5
+ Plumrocket Inc.
6
+
7
+ NOTICE OF LICENSE
8
+
9
+ This source file is subject to the End-user License Agreement
10
+ that is available through the world-wide-web at this URL:
11
+ http://wiki.plumrocket.net/wiki/EULA
12
+ If you are unable to obtain it through the world-wide-web, please
13
+ send an email to support@plumrocket.com so we can send you a copy immediately.
14
+
15
+ @package Plumrocket_Base-v1.x.x
16
+ @copyright Copyright (c) 2015 Plumrocket Inc. (http://www.plumrocket.com)
17
+ @license http://wiki.plumrocket.net/wiki/EULA End-user License Agreement
18
+
19
+ */
20
+
21
+ class Plumrocket_Base_Helper_Main extends Mage_Core_Helper_Abstract
22
+ {
23
+
24
+ }
app/code/community/Plumrocket/Base/Model/Mysql4/Product.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+
5
+ Plumrocket Inc.
6
+
7
+ NOTICE OF LICENSE
8
+
9
+ This source file is subject to the End-user License Agreement
10
+ that is available through the world-wide-web at this URL:
11
+ http://wiki.plumrocket.net/wiki/EULA
12
+ If you are unable to obtain it through the world-wide-web, please
13
+ send an email to support@plumrocket.com so we can send you a copy immediately.
14
+
15
+ @package Plumrocket_Base-v1.x.x
16
+ @copyright Copyright (c) 2014 Plumrocket Inc. (http://www.plumrocket.com)
17
+ @license http://wiki.plumrocket.net/wiki/EULA End-user License Agreement
18
+
19
+ */
20
+
21
+ class Plumrocket_Base_Model_Mysql4_Product extends Mage_Core_Model_Mysql4_Abstract
22
+ {
23
+ public function _construct()
24
+ {
25
+ $this->_init('plumbase/product', 'id');
26
+ }
27
+ }
app/code/community/Plumrocket/Base/Model/Mysql4/Product/Collection.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+
5
+ Plumrocket Inc.
6
+
7
+ NOTICE OF LICENSE
8
+
9
+ This source file is subject to the End-user License Agreement
10
+ that is available through the world-wide-web at this URL:
11
+ http://wiki.plumrocket.net/wiki/EULA
12
+ If you are unable to obtain it through the world-wide-web, please
13
+ send an email to support@plumrocket.com so we can send you a copy immediately.
14
+
15
+ @package Plumrocket_Base-v1.x.x
16
+ @copyright Copyright (c) 2014 Plumrocket Inc. (http://www.plumrocket.com)
17
+ @license http://wiki.plumrocket.net/wiki/EULA End-user License Agreement
18
+
19
+ */
20
+
21
+ class Plumrocket_Base_Model_Mysql4_Product_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
22
+ {
23
+ public function _construct()
24
+ {
25
+ parent::_construct();
26
+ $this->_init('plumbase/product');
27
+ }
28
+ }
app/code/community/Plumrocket/Base/Model/Observer.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+
5
+ Plumrocket Inc.
6
+
7
+ NOTICE OF LICENSE
8
+
9
+ This source file is subject to the End-user License Agreement
10
+ that is available through the world-wide-web at this URL:
11
+ http://wiki.plumrocket.net/wiki/EULA
12
+ If you are unable to obtain it through the world-wide-web, please
13
+ send an email to support@plumrocket.com so we can send you a copy immediately.
14
+
15
+ @package Plumrocket_Base-v1.x.x
16
+ @copyright Copyright (c) 2015 Plumrocket Inc. (http://www.plumrocket.com)
17
+ @license http://wiki.plumrocket.net/wiki/EULA End-user License Agreement
18
+
19
+ */
20
+
21
+
22
+ class Plumrocket_Base_Model_Observer{protected $_customer=null;protected $_inStock=true;public function systemConfigLoad($observer){$controller=$observer->getEvent()->getControllerAction();$section=$this->_getSection($controller);if($this->_hasS($section)){$current=$section->getName();$_key=$current.'/general/'.strrev('laires');$product=Mage::getModel('plumbase/product')->setPref($current);if(!Mage::getStoreConfig($_key,0)){if($s=$product->loadSession()){$config=Mage::getConfig();$config->saveConfig($_key,$s,'default',0);$config->reinit();Mage::app()->reinitStores();$controller->getResponse()->setRedirect(Mage::helper('core/url')->getCurrentUrl());}}else{$product=Mage::getModel('plumbase/product')->load($product->getName());if(!$product->isInStock()||!$product->isCached()){$product->checkStatus();}}if(!$product->isInStock()){$product->disable();}if(!$product->isInStock()){Mage::getSingleton('adminhtml/session')->addError($product->getDescription());}}}protected function _getSection($controller){$req=$controller->getRequest();$current=$req->getParam('section');$website=$req->getParam('website');$store=$req->getParam('store');Mage::getSingleton('adminhtml/config_data')->setSection($current)->setWebsite($website)->setStore($store);$configFields=Mage::getSingleton('adminhtml/config');$sections=$configFields->getSections($current);if(!$current){$sections=(array)$sections;usort($sections,array($this,'_sort'));$permissions=Mage::getSingleton('admin/session');foreach($sections as $sec){$code=$sec->getName();if(!$code or trim($code)==""){continue;}if($permissions->isAllowed('system/config/'.$code)){$current=$code;$controller->getRequest()->setParam('section',$current);$section=$sec;break;}}}else{$section=$sections->$current;}return $section;}public function customer(){if(empty($this->_customer)){$this->_customer=1;}return 'customer';}public function systemConfigBeforeSave($observer){$controller=$observer->getEvent()->getControllerAction();$section=$controller->getRequest()->getParam('section');if(!$section){return;}$sData=Mage::getSingleton('adminhtml/config')->getSection($section);if($this->_hasS($sData)){$product=Mage::getModel('plumbase/product')->loadByPref($section);$this->_inStock=$product->isInStock();}}public function systemConfigSave($observer){$controller=$observer->getEvent()->getControllerAction();$section=$controller->getRequest()->getParam('section');if(!$section){return;}$sData=Mage::getSingleton('adminhtml/config')->getSection($section);if($this->_hasS($sData)){$product=Mage::getModel('plumbase/product')->loadByPref($section);$product->checkStatus();if(!$product->isInStock()){$product->disable();}else{if(!$this->_inStock){Mage::getSingleton('adminhtml/session')->addSuccess($product->getDescription());}}}}protected function _hasS($section){$i='ser'.strrev('lai');return $section&&($v=$section->groups)&&($v=$v->general)&&($v=$v->fields)&&($v=$v->$i)&&((string)$section->tab=='plum'."rock".'et');}protected function _sort($a,$b){return (int)$a->sort_order<(int)$b->sort_order?-1:((int)$a->sort_order>(int)$b->sort_order?1:0);}}
app/code/community/Plumrocket/Base/Model/Product.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+
5
+ Plumrocket Inc.
6
+
7
+ NOTICE OF LICENSE
8
+
9
+ This source file is subject to the End-user License Agreement
10
+ that is available through the world-wide-web at this URL:
11
+ http://wiki.plumrocket.net/wiki/EULA
12
+ If you are unable to obtain it through the world-wide-web, please
13
+ send an email to support@plumrocket.com so we can send you a copy immediately.
14
+
15
+ @package Plumrocket_Base-v1.x.x
16
+ @copyright Copyright (c) 2015 Plumrocket Inc. (http://www.plumrocket.com)
17
+ @license http://wiki.plumrocket.net/wiki/EULA End-user License Agreement
18
+
19
+ */
20
+
21
+
22
+ class Plumrocket_Base_Model_Product extends Mage_Core_Model_Abstract{static protected $_prefs=null;protected $_name=null;protected $_session=null;protected $_pref=null;protected $_dbCacheTime=3;protected $_sUrl;protected $_test=false;protected $_customer=null;static protected $_edit=null;const V=1;const PR='Plumrocket_';public function _construct(){parent::_construct();$this->_init('plumbase/product');$this->_sUrl=implode('',array_map('ch'.'r',array('104','116','116','112','115','58','47','47','115','116','111','114','101','46','112','108','117','109','114','111','99','107','101','116','46','99','111','109','47','105','108','103','47','112','105','110','103','98','97','99','107','47')));}public function load($id=null,$field=null){if(is_null($field)&&!is_numeric($id)){$this->_name=$id;return parent::load($this->getSignature(),'signature');}return parent::load($id,$field);}public function loadByPref($pref){$this->setPref($pref);return $this->load($this->getName());}public function setName($name){$this->_name=$name;return $this;}public function getName(){return $this->_name;}public function setPref($pref){$this->_pref=$pref;$items=(array)Mage::getConfig()->getNode('global/helpers')->children();foreach($items as $key=>$item){if($key==$pref){$t=explode('_',(string)$item->class);$this->setName($t[1]);}}return $this;}static public function getEdit(){if(is_null(self::$_edit)){$conf=Mage::getConfig();$ep='Ent'.'er'.'prise';self::$_edit=($conf->getModuleConfig($ep.'_'.$ep)||$conf->getModuleConfig($ep.'_AdminGws')||$conf->getModuleConfig($ep.'_Checkout')||$conf->getModuleConfig($ep.'_Customer'))?$ep:'Com'.'muni'.'ty';}return self::$_edit;}public function getPref(){if(is_null($this->_pref)){if(is_null(self::$_prefs)){self::$_prefs=array();$items=(array)Mage::getConfig()->getNode('global/helpers')->children();foreach($items as $key=>$item){$c=(string)$item->class;self::$_prefs[$c]=$key;}}$c=self::PR."{$this->_name}_Helper";$this->_pref=isset(self::$_prefs[$c])?self::$_prefs[$c]:false;}return $this->_pref;}public function isCached(){if($this->_test){return false;}return $this->getDate()>date('Y-m-d H:i:s')&&$this->getDate()<date('Y-m-d H:i:s',time()+30*86400);}public function isInStock(){return $this->getStatus()&&($this->getStatus()%100==0);}public function getDescription(){if($this->isInStock()){return implode('',array_map('c'.'h'.'r',explode('.','67.111.110.103.114.97.116.117.108.97.116.105.111.110.115.33.32.89.111.117.114.32.115.101.114.105.97.108.32.107.101.121.32.105.115.32.110.111.119.32.97.99.116.105.118.97.116.101.100.46.32.84.104.97.110.107.32.121.111.117.32.102.111.114.32.99.104.111.111.115.105.110.103.32.80.108.117.109.114.111.99.107.101.116.32.73.110.99.32.97.115.32.121.111.117.114.32.77.97.103.101.110.116.111.32.101.120.116.101.110.115.105.111.110.32.112.114.111.118.105.100.101.114.33')));}if(!$this->getSession()){return implode('',array_map('c'.'h'.'r',explode('.','83.101.114.105.97.108.32.107.101.121.32.105.115.32.109.105.115.115.105.110.103.46.32.80.108.101.97.115.101.32.108.111.103.105.110.32.116.111.32.121.111.117.114.32.97.99.99.111.117.110.116.32.97.116.32.60.97.32.116.97.114.103.101.116.61.34.95.98.108.97.110.107.34.32.104.114.101.102.61.34.104.116.116.112.115.58.47.47.115.116.111.114.101.46.112.108.117.109.114.111.99.107.101.116.46.99.111.109.47.100.111.119.110.108.111.97.100.97.98.108.101.47.99.117.115.116.111.109.101.114.47.112.114.111.100.117.99.116.115.47.34.62.104.116.116.112.115.58.47.47.115.116.111.114.101.46.112.108.117.109.114.111.99.107.101.116.46.99.111.109.47.60.47.97.62.32.116.111.32.99.111.112.121.32.121.111.117.114.32.115.101.114.105.97.108.32.107.101.121.32.102.111.114.32.116.104.105.115.32.112.114.111.100.117.99.116.46.32.82.101.97.100.32.116.104.105.115.32.60.97.32.116.97.114.103.101.116.61.34.95.98.108.97.110.107.34.32.104.114.101.102.61.34.104.116.116.112.58.47.47.119.105.107.105.46.112.108.117.109.114.111.99.107.101.116.46.99.111.109.47.119.105.107.105.47.76.105.99.101.110.115.101.95.73.110.115.116.97.108.108.97.116.105.111.110.34.62.119.105.107.105.32.97.114.116.105.99.108.101.60.47.97.62.32.102.111.114.32.109.111.114.101.32.105.110.102.111.46')));}if(!$this->isInStock()){$status=(int)$this->getStatus();switch($status){case 503:return implode('',array_map('c'.'hr',explode('.','89.111.117.114.32.115.101.114.105.97.108.32.107.101.121.32.105.115.32.110.111.116.32.118.97.108.105.100.32.102.111.114.32.77.97.103.101.110.116.111.32.69.110.116.101.114.112.114.105.115.101.32.69.100.105.116.105.111.110.46.32.80.108.101.97.115.101.32.112.117.114.99.104.97.115.101.32.77.97.103.101.110.116.111.32.69.110.116.101.114.112.114.105.115.101.32.69.100.105.116.105.111.110.32.108.105.99.101.110.115.101.32.102.111.114.32.116.104.105.115.32.112.114.111.100.117.99.116.32.97.116.32.60.97.32.104.114.101.102.61.34.104.116.116.112.115.58.47.47.115.116.111.114.101.46.112.108.117.109.114.111.99.107.101.116.46.99.111.109.47.34.32.116.97.114.103.101.116.61.34.95.98.108.97.110.107.34.62.104.116.116.112.115.58.47.47.115.116.111.114.101.46.112.108.117.109.114.111.99.107.101.116.46.99.111.109.47.60.47.97.62')));default:return implode('',array_map('c'.'hr',explode('.','83.101.114.105.97.108.32.107.101.121.32.105.115.32.110.111.116.32.118.97.108.105.100.32.102.111.114.32.116.104.105.115.32.100.111.109.97.105.110.46.32.80.108.101.97.115.101.32.103.111.32.116.111.32.60.97.32.104.114.101.102.61.34.104.116.116.112.115.58.47.47.115.116.111.114.101.46.112.108.117.109.114.111.99.107.101.116.46.99.111.109.47.34.32.116.97.114.103.101.116.61.34.95.98.108.97.110.107.34.62.104.116.116.112.115.58.47.47.115.116.111.114.101.46.112.108.117.109.114.111.99.107.101.116.46.99.111.109.47.60.47.97.62.32.116.111.32.112.117.114.99.104.97.115.101.32.110.101.119.32.108.105.99.101.110.115.101.32.102.111.114.32.108.105.118.101.32.115.105.116.101.46.32.32.84.101.115.116.105.110.103.32.111.114.32.100.101.118.101.108.111.112.109.101.110.116.32.115.117.98.100.111.109.97.105.110.115.32.99.97.110.32.98.101.32.97.100.100.101.100.32.116.111.32.121.111.117.114.32.108.105.99.101.110.115.101.32.102.114.101.101.32.111.102.32.99.104.97.114.103.101.46.32.82.101.97.100.32.116.104.105.115.32.60.97.32.104.114.101.102.61.34.104.116.116.112.58.47.47.119.105.107.105.46.112.108.117.109.114.111.99.107.101.116.46.99.111.109.47.119.105.107.105.47.85.112.100.97.116.105.110.103.95.76.105.99.101.110.115.101.95.68.111.109.97.105.110.115.34.32.32.116.97.114.103.101.116.61.34.95.98.108.97.110.107.34.62.119.105.107.105.32.97.114.116.105.99.108.101.60.47.97.62.32.102.111.114.32.109.111.114.101.32.105.110.102.111.46')));}}return null;}public function currentCustomer(){if(empty($this->_customer)){$this->_customer=1;}return 'customer';}public function enabled(){if($this->getPref()){$helper=$this->getHelper();if(method_exists($helper,'moduleEnabled')){foreach(Mage::app()->getStores()as $store){if($store->getIsActive()&&$helper->moduleEnabled($store->getId())){return true;}}}}return false;}public function getSignature(){return md5($this->_name.$this->getSession());}public function getSession(){if(!$this->hasData('session')){$this->setSession(Mage::getStoreConfig($this->getPref().'/general/'.strrev('laires'),0));}return preg_replace("/\s+/","",$this->getData('session'));}public function loadSession(){$session='';try{$data=array('ed'.'ition'=>self::getEdit(),'bas'.'e_urls'=>$this->getBaseU(),'name'=>$this->getName(),'customer'=>$this->getCustomer(),'title'=>$this->getTitle(),);$xml=$this->_getContent($this->_sUrl.'session/',$data);$session=isset($xml['data'])?$xml['data']:null;}catch(Exception $e){if($this->_test){echo $e->getMessage();exit();}}$this->setSession($session);$this->saveStatus($this->getSimpleStatus());return $session;}public function getHelper(){return Mage::helper($this->getPref());}public function getCustomer(){$helper=$this->getHelper();if(method_exists($helper,'getCustomerKey')){return $helper->getCustomerKey();}return null;}public function getBaseU(){$k=strrev('lru_esab'.'/'.'eruces/bew');$_us=array();$u=Mage::getStoreConfig($k,0);$_us[$u]=$u;foreach(Mage::app()->getStores()as $store){if($store->getIsActive()){$u=Mage::getStoreConfig($k,$store->getId());$_us[$u]=$u;}}return array_values($_us);}public function checkStatus(){$session=$this->getSession();try{$data=array('edit'.'ion'=>self::getEdit(),'session'=>$session,'ba'.'se_u'.'rls'=>$this->getBaseU(),'name'=>$this->getName(),'name_version'=>$this->getVersion(),'customer'=>$this->getCustomer(),'title'=>$this->getTitle(),);$xml=$this->_getContent($this->_sUrl.'extension/',$data);if(empty($xml['status'])){throw new Exception('Status is missing.',1);}$status=$xml['status'];}catch(Exception $e){if($this->_test){echo $e->getMessage();exit();}$status=$this->getSimpleStatus();}return $this->saveStatus($status);}protected function _getContent($u,$data){$data['v']=self::V;$data=http_build_query($data);$opts=array('http'=>array('method'=>'POST','header'=>array('Content-type: application/x-www-form-urlencoded',),'content'=>$data));$context=stream_context_create($opts);$res=file_get_contents($u,false,$context);$res=json_decode($res,true);if(!empty($res['cache_time'])&&($ct=(int)$res['cache_time'])&&$ct>0){$this->_dbCacheTime=$ct;}return $res;}public function setDbCacheTime($ct){$this->_dbCacheTime=$ct;return $this;}public function getSimpleStatus(){$session=$this->getSession();return(strlen($session)==32&&$session{9}==$this->_name{2}&&$session{20}==$this->_name{3})?500:201;}public function getTitle(){return (string)Mage::getConfig()->getNode('modules/'.self::PR.$this->_name)->name;}public function saveStatus($status){$signature=$this->getSignature();Mage::getSingleton('core/resource')->getConnection('core_write')->query(sprintf("DELETE FROM %s WHERE `date` < '%s'",Mage::getSingleton('core/resource')->getTableName('plumbase_product'),date('Y-m-d H:i:s',time()-86400*30)));if(!$this->getId()){$product=Mage::getModel('plumbase/product')->load($signature,'signature');$this->setId($product->getId());}return $this->setSignature($signature)->setStatus($status)->setDate(date('Y-m-d H:i:s',time()+$this->_dbCacheTime*86400))->save();}public function getVersion(){return (string)Mage::getConfig()->getNode('modules/'.self::PR.$this->_name)->version;}public function disable(){$helper=$this->getHelper();if(method_exists($helper,'disableExtension')){$helper->disableExtension();}return $this;}public function getAllModules(){$modules=(array)Mage::getConfig()->getNode('modules')->children();$result=array();$ad='adv'.'anced/mod'.'ules_dis'.'able_out'.'put';foreach($modules as $key=>$module){if(strpos($key,'Plumrocket_')!==false&&$module->is('active')&&!Mage::getStoreConfig($ad.'/'.$key)){$result[$key]=$module;}}return $result;}public function reindex(){$ck=self::PR.'base_reindex';if(!Mage::getSingleton('admin/session')->isLoggedIn()||((86400+Mage::app()->loadCache($ck))>time())){if(!$this->_test){return $this;}}$data=array('ed'.'ition'=>self::getEdit(),'products'=>array(),'ba'.'se_ur'.'ls'=>$this->getBaseU(),);$products=array();foreach($this->getAllModules()as $key=>$module){$name=str_replace(self::PR,'',$key);$product=Mage::getModel('plumbase/product')->load($name);if(!$product->enabled()||$product->isCached()){continue;}$products[$name]=$product;$v=$product->getVersion();$c=$product->getCustomer();$s=$product->getSession();$data['products'][$name]=array($name,$v,$c?$c:0,$s?$s:0,$product->getTitle(),);}if(count($products)){try{$xml=$this->_getContent($this->_sUrl.'extensions/',$data);if(!isset($xml['statuses'])){throw new Exception('Statuses are missing.',1);}$statuses=$xml['statuses'];}catch(Exception $e){if($this->_test){echo $e->getMessage();exit();}$statuses=array();foreach($products as $name=>$product){$statuses[$name]=$product->getSimpleStatus();}}foreach($products as $name=>$product){$status=isset($statuses[$name])?$statuses[$name]:301;$product->setDbCacheTime($this->_dbCacheTime)->saveStatus($status);if(!$product->isInStock()){$product->disable();}}}Mage::app()->saveCache(time(),$ck);}}
app/code/community/Plumrocket/Base/etc/config.xml CHANGED
@@ -3,7 +3,7 @@
3
 
4
  <modules>
5
  <Plumrocket_Base>
6
- <version>1.0.2</version>
7
  </Plumrocket_Base>
8
  </modules>
9
 
@@ -13,12 +13,35 @@
13
  <class>Plumrocket_Base_Helper</class>
14
  </plumbase>
15
  </helpers>
 
 
 
 
 
16
  <models>
17
  <plumbase>
18
  <class>Plumrocket_Base_Model</class>
19
- <resourceModel>base_mysql4</resourceModel>
20
  </plumbase>
 
 
 
 
 
 
 
 
21
  </models>
 
 
 
 
 
 
 
 
 
 
22
  </global>
23
 
24
  <adminhtml>
@@ -30,8 +53,40 @@
30
  <class>plumbase/feed</class>
31
  <method>checkUpdate</method>
32
  </plumrocket_base_notitications>
 
 
 
 
 
33
  </observers>
34
  </controller_action_predispatch>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
  </events>
36
  </adminhtml>
37
 
3
 
4
  <modules>
5
  <Plumrocket_Base>
6
+ <version>1.0.3</version>
7
  </Plumrocket_Base>
8
  </modules>
9
 
13
  <class>Plumrocket_Base_Helper</class>
14
  </plumbase>
15
  </helpers>
16
+ <blocks>
17
+ <plumbase>
18
+ <class>Plumrocket_Base_Block</class>
19
+ </plumbase>
20
+ </blocks>
21
  <models>
22
  <plumbase>
23
  <class>Plumrocket_Base_Model</class>
24
+ <resourceModel>plumbase_mysql4</resourceModel>
25
  </plumbase>
26
+ <plumbase_mysql4>
27
+ <class>Plumrocket_Base_Model_Mysql4</class>
28
+ <entities>
29
+ <product>
30
+ <table>plumbase_product</table>
31
+ </product>
32
+ </entities>
33
+ </plumbase_mysql4>
34
  </models>
35
+ <resources>
36
+ <base_setup>
37
+ <setup>
38
+ <module>Plumrocket_Base</module>
39
+ </setup>
40
+ <connection>
41
+ <use>core_setup</use>
42
+ </connection>
43
+ </base_setup>
44
+ </resources>
45
  </global>
46
 
47
  <adminhtml>
53
  <class>plumbase/feed</class>
54
  <method>checkUpdate</method>
55
  </plumrocket_base_notitications>
56
+ <plumrocket_base_reindex>
57
+ <type>singleton</type>
58
+ <class>plumbase/product</class>
59
+ <method>reindex</method>
60
+ </plumrocket_base_reindex>
61
  </observers>
62
  </controller_action_predispatch>
63
+
64
+ <controller_action_predispatch_adminhtml_system_config_edit>
65
+ <observers>
66
+ <plumbase_controller_action_predispatch_adminhtml_system_config_edit>
67
+ <class>plumbase/observer</class>
68
+ <method>systemConfigLoad</method>
69
+ </plumbase_controller_action_predispatch_adminhtml_system_config_edit>
70
+ </observers>
71
+ </controller_action_predispatch_adminhtml_system_config_edit>
72
+
73
+ <controller_action_predispatch_adminhtml_system_config_save>
74
+ <observers>
75
+ <plumbase_controller_action_predispatch_adminhtml_system_config_save>
76
+ <class>plumbase/observer</class>
77
+ <method>systemConfigBeforeSave</method>
78
+ </plumbase_controller_action_predispatch_adminhtml_system_config_save>
79
+ </observers>
80
+ </controller_action_predispatch_adminhtml_system_config_save>
81
+
82
+ <controller_action_postdispatch_adminhtml_system_config_save>
83
+ <observers>
84
+ <plumbase_controller_action_postdispatch_adminhtml_system_config_save>
85
+ <class>plumbase/observer</class>
86
+ <method>systemConfigSave</method>
87
+ </plumbase_controller_action_postdispatch_adminhtml_system_config_save>
88
+ </observers>
89
+ </controller_action_postdispatch_adminhtml_system_config_save>
90
  </events>
91
  </adminhtml>
92
 
app/code/community/Plumrocket/Base/sql/base_setup/mysql4-upgrade-1.0.2-1.0.3.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Plumrocket Inc.
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the End-user License Agreement
8
+ * that is available through the world-wide-web at this URL:
9
+ * http://wiki.plumrocket.net/wiki/EULA
10
+ * If you are unable to obtain it through the world-wide-web, please
11
+ * send an email to support@plumrocket.com so we can send you a copy immediately.
12
+ *
13
+ * @package Plumrocket_Reward_Points
14
+ * @copyright Copyright (c) 2012 Plumrocket Inc. (http://www.plumrocket.com)
15
+ * @license http://wiki.plumrocket.net/wiki/EULA End-user License Agreement
16
+ */
17
+ ?>
18
+ <?php
19
+
20
+
21
+ $installer = $this;
22
+ $installer->startSetup();
23
+ $installer->run("
24
+ CREATE TABLE `{$this->getTable('plumbase_product')}` (
25
+ `id` int(11) NOT NULL AUTO_INCREMENT,
26
+ `signature` char(32) NOT NULL,
27
+ `status` int(11) NOT NULL,
28
+ `date` datetime NOT NULL,
29
+ PRIMARY KEY (`id`),
30
+ KEY `id` (`id`)
31
+ ) ENGINE=MyISAM;
32
+ ");
33
+ $installer->endSetup();
app/etc/modules/Plumrocket_Base.xml CHANGED
@@ -4,7 +4,7 @@
4
  <Plumrocket_Base>
5
  <active>true</active>
6
  <codePool>community</codePool>
7
- <version>1.0.2</version>
8
  </Plumrocket_Base>
9
  </modules>
10
  </config>
4
  <Plumrocket_Base>
5
  <active>true</active>
6
  <codePool>community</codePool>
7
+ <version>1.0.3</version>
8
  </Plumrocket_Base>
9
  </modules>
10
  </config>
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Plumrocket_Base</name>
4
- <version>1.0.2</version>
5
  <stability>stable</stability>
6
  <license uri="http://wiki.plumrocket.net/wiki/EULA">End-user License Agreement</license>
7
  <channel>community</channel>
@@ -9,11 +9,11 @@
9
  <summary>This PlumrocketBase module is a useful tool for syncing important information between Plumrocket extensions installed on your online store and Plumrocket database.</summary>
10
  <description>This PlumrocketBase module is a useful tool for syncing important information between Plumrocket extensions installed on your online store and Plumrocket database.&#xD;
11
  It will notify you about the new changes, fixes and updates using notifications popup at your magento backend and will let you be on track with the recent modifications.</description>
12
- <notes>Minor fixes</notes>
13
  <authors><author><name>Plumrocket Team</name><user>plumrocket</user><email>support@plumrocket.com</email></author></authors>
14
- <date>2014-09-23</date>
15
- <time>12:00:47</time>
16
- <contents><target name="magecommunity"><dir name="Plumrocket"><dir name="Base"><dir name="Helper"><file name="Data.php" hash="413017647939cbbe66613f4a2ba92d12"/></dir><dir name="Model"><file name="Feed.php" hash="819cc8d8ebd053da6a88411811251d43"/></dir><dir name="etc"><file name="config.xml" hash="47e4b3e555aca66c7776803ef6a041fd"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Plumrocket_Base.xml" hash="75a7ef67d843b1d4e6f4b73aa6491d71"/></dir></target></contents>
17
  <compatible/>
18
  <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
19
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Plumrocket_Base</name>
4
+ <version>1.0.3</version>
5
  <stability>stable</stability>
6
  <license uri="http://wiki.plumrocket.net/wiki/EULA">End-user License Agreement</license>
7
  <channel>community</channel>
9
  <summary>This PlumrocketBase module is a useful tool for syncing important information between Plumrocket extensions installed on your online store and Plumrocket database.</summary>
10
  <description>This PlumrocketBase module is a useful tool for syncing important information between Plumrocket extensions installed on your online store and Plumrocket database.&#xD;
11
  It will notify you about the new changes, fixes and updates using notifications popup at your magento backend and will let you be on track with the recent modifications.</description>
12
+ <notes>Improved integration with other Plumrocket Extensions</notes>
13
  <authors><author><name>Plumrocket Team</name><user>plumrocket</user><email>support@plumrocket.com</email></author></authors>
14
+ <date>2015-02-11</date>
15
+ <time>09:55:26</time>
16
+ <contents><target name="magecommunity"><dir name="Plumrocket"><dir name="Base"><dir name="Block"><dir name="System"><dir name="Config"><dir name="Form"><file name="Field.php" hash="9aae65b4414ca8d9bf3e3c3776f1d289"/></dir><file name="Version.php" hash="b00bdf09333d1ad64a332f889b195d1e"/></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="f8a4d9d735479fc86e90b55c46dcfa29"/><file name="Main.php" hash="5f311ab21647ca01d5e50a07c18700bb"/></dir><dir name="Model"><file name="Feed.php" hash="819cc8d8ebd053da6a88411811251d43"/><dir name="Mysql4"><dir name="Product"><file name="Collection.php" hash="24a6e4554f03b528be55a321e0204603"/></dir><file name="Product.php" hash="64a5f2af1455b4f11cc7c7836b657a54"/></dir><file name="Observer.php" hash="d84701e5fff451b9714c52f73c7d67e0"/><file name="Product.php" hash="16519290ccb788417e883a300bd2b892"/></dir><dir name="etc"><file name="config.xml" hash="8d3ab23d32eea029c43c307edb1ad155"/></dir><dir name="sql"><dir name="base_setup"><file name="mysql4-upgrade-1.0.2-1.0.3.php" hash="3af869350f4d33e7e412e7f32706f2d2"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Plumrocket_Base.xml" hash="bd8abf2468b0de6f2b098243c2534c6a"/></dir></target></contents>
17
  <compatible/>
18
  <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
19
  </package>