Skip to content

Set admin active menu based on ADMIN_RESOURCE #4707

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

Closed
wants to merge 7 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
6 changes: 0 additions & 6 deletions .phpstan.dist.baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -4722,12 +4722,6 @@ parameters:
count: 4
path: app/code/core/Mage/Oauth/Model/Resource/Token/Collection.php

-
message: '#^Parameter \#1 \$data of method Mage_Oauth_Adminhtml_Oauth_ConsumerController\:\:_setFormData\(\) expects array, null given\.$#'
identifier: argument.type
count: 2
path: app/code/core/Mage/Oauth/controllers/Adminhtml/Oauth/ConsumerController.php

-
message: '#^Call to an undefined method Mage_Payment_Model_Method_Abstract\:\:isPartialAuthorization\(\)\.$#'
identifier: method.notFound
Expand Down
4 changes: 3 additions & 1 deletion app/code/core/Mage/Adminhtml/Controller/Action.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,13 @@ protected function _getHelper()
/**
* Define active menu item in menu block
*
* @param string $menuPath
* @return $this
*/
protected function _setActiveMenu($menuPath)
{
$this->getLayout()->getBlock('menu')->setActive($menuPath);
$block = $this->getLayout()->getBlock('menu');
$block->setActive($menuPath);
return $this;
}

