From 41c6063a827aee627ca0a454344f9fc79ea99655 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Fri, 15 Nov 2024 09:55:57 +0100 Subject: [PATCH 1/2] set menu (wip) --- .../core/Mage/Adminhtml/Controller/Action.php | 4 +- .../Adminhtml/Controller/Sales/Creditmemo.php | 8 +++- .../Adminhtml/Controller/Sales/Invoice.php | 8 +++- .../Adminhtml/Controller/Sales/Shipment.php | 11 ++++-- .../core/Mage/Adminhtml/Model/Session.php | 2 + .../controllers/Api/RoleController.php | 2 +- .../controllers/Api/UserController.php | 2 +- .../Adminhtml/controllers/CacheController.php | 2 +- .../Catalog/CategoryController.php | 2 +- .../Catalog/Product/AttributeController.php | 2 +- .../Catalog/Product/SetController.php | 6 +-- .../controllers/Catalog/ProductController.php | 4 +- .../controllers/Catalog/SearchController.php | 2 +- .../controllers/CatalogController.php | 2 +- .../Checkout/AgreementController.php | 2 +- .../controllers/Cms/BlockController.php | 2 +- .../controllers/Cms/PageController.php | 16 ++++++-- .../controllers/Customer/ConfigController.php | 2 +- .../controllers/Customer/GroupController.php | 4 +- .../controllers/Customer/OnlineController.php | 2 +- .../controllers/CustomerController.php | 4 +- .../controllers/DashboardController.php | 2 +- .../Newsletter/ProblemController.php | 2 +- .../Newsletter/QueueController.php | 4 +- .../Newsletter/SubscriberController.php | 2 +- .../Newsletter/TemplateController.php | 15 +++----- .../Permissions/BlockController.php | 2 +- .../OrphanedResourceController.php | 2 +- .../Permissions/RoleController.php | 2 +- .../Permissions/UserController.php | 2 +- .../Permissions/VariableController.php | 2 +- .../controllers/Promo/CatalogController.php | 2 +- .../controllers/Promo/QuoteController.php | 2 +- .../Adminhtml/controllers/PromoController.php | 2 +- .../Sales/Order/CreditmemoController.php | 37 +++++++++---------- .../Sales/Order/StatusController.php | 8 ++-- .../Sales/Recurring/ProfileController.php | 4 +- .../Adminhtml/controllers/SalesController.php | 2 +- .../controllers/SitemapController.php | 2 +- .../controllers/System/AccountController.php | 2 +- .../controllers/System/CacheController.php | 2 +- .../controllers/System/ConfigController.php | 2 +- .../controllers/System/CurrencyController.php | 2 +- .../controllers/System/DesignController.php | 4 +- .../System/Email/TemplateController.php | 4 +- .../controllers/System/StoreController.php | 2 +- .../controllers/System/VariableController.php | 2 +- .../Tax/Class/CustomerController.php | 2 +- .../Tax/Class/ProductController.php | 2 +- .../controllers/Tax/RuleController.php | 2 +- .../controllers/UrlrewriteController.php | 4 +- .../System/CurrencysymbolController.php | 2 +- .../Adminhtml/ExportController.php | 2 +- .../Adminhtml/ImportController.php | 2 +- .../Adminhtml/ProcessController.php | 4 +- .../Adminhtml/Oauth/Admin/TokenController.php | 18 ++++----- .../Oauth/AuthorizedTokensController.php | 18 ++++----- .../Adminhtml/Oauth/ConsumerController.php | 16 +++++--- .../Mage/Widget/Model/Widget/Instance.php | 6 +-- .../Adminhtml/Widget/InstanceController.php | 2 +- lib/Varien/Object.php | 36 +++++++----------- 61 files changed, 164 insertions(+), 155 deletions(-) diff --git a/app/code/core/Mage/Adminhtml/Controller/Action.php b/app/code/core/Mage/Adminhtml/Controller/Action.php index ed492bedd1c..043d5424de4 100644 --- a/app/code/core/Mage/Adminhtml/Controller/Action.php +++ b/app/code/core/Mage/Adminhtml/Controller/Action.php @@ -103,11 +103,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; } diff --git a/app/code/core/Mage/Adminhtml/Controller/Sales/Creditmemo.php b/app/code/core/Mage/Adminhtml/Controller/Sales/Creditmemo.php index 68388283b03..e5893216af6 100644 --- a/app/code/core/Mage/Adminhtml/Controller/Sales/Creditmemo.php +++ b/app/code/core/Mage/Adminhtml/Controller/Sales/Creditmemo.php @@ -44,7 +44,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; @@ -65,7 +65,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'); @@ -95,6 +95,10 @@ public function emailAction() } } + /** + * @return Mage_Adminhtml_Controller_Sales_Creditmemo|void + * @throws Zend_Pdf_Exception + */ public function pdfcreditmemosAction() { $creditmemosIds = $this->getRequest()->getPost('creditmemo_ids'); diff --git a/app/code/core/Mage/Adminhtml/Controller/Sales/Invoice.php b/app/code/core/Mage/Adminhtml/Controller/Sales/Invoice.php index a5404b3aab1..d3d37edf39d 100644 --- a/app/code/core/Mage/Adminhtml/Controller/Sales/Invoice.php +++ b/app/code/core/Mage/Adminhtml/Controller/Sales/Invoice.php @@ -43,7 +43,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; @@ -77,7 +77,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'); @@ -120,6 +120,10 @@ public function printAction() } } + /** + * @return Mage_Adminhtml_Controller_Sales_Invoice|void + * @throws Zend_Pdf_Exception + */ public function pdfinvoicesAction() { $invoicesIds = $this->getRequest()->getPost('invoice_ids'); diff --git a/app/code/core/Mage/Adminhtml/Controller/Sales/Shipment.php b/app/code/core/Mage/Adminhtml/Controller/Sales/Shipment.php index 41d1303ceaf..47ce3d60939 100644 --- a/app/code/core/Mage/Adminhtml/Controller/Sales/Shipment.php +++ b/app/code/core/Mage/Adminhtml/Controller/Sales/Shipment.php @@ -43,7 +43,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; @@ -66,13 +66,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'); @@ -83,7 +87,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('*/*/'); } diff --git a/app/code/core/Mage/Adminhtml/Model/Session.php b/app/code/core/Mage/Adminhtml/Model/Session.php index e85c9ac3090..c598c264057 100644 --- a/app/code/core/Mage/Adminhtml/Model/Session.php +++ b/app/code/core/Mage/Adminhtml/Model/Session.php @@ -19,6 +19,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) */ diff --git a/app/code/core/Mage/Adminhtml/controllers/Api/RoleController.php b/app/code/core/Mage/Adminhtml/controllers/Api/RoleController.php index 7e254387b07..bb931d9f976 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Api/RoleController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Api/RoleController.php @@ -41,7 +41,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')); diff --git a/app/code/core/Mage/Adminhtml/controllers/Api/UserController.php b/app/code/core/Mage/Adminhtml/controllers/Api/UserController.php index bf787d8fd6a..520bc3d57ed 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Api/UserController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Api/UserController.php @@ -39,7 +39,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')) diff --git a/app/code/core/Mage/Adminhtml/controllers/CacheController.php b/app/code/core/Mage/Adminhtml/controllers/CacheController.php index 37de3175252..3dfebc3cfa6 100644 --- a/app/code/core/Mage/Adminhtml/controllers/CacheController.php +++ b/app/code/core/Mage/Adminhtml/controllers/CacheController.php @@ -43,7 +43,7 @@ public function indexAction() $this->_title($this->__('System'))->_title($this->__('Cache Management')); $this->loadLayout() - ->_setActiveMenu('system/cache') + ->_setActiveMenu(self::ADMIN_RESOURCE) ->renderLayout(); } diff --git a/app/code/core/Mage/Adminhtml/controllers/Catalog/CategoryController.php b/app/code/core/Mage/Adminhtml/controllers/Catalog/CategoryController.php index 9c7268ae1cb..cd4f817107d 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Catalog/CategoryController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Catalog/CategoryController.php @@ -188,7 +188,7 @@ public function editAction() } $this->loadLayout(); - $this->_setActiveMenu('catalog/categories'); + $this->_setActiveMenu(self::ADMIN_RESOURCE); $this->getLayout()->getBlock('head')->setCanLoadExtJs(true) ->setContainerCssClass('catalog-categories'); diff --git a/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/AttributeController.php b/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/AttributeController.php index b0e6e1f7177..82990d5fcb8 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/AttributeController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/AttributeController.php @@ -62,7 +62,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'), diff --git a/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/SetController.php b/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/SetController.php index 93461396617..6dec05f8161 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/SetController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/SetController.php @@ -36,7 +36,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( @@ -70,7 +70,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')); @@ -183,7 +183,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')); diff --git a/app/code/core/Mage/Adminhtml/controllers/Catalog/ProductController.php b/app/code/core/Mage/Adminhtml/controllers/Catalog/ProductController.php index 4db9d61ce65..9e1a77bcb72 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Catalog/ProductController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Catalog/ProductController.php @@ -217,7 +217,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); @@ -263,7 +263,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')) diff --git a/app/code/core/Mage/Adminhtml/controllers/Catalog/SearchController.php b/app/code/core/Mage/Adminhtml/controllers/Catalog/SearchController.php index a7297b9ea92..088930913b9 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Catalog/SearchController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Catalog/SearchController.php @@ -28,7 +28,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; diff --git a/app/code/core/Mage/Adminhtml/controllers/CatalogController.php b/app/code/core/Mage/Adminhtml/controllers/CatalogController.php index 46324f0c87c..1a67dd655c5 100644 --- a/app/code/core/Mage/Adminhtml/controllers/CatalogController.php +++ b/app/code/core/Mage/Adminhtml/controllers/CatalogController.php @@ -30,7 +30,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')); diff --git a/app/code/core/Mage/Adminhtml/controllers/Checkout/AgreementController.php b/app/code/core/Mage/Adminhtml/controllers/Checkout/AgreementController.php index 0b8ced5ec6a..e69f8921dc5 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Checkout/AgreementController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Checkout/AgreementController.php @@ -145,7 +145,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')) ; diff --git a/app/code/core/Mage/Adminhtml/controllers/Cms/BlockController.php b/app/code/core/Mage/Adminhtml/controllers/Cms/BlockController.php index 8d8e1aee4eb..df63bdb2449 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Cms/BlockController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Cms/BlockController.php @@ -47,7 +47,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')) ; diff --git a/app/code/core/Mage/Adminhtml/controllers/Cms/PageController.php b/app/code/core/Mage/Adminhtml/controllers/Cms/PageController.php index e600d223e9d..93717b3916f 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Cms/PageController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Cms/PageController.php @@ -21,6 +21,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 * @@ -30,7 +38,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')) ; @@ -225,11 +233,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); } } diff --git a/app/code/core/Mage/Adminhtml/controllers/Customer/ConfigController.php b/app/code/core/Mage/Adminhtml/controllers/Customer/ConfigController.php index 61b7cfd27af..c177193c74c 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Customer/ConfigController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Customer/ConfigController.php @@ -30,7 +30,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( diff --git a/app/code/core/Mage/Adminhtml/controllers/Customer/GroupController.php b/app/code/core/Mage/Adminhtml/controllers/Customer/GroupController.php index bd69f787c16..019b6680d2d 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Customer/GroupController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Customer/GroupController.php @@ -57,7 +57,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(); @@ -70,7 +70,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')); diff --git a/app/code/core/Mage/Adminhtml/controllers/Customer/OnlineController.php b/app/code/core/Mage/Adminhtml/controllers/Customer/OnlineController.php index 4886b1dbfce..c742a5d7a58 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Customer/OnlineController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Customer/OnlineController.php @@ -36,7 +36,7 @@ public function indexAction() $this->loadLayout(); - $this->_setActiveMenu('customer/online'); + $this->_setActiveMenu(self::ADMIN_RESOURCE); $this->_addContent($this->getLayout()->createBlock('adminhtml/customer_online', 'customers')); diff --git a/app/code/core/Mage/Adminhtml/controllers/CustomerController.php b/app/code/core/Mage/Adminhtml/controllers/CustomerController.php index ade3ab7923e..7783b8334f6 100644 --- a/app/code/core/Mage/Adminhtml/controllers/CustomerController.php +++ b/app/code/core/Mage/Adminhtml/controllers/CustomerController.php @@ -74,7 +74,7 @@ public function indexAction() /** * Set active menu item */ - $this->_setActiveMenu('customer/manage'); + $this->_setActiveMenu(self::ADMIN_RESOURCE); /** * Append customers block to content @@ -155,7 +155,7 @@ public function editAction() /** * Set active menu item */ - $this->_setActiveMenu('customer/manage'); + $this->_setActiveMenu(self::ADMIN_RESOURCE); $this->renderLayout(); } diff --git a/app/code/core/Mage/Adminhtml/controllers/DashboardController.php b/app/code/core/Mage/Adminhtml/controllers/DashboardController.php index 8ad8231033e..fb216e87517 100644 --- a/app/code/core/Mage/Adminhtml/controllers/DashboardController.php +++ b/app/code/core/Mage/Adminhtml/controllers/DashboardController.php @@ -32,7 +32,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(); } diff --git a/app/code/core/Mage/Adminhtml/controllers/Newsletter/ProblemController.php b/app/code/core/Mage/Adminhtml/controllers/Newsletter/ProblemController.php index 682865a735d..e60bd26c62c 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Newsletter/ProblemController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Newsletter/ProblemController.php @@ -41,7 +41,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')); diff --git a/app/code/core/Mage/Adminhtml/controllers/Newsletter/QueueController.php b/app/code/core/Mage/Adminhtml/controllers/Newsletter/QueueController.php index 696c5ba127d..640ee12b383 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Newsletter/QueueController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Newsletter/QueueController.php @@ -43,7 +43,7 @@ public function indexAction() $this->loadLayout(); - $this->_setActiveMenu('newsletter/queue'); + $this->_setActiveMenu(self::ADMIN_RESOURCE); $this->_addContent( $this->getLayout()->createBlock('adminhtml/newsletter_queue', 'queue') @@ -195,7 +195,7 @@ public function editAction() $this->loadLayout(); - $this->_setActiveMenu('newsletter/queue'); + $this->_setActiveMenu(self::ADMIN_RESOURCE); $this->_addBreadcrumb( Mage::helper('newsletter')->__('Newsletter Queue'), diff --git a/app/code/core/Mage/Adminhtml/controllers/Newsletter/SubscriberController.php b/app/code/core/Mage/Adminhtml/controllers/Newsletter/SubscriberController.php index a4b35f64564..7f0f228778e 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Newsletter/SubscriberController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Newsletter/SubscriberController.php @@ -38,7 +38,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')); diff --git a/app/code/core/Mage/Adminhtml/controllers/Newsletter/TemplateController.php b/app/code/core/Mage/Adminhtml/controllers/Newsletter/TemplateController.php index a5f1bf8d64f..a9cfb1092aa 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Newsletter/TemplateController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Newsletter/TemplateController.php @@ -21,15 +21,10 @@ class Mage_Adminhtml_Newsletter_TemplateController extends Mage_Adminhtml_Controller_Action { /** - * Check is allowed access - * - * @return bool + * ACL resource + * @see Mage_Adminhtml_Controller_Action::_isAllowed() */ - protected function _isAllowed() - { - return Mage::getSingleton('admin/session') - ->isAllowed('newsletter/template'); - } + public const ADMIN_RESOURCE = 'newsletter/template'; /** * Set title of page @@ -54,7 +49,7 @@ public function indexAction() return; } $this->loadLayout(); - $this->_setActiveMenu('newsletter/template'); + $this->_setActiveMenu(self::ADMIN_RESOURCE); $this->_addBreadcrumb(Mage::helper('newsletter')->__('Newsletter Templates'), Mage::helper('newsletter')->__('Newsletter Templates')); $this->_addContent($this->getLayout()->createBlock('adminhtml/newsletter_template', 'template')); $this->renderLayout(); @@ -97,7 +92,7 @@ public function editAction() Mage::register('_current_template', $model); $this->loadLayout(); - $this->_setActiveMenu('newsletter/template'); + $this->_setActiveMenu(self::ADMIN_RESOURCE); if ($model->getId()) { $breadcrumbTitle = Mage::helper('newsletter')->__('Edit Template'); diff --git a/app/code/core/Mage/Adminhtml/controllers/Permissions/BlockController.php b/app/code/core/Mage/Adminhtml/controllers/Permissions/BlockController.php index c9e72766061..81f548cb1e1 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Permissions/BlockController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Permissions/BlockController.php @@ -33,7 +33,7 @@ class Mage_Adminhtml_Permissions_BlockController extends Mage_Adminhtml_Controll protected function _initAction() { $this->loadLayout() - ->_setActiveMenu('system/acl/blocks') + ->_setActiveMenu(self::ADMIN_RESOURCE) ->_addBreadcrumb($this->__('System'), $this->__('System')) ->_addBreadcrumb($this->__('Permissions'), $this->__('Permissions')) ->_addBreadcrumb($this->__('Blocks'), $this->__('Blocks')); diff --git a/app/code/core/Mage/Adminhtml/controllers/Permissions/OrphanedResourceController.php b/app/code/core/Mage/Adminhtml/controllers/Permissions/OrphanedResourceController.php index 7c3d53d8ef5..6a2c4f0203f 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Permissions/OrphanedResourceController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Permissions/OrphanedResourceController.php @@ -28,7 +28,7 @@ class Mage_Adminhtml_Permissions_OrphanedResourceController extends Mage_Adminht protected function _initAction() { $this->loadLayout() - ->_setActiveMenu('system/acl/orphaned_resources') + ->_setActiveMenu(self::ADMIN_RESOURCE) ->_addBreadcrumb($this->__('System'), $this->__('System')) ->_addBreadcrumb($this->__('Permissions'), $this->__('Permissions')) ->_addBreadcrumb($this->__('Orphaned Resources'), $this->__('Orphaned Role Resources')); diff --git a/app/code/core/Mage/Adminhtml/controllers/Permissions/RoleController.php b/app/code/core/Mage/Adminhtml/controllers/Permissions/RoleController.php index e138b788f93..57ec240b2b2 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Permissions/RoleController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Permissions/RoleController.php @@ -46,7 +46,7 @@ public function preDispatch() protected function _initAction() { $this->loadLayout(); - $this->_setActiveMenu('system/acl/roles'); + $this->_setActiveMenu(self::ADMIN_RESOURCE); $this->_addBreadcrumb($this->__('System'), $this->__('System')); $this->_addBreadcrumb($this->__('Permissions'), $this->__('Permissions')); $this->_addBreadcrumb($this->__('Roles'), $this->__('Roles')); diff --git a/app/code/core/Mage/Adminhtml/controllers/Permissions/UserController.php b/app/code/core/Mage/Adminhtml/controllers/Permissions/UserController.php index d20c96b8a21..a3b3ca97d2d 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Permissions/UserController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Permissions/UserController.php @@ -39,7 +39,7 @@ public function preDispatch() protected function _initAction() { $this->loadLayout() - ->_setActiveMenu('system/acl/users') + ->_setActiveMenu(self::ADMIN_RESOURCE) ->_addBreadcrumb($this->__('System'), $this->__('System')) ->_addBreadcrumb($this->__('Permissions'), $this->__('Permissions')) ->_addBreadcrumb($this->__('Users'), $this->__('Users')) diff --git a/app/code/core/Mage/Adminhtml/controllers/Permissions/VariableController.php b/app/code/core/Mage/Adminhtml/controllers/Permissions/VariableController.php index 6daa10ec0d0..9229743bde6 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Permissions/VariableController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Permissions/VariableController.php @@ -33,7 +33,7 @@ class Mage_Adminhtml_Permissions_VariableController extends Mage_Adminhtml_Contr protected function _initAction() { $this->loadLayout() - ->_setActiveMenu('system/acl/variables') + ->_setActiveMenu(self::ADMIN_RESOURCE) ->_addBreadcrumb($this->__('System'), $this->__('System')) ->_addBreadcrumb($this->__('Permissions'), $this->__('Permissions')) ->_addBreadcrumb($this->__('Variables'), $this->__('Variables')); diff --git a/app/code/core/Mage/Adminhtml/controllers/Promo/CatalogController.php b/app/code/core/Mage/Adminhtml/controllers/Promo/CatalogController.php index 39fea5d79ee..32102792b73 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Promo/CatalogController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Promo/CatalogController.php @@ -48,7 +48,7 @@ public function preDispatch() protected function _initAction() { $this->loadLayout() - ->_setActiveMenu('promo/catalog') + ->_setActiveMenu(self::ADMIN_RESOURCE) ->_addBreadcrumb( Mage::helper('catalogrule')->__('Promotions'), Mage::helper('catalogrule')->__('Promotions') diff --git a/app/code/core/Mage/Adminhtml/controllers/Promo/QuoteController.php b/app/code/core/Mage/Adminhtml/controllers/Promo/QuoteController.php index c6d8be0eaa4..b458c74ed58 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Promo/QuoteController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Promo/QuoteController.php @@ -55,7 +55,7 @@ protected function _initRule() protected function _initAction() { $this->loadLayout() - ->_setActiveMenu('promo/quote') + ->_setActiveMenu(self::ADMIN_RESOURCE) ->_addBreadcrumb(Mage::helper('salesrule')->__('Promotions'), Mage::helper('salesrule')->__('Promotions')) ; return $this; diff --git a/app/code/core/Mage/Adminhtml/controllers/PromoController.php b/app/code/core/Mage/Adminhtml/controllers/PromoController.php index 67f63d56eaf..5d0928a6e7f 100644 --- a/app/code/core/Mage/Adminhtml/controllers/PromoController.php +++ b/app/code/core/Mage/Adminhtml/controllers/PromoController.php @@ -30,7 +30,7 @@ class Mage_Adminhtml_PromoController extends Mage_Adminhtml_Controller_Action public function indexAction() { $this->loadLayout(); - $this->_setActiveMenu('promo'); + $this->_setActiveMenu(self::ADMIN_RESOURCE); $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Promotions'), Mage::helper('adminhtml')->__('Promo')); $this->renderLayout(); } diff --git a/app/code/core/Mage/Adminhtml/controllers/Sales/Order/CreditmemoController.php b/app/code/core/Mage/Adminhtml/controllers/Sales/Order/CreditmemoController.php index fb24a661c89..2dbe672d71a 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Sales/Order/CreditmemoController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Sales/Order/CreditmemoController.php @@ -31,8 +31,7 @@ protected function _getItemData() $data = Mage::getSingleton('adminhtml/session')->getFormData(true); } - $qtys = $data['items'] ?? []; - return $qtys; + return $data['items'] ?? []; } /** @@ -235,16 +234,16 @@ public function newAction() public function updateQtyAction() { try { - $creditmemo = $this->_initCreditmemo(true); + $this->_initCreditmemo(true); $this->loadLayout(); $response = $this->getLayout()->getBlock('order_items')->toHtml(); - } catch (Mage_Core_Exception $e) { + } catch (Mage_Core_Exception $exception) { $response = [ 'error' => true, - 'message' => $e->getMessage() + 'message' => $exception->getMessage() ]; $response = Mage::helper('core')->jsonEncode($response); - } catch (Exception $e) { + } catch (Exception $exception) { $response = [ 'error' => true, 'message' => $this->__('Cannot update the item\'s quantity.') @@ -309,11 +308,11 @@ public function saveAction() $this->_forward('noRoute'); return; } - } catch (Mage_Core_Exception $e) { - $this->_getSession()->addError($e->getMessage()); + } catch (Mage_Core_Exception $exception) { + $this->_getSession()->addError($exception->getMessage()); Mage::getSingleton('adminhtml/session')->setFormData($data); - } catch (Exception $e) { - Mage::logException($e); + } catch (Exception $exception) { + Mage::logException($exception); $this->_getSession()->addError($this->__('Cannot save the credit memo.')); } $this->_redirect('*/*/new', ['_current' => true]); @@ -330,9 +329,9 @@ public function cancelAction() $creditmemo->cancel(); $this->_saveCreditmemo($creditmemo); $this->_getSession()->addSuccess($this->__('The credit memo has been canceled.')); - } catch (Mage_Core_Exception $e) { - $this->_getSession()->addError($e->getMessage()); - } catch (Exception $e) { + } catch (Mage_Core_Exception $exception) { + $this->_getSession()->addError($exception->getMessage()); + } catch (Exception $exception) { $this->_getSession()->addError($this->__('Unable to cancel the credit memo.')); } $this->_redirect('*/*/view', ['creditmemo_id' => $creditmemo->getId()]); @@ -352,9 +351,9 @@ public function voidAction() $creditmemo->void(); $this->_saveCreditmemo($creditmemo); $this->_getSession()->addSuccess($this->__('The credit memo has been voided.')); - } catch (Mage_Core_Exception $e) { - $this->_getSession()->addError($e->getMessage()); - } catch (Exception $e) { + } catch (Mage_Core_Exception $exception) { + $this->_getSession()->addError($exception->getMessage()); + } catch (Exception $exception) { $this->_getSession()->addError($this->__('Unable to void the credit memo.')); } $this->_redirect('*/*/view', ['creditmemo_id' => $creditmemo->getId()]); @@ -388,13 +387,13 @@ public function addCommentAction() $this->loadLayout(); $response = $this->getLayout()->getBlock('creditmemo_comments')->toHtml(); - } catch (Mage_Core_Exception $e) { + } catch (Mage_Core_Exception $exception) { $response = [ 'error' => true, - 'message' => $e->getMessage() + 'message' => $exception->getMessage() ]; $response = Mage::helper('core')->jsonEncode($response); - } catch (Exception $e) { + } catch (Exception $exception) { $response = [ 'error' => true, 'message' => $this->__('Cannot add new comment.') diff --git a/app/code/core/Mage/Adminhtml/controllers/Sales/Order/StatusController.php b/app/code/core/Mage/Adminhtml/controllers/Sales/Order/StatusController.php index 0e48b09e97b..18591f6e6bf 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Sales/Order/StatusController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Sales/Order/StatusController.php @@ -57,7 +57,7 @@ protected function _initStatus() public function indexAction() { $this->_title($this->__('Sales'))->_title($this->__('Order Statuses')); - $this->loadLayout()->_setActiveMenu('system/order_statuses')->renderLayout(); + $this->loadLayout()->_setActiveMenu(self::ADMIN_RESOURCE)->renderLayout(); } /** @@ -73,7 +73,7 @@ public function newAction() } $this->_title($this->__('Sales'))->_title($this->__('Create New Order Status')); $this->loadLayout() - ->_setActiveMenu('system/order_statuses') + ->_setActiveMenu(self::ADMIN_RESOURCE) ->renderLayout(); } @@ -87,7 +87,7 @@ public function editAction() Mage::register('current_status', $status); $this->_title($this->__('Sales'))->_title($this->__('Edit Order Status')); $this->loadLayout() - ->_setActiveMenu('system/order_statuses') + ->_setActiveMenu(self::ADMIN_RESOURCE) ->renderLayout(); } else { $this->_getSession()->addError( @@ -163,7 +163,7 @@ public function assignAction() { $this->_title($this->__('Sales'))->_title($this->__('Assign Order Status to State')); $this->loadLayout() - ->_setActiveMenu('system/order_statuses') + ->_setActiveMenu(self::ADMIN_RESOURCE) ->renderLayout(); } diff --git a/app/code/core/Mage/Adminhtml/controllers/Sales/Recurring/ProfileController.php b/app/code/core/Mage/Adminhtml/controllers/Sales/Recurring/ProfileController.php index e453c33ce06..cd40e9ab218 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Sales/Recurring/ProfileController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Sales/Recurring/ProfileController.php @@ -38,7 +38,7 @@ public function indexAction() { $this->_title(Mage::helper('sales')->__('Sales'))->_title(Mage::helper('sales')->__('Recurring Profiles')) ->loadLayout() - ->_setActiveMenu('sales/recurring_profile') + ->_setActiveMenu(self::ADMIN_RESOURCE) ->renderLayout(); return $this; } @@ -52,7 +52,7 @@ public function viewAction() $this->_title(Mage::helper('sales')->__('Sales'))->_title(Mage::helper('sales')->__('Recurring Profiles')); $profile = $this->_initProfile(); $this->loadLayout() - ->_setActiveMenu('sales/recurring_profile') + ->_setActiveMenu(self::ADMIN_RESOURCE) ->_title(Mage::helper('sales')->__('Profile #%s', $profile->getReferenceId())) ->renderLayout() ; diff --git a/app/code/core/Mage/Adminhtml/controllers/SalesController.php b/app/code/core/Mage/Adminhtml/controllers/SalesController.php index 6665262703c..d1ad13e56c5 100644 --- a/app/code/core/Mage/Adminhtml/controllers/SalesController.php +++ b/app/code/core/Mage/Adminhtml/controllers/SalesController.php @@ -39,7 +39,7 @@ protected function _construct() public function indexAction() { $this->loadLayout(); - $this->_setActiveMenu('sales'); + $this->_setActiveMenu(self::ADMIN_RESOURCE); $block = $this->getLayout()->createBlock('adminhtml/sales', 'sales'); $this->_addContent($block); diff --git a/app/code/core/Mage/Adminhtml/controllers/SitemapController.php b/app/code/core/Mage/Adminhtml/controllers/SitemapController.php index 4732ae284c5..c20d3d20345 100644 --- a/app/code/core/Mage/Adminhtml/controllers/SitemapController.php +++ b/app/code/core/Mage/Adminhtml/controllers/SitemapController.php @@ -52,7 +52,7 @@ protected function _initAction() { // load layout, set active menu and breadcrumbs $this->loadLayout() - ->_setActiveMenu('catalog/sitemap') + ->_setActiveMenu(self::ADMIN_RESOURCE) ->_addBreadcrumb( Mage::helper('catalog')->__('Catalog'), Mage::helper('catalog')->__('Catalog') diff --git a/app/code/core/Mage/Adminhtml/controllers/System/AccountController.php b/app/code/core/Mage/Adminhtml/controllers/System/AccountController.php index 5f94f81875a..d5d19a6bdf4 100644 --- a/app/code/core/Mage/Adminhtml/controllers/System/AccountController.php +++ b/app/code/core/Mage/Adminhtml/controllers/System/AccountController.php @@ -32,7 +32,7 @@ public function indexAction() $this->_title($this->__('System'))->_title($this->__('My Account')); $this->loadLayout(); - $this->_setActiveMenu('system/myaccount'); + $this->_setActiveMenu(self::ADMIN_RESOURCE); $this->_addContent($this->getLayout()->createBlock('adminhtml/system_account_edit')); $this->renderLayout(); } diff --git a/app/code/core/Mage/Adminhtml/controllers/System/CacheController.php b/app/code/core/Mage/Adminhtml/controllers/System/CacheController.php index cc2a1fad09a..83c15396a1f 100644 --- a/app/code/core/Mage/Adminhtml/controllers/System/CacheController.php +++ b/app/code/core/Mage/Adminhtml/controllers/System/CacheController.php @@ -45,7 +45,7 @@ public function indexAction() /** @var Mage_Adminhtml_Block_System_Cache_Edit $block */ $block = $this->getLayout()->createBlock('adminhtml/system_cache_edit'); $this->loadLayout() - ->_setActiveMenu('system/cache') + ->_setActiveMenu(self::ADMIN_RESOURCE) ->_addContent($block->initForm()) ->renderLayout(); } diff --git a/app/code/core/Mage/Adminhtml/controllers/System/ConfigController.php b/app/code/core/Mage/Adminhtml/controllers/System/ConfigController.php index 581bb5ef115..fc50ad7ee4f 100644 --- a/app/code/core/Mage/Adminhtml/controllers/System/ConfigController.php +++ b/app/code/core/Mage/Adminhtml/controllers/System/ConfigController.php @@ -87,7 +87,7 @@ public function editAction() $this->loadLayout(); - $this->_setActiveMenu('system/config'); + $this->_setActiveMenu(self::ADMIN_RESOURCE); $this->getLayout()->getBlock('menu')->setAdditionalCacheKeyInfo([$current]); $this->_addBreadcrumb( diff --git a/app/code/core/Mage/Adminhtml/controllers/System/CurrencyController.php b/app/code/core/Mage/Adminhtml/controllers/System/CurrencyController.php index b8e08da93b4..ba2e3d45d0f 100644 --- a/app/code/core/Mage/Adminhtml/controllers/System/CurrencyController.php +++ b/app/code/core/Mage/Adminhtml/controllers/System/CurrencyController.php @@ -50,7 +50,7 @@ public function indexAction() $this->_title($this->__('System'))->_title($this->__('Manage Currency Rates')); $this->loadLayout(); - $this->_setActiveMenu('system/currency/rates'); + $this->_setActiveMenu(self::ADMIN_RESOURCE); $this->_addContent($this->getLayout()->createBlock('adminhtml/system_currency')); $this->renderLayout(); } diff --git a/app/code/core/Mage/Adminhtml/controllers/System/DesignController.php b/app/code/core/Mage/Adminhtml/controllers/System/DesignController.php index 5e38ff397d0..83a87e3a964 100644 --- a/app/code/core/Mage/Adminhtml/controllers/System/DesignController.php +++ b/app/code/core/Mage/Adminhtml/controllers/System/DesignController.php @@ -41,7 +41,7 @@ public function indexAction() $this->_title($this->__('System'))->_title($this->__('Design')); $this->loadLayout(); - $this->_setActiveMenu('system/design'); + $this->_setActiveMenu(self::ADMIN_RESOURCE); $this->_addContent($this->getLayout()->createBlock('adminhtml/system_design')); $this->renderLayout(); } @@ -61,7 +61,7 @@ public function editAction() $this->_title($this->__('System'))->_title($this->__('Design')); $this->loadLayout(); - $this->_setActiveMenu('system/design'); + $this->_setActiveMenu(self::ADMIN_RESOURCE); $this->getLayout()->getBlock('head')->setCanLoadExtJs(true); $id = (int) $this->getRequest()->getParam('id'); diff --git a/app/code/core/Mage/Adminhtml/controllers/System/Email/TemplateController.php b/app/code/core/Mage/Adminhtml/controllers/System/Email/TemplateController.php index b3b25e3ba84..2a9ed292b37 100644 --- a/app/code/core/Mage/Adminhtml/controllers/System/Email/TemplateController.php +++ b/app/code/core/Mage/Adminhtml/controllers/System/Email/TemplateController.php @@ -40,7 +40,7 @@ public function indexAction() } $this->loadLayout(); - $this->_setActiveMenu('system/email_template'); + $this->_setActiveMenu(self::ADMIN_RESOURCE); $this->_addBreadcrumb( Mage::helper('adminhtml')->__('Transactional Emails'), Mage::helper('adminhtml')->__('Transactional Emails') @@ -75,7 +75,7 @@ public function editAction() { $this->loadLayout(); $template = $this->_initTemplate('id'); - $this->_setActiveMenu('system/email_template'); + $this->_setActiveMenu(self::ADMIN_RESOURCE); $this->_addBreadcrumb( Mage::helper('adminhtml')->__('Transactional Emails'), Mage::helper('adminhtml')->__('Transactional Emails'), diff --git a/app/code/core/Mage/Adminhtml/controllers/System/StoreController.php b/app/code/core/Mage/Adminhtml/controllers/System/StoreController.php index 08a67c2a4a9..ee9e982f766 100644 --- a/app/code/core/Mage/Adminhtml/controllers/System/StoreController.php +++ b/app/code/core/Mage/Adminhtml/controllers/System/StoreController.php @@ -47,7 +47,7 @@ protected function _initAction() { // load layout, set active menu and breadcrumbs $this->loadLayout() - ->_setActiveMenu('system/store') + ->_setActiveMenu(self::ADMIN_RESOURCE) ->_addBreadcrumb(Mage::helper('adminhtml')->__('System'), Mage::helper('adminhtml')->__('System')) ->_addBreadcrumb(Mage::helper('adminhtml')->__('Manage Stores'), Mage::helper('adminhtml')->__('Manage Stores')) ; diff --git a/app/code/core/Mage/Adminhtml/controllers/System/VariableController.php b/app/code/core/Mage/Adminhtml/controllers/System/VariableController.php index 53d77e9160d..0559776d956 100644 --- a/app/code/core/Mage/Adminhtml/controllers/System/VariableController.php +++ b/app/code/core/Mage/Adminhtml/controllers/System/VariableController.php @@ -35,7 +35,7 @@ class Mage_Adminhtml_System_VariableController extends Mage_Adminhtml_Controller protected function _initLayout() { $this->loadLayout() - ->_setActiveMenu('system/variable') + ->_setActiveMenu(self::ADMIN_RESOURCE) ->_addBreadcrumb(Mage::helper('adminhtml')->__('Custom Variables'), Mage::helper('adminhtml')->__('Custom Variables')); return $this; } diff --git a/app/code/core/Mage/Adminhtml/controllers/Tax/Class/CustomerController.php b/app/code/core/Mage/Adminhtml/controllers/Tax/Class/CustomerController.php index b42a16e2573..1e408c4bd85 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Tax/Class/CustomerController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Tax/Class/CustomerController.php @@ -157,7 +157,7 @@ public function deleteAction() protected function _initAction() { $this->loadLayout() - ->_setActiveMenu('sales/tax/classes_customer') + ->_setActiveMenu(self::ADMIN_RESOURCE) ->_addBreadcrumb(Mage::helper('tax')->__('Sales'), Mage::helper('tax')->__('Sales')) ->_addBreadcrumb(Mage::helper('tax')->__('Tax'), Mage::helper('tax')->__('Tax')) ->_addBreadcrumb(Mage::helper('tax')->__('Manage Customer Tax Classes'), Mage::helper('tax')->__('Manage Customer Tax Classes')) diff --git a/app/code/core/Mage/Adminhtml/controllers/Tax/Class/ProductController.php b/app/code/core/Mage/Adminhtml/controllers/Tax/Class/ProductController.php index a190b031353..60e768b2ae6 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Tax/Class/ProductController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Tax/Class/ProductController.php @@ -156,7 +156,7 @@ public function deleteAction() protected function _initAction() { $this->loadLayout() - ->_setActiveMenu('sales/tax/classes_product') + ->_setActiveMenu(self::ADMIN_RESOURCE) ->_addBreadcrumb(Mage::helper('tax')->__('Sales'), Mage::helper('tax')->__('Sales')) ->_addBreadcrumb(Mage::helper('tax')->__('Tax'), Mage::helper('tax')->__('Tax')) ->_addBreadcrumb(Mage::helper('tax')->__('Manage Product Tax Classes'), Mage::helper('tax')->__('Manage Product Tax Classes')) diff --git a/app/code/core/Mage/Adminhtml/controllers/Tax/RuleController.php b/app/code/core/Mage/Adminhtml/controllers/Tax/RuleController.php index 208e7f832fa..05e89f52611 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Tax/RuleController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Tax/RuleController.php @@ -206,7 +206,7 @@ public function deleteAction() protected function _initAction() { $this->loadLayout() - ->_setActiveMenu('sales/tax/rules') + ->_setActiveMenu(self::ADMIN_RESOURCE) ->_addBreadcrumb(Mage::helper('tax')->__('Tax'), Mage::helper('tax')->__('Tax')) ->_addBreadcrumb(Mage::helper('tax')->__('Tax Rules'), Mage::helper('tax')->__('Tax Rules')) ; diff --git a/app/code/core/Mage/Adminhtml/controllers/UrlrewriteController.php b/app/code/core/Mage/Adminhtml/controllers/UrlrewriteController.php index 5f964ae5091..ed35934443e 100644 --- a/app/code/core/Mage/Adminhtml/controllers/UrlrewriteController.php +++ b/app/code/core/Mage/Adminhtml/controllers/UrlrewriteController.php @@ -63,7 +63,7 @@ public function indexAction() { $this->_initRegistry(); $this->loadLayout(); - $this->_setActiveMenu('catalog/urlrewrite'); + $this->_setActiveMenu(self::ADMIN_RESOURCE); $this->_addContent( $this->getLayout()->createBlock('adminhtml/urlrewrite') ); @@ -81,7 +81,7 @@ public function editAction() $this->_title($this->__('URL Rewrite')); $this->loadLayout(); - $this->_setActiveMenu('catalog/urlrewrite'); + $this->_setActiveMenu(self::ADMIN_RESOURCE); $this->_addContent($this->getLayout()->createBlock('adminhtml/urlrewrite_edit')); $this->getLayout()->getBlock('head')->setCanLoadExtJs(true); $this->renderLayout(); diff --git a/app/code/core/Mage/CurrencySymbol/controllers/Adminhtml/System/CurrencysymbolController.php b/app/code/core/Mage/CurrencySymbol/controllers/Adminhtml/System/CurrencysymbolController.php index fd65fb08bc1..835aeeec2e4 100644 --- a/app/code/core/Mage/CurrencySymbol/controllers/Adminhtml/System/CurrencysymbolController.php +++ b/app/code/core/Mage/CurrencySymbol/controllers/Adminhtml/System/CurrencysymbolController.php @@ -34,7 +34,7 @@ public function indexAction() { // set active menu and breadcrumbs $this->loadLayout() - ->_setActiveMenu('system/currency/symbols') + ->_setActiveMenu(self::ADMIN_RESOURCE) ->_addBreadcrumb( Mage::helper('currencysymbol')->__('System'), Mage::helper('currencysymbol')->__('System') diff --git a/app/code/core/Mage/ImportExport/controllers/Adminhtml/ExportController.php b/app/code/core/Mage/ImportExport/controllers/Adminhtml/ExportController.php index a3e4fe2fb70..1fa10e4e0c0 100644 --- a/app/code/core/Mage/ImportExport/controllers/Adminhtml/ExportController.php +++ b/app/code/core/Mage/ImportExport/controllers/Adminhtml/ExportController.php @@ -45,7 +45,7 @@ protected function _initAction() { $this->_title($this->__('Import/Export')) ->loadLayout() - ->_setActiveMenu('system/convert/export'); + ->_setActiveMenu(self::ADMIN_RESOURCE); return $this; } diff --git a/app/code/core/Mage/ImportExport/controllers/Adminhtml/ImportController.php b/app/code/core/Mage/ImportExport/controllers/Adminhtml/ImportController.php index 099cfff7de6..f06574ad05e 100644 --- a/app/code/core/Mage/ImportExport/controllers/Adminhtml/ImportController.php +++ b/app/code/core/Mage/ImportExport/controllers/Adminhtml/ImportController.php @@ -45,7 +45,7 @@ protected function _initAction() { $this->_title($this->__('Import/Export')) ->loadLayout() - ->_setActiveMenu('system/convert/import'); + ->_setActiveMenu(self::ADMIN_RESOURCE); return $this; } diff --git a/app/code/core/Mage/Index/controllers/Adminhtml/ProcessController.php b/app/code/core/Mage/Index/controllers/Adminhtml/ProcessController.php index 9460b9770dd..28b645e2c40 100644 --- a/app/code/core/Mage/Index/controllers/Adminhtml/ProcessController.php +++ b/app/code/core/Mage/Index/controllers/Adminhtml/ProcessController.php @@ -51,7 +51,7 @@ public function listAction() $this->_title($this->__('System'))->_title($this->__('Index Management')); $this->loadLayout(); - $this->_setActiveMenu('system/index'); + $this->_setActiveMenu(self::ADMIN_RESOURCE); $this->renderLayout(); } @@ -71,7 +71,7 @@ public function editAction() Mage::register('current_index_process', $process); $this->loadLayout(); - $this->_setActiveMenu('system/index'); + $this->_setActiveMenu(self::ADMIN_RESOURCE); $this->renderLayout(); } else { $this->_getSession()->addError( diff --git a/app/code/core/Mage/Oauth/controllers/Adminhtml/Oauth/Admin/TokenController.php b/app/code/core/Mage/Oauth/controllers/Adminhtml/Oauth/Admin/TokenController.php index a51024ded1c..d3d1d51342e 100644 --- a/app/code/core/Mage/Oauth/controllers/Adminhtml/Oauth/Admin/TokenController.php +++ b/app/code/core/Mage/Oauth/controllers/Adminhtml/Oauth/Admin/TokenController.php @@ -23,6 +23,12 @@ */ class Mage_Oauth_Adminhtml_Oauth_Admin_TokenController extends Mage_Adminhtml_Controller_Action { + /** + * ACL resource + * @see Mage_Adminhtml_Controller_Action::_isAllowed() + */ + public const ADMIN_RESOURCE = 'system/api/oauth_admin_token'; + /** * Init titles * @@ -43,7 +49,7 @@ public function preDispatch() public function indexAction() { $this->loadLayout(); - $this->_setActiveMenu('system/api/oauth_admin_token'); + $this->_setActiveMenu(self::ADMIN_RESOURCE); $this->renderLayout(); } @@ -148,14 +154,4 @@ public function deleteAction() } $this->_redirect('*/*/index'); } - - /** - * @inheritDoc - */ - protected function _isAllowed() - { - /** @var Mage_Admin_Model_Session $session */ - $session = Mage::getSingleton('admin/session'); - return $session->isAllowed('system/api/oauth_admin_token'); - } } diff --git a/app/code/core/Mage/Oauth/controllers/Adminhtml/Oauth/AuthorizedTokensController.php b/app/code/core/Mage/Oauth/controllers/Adminhtml/Oauth/AuthorizedTokensController.php index 53c8e126a1b..92ac3285cad 100644 --- a/app/code/core/Mage/Oauth/controllers/Adminhtml/Oauth/AuthorizedTokensController.php +++ b/app/code/core/Mage/Oauth/controllers/Adminhtml/Oauth/AuthorizedTokensController.php @@ -21,6 +21,12 @@ */ class Mage_Oauth_Adminhtml_Oauth_AuthorizedTokensController extends Mage_Adminhtml_Controller_Action { + /** + * ACL resource + * @see Mage_Adminhtml_Controller_Action::_isAllowed() + */ + public const ADMIN_RESOURCE = 'system/api/oauth_authorized_tokens'; + /** * Init titles * @@ -41,7 +47,7 @@ public function preDispatch() public function indexAction() { $this->loadLayout(); - $this->_setActiveMenu('system/api/oauth_authorized_tokens'); + $this->_setActiveMenu(self::ADMIN_RESOURCE); $this->renderLayout(); } @@ -143,16 +149,6 @@ public function deleteAction() $this->_redirect('*/*/index'); } - /** - * @inheritDoc - */ - protected function _isAllowed() - { - /** @var Mage_Admin_Model_Session $session */ - $session = Mage::getSingleton('admin/session'); - return $session->isAllowed('system/api/oauth_authorized_tokens'); - } - /** * Send email notification to user about token status change * diff --git a/app/code/core/Mage/Oauth/controllers/Adminhtml/Oauth/ConsumerController.php b/app/code/core/Mage/Oauth/controllers/Adminhtml/Oauth/ConsumerController.php index 0cb65932db4..3b8569492f9 100644 --- a/app/code/core/Mage/Oauth/controllers/Adminhtml/Oauth/ConsumerController.php +++ b/app/code/core/Mage/Oauth/controllers/Adminhtml/Oauth/ConsumerController.php @@ -21,6 +21,12 @@ */ class Mage_Oauth_Adminhtml_Oauth_ConsumerController extends Mage_Adminhtml_Controller_Action { + /** + * ACL resource + * @see Mage_Adminhtml_Controller_Action::_isAllowed() + */ + public const ADMIN_RESOURCE = 'system/api/oauth_consumer'; + /** * Unset unused data from request * Skip getting "key" and "secret" because its generated from server side only @@ -58,7 +64,7 @@ public function preDispatch() public function indexAction() { $this->loadLayout(); - $this->_setActiveMenu('system/api/oauth_consumer'); + $this->_setActiveMenu(self::ADMIN_RESOURCE); $this->renderLayout(); } @@ -94,7 +100,7 @@ public function newAction() Mage::register('current_consumer', $model); $this->loadLayout(); - $this->_setActiveMenu('system/api/oauth_consumer'); + $this->_setActiveMenu(self::ADMIN_RESOURCE); $this->renderLayout(); } @@ -125,7 +131,7 @@ public function editAction() Mage::register('current_consumer', $model); $this->loadLayout(); - $this->_setActiveMenu('system/api/oauth_consumer'); + $this->_setActiveMenu(self::ADMIN_RESOURCE); $this->renderLayout(); } @@ -242,7 +248,7 @@ protected function _isAllowed() } /** @var Mage_Admin_Model_Session $session */ $session = Mage::getSingleton('admin/session'); - return $session->isAllowed('system/api/oauth_consumer' . $action); + return $session->isAllowed(self::ADMIN_RESOURCE . $action); } /** @@ -258,7 +264,7 @@ protected function _getFormData() /** * Set form data * - * @param array $data + * @param array|null $data * @return $this */ protected function _setFormData($data) diff --git a/app/code/core/Mage/Widget/Model/Widget/Instance.php b/app/code/core/Mage/Widget/Model/Widget/Instance.php index 6d84d15e256..f97f2a2a0bb 100644 --- a/app/code/core/Mage/Widget/Model/Widget/Instance.php +++ b/app/code/core/Mage/Widget/Model/Widget/Instance.php @@ -26,11 +26,11 @@ * @method array getPageGroups() * @method $this setPageGroups(array $value) * @method $this setStoreIds(string $value) - * @method string getTitle() - * @method $this setTitle(string $value) - * @method $this setWidgetParameters(string $value) * @method int getSortOrder() * @method $this setSortOrder(int $value) + * @method string getTitle() + * @method $this setTitle(string $value) + * @method $this setWidgetParameters(array $value) */ class Mage_Widget_Model_Widget_Instance extends Mage_Core_Model_Abstract { diff --git a/app/code/core/Mage/Widget/controllers/Adminhtml/Widget/InstanceController.php b/app/code/core/Mage/Widget/controllers/Adminhtml/Widget/InstanceController.php index bf59653d732..bf7607fcaee 100644 --- a/app/code/core/Mage/Widget/controllers/Adminhtml/Widget/InstanceController.php +++ b/app/code/core/Mage/Widget/controllers/Adminhtml/Widget/InstanceController.php @@ -45,7 +45,7 @@ protected function _getSession() protected function _initAction() { $this->loadLayout() - ->_setActiveMenu('cms/widget_instance') + ->_setActiveMenu(self::ADMIN_RESOURCE) ->_addBreadcrumb( Mage::helper('widget')->__('CMS'), Mage::helper('widget')->__('CMS') diff --git a/lib/Varien/Object.php b/lib/Varien/Object.php index 0e830507575..e0bdaa559d2 100644 --- a/lib/Varien/Object.php +++ b/lib/Varien/Object.php @@ -51,7 +51,7 @@ class Varien_Object implements ArrayAccess /** * Object delete flag * - * @var boolean + * @var bool */ protected $_isDeleted = false; @@ -95,6 +95,9 @@ public function __construct() $this->_construct(); } + /** + * @return void + */ protected function _addFullNames() { if (empty($this->_syncFieldsMap)) { @@ -141,8 +144,8 @@ protected function _construct() /** * Set _isDeleted flag value (if $isDeleted param is defined) and return current flag value * - * @param boolean $isDeleted - * @return boolean + * @param bool $isDeleted + * @return bool */ public function isDeleted($isDeleted = null) { @@ -436,7 +439,7 @@ public function getDataSetDefault($key, $default) * Otherwise checks if the specified attribute is set. * * @param string $key - * @return boolean + * @return bool */ public function hasData($key = '') { @@ -611,30 +614,19 @@ public function __call($method, $args) { switch (substr($method, 0, 3)) { case 'get': - //Varien_Profiler::start('GETTER: '.get_class($this).'::'.$method); $key = $this->_underscore(substr($method, 3)); - $data = $this->getData($key, $args[0] ?? null); - //Varien_Profiler::stop('GETTER: '.get_class($this).'::'.$method); - return $data; + return $this->getData($key, $args[0] ?? null); case 'set': - //Varien_Profiler::start('SETTER: '.get_class($this).'::'.$method); $key = $this->_underscore(substr($method, 3)); - $result = $this->setData($key, $args[0] ?? null); - //Varien_Profiler::stop('SETTER: '.get_class($this).'::'.$method); - return $result; + return $this->setData($key, $args[0] ?? null); case 'uns': - //Varien_Profiler::start('UNS: '.get_class($this).'::'.$method); $key = $this->_underscore(substr($method, 3)); - $result = $this->unsetData($key); - //Varien_Profiler::stop('UNS: '.get_class($this).'::'.$method); - return $result; + return $this->unsetData($key); case 'has': - //Varien_Profiler::start('HAS: '.get_class($this).'::'.$method); $key = $this->_underscore(substr($method, 3)); - //Varien_Profiler::stop('HAS: '.get_class($this).'::'.$method); return isset($this->_data[$key]); } throw new Varien_Exception( @@ -669,7 +661,7 @@ public function __set($var, $value) /** * checks whether the object is empty * - * @return boolean + * @return bool */ public function isEmpty() { @@ -736,7 +728,7 @@ public function serialize($attributes = [], $valueSeparator = '=', $fieldSeparat /** * Clears data changes status * - * @param boolean $value + * @param bool $value * @return $this */ public function setDataChanges($value) @@ -824,7 +816,7 @@ public function offsetGet($offset) /** * @param string $field - * @return boolean + * @return bool */ public function isDirty($field = null) { @@ -839,7 +831,7 @@ public function isDirty($field = null) /** * @param string $field - * @param boolean $flag + * @param bool $flag * @return $this */ public function flagDirty($field, $flag = true) From 9b51cb46790911b50e7e1daeb09dfb9aceaf68f7 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Sun, 16 Mar 2025 01:30:28 +0100 Subject: [PATCH 2/2] phpstan --- .phpstan.dist.baseline.neon | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.phpstan.dist.baseline.neon b/.phpstan.dist.baseline.neon index dd709b49d76..3c0a6a7a1c9 100644 --- a/.phpstan.dist.baseline.neon +++ b/.phpstan.dist.baseline.neon @@ -4716,12 +4716,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