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

Use config for admin RSS links, ref #2741 #2760

Closed
wants to merge 10 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 @@ -298,7 +298,9 @@ protected function _prepareColumns()
);

if (Mage::helper('catalog')->isModuleEnabled('Mage_Rss')) {
$this->addRssList('rss/catalog/notifystock', Mage::helper('catalog')->__('Notify Low Stock RSS'));
if (Mage::helper('rss')->isRssAdminCatalogNotifyStockEnabled()) {
$this->addRssList('rss/catalog/notifystock', Mage::helper('catalog')->__('Notify Low Stock RSS'));
}
}

return parent::_prepareColumns();
Expand Down
8 changes: 6 additions & 2 deletions app/code/core/Mage/Adminhtml/Block/Review/Grid.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,15 +196,19 @@ protected function _prepareColumns()
'ret' => (Mage::registry('usePendingFilter')) ? 'pending' : null
]
],
'field' => 'id'
'field' => 'id'
]
],
'filter' => false,
'sortable' => false
]
);

$this->addRssList('rss/catalog/review', Mage::helper('catalog')->__('Pending Reviews RSS'));
if (Mage::helper('review')->isModuleOutputEnabled('Mage_Rss')) {
if (Mage::helper('rss')->isRssAdminCatalogReviewEnabled()) {
$this->addRssList('rss/catalog/review', Mage::helper('catalog')->__('Pending Reviews RSS'));
}
}

return parent::_prepareColumns();
}
Expand Down
12 changes: 11 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 @@ -147,7 +147,17 @@ protected function _prepareColumns()
]
);
}
$this->addRssList('rss/order/new', Mage::helper('sales')->__('New Order RSS'));

if (Mage::helper('sales')->isModuleOutputEnabled('Mage_Rss')) {
$filterString = $this->getParam($this->getVarNameFilter());
$filter = Mage::helper('adminhtml')->prepareFilterString($filterString);
$storeId = array_key_exists('store_id', $filter) ? $filter['store_id'] : null;

if (Mage::helper('rss')->isRssAdminOrderNewEnabled($storeId)) {
$slug = $storeId ? '/store/' . $storeId : '';
$this->addRssList('rss/order/new' . $slug, Mage::helper('sales')->__('New Order RSS'));
}
}

