Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide and show RSS links #2741

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion app/code/core/Mage/Adminhtml/Block/Catalog/Product/Grid.php
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,9 @@ protected function _prepareColumns()
);

if (Mage::helper('catalog')->isModuleEnabled('Mage_Rss')) {
$this->addRssList('rss/catalog/notifystock', Mage::helper('catalog')->__('Notify Low Stock RSS'));
$storeId = (int) $this->getRequest()->getParam('store', Mage::app()->getDefaultStoreView()->getId());
if (Mage::helper('rss')->isRssEnabled($storeId, 'rss/catalog/notifystock'))
$this->addRssList('rss/catalog/notifystock', Mage::helper('catalog')->__('Notify Low Stock RSS'), $storeId);
}

return parent::_prepareColumns();
Expand Down
15 changes: 14 additions & 1 deletion app/code/core/Mage/Adminhtml/Block/Review/Grid.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,20 @@ protected function _prepareColumns()
]
);

$this->addRssList('rss/catalog/review', Mage::helper('catalog')->__('Pending Reviews RSS'));
if (Mage::helper('catalog')->isModuleEnabled('Mage_Rss')) {
if ($this->getColumn('visible_in')) {
$filter = $this->getParam($this->getVarNameFilter());
if (!empty($filter)) {
$filter = Mage::helper('adminhtml')->prepareFilterString($filter);
if (!empty($filter['visible_in']))
$storeId = $filter['visible_in'];
}
}
if (empty($storeId))
sreichel marked this conversation as resolved.
Show resolved Hide resolved
$storeId = Mage::app()->getDefaultStoreView()->getId();
if (Mage::helper('rss')->isRssEnabled($storeId, 'rss/catalog/review'))
$this->addRssList('rss/catalog/review', Mage::helper('catalog')->__('Pending Reviews RSS'), $storeId);
}

return parent::_prepareColumns();
}
Expand Down
16 changes: 15 additions & 1 deletion app/code/core/Mage/Adminhtml/Block/Sales/Order/Grid.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,21 @@ protected function _prepareColumns()
]
);
}
$this->addRssList('rss/order/new', Mage::helper('sales')->__('New Order RSS'));

if (Mage::helper('catalog')->isModuleEnabled('Mage_Rss')) {
if ($this->getColumn('store_id')) {
$filter = $this->getParam($this->getVarNameFilter());
if (!empty($filter)) {
$filter = Mage::helper('adminhtml')->prepareFilterString($filter);
if (!empty($filter['store_id']))
$storeId = $filter['store_id'];
}
}
if (empty($storeId))
$storeId = Mage::app()->getDefaultStoreView()->getId();
if (Mage::helper('rss')->isRssEnabled($storeId, 'rss/order/new'))
$this->addRssList('rss/order/new', Mage::helper('sales')->__('New Order RSS'), $storeId);
}

$this->addExportType('*/*/exportCsv', Mage::helper('sales')->__('CSV'));
$this->addExportType('*/*/exportExcel', Mage::helper('sales')->__('Excel XML'));
Expand Down
13 changes: 9 additions & 4 deletions app/code/core/Mage/Adminhtml/Block/Widget/Grid.php
Original file line number Diff line number Diff line change
Expand Up @@ -999,15 +999,19 @@ public function getRssLists()
* Can be overloaded in descendant classes to perform custom changes to url passed to addRssList()
*
* @param string $url
* @param mixed $store
* @return string
* @throws Mage_Core_Model_Store_Exception
*/
protected function _getRssUrl($url)
protected function _getRssUrl($url, $store = null)
{
$urlModel = Mage::getModel('core/url');
if (Mage::app()->getStore()->getStoreInUrl()) {
// Url in 'admin' store view won't be accessible, so form it in default store view frontend
$urlModel->setStore(Mage::app()->getDefaultStoreView());
if (empty($store))
$urlModel->setStore(Mage::app()->getDefaultStoreView());
else
$urlModel->setStore(is_object($store) ? $store : Mage::app()->getStore($store));
}
return $urlModel->getUrl($url);
}
Expand All @@ -1017,14 +1021,15 @@ protected function _getRssUrl($url)
*
* @param string $url
* @param string $label
* @param mixed $store
* @return Mage_Adminhtml_Block_Widget_Grid
* @throws Mage_Core_Model_Store_Exception
*/
public function addRssList($url, $label)
public function addRssList($url, $label, $store = null)
{
$this->_rssLists[] = new Varien_Object(
[
'url' => $this->_getRssUrl($url),
'url' => $this->_getRssUrl($url, $store),
'label' => $label
]
);
Expand Down
13 changes: 9 additions & 4 deletions app/code/core/Mage/Rss/Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ public function __construct(array $params = [])

/**
* Authenticate customer on frontend
*
*/
public function authFrontend()
{
Expand Down Expand Up @@ -105,7 +104,6 @@ public function authValidate($headers = null)

/**
* Send authenticate failed headers
*
*/
public function authFailed()
{
Expand All @@ -132,10 +130,17 @@ public function disableFlat()
/**
* Check if module was activated in system configurations
*
* @param mixed $store
* @param string $config
* @return bool
*/
public function isRssEnabled()
public function isRssEnabled($store = null, $config = null)
{
return Mage::getStoreConfigFlag(self::XML_PATH_RSS_ACTIVE);
$result = Mage::getStoreConfigFlag(self::XML_PATH_RSS_ACTIVE, $store);

if (!empty($config))
$result = $result && Mage::getStoreConfigFlag($config, $store);

return $result;
}
}
10 changes: 5 additions & 5 deletions app/code/core/Mage/Rss/etc/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,16 @@
<show_in_store>1</show_in_store>
<groups>
<config translate="label">
<label>Rss Config</label>
<label>General</label>
<sort_order>1</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<fields>
<active translate="label">
<label>Enable RSS</label>
<label>Enable</label>
<frontend_type>select</frontend_type>
<source_model>adminhtml/system_config_source_enabledisable</source_model>
<source_model>adminhtml/system_config_source_yesno</source_model>
sreichel marked this conversation as resolved.
Show resolved Hide resolved
<backend_model>rss/system_config_backend_links</backend_model>
<sort_order>10</sort_order>
<show_in_default>1</show_in_default>
Expand All @@ -57,9 +57,9 @@
<show_in_store>1</show_in_store>
<fields>
<active translate="label">
<label>Enable RSS</label>
<label>Enable</label>
<frontend_type>select</frontend_type>
<source_model>adminhtml/system_config_source_enabledisable</source_model>
<source_model>adminhtml/system_config_source_yesno</source_model>
<sort_order>10</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
Expand Down