Expand Down
8 changes: 6 additions & 2 deletions app/code/core/Mage/Adminhtml/Controller/Sales/Creditmemo.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ protected function _construct()
protected function _initAction()
{
$this->loadLayout()
->_setActiveMenu('sales/creditmemo')
->_setActiveMenu(self::ADMIN_RESOURCE)
->_addBreadcrumb($this->__('Sales'), $this->__('Sales'))
->_addBreadcrumb($this->__('Credit Memos'), $this->__('Credit Memos'));
return $this;
Expand All @@ -66,7 +66,7 @@ public function indexAction()
*/
public function viewAction()
{
if ($creditmemoId = $this->getRequest()->getParam('creditmemo_id')) {
if ($this->getRequest()->getParam('creditmemo_id')) {
$this->_forward('view', 'sales_order_creditmemo', null, ['come_from' => 'sales_creditmemo']);
} else {
$this->_forward('noRoute');
Expand Down Expand Up @@ -96,6 +96,10 @@ public function emailAction()
}
}

/**
* @return Mage_Adminhtml_Controller_Sales_Creditmemo|void
* @throws Zend_Pdf_Exception
*/
public function pdfcreditmemosAction()
{
$creditmemosIds = $this->getRequest()->getPost('creditmemo_ids');
Expand Down
8 changes: 6 additions & 2 deletions app/code/core/Mage/Adminhtml/Controller/Sales/Invoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ protected function _construct()
protected function _initAction()
{
$this->loadLayout()
->_setActiveMenu('sales/invoice')
->_setActiveMenu(self::ADMIN_RESOURCE)
->_addBreadcrumb($this->__('Sales'), $this->__('Sales'))
->_addBreadcrumb($this->__('Invoices'), $this->__('Invoices'));
return $this;
Expand Down Expand Up @@ -78,7 +78,7 @@ public function indexAction()
*/
public function viewAction()
{
if ($invoiceId = $this->getRequest()->getParam('invoice_id')) {
if ($this->getRequest()->getParam('invoice_id')) {
$this->_forward('view', 'sales_order_invoice', null, ['come_from' => 'invoice']);
} else {
$this->_forward('noRoute');
Expand Down Expand Up @@ -121,6 +121,10 @@ public function printAction()
}
}

/**
* @return Mage_Adminhtml_Controller_Sales_Invoice|void
* @throws Zend_Pdf_Exception
*/
public function pdfinvoicesAction()
{
$invoicesIds = $this->getRequest()->getPost('invoice_ids');
Expand Down
11 changes: 8 additions & 3 deletions app/code/core/Mage/Adminhtml/Controller/Sales/Shipment.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ protected function _construct()
protected function _initAction()
{
$this->loadLayout()
->_setActiveMenu('sales/shipment')
->_setActiveMenu(self::ADMIN_RESOURCE)
->_addBreadcrumb($this->__('Sales'), $this->__('Sales'))
->_addBreadcrumb($this->__('Shipments'), $this->__('Shipments'));
return $this;
Expand All @@ -67,13 +67,17 @@ public function indexAction()
*/
public function viewAction()
{
if ($shipmentId = $this->getRequest()->getParam('shipment_id')) {
if ($this->getRequest()->getParam('shipment_id')) {
$this->_forward('view', 'sales_order_shipment', null, ['come_from' => 'shipment']);
} else {
$this->_forward('noRoute');
}
}

/**
* @return Mage_Adminhtml_Controller_Sales_Shipment|void
* @throws Zend_Pdf_Exception
*/
public function pdfshipmentsAction()
{
$shipmentIds = $this->getRequest()->getPost('shipment_ids');
Expand All @@ -84,7 +88,8 @@ public function pdfshipmentsAction()
->load();
$pdf = Mage::getModel('sales/order_pdf_shipment')->getPdf($shipments);

return $this->_prepareDownloadResponse('packingslip' . Mage::getSingleton('core/date')->date('Y-m-d_H-i-s') . '.pdf', $pdf->render(), 'application/pdf');
return $this->_prepareDownloadResponse('packingslip' . Mage::getSingleton('core/date')->date('Y-m-d_H-i-s') .
'.pdf', $pdf->render(), 'application/pdf');
}
$this->_redirect('*/*/');
}
Expand Down
2 changes: 2 additions & 0 deletions app/code/core/Mage/Adminhtml/Model/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
* @category Mage
* @package Mage_Adminhtml
*
* @method string getCommentText(bool $value)
* @method $this setCommentText(string $value)
* @method array|string getProductIds()
* @method $this setProductIds(array|string $value)
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function preDispatch()
protected function _initAction()
{
$this->loadLayout();
$this->_setActiveMenu('system/api/roles');
$this->_setActiveMenu(self::ADMIN_RESOURCE);
$this->_addBreadcrumb($this->__('Web services'), $this->__('Web services'));
$this->_addBreadcrumb($this->__('Permissions'), $this->__('Permissions'));
$this->_addBreadcrumb($this->__('Roles'), $this->__('Roles'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function preDispatch()
protected function _initAction()
{
$this->loadLayout()
->_setActiveMenu('system/api/users')
->_setActiveMenu(self::ADMIN_RESOURCE)
->_addBreadcrumb($this->__('Web Services'), $this->__('Web Services'))
->_addBreadcrumb($this->__('Permissions'), $this->__('Permissions'))
->_addBreadcrumb($this->__('Users'), $this->__('Users'))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function indexAction()
$this->_title($this->__('System'))->_title($this->__('Cache Management'));

$this->loadLayout()
->_setActiveMenu('system/cache')
->_setActiveMenu(self::ADMIN_RESOURCE)
->renderLayout();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ public function editAction()
}

$this->loadLayout();
$this->_setActiveMenu('catalog/categories');
$this->_setActiveMenu(self::ADMIN_RESOURCE);
$this->getLayout()->getBlock('head')->setCanLoadExtJs(true)
->setContainerCssClass('catalog-categories');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ protected function _initAction()
$this->loadLayout('popup');
} else {
$this->loadLayout()
->_setActiveMenu('catalog/attributes/attributes')
->_setActiveMenu(self::ADMIN_RESOURCE)
->_addBreadcrumb(Mage::helper('catalog')->__('Catalog'), Mage::helper('catalog')->__('Catalog'))
->_addBreadcrumb(
Mage::helper('catalog')->__('Manage Product Attributes'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function indexAction()
$this->_setTypeId();

$this->loadLayout();
$this->_setActiveMenu('catalog/attributes/sets');
$this->_setActiveMenu(self::ADMIN_RESOURCE);

$this->_addBreadcrumb(Mage::helper('catalog')->__('Catalog'), Mage::helper('catalog')->__('Catalog'));
$this->_addBreadcrumb(
Expand Down Expand Up @@ -71,7 +71,7 @@ public function editAction()
Mage::register('current_attribute_set', $attributeSet);

$this->loadLayout();
$this->_setActiveMenu('catalog/attributes/sets');
$this->_setActiveMenu(self::ADMIN_RESOURCE);
$this->getLayout()->getBlock('head')->setCanLoadExtJs(true);

$this->_addBreadcrumb(Mage::helper('catalog')->__('Catalog'), Mage::helper('catalog')->__('Catalog'));
Expand Down Expand Up @@ -184,7 +184,7 @@ public function addAction()
$this->_setTypeId();

$this->loadLayout();
$this->_setActiveMenu('catalog/sets');
$this->_setActiveMenu(self::ADMIN_RESOURCE);

$this->_addContent($this->getLayout()->createBlock('adminhtml/catalog_product_attribute_set_toolbar_add'));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ public function newAction()
strtolower($this->getFullActionName()),
'adminhtml_catalog_product_' . $product->getTypeId() . $additionalLayoutPart,
]);
$this->_setActiveMenu('catalog/products');
$this->_setActiveMenu(self::ADMIN_RESOURCE);
}

$this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
Expand Down Expand Up @@ -264,7 +264,7 @@ public function editAction()
'adminhtml_catalog_product_' . $product->getTypeId() . $additionalLayoutPart,
]);

$this->_setActiveMenu('catalog/products');
$this->_setActiveMenu(self::ADMIN_RESOURCE);

if (!Mage::app()->isSingleStoreMode() && ($switchBlock = $this->getLayout()->getBlock('store_switcher'))) {
$switchBlock->setDefaultStoreName($this->__('Default Values'))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Mage_Adminhtml_Catalog_SearchController extends Mage_Adminhtml_Controller_
protected function _initAction()
{
$this->loadLayout()
->_setActiveMenu('catalog/search')
->_setActiveMenu(self::ADMIN_RESOURCE)
->_addBreadcrumb(Mage::helper('catalog')->__('Search'), Mage::helper('catalog')->__('Search'))
;
return $this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Mage_Adminhtml_CatalogController extends Mage_Adminhtml_Controller_Action
public function indexAction()
{
$this->loadLayout();
$this->_setActiveMenu('catalog');
$this->_setActiveMenu(self::ADMIN_RESOURCE);
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Catalog'), Mage::helper('adminhtml')->__('Catalog'));

$this->_addContent($this->getLayout()->createBlock('adminhtml/catalog'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public function deleteAction()
protected function _initAction()
{
$this->loadLayout()
->_setActiveMenu('sales/checkoutagreement')
->_setActiveMenu(self::ADMIN_RESOURCE)
->_addBreadcrumb(Mage::helper('checkout')->__('Sales'), Mage::helper('checkout')->__('Sales'))
->_addBreadcrumb(Mage::helper('checkout')->__('Checkout Conditions'), Mage::helper('checkout')->__('Checkout Terms and Conditions'))
;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ protected function _initAction()
{
// load layout, set active menu and breadcrumbs
$this->loadLayout()
->_setActiveMenu('cms/block')
->_setActiveMenu(self::ADMIN_RESOURCE)
->_addBreadcrumb(Mage::helper('cms')->__('CMS'), Mage::helper('cms')->__('CMS'))
->_addBreadcrumb(Mage::helper('cms')->__('Static Blocks'), Mage::helper('cms')->__('Static Blocks'))
;
Expand Down
16 changes: 12 additions & 4 deletions app/code/core/Mage/Adminhtml/controllers/Cms/PageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@
*/
class Mage_Adminhtml_Cms_PageController extends Mage_Adminhtml_Controller_Action
{
/**
* ACL resource
* @see Mage_Adminhtml_Controller_Action::_isAllowed()
*/
public const ADMIN_RESOURCE = 'cms/page';
public const ADMIN_RESOURCE_SAVE = 'cms/page/save';
public const ADMIN_RESOURCE_DELETE = 'cms/page/delete';

/**
* Init actions
*
Expand All @@ -31,7 +39,7 @@ protected function _initAction()
{
// load layout, set active menu and breadcrumbs
$this->loadLayout()
->_setActiveMenu('cms/page')
->_setActiveMenu(self::ADMIN_RESOURCE)
->_addBreadcrumb(Mage::helper('cms')->__('CMS'), Mage::helper('cms')->__('CMS'))
->_addBreadcrumb(Mage::helper('cms')->__('Manage Pages'), Mage::helper('cms')->__('Manage Pages'))
;
Expand Down Expand Up @@ -226,11 +234,11 @@ protected function _isAllowed()
switch ($action) {
case 'new':
case 'save':
return Mage::getSingleton('admin/session')->isAllowed('cms/page/save');
return Mage::getSingleton('admin/session')->isAllowed(self::ADMIN_RESOURCE_SAVE);
case 'delete':
return Mage::getSingleton('admin/session')->isAllowed('cms/page/delete');
return Mage::getSingleton('admin/session')->isAllowed(self::ADMIN_RESOURCE_DELETE);
default:
return Mage::getSingleton('admin/session')->isAllowed('cms/page');
return Mage::getSingleton('admin/session')->isAllowed(self::ADMIN_RESOURCE);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Mage_Adminhtml_Customer_ConfigController extends Mage_Adminhtml_Controller
public function indexAction()
{
$this->loadLayout();
$this->_setActiveMenu('customer/config');
$this->_setActiveMenu(self::ADMIN_RESOURCE);
$this->_addBreadcrumb(Mage::helper('customer')->__('Customer'), Mage::helper('customer')->__('Customer'));
$this->_addBreadcrumb(Mage::helper('customer')->__('Config'), Mage::helper('customer')->__('Config'));
$this->_addContent(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function indexAction()
$this->_title($this->__('Customers'))->_title($this->__('Customer Groups'));

$this->loadLayout();
$this->_setActiveMenu('customer/group');
$this->_setActiveMenu(self::ADMIN_RESOURCE);
$this->_addBreadcrumb(Mage::helper('customer')->__('Customers'), Mage::helper('customer')->__('Customers'));
$this->_addBreadcrumb(Mage::helper('customer')->__('Customer Groups'), Mage::helper('customer')->__('Customer Groups'));
$this->renderLayout();
Expand All @@ -71,7 +71,7 @@ public function newAction()
{
$this->_initGroup();
$this->loadLayout();
$this->_setActiveMenu('customer/group');
$this->_setActiveMenu(self::ADMIN_RESOURCE);
$this->_addBreadcrumb(Mage::helper('customer')->__('Customers'), Mage::helper('customer')->__('Customers'));
$this->_addBreadcrumb(Mage::helper('customer')->__('Customer Groups'), Mage::helper('customer')->__('Customer Groups'), $this->getUrl('*/customer_group'));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function indexAction()

$this->loadLayout();

$this->_setActiveMenu('customer/online');
$this->_setActiveMenu(self::ADMIN_RESOURCE);

$this->_addContent($this->getLayout()->createBlock('adminhtml/customer_online', 'customers'));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function indexAction()
/**
* Set active menu item
*/
$this->_setActiveMenu('customer/manage');
$this->_setActiveMenu(self::ADMIN_RESOURCE);

/**
* Append customers block to content
Expand Down Expand Up @@ -156,7 +156,7 @@ public function editAction()
/**
* Set active menu item
*/
$this->_setActiveMenu('customer/manage');
$this->_setActiveMenu(self::ADMIN_RESOURCE);

$this->renderLayout();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function indexAction()
$this->_title($this->__('Dashboard'));

$this->loadLayout();
$this->_setActiveMenu('dashboard');
$this->_setActiveMenu(self::ADMIN_RESOURCE);
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Dashboard'), Mage::helper('adminhtml')->__('Dashboard'));
$this->renderLayout();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function indexAction()
);
$this->loadLayout();

$this->_setActiveMenu('newsletter/problem');
$this->_setActiveMenu(self::ADMIN_RESOURCE);

$this->_addBreadcrumb(Mage::helper('newsletter')->__('Newsletter Problem Reports'), Mage::helper('newsletter')->__('Newsletter Problem Reports'));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function indexAction()

$this->loadLayout();

$this->_setActiveMenu('newsletter/queue');
$this->_setActiveMenu(self::ADMIN_RESOURCE);

$this->_addContent(
$this->getLayout()->createBlock('adminhtml/newsletter_queue', 'queue'),
Expand Down Expand Up @@ -196,7 +196,7 @@ public function editAction()

$this->loadLayout();

$this->_setActiveMenu('newsletter/queue');
$this->_setActiveMenu(self::ADMIN_RESOURCE);

$this->_addBreadcrumb(
Mage::helper('newsletter')->__('Newsletter Queue'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function indexAction()

$this->loadLayout();

$this->_setActiveMenu('newsletter/subscriber');
$this->_setActiveMenu(self::ADMIN_RESOURCE);

$this->_addBreadcrumb(Mage::helper('newsletter')->__('Newsletter'), Mage::helper('newsletter')->__('Newsletter'));
$this->_addBreadcrumb(Mage::helper('newsletter')->__('Subscribers'), Mage::helper('newsletter')->__('Subscribers'));
Expand Down
Loading
Loading