$this->addExportType('*/*/exportCsv', Mage::helper('sales')->__('CSV'));
$this->addExportType('*/*/exportExcel', Mage::helper('sales')->__('Excel XML'));
Expand Down
8 changes: 7 additions & 1 deletion app/code/core/Mage/Rss/Block/Order/New.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,11 @@ protected function _construct()
*/
protected function _toHtml()
{
$storeId = $this->getRequest()->getParam('store', null);
$order = Mage::getModel('sales/order');
$period = Mage::helper('rss')->getRssAdminOrderNewPeriod($storeId);
$passDate = $order->getResource()->formatDate(
mktime(0, 0, 0, (int)date('m'), (int)date('d') - 7)
mktime(0, 0, 0, (int)date('m'), (int)date('d') - $period)
);

$newurl = Mage::helper('adminhtml')->getUrl('adminhtml/sales_order', ['_secure' => true, '_nosecret' => true]);
Expand All @@ -72,6 +74,10 @@ protected function _toHtml()
->addAttributeToSort('created_at', 'desc')
;

if ($storeId) {
$collection->addAttributeToFilter('store_id', $storeId);
}

$detailBlock = Mage::getBlockSingleton('rss/order_details');

Mage::dispatchEvent('rss_order_new_collection_select', ['collection' => $collection]);
Expand Down
40 changes: 39 additions & 1 deletion app/code/core/Mage/Rss/Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ class Mage_Rss_Helper_Data extends Mage_Core_Helper_Abstract
/**
* Config path to RSS field
*/
public const XML_PATH_RSS_ACTIVE = 'rss/config/active';
public const XML_PATH_RSS_ACTIVE = 'rss/config/active';
public const XML_PATH_RSS_ADMIN_CATALOG_NOTIFYSTOCK = 'rss/admin_catalog/notifystock';
public const XML_PATH_RSS_ADMIN_CATALOG_REVIEW = 'rss/admin_catalog/review';
public const XML_PATH_RSS_ADMIN_ORDER_NEW = 'rss/admin_order/new';
public const XML_PATH_RSS_ADMIN_ORDER_NEW_PERIOD = 'rss/admin_order/new_period';

protected $_moduleName = 'Mage_Rss';

Expand Down Expand Up @@ -138,4 +142,38 @@ public function isRssEnabled()
{
return Mage::getStoreConfigFlag(self::XML_PATH_RSS_ACTIVE);
}

/**
* @return bool
*/
public function isRssAdminCatalogNotifyStockEnabled(): bool
{
return $this->isRssEnabled() && Mage::getStoreConfigFlag(self::XML_PATH_RSS_ADMIN_CATALOG_NOTIFYSTOCK);
}

/**
* @return bool
*/
public function isRssAdminCatalogReviewEnabled(): bool
{
return $this->isRssEnabled() && Mage::getStoreConfigFlag(self::XML_PATH_RSS_ADMIN_CATALOG_REVIEW);
}

/**
* @param null|string|bool|int|Mage_Core_Model_Store $store
* @return bool
*/
public function isRssAdminOrderNewEnabled($store = null): bool
{
return $this->isRssEnabled() && Mage::getStoreConfigFlag(self::XML_PATH_RSS_ADMIN_ORDER_NEW, $store);
}

/**
* @param null|string|bool|int|Mage_Core_Model_Store $store
* @return int
*/
public function getRssAdminOrderNewPeriod($store = null): int
{
return (int)Mage::getStoreConfig(self::XML_PATH_RSS_ADMIN_ORDER_NEW_PERIOD, $store);
}
}
5 changes: 5 additions & 0 deletions app/code/core/Mage/Rss/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@
</layout>
</frontend>
<default>
<rss>
<admin_order>
<new_period>7</new_period>
</admin_order>
</rss>
<validators>
<custom_layout>
<disallowed_block>
Expand Down
27 changes: 18 additions & 9 deletions app/code/core/Mage/Rss/etc/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<fields>
<active translate="label">
<active translate="label">
<label>Enable RSS</label>
<frontend_type>select</frontend_type>
<source_model>adminhtml/system_config_source_enabledisable</source_model>
Expand Down Expand Up @@ -146,7 +146,7 @@
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<fields>
<status_notified translate="label comment">
<status_notified translate="label comment">
<label>Customer Order Status Notification</label>
<comment>Enabling can increase security risk by exposing some order details.</comment>
<frontend_type>select</frontend_type>
Expand Down Expand Up @@ -180,26 +180,26 @@
<label>Admin Catalog</label>
<sort_order>5</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<show_in_website>0</show_in_website>
<show_in_store>0</show_in_store>
<fields>
<review translate="label">
<label>Review Notification</label>
<frontend_type>select</frontend_type>
<source_model>adminhtml/system_config_source_enabledisable</source_model>
<sort_order>10</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<show_in_website>0</show_in_website>
<show_in_store>0</show_in_store>
</review>
<notifystock translate="label">
<label>Stock Notification</label>
<frontend_type>select</frontend_type>
<source_model>adminhtml/system_config_source_enabledisable</source_model>
<sort_order>20</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<show_in_website>0</show_in_website>
<show_in_store>0</show_in_store>
</notifystock>
</fields>
</admin_catalog>
Expand All @@ -210,7 +210,7 @@
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<fields>
<new translate="label">
<new translate="label">
<label>New Order Notification</label>
<frontend_type>select</frontend_type>
<source_model>adminhtml/system_config_source_enabledisable</source_model>
Expand All @@ -219,6 +219,15 @@
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
</new>
<new_period translate="label">
<label>New Order Period (days)</label>
<validate>validate-digits</validate>
<sort_order>20</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<depends><new>1</new></depends>
</new_period>
</fields>
</admin_order>
</groups>
Expand Down
1 change: 1 addition & 0 deletions app/locale/en_US/Mage_Rss.csv
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"Message:","Message:"
"Miscellaneous Feeds","Miscellaneous Feeds"
"New Order Notification","New Order Notification"
"New Order Period (days)","New Order Period (days)"
"New Orders","New Orders"
"New Products","New Products"
"New Products from %s","New Products from %s"
Expand Down