Plumrocket_Base - Version 1.0.6

Version Notes

Improvements for PHP versions 5.4+

Download this release

Release Info

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


Code changes from version 1.0.5 to 1.0.6

app/code/community/Plumrocket/Base/Model/Product.php CHANGED
@@ -19,4 +19,4 @@ send an email to support@plumrocket.com so we can send you a copy immediately.
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=array()){$data['v']=self::V;$query=http_build_query($data);$ch=curl_init();curl_setopt($ch,CURLOPT_URL,$u);curl_setopt($ch,CURLOPT_POST,count($data));curl_setopt($ch,CURLOPT_POSTFIELDS,$query);curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);$res=curl_exec($ch);$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);}}
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, $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=array()){$data['v']=self::V;$query=http_build_query($data);$ch=curl_init();curl_setopt($ch,CURLOPT_URL,$u);curl_setopt($ch,CURLOPT_POST,count($data));curl_setopt($ch,CURLOPT_POSTFIELDS,$query);curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);$res=curl_exec($ch);$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.5</version>
7
  </Plumrocket_Base>
8
  </modules>
9
 
@@ -53,18 +53,24 @@
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
  <plumrocket_base_permissionsCheck>
 
62
  <class>plumbase/observer</class>
63
  <method>permissionsCheck</method>
64
  </plumrocket_base_permissionsCheck>
65
  </observers>
66
  </controller_action_predispatch>
67
 
 
 
 
 
 
 
 
 
 
 
68
  <controller_action_predispatch_adminhtml_system_config_edit>
69
  <observers>
70
  <plumbase_controller_action_predispatch_adminhtml_system_config_edit>
3
 
4
  <modules>
5
  <Plumrocket_Base>
6
+ <version>1.0.6</version>
7
  </Plumrocket_Base>
8
  </modules>
9
 
53
  <class>plumbase/feed</class>
54
  <method>checkUpdate</method>
55
  </plumrocket_base_notitications>
 
 
 
 
 
56
  <plumrocket_base_permissionsCheck>
57
+ <type>singleton</type>
58
  <class>plumbase/observer</class>
59
  <method>permissionsCheck</method>
60
  </plumrocket_base_permissionsCheck>
61
  </observers>
62
  </controller_action_predispatch>
63
 
64
+ <controller_action_postdispatch>
65
+ <observers>
66
+ <plumrocket_base_reindex>
67
+ <type>singleton</type>
68
+ <class>plumbase/product</class>
69
+ <method>reindex</method>
70
+ </plumrocket_base_reindex>
71
+ </observers>
72
+ </controller_action_postdispatch>
73
+
74
  <controller_action_predispatch_adminhtml_system_config_edit>
75
  <observers>
76
  <plumbase_controller_action_predispatch_adminhtml_system_config_edit>
app/code/community/Plumrocket/Base/sql/base_setup/mysql4-upgrade-1.0.2-1.0.3.php CHANGED
@@ -21,7 +21,7 @@
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,
21
  $installer = $this;
22
  $installer->startSetup();
23
  $installer->run("
24
+ CREATE TABLE IF NOT EXISTS `{$this->getTable('plumbase_product')}` (
25
  `id` int(11) NOT NULL AUTO_INCREMENT,
26
  `signature` char(32) NOT NULL,
27
  `status` int(11) NOT NULL,
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.5</version>
8
  </Plumrocket_Base>
9
  </modules>
10
  </config>
4
  <Plumrocket_Base>
5
  <active>true</active>
6
  <codePool>community</codePool>
7
+ <version>1.0.6</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.5</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>2015-03-24</date>
15
- <time>09:21:44</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="79c9f4af420639ba3136457007714797"/></dir><file name="Version.php" hash="4823969de9c895aa16feb015686bc71b"/></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="f8a4d9d735479fc86e90b55c46dcfa29"/><file name="Main.php" hash="5f311ab21647ca01d5e50a07c18700bb"/></dir><dir name="Model"><file name="CronChecker.php" hash="fe64f5cf4432127043cd6cf0374b52de"/><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="15b4655f0c0b1e5b00dd02c951a19ffe"/><file name="Product.php" hash="aa896cba6a284e4ed1b40a059de76ec4"/></dir><dir name="etc"><file name="config.xml" hash="2b9109c1fe12ad1bf52a59edadfe5fa1"/></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="bcbd05cb8a4a0e71e066b690933af1a1"/></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.6</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>Improvements for PHP versions 5.4+</notes>
13
  <authors><author><name>Plumrocket Team</name><user>plumrocket</user><email>support@plumrocket.com</email></author></authors>
14
+ <date>2015-05-25</date>
15
+ <time>13:25:16</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="79c9f4af420639ba3136457007714797"/></dir><file name="Version.php" hash="4823969de9c895aa16feb015686bc71b"/></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="f8a4d9d735479fc86e90b55c46dcfa29"/><file name="Main.php" hash="5f311ab21647ca01d5e50a07c18700bb"/></dir><dir name="Model"><file name="CronChecker.php" hash="fe64f5cf4432127043cd6cf0374b52de"/><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="15b4655f0c0b1e5b00dd02c951a19ffe"/><file name="Product.php" hash="382b24117a126f20b0bfa0d4f92d4a48"/></dir><dir name="etc"><file name="config.xml" hash="968207312d8cc466c5715d21ef8cec84"/></dir><dir name="sql"><dir name="base_setup"><file name="mysql4-upgrade-1.0.2-1.0.3.php" hash="206149fc03911af4ea5b2ace60b455f3"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Plumrocket_Base.xml" hash="e1576a5c29d6c4ecf966d331eced1198"/></dir></target></contents>
17
  <compatible/>
18
  <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
19
  </package>