Skip to content

Better config for admin RSS links #4243

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

Merged
merged 2 commits into from
Oct 14, 2024
Merged
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ UPS shut down their old CGI APIs so we removed the support for it from the Mage_
- `catalog/search/search_separator`
- `dev/log/max_level`
- `newsletter/security/enable_form_key`
- `rss/admin_order/new_period`
- `sitemap/category/lastmod`
- `sitemap/page/lastmod`
- `sitemap/product/lastmod`
Expand Down
3 changes: 1 addition & 2 deletions app/code/core/Mage/Adminhtml/Block/Catalog/Product/Grid.php
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,7 @@ protected function _prepareColumns()
);

if (Mage::helper('catalog')->isModuleEnabled('Mage_Rss') &&
Mage::helper('rss')->isRssEnabled() &&
Mage::getStoreConfigFlag('rss/catalog/notifystock')
Mage::helper('rss')->isRssAdminCatalogNotifyStockEnabled()
) {
$this->addRssList('rss/catalog/notifystock', Mage::helper('catalog')->__('Notify Low Stock RSS'));
}
Expand Down
5 changes: 2 additions & 3 deletions app/code/core/Mage/Adminhtml/Block/Review/Grid.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ protected function _prepareColumns()
'ret' => (Mage::registry('usePendingFilter')) ? 'pending' : null
]
],
'field' => 'id'
'field' => 'id'
]
],
'filter' => false,
Expand All @@ -198,8 +198,7 @@ protected function _prepareColumns()
);

if (Mage::helper('catalog')->isModuleEnabled('Mage_Rss') &&
Mage::helper('rss')->isRssEnabled() &&
Mage::getStoreConfigFlag('rss/catalog/review')
Mage::helper('rss')->isRssAdminCatalogReviewEnabled()
) {
$this->addRssList('rss/catalog/review', Mage::helper('catalog')->__('Pending Reviews RSS'));
}
Expand Down
14 changes: 9 additions & 5 deletions app/code/core/Mage/Adminhtml/Block/Sales/Order/Grid.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,15 @@ protected function _prepareColumns()
);
}

if (Mage::helper('catalog')->isModuleEnabled('Mage_Rss') &&
Mage::helper('rss')->isRssEnabled() &&
Mage::getStoreConfigFlag('rss/order/new')
) {
$this->addRssList('rss/order/new', Mage::helper('sales')->__('New Order RSS'));
if (Mage::helper('sales')->isModuleOutputEnabled('Mage_Rss')) {
$filterString = $this->getParam($this->getVarNameFilter());

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can be null and it triggers a null parameter warning in prepareFilterString

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sreichel Can you fix:

    [type] => 8192:E_DEPRECATED
    [message] => base64_decode(): Passing null to parameter #1 ($string) of type string is deprecated
    [file] => app\code\core\Mage\Adminhtml\Helper\Data.php
    [line] => 108

Copy link
Contributor Author

@sreichel sreichel Oct 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. PR comming. How to reproduce?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

go to the sales->order backend page...

$filter = Mage::helper('adminhtml')->prepareFilterString($filterString);
$storeId = array_key_exists('store_id', $filter) ? $filter['store_id'] : null;

if (Mage::helper('rss')->isRssAdminOrderNewEnabled($storeId)) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if ($storeId && Mage::helper('rss')->isRssAdminOrderNewEnabled($storeId)) {

Copy link
Contributor Author

@sreichel sreichel Oct 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$storeId is used one line later and default view (when i remember right?)

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

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

$this->addExportType('*/*/exportCsv', Mage::helper('sales')->__('CSV'));
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 @@ -44,9 +44,11 @@ protected function _construct()
*/
protected function _toHtml()
{
$storeId = $this->getRequest()->getParam('store');
$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 @@ -65,6 +67,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
32 changes: 31 additions & 1 deletion app/code/core/Mage/Rss/Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,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 @@ -131,4 +135,30 @@ public function isRssEnabled()
{
return Mage::getStoreConfigFlag(self::XML_PATH_RSS_ACTIVE);
}

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

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
*/
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
*/
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 @@ -113,6 +113,11 @@
</layout>
</frontend>
<default>
<rss>
<admin_order>
<new_period>7</new_period>
</admin_order>
</rss>
<validators>
<custom_layout>
<disallowed_block>
Expand Down
22 changes: 13 additions & 9 deletions app/code/core/Mage/Rss/etc/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,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 @@ -140,7 +140,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 @@ -174,26 +174,20 @@
<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>
<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>
</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>
</notifystock>
</fields>
</admin_catalog>
Expand All @@ -204,7 +198,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 @@ -213,6 +207,16 @@
<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>
<validate>required-entry validate-digits validate-greater-than-zero</validate>
</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
Loading