Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/ref-2940' into ref-2940
Browse files Browse the repository at this point in the history
  • Loading branch information
sreichel committed Oct 14, 2024
2 parents 9085a10 + 30f22b3 commit 99defaf
Show file tree
Hide file tree
Showing 11 changed files with 241 additions and 38 deletions.
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());
$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'));
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
10 changes: 6 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@
"phpseclib/mcrypt_compat": "^2.0.3",
"phpseclib/phpseclib": "^3.0.14",
"shardj/zf1-future": "1.24.0",
"symfony/polyfill-php74": "^1.29",
"symfony/polyfill-php80": "^1.29",
"symfony/polyfill-php81": "^1.29",
"symfony/polyfill-php82": "^1.29"
"symfony/polyfill-php74": "^1.31",
"symfony/polyfill-php80": "^1.31",
"symfony/polyfill-php81": "^1.31",
"symfony/polyfill-php82": "^1.31",
"symfony/polyfill-php83": "^1.31",
"symfony/polyfill-php84": "^1.31"
},
"require-dev": {
"ext-xmlreader": "*",
Expand Down
Loading

0 comments on commit 99defaf

Please sign in to comment.