From 7fec10a1d6238d8e0058f9907535d98898b7f3d0 Mon Sep 17 00:00:00 2001 From: mage2-team <mage2-team@magento.com> Date: Wed, 1 Aug 2012 22:21:10 -0700 Subject: [PATCH] Update as of 8/1/2012 * Refactored ACL for the backend * ACL resources * Strict configuration format, validated by XSD schema * ACL configuration relocation from `app/code/<pool>/<namespace>/<module>/etc/adminhtml.xml` to `app/code/<pool>/<namespace>/<module>/etc/adminhtml/acl.xml` * Renamed ACL resource identifiers according to the format `<namespace>_<module>::<resource>` throughout the system * Backend menu configuration requires to specify ACL resource identifier in the new format * Explicit declaration of ACL resources in `app/code/<pool>/<namespace>/<module>/etc/system.xml` instead of implicit relation by XPath * Migration tool `dev/tools/migration/acl.php` to convert ACL configuration from 1.x to 2.x * Declaration of ACL resource/role/rule loaders through the area configuration * Module `Mage_Backend` declares loader for ACL resources in backend area * Module `Mage_User` declares loaders for ACL roles and rules (relations between roles and resources) in backend area * Implemented integrity and legacy tests for ACL * Fixed issues: * Losing qty and visibility information when importing products * Impossibility to reload captcha on backend * Temporary excluded from execution integration test `Mage_Review_Model_Resource_Review_Product_CollectionTest::testGetResultingIds()` and corresponding fixture script, which cause occasional `segmentation fault` (exit code 139) * Refactored methods with high cyclomatic complexity: * `Mage_Adminhtml_Block_System_Store_Edit_Form::_prepareForm()` * `Mage_Adminhtml_Block_System_Config_Form::initForm()` * `Mage_Adminhtml_Block_System_Config_Form::initFields()` * GitHub requests: * [#32](https://github.com/magento/magento2/pull/32) -- fixed declaration of localization CSV files * [#35](https://github.com/magento/magento2/issues/35) -- removed non-used `Mage_Core_Block_Flush` block * [#41](https://github.com/magento/magento2/pull/41) -- implemented ability to extends `app/etc/local.xml` by specifying additional config file via `MAGE_LOCAL_CONFIG` environment variable --- CHANGELOG.markdown | 27 + .../etc/{adminhtml.xml => adminhtml/acl.xml} | 22 +- .../Phoenix/Moneybookers/etc/system.xml | 1 + app/code/core/Mage/Admin/Model/Config.php | 215 ----- .../core/Mage/Admin/Model/Resource/Acl.php | 171 ---- .../Mage/AdminNotification/etc/adminhtml.xml | 63 -- .../etc/adminhtml/acl.xml} | 28 +- .../AdminNotification/etc/adminhtml/menu.xml | 2 +- .../Adminhtml/Block/Cache/Notifications.php | 2 +- .../Catalog/Product/Edit/Tab/Attributes.php | 2 +- .../Block/Catalog/Product/Edit/Tabs.php | 4 +- .../Adminhtml/Block/Catalog/Product/Grid.php | 2 +- .../core/Mage/Adminhtml/Block/Cms/Page.php | 8 +- .../Mage/Adminhtml/Block/Cms/Page/Edit.php | 10 +- .../Block/Cms/Page/Edit/Tab/Content.php | 8 +- .../Block/Cms/Page/Edit/Tab/Design.php | 8 +- .../Block/Cms/Page/Edit/Tab/Main.php | 8 +- .../Block/Cms/Page/Edit/Tab/Meta.php | 8 +- .../Mage/Adminhtml/Block/Customer/Edit.php | 2 +- .../Adminhtml/Block/Customer/Edit/Tabs.php | 8 +- .../Adminhtml/Block/Customer/Online/Grid.php | 2 +- .../Adminhtml/Block/Notification/Survey.php | 3 +- .../Adminhtml/Block/Notification/Window.php | 2 +- .../Adminhtml/Block/Sales/Creditmemo/Grid.php | 4 +- .../Adminhtml/Block/Sales/Invoice/Grid.php | 4 +- .../Adminhtml/Block/Sales/Items/Abstract.php | 2 +- .../core/Mage/Adminhtml/Block/Sales/Order.php | 2 +- .../Block/Sales/Order/Creditmemo/View.php | 8 +- .../Mage/Adminhtml/Block/Sales/Order/Grid.php | 10 +- .../Sales/Order/Invoice/Create/Items.php | 2 +- .../Block/Sales/Order/Invoice/View.php | 14 +- .../Block/Sales/Order/Shipment/View.php | 2 +- .../Mage/Adminhtml/Block/Sales/Order/View.php | 26 +- .../Block/Sales/Order/View/History.php | 2 +- .../Sales/Order/View/Tab/Transactions.php | 2 +- .../Adminhtml/Block/Sales/Shipment/Grid.php | 4 +- .../Block/Sales/Transactions/Detail.php | 2 +- .../Adminhtml/Block/System/Config/Form.php | 476 ++++++----- .../Adminhtml/Block/System/Config/Tabs.php | 12 +- .../Adminhtml/Block/System/Store/Edit.php | 25 +- .../Block/System/Store/Edit/Form.php | 346 -------- .../Block/System/Store/Edit/Form/Group.php | 120 +++ .../Block/System/Store/Edit/Form/Store.php | 148 ++++ .../Block/System/Store/Edit/Form/Website.php | 111 +++ .../Block/System/Store/Edit/FormAbstract.php | 90 ++ .../Adminhtml/Controller/Sales/Creditmemo.php | 2 +- .../Adminhtml/Controller/Sales/Invoice.php | 2 +- .../Adminhtml/Controller/Sales/Shipment.php | 2 +- .../controllers/Api/RoleController.php | 2 +- .../controllers/Api/UserController.php | 2 +- .../Adminhtml/controllers/CacheController.php | 2 +- .../Catalog/CategoryController.php | 2 +- .../Product/Action/AttributeController.php | 2 +- .../Catalog/Product/AttributeController.php | 2 +- .../Catalog/Product/GalleryController.php | 2 +- .../Catalog/Product/GroupController.php | 2 +- .../Catalog/Product/ReviewController.php | 4 +- .../Catalog/Product/SetController.php | 2 +- .../controllers/Catalog/ProductController.php | 2 +- .../controllers/Catalog/SearchController.php | 2 +- .../Checkout/AgreementController.php | 2 +- .../controllers/Cms/BlockController.php | 2 +- .../controllers/Cms/PageController.php | 6 +- .../Cms/Wysiwyg/ImagesController.php | 2 +- .../Cart/Product/Composite/CartController.php | 2 +- .../controllers/Customer/GroupController.php | 2 +- .../controllers/Customer/OnlineController.php | 2 +- .../Product/Composite/WishlistController.php | 2 +- .../controllers/CustomerController.php | 5 +- .../controllers/DashboardController.php | 2 +- .../Adminhtml/controllers/IndexController.php | 2 +- .../controllers/Media/EditorController.php | 4 +- .../controllers/Media/UploaderController.php | 3 +- .../Newsletter/ProblemController.php | 2 +- .../Newsletter/QueueController.php | 2 +- .../Newsletter/SubscriberController.php | 2 +- .../Newsletter/TemplateController.php | 2 +- .../controllers/NotificationController.php | 10 +- .../controllers/Poll/AnswerController.php | 2 +- .../Adminhtml/controllers/PollController.php | 2 +- .../controllers/Promo/CatalogController.php | 2 +- .../controllers/Promo/QuoteController.php | 2 +- .../controllers/Promo/WidgetController.php | 2 +- .../Adminhtml/controllers/PromoController.php | 2 +- .../controllers/RatingController.php | 2 +- .../controllers/Report/CustomerController.php | 8 +- .../controllers/Report/ProductController.php | 8 +- .../controllers/Report/ReviewController.php | 6 +- .../controllers/Report/SalesController.php | 18 +- .../controllers/Report/ShopcartController.php | 9 +- .../Report/StatisticsController.php | 2 +- .../controllers/Report/TagController.php | 10 +- .../controllers/ReportController.php | 4 +- .../Sales/Billing/AgreementController.php | 6 +- .../Sales/Order/CreateController.php | 10 +- .../Sales/Order/EditController.php | 2 +- .../Sales/Order/StatusController.php | 2 +- .../controllers/Sales/OrderController.php | 18 +- .../Sales/TransactionsController.php | 4 +- .../controllers/SitemapController.php | 2 +- .../controllers/SurveyController.php | 3 +- .../controllers/System/AccountController.php | 2 +- .../controllers/System/BackupController.php | 2 +- .../controllers/System/ConfigController.php | 8 +- .../System/Convert/GuiController.php | 2 +- .../System/Convert/ProfileController.php | 2 +- .../controllers/System/CurrencyController.php | 2 +- .../controllers/System/DesignController.php | 2 +- .../System/Email/TemplateController.php | 2 +- .../controllers/System/StoreController.php | 2 +- .../controllers/System/VariableController.php | 2 +- .../controllers/SystemController.php | 2 +- .../Adminhtml/controllers/TagController.php | 6 +- .../Tax/Class/CustomerController.php | 2 +- .../Tax/Class/ProductController.php | 2 +- .../controllers/Tax/ClassController.php | 4 +- .../controllers/Tax/RateController.php | 6 +- .../controllers/Tax/RuleController.php | 2 +- .../controllers/UrlrewriteController.php | 2 +- .../core/Mage/Adminhtml/etc/adminhtml.xml | 177 ---- .../core/Mage/Adminhtml/etc/adminhtml/acl.xml | 70 ++ .../Mage/Adminhtml/etc/adminhtml/menu.xml | 30 +- app/code/core/Mage/Adminhtml/etc/config.xml | 6 +- .../view/adminhtml/adminnotification.xml | 4 +- .../view/adminhtml/page/header.phtml | 2 +- .../adminhtml/system/config/switcher.phtml | 2 +- app/code/core/Mage/Api/etc/adminhtml.xml | 62 -- .../etc/adminhtml/acl.xml} | 28 +- app/code/core/Mage/Api/etc/adminhtml/menu.xml | 6 +- app/code/core/Mage/Api/etc/system.xml | 1 + .../Api2/Block/Adminhtml/Attribute/Grid.php | 2 +- .../core/Mage/Api2/Block/Adminhtml/Roles.php | 2 +- .../Mage/Api2/Block/Adminhtml/Roles/Grid.php | 2 +- .../Adminhtml/Api2/RoleController.php | 2 +- app/code/core/Mage/Api2/etc/adminhtml.xml | 73 -- .../etc/adminhtml/acl.xml} | 36 +- .../core/Mage/Api2/etc/adminhtml/menu.xml | 4 +- .../core/Mage/Backend/Block/Menu/Item.php | 2 +- .../Backend/Block/Widget/Form/Container.php | 27 +- .../core/Mage/Backend/Model/Acl/Config.php | 133 +++ .../Mage/Backend/Model/Acl/Config/Reader.php | 110 +++ .../Backend/Model/Acl/Config/Reader/Dom.php | 45 + .../Model/Acl/Config/ReaderInterface.php} | 29 +- .../Mage/Backend/Model/Acl/Config/acl.xsd | 112 +++ .../Backend/Model/Acl/Loader/Resource.php | 87 ++ app/code/core/Mage/Backend/Model/Auth.php | 14 +- .../core/Mage/Backend/Model/Auth/Session.php | 31 +- app/code/core/Mage/Backend/Model/Menu.php | 25 - .../Model/Menu/Builder/Command/Add.php | 3 +- .../Mage/Backend/Model/Menu/Config/menu.xsd | 4 +- .../core/Mage/Backend/Model/Menu/Item.php | 46 +- .../Backend/Model/Menu/Item/Validator.php | 11 +- app/code/core/Mage/Backend/Model/Url.php | 7 +- app/code/core/Mage/Backend/etc/config.xml | 7 +- app/code/core/Mage/Backup/Helper/Data.php | 2 +- .../core/Mage/Backup/etc/adminhtml/acl.xml | 42 + .../core/Mage/Backup/etc/adminhtml/menu.xml | 2 +- .../core/Mage/Captcha/Block/Captcha/Zend.php | 13 +- app/code/core/Mage/Captcha/etc/config.xml | 26 + app/code/core/Mage/Catalog/etc/adminhtml.xml | 77 -- .../core/Mage/Catalog/etc/adminhtml/acl.xml | 50 ++ .../core/Mage/Catalog/etc/adminhtml/menu.xml | 14 +- app/code/core/Mage/Catalog/etc/system.xml | 1 + .../CatalogInventory/etc/adminhtml/acl.xml | 40 + .../core/Mage/CatalogInventory/etc/system.xml | 1 + .../core/Mage/CatalogRule/etc/adminhtml.xml | 46 - .../Mage/CatalogRule/etc/adminhtml/acl.xml | 38 + .../Mage/CatalogRule/etc/adminhtml/menu.xml | 4 +- .../Mage/CatalogSearch/etc/adminhtml/acl.xml | 38 + .../Mage/CatalogSearch/etc/adminhtml/menu.xml | 2 +- app/code/core/Mage/Centinel/etc/system.xml | 1 + app/code/core/Mage/Checkout/etc/adminhtml.xml | 57 -- .../core/Mage/Checkout/etc/adminhtml/acl.xml | 43 + .../core/Mage/Checkout/etc/adminhtml/menu.xml | 2 +- app/code/core/Mage/Checkout/etc/system.xml | 1 + .../core/Mage/Cms/Model/Wysiwyg/Config.php | 2 +- app/code/core/Mage/Cms/etc/adminhtml/acl.xml | 48 ++ app/code/core/Mage/Cms/etc/adminhtml/menu.xml | 6 +- app/code/core/Mage/Cms/etc/system.xml | 1 + .../Adminhtml/Extension/CustomController.php | 2 +- .../core/Mage/Connect/etc/adminhtml/acl.xml | 32 + .../core/Mage/Connect/etc/adminhtml/menu.xml | 6 +- app/code/core/Mage/Connect/etc/config.xml | 9 + .../core/Mage/Contacts/etc/adminhtml/acl.xml | 40 + app/code/core/Mage/Contacts/etc/system.xml | 1 + app/code/core/Mage/Core/Model/Acl/Builder.php | 98 +++ app/code/core/Mage/Core/Model/Config.php | 42 +- app/code/core/Mage/Core/etc/system.xml | 8 + .../System/CurrencysymbolController.php | 2 +- .../Mage/CurrencySymbol/etc/adminhtml.xml | 54 -- .../Mage/CurrencySymbol/etc/adminhtml/acl.xml | 41 + .../CurrencySymbol/etc/adminhtml/menu.xml | 6 +- .../core/Mage/Customer/etc/adminhtml/acl.xml | 45 + .../core/Mage/Customer/etc/adminhtml/menu.xml | 8 +- app/code/core/Mage/Customer/etc/system.xml | 1 + app/code/core/Mage/Dataflow/etc/config.xml | 11 + .../System/Design/EditorController.php | 2 +- .../Mage/DesignEditor/etc/adminhtml/acl.xml | 40 + .../Mage/DesignEditor/etc/adminhtml/menu.xml | 2 +- app/code/core/Mage/Directory/etc/system.xml | 1 + .../Adminhtml/Downloadable/FileController.php | 2 +- .../core/Mage/Downloadable/etc/adminhtml.xml | 48 -- .../Mage/Downloadable/etc/adminhtml/acl.xml | 40 + .../Mage/Downloadable/etc/adminhtml/menu.xml | 2 +- .../core/Mage/Eav/Model/Entity/Abstract.php | 7 +- .../core/Mage/Eav/Model/Entity/Attribute.php | 17 + .../GoogleAnalytics/etc/adminhtml/acl.xml | 40 + .../core/Mage/GoogleAnalytics/etc/system.xml | 1 + .../Mage/GoogleCheckout/etc/adminhtml.xml | 48 -- .../Mage/GoogleCheckout/etc/adminhtml/acl.xml | 40 + .../core/Mage/GoogleCheckout/etc/system.xml | 1 + .../Cms/Page/Edit/Tab/Googleoptimizer.php | 8 +- .../Googleshopping/ItemsController.php | 2 +- .../Googleshopping/TypesController.php | 2 +- .../Mage/GoogleShopping/etc/adminhtml.xml | 55 -- .../Mage/GoogleShopping/etc/adminhtml/acl.xml | 41 + .../GoogleShopping/etc/adminhtml/menu.xml | 6 +- .../Model/Import/Entity/Product.php | 29 +- .../Import/Entity/Product/Type/Abstract.php | 29 +- .../Adminhtml/ExportController.php | 2 +- .../Adminhtml/ImportController.php | 2 +- .../core/Mage/ImportExport/etc/adminhtml.xml | 53 -- .../Mage/ImportExport/etc/adminhtml/acl.xml | 41 + .../Mage/ImportExport/etc/adminhtml/menu.xml | 4 +- .../core/Mage/ImportExport/etc/config.xml | 9 + .../Index/Block/Adminhtml/Notifications.php | 2 +- .../Adminhtml/ProcessController.php | 2 +- .../core/Mage/Index/etc/adminhtml/acl.xml | 38 + .../core/Mage/Index/etc/adminhtml/menu.xml | 2 +- .../core/Mage/Newsletter/etc/adminhtml.xml | 66 -- .../Mage/Newsletter/etc/adminhtml/acl.xml | 46 + .../Mage/Newsletter/etc/adminhtml/menu.xml | 10 +- app/code/core/Mage/Newsletter/etc/system.xml | 1 + .../Adminhtml/Oauth/AuthorizedTokens/Grid.php | 2 +- .../Oauth/Block/Adminhtml/Oauth/Consumer.php | 2 +- .../Block/Adminhtml/Oauth/Consumer/Edit.php | 2 +- .../Block/Adminhtml/Oauth/Consumer/Grid.php | 2 +- .../Adminhtml/Oauth/Admin/TokenController.php | 2 +- .../Oauth/AuthorizedTokensController.php | 2 +- .../Adminhtml/Oauth/ConsumerController.php | 24 +- app/code/core/Mage/Oauth/etc/adminhtml.xml | 75 -- .../core/Mage/Oauth/etc/adminhtml/acl.xml | 48 ++ .../core/Mage/Oauth/etc/adminhtml/menu.xml | 6 +- app/code/core/Mage/Oauth/etc/system.xml | 1 + app/code/core/Mage/Ogone/etc/config.xml | 9 + .../Block/Adminhtml/Cache/Additional.php | 2 +- .../Adminhtml/PageCacheController.php | 2 +- .../core/Mage/PageCache/etc/adminhtml/acl.xml | 36 + app/code/core/Mage/Payment/etc/adminhtml.xml | 51 -- .../core/Mage/Payment/etc/adminhtml/acl.xml | 41 + app/code/core/Mage/Payment/etc/system.xml | 1 + .../Adminhtml/Paypal/ReportsController.php | 6 +- app/code/core/Mage/Paypal/etc/adminhtml.xml | 67 -- .../core/Mage/Paypal/etc/adminhtml/acl.xml | 48 ++ .../core/Mage/Paypal/etc/adminhtml/menu.xml | 2 +- .../core/Mage/Persistent/etc/adminhtml.xml | 48 -- .../Mage/Persistent/etc/adminhtml/acl.xml | 40 + app/code/core/Mage/Persistent/etc/system.xml | 2 +- app/code/core/Mage/Poll/etc/adminhtml/acl.xml | 38 + .../core/Mage/Poll/etc/adminhtml/menu.xml | 2 +- app/code/core/Mage/Rating/etc/adminhtml.xml | 48 -- .../core/Mage/Rating/etc/adminhtml/acl.xml | 40 + app/code/core/Mage/Reports/etc/adminhtml.xml | 153 ---- .../core/Mage/Reports/etc/adminhtml/acl.xml | 77 ++ .../core/Mage/Reports/etc/adminhtml/menu.xml | 44 +- app/code/core/Mage/Reports/etc/system.xml | 1 + app/code/core/Mage/Review/etc/adminhtml.xml | 57 -- .../etc/adminhtml/acl.xml} | 27 +- .../core/Mage/Review/etc/adminhtml/menu.xml | 16 +- .../Mage/Rss/controllers/OrderController.php | 2 +- app/code/core/Mage/Rss/etc/adminhtml.xml | 49 -- app/code/core/Mage/Rss/etc/adminhtml/acl.xml | 40 + app/code/core/Mage/Rss/etc/system.xml | 1 + .../Adminhtml/Billing/Agreement/View.php | 10 +- .../Recurring/Profile/View/Tab/Orders.php | 2 +- app/code/core/Mage/Sales/Model/Observer.php | 2 +- app/code/core/Mage/Sales/etc/adminhtml.xml | 139 --- .../core/Mage/Sales/etc/adminhtml/acl.xml | 78 ++ .../core/Mage/Sales/etc/adminhtml/menu.xml | 18 +- app/code/core/Mage/Sales/etc/system.xml | 3 + .../core/Mage/SalesRule/etc/adminhtml/acl.xml | 43 + .../Mage/SalesRule/etc/adminhtml/menu.xml | 2 +- app/code/core/Mage/Sendfriend/etc/system.xml | 1 + app/code/core/Mage/Shipping/etc/adminhtml.xml | 53 -- .../core/Mage/Shipping/etc/adminhtml/acl.xml | 41 + app/code/core/Mage/Shipping/etc/system.xml | 2 + app/code/core/Mage/Sitemap/etc/adminhtml.xml | 55 -- .../core/Mage/Sitemap/etc/adminhtml/acl.xml | 43 + .../core/Mage/Sitemap/etc/adminhtml/menu.xml | 2 +- app/code/core/Mage/Sitemap/etc/system.xml | 1 + app/code/core/Mage/Tag/etc/adminhtml.xml | 52 -- app/code/core/Mage/Tag/etc/adminhtml/acl.xml | 41 + app/code/core/Mage/Tag/etc/adminhtml/menu.xml | 14 +- app/code/core/Mage/Tax/etc/adminhtml.xml | 79 -- app/code/core/Mage/Tax/etc/adminhtml/acl.xml | 49 ++ app/code/core/Mage/Tax/etc/adminhtml/menu.xml | 12 +- app/code/core/Mage/Tax/etc/system.xml | 1 + .../core/Mage/User/Block/Role/Tab/Edit.php | 52 +- .../core/Mage/User/Model/Acl/Loader/Role.php | 84 ++ .../core/Mage/User/Model/Acl/Loader/Rule.php | 72 ++ .../Model/Acl/Role/Generic.php | 8 +- .../{Admin => User}/Model/Acl/Role/Group.php | 14 +- .../{Admin => User}/Model/Acl/Role/User.php | 14 +- .../core/Mage/User/Model/Resource/Rules.php | 14 +- .../Adminhtml/User/RoleController.php | 4 +- .../controllers/Adminhtml/UserController.php | 2 +- .../data/user_setup/data-install-1.6.0.0.php | 3 +- app/code/core/Mage/User/etc/adminhtml.xml | 55 -- app/code/core/Mage/User/etc/adminhtml/acl.xml | 41 + .../core/Mage/User/etc/adminhtml/menu.xml | 6 +- app/code/core/Mage/User/etc/config.xml | 18 +- .../user_setup/upgrade-1.6.1.0-1.6.1.1.php | 35 + app/code/core/Mage/Weee/etc/config.xml | 18 + .../Adminhtml/Widget/InstanceController.php | 2 +- .../etc/{adminhtml.xml => adminhtml/acl.xml} | 17 +- .../core/Mage/Widget/etc/adminhtml/menu.xml | 2 +- app/code/core/Mage/Wishlist/etc/adminhtml.xml | 48 -- .../core/Mage/Wishlist/etc/adminhtml/acl.xml | 40 + app/code/core/Mage/Wishlist/etc/system.xml | 1 + .../Adminhtml/MobileController.php | 2 +- .../core/Mage/XmlConnect/etc/adminhtml.xml | 59 -- .../etc/adminhtml/acl.xml} | 25 +- .../Mage/XmlConnect/etc/adminhtml/menu.xml | 10 +- .../framework/Magento/Test/Bootstrap.php | 2 +- .../Block/System/Config/FormTest.php | 53 ++ .../System/Store/Edit/Form/GroupTest.php | 72 ++ .../System/Store/Edit/Form/StoreTest.php | 72 ++ .../System/Store/Edit/Form/WebsiteTest.php | 72 ++ .../Adminhtml/Block/System/Store/EditTest.php | 155 ++++ .../testsuite/Mage/Backend/Model/MenuTest.php | 4 +- .../Mage/Captcha/Block/Captcha/ZendTest.php | 60 ++ .../testsuite/Mage/Core/Block/FlushTest.php | 83 -- .../testsuite/Mage/Core/Model/ConfigTest.php | 46 +- .../custom/invalid.pattern.xml | 29 + .../custom/local.xml | 31 + .../local_config_custom_config/local.xml | 31 + .../local_config_no_custom_config/local.xml | 31 + .../local_config_no_custom_config/z.xml | 31 + .../no_local_config_custom_config/a.xml | 31 + .../custom/local.xml | 29 + .../no_local_config_no_custom_config/a.xml | 33 + .../no_local_config_no_custom_config/b.xml | 33 + .../Mage/Newsletter/Model/TemplateTest.php | 46 +- .../Review/Product/CollectionTest.php | 3 +- .../Mage/Review/_files/different_reviews.php | 2 + .../Mage/User/Block/Role/Tab/EditTest.php | 12 +- .../testsuite/Mage/User/Model/RulesTest.php | 8 +- .../integrity/modular/AclConfigFilesTest.php | 109 +++ dev/tests/performance/config.php.dist | 10 +- .../performance/framework/Magento/Config.php | 37 +- .../framework/Magento/Scenario.php | 3 + dev/tests/performance/framework/bootstrap.php | 7 + .../unit/testsuite/Magento/ConfigTest.php | 17 +- dev/tests/performance/run_scenarios.php | 7 +- .../testsuite/{ => _samples}/add_to_cart.jmx | 0 .../testsuite/{ => _samples}/checkout.jmx | 0 .../testsuite/_samples/product_edit.jmx | 347 ++++++++ .../static/testsuite/Legacy/ConfigTest.php | 49 ++ .../testsuite/Legacy/ObsoleteAclTest.php | 54 ++ .../testsuite/Legacy/ObsoleteCodeTest.php | 8 + .../Legacy/_files/obsolete_classes.php | 8 + .../Legacy/_files/obsolete_methods.php | 4 + .../testsuite/Php/_files/whitelist/core.txt | 2 + .../testsuite/Mage/Admin/Model/ConfigTest.php | 105 --- .../Mage/Admin/Model/_files/adminhtml.xml | 56 -- .../Backend/Model/Acl/Config/ReaderTest.php | 69 ++ .../Mage/Backend/Model/Acl/ConfigTest.php | 173 ++++ .../Backend/Model/Acl/Loader/ResourceTest.php | 85 ++ .../Model/Menu/Builder/Command/AddTest.php | 6 +- .../Mage/Backend/Model/Menu/BuilderTest.php | 21 +- .../Backend/Model/Menu/Item/ValidatorTest.php | 23 +- .../Mage/Backend/Model/Menu/ItemTest.php | 32 +- .../testsuite/Mage/Backend/Model/MenuTest.php | 12 - .../Mage/Backend/Model/_files/acl.xml | 40 + .../Mage/Backend/Model/_files/acl_1.xml | 40 + .../Mage/Backend/Model/_files/acl_2.xml | 42 + .../Mage/Backend/Model/_files/acl_merged.xml | 45 + .../Mage/Backend/Model/_files/menu_1.xml | 4 +- .../Mage/Backend/Model/_files/menu_2.xml | 4 +- .../Mage/Backend/Model/_files/menu_merged.php | 5 +- .../Mage/Backend/Model/_files/menu_merged.xml | 8 +- .../Mage/Core/Model/Acl/BuilderTest.php | 142 ++++ .../Mage/Eav/Model/Entity/AbstractTest.php | 99 +++ .../Mage/Eav/Model/Entity/AttributeTest.php | 66 +- .../Mage/User/Model/Acl/Loader/RoleTest.php | 118 +++ .../Mage/User/Model/Acl/Loader/RuleTest.php | 81 ++ .../Magento/Acl/Loader/DefaultTest.php | 48 ++ .../Magento/Config/_files/dom/ids_merged.xml | 2 +- .../Magento/Config/_files/dom/ids_new.xml | 2 +- .../migration/Acl/GeneratorRemoveTest.php | 103 +++ .../tools/migration/Acl/GeneratorSaveTest.php | 144 ++++ .../tools/migration/Acl/GeneratorTest.php | 411 +++++++++ .../migration/Acl/Menu/GeneratorTest.php | 276 ++++++ .../Namespace/Module}/etc/adminhtml.xml | 8 +- .../Namespace/Module/etc/adminhtml/menu.xml | 35 + .../core/Enterprise/Module}/etc/adminhtml.xml | 11 +- .../Enterprise/Module/etc/adminhtml/menu.xml | 32 + .../code/core/Mage/Module}/etc/adminhtml.xml | 11 +- .../core/Mage/Module/etc/adminhtml/menu.xml | 32 + .../local/Namespace/Module}/etc/adminhtml.xml | 12 +- .../Namespace/Module/etc/adminhtml/menu.xml | 32 + .../Acl/_files/parse_node_result.xml | 41 + .../Acl/_files/parse_node_source.xml | 32 +- .../migration/Acl/_files/remove/empty.xml | 65 +- .../migration/Acl/_files/remove/not_empty.xml | 85 ++ .../migration/Acl/_files/save}/adminhtml.xml | 4 +- .../Acl/_files/template_document.xml | 32 + .../_files/update_child_acl_nodes_result.xml | 45 + .../_files/update_child_acl_nodes_source.xml | 45 + .../_files/update_menu_attributes_result.xml | 38 + .../_files/update_menu_attributes_source.xml | 38 + dev/tools/migration/Acl/FileWriter.php | 50 ++ dev/tools/migration/Acl/Formatter.php | 38 + dev/tools/migration/Acl/Generator.php | 788 ++++++++++++++++++ dev/tools/migration/Acl/Menu/Generator.php | 426 ++++++++++ .../migration/Acl/log/AclXPathToAclId.log | 1 + dev/tools/migration/Acl/log/MenuIdToAclId.log | 1 + dev/tools/migration/acl.php | 42 + downloader/Maged/Model/Session.php | 2 +- index.php | 7 +- index.php.sample | 28 +- .../Mage/Admin/Model => lib/Magento}/Acl.php | 42 +- lib/Magento/Acl/Loader.php | 41 + lib/Magento/Acl/Loader/Default.php | 44 + .../Model => lib/Magento}/Acl/Resource.php | 12 +- .../Magento}/Acl/Role/Registry.php | 17 +- lib/Magento/Config/Dom.php | 6 +- pub/index.php | 8 +- 428 files changed, 9597 insertions(+), 4140 deletions(-) rename app/code/community/Phoenix/Moneybookers/etc/{adminhtml.xml => adminhtml/acl.xml} (63%) delete mode 100755 app/code/core/Mage/Admin/Model/Resource/Acl.php delete mode 100644 app/code/core/Mage/AdminNotification/etc/adminhtml.xml rename app/code/core/Mage/{DesignEditor/etc/adminhtml.xml => AdminNotification/etc/adminhtml/acl.xml} (55%) delete mode 100644 app/code/core/Mage/Adminhtml/Block/System/Store/Edit/Form.php create mode 100644 app/code/core/Mage/Adminhtml/Block/System/Store/Edit/Form/Group.php create mode 100644 app/code/core/Mage/Adminhtml/Block/System/Store/Edit/Form/Store.php create mode 100644 app/code/core/Mage/Adminhtml/Block/System/Store/Edit/Form/Website.php create mode 100644 app/code/core/Mage/Adminhtml/Block/System/Store/Edit/FormAbstract.php delete mode 100644 app/code/core/Mage/Adminhtml/etc/adminhtml.xml create mode 100644 app/code/core/Mage/Adminhtml/etc/adminhtml/acl.xml delete mode 100644 app/code/core/Mage/Api/etc/adminhtml.xml rename app/code/core/Mage/{CatalogInventory/etc/adminhtml.xml => Api/etc/adminhtml/acl.xml} (58%) delete mode 100644 app/code/core/Mage/Api2/etc/adminhtml.xml rename app/code/core/Mage/{Backup/etc/adminhtml.xml => Api2/etc/adminhtml/acl.xml} (51%) create mode 100644 app/code/core/Mage/Backend/Model/Acl/Config.php create mode 100644 app/code/core/Mage/Backend/Model/Acl/Config/Reader.php create mode 100644 app/code/core/Mage/Backend/Model/Acl/Config/Reader/Dom.php rename app/code/core/Mage/{Core/Block/Flush.php => Backend/Model/Acl/Config/ReaderInterface.php} (69%) create mode 100644 app/code/core/Mage/Backend/Model/Acl/Config/acl.xsd create mode 100644 app/code/core/Mage/Backend/Model/Acl/Loader/Resource.php create mode 100644 app/code/core/Mage/Backup/etc/adminhtml/acl.xml delete mode 100644 app/code/core/Mage/Catalog/etc/adminhtml.xml create mode 100644 app/code/core/Mage/Catalog/etc/adminhtml/acl.xml create mode 100644 app/code/core/Mage/CatalogInventory/etc/adminhtml/acl.xml delete mode 100644 app/code/core/Mage/CatalogRule/etc/adminhtml.xml create mode 100644 app/code/core/Mage/CatalogRule/etc/adminhtml/acl.xml create mode 100644 app/code/core/Mage/CatalogSearch/etc/adminhtml/acl.xml delete mode 100644 app/code/core/Mage/Checkout/etc/adminhtml.xml create mode 100644 app/code/core/Mage/Checkout/etc/adminhtml/acl.xml create mode 100644 app/code/core/Mage/Cms/etc/adminhtml/acl.xml create mode 100644 app/code/core/Mage/Connect/etc/adminhtml/acl.xml create mode 100644 app/code/core/Mage/Contacts/etc/adminhtml/acl.xml create mode 100644 app/code/core/Mage/Core/Model/Acl/Builder.php delete mode 100644 app/code/core/Mage/CurrencySymbol/etc/adminhtml.xml create mode 100644 app/code/core/Mage/CurrencySymbol/etc/adminhtml/acl.xml create mode 100644 app/code/core/Mage/Customer/etc/adminhtml/acl.xml create mode 100644 app/code/core/Mage/DesignEditor/etc/adminhtml/acl.xml delete mode 100644 app/code/core/Mage/Downloadable/etc/adminhtml.xml create mode 100644 app/code/core/Mage/Downloadable/etc/adminhtml/acl.xml create mode 100644 app/code/core/Mage/GoogleAnalytics/etc/adminhtml/acl.xml delete mode 100644 app/code/core/Mage/GoogleCheckout/etc/adminhtml.xml create mode 100644 app/code/core/Mage/GoogleCheckout/etc/adminhtml/acl.xml delete mode 100644 app/code/core/Mage/GoogleShopping/etc/adminhtml.xml create mode 100644 app/code/core/Mage/GoogleShopping/etc/adminhtml/acl.xml delete mode 100644 app/code/core/Mage/ImportExport/etc/adminhtml.xml create mode 100644 app/code/core/Mage/ImportExport/etc/adminhtml/acl.xml create mode 100644 app/code/core/Mage/Index/etc/adminhtml/acl.xml delete mode 100644 app/code/core/Mage/Newsletter/etc/adminhtml.xml create mode 100644 app/code/core/Mage/Newsletter/etc/adminhtml/acl.xml delete mode 100644 app/code/core/Mage/Oauth/etc/adminhtml.xml create mode 100644 app/code/core/Mage/Oauth/etc/adminhtml/acl.xml create mode 100644 app/code/core/Mage/PageCache/etc/adminhtml/acl.xml delete mode 100644 app/code/core/Mage/Payment/etc/adminhtml.xml create mode 100644 app/code/core/Mage/Payment/etc/adminhtml/acl.xml delete mode 100644 app/code/core/Mage/Paypal/etc/adminhtml.xml create mode 100644 app/code/core/Mage/Paypal/etc/adminhtml/acl.xml delete mode 100644 app/code/core/Mage/Persistent/etc/adminhtml.xml create mode 100644 app/code/core/Mage/Persistent/etc/adminhtml/acl.xml create mode 100644 app/code/core/Mage/Poll/etc/adminhtml/acl.xml delete mode 100644 app/code/core/Mage/Rating/etc/adminhtml.xml create mode 100644 app/code/core/Mage/Rating/etc/adminhtml/acl.xml delete mode 100644 app/code/core/Mage/Reports/etc/adminhtml.xml create mode 100644 app/code/core/Mage/Reports/etc/adminhtml/acl.xml delete mode 100644 app/code/core/Mage/Review/etc/adminhtml.xml rename app/code/core/Mage/{Contacts/etc/adminhtml.xml => Review/etc/adminhtml/acl.xml} (62%) delete mode 100644 app/code/core/Mage/Rss/etc/adminhtml.xml create mode 100644 app/code/core/Mage/Rss/etc/adminhtml/acl.xml delete mode 100644 app/code/core/Mage/Sales/etc/adminhtml.xml create mode 100644 app/code/core/Mage/Sales/etc/adminhtml/acl.xml create mode 100644 app/code/core/Mage/SalesRule/etc/adminhtml/acl.xml delete mode 100644 app/code/core/Mage/Shipping/etc/adminhtml.xml create mode 100644 app/code/core/Mage/Shipping/etc/adminhtml/acl.xml delete mode 100644 app/code/core/Mage/Sitemap/etc/adminhtml.xml create mode 100644 app/code/core/Mage/Sitemap/etc/adminhtml/acl.xml delete mode 100644 app/code/core/Mage/Tag/etc/adminhtml.xml create mode 100644 app/code/core/Mage/Tag/etc/adminhtml/acl.xml delete mode 100644 app/code/core/Mage/Tax/etc/adminhtml.xml create mode 100644 app/code/core/Mage/Tax/etc/adminhtml/acl.xml create mode 100644 app/code/core/Mage/User/Model/Acl/Loader/Role.php create mode 100644 app/code/core/Mage/User/Model/Acl/Loader/Rule.php rename app/code/core/Mage/{Admin => User}/Model/Acl/Role/Generic.php (82%) rename app/code/core/Mage/{Admin => User}/Model/Acl/Role/Group.php (81%) rename app/code/core/Mage/{Admin => User}/Model/Acl/Role/User.php (81%) delete mode 100644 app/code/core/Mage/User/etc/adminhtml.xml create mode 100644 app/code/core/Mage/User/etc/adminhtml/acl.xml create mode 100644 app/code/core/Mage/User/sql/user_setup/upgrade-1.6.1.0-1.6.1.1.php rename app/code/core/Mage/Widget/etc/{adminhtml.xml => adminhtml/acl.xml} (69%) delete mode 100644 app/code/core/Mage/Wishlist/etc/adminhtml.xml create mode 100644 app/code/core/Mage/Wishlist/etc/adminhtml/acl.xml delete mode 100644 app/code/core/Mage/XmlConnect/etc/adminhtml.xml rename app/code/core/Mage/{GoogleAnalytics/etc/adminhtml.xml => XmlConnect/etc/adminhtml/acl.xml} (56%) create mode 100644 dev/tests/integration/testsuite/Mage/Adminhtml/Block/System/Store/Edit/Form/GroupTest.php create mode 100644 dev/tests/integration/testsuite/Mage/Adminhtml/Block/System/Store/Edit/Form/StoreTest.php create mode 100644 dev/tests/integration/testsuite/Mage/Adminhtml/Block/System/Store/Edit/Form/WebsiteTest.php create mode 100644 dev/tests/integration/testsuite/Mage/Adminhtml/Block/System/Store/EditTest.php create mode 100644 dev/tests/integration/testsuite/Mage/Captcha/Block/Captcha/ZendTest.php delete mode 100644 dev/tests/integration/testsuite/Mage/Core/Block/FlushTest.php create mode 100644 dev/tests/integration/testsuite/Mage/Core/Model/_files/local_config/local_config_custom_config/custom/invalid.pattern.xml create mode 100644 dev/tests/integration/testsuite/Mage/Core/Model/_files/local_config/local_config_custom_config/custom/local.xml create mode 100644 dev/tests/integration/testsuite/Mage/Core/Model/_files/local_config/local_config_custom_config/local.xml create mode 100644 dev/tests/integration/testsuite/Mage/Core/Model/_files/local_config/local_config_no_custom_config/local.xml create mode 100644 dev/tests/integration/testsuite/Mage/Core/Model/_files/local_config/local_config_no_custom_config/z.xml create mode 100644 dev/tests/integration/testsuite/Mage/Core/Model/_files/local_config/no_local_config_custom_config/a.xml create mode 100644 dev/tests/integration/testsuite/Mage/Core/Model/_files/local_config/no_local_config_custom_config/custom/local.xml create mode 100644 dev/tests/integration/testsuite/Mage/Core/Model/_files/local_config/no_local_config_no_custom_config/a.xml create mode 100644 dev/tests/integration/testsuite/Mage/Core/Model/_files/local_config/no_local_config_no_custom_config/b.xml create mode 100644 dev/tests/integration/testsuite/integrity/modular/AclConfigFilesTest.php rename dev/tests/performance/testsuite/{ => _samples}/add_to_cart.jmx (100%) rename dev/tests/performance/testsuite/{ => _samples}/checkout.jmx (100%) create mode 100644 dev/tests/performance/testsuite/_samples/product_edit.jmx create mode 100644 dev/tests/static/testsuite/Legacy/ObsoleteAclTest.php delete mode 100644 dev/tests/unit/testsuite/Mage/Admin/Model/ConfigTest.php delete mode 100644 dev/tests/unit/testsuite/Mage/Admin/Model/_files/adminhtml.xml create mode 100644 dev/tests/unit/testsuite/Mage/Backend/Model/Acl/Config/ReaderTest.php create mode 100644 dev/tests/unit/testsuite/Mage/Backend/Model/Acl/ConfigTest.php create mode 100644 dev/tests/unit/testsuite/Mage/Backend/Model/Acl/Loader/ResourceTest.php create mode 100644 dev/tests/unit/testsuite/Mage/Backend/Model/_files/acl.xml create mode 100644 dev/tests/unit/testsuite/Mage/Backend/Model/_files/acl_1.xml create mode 100644 dev/tests/unit/testsuite/Mage/Backend/Model/_files/acl_2.xml create mode 100644 dev/tests/unit/testsuite/Mage/Backend/Model/_files/acl_merged.xml create mode 100644 dev/tests/unit/testsuite/Mage/Core/Model/Acl/BuilderTest.php create mode 100644 dev/tests/unit/testsuite/Mage/Eav/Model/Entity/AbstractTest.php create mode 100644 dev/tests/unit/testsuite/Mage/User/Model/Acl/Loader/RoleTest.php create mode 100644 dev/tests/unit/testsuite/Mage/User/Model/Acl/Loader/RuleTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Acl/Loader/DefaultTest.php create mode 100644 dev/tests/unit/testsuite/tools/migration/Acl/GeneratorRemoveTest.php create mode 100644 dev/tests/unit/testsuite/tools/migration/Acl/GeneratorSaveTest.php create mode 100644 dev/tests/unit/testsuite/tools/migration/Acl/GeneratorTest.php create mode 100644 dev/tests/unit/testsuite/tools/migration/Acl/Menu/GeneratorTest.php rename {app/code/core/Mage/PageCache => dev/tests/unit/testsuite/tools/migration/Acl/_files/app/code/community/Namespace/Module}/etc/adminhtml.xml (78%) create mode 100644 dev/tests/unit/testsuite/tools/migration/Acl/_files/app/code/community/Namespace/Module/etc/adminhtml/menu.xml rename {app/code/core/Mage/Index => dev/tests/unit/testsuite/tools/migration/Acl/_files/app/code/core/Enterprise/Module}/etc/adminhtml.xml (74%) create mode 100644 dev/tests/unit/testsuite/tools/migration/Acl/_files/app/code/core/Enterprise/Module/etc/adminhtml/menu.xml rename {app/code/core/Mage/CatalogSearch => dev/tests/unit/testsuite/tools/migration/Acl/_files/app/code/core/Mage/Module}/etc/adminhtml.xml (72%) create mode 100644 dev/tests/unit/testsuite/tools/migration/Acl/_files/app/code/core/Mage/Module/etc/adminhtml/menu.xml rename {app/code/core/Mage/Poll => dev/tests/unit/testsuite/tools/migration/Acl/_files/app/code/local/Namespace/Module}/etc/adminhtml.xml (71%) create mode 100644 dev/tests/unit/testsuite/tools/migration/Acl/_files/app/code/local/Namespace/Module/etc/adminhtml/menu.xml create mode 100644 dev/tests/unit/testsuite/tools/migration/Acl/_files/parse_node_result.xml rename app/code/core/Mage/SalesRule/etc/adminhtml.xml => dev/tests/unit/testsuite/tools/migration/Acl/_files/parse_node_source.xml (55%) rename app/code/core/Mage/Cms/etc/adminhtml.xml => dev/tests/unit/testsuite/tools/migration/Acl/_files/remove/empty.xml (51%) create mode 100644 dev/tests/unit/testsuite/tools/migration/Acl/_files/remove/not_empty.xml rename {app/code/core/Mage/Customer/etc => dev/tests/unit/testsuite/tools/migration/Acl/_files/save}/adminhtml.xml (98%) create mode 100644 dev/tests/unit/testsuite/tools/migration/Acl/_files/template_document.xml create mode 100644 dev/tests/unit/testsuite/tools/migration/Acl/_files/update_child_acl_nodes_result.xml create mode 100644 dev/tests/unit/testsuite/tools/migration/Acl/_files/update_child_acl_nodes_source.xml create mode 100644 dev/tests/unit/testsuite/tools/migration/Acl/_files/update_menu_attributes_result.xml create mode 100644 dev/tests/unit/testsuite/tools/migration/Acl/_files/update_menu_attributes_source.xml create mode 100644 dev/tools/migration/Acl/FileWriter.php create mode 100644 dev/tools/migration/Acl/Formatter.php create mode 100644 dev/tools/migration/Acl/Generator.php create mode 100644 dev/tools/migration/Acl/Menu/Generator.php create mode 100644 dev/tools/migration/Acl/log/AclXPathToAclId.log create mode 100644 dev/tools/migration/Acl/log/MenuIdToAclId.log create mode 100644 dev/tools/migration/acl.php rename {app/code/core/Mage/Admin/Model => lib/Magento}/Acl.php (65%) create mode 100644 lib/Magento/Acl/Loader.php create mode 100644 lib/Magento/Acl/Loader/Default.php rename {app/code/core/Mage/Admin/Model => lib/Magento}/Acl/Resource.php (80%) rename {app/code/core/Mage/Admin/Model => lib/Magento}/Acl/Role/Registry.php (88%) diff --git a/CHANGELOG.markdown b/CHANGELOG.markdown index 84c0454d148..8c3ce00b88b 100644 --- a/CHANGELOG.markdown +++ b/CHANGELOG.markdown @@ -1,3 +1,30 @@ +Update as of 8/1/2012 +===================== +* Refactored ACL for the backend + * ACL resources + * Strict configuration format, validated by XSD schema + * ACL configuration relocation from `app/code/<pool>/<namespace>/<module>/etc/adminhtml.xml` to `app/code/<pool>/<namespace>/<module>/etc/adminhtml/acl.xml` + * Renamed ACL resource identifiers according to the format `<namespace>_<module>::<resource>` throughout the system + * Backend menu configuration requires to specify ACL resource identifier in the new format + * Explicit declaration of ACL resources in `app/code/<pool>/<namespace>/<module>/etc/system.xml` instead of implicit relation by XPath + * Migration tool `dev/tools/migration/acl.php` to convert ACL configuration from 1.x to 2.x + * Declaration of ACL resource/role/rule loaders through the area configuration + * Module `Mage_Backend` declares loader for ACL resources in backend area + * Module `Mage_User` declares loaders for ACL roles and rules (relations between roles and resources) in backend area + * Implemented integrity and legacy tests for ACL +* Fixed issues: + * Losing qty and visibility information when importing products + * Impossibility to reload captcha on backend + * Temporary excluded from execution integration test `Mage_Review_Model_Resource_Review_Product_CollectionTest::testGetResultingIds()` and corresponding fixture script, which cause occasional `segmentation fault` (exit code 139) +* Refactored methods with high cyclomatic complexity: + * `Mage_Adminhtml_Block_System_Store_Edit_Form::_prepareForm()` + * `Mage_Adminhtml_Block_System_Config_Form::initForm()` + * `Mage_Adminhtml_Block_System_Config_Form::initFields()` +* GitHub requests: + * [#32](https://github.com/magento/magento2/pull/32) -- fixed declaration of localization CSV files + * [#35](https://github.com/magento/magento2/issues/35) -- removed non-used `Mage_Core_Block_Flush` block + * [#41](https://github.com/magento/magento2/pull/41) -- implemented ability to extends `app/etc/local.xml` by specifying additional config file via `MAGE_LOCAL_CONFIG` environment variable + Update as of 7/26/2012 ===================== * Implemented Magento Validator library in order to have clear solid mechanism and formal rules of input data validation diff --git a/app/code/community/Phoenix/Moneybookers/etc/adminhtml.xml b/app/code/community/Phoenix/Moneybookers/etc/adminhtml/acl.xml similarity index 63% rename from app/code/community/Phoenix/Moneybookers/etc/adminhtml.xml rename to app/code/community/Phoenix/Moneybookers/etc/adminhtml/acl.xml index 2a2b02f59c6..0624ff5fb66 100644 --- a/app/code/community/Phoenix/Moneybookers/etc/adminhtml.xml +++ b/app/code/community/Phoenix/Moneybookers/etc/adminhtml/acl.xml @@ -28,21 +28,13 @@ <config> <acl> <resources> - <admin> - <children> - <system> - <children> - <config> - <children> - <moneybookers translate="title" module="Phoenix_Moneybookers"> - <title>Moneybookers Settings</title> - </moneybookers> - </children> - </config> - </children> - </system> - </children> - </admin> + <resource id="Mage_Adminhtml::admin"> + <resource id="Mage_Adminhtml::system"> + <resource id="Mage_Adminhtml::config"> + <resource id="Phoenix_Moneybookers::moneybookers" module="Phoenix_Moneybookers" title="Moneybookers Settings" /> + </resource> + </resource> + </resource> </resources> </acl> </config> diff --git a/app/code/community/Phoenix/Moneybookers/etc/system.xml b/app/code/community/Phoenix/Moneybookers/etc/system.xml index d2dae0a0ccd..1c830551254 100644 --- a/app/code/community/Phoenix/Moneybookers/etc/system.xml +++ b/app/code/community/Phoenix/Moneybookers/etc/system.xml @@ -35,6 +35,7 @@ <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>1</show_in_store> + <resource>Phoenix_Moneybookers::moneybookers</resource> <groups> <settings translate="label"> <label>Moneybookers Settings</label> diff --git a/app/code/core/Mage/Admin/Model/Config.php b/app/code/core/Mage/Admin/Model/Config.php index 941e6a73f89..e560b3ece33 100644 --- a/app/code/core/Mage/Admin/Model/Config.php +++ b/app/code/core/Mage/Admin/Model/Config.php @@ -109,221 +109,6 @@ class Mage_Admin_Model_Config extends Varien_Simplexml_Config return Mage::helper($module); } - /** - * Load Acl resources from config - * - * @param Mage_Admin_Model_Acl $acl - * @param Mage_Core_Model_Config_Element $resource - * @param string $parentName - * @return Mage_Admin_Model_Config - */ - public function loadAclResources(Mage_Admin_Model_Acl $acl, $resource = null, $parentName = null) - { - if (is_null($resource)) { - $resource = $this->getAdminhtmlConfig()->getNode("acl/resources"); - $resourceName = null; - } else { - $resourceName = (is_null($parentName) ? '' : $parentName . '/') . $resource->getName(); - $acl->add(Mage::getModel('Mage_Admin_Model_Acl_Resource', $resourceName), $parentName); - } - - if (isset($resource->all)) { - $acl->add(Mage::getModel('Mage_Admin_Model_Acl_Resource', 'all'), null); - } - - if (isset($resource->admin)) { - $children = $resource->admin; - } elseif (isset($resource->children)){ - $children = $resource->children->children(); - } - - - - if (empty($children)) { - return $this; - } - - foreach ($children as $res) { - if (1 == $res->disabled) { - continue; - } - $this->loadAclResources($acl, $res, $resourceName); - } - return $this; - } - - /** - * Retrieve Acl Resource Tree with module and path information - * - * @return Varien_Simplexml_Element - */ - public function getAclResourceTree() - { - return $this->_walkResourceTree(); - } - - /** - * Retrieve flat Acl Resource list with level information - * @param bool $shortFormat - * @return array - */ - public function getAclResourceList($shortFormat = false) - { - return $this->_flattenResourceTree(null, null, 0, 'Mage_Backend', $shortFormat); - } - - /** - * Decorate acl resource tree - * - * @param Varien_Simplexml_Element $resource - * @param null $parentName - * @param string $module - * @return Varien_Simplexml_Element - */ - protected function _walkResourceTree(Varien_Simplexml_Element $resource = null, - $parentName = null, $module = 'Mage_Backend') - { - $resourceName = $parentName; - if (is_null($resource)) { - $resource = $this->getAdminhtmlConfig()->getNode('acl/resources'); - $resourceName = null; - $level = -1; - } else { - if (!$this->_isServiceElement($resource)) { - $resourceName = $this->_buildFullResourceName($resource, $parentName); - //assigning module for its' children nodes - if ($resource->getAttribute('module')) { - $module = (string)$resource->getAttribute('module'); - - } - $resource->addAttribute('aclpath', $resourceName); - $resource->addAttribute('module_c', $module); - } - } - - //check children and run recursion if they exists - $children = $resource->children(); - foreach ($children as $key => $child) { - if (1 == $child->disabled) { - $resource->{$key} = null; - continue; - } - $this->_walkResourceTree($child, $resourceName, $module); - } - return $resource; - } - - /** - * Flatten acl resources tree - * - * @param null|Varien_Simplexml_Element $resource - * @param null $parentName - * @param int $level - * @param string $module - * @param bool $shortFormat - * @return array - */ - protected function _flattenResourceTree(Varien_Simplexml_Element $resource = null, - $parentName = null, $level = 0, $module = 'Mage_Backend', $shortFormat = false) - { - $result = array(); - $resourceName = $parentName; - if (is_null($resource)) { - $resource = $this->getAdminhtmlConfig()->getNode('acl/resources'); - $resourceName = null; - $level = -1; - } else { - if (!$this->_isServiceElement($resource)) { - $resourceName = $this->_buildFullResourceName($resource, $parentName); - - if ($shortFormat) { - $result[] = $resourceName; - } else { - if ($resource->getAttribute('module')) { - $module = (string)$resource->getAttribute('module'); - } - $result[$resourceName]['name'] = $this->_getHelper($module)->__((string)$resource->title); - $result[$resourceName]['level'] = $level; - } - } - } - //check children and run recursion if they exists - $children = $resource->children(); - foreach ($children as $key => $child) { - if (1 == $child->disabled) { - continue; - } - $result = array_merge( - $this->_flattenResourceTree($child, $resourceName, $level + 1, $module, $shortFormat), - $result - ); - } - return $result; - } - - /** - * Check whether provided element is a service element of Admin Xml configuration - * - * @param Varien_Simplexml_Element $resource - * @return bool - */ - protected function _isServiceElement(Varien_Simplexml_Element $resource) - { - return in_array($resource->getName(), array('title', 'sort_order', 'children', 'disabled')); - } - - /** - * Build acl resource name with path to parent - * - * @param Varien_Simplexml_Element $resource - * @param string $path - * @return string - */ - protected function _buildFullResourceName(Varien_Simplexml_Element $resource, $path = null) - { - return (is_null($path) ? '' : $path . '/') . $resource->getName(); - } - - /** - * Get acl assert config - * - * @param string $name - * @return Mage_Core_Model_Config_Element|boolean - */ - public function getAclAssert($name = '') - { - $asserts = $this->getNode("admin/acl/asserts"); - if ('' === $name) { - return $asserts; - } - - if (isset($asserts->$name)) { - return $asserts->$name; - } - - return false; - } - - /** - * Retrieve privilege set by name - * - * @param string $name - * @return Mage_Core_Model_Config_Element|boolean - */ - public function getAclPrivilegeSet($name = '') - { - $sets = $this->getNode("admin/acl/privilegeSets"); - if ('' === $name) { - return $sets; - } - - if (isset($sets->$name)) { - return $sets->$name; - } - - return false; - } - /** * Retrieve xml config * diff --git a/app/code/core/Mage/Admin/Model/Resource/Acl.php b/app/code/core/Mage/Admin/Model/Resource/Acl.php deleted file mode 100755 index c5b8d578521..00000000000 --- a/app/code/core/Mage/Admin/Model/Resource/Acl.php +++ /dev/null @@ -1,171 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @category Mage - * @package Mage_Admin - * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ - - -/** - * Resource model for admin ACL - * - * @category Mage - * @package Mage_Admin - * @author Magento Core Team <core@magentocommerce.com> - */ -class Mage_Admin_Model_Resource_Acl extends Mage_Core_Model_Resource_Db_Abstract -{ - const ACL_ALL_RULES = 'all'; - - /** - * Initialize resource - * - */ - protected function _construct() - { - $this->_init('admin_role', 'role_id'); - } - - /** - * Load ACL for the user - * - * @return Mage_Admin_Model_Acl - */ - public function loadAcl() - { - $acl = Mage::getModel('Mage_Admin_Model_Acl'); - - Mage::getSingleton('Mage_Admin_Model_Config')->loadAclResources($acl); - - $roleTable = $this->getTable('admin_role'); - $ruleTable = $this->getTable('admin_rule'); - $assertTable = $this->getTable('admin_assert'); - - $adapter = $this->_getReadAdapter(); - - $select = $adapter->select() - ->from($roleTable) - ->order('tree_level'); - - $rolesArr = $adapter->fetchAll($select); - - $this->loadRoles($acl, $rolesArr); - - $select = $adapter->select() - ->from(array('r' => $ruleTable)) - ->joinLeft( - array('a' => $assertTable), - 'a.assert_id = r.assert_id', - array('assert_type', 'assert_data') - ); - - $rulesArr = $adapter->fetchAll($select); - - $this->loadRules($acl, $rulesArr); - - return $acl; - } - - /** - * Load roles - * - * @param Mage_Admin_Model_Acl $acl - * @param array $rolesArr - * @return Mage_Admin_Model_Resource_Acl - */ - public function loadRoles(Mage_Admin_Model_Acl $acl, array $rolesArr) - { - foreach ($rolesArr as $role) { - $parent = ($role['parent_id'] > 0) ? Mage_Admin_Model_Acl::ROLE_TYPE_GROUP . $role['parent_id'] : null; - switch ($role['role_type']) { - case Mage_Admin_Model_Acl::ROLE_TYPE_GROUP: - $roleId = $role['role_type'] . $role['role_id']; - $acl->addRole(Mage::getModel('Mage_Admin_Model_Acl_Role_Group', $roleId), $parent); - break; - - case Mage_Admin_Model_Acl::ROLE_TYPE_USER: - $roleId = $role['role_type'] . $role['user_id']; - if (!$acl->hasRole($roleId)) { - $acl->addRole(Mage::getModel('Mage_Admin_Model_Acl_Role_User', $roleId), $parent); - } else { - $acl->addRoleParent($roleId, $parent); - } - break; - } - } - - return $this; - } - - /** - * Load rules - * - * @param Mage_Admin_Model_Acl $acl - * @param array $rulesArr - * @return Mage_Admin_Model_Resource_Acl - */ - public function loadRules(Mage_Admin_Model_Acl $acl, array $rulesArr) - { - foreach ($rulesArr as $rule) { - $role = $rule['role_type'] . $rule['role_id']; - $resource = $rule['resource_id']; - $privileges = !empty($rule['privileges']) ? explode(',', $rule['privileges']) : null; - - $assert = null; - if (0 != $rule['assert_id']) { - $assertClass = Mage::getSingleton('Mage_Admin_Model_Config')->getAclAssert($rule['assert_type'])->getClassName(); - $assert = new $assertClass(unserialize($rule['assert_data'])); - } - try { - if ( $rule['permission'] == 'allow' ) { - if ($resource === self::ACL_ALL_RULES) { - $acl->allow($role, null, $privileges, $assert); - } - $acl->allow($role, $resource, $privileges, $assert); - } else if ( $rule['permission'] == 'deny' ) { - $acl->deny($role, $resource, $privileges, $assert); - } - } catch (Exception $e) { - //$m = $e->getMessage(); - //if ( eregi("^Resource '(.*)' not found", $m) ) { - // Deleting non existent resource rule from rules table - //$cond = $this->_write->quoteInto('resource_id = ?', $resource); - //$this->_write->delete(Mage::getSingleton('Mage_Core_Model_Resource')->getTableName('admin_rule'), $cond); - //} else { - //TODO: We need to log such exceptions to somewhere like a system/errors.log - //} - } - /* - switch ($rule['permission']) { - case Mage_Admin_Model_Acl::RULE_PERM_ALLOW: - $acl->allow($role, $resource, $privileges, $assert); - break; - - case Mage_Admin_Model_Acl::RULE_PERM_DENY: - $acl->deny($role, $resource, $privileges, $assert); - break; - } - */ - } - return $this; - } -} diff --git a/app/code/core/Mage/AdminNotification/etc/adminhtml.xml b/app/code/core/Mage/AdminNotification/etc/adminhtml.xml deleted file mode 100644 index 053695bdc39..00000000000 --- a/app/code/core/Mage/AdminNotification/etc/adminhtml.xml +++ /dev/null @@ -1,63 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License (AFL 3.0) - * that is bundled with this package in the file LICENSE_AFL.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/afl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @category Mage - * @package Mage_AdminNotification - * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - */ ---> -<config> - <acl> - <resources> - <admin> - <children> - <system> - <children> - <adminnotification translate="title" module="Mage_AdminNotification"> - <title>Notifications</title> - <sort_order>10</sort_order> - <children> - <show_toolbar translate="title"> - <title>Show Toolbar</title> - <sort_order>10</sort_order> - </show_toolbar> - <show_list translate="title"> - <title>Show List</title> - <sort_order>20</sort_order> - </show_list> - <mark_as_read translate="title"> - <title>Mark as read</title> - <sort_order>30</sort_order> - </mark_as_read> - <remove translate="title"> - <title>Remove</title> - <sort_order>40</sort_order> - </remove> - </children> - </adminnotification> - </children> - </system> - </children> - </admin> - </resources> - </acl> -</config> diff --git a/app/code/core/Mage/DesignEditor/etc/adminhtml.xml b/app/code/core/Mage/AdminNotification/etc/adminhtml/acl.xml similarity index 55% rename from app/code/core/Mage/DesignEditor/etc/adminhtml.xml rename to app/code/core/Mage/AdminNotification/etc/adminhtml/acl.xml index 23b9c5bbe2d..7fe3ed8ee15 100644 --- a/app/code/core/Mage/DesignEditor/etc/adminhtml.xml +++ b/app/code/core/Mage/AdminNotification/etc/adminhtml/acl.xml @@ -20,7 +20,7 @@ * needs please refer to http://www.magentocommerce.com for more information. * * @category Mage - * @package Mage_DesignEditor + * @package Mage_AdminNotification * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ @@ -28,22 +28,16 @@ <config> <acl> <resources> - <admin> - <children> - <system> - <children> - <design> - <children> - <editor translate="title" module="Mage_DesignEditor"> - <title>Editor</title> - <sort_order>20</sort_order> - </editor> - </children> - </design> - </children> - </system> - </children> - </admin> + <resource id="Mage_Adminhtml::admin"> + <resource id="Mage_Adminhtml::system"> + <resource id="Mage_AdminNotification::adminnotification" module="Mage_AdminNotification" title="Notifications" sortOrder="10"> + <resource id="Mage_AdminNotification::show_toolbar" title="Show Toolbar" sortOrder="10" /> + <resource id="Mage_AdminNotification::show_list" title="Show List" sortOrder="20" /> + <resource id="Mage_AdminNotification::mark_as_read" title="Mark as read" sortOrder="30" /> + <resource id="Mage_AdminNotification::adminnotification_remove" title="Remove" sortOrder="40" /> + </resource> + </resource> + </resource> </resources> </acl> </config> diff --git a/app/code/core/Mage/AdminNotification/etc/adminhtml/menu.xml b/app/code/core/Mage/AdminNotification/etc/adminhtml/menu.xml index a2d90079d57..a7639f05ca7 100644 --- a/app/code/core/Mage/AdminNotification/etc/adminhtml/menu.xml +++ b/app/code/core/Mage/AdminNotification/etc/adminhtml/menu.xml @@ -27,6 +27,6 @@ --> <config> <menu> - <add id="Mage_AdminNotification::system_adminnotification" title="Notifications" module="Mage_AdminNotification" sortOrder="15" parent="Mage_Adminhtml::system" action="adminhtml/notification" /> + <add id="Mage_AdminNotification::system_adminnotification" title="Notifications" module="Mage_AdminNotification" sortOrder="15" parent="Mage_Adminhtml::system" action="adminhtml/notification" resource="Mage_AdminNotification::adminnotification"/> </menu> </config> diff --git a/app/code/core/Mage/Adminhtml/Block/Cache/Notifications.php b/app/code/core/Mage/Adminhtml/Block/Cache/Notifications.php index 87eb9a7bbec..ffc0b7c15ed 100644 --- a/app/code/core/Mage/Adminhtml/Block/Cache/Notifications.php +++ b/app/code/core/Mage/Adminhtml/Block/Cache/Notifications.php @@ -58,7 +58,7 @@ class Mage_Adminhtml_Block_Cache_Notifications extends Mage_Adminhtml_Block_Temp */ protected function _toHtml() { - if (Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('system/cache')) { + if (Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Adminhtml::cache')) { return parent::_toHtml(); } return ''; diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Attributes.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Attributes.php index 777f0daa648..b3cf292a782 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Attributes.php +++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Attributes.php @@ -99,7 +99,7 @@ class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Attributes extends Mage_Admi // Add new attribute button if it is not an image tab if (!$form->getElement('media_gallery') - && Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('catalog/attributes/attributes') + && Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Catalog::attributes_attributes') ) { $headerBar = $this->getLayout()->createBlock('Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Attributes_Create'); diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tabs.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tabs.php index dcff91b8fd8..6962d1cd6fd 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tabs.php +++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tabs.php @@ -146,7 +146,7 @@ class Mage_Adminhtml_Block_Catalog_Product_Edit_Tabs extends Mage_Adminhtml_Bloc if( $this->getRequest()->getParam('id', false) ) { if (Mage::helper('Mage_Catalog_Helper_Data')->isModuleEnabled('Mage_Review')) { - if (Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('admin/catalog/reviews_ratings')){ + if (Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Review::reviews_ratings')){ $this->addTab('reviews', array( 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Product Reviews'), 'url' => $this->getUrl('*/*/reviews', array('_current' => true)), @@ -155,7 +155,7 @@ class Mage_Adminhtml_Block_Catalog_Product_Edit_Tabs extends Mage_Adminhtml_Bloc } } if (Mage::helper('Mage_Catalog_Helper_Data')->isModuleEnabled('Mage_Tag')) { - if (Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('admin/catalog/tag')){ + if (Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Tag::tag')){ $this->addTab('tags', array( 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Product Tags'), 'url' => $this->getUrl('*/*/tagGrid', array('_current' => true)), diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Grid.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Grid.php index cf03bb6b886..b1e05d1488e 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Grid.php +++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Grid.php @@ -301,7 +301,7 @@ class Mage_Adminhtml_Block_Catalog_Product_Grid extends Mage_Adminhtml_Block_Wid ) )); - if (Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('catalog/update_attributes')){ + if (Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Catalog::update_attributes')){ $this->getMassactionBlock()->addItem('attributes', array( 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Update Attributes'), 'url' => $this->getUrl('*/catalog_product_action_attribute/edit', array('_current'=>true)) diff --git a/app/code/core/Mage/Adminhtml/Block/Cms/Page.php b/app/code/core/Mage/Adminhtml/Block/Cms/Page.php index eafcf7cdf84..6827bd3d05a 100644 --- a/app/code/core/Mage/Adminhtml/Block/Cms/Page.php +++ b/app/code/core/Mage/Adminhtml/Block/Cms/Page.php @@ -45,7 +45,7 @@ class Mage_Adminhtml_Block_Cms_Page extends Mage_Adminhtml_Block_Widget_Grid_Con parent::__construct(); - if ($this->_isAllowedAction('save')) { + if ($this->_isAllowedAction('Mage_Cms::save')) { $this->_updateButton('add', 'label', Mage::helper('Mage_Cms_Helper_Data')->__('Add New Page')); } else { $this->_removeButton('add'); @@ -56,12 +56,12 @@ class Mage_Adminhtml_Block_Cms_Page extends Mage_Adminhtml_Block_Widget_Grid_Con /** * Check permission for passed action * - * @param string $action + * @param string $resourceId * @return bool */ - protected function _isAllowedAction($action) + protected function _isAllowedAction($resourceId) { - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('cms/page/' . $action); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed($resourceId); } } diff --git a/app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit.php b/app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit.php index 67a233116ff..b90cfdc7e06 100644 --- a/app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit.php +++ b/app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit.php @@ -45,7 +45,7 @@ class Mage_Adminhtml_Block_Cms_Page_Edit extends Mage_Adminhtml_Block_Widget_For parent::__construct(); - if ($this->_isAllowedAction('save')) { + if ($this->_isAllowedAction('Mage_Cms::save')) { $this->_updateButton('save', 'label', Mage::helper('Mage_Cms_Helper_Data')->__('Save Page')); $this->_addButton('saveandcontinue', array( 'label' => Mage::helper('Mage_Adminhtml_Helper_Data')->__('Save and Continue Edit'), @@ -56,7 +56,7 @@ class Mage_Adminhtml_Block_Cms_Page_Edit extends Mage_Adminhtml_Block_Widget_For $this->_removeButton('save'); } - if ($this->_isAllowedAction('delete')) { + if ($this->_isAllowedAction('Mage_Cms::page_delete')) { $this->_updateButton('delete', 'label', Mage::helper('Mage_Cms_Helper_Data')->__('Delete Page')); } else { $this->_removeButton('delete'); @@ -81,12 +81,12 @@ class Mage_Adminhtml_Block_Cms_Page_Edit extends Mage_Adminhtml_Block_Widget_For /** * Check permission for passed action * - * @param string $action + * @param string $resourceId * @return bool */ - protected function _isAllowedAction($action) + protected function _isAllowedAction($resourceId) { - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('cms/page/' . $action); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed($resourceId); } /** diff --git a/app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/Content.php b/app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/Content.php index 7f85409c4e8..c313a8fa69f 100644 --- a/app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/Content.php +++ b/app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/Content.php @@ -55,7 +55,7 @@ class Mage_Adminhtml_Block_Cms_Page_Edit_Tab_Content /* * Checking if user have permissions to save information */ - if ($this->_isAllowedAction('save')) { + if ($this->_isAllowedAction('Mage_Cms::save')) { $isElementDisabled = false; } else { $isElementDisabled = true; @@ -143,11 +143,11 @@ class Mage_Adminhtml_Block_Cms_Page_Edit_Tab_Content /** * Check permission for passed action * - * @param string $action + * @param string $resourceId * @return bool */ - protected function _isAllowedAction($action) + protected function _isAllowedAction($resourceId) { - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('cms/page/' . $action); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed($resourceId); } } diff --git a/app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/Design.php b/app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/Design.php index 85a733a6e87..b8c103fbbcc 100644 --- a/app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/Design.php +++ b/app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/Design.php @@ -38,7 +38,7 @@ class Mage_Adminhtml_Block_Cms_Page_Edit_Tab_Design /* * Checking if user have permissions to save information */ - if ($this->_isAllowedAction('save')) { + if ($this->_isAllowedAction('Mage_Cms::save')) { $isElementDisabled = false; } else { $isElementDisabled = true; @@ -176,11 +176,11 @@ class Mage_Adminhtml_Block_Cms_Page_Edit_Tab_Design /** * Check permission for passed action * - * @param string $action + * @param string $resourceId * @return bool */ - protected function _isAllowedAction($action) + protected function _isAllowedAction($resourceId) { - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('cms/page/' . $action); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed($resourceId); } } diff --git a/app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/Main.php b/app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/Main.php index 5474f8a4046..f769783d582 100644 --- a/app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/Main.php +++ b/app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/Main.php @@ -44,7 +44,7 @@ class Mage_Adminhtml_Block_Cms_Page_Edit_Tab_Main /* * Checking if user have permissions to save information */ - if ($this->_isAllowedAction('save')) { + if ($this->_isAllowedAction('Mage_Cms::save')) { $isElementDisabled = false; } else { $isElementDisabled = true; @@ -167,11 +167,11 @@ class Mage_Adminhtml_Block_Cms_Page_Edit_Tab_Main /** * Check permission for passed action * - * @param string $action + * @param string $resourceId * @return bool */ - protected function _isAllowedAction($action) + protected function _isAllowedAction($resourceId) { - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('cms/page/' . $action); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed($resourceId); } } diff --git a/app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/Meta.php b/app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/Meta.php index 62ec5041d37..0a0fee0a70b 100644 --- a/app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/Meta.php +++ b/app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/Meta.php @@ -45,7 +45,7 @@ class Mage_Adminhtml_Block_Cms_Page_Edit_Tab_Meta /* * Checking if user have permissions to save information */ - if ($this->_isAllowedAction('save')) { + if ($this->_isAllowedAction('Mage_Cms::save')) { $isElementDisabled = false; } else { $isElementDisabled = true; @@ -125,11 +125,11 @@ class Mage_Adminhtml_Block_Cms_Page_Edit_Tab_Meta /** * Check permission for passed action * - * @param string $action + * @param string $resourceId * @return bool */ - protected function _isAllowedAction($action) + protected function _isAllowedAction($resourceId) { - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('cms/page/' . $action); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed($resourceId); } } diff --git a/app/code/core/Mage/Adminhtml/Block/Customer/Edit.php b/app/code/core/Mage/Adminhtml/Block/Customer/Edit.php index 341631132c9..925ca5a6306 100644 --- a/app/code/core/Mage/Adminhtml/Block/Customer/Edit.php +++ b/app/code/core/Mage/Adminhtml/Block/Customer/Edit.php @@ -39,7 +39,7 @@ class Mage_Adminhtml_Block_Customer_Edit extends Mage_Adminhtml_Block_Widget_For $this->_controller = 'customer'; if ($this->getCustomerId() && - Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('sales/order/actions/create')) { + Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Sales::create')) { $this->_addButton('order', array( 'label' => Mage::helper('Mage_Customer_Helper_Data')->__('Create Order'), 'onclick' => 'setLocation(\'' . $this->getCreateOrderUrl() . '\')', diff --git a/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tabs.php b/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tabs.php index 810fe9a7790..bc01c9afb97 100644 --- a/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tabs.php +++ b/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tabs.php @@ -71,7 +71,7 @@ class Mage_Adminhtml_Block_Customer_Edit_Tabs extends Mage_Adminhtml_Block_Widge if (Mage::registry('current_customer')->getId()) { - if (Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('sales/order/actions/view')) { + if (Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Sales::actions_view')) { $this->addTab('orders', array( 'label' => Mage::helper('Mage_Customer_Helper_Data')->__('Orders'), 'class' => 'ajax', @@ -91,7 +91,7 @@ class Mage_Adminhtml_Block_Customer_Edit_Tabs extends Mage_Adminhtml_Block_Widge 'url' => $this->getUrl('*/*/wishlist', array('_current' => true)), )); - if (Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('newsletter/subscriber')) { + if (Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Newsletter::subscriber')) { $this->addTab('newsletter', array( 'label' => Mage::helper('Mage_Customer_Helper_Data')->__('Newsletter'), 'content' => $this->getLayout() @@ -99,7 +99,7 @@ class Mage_Adminhtml_Block_Customer_Edit_Tabs extends Mage_Adminhtml_Block_Widge )); } - if (Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('catalog/reviews_ratings')) { + if (Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Review::reviews_ratings')) { $this->addTab('reviews', array( 'label' => Mage::helper('Mage_Customer_Helper_Data')->__('Product Reviews'), 'class' => 'ajax', @@ -107,7 +107,7 @@ class Mage_Adminhtml_Block_Customer_Edit_Tabs extends Mage_Adminhtml_Block_Widge )); } - if (Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('catalog/tag')) { + if (Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Tag::tag')) { $this->addTab('tags', array( 'label' => Mage::helper('Mage_Customer_Helper_Data')->__('Product Tags'), 'class' => 'ajax', diff --git a/app/code/core/Mage/Adminhtml/Block/Customer/Online/Grid.php b/app/code/core/Mage/Adminhtml/Block/Customer/Online/Grid.php index 2214c3a6203..1853da19aaa 100644 --- a/app/code/core/Mage/Adminhtml/Block/Customer/Online/Grid.php +++ b/app/code/core/Mage/Adminhtml/Block/Customer/Online/Grid.php @@ -160,7 +160,7 @@ class Mage_Adminhtml_Block_Customer_Online_Grid extends Mage_Adminhtml_Block_Wid */ public function getRowUrl($row) { - return (Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('customer/manage') && $row->getCustomerId()) + return (Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Customer::manage') && $row->getCustomerId()) ? $this->getUrl('*/customer/edit', array('id' => $row->getCustomerId())) : ''; } } diff --git a/app/code/core/Mage/Adminhtml/Block/Notification/Survey.php b/app/code/core/Mage/Adminhtml/Block/Notification/Survey.php index 1131e9c004e..69f0bd17626 100644 --- a/app/code/core/Mage/Adminhtml/Block/Notification/Survey.php +++ b/app/code/core/Mage/Adminhtml/Block/Notification/Survey.php @@ -42,7 +42,8 @@ class Mage_Adminhtml_Block_Notification_Survey extends Mage_Adminhtml_Block_Temp { $adminSession = Mage::getSingleton('Mage_Backend_Model_Auth_Session'); $seconds = intval(date('s', time())); - if ($adminSession->getHideSurveyQuestion() || !$adminSession->isAllowed('all') + if ($adminSession->getHideSurveyQuestion() + || !$adminSession->isAllowed(Mage_Backend_Model_Acl_Config::ACL_RESOURCE_ALL) || Mage_AdminNotification_Model_Survey::isSurveyViewed() || !Mage_AdminNotification_Model_Survey::isSurveyUrlValid()) { diff --git a/app/code/core/Mage/Adminhtml/Block/Notification/Window.php b/app/code/core/Mage/Adminhtml/Block/Notification/Window.php index 64f9bd393b5..a1b8641f981 100644 --- a/app/code/core/Mage/Adminhtml/Block/Notification/Window.php +++ b/app/code/core/Mage/Adminhtml/Block/Notification/Window.php @@ -173,6 +173,6 @@ class Mage_Adminhtml_Block_Notification_Window extends Mage_Adminhtml_Block_Noti protected function _isAllowed() { return Mage::getSingleton('Mage_Backend_Model_Auth_Session') - ->isAllowed('admin/system/adminnotification/show_toolbar'); + ->isAllowed('Mage_AdminNotification::show_toolbar'); } } diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Creditmemo/Grid.php b/app/code/core/Mage/Adminhtml/Block/Sales/Creditmemo/Grid.php index d9dd5b2b94e..9f0e120df89 100644 --- a/app/code/core/Mage/Adminhtml/Block/Sales/Creditmemo/Grid.php +++ b/app/code/core/Mage/Adminhtml/Block/Sales/Creditmemo/Grid.php @@ -144,7 +144,9 @@ class Mage_Adminhtml_Block_Sales_Creditmemo_Grid extends Mage_Adminhtml_Block_Wi public function getRowUrl($row) { - if (!Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('sales/order/creditmemo')) { + if (!Mage::getSingleton('Mage_Backend_Model_Auth_Session') + ->isAllowed(Mage_Backend_Model_Acl_Config::ACL_RESOURCE_ALL) + ) { return false; } diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Invoice/Grid.php b/app/code/core/Mage/Adminhtml/Block/Sales/Invoice/Grid.php index 94a501eeb10..11bba3e79f8 100644 --- a/app/code/core/Mage/Adminhtml/Block/Sales/Invoice/Grid.php +++ b/app/code/core/Mage/Adminhtml/Block/Sales/Invoice/Grid.php @@ -145,7 +145,9 @@ class Mage_Adminhtml_Block_Sales_Invoice_Grid extends Mage_Adminhtml_Block_Widge public function getRowUrl($row) { - if (!Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('sales/order/invoice')) { + if (!Mage::getSingleton('Mage_Backend_Model_Auth_Session') + ->isAllowed(Mage_Backend_Model_Acl_Config::ACL_RESOURCE_ALL) + ) { return false; } diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Items/Abstract.php b/app/code/core/Mage/Adminhtml/Block/Sales/Items/Abstract.php index 4d94f3938a6..d4511a3c948 100644 --- a/app/code/core/Mage/Adminhtml/Block/Sales/Items/Abstract.php +++ b/app/code/core/Mage/Adminhtml/Block/Sales/Items/Abstract.php @@ -486,7 +486,7 @@ class Mage_Adminhtml_Block_Sales_Items_Abstract extends Mage_Adminhtml_Block_Te public function canCapture() { - if (Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('sales/order/actions/capture')) { + if (Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Sales::capture')) { return $this->getInvoice()->canCapture(); } return false; diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order.php b/app/code/core/Mage/Adminhtml/Block/Sales/Order.php index 23d89f763f0..4e69ae3a1f2 100644 --- a/app/code/core/Mage/Adminhtml/Block/Sales/Order.php +++ b/app/code/core/Mage/Adminhtml/Block/Sales/Order.php @@ -40,7 +40,7 @@ class Mage_Adminhtml_Block_Sales_Order extends Mage_Adminhtml_Block_Widget_Grid_ $this->_headerText = Mage::helper('Mage_Sales_Helper_Data')->__('Orders'); $this->_addButtonLabel = Mage::helper('Mage_Sales_Helper_Data')->__('Create New Order'); parent::__construct(); - if (!Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('sales/order/actions/create')) { + if (!Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Sales::create')) { $this->_removeButton('add'); } } diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Creditmemo/View.php b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Creditmemo/View.php index a4a92b1c5f0..eca52226a3a 100644 --- a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Creditmemo/View.php +++ b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Creditmemo/View.php @@ -63,7 +63,7 @@ class Mage_Adminhtml_Block_Sales_Order_Creditmemo_View extends Mage_Adminhtml_Bl ); } - if ($this->_isAllowedAction('emails')) { + if ($this->_isAllowedAction('Mage_Sales::emails')) { $this->addButton('send_notification', array( 'label' => Mage::helper('Mage_Sales_Helper_Data')->__('Send Email'), 'onclick' => 'confirmSetLocation(\'' @@ -224,11 +224,11 @@ class Mage_Adminhtml_Block_Sales_Order_Creditmemo_View extends Mage_Adminhtml_Bl /** * Check whether action is allowed * - * @param string $action + * @param string $resourceId * @return bool */ - public function _isAllowedAction($action) + public function _isAllowedAction($resourceId) { - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('sales/order/actions/' . $action); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed($resourceId); } } diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Grid.php b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Grid.php index ecfc3bf379d..86281a96448 100644 --- a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Grid.php +++ b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Grid.php @@ -120,7 +120,7 @@ class Mage_Adminhtml_Block_Sales_Order_Grid extends Mage_Adminhtml_Block_Widget_ 'options' => Mage::getSingleton('Mage_Sales_Model_Order_Config')->getStatuses(), )); - if (Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('sales/order/actions/view')) { + if (Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Sales::actions_view')) { $this->addColumn('action', array( 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Action'), @@ -154,21 +154,21 @@ class Mage_Adminhtml_Block_Sales_Order_Grid extends Mage_Adminhtml_Block_Widget_ $this->getMassactionBlock()->setFormFieldName('order_ids'); $this->getMassactionBlock()->setUseSelectAll(false); - if (Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('sales/order/actions/cancel')) { + if (Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Sales::cancel')) { $this->getMassactionBlock()->addItem('cancel_order', array( 'label'=> Mage::helper('Mage_Sales_Helper_Data')->__('Cancel'), 'url' => $this->getUrl('*/sales_order/massCancel'), )); } - if (Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('sales/order/actions/hold')) { + if (Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Sales::hold')) { $this->getMassactionBlock()->addItem('hold_order', array( 'label'=> Mage::helper('Mage_Sales_Helper_Data')->__('Hold'), 'url' => $this->getUrl('*/sales_order/massHold'), )); } - if (Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('sales/order/actions/unhold')) { + if (Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Sales::unhold')) { $this->getMassactionBlock()->addItem('unhold_order', array( 'label'=> Mage::helper('Mage_Sales_Helper_Data')->__('Unhold'), 'url' => $this->getUrl('*/sales_order/massUnhold'), @@ -205,7 +205,7 @@ class Mage_Adminhtml_Block_Sales_Order_Grid extends Mage_Adminhtml_Block_Widget_ public function getRowUrl($row) { - if (Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('sales/order/actions/view')) { + if (Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Sales::actions_view')) { return $this->getUrl('*/sales_order/view', array('order_id' => $row->getId())); } return false; diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Invoice/Create/Items.php b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Invoice/Create/Items.php index 0b751e85087..18544652eb4 100644 --- a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Invoice/Create/Items.php +++ b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Invoice/Create/Items.php @@ -194,7 +194,7 @@ class Mage_Adminhtml_Block_Sales_Order_Invoice_Create_Items extends Mage_Adminht */ public function isCaptureAllowed() { - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('sales/order/actions/capture'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Sales::capture'); } /** diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Invoice/View.php b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Invoice/View.php index 062632d0774..72351ebedab 100644 --- a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Invoice/View.php +++ b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Invoice/View.php @@ -57,7 +57,7 @@ class Mage_Adminhtml_Block_Sales_Order_Invoice_View extends Mage_Adminhtml_Block return; } - if ($this->_isAllowedAction('cancel') && $this->getInvoice()->canCancel()) { + if ($this->_isAllowedAction('Mage_Sales::cancel') && $this->getInvoice()->canCancel()) { $this->_addButton('cancel', array( 'label' => Mage::helper('Mage_Sales_Helper_Data')->__('Cancel'), 'class' => 'delete', @@ -66,7 +66,7 @@ class Mage_Adminhtml_Block_Sales_Order_Invoice_View extends Mage_Adminhtml_Block ); } - if ($this->_isAllowedAction('emails')) { + if ($this->_isAllowedAction('Mage_Sales::emails')) { $this->addButton('send_notification', array( 'label' => Mage::helper('Mage_Sales_Helper_Data')->__('Send Email'), 'onclick' => 'confirmSetLocation(\'' @@ -77,7 +77,7 @@ class Mage_Adminhtml_Block_Sales_Order_Invoice_View extends Mage_Adminhtml_Block $orderPayment = $this->getInvoice()->getOrder()->getPayment(); - if ($this->_isAllowedAction('creditmemo') && $this->getInvoice()->getOrder()->canCreditmemo()) { + if ($this->_isAllowedAction('Mage_Sales::creditmemo') && $this->getInvoice()->getOrder()->canCreditmemo()) { if (($orderPayment->canRefundPartialPerInvoice() && $this->getInvoice()->canRefund() && $orderPayment->getAmountPaid() > $orderPayment->getAmountRefunded()) @@ -91,7 +91,7 @@ class Mage_Adminhtml_Block_Sales_Order_Invoice_View extends Mage_Adminhtml_Block } } - if ($this->_isAllowedAction('capture') && $this->getInvoice()->canCapture()) { + if ($this->_isAllowedAction('Mage_Sales::capture') && $this->getInvoice()->canCapture()) { $this->_addButton('capture', array( 'label' => Mage::helper('Mage_Sales_Helper_Data')->__('Capture'), 'class' => 'save', @@ -202,11 +202,11 @@ class Mage_Adminhtml_Block_Sales_Order_Invoice_View extends Mage_Adminhtml_Block /** * Check whether is allowed action * - * @param string $action + * @param string $resourceId * @return bool */ - protected function _isAllowedAction($action) + protected function _isAllowedAction($resourceId) { - return $this->_session->isAllowed('sales/order/actions/' . $action); + return $this->_session->isAllowed($resourceId); } } diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Shipment/View.php b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Shipment/View.php index 5ca4ce0c8ad..7622144c62c 100644 --- a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Shipment/View.php +++ b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Shipment/View.php @@ -48,7 +48,7 @@ class Mage_Adminhtml_Block_Sales_Order_Shipment_View extends Mage_Adminhtml_Bloc return; } - if (Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('sales/order/actions/emails')) { + if (Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Sales::emails')) { $this->_updateButton('save', 'label', Mage::helper('Mage_Sales_Helper_Data')->__('Send Tracking Information')); $this->_updateButton('save', 'onclick', "deleteConfirm('" diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/View.php b/app/code/core/Mage/Adminhtml/Block/Sales/Order/View.php index 6a40995e649..2cd03218ead 100644 --- a/app/code/core/Mage/Adminhtml/Block/Sales/Order/View.php +++ b/app/code/core/Mage/Adminhtml/Block/Sales/Order/View.php @@ -52,7 +52,7 @@ class Mage_Adminhtml_Block_Sales_Order_View extends Mage_Adminhtml_Block_Widget_ return; } - if ($this->_isAllowedAction('edit') && $order->canEdit()) { + if ($this->_isAllowedAction('Mage_Sales::actions_edit') && $order->canEdit()) { $onclickJs = 'deleteConfirm(\'' . Mage::helper('Mage_Sales_Helper_Data')->__('Are you sure? This order will be canceled and a new one will be created instead') . '\', \'' . $this->getEditUrl() . '\');'; @@ -77,7 +77,7 @@ class Mage_Adminhtml_Block_Sales_Order_View extends Mage_Adminhtml_Block_Widget_ } } - if ($this->_isAllowedAction('cancel') && $order->canCancel()) { + if ($this->_isAllowedAction('Mage_Sales::cancel') && $order->canCancel()) { $message = Mage::helper('Mage_Sales_Helper_Data')->__('Are you sure you want to cancel this order?'); $this->_addButton('order_cancel', array( 'label' => Mage::helper('Mage_Sales_Helper_Data')->__('Cancel'), @@ -85,7 +85,7 @@ class Mage_Adminhtml_Block_Sales_Order_View extends Mage_Adminhtml_Block_Widget_ )); } - if ($this->_isAllowedAction('emails') && !$order->isCanceled()) { + if ($this->_isAllowedAction('Mage_Sales::emails') && !$order->isCanceled()) { $message = Mage::helper('Mage_Sales_Helper_Data')->__('Are you sure you want to send order email to customer?'); $this->addButton('send_notification', array( 'label' => Mage::helper('Mage_Sales_Helper_Data')->__('Send Email'), @@ -93,7 +93,7 @@ class Mage_Adminhtml_Block_Sales_Order_View extends Mage_Adminhtml_Block_Widget_ )); } - if ($this->_isAllowedAction('creditmemo') && $order->canCreditmemo()) { + if ($this->_isAllowedAction('Mage_Sales::creditmemo') && $order->canCreditmemo()) { $message = Mage::helper('Mage_Sales_Helper_Data')->__('This will create an offline refund. To create an online refund, open an invoice and create credit memo for it. Do you wish to proceed?'); $onClick = "setLocation('{$this->getCreditmemoUrl()}')"; if ($order->getPayment()->getMethodInstance()->isGateway()) { @@ -107,7 +107,7 @@ class Mage_Adminhtml_Block_Sales_Order_View extends Mage_Adminhtml_Block_Widget_ } // invoice action intentionally - if ($this->_isAllowedAction('invoice') && $order->canVoidPayment()) { + if ($this->_isAllowedAction('Mage_Sales::invoice') && $order->canVoidPayment()) { $message = Mage::helper('Mage_Sales_Helper_Data')->__('Are you sure you want to void the payment?'); $this->addButton('void_payment', array( 'label' => Mage::helper('Mage_Sales_Helper_Data')->__('Void'), @@ -115,21 +115,21 @@ class Mage_Adminhtml_Block_Sales_Order_View extends Mage_Adminhtml_Block_Widget_ )); } - if ($this->_isAllowedAction('hold') && $order->canHold()) { + if ($this->_isAllowedAction('Mage_Sales::hold') && $order->canHold()) { $this->_addButton('order_hold', array( 'label' => Mage::helper('Mage_Sales_Helper_Data')->__('Hold'), 'onclick' => 'setLocation(\'' . $this->getHoldUrl() . '\')', )); } - if ($this->_isAllowedAction('unhold') && $order->canUnhold()) { + if ($this->_isAllowedAction('Mage_Sales::unhold') && $order->canUnhold()) { $this->_addButton('order_unhold', array( 'label' => Mage::helper('Mage_Sales_Helper_Data')->__('Unhold'), 'onclick' => 'setLocation(\'' . $this->getUnholdUrl() . '\')', )); } - if ($this->_isAllowedAction('review_payment')) { + if ($this->_isAllowedAction('Mage_Sales::review_payment')) { if ($order->canReviewPayment()) { $message = Mage::helper('Mage_Sales_Helper_Data')->__('Are you sure you want to accept this payment?'); $this->_addButton('accept_payment', array( @@ -150,7 +150,7 @@ class Mage_Adminhtml_Block_Sales_Order_View extends Mage_Adminhtml_Block_Widget_ } } - if ($this->_isAllowedAction('invoice') && $order->canInvoice()) { + if ($this->_isAllowedAction('Mage_Sales::invoice') && $order->canInvoice()) { $_label = $order->getForcedShipmentWithInvoice() ? Mage::helper('Mage_Sales_Helper_Data')->__('Invoice and Ship') : Mage::helper('Mage_Sales_Helper_Data')->__('Invoice'); @@ -161,7 +161,7 @@ class Mage_Adminhtml_Block_Sales_Order_View extends Mage_Adminhtml_Block_Widget_ )); } - if ($this->_isAllowedAction('ship') && $order->canShip() + if ($this->_isAllowedAction('Mage_Sales::ship') && $order->canShip() && !$order->getForcedShipmentWithInvoice()) { $this->_addButton('order_ship', array( 'label' => Mage::helper('Mage_Sales_Helper_Data')->__('Ship'), @@ -170,7 +170,7 @@ class Mage_Adminhtml_Block_Sales_Order_View extends Mage_Adminhtml_Block_Widget_ )); } - if ($this->_isAllowedAction('reorder') + if ($this->_isAllowedAction('Mage_Sales::reorder') && $this->helper('Mage_Sales_Helper_Reorder')->isAllowed($order->getStore()) && $order->canReorderIgnoreSalable() ) { @@ -276,9 +276,9 @@ class Mage_Adminhtml_Block_Sales_Order_View extends Mage_Adminhtml_Block_Widget_ return $this->getUrl('*/*/voidPayment'); } - protected function _isAllowedAction($action) + protected function _isAllowedAction($resourceId) { - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('sales/order/actions/' . $action); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed($resourceId); } /** diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/View/History.php b/app/code/core/Mage/Adminhtml/Block/Sales/Order/View/History.php index 41ca46afe19..a5a1a184751 100644 --- a/app/code/core/Mage/Adminhtml/Block/Sales/Order/View/History.php +++ b/app/code/core/Mage/Adminhtml/Block/Sales/Order/View/History.php @@ -70,7 +70,7 @@ class Mage_Adminhtml_Block_Sales_Order_View_History extends Mage_Adminhtml_Block public function canAddComment() { - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('sales/order/actions/comment') && + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Sales::comment') && $this->getOrder()->canComment(); } diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/View/Tab/Transactions.php b/app/code/core/Mage/Adminhtml/Block/Sales/Order/View/Tab/Transactions.php index 1866cf772b8..04d80a76047 100644 --- a/app/code/core/Mage/Adminhtml/Block/Sales/Order/View/Tab/Transactions.php +++ b/app/code/core/Mage/Adminhtml/Block/Sales/Order/View/Tab/Transactions.php @@ -93,6 +93,6 @@ class Mage_Adminhtml_Block_Sales_Order_View_Tab_Transactions */ public function isHidden() { - return !Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('sales/transactions/fetch'); + return !Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Sales::transactions_fetch'); } } diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Shipment/Grid.php b/app/code/core/Mage/Adminhtml/Block/Sales/Shipment/Grid.php index d4ee4897037..5b5b8cb0ad2 100644 --- a/app/code/core/Mage/Adminhtml/Block/Sales/Shipment/Grid.php +++ b/app/code/core/Mage/Adminhtml/Block/Sales/Shipment/Grid.php @@ -139,7 +139,9 @@ class Mage_Adminhtml_Block_Sales_Shipment_Grid extends Mage_Adminhtml_Block_Widg */ public function getRowUrl($row) { - if (!Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('sales/order/shipment')) { + if (!Mage::getSingleton('Mage_Backend_Model_Auth_Session') + ->isAllowed(Mage_Backend_Model_Acl_Config::ACL_RESOURCE_ALL) + ) { return false; } diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Transactions/Detail.php b/app/code/core/Mage/Adminhtml/Block/Sales/Transactions/Detail.php index c6d421d436a..b2aaab310f1 100644 --- a/app/code/core/Mage/Adminhtml/Block/Sales/Transactions/Detail.php +++ b/app/code/core/Mage/Adminhtml/Block/Sales/Transactions/Detail.php @@ -60,7 +60,7 @@ class Mage_Adminhtml_Block_Sales_Transactions_Detail extends Mage_Adminhtml_Bloc 'class' => 'back' )); - if (Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('sales/transactions/fetch') + if (Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Sales::transactions_fetch') && $this->_txn->getOrderPaymentObject()->getMethodInstance()->canFetchTransactionInfo()) { $fetchUrl = $this->getUrl('*/*/fetch' , array('_current' => true)); $this->_addButton('fetch', array( diff --git a/app/code/core/Mage/Adminhtml/Block/System/Config/Form.php b/app/code/core/Mage/Adminhtml/Block/System/Config/Form.php index 52d0a381ea1..e7d3032a4a5 100644 --- a/app/code/core/Mage/Adminhtml/Block/System/Config/Form.php +++ b/app/code/core/Mage/Adminhtml/Block/System/Config/Form.php @@ -167,52 +167,7 @@ class Mage_Adminhtml_Block_System_Config_Form extends Mage_Adminhtml_Block_Widge continue; } - if ($group->frontend_model) { - $fieldsetRenderer = Mage::getBlockSingleton((string)$group->frontend_model); - } else { - $fieldsetRenderer = $this->_defaultFieldsetRenderer; - } - - $fieldsetRenderer->setForm($this); - $fieldsetRenderer->setConfigData($this->_configData); - $fieldsetRenderer->setGroup($group); - - if ($this->_configFields->hasChildren($group, $this->getWebsiteCode(), $this->getStoreCode())) { - - $helperName = $this->_configFields->getAttributeModule($section, $group); - - $fieldsetConfig = array('legend' => Mage::helper($helperName)->__((string)$group->label)); - if (!empty($group->comment)) { - $fieldsetConfig['comment'] = Mage::helper($helperName)->__((string)$group->comment); - } - if (!empty($group->expanded)) { - $fieldsetConfig['expanded'] = (bool)$group->expanded; - } - - $fieldset = $form->addFieldset( - $section->getName() . '_' . $group->getName(), $fieldsetConfig) - ->setRenderer($fieldsetRenderer); - $this->_prepareFieldOriginalData($fieldset, $group); - $this->_addElementTypes($fieldset); - - if ($group->clone_fields) { - if ($group->clone_model) { - $cloneModel = Mage::getModel((string)$group->clone_model); - } else { - Mage::throwException( - 'Config form fieldset clone model required to be able to clone fields' - ); - } - foreach ($cloneModel->getPrefixes() as $prefix) { - $this->initFields($fieldset, $group, $section, $prefix['field'], $prefix['label']); - } - } else { - $this->initFields($fieldset, $group, $section); - } - - $this->_fieldsets[$group->getName()] = $fieldset; - - } + $this->_initGroup($group, $section, $form); } } } @@ -221,6 +176,62 @@ class Mage_Adminhtml_Block_System_Config_Form extends Mage_Adminhtml_Block_Widge return $this; } + /** + * Initialize element group + * + * @param Varien_SimpleXml_Element $group + * @param Varien_SimpleXml_Element $section + * @param Varien_Data_Form $form + */ + protected function _initGroup($group, $section, $form) + { + if ($group->frontend_model) { + $fieldsetRenderer = Mage::getBlockSingleton((string)$group->frontend_model); + } else { + $fieldsetRenderer = $this->_defaultFieldsetRenderer; + } + + $fieldsetRenderer->setForm($this); + $fieldsetRenderer->setConfigData($this->_configData); + $fieldsetRenderer->setGroup($group); + + if ($this->_configFields->hasChildren($group, $this->getWebsiteCode(), $this->getStoreCode())) { + + $helperName = $this->_configFields->getAttributeModule($section, $group); + + $fieldsetConfig = array('legend' => Mage::helper($helperName)->__((string)$group->label)); + if (!empty($group->comment)) { + $fieldsetConfig['comment'] = Mage::helper($helperName)->__((string)$group->comment); + } + if (!empty($group->expanded)) { + $fieldsetConfig['expanded'] = (bool)$group->expanded; + } + + $fieldset = $form->addFieldset( + $section->getName() . '_' . $group->getName(), $fieldsetConfig) + ->setRenderer($fieldsetRenderer); + $this->_prepareFieldOriginalData($fieldset, $group); + $this->_addElementTypes($fieldset); + + if ($group->clone_fields) { + if ($group->clone_model) { + $cloneModel = Mage::getModel((string)$group->clone_model); + } else { + Mage::throwException( + 'Config form fieldset clone model required to be able to clone fields' + ); + } + foreach ($cloneModel->getPrefixes() as $prefix) { + $this->initFields($fieldset, $group, $section, $prefix['field'], $prefix['label']); + } + } else { + $this->initFields($fieldset, $group, $section); + } + + $this->_fieldsets[$group->getName()] = $fieldset; + } + } + /** * Return dependency block object * @@ -256,27 +267,20 @@ class Mage_Adminhtml_Block_System_Config_Form extends Mage_Adminhtml_Block_Widge foreach ($group->fields as $elements) { - $elements = (array)$elements; // sort either by sort_order or by child node values bypassing the sort_order - if ($group->sort_fields && $group->sort_fields->by) { - $fieldset->setSortElementsByAttribute((string)$group->sort_fields->by, - ($group->sort_fields->direction_desc ? SORT_DESC : SORT_ASC) - ); - } else { - usort($elements, array($this, '_sortForm')); - } + $elements = $this->_sortElements($group, $fieldset, (array) $elements); - foreach ($elements as $e) { - if (!$this->_canShowField($e)) { + foreach ($elements as $element) { + if (!$this->_canShowField($element)) { continue; } /** * Look for custom defined field path */ - $path = (string)$e->config_path; + $path = (string)$element->config_path; if (empty($path)) { - $path = $section->getName() . '/' . $group->getName() . '/' . $fieldPrefix . $e->getName(); + $path = $section->getName() . '/' . $group->getName() . '/' . $fieldPrefix . $element->getName(); } elseif (strrpos($path, '/') > 0) { // Extend config data with new section group $groupPath = substr($path, 0, strrpos($path, '/')); @@ -290,151 +294,249 @@ class Mage_Adminhtml_Block_System_Config_Form extends Mage_Adminhtml_Block_Widge } } - $id = $section->getName() . '_' . $group->getName() . '_' . $fieldPrefix . $e->getName(); + $this->_initElement($element, $fieldset, $group, $section, $path, $fieldPrefix, $labelPrefix); + } + } + return $this; + } - if (array_key_exists($path, $this->_configData)) { - $data = $this->_configData[$path]; - $inherit = false; - } else { - $data = $this->_configRoot->descend($path); - $inherit = true; - } - if ($e->frontend_model) { - $fieldRenderer = Mage::getBlockSingleton((string)$e->frontend_model); - } else { - $fieldRenderer = $this->_defaultFieldRenderer; - } + /** + * @param Varien_SimpleXml_Element $group + * @param Varien_Data_Form_Element_Fieldset $fieldset + * @param array $elements + * @return mixed + */ + protected function _sortElements($group, $fieldset, $elements) + { + if ($group->sort_fields && $group->sort_fields->by) { + $fieldset->setSortElementsByAttribute((string)$group->sort_fields->by, + ($group->sort_fields->direction_desc ? SORT_DESC : SORT_ASC) + ); + } else { + usort($elements, array($this, '_sortForm')); + } + return $elements; + } - $fieldRenderer->setForm($this); - $fieldRenderer->setConfigData($this->_configData); + /** + * Initialize form element + * + * @param Varien_Data_Form_Element_Abstract $element + * @param Varien_Data_Form_Element_Fieldset $fieldset + * @param Varien_SimpleXml_Element $group + * @param Varien_SimpleXml_Element $section + * @param string $path + * @param string $fieldPrefix + * @param string $labelPrefix + */ + protected function _initElement($element, $fieldset, $group, $section, $path, $fieldPrefix = '', $labelPrefix = '') + { + $elementId = $section->getName() . '_' . $group->getName() . '_' . $fieldPrefix . $element->getName(); + + if (array_key_exists($path, $this->_configData)) { + $data = $this->_configData[$path]; + $inherit = false; + } else { + $data = $this->_configRoot->descend($path); + $inherit = true; + } + $fieldRenderer = $this->_getFieldRenderer($element); - $helperName = $this->_configFields->getAttributeModule($section, $group, $e); - $fieldType = (string)$e->frontend_type ? (string)$e->frontend_type : 'text'; - $name = 'groups['.$group->getName().'][fields]['.$fieldPrefix.$e->getName().'][value]'; - $label = Mage::helper($helperName)->__($labelPrefix).' '.Mage::helper($helperName)->__((string)$e->label); - $hint = (string)$e->hint ? Mage::helper($helperName)->__((string)$e->hint) : ''; + $fieldRenderer->setForm($this); + $fieldRenderer->setConfigData($this->_configData); - if ($e->backend_model) { - $model = Mage::getModel((string)$e->backend_model); - if (!$model instanceof Mage_Core_Model_Config_Data) { - Mage::throwException('Invalid config field backend model: '.(string)$e->backend_model); - } - $model->setPath($path) - ->setValue($data) - ->setWebsite($this->getWebsiteCode()) - ->setStore($this->getStoreCode()) - ->afterLoad(); - $data = $model->getValue(); - } + $helperName = $this->_configFields->getAttributeModule($section, $group, $element); + $fieldType = (string)$element->frontend_type ? (string)$element->frontend_type : 'text'; + $name = 'groups[' . $group->getName() . '][fields][' . $fieldPrefix . $element->getName() . '][value]'; + $label = Mage::helper($helperName)->__($labelPrefix) . ' ' . Mage::helper($helperName)->__((string)$element->label); + $hint = (string)$element->hint ? Mage::helper($helperName)->__((string)$element->hint) : ''; - $comment = $this->_prepareFieldComment($e, $helperName, $data); - $tooltip = $this->_prepareFieldTooltip($e, $helperName); - - if ($e->depends) { - foreach ($e->depends->children() as $dependent) { - /* @var $dependent Mage_Core_Model_Config_Element */ - $dependentId = $section->getName() - . '_' . $group->getName() - . '_' . $fieldPrefix - . $dependent->getName(); - $shouldBeAddedDependence = true; - $dependentValue = (string) $dependent; - if (isset($dependent['separator'])) { - $dependentValue = explode((string)$dependent['separator'], $dependentValue); - } - $dependentFieldName = $fieldPrefix . $dependent->getName(); - $dependentField = $group->fields->$dependentFieldName; - /* - * If dependent field can't be shown in current scope and real dependent config value - * is not equal to preferred one, then hide dependence fields by adding dependence - * based on not shown field (not rendered field) - */ - if (!$this->_canShowField($dependentField)) { - $dependentFullPath = $section->getName() - . '/' . $group->getName() - . '/' . $fieldPrefix - . $dependent->getName(); - $dependentValueInStore = Mage::getStoreConfig($dependentFullPath, $this->getStoreCode()); - if (is_array($dependentValue)) { - $shouldBeAddedDependence = !in_array($dependentValueInStore, $dependentValue); - } else { - $shouldBeAddedDependence = $dependentValue != $dependentValueInStore; - } - } - if($shouldBeAddedDependence) { - $this->_getDependence() - ->addFieldMap($id, $id) - ->addFieldMap($dependentId, $dependentId) - ->addFieldDependence($id, $dependentId, $dependentValue); - } - } - } + if ($element->backend_model) { + $data = $this->_fetchBackendModelData($element, $path, $data); + } - $field = $fieldset->addField($id, $fieldType, array( - 'name' => $name, - 'label' => $label, - 'comment' => $comment, - 'tooltip' => $tooltip, - 'hint' => $hint, - 'value' => $data, - 'inherit' => $inherit, - 'class' => $e->frontend_class, - 'field_config' => $e, - 'scope' => $this->getScope(), - 'scope_id' => $this->getScopeId(), - 'scope_label' => $this->getScopeLabel($e), - 'can_use_default_value' => $this->canUseDefaultValue((int)$e->show_in_default), - 'can_use_website_value' => $this->canUseWebsiteValue((int)$e->show_in_website), - )); - $this->_prepareFieldOriginalData($field, $e); - - if (isset($e->validate)) { - $field->addClass($e->validate); - } + $comment = $this->_prepareFieldComment($element, $helperName, $data); + $tooltip = $this->_prepareFieldTooltip($element, $helperName); + + if ($element->depends) { + $this->_processElementDependencies($element, $section, $group, $elementId, $fieldPrefix); + } + + $field = $fieldset->addField($elementId, $fieldType, array( + 'name' => $name, + 'label' => $label, + 'comment' => $comment, + 'tooltip' => $tooltip, + 'hint' => $hint, + 'value' => $data, + 'inherit' => $inherit, + 'class' => $element->frontend_class, + 'field_config' => $element, + 'scope' => $this->getScope(), + 'scope_id' => $this->getScopeId(), + 'scope_label' => $this->getScopeLabel($element), + 'can_use_default_value' => $this->canUseDefaultValue((int)$element->show_in_default), + 'can_use_website_value' => $this->canUseWebsiteValue((int)$element->show_in_website), + )); + $this->_applyFieldConfiguration($field, $element); + + $field->setRenderer($fieldRenderer); + + if ($element->source_model) { + $field->setValues($this->_extractDataFromSourceModel($element, $path, $fieldType)); + } + } + + /** + * Retreive field renderer block + * + * @param Varien_SimpleXml_Element $element + * @return Mage_Adminhtml_Block_System_Config_Form_Field + */ + protected function _getFieldRenderer($element) + { + if ($element->frontend_model) { + $fieldRenderer = Mage::getBlockSingleton((string)$element->frontend_model); + return $fieldRenderer; + } else { + $fieldRenderer = $this->_defaultFieldRenderer; + return $fieldRenderer; + } + } - if (isset($e->frontend_type) - && 'multiselect' === (string)$e->frontend_type - && isset($e->can_be_empty) - ) { - $field->setCanBeEmpty(true); + /** + * Retreive dvta from bakcend model + * + * @param Varien_SimpleXml_Element $element + * @param string $path + * @param mixed $data + * @return mixed + */ + protected function _fetchBackendModelData($element, $path, $data) + { + $model = Mage::getModel((string)$element->backend_model); + if (!$model instanceof Mage_Core_Model_Config_Data) { + Mage::throwException('Invalid config field backend model: ' . (string)$element->backend_model); + } + $model->setPath($path) + ->setValue($data) + ->setWebsite($this->getWebsiteCode()) + ->setStore($this->getStoreCode()) + ->afterLoad(); + $data = $model->getValue(); + return $data; + } + + /** + * Apply element dependencies from configuration + * + * @param Varien_SimpleXml_Element $element + * @param Varien_SimpleXml_Element $section + * @param Varien_SimpleXml_Element $group + * @param string $elementId + * @param string $fieldPrefix + */ + protected function _processElementDependencies($element, $section, $group, $elementId, $fieldPrefix = '') + { + foreach ($element->depends->children() as $dependent) { + /* @var $dependent Mage_Core_Model_Config_Element */ + $dependentId = $section->getName() + . '_' . $group->getName() + . '_' . $fieldPrefix + . $dependent->getName(); + $shouldBeAddedDependence = true; + $dependentValue = (string)$dependent; + if (isset($dependent['separator'])) { + $dependentValue = explode((string)$dependent['separator'], $dependentValue); + } + $dependentFieldName = $fieldPrefix . $dependent->getName(); + $dependentField = $group->fields->$dependentFieldName; + /* + * If dependent field can't be shown in current scope and real dependent config value + * is not equal to preferred one, then hide dependence fields by adding dependence + * based on not shown field (not rendered field) + */ + if (!$this->_canShowField($dependentField)) { + $dependentFullPath = $section->getName() + . '/' . $group->getName() + . '/' . $fieldPrefix + . $dependent->getName(); + $dependentValueInStore = Mage::getStoreConfig($dependentFullPath, $this->getStoreCode()); + if (is_array($dependentValue)) { + $shouldBeAddedDependence = !in_array($dependentValueInStore, $dependentValue); + } else { + $shouldBeAddedDependence = $dependentValue != $dependentValueInStore; } + } + if ($shouldBeAddedDependence) { + $this->_getDependence() + ->addFieldMap($elementId, $elementId) + ->addFieldMap($dependentId, $dependentId) + ->addFieldDependence($elementId, $dependentId, $dependentValue); + } + } + } - $field->setRenderer($fieldRenderer); + /** + * Apply custom element configuration + * + * @param Varien_Data_Form_Element_Abstract $field + * @param Varien_SimpleXml_Element $element + */ + protected function _applyFieldConfiguration($field, $element) + { + $this->_prepareFieldOriginalData($field, $element); - if ($e->source_model) { - // determine callback for the source model - $factoryName = (string)$e->source_model; - $method = false; - if (preg_match('/^([^:]+?)::([^:]+?)$/', $factoryName, $matches)) { - array_shift($matches); - list($factoryName, $method) = array_values($matches); - } + if (isset($element->validate)) { + $field->addClass($element->validate); + } - $sourceModel = Mage::getSingleton($factoryName); - if ($sourceModel instanceof Varien_Object) { - $sourceModel->setPath($path); - } - if ($method) { - if ($fieldType == 'multiselect') { - $optionArray = $sourceModel->$method(); - } else { - $optionArray = array(); - foreach ($sourceModel->$method() as $key => $value) { - if (is_array($value)) { - $optionArray[] = $value; - } else { - $optionArray[] = array('label' => $value, 'value' => $key); - } - } - } + if (isset($element->frontend_type) + && 'multiselect' === (string)$element->frontend_type + && isset($element->can_be_empty) + ) { + $field->setCanBeEmpty(true); + } + } + + /** + * Retreive source model option list + * + * @param Varien_SimpleXml_Element $element + * @param string $path + * @param string $fieldType + * @return array + */ + protected function _extractDataFromSourceModel($element, $path, $fieldType) + { + $factoryName = (string)$element->source_model; + $method = false; + if (preg_match('/^([^:]+?)::([^:]+?)$/', $factoryName, $matches)) { + array_shift($matches); + list($factoryName, $method) = array_values($matches); + } + + $sourceModel = Mage::getSingleton($factoryName); + if ($sourceModel instanceof Varien_Object) { + $sourceModel->setPath($path); + } + if ($method) { + if ($fieldType == 'multiselect') { + $optionArray = $sourceModel->$method(); + } else { + $optionArray = array(); + foreach ($sourceModel->$method() as $key => $value) { + if (is_array($value)) { + $optionArray[] = $value; } else { - $optionArray = $sourceModel->toOptionArray($fieldType == 'multiselect'); + $optionArray[] = array('label' => $value, 'value' => $key); } - $field->setValues($optionArray); } } + } else { + $optionArray = $sourceModel->toOptionArray($fieldType == 'multiselect'); } - return $this; + return $optionArray; } /** diff --git a/app/code/core/Mage/Adminhtml/Block/System/Config/Tabs.php b/app/code/core/Mage/Adminhtml/Block/System/Config/Tabs.php index 59f98afe30c..e9896c914a1 100644 --- a/app/code/core/Mage/Adminhtml/Block/System/Config/Tabs.php +++ b/app/code/core/Mage/Adminhtml/Block/System/Config/Tabs.php @@ -102,10 +102,8 @@ class Mage_Adminhtml_Block_System_Config_Tabs extends Mage_Adminhtml_Block_Widge Mage::dispatchEvent('adminhtml_block_system_config_init_tab_sections_before', array('section' => $section)); $hasChildren = $configFields->hasChildren($section, $websiteCode, $storeCode); - //$code = $section->getPath(); $code = $section->getName(); - - $sectionAllowed = $this->checkSectionPermissions($code); + $sectionAllowed = $this->checkSectionPermissions($section->resource); if ((empty($current) && $sectionAllowed)) { $current = $code; @@ -317,14 +315,14 @@ class Mage_Adminhtml_Block_System_Config_Tabs extends Mage_Adminhtml_Block_Widge /** * Enter description here... * - * @param string $code + * @param string $aclResourceId * @return boolean */ - public function checkSectionPermissions($code=null) + public function checkSectionPermissions($aclResourceId=null) { static $permissions; - if (!$code or trim($code) == "") { + if (!$aclResourceId or trim($aclResourceId) == "") { return false; } @@ -333,7 +331,7 @@ class Mage_Adminhtml_Block_System_Config_Tabs extends Mage_Adminhtml_Block_Widge } $showTab = false; - if ( $permissions->isAllowed('system/config/'.$code) ) { + if ( $permissions->isAllowed($aclResourceId) ) { $showTab = true; } return $showTab; diff --git a/app/code/core/Mage/Adminhtml/Block/System/Store/Edit.php b/app/code/core/Mage/Adminhtml/Block/System/Store/Edit.php index 9451223ee8f..6d7ad57f244 100644 --- a/app/code/core/Mage/Adminhtml/Block/System/Store/Edit.php +++ b/app/code/core/Mage/Adminhtml/Block/System/Store/Edit.php @@ -45,19 +45,28 @@ class Mage_Adminhtml_Block_System_Store_Edit extends Mage_Adminhtml_Block_Widget $this->_objectId = 'website_id'; $saveLabel = Mage::helper('Mage_Core_Helper_Data')->__('Save Website'); $deleteLabel = Mage::helper('Mage_Core_Helper_Data')->__('Delete Website'); - $deleteUrl = $this->getUrl('*/*/deleteWebsite', array('item_id' => Mage::registry('store_data')->getId())); + $deleteUrl = $this->getUrl( + '*/*/deleteWebsite', + array('item_id' => Mage::registry('store_data')->getId()) + ); break; case 'group': $this->_objectId = 'group_id'; $saveLabel = Mage::helper('Mage_Core_Helper_Data')->__('Save Store'); $deleteLabel = Mage::helper('Mage_Core_Helper_Data')->__('Delete Store'); - $deleteUrl = $this->getUrl('*/*/deleteGroup', array('item_id' => Mage::registry('store_data')->getId())); + $deleteUrl = $this->getUrl( + '*/*/deleteGroup', + array('item_id' => Mage::registry('store_data')->getId()) + ); break; case 'store': $this->_objectId = 'store_id'; $saveLabel = Mage::helper('Mage_Core_Helper_Data')->__('Save Store View'); $deleteLabel = Mage::helper('Mage_Core_Helper_Data')->__('Delete Store View'); - $deleteUrl = $this->getUrl('*/*/deleteStore', array('item_id' => Mage::registry('store_data')->getId())); + $deleteUrl = $this->getUrl( + '*/*/deleteStore', + array('item_id' => Mage::registry('store_data')->getId()) + ); break; default: $saveLabel = ''; @@ -108,4 +117,14 @@ class Mage_Adminhtml_Block_System_Store_Edit extends Mage_Adminhtml_Block_Widget return Mage::registry('store_action') == 'add' ? $addLabel : $editLabel; } + + /** + * Build child form class form name based on value of store_type in registry + * + * @return string + */ + protected function _buildFormClassName() + { + return parent::_buildFormClassName() . '_' . ucwords(Mage::registry('store_type')); + } } diff --git a/app/code/core/Mage/Adminhtml/Block/System/Store/Edit/Form.php b/app/code/core/Mage/Adminhtml/Block/System/Store/Edit/Form.php deleted file mode 100644 index 589bc2edaf0..00000000000 --- a/app/code/core/Mage/Adminhtml/Block/System/Store/Edit/Form.php +++ /dev/null @@ -1,346 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @category Mage - * @package Mage_Adminhtml - * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ - -/** - * Adminhtml store edit form - * - * @category Mage - * @package Mage_Adminhtml - * @author Magento Core Team <core@magentocommerce.com> - */ -class Mage_Adminhtml_Block_System_Store_Edit_Form extends Mage_Adminhtml_Block_Widget_Form -{ - - /** - * Class constructor - * - */ - public function __construct() - { - parent::__construct(); - $this->setId('coreStoreForm'); - } - - /** - * Prepare form data - * - * return Mage_Adminhtml_Block_Widget_Form - */ - protected function _prepareForm() - { - if (Mage::registry('store_type') == 'website') { - $websiteModel = Mage::registry('store_data'); - $showWebsiteFieldset = true; - $showGroupFieldset = $showStoreFieldset = false; - } elseif (Mage::registry('store_type') == 'group') { - $groupModel = Mage::registry('store_data'); - $showGroupFieldset = true; - $showWebsiteFieldset = $showStoreFieldset = false; - } elseif (Mage::registry('store_type') == 'store') { - $storeModel = Mage::registry('store_data'); - $showWebsiteFieldset = $showGroupFieldset = false; - $showStoreFieldset = true; - } - - /* @var $websiteModel Mage_Core_Model_Website */ - /* @var $groupModel Mage_Core_Model_Store_Group */ - /* @var $storeModel Mage_Core_Model_Store */ - - $form = new Varien_Data_Form(array( - 'id' => 'edit_form', - 'action' => $this->getData('action'), - 'method' => 'post' - )); - - if ($showWebsiteFieldset) { - if ($postData = Mage::registry('store_post_data')) { - $websiteModel->setData($postData['website']); - } - $fieldset = $form->addFieldset('website_fieldset', array( - 'legend' => Mage::helper('Mage_Core_Helper_Data')->__('Website Information') - )); - /* @var $fieldset Varien_Data_Form */ - - $fieldset->addField('website_name', 'text', array( - 'name' => 'website[name]', - 'label' => Mage::helper('Mage_Core_Helper_Data')->__('Name'), - 'value' => $websiteModel->getName(), - 'required' => true, - 'disabled' => $websiteModel->isReadOnly(), - )); - - $fieldset->addField('website_code', 'text', array( - 'name' => 'website[code]', - 'label' => Mage::helper('Mage_Core_Helper_Data')->__('Code'), - 'value' => $websiteModel->getCode(), - 'required' => true, - 'disabled' => $websiteModel->isReadOnly(), - )); - - $fieldset->addField('website_sort_order', 'text', array( - 'name' => 'website[sort_order]', - 'label' => Mage::helper('Mage_Core_Helper_Data')->__('Sort Order'), - 'value' => $websiteModel->getSortOrder(), - 'required' => false, - 'disabled' => $websiteModel->isReadOnly(), - )); - - if (Mage::registry('store_action') == 'edit') { - $groups = Mage::getModel('Mage_Core_Model_Store_Group')->getCollection() - ->addWebsiteFilter($websiteModel->getId()) - ->setWithoutStoreViewFilter() - ->toOptionArray(); - - $fieldset->addField('website_default_group_id', 'select', array( - 'name' => 'website[default_group_id]', - 'label' => Mage::helper('Mage_Core_Helper_Data')->__('Default Store'), - 'value' => $websiteModel->getDefaultGroupId(), - 'values' => $groups, - 'required' => false, - 'disabled' => $websiteModel->isReadOnly(), - )); - } - - if (!$websiteModel->getIsDefault() && $websiteModel->getStoresCount()) { - $fieldset->addField('is_default', 'checkbox', array( - 'name' => 'website[is_default]', - 'label' => Mage::helper('Mage_Core_Helper_Data')->__('Set as Default'), - 'value' => 1, - 'disabled' => $websiteModel->isReadOnly(), - )); - } - else { - $fieldset->addField('is_default', 'hidden', array( - 'name' => 'website[is_default]', - 'value' => $websiteModel->getIsDefault() - )); - } - - $fieldset->addField('website_website_id', 'hidden', array( - 'name' => 'website[website_id]', - 'value' => $websiteModel->getId() - )); - } - - if ($showGroupFieldset) { - if ($postData = Mage::registry('store_post_data')) { - $groupModel->setData($postData['group']); - } - $fieldset = $form->addFieldset('group_fieldset', array( - 'legend' => Mage::helper('Mage_Core_Helper_Data')->__('Store Information') - )); - - if (Mage::registry('store_action') == 'edit' - || (Mage::registry('store_action') == 'add' && Mage::registry('store_type') == 'group')) { - $websites = Mage::getModel('Mage_Core_Model_Website')->getCollection()->toOptionArray(); - $fieldset->addField('group_website_id', 'select', array( - 'name' => 'group[website_id]', - 'label' => Mage::helper('Mage_Core_Helper_Data')->__('Website'), - 'value' => $groupModel->getWebsiteId(), - 'values' => $websites, - 'required' => true, - 'disabled' => $groupModel->isReadOnly(), - )); - - if ($groupModel->getId() && $groupModel->getWebsite()->getDefaultGroupId() == $groupModel->getId()) { - if ($groupModel->getWebsite()->getIsDefault() || $groupModel->getWebsite()->getGroupsCount() == 1) { - $form->getElement('group_website_id')->setDisabled(true); - - $fieldset->addField('group_hidden_website_id', 'hidden', array( - 'name' => 'group[website_id]', - 'no_span' => true, - 'value' => $groupModel->getWebsiteId() - )); - } - else { - $fieldset->addField('group_original_website_id', 'hidden', array( - 'name' => 'group[original_website_id]', - 'no_span' => true, - 'value' => $groupModel->getWebsiteId() - )); - } - } - } - - $fieldset->addField('group_name', 'text', array( - 'name' => 'group[name]', - 'label' => Mage::helper('Mage_Core_Helper_Data')->__('Name'), - 'value' => $groupModel->getName(), - 'required' => true, - 'disabled' => $groupModel->isReadOnly(), - )); - - $categories = Mage::getModel('Mage_Adminhtml_Model_System_Config_Source_Category')->toOptionArray(); - - $fieldset->addField('group_root_category_id', 'select', array( - 'name' => 'group[root_category_id]', - 'label' => Mage::helper('Mage_Core_Helper_Data')->__('Root Category'), - 'value' => $groupModel->getRootCategoryId(), - 'values' => $categories, - 'required' => true, - 'disabled' => $groupModel->isReadOnly(), - )); - - if (Mage::registry('store_action') == 'edit') { - $stores = Mage::getModel('Mage_Core_Model_Store')->getCollection() - ->addGroupFilter($groupModel->getId())->toOptionArray(); - //array_unshift($stores, array('label'=>'', 'value'=>0)); - $fieldset->addField('group_default_store_id', 'select', array( - 'name' => 'group[default_store_id]', - 'label' => Mage::helper('Mage_Core_Helper_Data')->__('Default Store View'), - 'value' => $groupModel->getDefaultStoreId(), - 'values' => $stores, - 'required' => false, - 'disabled' => $groupModel->isReadOnly(), - )); - } - - $fieldset->addField('group_group_id', 'hidden', array( - 'name' => 'group[group_id]', - 'no_span' => true, - 'value' => $groupModel->getId() - )); - } - - if ($showStoreFieldset) { - if ($postData = Mage::registry('store_post_data')) { - $storeModel->setData($postData['store']); - } - $fieldset = $form->addFieldset('store_fieldset', array( - 'legend' => Mage::helper('Mage_Core_Helper_Data')->__('Store View Information') - )); - - if (Mage::registry('store_action') == 'edit' - || Mage::registry('store_action') == 'add' && Mage::registry('store_type') == 'store') { - $websites = Mage::getModel('Mage_Core_Model_Website')->getCollection(); - $allgroups = Mage::getModel('Mage_Core_Model_Store_Group')->getCollection(); - $groups = array(); - foreach ($websites as $website) { - $values = array(); - foreach ($allgroups as $group) { - if ($group->getWebsiteId() == $website->getId()) { - $values[] = array('label'=>$group->getName(),'value'=>$group->getId()); - } - } - $groups[] = array('label'=>$website->getName(),'value'=>$values); - } - $fieldset->addField('store_group_id', 'select', array( - 'name' => 'store[group_id]', - 'label' => Mage::helper('Mage_Core_Helper_Data')->__('Store'), - 'value' => $storeModel->getGroupId(), - 'values' => $groups, - 'required' => true, - 'disabled' => $storeModel->isReadOnly(), - )); - if ($storeModel->getId() && $storeModel->getGroup()->getDefaultStoreId() == $storeModel->getId()) { - if ($storeModel->getGroup() && $storeModel->getGroup()->getStoresCount() > 1) { - $form->getElement('store_group_id')->setDisabled(true); - - $fieldset->addField('store_hidden_group_id', 'hidden', array( - 'name' => 'store[group_id]', - 'no_span' => true, - 'value' => $storeModel->getGroupId() - )); - } - else { - $fieldset->addField('store_original_group_id', 'hidden', array( - 'name' => 'store[original_group_id]', - 'no_span' => true, - 'value' => $storeModel->getGroupId() - )); - } - } - } - - $fieldset->addField('store_name', 'text', array( - 'name' => 'store[name]', - 'label' => Mage::helper('Mage_Core_Helper_Data')->__('Name'), - 'value' => $storeModel->getName(), - 'required' => true, - 'disabled' => $storeModel->isReadOnly(), - )); - $fieldset->addField('store_code', 'text', array( - 'name' => 'store[code]', - 'label' => Mage::helper('Mage_Core_Helper_Data')->__('Code'), - 'value' => $storeModel->getCode(), - 'required' => true, - 'disabled' => $storeModel->isReadOnly(), - )); - - $fieldset->addField('store_is_active', 'select', array( - 'name' => 'store[is_active]', - 'label' => Mage::helper('Mage_Core_Helper_Data')->__('Status'), - 'value' => $storeModel->getIsActive(), - 'options' => array( - 0 => Mage::helper('Mage_Adminhtml_Helper_Data')->__('Disabled'), - 1 => Mage::helper('Mage_Adminhtml_Helper_Data')->__('Enabled')), - 'required' => true, - 'disabled' => $storeModel->isReadOnly(), - )); - - $fieldset->addField('store_sort_order', 'text', array( - 'name' => 'store[sort_order]', - 'label' => Mage::helper('Mage_Core_Helper_Data')->__('Sort Order'), - 'value' => $storeModel->getSortOrder(), - 'required' => false, - 'disabled' => $storeModel->isReadOnly(), - )); - - $fieldset->addField('store_is_default', 'hidden', array( - 'name' => 'store[is_default]', - 'no_span' => true, - 'value' => $storeModel->getIsDefault(), - )); - - $fieldset->addField('store_store_id', 'hidden', array( - 'name' => 'store[store_id]', - 'no_span' => true, - 'value' => $storeModel->getId(), - 'disabled' => $storeModel->isReadOnly(), - )); - } - - $form->addField('store_type', 'hidden', array( - 'name' => 'store_type', - 'no_span' => true, - 'value' => Mage::registry('store_type') - )); - - $form->addField('store_action', 'hidden', array( - 'name' => 'store_action', - 'no_span' => true, - 'value' => Mage::registry('store_action') - )); - - $form->setAction($this->getUrl('*/*/save')); - $form->setUseContainer(true); - $this->setForm($form); - - Mage::dispatchEvent('adminhtml_store_edit_form_prepare_form', array('block' => $this)); - - return parent::_prepareForm(); - } -} diff --git a/app/code/core/Mage/Adminhtml/Block/System/Store/Edit/Form/Group.php b/app/code/core/Mage/Adminhtml/Block/System/Store/Edit/Form/Group.php new file mode 100644 index 00000000000..478afad94f6 --- /dev/null +++ b/app/code/core/Mage/Adminhtml/Block/System/Store/Edit/Form/Group.php @@ -0,0 +1,120 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Mage + * @package Mage_Adminhtml + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +/** + * Adminhtml store edit form for group + * + * @category Mage + * @package Mage_Adminhtml + * @author Magento Core Team <core@magentocommerce.com> + */ +class Mage_Adminhtml_Block_System_Store_Edit_Form_Group extends Mage_Adminhtml_Block_System_Store_Edit_FormAbstract +{ + /** + * Prepare group specific fieldset + * + * @param Varien_Data_Form $form + */ + protected function _prepareStoreFieldset(Varien_Data_Form $form) + { + $groupModel = Mage::registry('store_data'); + if ($postData = Mage::registry('store_post_data')) { + $groupModel->setData($postData['group']); + } + + $fieldset = $form->addFieldset('group_fieldset', array( + 'legend' => Mage::helper('Mage_Core_Helper_Data')->__('Store Information') + )); + + if (Mage::registry('store_action') == 'edit' || Mage::registry('store_action') == 'add') { + $websites = Mage::getModel('Mage_Core_Model_Website')->getCollection()->toOptionArray(); + $fieldset->addField('group_website_id', 'select', array( + 'name' => 'group[website_id]', + 'label' => Mage::helper('Mage_Core_Helper_Data')->__('Website'), + 'value' => $groupModel->getWebsiteId(), + 'values' => $websites, + 'required' => true, + 'disabled' => $groupModel->isReadOnly(), + )); + + if ($groupModel->getId() && $groupModel->getWebsite()->getDefaultGroupId() == $groupModel->getId()) { + if ($groupModel->getWebsite()->getIsDefault() || $groupModel->getWebsite()->getGroupsCount() == 1) { + $form->getElement('group_website_id')->setDisabled(true); + + $fieldset->addField('group_hidden_website_id', 'hidden', array( + 'name' => 'group[website_id]', + 'no_span' => true, + 'value' => $groupModel->getWebsiteId() + )); + } else { + $fieldset->addField('group_original_website_id', 'hidden', array( + 'name' => 'group[original_website_id]', + 'no_span' => true, + 'value' => $groupModel->getWebsiteId() + )); + } + } + } + + $fieldset->addField('group_name', 'text', array( + 'name' => 'group[name]', + 'label' => Mage::helper('Mage_Core_Helper_Data')->__('Name'), + 'value' => $groupModel->getName(), + 'required' => true, + 'disabled' => $groupModel->isReadOnly(), + )); + + $categories = Mage::getModel('Mage_Adminhtml_Model_System_Config_Source_Category')->toOptionArray(); + + $fieldset->addField('group_root_category_id', 'select', array( + 'name' => 'group[root_category_id]', + 'label' => Mage::helper('Mage_Core_Helper_Data')->__('Root Category'), + 'value' => $groupModel->getRootCategoryId(), + 'values' => $categories, + 'required' => true, + 'disabled' => $groupModel->isReadOnly(), + )); + + if (Mage::registry('store_action') == 'edit') { + $stores = Mage::getModel('Mage_Core_Model_Store')->getCollection() + ->addGroupFilter($groupModel->getId())->toOptionArray(); + $fieldset->addField('group_default_store_id', 'select', array( + 'name' => 'group[default_store_id]', + 'label' => Mage::helper('Mage_Core_Helper_Data')->__('Default Store View'), + 'value' => $groupModel->getDefaultStoreId(), + 'values' => $stores, + 'required' => false, + 'disabled' => $groupModel->isReadOnly(), + )); + } + + $fieldset->addField('group_group_id', 'hidden', array( + 'name' => 'group[group_id]', + 'no_span' => true, + 'value' => $groupModel->getId() + )); + } +} diff --git a/app/code/core/Mage/Adminhtml/Block/System/Store/Edit/Form/Store.php b/app/code/core/Mage/Adminhtml/Block/System/Store/Edit/Form/Store.php new file mode 100644 index 00000000000..8280932145d --- /dev/null +++ b/app/code/core/Mage/Adminhtml/Block/System/Store/Edit/Form/Store.php @@ -0,0 +1,148 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Mage + * @package Mage_Adminhtml + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +/** + * Adminhtml store edit form for store + * + * @category Mage + * @package Mage_Adminhtml + * @author Magento Core Team <core@magentocommerce.com> + */ +class Mage_Adminhtml_Block_System_Store_Edit_Form_Store extends Mage_Adminhtml_Block_System_Store_Edit_FormAbstract +{ + /** + * Prepare store specific fieldset + * + * @param Varien_Data_Form $form + */ + protected function _prepareStoreFieldset(Varien_Data_Form $form) + { + $storeModel = Mage::registry('store_data'); + if ($postData = Mage::registry('store_post_data')) { + $storeModel->setData($postData['store']); + } + $fieldset = $form->addFieldset('store_fieldset', array( + 'legend' => Mage::helper('Mage_Core_Helper_Data')->__('Store View Information') + )); + + if (Mage::registry('store_action') == 'edit' || Mage::registry('store_action') == 'add' ) { + $fieldset->addField('store_group_id', 'select', array( + 'name' => 'store[group_id]', + 'label' => Mage::helper('Mage_Core_Helper_Data')->__('Store'), + 'value' => $storeModel->getGroupId(), + 'values' => $this->_getStoreGroups(), + 'required' => true, + 'disabled' => $storeModel->isReadOnly(), + )); + if ($storeModel->getId() && $storeModel->getGroup()->getDefaultStoreId() == $storeModel->getId()) { + if ($storeModel->getGroup() && $storeModel->getGroup()->getStoresCount() > 1) { + $form->getElement('store_group_id')->setDisabled(true); + + $fieldset->addField('store_hidden_group_id', 'hidden', array( + 'name' => 'store[group_id]', + 'no_span' => true, + 'value' => $storeModel->getGroupId() + )); + } else { + $fieldset->addField('store_original_group_id', 'hidden', array( + 'name' => 'store[original_group_id]', + 'no_span' => true, + 'value' => $storeModel->getGroupId() + )); + } + } + } + + $fieldset->addField('store_name', 'text', array( + 'name' => 'store[name]', + 'label' => Mage::helper('Mage_Core_Helper_Data')->__('Name'), + 'value' => $storeModel->getName(), + 'required' => true, + 'disabled' => $storeModel->isReadOnly(), + )); + $fieldset->addField('store_code', 'text', array( + 'name' => 'store[code]', + 'label' => Mage::helper('Mage_Core_Helper_Data')->__('Code'), + 'value' => $storeModel->getCode(), + 'required' => true, + 'disabled' => $storeModel->isReadOnly(), + )); + + $fieldset->addField('store_is_active', 'select', array( + 'name' => 'store[is_active]', + 'label' => Mage::helper('Mage_Core_Helper_Data')->__('Status'), + 'value' => $storeModel->getIsActive(), + 'options' => array( + 0 => Mage::helper('Mage_Adminhtml_Helper_Data')->__('Disabled'), + 1 => Mage::helper('Mage_Adminhtml_Helper_Data')->__('Enabled')), + 'required' => true, + 'disabled' => $storeModel->isReadOnly(), + )); + + $fieldset->addField('store_sort_order', 'text', array( + 'name' => 'store[sort_order]', + 'label' => Mage::helper('Mage_Core_Helper_Data')->__('Sort Order'), + 'value' => $storeModel->getSortOrder(), + 'required' => false, + 'disabled' => $storeModel->isReadOnly(), + )); + + $fieldset->addField('store_is_default', 'hidden', array( + 'name' => 'store[is_default]', + 'no_span' => true, + 'value' => $storeModel->getIsDefault(), + )); + + $fieldset->addField('store_store_id', 'hidden', array( + 'name' => 'store[store_id]', + 'no_span' => true, + 'value' => $storeModel->getId(), + 'disabled' => $storeModel->isReadOnly(), + )); + } + + /** + * Retrieve list of store groups + * + * @return array + */ + protected function _getStoreGroups() + { + $websites = Mage::getModel('Mage_Core_Model_Website')->getCollection(); + $allgroups = Mage::getModel('Mage_Core_Model_Store_Group')->getCollection(); + $groups = array(); + foreach ($websites as $website) { + $values = array(); + foreach ($allgroups as $group) { + if ($group->getWebsiteId() == $website->getId()) { + $values[] = array('label'=>$group->getName(),'value'=>$group->getId()); + } + } + $groups[] = array('label'=>$website->getName(),'value'=>$values); + } + return $groups; + } +} diff --git a/app/code/core/Mage/Adminhtml/Block/System/Store/Edit/Form/Website.php b/app/code/core/Mage/Adminhtml/Block/System/Store/Edit/Form/Website.php new file mode 100644 index 00000000000..720b6fe0d6f --- /dev/null +++ b/app/code/core/Mage/Adminhtml/Block/System/Store/Edit/Form/Website.php @@ -0,0 +1,111 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Mage + * @package Mage_Adminhtml + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +/** + * Adminhtml store edit form for website + * + * @category Mage + * @package Mage_Adminhtml + * @author Magento Core Team <core@magentocommerce.com> + */ +class Mage_Adminhtml_Block_System_Store_Edit_Form_Website extends Mage_Adminhtml_Block_System_Store_Edit_FormAbstract +{ + /** + * Prepare website specific fieldset + * + * @param Varien_Data_Form $form + */ + protected function _prepareStoreFieldset(Varien_Data_Form $form) + { + $websiteModel = Mage::registry('store_data'); + if ($postData = Mage::registry('store_post_data')) { + $websiteModel->setData($postData['website']); + } + $fieldset = $form->addFieldset('website_fieldset', array( + 'legend' => Mage::helper('Mage_Core_Helper_Data')->__('Website Information') + )); + /* @var $fieldset Varien_Data_Form */ + + $fieldset->addField('website_name', 'text', array( + 'name' => 'website[name]', + 'label' => Mage::helper('Mage_Core_Helper_Data')->__('Name'), + 'value' => $websiteModel->getName(), + 'required' => true, + 'disabled' => $websiteModel->isReadOnly(), + )); + + $fieldset->addField('website_code', 'text', array( + 'name' => 'website[code]', + 'label' => Mage::helper('Mage_Core_Helper_Data')->__('Code'), + 'value' => $websiteModel->getCode(), + 'required' => true, + 'disabled' => $websiteModel->isReadOnly(), + )); + + $fieldset->addField('website_sort_order', 'text', array( + 'name' => 'website[sort_order]', + 'label' => Mage::helper('Mage_Core_Helper_Data')->__('Sort Order'), + 'value' => $websiteModel->getSortOrder(), + 'required' => false, + 'disabled' => $websiteModel->isReadOnly(), + )); + + if (Mage::registry('store_action') == 'edit') { + $groups = Mage::getModel('Mage_Core_Model_Store_Group')->getCollection() + ->addWebsiteFilter($websiteModel->getId()) + ->setWithoutStoreViewFilter() + ->toOptionArray(); + + $fieldset->addField('website_default_group_id', 'select', array( + 'name' => 'website[default_group_id]', + 'label' => Mage::helper('Mage_Core_Helper_Data')->__('Default Store'), + 'value' => $websiteModel->getDefaultGroupId(), + 'values' => $groups, + 'required' => false, + 'disabled' => $websiteModel->isReadOnly(), + )); + } + + if (!$websiteModel->getIsDefault() && $websiteModel->getStoresCount()) { + $fieldset->addField('is_default', 'checkbox', array( + 'name' => 'website[is_default]', + 'label' => Mage::helper('Mage_Core_Helper_Data')->__('Set as Default'), + 'value' => 1, + 'disabled' => $websiteModel->isReadOnly(), + )); + } else { + $fieldset->addField('is_default', 'hidden', array( + 'name' => 'website[is_default]', + 'value' => $websiteModel->getIsDefault() + )); + } + + $fieldset->addField('website_website_id', 'hidden', array( + 'name' => 'website[website_id]', + 'value' => $websiteModel->getId() + )); + } +} diff --git a/app/code/core/Mage/Adminhtml/Block/System/Store/Edit/FormAbstract.php b/app/code/core/Mage/Adminhtml/Block/System/Store/Edit/FormAbstract.php new file mode 100644 index 00000000000..ed39808769c --- /dev/null +++ b/app/code/core/Mage/Adminhtml/Block/System/Store/Edit/FormAbstract.php @@ -0,0 +1,90 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Mage + * @package Mage_Adminhtml + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +/** + * Adminhtml store edit form + * + * @category Mage + * @package Mage_Adminhtml + * @author Magento Core Team <core@magentocommerce.com> + */ +abstract class Mage_Adminhtml_Block_System_Store_Edit_FormAbstract extends Mage_Adminhtml_Block_Widget_Form +{ + + /** + * Class constructor + * + */ + public function __construct() + { + parent::__construct(); + $this->setId('coreStoreForm'); + } + + /** + * Prepare form data + * + * return Mage_Adminhtml_Block_Widget_Form + */ + protected function _prepareForm() + { + $form = new Varien_Data_Form(array( + 'id' => 'edit_form', + 'action' => $this->getData('action'), + 'method' => 'post' + )); + + $this->_prepareStoreFieldSet($form); + + $form->addField('store_type', 'hidden', array( + 'name' => 'store_type', + 'no_span' => true, + 'value' => Mage::registry('store_type') + )); + + $form->addField('store_action', 'hidden', array( + 'name' => 'store_action', + 'no_span' => true, + 'value' => Mage::registry('store_action') + )); + + $form->setAction($this->getUrl('*/*/save')); + $form->setUseContainer(true); + $this->setForm($form); + + Mage::dispatchEvent('adminhtml_store_edit_form_prepare_form', array('block' => $this)); + + return parent::_prepareForm(); + } + + /** + * Build store type specific fieldset + * + * @abstract + * @param Varien_Data_Form $form + */ + abstract protected function _prepareStoreFieldset(Varien_Data_Form $form); +} diff --git a/app/code/core/Mage/Adminhtml/Controller/Sales/Creditmemo.php b/app/code/core/Mage/Adminhtml/Controller/Sales/Creditmemo.php index c36b0384ae2..74d04c84d3a 100644 --- a/app/code/core/Mage/Adminhtml/Controller/Sales/Creditmemo.php +++ b/app/code/core/Mage/Adminhtml/Controller/Sales/Creditmemo.php @@ -136,6 +136,6 @@ class Mage_Adminhtml_Controller_Sales_Creditmemo extends Mage_Adminhtml_Controll protected function _isAllowed() { - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('sales/creditmemo'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Sales::sales_creditmemo'); } } diff --git a/app/code/core/Mage/Adminhtml/Controller/Sales/Invoice.php b/app/code/core/Mage/Adminhtml/Controller/Sales/Invoice.php index 3199448d9c0..2d2f50725ee 100644 --- a/app/code/core/Mage/Adminhtml/Controller/Sales/Invoice.php +++ b/app/code/core/Mage/Adminhtml/Controller/Sales/Invoice.php @@ -148,7 +148,7 @@ class Mage_Adminhtml_Controller_Sales_Invoice extends Mage_Adminhtml_Controller_ protected function _isAllowed() { - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('sales/invoice'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Sales::sales_invoice'); } } diff --git a/app/code/core/Mage/Adminhtml/Controller/Sales/Shipment.php b/app/code/core/Mage/Adminhtml/Controller/Sales/Shipment.php index cc82fbf1a01..f9719af0ee0 100644 --- a/app/code/core/Mage/Adminhtml/Controller/Sales/Shipment.php +++ b/app/code/core/Mage/Adminhtml/Controller/Sales/Shipment.php @@ -114,6 +114,6 @@ class Mage_Adminhtml_Controller_Sales_Shipment extends Mage_Adminhtml_Controller protected function _isAllowed() { - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('sales/shipment'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Sales::shipment'); } } diff --git a/app/code/core/Mage/Adminhtml/controllers/Api/RoleController.php b/app/code/core/Mage/Adminhtml/controllers/Api/RoleController.php index de1076af2e0..21e88f16fe9 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Api/RoleController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Api/RoleController.php @@ -212,6 +212,6 @@ class Mage_Adminhtml_Api_RoleController extends Mage_Adminhtml_Controller_Action protected function _isAllowed() { - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('system/api/roles'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Api::roles'); } } diff --git a/app/code/core/Mage/Adminhtml/controllers/Api/UserController.php b/app/code/core/Mage/Adminhtml/controllers/Api/UserController.php index 2c53eec41c2..d4bcfe56010 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Api/UserController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Api/UserController.php @@ -184,7 +184,7 @@ class Mage_Adminhtml_Api_UserController extends Mage_Adminhtml_Controller_Action protected function _isAllowed() { - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('system/api/users'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Api::users'); } } diff --git a/app/code/core/Mage/Adminhtml/controllers/CacheController.php b/app/code/core/Mage/Adminhtml/controllers/CacheController.php index e446ac27530..ba3f027146e 100644 --- a/app/code/core/Mage/Adminhtml/controllers/CacheController.php +++ b/app/code/core/Mage/Adminhtml/controllers/CacheController.php @@ -190,6 +190,6 @@ class Mage_Adminhtml_CacheController extends Mage_Adminhtml_Controller_Action */ protected function _isAllowed() { - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('system/cache'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Adminhtml::cache'); } } diff --git a/app/code/core/Mage/Adminhtml/controllers/Catalog/CategoryController.php b/app/code/core/Mage/Adminhtml/controllers/Catalog/CategoryController.php index 926beb68ae9..02c3f196f26 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Catalog/CategoryController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Catalog/CategoryController.php @@ -509,6 +509,6 @@ class Mage_Adminhtml_Catalog_CategoryController extends Mage_Adminhtml_Controlle */ protected function _isAllowed() { - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('catalog/categories'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Catalog::categories'); } } diff --git a/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/Action/AttributeController.php b/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/Action/AttributeController.php index 13d5956691b..f34b6481914 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/Action/AttributeController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/Action/AttributeController.php @@ -216,7 +216,7 @@ class Mage_Adminhtml_Catalog_Product_Action_AttributeController extends Mage_Adm protected function _isAllowed() { - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('catalog/update_attributes'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Catalog::update_attributes'); } /** 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 8c4ac365d72..f9bc2bfabd9 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/AttributeController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/AttributeController.php @@ -341,6 +341,6 @@ class Mage_Adminhtml_Catalog_Product_AttributeController extends Mage_Adminhtml_ protected function _isAllowed() { - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('catalog/attributes/attributes'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Catalog::attributes_attributes'); } } diff --git a/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/GalleryController.php b/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/GalleryController.php index 617e8921729..e07f15e71c7 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/GalleryController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/GalleryController.php @@ -78,6 +78,6 @@ class Mage_Adminhtml_Catalog_Product_GalleryController extends Mage_Adminhtml_Co protected function _isAllowed() { - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('catalog/products'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Catalog::products'); } } // Class Mage_Adminhtml_Catalog_Product_GalleryController End diff --git a/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/GroupController.php b/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/GroupController.php index dc14a7a0b1a..800b12a711a 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/GroupController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/GroupController.php @@ -46,6 +46,6 @@ class Mage_Adminhtml_Catalog_Product_GroupController extends Mage_Adminhtml_Cont protected function _isAllowed() { - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('catalog/products'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Catalog::products'); } } diff --git a/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/ReviewController.php b/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/ReviewController.php index 9829f7a5fd8..31011e9f8f9 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/ReviewController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/ReviewController.php @@ -381,10 +381,10 @@ class Mage_Adminhtml_Catalog_Product_ReviewController extends Mage_Adminhtml_Con { switch ($this->getRequest()->getActionName()) { case 'pending': - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('catalog/reviews_ratings/reviews/pending'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Review::pending'); break; default: - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('catalog/reviews_ratings/reviews/all'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Review::reviews_all'); break; } } 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 09f33632970..ddc7fa36b01 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/SetController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/SetController.php @@ -226,7 +226,7 @@ class Mage_Adminhtml_Catalog_Product_SetController extends Mage_Adminhtml_Contro protected function _isAllowed() { - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('catalog/attributes/sets'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Catalog::sets'); } /** diff --git a/app/code/core/Mage/Adminhtml/controllers/Catalog/ProductController.php b/app/code/core/Mage/Adminhtml/controllers/Catalog/ProductController.php index 363e7a44887..511cd1bdd10 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Catalog/ProductController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Catalog/ProductController.php @@ -1063,7 +1063,7 @@ class Mage_Adminhtml_Catalog_ProductController extends Mage_Adminhtml_Controller */ protected function _isAllowed() { - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('catalog/products'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Catalog::products'); } /** diff --git a/app/code/core/Mage/Adminhtml/controllers/Catalog/SearchController.php b/app/code/core/Mage/Adminhtml/controllers/Catalog/SearchController.php index 63de802a118..ad90e074a4b 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Catalog/SearchController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Catalog/SearchController.php @@ -190,6 +190,6 @@ class Mage_Adminhtml_Catalog_SearchController extends Mage_Adminhtml_Controller_ protected function _isAllowed() { - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('catalog/search'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_CatalogSearch::search'); } } diff --git a/app/code/core/Mage/Adminhtml/controllers/Checkout/AgreementController.php b/app/code/core/Mage/Adminhtml/controllers/Checkout/AgreementController.php index 4b1a34fdf71..2660d1f7b6c 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Checkout/AgreementController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Checkout/AgreementController.php @@ -162,6 +162,6 @@ class Mage_Adminhtml_Checkout_AgreementController extends Mage_Adminhtml_Control protected function _isAllowed() { - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('sales/checkoutagreement'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Checkout::checkoutagreement'); } } diff --git a/app/code/core/Mage/Adminhtml/controllers/Cms/BlockController.php b/app/code/core/Mage/Adminhtml/controllers/Cms/BlockController.php index b499d7c940e..2964bc0aa22 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Cms/BlockController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Cms/BlockController.php @@ -200,6 +200,6 @@ class Mage_Adminhtml_Cms_BlockController extends Mage_Adminhtml_Controller_Actio */ protected function _isAllowed() { - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('cms/block'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Cms::block'); } } diff --git a/app/code/core/Mage/Adminhtml/controllers/Cms/PageController.php b/app/code/core/Mage/Adminhtml/controllers/Cms/PageController.php index c54ae4f4ecc..d3aab7a52c6 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Cms/PageController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Cms/PageController.php @@ -225,13 +225,13 @@ class Mage_Adminhtml_Cms_PageController extends Mage_Adminhtml_Controller_Action switch ($this->getRequest()->getActionName()) { case 'new': case 'save': - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('cms/page/save'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Cms::save'); break; case 'delete': - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('cms/page/delete'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Cms::page_delete'); break; default: - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('cms/page'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Cms::page'); break; } } diff --git a/app/code/core/Mage/Adminhtml/controllers/Cms/Wysiwyg/ImagesController.php b/app/code/core/Mage/Adminhtml/controllers/Cms/Wysiwyg/ImagesController.php index e0759ba640f..21b14837e84 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Cms/Wysiwyg/ImagesController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Cms/Wysiwyg/ImagesController.php @@ -229,6 +229,6 @@ class Mage_Adminhtml_Cms_Wysiwyg_ImagesController extends Mage_Adminhtml_Control */ protected function _isAllowed() { - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('cms/media_gallery'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Cms::media_gallery'); } } diff --git a/app/code/core/Mage/Adminhtml/controllers/Customer/Cart/Product/Composite/CartController.php b/app/code/core/Mage/Adminhtml/controllers/Customer/Cart/Product/Composite/CartController.php index ff43d4214b9..f8775bafc20 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Customer/Cart/Product/Composite/CartController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Customer/Cart/Product/Composite/CartController.php @@ -155,6 +155,6 @@ class Mage_Adminhtml_Customer_Cart_Product_Composite_CartController extends Mage */ protected function _isAllowed() { - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('customer/manage'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Customer::manage'); } } diff --git a/app/code/core/Mage/Adminhtml/controllers/Customer/GroupController.php b/app/code/core/Mage/Adminhtml/controllers/Customer/GroupController.php index 60cb929a645..decb55ae780 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Customer/GroupController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Customer/GroupController.php @@ -154,6 +154,6 @@ class Mage_Adminhtml_Customer_GroupController extends Mage_Adminhtml_Controller_ protected function _isAllowed() { - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('customer/group'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_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 c31a80ebb29..3d0f3b21a3f 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Customer/OnlineController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Customer/OnlineController.php @@ -49,6 +49,6 @@ class Mage_Adminhtml_Customer_OnlineController extends Mage_Adminhtml_Controller protected function _isAllowed() { - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('customer/online'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Customer::online'); } } diff --git a/app/code/core/Mage/Adminhtml/controllers/Customer/Wishlist/Product/Composite/WishlistController.php b/app/code/core/Mage/Adminhtml/controllers/Customer/Wishlist/Product/Composite/WishlistController.php index a8ce8a2a0c3..101d0fde554 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Customer/Wishlist/Product/Composite/WishlistController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Customer/Wishlist/Product/Composite/WishlistController.php @@ -142,6 +142,6 @@ class Mage_Adminhtml_Customer_Wishlist_Product_Composite_WishlistController */ protected function _isAllowed() { - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('customer/manage'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Customer::manage'); } } diff --git a/app/code/core/Mage/Adminhtml/controllers/CustomerController.php b/app/code/core/Mage/Adminhtml/controllers/CustomerController.php index 15b3cfc448a..da83fb91459 100644 --- a/app/code/core/Mage/Adminhtml/controllers/CustomerController.php +++ b/app/code/core/Mage/Adminhtml/controllers/CustomerController.php @@ -290,7 +290,8 @@ class Mage_Adminhtml_CustomerController extends Mage_Adminhtml_Controller_Action } } - if (Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('customer/newsletter') + if (Mage::getSingleton('Mage_Backend_Model_Auth_Session') + ->isAllowed(Mage_Backend_Model_Acl_Config::ACL_RESOURCE_ALL) && !$customer->getConfirmation() ) { $customer->setIsSubscribed(isset($data['subscription'])); @@ -807,7 +808,7 @@ class Mage_Adminhtml_CustomerController extends Mage_Adminhtml_Controller_Action protected function _isAllowed() { - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('customer/manage'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Customer::manage'); } /** diff --git a/app/code/core/Mage/Adminhtml/controllers/DashboardController.php b/app/code/core/Mage/Adminhtml/controllers/DashboardController.php index b5da784d369..d6e5976a743 100644 --- a/app/code/core/Mage/Adminhtml/controllers/DashboardController.php +++ b/app/code/core/Mage/Adminhtml/controllers/DashboardController.php @@ -112,6 +112,6 @@ class Mage_Adminhtml_DashboardController extends Mage_Adminhtml_Controller_Actio protected function _isAllowed() { - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('dashboard'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Adminhtml::dashboard'); } } diff --git a/app/code/core/Mage/Adminhtml/controllers/IndexController.php b/app/code/core/Mage/Adminhtml/controllers/IndexController.php index 237625123aa..cfe5806c5a3 100644 --- a/app/code/core/Mage/Adminhtml/controllers/IndexController.php +++ b/app/code/core/Mage/Adminhtml/controllers/IndexController.php @@ -42,7 +42,7 @@ class Mage_Adminhtml_IndexController extends Mage_Adminhtml_Controller_Action $searchModules = Mage::getConfig()->getNode("adminhtml/global_search"); $items = array(); - if (!Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('admin/global_search')) { + if (!Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Adminhtml::global_search')) { $items[] = array( 'id' => 'error', 'type' => Mage::helper('Mage_Adminhtml_Helper_Data')->__('Error'), diff --git a/app/code/core/Mage/Adminhtml/controllers/Media/EditorController.php b/app/code/core/Mage/Adminhtml/controllers/Media/EditorController.php index 366da652c88..d63e813564e 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Media/EditorController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Media/EditorController.php @@ -45,6 +45,8 @@ class Mage_Adminhtml_Media_EditorController extends Mage_Adminhtml_Controller_Ac protected function _isAllowed() { - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('media'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed( + Mage_Backend_Model_Acl_Config::ACL_RESOURCE_ALL + ); } } diff --git a/app/code/core/Mage/Adminhtml/controllers/Media/UploaderController.php b/app/code/core/Mage/Adminhtml/controllers/Media/UploaderController.php index 6560f2f3e0b..db854125468 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Media/UploaderController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Media/UploaderController.php @@ -50,6 +50,7 @@ class Mage_Adminhtml_Media_UploaderController extends Mage_Adminhtml_Controller_ protected function _isAllowed() { - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('media'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session') + ->isAllowed(Mage_Backend_Model_Acl_Config::ACL_RESOURCE_ALL); } } diff --git a/app/code/core/Mage/Adminhtml/controllers/Newsletter/ProblemController.php b/app/code/core/Mage/Adminhtml/controllers/Newsletter/ProblemController.php index 25fc01fb8e3..c1a9c941c21 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Newsletter/ProblemController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Newsletter/ProblemController.php @@ -99,6 +99,6 @@ class Mage_Adminhtml_Newsletter_ProblemController extends Mage_Adminhtml_Control protected function _isAllowed() { - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('newsletter/problem'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Newsletter::problem'); } } diff --git a/app/code/core/Mage/Adminhtml/controllers/Newsletter/QueueController.php b/app/code/core/Mage/Adminhtml/controllers/Newsletter/QueueController.php index 904938164e8..8f548aeeb5b 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Newsletter/QueueController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Newsletter/QueueController.php @@ -276,6 +276,6 @@ class Mage_Adminhtml_Newsletter_QueueController extends Mage_Adminhtml_Controlle protected function _isAllowed() { - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('newsletter/queue'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_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 90ba5a7a2eb..a2e83c8d872 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Newsletter/SubscriberController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Newsletter/SubscriberController.php @@ -137,6 +137,6 @@ class Mage_Adminhtml_Newsletter_SubscriberController extends Mage_Adminhtml_Cont protected function _isAllowed() { - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('newsletter/subscriber'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Newsletter::subscriber'); } } diff --git a/app/code/core/Mage/Adminhtml/controllers/Newsletter/TemplateController.php b/app/code/core/Mage/Adminhtml/controllers/Newsletter/TemplateController.php index 43467934ac2..95846ac039d 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Newsletter/TemplateController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Newsletter/TemplateController.php @@ -40,7 +40,7 @@ class Mage_Adminhtml_Newsletter_TemplateController extends Mage_Adminhtml_Contro protected function _isAllowed () { return Mage::getSingleton('Mage_Backend_Model_Auth_Session') - ->isAllowed('newsletter/template'); + ->isAllowed('Mage_Newsletter::template'); } /** diff --git a/app/code/core/Mage/Adminhtml/controllers/NotificationController.php b/app/code/core/Mage/Adminhtml/controllers/NotificationController.php index 5b8f705ec1d..3844fc2f77a 100644 --- a/app/code/core/Mage/Adminhtml/controllers/NotificationController.php +++ b/app/code/core/Mage/Adminhtml/controllers/NotificationController.php @@ -162,23 +162,23 @@ class Mage_Adminhtml_NotificationController extends Mage_Adminhtml_Controller_Ac { switch ($this->getRequest()->getActionName()) { case 'markAsRead': - $acl = 'system/adminnotification/mark_as_read'; + $acl = 'Mage_AdminNotification::mark_as_read'; break; case 'massMarkAsRead': - $acl = 'system/adminnotification/mark_as_read'; + $acl = 'Mage_AdminNotification::mark_as_read'; break; case 'remove': - $acl = 'system/adminnotification/remove'; + $acl = 'Mage_AdminNotification::adminnotification_remove'; break; case 'massRemove': - $acl = 'system/adminnotification/remove'; + $acl = 'Mage_AdminNotification::adminnotification_remove'; break; default: - $acl = 'system/adminnotification/show_list'; + $acl = 'Mage_AdminNotification::show_list'; } return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed($acl); } diff --git a/app/code/core/Mage/Adminhtml/controllers/Poll/AnswerController.php b/app/code/core/Mage/Adminhtml/controllers/Poll/AnswerController.php index 22e15c5e004..d4cb2ffce33 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Poll/AnswerController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Poll/AnswerController.php @@ -125,7 +125,7 @@ class Mage_Adminhtml_Poll_AnswerController extends Mage_Adminhtml_Controller_Act protected function _isAllowed() { - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('cms/poll'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Poll::poll'); } } diff --git a/app/code/core/Mage/Adminhtml/controllers/PollController.php b/app/code/core/Mage/Adminhtml/controllers/PollController.php index 8a08775d8b8..16dad36c892 100644 --- a/app/code/core/Mage/Adminhtml/controllers/PollController.php +++ b/app/code/core/Mage/Adminhtml/controllers/PollController.php @@ -210,7 +210,7 @@ class Mage_Adminhtml_PollController extends Mage_Adminhtml_Controller_Action protected function _isAllowed() { - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('cms/poll'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Poll::poll'); } } diff --git a/app/code/core/Mage/Adminhtml/controllers/Promo/CatalogController.php b/app/code/core/Mage/Adminhtml/controllers/Promo/CatalogController.php index e663edffe28..8cfc1470b2b 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Promo/CatalogController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Promo/CatalogController.php @@ -303,7 +303,7 @@ class Mage_Adminhtml_Promo_CatalogController extends Mage_Adminhtml_Controller_A protected function _isAllowed() { - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('promo/catalog'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_CatalogRule::promo_catalog'); } /** diff --git a/app/code/core/Mage/Adminhtml/controllers/Promo/QuoteController.php b/app/code/core/Mage/Adminhtml/controllers/Promo/QuoteController.php index fc1ff2416c3..bf570006f24 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Promo/QuoteController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Promo/QuoteController.php @@ -411,6 +411,6 @@ class Mage_Adminhtml_Promo_QuoteController extends Mage_Adminhtml_Controller_Act */ protected function _isAllowed() { - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('promo/quote'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_SalesRule::quote'); } } diff --git a/app/code/core/Mage/Adminhtml/controllers/Promo/WidgetController.php b/app/code/core/Mage/Adminhtml/controllers/Promo/WidgetController.php index faff53cce6d..cb155fdd527 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Promo/WidgetController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Promo/WidgetController.php @@ -80,7 +80,7 @@ class Mage_Adminhtml_Promo_WidgetController extends Mage_Adminhtml_Controller_Ac protected function _isAllowed() { - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('promo/catalog'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_CatalogRule::promo_catalog'); } /** diff --git a/app/code/core/Mage/Adminhtml/controllers/PromoController.php b/app/code/core/Mage/Adminhtml/controllers/PromoController.php index fb21b4a656e..7613687c496 100644 --- a/app/code/core/Mage/Adminhtml/controllers/PromoController.php +++ b/app/code/core/Mage/Adminhtml/controllers/PromoController.php @@ -44,7 +44,7 @@ class Mage_Adminhtml_PromoController extends Mage_Adminhtml_Controller_Action protected function _isAllowed() { - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('promo'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_CatalogRule::promo'); } } diff --git a/app/code/core/Mage/Adminhtml/controllers/RatingController.php b/app/code/core/Mage/Adminhtml/controllers/RatingController.php index d5f8610f5e4..4aa5037a91b 100644 --- a/app/code/core/Mage/Adminhtml/controllers/RatingController.php +++ b/app/code/core/Mage/Adminhtml/controllers/RatingController.php @@ -156,7 +156,7 @@ class Mage_Adminhtml_RatingController extends Mage_Adminhtml_Controller_Action protected function _isAllowed() { - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('catalog/reviews_ratings/ratings'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Rating::ratings'); } } diff --git a/app/code/core/Mage/Adminhtml/controllers/Report/CustomerController.php b/app/code/core/Mage/Adminhtml/controllers/Report/CustomerController.php index 5357a6467bc..b1f1f565aeb 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Report/CustomerController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Report/CustomerController.php @@ -163,16 +163,16 @@ class Mage_Adminhtml_Report_CustomerController extends Mage_Adminhtml_Controller { switch ($this->getRequest()->getActionName()) { case 'accounts': - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('report/customers/accounts'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Reports::accounts'); break; case 'orders': - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('report/customers/orders'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Reports::customers_orders'); break; case 'totals': - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('report/customers/totals'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Reports::totals'); break; default: - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('report/customers'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Reports::customers'); break; } } diff --git a/app/code/core/Mage/Adminhtml/controllers/Report/ProductController.php b/app/code/core/Mage/Adminhtml/controllers/Report/ProductController.php index 10e35459ca9..3e2d0e040bb 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Report/ProductController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Report/ProductController.php @@ -239,16 +239,16 @@ class Mage_Adminhtml_Report_ProductController extends Mage_Adminhtml_Controller_ { switch ($this->getRequest()->getActionName()) { case 'viewed': - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('report/products/viewed'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Reports::viewed'); break; case 'sold': - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('report/products/sold'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Reports::sold'); break; case 'lowstock': - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('report/products/lowstock'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Reports::lowstock'); break; default: - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('report/products'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Reports::report_products'); break; } } diff --git a/app/code/core/Mage/Adminhtml/controllers/Report/ReviewController.php b/app/code/core/Mage/Adminhtml/controllers/Report/ReviewController.php index 845906dcb80..c90d3dfc5e3 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Report/ReviewController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Report/ReviewController.php @@ -162,13 +162,13 @@ class Mage_Adminhtml_Report_ReviewController extends Mage_Adminhtml_Controller_A { switch ($this->getRequest()->getActionName()) { case 'customer': - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('report/review/customer'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Reports::review_customer'); break; case 'product': - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('report/review/product'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Reports::review_product'); break; default: - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('report/review'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Reports::review'); break; } } diff --git a/app/code/core/Mage/Adminhtml/controllers/Report/SalesController.php b/app/code/core/Mage/Adminhtml/controllers/Report/SalesController.php index 1814539c679..a835da95d66 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Report/SalesController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Report/SalesController.php @@ -375,31 +375,31 @@ class Mage_Adminhtml_Report_SalesController extends Mage_Adminhtml_Controller_Re { switch ($this->getRequest()->getActionName()) { case 'sales': - return $this->_getSession()->isAllowed('report/salesroot/sales'); + return $this->_getSession()->isAllowed('Mage_Reports::salesroot_sales'); break; case 'tax': - return $this->_getSession()->isAllowed('report/salesroot/tax'); + return $this->_getSession()->isAllowed('Mage_Reports::tax'); break; case 'shipping': - return $this->_getSession()->isAllowed('report/salesroot/shipping'); + return $this->_getSession()->isAllowed('Mage_Reports::shipping'); break; case 'invoiced': - return $this->_getSession()->isAllowed('report/salesroot/invoiced'); + return $this->_getSession()->isAllowed('Mage_Reports::invoiced'); break; case 'refunded': - return $this->_getSession()->isAllowed('report/salesroot/refunded'); + return $this->_getSession()->isAllowed('Mage_Reports::refunded'); break; case 'coupons': - return $this->_getSession()->isAllowed('report/salesroot/coupons'); + return $this->_getSession()->isAllowed('Mage_Reports::coupons'); break; case 'shipping': - return $this->_getSession()->isAllowed('report/salesroot/shipping'); + return $this->_getSession()->isAllowed('Mage_Reports::shipping'); break; case 'bestsellers': - return $this->_getSession()->isAllowed('report/products/bestsellers'); + return $this->_getSession()->isAllowed('Mage_Reports::bestsellers'); break; default: - return $this->_getSession()->isAllowed('report/salesroot'); + return $this->_getSession()->isAllowed('Mage_Reports::salesroot'); break; } } diff --git a/app/code/core/Mage/Adminhtml/controllers/Report/ShopcartController.php b/app/code/core/Mage/Adminhtml/controllers/Report/ShopcartController.php index e8957c6278a..d1b78cc71a9 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Report/ShopcartController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Report/ShopcartController.php @@ -157,16 +157,17 @@ class Mage_Adminhtml_Report_ShopcartController extends Mage_Adminhtml_Controller { switch ($this->getRequest()->getActionName()) { case 'customer': - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('report/shopcart/customer'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session') + ->isAllowed(Mage_Backend_Model_Acl_Config::ACL_RESOURCE_ALL); break; case 'product': - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('report/shopcart/product'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Reports::product'); break; case 'abandoned': - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('report/shopcart/abandoned'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Reports::abandoned'); break; default: - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('report/shopcart'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Reports::shopcart'); break; } } diff --git a/app/code/core/Mage/Adminhtml/controllers/Report/StatisticsController.php b/app/code/core/Mage/Adminhtml/controllers/Report/StatisticsController.php index 7b6cc54066d..cdfbbffd8b3 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Report/StatisticsController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Report/StatisticsController.php @@ -186,7 +186,7 @@ class Mage_Adminhtml_Report_StatisticsController extends Mage_Adminhtml_Controll protected function _isAllowed() { - return $this->_getSession()->isAllowed('report/statistics'); + return $this->_getSession()->isAllowed('Mage_Reports::statistics'); } /** diff --git a/app/code/core/Mage/Adminhtml/controllers/Report/TagController.php b/app/code/core/Mage/Adminhtml/controllers/Report/TagController.php index e73513b1ef2..caf96bf18ca 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Report/TagController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Report/TagController.php @@ -284,19 +284,19 @@ class Mage_Adminhtml_Report_TagController extends Mage_Adminhtml_Controller_Acti { switch ($this->getRequest()->getActionName()) { case 'customer': - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('report/tags/customer'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Reports::tags_customer'); break; case 'product': - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('report/tags/product'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Reports::tags_product'); break; case 'productAll': - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('report/tags/product'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Reports::tags_product'); break; case 'popular': - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('report/tags/popular'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Reports::popular'); break; default: - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('report/tags'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Reports::tags'); break; } } diff --git a/app/code/core/Mage/Adminhtml/controllers/ReportController.php b/app/code/core/Mage/Adminhtml/controllers/ReportController.php index 0b65e32fc46..e612be0114c 100644 --- a/app/code/core/Mage/Adminhtml/controllers/ReportController.php +++ b/app/code/core/Mage/Adminhtml/controllers/ReportController.php @@ -82,10 +82,10 @@ class Mage_Adminhtml_ReportController extends Mage_Adminhtml_Controller_Action { switch ($this->getRequest()->getActionName()) { case 'search': - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('report/search'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Reports::report_search'); break; default: - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('report'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Reports::report'); break; } } diff --git a/app/code/core/Mage/Adminhtml/controllers/Sales/Billing/AgreementController.php b/app/code/core/Mage/Adminhtml/controllers/Sales/Billing/AgreementController.php index bc6f667566f..12c36ce3905 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Sales/Billing/AgreementController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Sales/Billing/AgreementController.php @@ -207,14 +207,14 @@ class Mage_Adminhtml_Sales_Billing_AgreementController extends Mage_Adminhtml_Co case 'index': case 'grid' : case 'view' : - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('sales/billing_agreement/actions/view'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Sales::billing_agreement_actions_view'); break; case 'cancel': case 'delete': - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('sales/billing_agreement/actions/manage'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Sales::actions_manage'); break; default: - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('sales/billing_agreement'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Sales::billing_agreement'); break; } } diff --git a/app/code/core/Mage/Adminhtml/controllers/Sales/Order/CreateController.php b/app/code/core/Mage/Adminhtml/controllers/Sales/Order/CreateController.php index 78db2720b63..a9bee9da7df 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Sales/Order/CreateController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Sales/Order/CreateController.php @@ -495,7 +495,7 @@ class Mage_Adminhtml_Sales_Order_CreateController extends Mage_Adminhtml_Control $this->_getSession()->clear(); Mage::getSingleton('Mage_Adminhtml_Model_Session')->addSuccess($this->__('The order has been created.')); - if (Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('sales/order/actions/view')) { + if (Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Sales::actions_view')) { $this->_redirect('*/sales_order/view', array('order_id' => $order->getId())); } else { $this->_redirect('*/sales_order/index'); @@ -531,16 +531,16 @@ class Mage_Adminhtml_Sales_Order_CreateController extends Mage_Adminhtml_Control switch ($action) { case 'index': case 'save': - $aclResource = 'sales/order/actions/create'; + $aclResource = 'Mage_Sales::create'; break; case 'reorder': - $aclResource = 'sales/order/actions/reorder'; + $aclResource = 'Mage_Sales::reorder'; break; case 'cancel': - $aclResource = 'sales/order/actions/cancel'; + $aclResource = 'Mage_Sales::cancel'; break; default: - $aclResource = 'sales/order/actions'; + $aclResource = 'Mage_Sales::actions'; break; } return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed($aclResource); diff --git a/app/code/core/Mage/Adminhtml/controllers/Sales/Order/EditController.php b/app/code/core/Mage/Adminhtml/controllers/Sales/Order/EditController.php index b09ee4c5c65..22905c676ab 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Sales/Order/EditController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Sales/Order/EditController.php @@ -81,6 +81,6 @@ class Mage_Adminhtml_Sales_Order_EditController extends Mage_Adminhtml_Sales_Ord */ protected function _isAllowed() { - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('sales/order/actions/edit'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Sales::actions_edit'); } } 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 8c18a3db189..f6f78c2c0e2 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Sales/Order/StatusController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Sales/Order/StatusController.php @@ -234,6 +234,6 @@ class Mage_Adminhtml_Sales_Order_StatusController extends Mage_Adminhtml_Control */ protected function _isAllowed() { - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('system/order_statuses'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Sales::order_statuses'); } } diff --git a/app/code/core/Mage/Adminhtml/controllers/Sales/OrderController.php b/app/code/core/Mage/Adminhtml/controllers/Sales/OrderController.php index e891015d4e8..3cdc084513f 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Sales/OrderController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Sales/OrderController.php @@ -653,31 +653,31 @@ class Mage_Adminhtml_Sales_OrderController extends Mage_Adminhtml_Controller_Act $action = strtolower($this->getRequest()->getActionName()); switch ($action) { case 'hold': - $aclResource = 'sales/order/actions/hold'; + $aclResource = 'Mage_Sales::hold'; break; case 'unhold': - $aclResource = 'sales/order/actions/unhold'; + $aclResource = 'Mage_Sales::unhold'; break; case 'email': - $aclResource = 'sales/order/actions/email'; + $aclResource = 'Mage_Sales::email'; break; case 'cancel': - $aclResource = 'sales/order/actions/cancel'; + $aclResource = 'Mage_Sales::cancel'; break; case 'view': - $aclResource = 'sales/order/actions/view'; + $aclResource = 'Mage_Sales::actions_view'; break; case 'addcomment': - $aclResource = 'sales/order/actions/comment'; + $aclResource = 'Mage_Sales::comment'; break; case 'creditmemos': - $aclResource = 'sales/order/actions/creditmemo'; + $aclResource = 'Mage_Sales::creditmemo'; break; case 'reviewpayment': - $aclResource = 'sales/order/actions/review_payment'; + $aclResource = 'Mage_Sales::review_payment'; break; default: - $aclResource = 'sales/order'; + $aclResource = 'Mage_Sales::sales_order'; break; } diff --git a/app/code/core/Mage/Adminhtml/controllers/Sales/TransactionsController.php b/app/code/core/Mage/Adminhtml/controllers/Sales/TransactionsController.php index 2dfeb908ab4..81ff5ca8138 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Sales/TransactionsController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Sales/TransactionsController.php @@ -132,10 +132,10 @@ class Mage_Adminhtml_Sales_TransactionsController extends Mage_Adminhtml_Control { switch ($this->getRequest()->getActionName()) { case 'fetch': - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('sales/transactions/fetch'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Sales::transactions_fetch'); break; default: - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('sales/transactions'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Sales::transactions'); break; } } diff --git a/app/code/core/Mage/Adminhtml/controllers/SitemapController.php b/app/code/core/Mage/Adminhtml/controllers/SitemapController.php index 05d8328ebf9..4801574ce86 100644 --- a/app/code/core/Mage/Adminhtml/controllers/SitemapController.php +++ b/app/code/core/Mage/Adminhtml/controllers/SitemapController.php @@ -280,6 +280,6 @@ class Mage_Adminhtml_SitemapController extends Mage_Adminhtml_Controller_Action */ protected function _isAllowed() { - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('catalog/sitemap'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Sitemap::sitemap'); } } diff --git a/app/code/core/Mage/Adminhtml/controllers/SurveyController.php b/app/code/core/Mage/Adminhtml/controllers/SurveyController.php index 61319838423..68c7dede4a2 100644 --- a/app/code/core/Mage/Adminhtml/controllers/SurveyController.php +++ b/app/code/core/Mage/Adminhtml/controllers/SurveyController.php @@ -53,6 +53,7 @@ class Mage_Adminhtml_SurveyController extends Mage_Adminhtml_Controller_Action */ protected function _isAllowed() { - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('all'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session') + ->isAllowed(Mage_Backend_Model_Acl_Config::ACL_RESOURCE_ALL); } } diff --git a/app/code/core/Mage/Adminhtml/controllers/System/AccountController.php b/app/code/core/Mage/Adminhtml/controllers/System/AccountController.php index 892fc1fcb5d..77f68c6bb1c 100644 --- a/app/code/core/Mage/Adminhtml/controllers/System/AccountController.php +++ b/app/code/core/Mage/Adminhtml/controllers/System/AccountController.php @@ -91,6 +91,6 @@ class Mage_Adminhtml_System_AccountController extends Mage_Adminhtml_Controller_ protected function _isAllowed() { - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('system/myaccount'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Adminhtml::myaccount'); } } diff --git a/app/code/core/Mage/Adminhtml/controllers/System/BackupController.php b/app/code/core/Mage/Adminhtml/controllers/System/BackupController.php index 4faf5d8d066..c8b5c5e1ed6 100644 --- a/app/code/core/Mage/Adminhtml/controllers/System/BackupController.php +++ b/app/code/core/Mage/Adminhtml/controllers/System/BackupController.php @@ -358,7 +358,7 @@ class Mage_Adminhtml_System_BackupController extends Mage_Adminhtml_Controller_A */ protected function _isAllowed() { - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('system/tools/backup'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Backup::backup'); } /** diff --git a/app/code/core/Mage/Adminhtml/controllers/System/ConfigController.php b/app/code/core/Mage/Adminhtml/controllers/System/ConfigController.php index 0b92fd06a28..9d1a77a1cf5 100644 --- a/app/code/core/Mage/Adminhtml/controllers/System/ConfigController.php +++ b/app/code/core/Mage/Adminhtml/controllers/System/ConfigController.php @@ -257,7 +257,7 @@ class Mage_Adminhtml_System_ConfigController extends Mage_Adminhtml_Controller_A */ protected function _isAllowed() { - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('system/config'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Adminhtml::config'); } /** @@ -272,9 +272,9 @@ class Mage_Adminhtml_System_ConfigController extends Mage_Adminhtml_Controller_A { try { $session = Mage::getSingleton('Mage_Backend_Model_Auth_Session'); - $resourceLookup = "admin/system/config/{$section}"; - if ($session->getData('acl') instanceof Mage_Admin_Model_Acl) { - $resourceId = $session->getData('acl')->get($resourceLookup)->getResourceId(); + if ($session->getData('acl') instanceof Magento_Acl) { + $resourceId = (string) Mage::getSingleton('Mage_Adminhtml_Model_Config') + ->getSection($section)->resource; if (!$session->isAllowed($resourceId)) { throw new Exception(''); } diff --git a/app/code/core/Mage/Adminhtml/controllers/System/Convert/GuiController.php b/app/code/core/Mage/Adminhtml/controllers/System/Convert/GuiController.php index 09283bbe0d3..b57d89d4a9f 100644 --- a/app/code/core/Mage/Adminhtml/controllers/System/Convert/GuiController.php +++ b/app/code/core/Mage/Adminhtml/controllers/System/Convert/GuiController.php @@ -151,6 +151,6 @@ class Mage_Adminhtml_System_Convert_GuiController extends Mage_Adminhtml_System_ // break; // } - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('admin/system/convert/gui'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Adminhtml::gui'); } } diff --git a/app/code/core/Mage/Adminhtml/controllers/System/Convert/ProfileController.php b/app/code/core/Mage/Adminhtml/controllers/System/Convert/ProfileController.php index dba0670af3d..3ce5b385648 100644 --- a/app/code/core/Mage/Adminhtml/controllers/System/Convert/ProfileController.php +++ b/app/code/core/Mage/Adminhtml/controllers/System/Convert/ProfileController.php @@ -312,6 +312,6 @@ class Mage_Adminhtml_System_Convert_ProfileController extends Mage_Adminhtml_Con protected function _isAllowed() { - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('admin/system/convert/profiles'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Adminhtml::profiles'); } } diff --git a/app/code/core/Mage/Adminhtml/controllers/System/CurrencyController.php b/app/code/core/Mage/Adminhtml/controllers/System/CurrencyController.php index 9776f9fd69f..94e2c006bad 100644 --- a/app/code/core/Mage/Adminhtml/controllers/System/CurrencyController.php +++ b/app/code/core/Mage/Adminhtml/controllers/System/CurrencyController.php @@ -122,6 +122,6 @@ class Mage_Adminhtml_System_CurrencyController extends Mage_Adminhtml_Controller protected function _isAllowed() { - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('system/currency/rates'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_CurrencySymbol::currency_rates'); } } diff --git a/app/code/core/Mage/Adminhtml/controllers/System/DesignController.php b/app/code/core/Mage/Adminhtml/controllers/System/DesignController.php index f2bf325e814..e12d6567a86 100644 --- a/app/code/core/Mage/Adminhtml/controllers/System/DesignController.php +++ b/app/code/core/Mage/Adminhtml/controllers/System/DesignController.php @@ -127,6 +127,6 @@ class Mage_Adminhtml_System_DesignController extends Mage_Adminhtml_Controller_A protected function _isAllowed() { - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('system/design'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Adminhtml::design'); } } 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 dfc174fe571..8df9744ff17 100644 --- a/app/code/core/Mage/Adminhtml/controllers/System/Email/TemplateController.php +++ b/app/code/core/Mage/Adminhtml/controllers/System/Email/TemplateController.php @@ -225,6 +225,6 @@ class Mage_Adminhtml_System_Email_TemplateController extends Mage_Adminhtml_Cont protected function _isAllowed() { - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('system/email_template'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Adminhtml::email_template'); } } diff --git a/app/code/core/Mage/Adminhtml/controllers/System/StoreController.php b/app/code/core/Mage/Adminhtml/controllers/System/StoreController.php index cde7f647688..7119fd97f0a 100644 --- a/app/code/core/Mage/Adminhtml/controllers/System/StoreController.php +++ b/app/code/core/Mage/Adminhtml/controllers/System/StoreController.php @@ -448,7 +448,7 @@ class Mage_Adminhtml_System_StoreController extends Mage_Adminhtml_Controller_Ac protected function _isAllowed() { - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('system/store'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Adminhtml::store'); } /** diff --git a/app/code/core/Mage/Adminhtml/controllers/System/VariableController.php b/app/code/core/Mage/Adminhtml/controllers/System/VariableController.php index f7bd4ac0d5c..535e5b26fed 100644 --- a/app/code/core/Mage/Adminhtml/controllers/System/VariableController.php +++ b/app/code/core/Mage/Adminhtml/controllers/System/VariableController.php @@ -201,6 +201,6 @@ class Mage_Adminhtml_System_VariableController extends Mage_Adminhtml_Controller */ protected function _isAllowed() { - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('system/variable'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Adminhtml::variable'); } } diff --git a/app/code/core/Mage/Adminhtml/controllers/SystemController.php b/app/code/core/Mage/Adminhtml/controllers/SystemController.php index 3050961dc91..e6ed5fb6e68 100644 --- a/app/code/core/Mage/Adminhtml/controllers/SystemController.php +++ b/app/code/core/Mage/Adminhtml/controllers/SystemController.php @@ -52,6 +52,6 @@ class Mage_Adminhtml_SystemController extends Mage_Adminhtml_Controller_Action protected function _isAllowed() { - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('system'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Adminhtml::system'); } } diff --git a/app/code/core/Mage/Adminhtml/controllers/TagController.php b/app/code/core/Mage/Adminhtml/controllers/TagController.php index aa903c79116..64f3dd83f72 100644 --- a/app/code/core/Mage/Adminhtml/controllers/TagController.php +++ b/app/code/core/Mage/Adminhtml/controllers/TagController.php @@ -348,13 +348,13 @@ class Mage_Adminhtml_TagController extends Mage_Adminhtml_Controller_Action { switch ($this->getRequest()->getActionName()) { case 'pending': - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('catalog/tag/pending'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Tag::tag_pending'); break; case 'all': - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('catalog/tag/all'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Tag::tag_all'); break; default: - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('catalog/tag'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Tag::tag'); break; } } 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 7990e9279c8..f41451998a9 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Tax/Class/CustomerController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Tax/Class/CustomerController.php @@ -182,6 +182,6 @@ class Mage_Adminhtml_Tax_Class_CustomerController extends Mage_Adminhtml_Control */ protected function _isAllowed() { - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('sales/tax/classes_customer'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Tax::classes_customer'); } } 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 5283f137a8f..3a57a111224 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Tax/Class/ProductController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Tax/Class/ProductController.php @@ -181,7 +181,7 @@ class Mage_Adminhtml_Tax_Class_ProductController extends Mage_Adminhtml_Controll */ protected function _isAllowed() { - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('sales/tax/classes_product'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Tax::classes_product'); } } diff --git a/app/code/core/Mage/Adminhtml/controllers/Tax/ClassController.php b/app/code/core/Mage/Adminhtml/controllers/Tax/ClassController.php index eca1b2b141a..70b0f7d1ab6 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Tax/ClassController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Tax/ClassController.php @@ -97,7 +97,7 @@ class Mage_Adminhtml_Tax_ClassController extends Mage_Adminhtml_Controller_Actio */ protected function _isAllowed() { - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('sales/tax/classes_product') - || Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('sales/tax/classes_customer'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Tax::classes_product') + || Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Tax::classes_customer'); } } diff --git a/app/code/core/Mage/Adminhtml/controllers/Tax/RateController.php b/app/code/core/Mage/Adminhtml/controllers/Tax/RateController.php index 0fa4530dc2c..6cb6bf199f6 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Tax/RateController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Tax/RateController.php @@ -464,13 +464,13 @@ class Mage_Adminhtml_Tax_RateController extends Mage_Adminhtml_Controller_Action switch ($this->getRequest()->getActionName()) { case 'importExport': - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('sales/tax/import_export'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Tax::import_export'); break; case 'index': - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('sales/tax/rates'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Tax::tax_rates'); break; default: - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('sales/tax/rates'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Tax::tax_rates'); break; } } diff --git a/app/code/core/Mage/Adminhtml/controllers/Tax/RuleController.php b/app/code/core/Mage/Adminhtml/controllers/Tax/RuleController.php index e67fb5ac75b..9de1f50b700 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Tax/RuleController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Tax/RuleController.php @@ -165,6 +165,6 @@ class Mage_Adminhtml_Tax_RuleController extends Mage_Adminhtml_Controller_Action protected function _isAllowed() { - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('sales/tax/rules'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Tax::rules'); } } diff --git a/app/code/core/Mage/Adminhtml/controllers/UrlrewriteController.php b/app/code/core/Mage/Adminhtml/controllers/UrlrewriteController.php index febbaa15a30..a398eeaede9 100644 --- a/app/code/core/Mage/Adminhtml/controllers/UrlrewriteController.php +++ b/app/code/core/Mage/Adminhtml/controllers/UrlrewriteController.php @@ -229,6 +229,6 @@ class Mage_Adminhtml_UrlrewriteController extends Mage_Adminhtml_Controller_Acti */ protected function _isAllowed() { - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('catalog/urlrewrite'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Catalog::urlrewrite'); } } diff --git a/app/code/core/Mage/Adminhtml/etc/adminhtml.xml b/app/code/core/Mage/Adminhtml/etc/adminhtml.xml deleted file mode 100644 index c69a3c1a37a..00000000000 --- a/app/code/core/Mage/Adminhtml/etc/adminhtml.xml +++ /dev/null @@ -1,177 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License (AFL 3.0) - * that is bundled with this package in the file LICENSE_AFL.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/afl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @category Mage - * @package Mage_Adminhtml - * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - */ ---> -<config> - <acl> - <resources> - <all> - <title>Allow everything</title> - </all> - <admin translate="title" module="Mage_Adminhtml"> - <title>Magento Admin</title> - <children> - <dashboard translate="title"> - <title>Dashboard</title> - <sort_order>0</sort_order> - </dashboard> - <system translate="title"> - <title>System</title> - <sort_order>90</sort_order> - <children> - <store translate="title"> - <title>Manage Stores</title> - </store> - <design translate="title"> - <title>Design</title> - <sort_order>25</sort_order> - <children> - <schedule translate="title"> - <title>Schedule</title> - <sort_order>10</sort_order> - </schedule> - </children> - </design> - <config translate="title"> - <title>Configuration</title> - <sort_order>20</sort_order> - <children> - <general translate="title"> - <title>General Section</title> - <sort_order>20</sort_order> - </general> - <web translate="title"> - <title>Web Section</title> - <sort_order>30</sort_order> - </web> - <design translate="title"> - <title>Design Section</title> - <sort_order>40</sort_order> - </design> - <system translate="title"> - <title>System Section</title> - <sort_order>80</sort_order> - </system> - <advanced translate="title"> - <title>Advanced Section</title> - <sort_order>90</sort_order> - </advanced> - <trans_email translate="title"> - <title>Store Email Addresses Section</title> - <sort_order>100</sort_order> - </trans_email> - <dev translate="title"> - <title>Developer Section</title> - <sort_order>110</sort_order> - </dev> - <currency translate="title"> - <title>Currency Setup Section</title> - <sort_order>120</sort_order> - </currency> - <sendfriend translate="title"> - <title>Email to a Friend</title> - <sort_order>140</sort_order> - </sendfriend> - <admin translate="title"> - <title>Advanced Admin Section</title> - <sort_order>100</sort_order> - </admin> - </children> - </config> - <currency translate="title"> - <title>Manage Currency Rates</title> - <sort_order>30</sort_order> - </currency> - <email_template translate="title"> - <title>Transactional Emails</title> - <sort_order>40</sort_order> - </email_template> - <variable translate="title"> - <title>Custom Variables</title> - <sort_order>45</sort_order> - </variable> - <myaccount translate="title"> - <title>My Account</title> - <sort_order>50</sort_order> - </myaccount> - <tools translate="title"> - <title>Tools</title> - <sort_order>60</sort_order> - </tools> - <convert translate="title"> - <title>Import/Export</title> - <children> - <gui translate="title"> - <title>Dataflow - Profiles</title> - </gui> - <profiles translate="title"> - <title>Dataflow - Advanced Profiles</title> - </profiles> - </children> - </convert> - <cache translate="title"> - <title>Cache Management</title> - </cache> - <extensions translate="title"> - <title>Magento Connect</title> - <children> - <local translate="title"> - <title>Magento Connect Manager</title> - <sort_order>0</sort_order> - </local> - <custom translate="title"> - <title>Package Extensions</title> - <sort_order>5</sort_order> - </custom> - </children> - </extensions> - </children> - </system> - <global_search translate="title"> - <title>Global Search</title> - <sort_order>100</sort_order> - </global_search> - </children> - </admin> - </resources> - <privilegeSets> - <default> - <view> - <descr>View entity</descr> - </view> - <edit> - <descr>Edit entity</descr> - </edit> - <delete> - <descr/> - </delete> - <create> - <descr/> - </create> - </default> - </privilegeSets> - </acl> -</config> diff --git a/app/code/core/Mage/Adminhtml/etc/adminhtml/acl.xml b/app/code/core/Mage/Adminhtml/etc/adminhtml/acl.xml new file mode 100644 index 00000000000..666a65aec96 --- /dev/null +++ b/app/code/core/Mage/Adminhtml/etc/adminhtml/acl.xml @@ -0,0 +1,70 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Mage + * @package Mage_Adminhtml + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config> + <acl> + <resources> + <resource id="Mage_Adminhtml::all" title="Allow everything" /> + <resource id="Mage_Adminhtml::admin" module="Mage_Adminhtml" title="Magento Admin"> + <resource id="Mage_Adminhtml::dashboard" title="Dashboard" sortOrder="0" /> + <resource id="Mage_Adminhtml::system" title="System" sortOrder="90"> + <resource id="Mage_Adminhtml::store" title="Manage Stores" /> + <resource id="Mage_Adminhtml::design" title="Design" sortOrder="25"> + <resource id="Mage_Adminhtml::schedule" title="Schedule" sortOrder="10" /> + </resource> + <resource id="Mage_Adminhtml::config" title="Configuration" sortOrder="20"> + <resource id="Mage_Adminhtml::config_general" title="General Section" sortOrder="20" /> + <resource id="Mage_Adminhtml::web" title="Web Section" sortOrder="30" /> + <resource id="Mage_Adminhtml::config_design" title="Design Section" sortOrder="40" /> + <resource id="Mage_Adminhtml::config_system" title="System Section" sortOrder="80" /> + <resource id="Mage_Adminhtml::advanced" title="Advanced Section" sortOrder="90" /> + <resource id="Mage_Adminhtml::trans_email" title="Store Email Addresses Section" sortOrder="100" /> + <resource id="Mage_Adminhtml::dev" title="Developer Section" sortOrder="110" /> + <resource id="Mage_Adminhtml::currency" title="Currency Setup Section" sortOrder="120" /> + <resource id="Mage_Adminhtml::sendfriend" title="Email to a Friend" sortOrder="140" /> + <resource id="Mage_Adminhtml::config_admin" title="Advanced Admin Section" sortOrder="100" /> + </resource> + <resource id="Mage_CurrencySymbol::system_currency" title="Manage Currency Rates" sortOrder="30" /> + <resource id="Mage_Adminhtml::email_template" title="Transactional Emails" sortOrder="40" /> + <resource id="Mage_Adminhtml::variable" title="Custom Variables" sortOrder="45" /> + <resource id="Mage_Adminhtml::myaccount" title="My Account" sortOrder="50" /> + <resource id="Mage_Adminhtml::tools" title="Tools" sortOrder="60" /> + <resource id="Mage_Adminhtml::convert" title="Import/Export"> + <resource id="Mage_Adminhtml::gui" title="Dataflow - Profiles" /> + <resource id="Mage_Adminhtml::profiles" title="Dataflow - Advanced Profiles" /> + </resource> + <resource id="Mage_Adminhtml::cache" title="Cache Management" /> + <resource id="Mage_Adminhtml::extensions" title="Magento Connect"> + <resource id="Mage_Adminhtml::local" title="Magento Connect Manager" sortOrder="0" /> + <resource id="Mage_Adminhtml::custom" title="Package Extensions" sortOrder="5" /> + </resource> + </resource> + <resource id="Mage_Adminhtml::global_search" title="Global Search" sortOrder="100" /> + </resource> + </resources> + </acl> +</config> diff --git a/app/code/core/Mage/Adminhtml/etc/adminhtml/menu.xml b/app/code/core/Mage/Adminhtml/etc/adminhtml/menu.xml index a2dc5c9837e..1121235fb12 100644 --- a/app/code/core/Mage/Adminhtml/etc/adminhtml/menu.xml +++ b/app/code/core/Mage/Adminhtml/etc/adminhtml/menu.xml @@ -27,20 +27,20 @@ --> <config> <menu> - <add id="Mage_Adminhtml::dashboard" title="Dashboard" module="Mage_Adminhtml" sortOrder="10" action="adminhtml/dashboard" /> - <add id="Mage_Adminhtml::system" title="System" module="Mage_Adminhtml" sortOrder="90" /> - <add id="Mage_Adminhtml::system_myaccount" title="My Account" module="Mage_Adminhtml" sortOrder="10" parent="Mage_Adminhtml::system" action="adminhtml/system_account" /> - <add id="Mage_Adminhtml::system_tools" title="Tools" module="Mage_Adminhtml" sortOrder="20" parent="Mage_Adminhtml::system" /> - <add id="Mage_Adminhtml::system_design" title="Design" module="Mage_Adminhtml" sortOrder="30" parent="Mage_Adminhtml::system" /> - <add id="Mage_Adminhtml::system_design_schedule" title="Schedule" module="Mage_Adminhtml" sortOrder="10" parent="Mage_Adminhtml::system_design" action="adminhtml/system_design" /> - <add id="Mage_Adminhtml::system_convert" title="Import/Export" module="Mage_Adminhtml" sortOrder="40" parent="Mage_Adminhtml::system" /> - <add id="Mage_Adminhtml::system_convert_gui" title="Dataflow - Profiles" module="Mage_Adminhtml" sortOrder="30" parent="Mage_Adminhtml::system_convert" action="adminhtml/system_convert_gui" /> - <add id="Mage_Adminhtml::system_convert_profiles" title="Dataflow - Advanced Profiles" module="Mage_Adminhtml" sortOrder="40" parent="Mage_Adminhtml::system_convert" action="adminhtml/system_convert_profile" /> - <add id="Mage_Adminhtml::system_currency" title="Manage Currency Rates" module="Mage_Adminhtml" sortOrder="50" parent="Mage_Adminhtml::system" action="adminhtml/system_currency" /> - <add id="Mage_Adminhtml::system_email_template" title="Transactional Emails" module="Mage_Adminhtml" sortOrder="60" parent="Mage_Adminhtml::system" action="adminhtml/system_email_template" /> - <add id="Mage_Adminhtml::system_variable" title="Custom Variables" module="Mage_Adminhtml" sortOrder="65" parent="Mage_Adminhtml::system" action="adminhtml/system_variable" /> - <add id="Mage_Adminhtml::system_cache" title="Cache Management" module="Mage_Adminhtml" sortOrder="90" parent="Mage_Adminhtml::system" action="adminhtml/cache" /> - <add id="Mage_Adminhtml::system_store" title="Manage Stores" module="Mage_Core" sortOrder="100" parent="Mage_Adminhtml::system" action="adminhtml/system_store/" /> - <add id="Mage_Adminhtml::system_config" title="Configuration" module="Mage_Adminhtml" sortOrder="110" parent="Mage_Adminhtml::system" action="adminhtml/system_config" /> + <add id="Mage_Adminhtml::dashboard" title="Dashboard" module="Mage_Adminhtml" sortOrder="10" action="adminhtml/dashboard" resource="Mage_Adminhtml::dashboard"/> + <add id="Mage_Adminhtml::system" title="System" module="Mage_Adminhtml" sortOrder="90" resource="Mage_Adminhtml::system"/> + <add id="Mage_Adminhtml::system_myaccount" title="My Account" module="Mage_Adminhtml" sortOrder="10" parent="Mage_Adminhtml::system" action="adminhtml/system_account" resource="Mage_Adminhtml::myaccount"/> + <add id="Mage_Adminhtml::system_tools" title="Tools" module="Mage_Adminhtml" sortOrder="20" parent="Mage_Adminhtml::system" resource="Mage_Adminhtml::tools"/> + <add id="Mage_Adminhtml::system_design" title="Design" module="Mage_Adminhtml" sortOrder="30" parent="Mage_Adminhtml::system" resource="Mage_Adminhtml::design"/> + <add id="Mage_Adminhtml::system_design_schedule" title="Schedule" module="Mage_Adminhtml" sortOrder="10" parent="Mage_Adminhtml::system_design" action="adminhtml/system_design" resource="Mage_Adminhtml::schedule"/> + <add id="Mage_Adminhtml::system_convert" title="Import/Export" module="Mage_Adminhtml" sortOrder="40" parent="Mage_Adminhtml::system" resource="Mage_Adminhtml::convert"/> + <add id="Mage_Adminhtml::system_convert_gui" title="Dataflow - Profiles" module="Mage_Adminhtml" sortOrder="30" parent="Mage_Adminhtml::system_convert" action="adminhtml/system_convert_gui" resource="Mage_Adminhtml::gui"/> + <add id="Mage_Adminhtml::system_convert_profiles" title="Dataflow - Advanced Profiles" module="Mage_Adminhtml" sortOrder="40" parent="Mage_Adminhtml::system_convert" action="adminhtml/system_convert_profile" resource="Mage_Adminhtml::profiles"/> + <add id="Mage_Adminhtml::system_currency" title="Manage Currency Rates" module="Mage_Adminhtml" sortOrder="50" parent="Mage_Adminhtml::system" action="adminhtml/system_currency" resource="Mage_CurrencySymbol::system_currency"/> + <add id="Mage_Adminhtml::system_email_template" title="Transactional Emails" module="Mage_Adminhtml" sortOrder="60" parent="Mage_Adminhtml::system" action="adminhtml/system_email_template" resource="Mage_Adminhtml::email_template"/> + <add id="Mage_Adminhtml::system_variable" title="Custom Variables" module="Mage_Adminhtml" sortOrder="65" parent="Mage_Adminhtml::system" action="adminhtml/system_variable" resource="Mage_Adminhtml::variable"/> + <add id="Mage_Adminhtml::system_cache" title="Cache Management" module="Mage_Adminhtml" sortOrder="90" parent="Mage_Adminhtml::system" action="adminhtml/cache" resource="Mage_Adminhtml::cache"/> + <add id="Mage_Adminhtml::system_store" title="Manage Stores" module="Mage_Core" sortOrder="100" parent="Mage_Adminhtml::system" action="adminhtml/system_store/" resource="Mage_Adminhtml::store"/> + <add id="Mage_Adminhtml::system_config" title="Configuration" module="Mage_Adminhtml" sortOrder="110" parent="Mage_Adminhtml::system" action="adminhtml/system_config" resource="Mage_Adminhtml::config"/> </menu> </config> diff --git a/app/code/core/Mage/Adminhtml/etc/config.xml b/app/code/core/Mage/Adminhtml/etc/config.xml index 1a6af112fb5..23c8d6ccab5 100644 --- a/app/code/core/Mage/Adminhtml/etc/config.xml +++ b/app/code/core/Mage/Adminhtml/etc/config.xml @@ -90,15 +90,15 @@ <global_search> <products> <class>Mage_Adminhtml_Model_Search_Catalog</class> - <acl>catalog</acl> + <acl>Mage_Catalog::catalog</acl> </products> <customers> <class>Mage_Adminhtml_Model_Search_Customer</class> - <acl>customer</acl> + <acl>Mage_Customer::customer</acl> </customers> <sales> <class>Mage_Adminhtml_Model_Search_Order</class> - <acl>sales</acl> + <acl>Mage_Sales::sales</acl> </sales> </global_search> <translate> diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/adminnotification.xml b/app/code/core/Mage/Adminhtml/view/adminhtml/adminnotification.xml index 5c4bc5d5496..6fc257d25ac 100644 --- a/app/code/core/Mage/Adminhtml/view/adminhtml/adminnotification.xml +++ b/app/code/core/Mage/Adminhtml/view/adminhtml/adminnotification.xml @@ -29,10 +29,10 @@ <layout> <default> <reference name="notifications"> - <block type="Mage_Adminhtml_Block_Notification_Toolbar" name="notification_toolbar" as="notification_toolbar" acl="system/adminnotification/show_toolbar" template="notification/toolbar.phtml" /> + <block type="Mage_Adminhtml_Block_Notification_Toolbar" name="notification_toolbar" as="notification_toolbar" acl="Mage_AdminNotification::show_toolbar" template="notification/toolbar.phtml" /> </reference> <reference name="notifications"> - <block type="Mage_Adminhtml_Block_Notification_Window" name="notification_window" as="notification_window" acl="system/adminnotification/show_toolbar" template="notification/window.phtml" /> + <block type="Mage_Adminhtml_Block_Notification_Window" name="notification_window" as="notification_window" acl="Mage_AdminNotification::show_toolbar" template="notification/window.phtml" /> </reference> </default> </layout> diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/page/header.phtml b/app/code/core/Mage/Adminhtml/view/adminhtml/page/header.phtml index 75da6536b7f..7f812974fb3 100644 --- a/app/code/core/Mage/Adminhtml/view/adminhtml/page/header.phtml +++ b/app/code/core/Mage/Adminhtml/view/adminhtml/page/header.phtml @@ -32,7 +32,7 @@ <p class="super"> <?php echo $this->__("Logged in as %s", $this->escapeHtml($this->getUser()->getUsername())) ?><span class="separator">|</span><?php echo $this->formatDate(null, 'full') ?><span class="separator">|</span><a href="http://golinks.magento.com/CE15" onclick="this.target='_blank'" class="go-try"><?php echo $this->__('Try Magento Go for Free') ?></a><span class="separator">|</span><a href="<?php echo $this->getLogoutLink() ?>" class="link-logout"><?php echo $this->__('Log Out') ?></a> </p> - <?php if ( Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('admin/global_search') ): ?> + <?php if ( Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Adminhtml::global_search') ): ?> <fieldset> <legend>Search</legend> <span id="global_search_indicator" class="autocomplete-indicator" style="display: none"> diff --git a/app/code/core/Mage/Adminhtml/view/adminhtml/system/config/switcher.phtml b/app/code/core/Mage/Adminhtml/view/adminhtml/system/config/switcher.phtml index e26056ee0b2..f32eff4ec36 100644 --- a/app/code/core/Mage/Adminhtml/view/adminhtml/system/config/switcher.phtml +++ b/app/code/core/Mage/Adminhtml/view/adminhtml/system/config/switcher.phtml @@ -43,7 +43,7 @@ </option> <?php endforeach ?> </select> - <?php if (Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('system/store')): ?> + <?php if (Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Adminhtml::store')): ?> <p style="margin:10px 0 0;"> <a href="<?php echo $this->getUrl('*/system_store') ?>"><?php echo $this->__('Manage Stores') ?></a> </p> diff --git a/app/code/core/Mage/Api/etc/adminhtml.xml b/app/code/core/Mage/Api/etc/adminhtml.xml deleted file mode 100644 index 5dfb93fdc50..00000000000 --- a/app/code/core/Mage/Api/etc/adminhtml.xml +++ /dev/null @@ -1,62 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License (AFL 3.0) - * that is bundled with this package in the file LICENSE_AFL.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/afl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @category Mage - * @package Mage_Api - * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - */ ---> -<config> - <acl> - <resources> - <admin> - <children> - <system> - <children> - <api translate="title" module="Mage_Api"> - <title>Web Services</title> - <sort_order>0</sort_order> - <children> - <users translate="title"> - <title>SOAP/XML-RPC - Users</title> - <sort_order>10</sort_order> - </users> - <roles translate="title"> - <title>SOAP/XML-RPC - Roles</title> - <sort_order>20</sort_order> - </roles> - </children> - </api> - <config> - <children> - <api translate="title" module="Mage_Api"> - <title>Magento Core API Section</title> - </api> - </children> - </config> - </children> - </system> - </children> - </admin> - </resources> - </acl> -</config> diff --git a/app/code/core/Mage/CatalogInventory/etc/adminhtml.xml b/app/code/core/Mage/Api/etc/adminhtml/acl.xml similarity index 58% rename from app/code/core/Mage/CatalogInventory/etc/adminhtml.xml rename to app/code/core/Mage/Api/etc/adminhtml/acl.xml index e4da40f01f7..9e7e1b02690 100644 --- a/app/code/core/Mage/CatalogInventory/etc/adminhtml.xml +++ b/app/code/core/Mage/Api/etc/adminhtml/acl.xml @@ -20,7 +20,7 @@ * needs please refer to http://www.magentocommerce.com for more information. * * @category Mage - * @package Mage_CatalogInventory + * @package Mage_Api * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ @@ -28,21 +28,17 @@ <config> <acl> <resources> - <admin> - <children> - <system> - <children> - <config> - <children> - <cataloginventory translate="title" module="Mage_CatalogInventory"> - <title>Inventory Section</title> - </cataloginventory> - </children> - </config> - </children> - </system> - </children> - </admin> + <resource id="Mage_Adminhtml::admin"> + <resource id="Mage_Adminhtml::system"> + <resource id="Mage_Api::api" module="Mage_Api" title="Web Services" sortOrder="0"> + <resource id="Mage_Api::users" title="SOAP/XML-RPC - Users" sortOrder="10" /> + <resource id="Mage_Api::roles" title="SOAP/XML-RPC - Roles" sortOrder="20" /> + </resource> + <resource id="Mage_Adminhtml::config"> + <resource id="Mage_Api::config_api" module="Mage_Api" title="Magento Core API Section" /> + </resource> + </resource> + </resource> </resources> </acl> </config> diff --git a/app/code/core/Mage/Api/etc/adminhtml/menu.xml b/app/code/core/Mage/Api/etc/adminhtml/menu.xml index 722de4b537e..a00cdb2092c 100644 --- a/app/code/core/Mage/Api/etc/adminhtml/menu.xml +++ b/app/code/core/Mage/Api/etc/adminhtml/menu.xml @@ -27,8 +27,8 @@ --> <config> <menu> - <add id="Mage_Api::system_api" title="Web Services" module="Mage_Api" sortOrder="25" parent="Mage_Adminhtml::system" /> - <add id="Mage_Api::system_api_users" title="SOAP/XML-RPC - Users" module="Mage_Api" sortOrder="10" parent="Mage_Api::system_api" action="adminhtml/api_user" /> - <add id="Mage_Api::system_api_roles" title="SOAP/XML-RPC - Roles" module="Mage_Api" sortOrder="20" parent="Mage_Api::system_api" action="adminhtml/api_role" /> + <add id="Mage_Api::system_api" title="Web Services" module="Mage_Api" sortOrder="25" parent="Mage_Adminhtml::system" resource="Mage_Api::api"/> + <add id="Mage_Api::system_api_users" title="SOAP/XML-RPC - Users" module="Mage_Api" sortOrder="10" parent="Mage_Api::system_api" action="adminhtml/api_user" resource="Mage_Api::users"/> + <add id="Mage_Api::system_api_roles" title="SOAP/XML-RPC - Roles" module="Mage_Api" sortOrder="20" parent="Mage_Api::system_api" action="adminhtml/api_role" resource="Mage_Api::roles"/> </menu> </config> diff --git a/app/code/core/Mage/Api/etc/system.xml b/app/code/core/Mage/Api/etc/system.xml index 0f0034d6765..de89fe4ed58 100644 --- a/app/code/core/Mage/Api/etc/system.xml +++ b/app/code/core/Mage/Api/etc/system.xml @@ -35,6 +35,7 @@ <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>1</show_in_store> + <resource>Mage_Api::config_api</resource> <groups> <config translate="label"> <label>General Settings</label> diff --git a/app/code/core/Mage/Api2/Block/Adminhtml/Attribute/Grid.php b/app/code/core/Mage/Api2/Block/Adminhtml/Attribute/Grid.php index bce3f350f3f..5627bca788c 100644 --- a/app/code/core/Mage/Api2/Block/Adminhtml/Attribute/Grid.php +++ b/app/code/core/Mage/Api2/Block/Adminhtml/Attribute/Grid.php @@ -98,7 +98,7 @@ class Mage_Api2_Block_Adminhtml_Attribute_Grid extends Mage_Adminhtml_Block_Widg { /** @var $session Mage_Backend_Model_Auth_Session */ $session = Mage::getSingleton('Mage_Backend_Model_Auth_Session'); - if ($session->isAllowed('system/api/attributes/edit')) { + if ($session->isAllowed('Mage_Api2::rest_attributes_edit')) { return $this->getUrl('*/*/edit', array('type' => $row->getUserTypeCode())); } diff --git a/app/code/core/Mage/Api2/Block/Adminhtml/Roles.php b/app/code/core/Mage/Api2/Block/Adminhtml/Roles.php index 360d07ebbb7..4a0a5585cff 100644 --- a/app/code/core/Mage/Api2/Block/Adminhtml/Roles.php +++ b/app/code/core/Mage/Api2/Block/Adminhtml/Roles.php @@ -47,7 +47,7 @@ class Mage_Api2_Block_Adminhtml_Roles extends Mage_Adminhtml_Block_Widget_Grid_C //check allow edit /** @var $session Mage_Backend_Model_Auth_Session */ $session = Mage::getSingleton('Mage_Backend_Model_Auth_Session'); - if ($session->isAllowed('system/api/roles/add')) { + if ($session->isAllowed('Mage_Api2::rest_roles_add')) { $this->_updateButton('add', 'label', $this->__('Add Admin Role')); } else { $this->_removeButton('add'); diff --git a/app/code/core/Mage/Api2/Block/Adminhtml/Roles/Grid.php b/app/code/core/Mage/Api2/Block/Adminhtml/Roles/Grid.php index 72c40cb8cc5..c5988e303b5 100644 --- a/app/code/core/Mage/Api2/Block/Adminhtml/Roles/Grid.php +++ b/app/code/core/Mage/Api2/Block/Adminhtml/Roles/Grid.php @@ -116,7 +116,7 @@ class Mage_Api2_Block_Adminhtml_Roles_Grid extends Mage_Adminhtml_Block_Widget_G /** @var $session Mage_Backend_Model_Auth_Session */ $session = Mage::getSingleton('Mage_Backend_Model_Auth_Session'); - if ($session->isAllowed('system/api/roles/edit')) { + if ($session->isAllowed('Mage_Api2::rest_roles_edit')) { return $this->getUrl('*/*/edit', array('id' => $row->getId())); } return null; diff --git a/app/code/core/Mage/Api2/controllers/Adminhtml/Api2/RoleController.php b/app/code/core/Mage/Api2/controllers/Adminhtml/Api2/RoleController.php index 2551cc242a1..f6462a34958 100644 --- a/app/code/core/Mage/Api2/controllers/Adminhtml/Api2/RoleController.php +++ b/app/code/core/Mage/Api2/controllers/Adminhtml/Api2/RoleController.php @@ -267,7 +267,7 @@ class Mage_Api2_Adminhtml_Api2_RoleController extends Mage_Adminhtml_Controller_ { /** @var $session Mage_Backend_Model_Auth_Session */ $session = Mage::getSingleton('Mage_Backend_Model_Auth_Session'); - return $session->isAllowed('system/api/roles_rest'); + return $session->isAllowed('Mage_Api2::rest_roles'); } /** diff --git a/app/code/core/Mage/Api2/etc/adminhtml.xml b/app/code/core/Mage/Api2/etc/adminhtml.xml deleted file mode 100644 index 7b210ceb892..00000000000 --- a/app/code/core/Mage/Api2/etc/adminhtml.xml +++ /dev/null @@ -1,73 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License (AFL 3.0) - * that is bundled with this package in the file LICENSE_AFL.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/afl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @category Mage - * @package Mage_Api2 - * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - */ ---> -<config> - <acl> - <resources> - <admin> - <children> - <system> - <children> - <api> - <children> - <rest_roles translate="title" module="Mage_Api2"> - <title>REST - Roles</title> - <sort_order>30</sort_order> - <children> - <add translate="title"> - <title>Add</title> - <sort_order>10</sort_order> - </add> - <edit translate="title"> - <title>Edit</title> - <sort_order>20</sort_order> - </edit> - <delete translate="title"> - <title>Delete</title> - <sort_order>30</sort_order> - </delete> - </children> - </rest_roles> - <rest_attributes translate="title" module="Mage_Api2"> - <title>REST - Attributes</title> - <sort_order>40</sort_order> - <children> - <edit translate="title"> - <title>Edit</title> - <sort_order>10</sort_order> - </edit> - </children> - </rest_attributes> - </children> - </api> - </children> - </system> - </children> - </admin> - </resources> - </acl> -</config> diff --git a/app/code/core/Mage/Backup/etc/adminhtml.xml b/app/code/core/Mage/Api2/etc/adminhtml/acl.xml similarity index 51% rename from app/code/core/Mage/Backup/etc/adminhtml.xml rename to app/code/core/Mage/Api2/etc/adminhtml/acl.xml index 6f536065899..073c20207ad 100644 --- a/app/code/core/Mage/Backup/etc/adminhtml.xml +++ b/app/code/core/Mage/Api2/etc/adminhtml/acl.xml @@ -20,7 +20,7 @@ * needs please refer to http://www.magentocommerce.com for more information. * * @category Mage - * @package Mage_Backup + * @package Mage_Api2 * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ @@ -28,26 +28,20 @@ <config> <acl> <resources> - <admin> - <children> - <system> - <children> - <tools> - <children> - <backup translate="title" module="Mage_Backup"> - <title>Backups</title> - <children> - <rollback translate="title" module="Mage_Backup"> - <title>Rollback</title> - </rollback> - </children> - </backup> - </children> - </tools> - </children> - </system> - </children> - </admin> + <resource id="Mage_Adminhtml::admin"> + <resource id="Mage_Adminhtml::system"> + <resource id="Mage_Api::api"> + <resource id="Mage_Api2::rest_roles" module="Mage_Api2" title="REST - Roles" sortOrder="30"> + <resource id="Mage_Api2::rest_roles_add" title="Add" sortOrder="10" /> + <resource id="Mage_Api2::rest_roles_edit" title="Edit" sortOrder="20" /> + <resource id="Mage_Api2::delete" title="Delete" sortOrder="30" /> + </resource> + <resource id="Mage_Api2::rest_attributes" module="Mage_Api2" title="REST - Attributes" sortOrder="40"> + <resource id="Mage_Api2::rest_attributes_edit" title="Edit" sortOrder="10" /> + </resource> + </resource> + </resource> + </resource> </resources> </acl> </config> diff --git a/app/code/core/Mage/Api2/etc/adminhtml/menu.xml b/app/code/core/Mage/Api2/etc/adminhtml/menu.xml index a020f71a293..1fda4d8d453 100644 --- a/app/code/core/Mage/Api2/etc/adminhtml/menu.xml +++ b/app/code/core/Mage/Api2/etc/adminhtml/menu.xml @@ -27,7 +27,7 @@ --> <config> <menu> - <add id="Mage_Api2::system_api_rest_roles" title="REST - Roles" module="Mage_Api2" sortOrder="30" parent="Mage_Api::system_api" action="adminhtml/api2_role" /> - <add id="Mage_Api2::system_api_rest_attributes" title="REST - Attributes" module="Mage_Api2" sortOrder="40" parent="Mage_Api::system_api" action="adminhtml/api2_attribute" /> + <add id="Mage_Api2::system_api_rest_roles" title="REST - Roles" module="Mage_Api2" sortOrder="30" parent="Mage_Api::system_api" action="adminhtml/api2_role" resource="Mage_Api2::rest_roles"/> + <add id="Mage_Api2::system_api_rest_attributes" title="REST - Attributes" module="Mage_Api2" sortOrder="40" parent="Mage_Api::system_api" action="adminhtml/api2_attribute" resource="Mage_Api2::rest_attributes"/> </menu> </config> diff --git a/app/code/core/Mage/Backend/Block/Menu/Item.php b/app/code/core/Mage/Backend/Block/Menu/Item.php index ab3a5eb989b..68c7bc94318 100644 --- a/app/code/core/Mage/Backend/Block/Menu/Item.php +++ b/app/code/core/Mage/Backend/Block/Menu/Item.php @@ -78,7 +78,7 @@ class Mage_Backend_Block_Menu_Item extends Mage_Backend_Block_Template if ($this->getLevel() == 0 && $itemModel instanceof Mage_Backend_Model_Menu_Item && ($itemModel->getId() == $item->getId() - || (strpos($itemModel->getFullPath(), $item->getFullPath() . '/') === 0)) + || $item->getChildren()->get($itemModel->getId())!== null) ) { $output = true; } diff --git a/app/code/core/Mage/Backend/Block/Widget/Form/Container.php b/app/code/core/Mage/Backend/Block/Widget/Form/Container.php index aa9346badb1..4a86b238805 100644 --- a/app/code/core/Mage/Backend/Block/Widget/Form/Container.php +++ b/app/code/core/Mage/Backend/Block/Widget/Form/Container.php @@ -76,23 +76,34 @@ class Mage_Backend_Block_Widget_Form_Container extends Mage_Backend_Block_Widget ), 1); } + /** + * Create form block + * + * @return Mage_Core_Block_Abstract + */ protected function _prepareLayout() { if ($this->_blockGroup && $this->_controller && $this->_mode && !$this->_layout->getChildName($this->_nameInLayout, 'form') ) { - $this->setChild( - 'form', - $this->getLayout()->createBlock($this->_blockGroup - . '_Block_' - . str_replace(' ', '_', ucwords(str_replace('_', ' ', $this->_controller . '_' . $this->_mode))) - . '_Form' - ) - ); + $this->setChild('form', $this->getLayout()->createBlock($this->_buildFormClassName())); } return parent::_prepareLayout(); } + /** + * Build child form class name + * + * @return string + */ + protected function _buildFormClassName() + { + return $this->_blockGroup + . '_Block_' + . str_replace(' ', '_', ucwords(str_replace('_', ' ', $this->_controller . '_' . $this->_mode))) + . '_Form'; + } + /** * Get URL for back (reset) button * diff --git a/app/code/core/Mage/Backend/Model/Acl/Config.php b/app/code/core/Mage/Backend/Model/Acl/Config.php new file mode 100644 index 00000000000..a3cc97854fd --- /dev/null +++ b/app/code/core/Mage/Backend/Model/Acl/Config.php @@ -0,0 +1,133 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Mage + * @package Mage_Backend + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + + +/** + * Backend Acl Config model + * + * @category Mage + * @package Mage_Backend + * @author Magento Core Team <core@magentocommerce.com> + */ +class Mage_Backend_Model_Acl_Config +{ + const CACHE_ID = 'backend_acl_resources'; + + const ACL_RESOURCE_ALL = 'Mage_Adminhtml::all'; + + /** + * @var Mage_Core_Model_Config + */ + protected $_config; + + /** + * @var Mage_Core_Model_Cache + */ + protected $_cache; + + /** + * @var Mage_Backend_Model_Acl_Config_Reader + */ + protected $_reader; + + public function __construct(array $args = array()) + { + $this->_config = isset($args['config']) ? $args['config'] : Mage::getConfig(); + $this->_cache = isset($args['cache']) ? $args['cache'] : Mage::app()->getCacheInstance(); + } + + /** + * Retrieve list of acl files from each module + * + * @return array + */ + protected function _getAclResourceFiles() + { + $files = $this->_config + ->getModuleConfigurationFiles('adminhtml' . DIRECTORY_SEPARATOR . 'acl.xml'); + return (array) $files; + } + + /** + * Reader object initialization + * + * @return Mage_Backend_Model_Acl_Config_Reader + */ + protected function _getReader() + { + if (null === $this->_reader) { + $aclResourceFiles = $this->_getAclResourceFiles(); + $this->_reader = $this->_config->getModelInstance('Mage_Backend_Model_Acl_Config_Reader', $aclResourceFiles); + } + return $this->_reader; + } + + /** + * Return ACL Resources loaded from cache if enabled or from files merged previously + * + * @return DOMDocument + */ + public function getAclResources() + { + $aclResourcesXml = $this->_loadAclResourcesFromCache(); + if ($aclResourcesXml && is_string($aclResourcesXml)) { + $aclResources = new DOMDocument(); + $aclResources->loadXML($aclResourcesXml); + } else { + $aclResources = $this->_getReader()->getAclResources(); + $this->_saveAclResourcesToCache($aclResources->saveXML()); + } + $xpath = new DOMXPath($aclResources); + return $xpath->query('/config/acl/resources/*'); + } + + /** + * Load ACL resources from cache + * + * @return null|string + */ + private function _loadAclResourcesFromCache() + { + if ($this->_cache->canUse('config')) { + return $this->_cache->load(self::CACHE_ID); + } + return null; + } + + /** + * Save ACL resources into the cache + * + * @param $data + * @return Mage_Backend_Model_Acl_Config + */ + private function _saveAclResourcesToCache($data) + { + if ($this->_cache->canUse('config')) { + $this->_cache->save($data, self::CACHE_ID, array(Mage_Core_Model_Config::CACHE_TAG)); + } + return $this; + } +} diff --git a/app/code/core/Mage/Backend/Model/Acl/Config/Reader.php b/app/code/core/Mage/Backend/Model/Acl/Config/Reader.php new file mode 100644 index 00000000000..c7bd8562400 --- /dev/null +++ b/app/code/core/Mage/Backend/Model/Acl/Config/Reader.php @@ -0,0 +1,110 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Mage + * @package Mage_Backend + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +/** + * Backend Acl Resources reader + * + * @category Mage + * @package Mage_Backend + * @author Magento Core Team <core@magentocommerce.com> + */ +class Mage_Backend_Model_Acl_Config_Reader extends Magento_Config_XmlAbstract + implements Mage_Backend_Model_Acl_Config_ReaderInterface +{ + /** + * Get absolute path to the XML-schema file + * + * @return string + */ + public function getSchemaFile() + { + return __DIR__ . '/acl.xsd'; + } + + /** + * Extract configuration data from the DOM structure + * + * @param DOMDocument $dom + * @return array + */ + protected function _extractData(DOMDocument $dom) + { + return array(); + } + + /** + * Get XML-contents, initial for merging + * + * @return string + */ + protected function _getInitialXml() + { + return '<?xml version="1.0" encoding="utf-8"?><config><acl></acl></config>'; + } + + /** + * Get list of paths to identifiable nodes + * + * @return array + */ + protected function _getIdAttributes() + { + return array(); + } + + /** + * Get Dom configuration model + * @return Magento_Config_Dom + */ + protected function _getDomConfigModel() + { + if (is_null($this->_domConfig)) { + $this->_domConfig = new Mage_Backend_Model_Acl_Config_Reader_Dom( + $this->_getInitialXml(), + $this->_getIdAttributes() + ); + } + return $this->_domConfig; + } + + /** + * Get if xml files must be runtime validated + * @return boolean + */ + protected function _isRuntimeValidated() + { + return false; + } + + /** + * Retrieve ACL resources + * @return DOMDocument + */ + function getAclResources() + { + return $this->_getDomConfigModel()->getDom(); + } +} diff --git a/app/code/core/Mage/Backend/Model/Acl/Config/Reader/Dom.php b/app/code/core/Mage/Backend/Model/Acl/Config/Reader/Dom.php new file mode 100644 index 00000000000..8724baf3416 --- /dev/null +++ b/app/code/core/Mage/Backend/Model/Acl/Config/Reader/Dom.php @@ -0,0 +1,45 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Mage + * @package Mage_Backend + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +/** + * @category Mage + * @package Mage_Backend + * @author Magento Core Team <core@magentocommerce.com> + */ +class Mage_Backend_Model_Acl_Config_Reader_Dom extends Magento_Config_Dom +{ + /** + * Return attribute for resource node that identify it as unique + * + * @param string $xPath + * @return bool|string + */ + protected function _findIdAttribute($xPath) + { + $needle = 'resource'; + return substr($xPath, -strlen($needle)) === $needle ? 'id' : false; + } +} diff --git a/app/code/core/Mage/Core/Block/Flush.php b/app/code/core/Mage/Backend/Model/Acl/Config/ReaderInterface.php similarity index 69% rename from app/code/core/Mage/Core/Block/Flush.php rename to app/code/core/Mage/Backend/Model/Acl/Config/ReaderInterface.php index 6f899bc8fb2..aa066d7c113 100644 --- a/app/code/core/Mage/Core/Block/Flush.php +++ b/app/code/core/Mage/Backend/Model/Acl/Config/ReaderInterface.php @@ -19,32 +19,25 @@ * needs please refer to http://www.magentocommerce.com for more information. * * @category Mage - * @package Mage_Core + * @package Mage_Backend * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ /** - * Immediate flush block. To be used only as root + * Acl resources reader interface * + * @category Mage + * @package Mage_Backend * @author Magento Core Team <core@magentocommerce.com> */ -class Mage_Core_Block_Flush extends Mage_Core_Block_Abstract +interface Mage_Backend_Model_Acl_Config_ReaderInterface { - - protected function _toHtml() - { - if (!$this->_beforeToHtml()) { - return ''; - } - - ob_implicit_flush(); - - $layout = $this->getLayout(); - foreach ($this->getChildNames() as $name) { - echo $layout->renderElement($name); - } - } - + /** + * Retrieve ACL resources + * @abstract + * @return mixed + */ + function getAclResources(); } diff --git a/app/code/core/Mage/Backend/Model/Acl/Config/acl.xsd b/app/code/core/Mage/Backend/Model/Acl/Config/acl.xsd new file mode 100644 index 00000000000..84d5f28fe41 --- /dev/null +++ b/app/code/core/Mage/Backend/Model/Acl/Config/acl.xsd @@ -0,0 +1,112 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Magento + * @package Framework + * @subpackage Config + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> + <xs:element name="config"> + <xs:complexType> + <xs:sequence> + <xs:element name="acl"> + <xs:complexType> + <xs:sequence> + <xs:element name="resources"> + <xs:complexType> + <xs:sequence> + <xs:element minOccurs="0" maxOccurs="unbounded" name="resource" type="aclResource" /> + </xs:sequence> + </xs:complexType> + + <xs:unique name="uniqueResourceId"> + <xs:annotation> + <xs:documentation> + Attribute id is unique under all ACL resources + </xs:documentation> + </xs:annotation> + <xs:selector xpath=".//*"/> + <xs:field xpath="@id"/> + </xs:unique> + </xs:element> + </xs:sequence> + </xs:complexType> + </xs:element> + </xs:sequence> + </xs:complexType> + </xs:element> + + <xs:complexType name="aclResource"> + <xs:annotation> + <xs:documentation> + ACL Resource. Recursive complex type + </xs:documentation> + </xs:annotation> + + <xs:sequence> + <xs:element minOccurs="0" maxOccurs="unbounded" name="resource" type="aclResource" /> + </xs:sequence> + + <xs:attribute name="id" type="typeId" use="required" /> + <xs:attribute name="module" type="typeModule" use="optional" /> + <xs:attribute name="title" type="typeTitle" use="optional" /> + <xs:attribute name="sortOrder" type="xs:int" use="optional" /> + </xs:complexType> + + <xs:simpleType name="typeId"> + <xs:annotation> + <xs:documentation> + Item id attribute can has only [a-z0-9/_]. Minimal length 3 symbol. Case insensitive. + </xs:documentation> + </xs:annotation> + + <xs:restriction base="xs:string"> + <xs:pattern value="[A-Z]+[a-z0-9]{1,}_[A-Z]+[A-Z0-9a-z]{1,}::[A-Za-z_0-9]{1,}" /> + </xs:restriction> + </xs:simpleType> + + <xs:simpleType name="typeTitle"> + <xs:annotation> + <xs:documentation> + Item title attribute minimal length 3 symbol + </xs:documentation> + </xs:annotation> + + <xs:restriction base="xs:string"> + <xs:minLength value="3" /> + <xs:maxLength value="50" /> + </xs:restriction> + </xs:simpleType> + + <xs:simpleType name="typeModule"> + <xs:annotation> + <xs:documentation> + Item module attribute can has only [a-z0-9_]. Minimal length 3 symbol. Case insensitive. + </xs:documentation> + </xs:annotation> + <xs:restriction base="xs:string"> + <xs:pattern value="[A-Z]+[a-z0-9]{1,}_[A-Z]+[A-Z0-9a-z]{1,}" /> + </xs:restriction> + </xs:simpleType> +</xs:schema> diff --git a/app/code/core/Mage/Backend/Model/Acl/Loader/Resource.php b/app/code/core/Mage/Backend/Model/Acl/Loader/Resource.php new file mode 100644 index 00000000000..24b78710873 --- /dev/null +++ b/app/code/core/Mage/Backend/Model/Acl/Loader/Resource.php @@ -0,0 +1,87 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Mage + * @package Mage_Backend + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +class Mage_Backend_Model_Acl_Loader_Resource implements Magento_Acl_Loader +{ + /** + * Acl config + * + * @var Mage_Backend_Model_Acl_Config + */ + protected $_config; + + /** + * Application object factory + * + * @var Mage_Core_Model_Config + */ + protected $_objectFactory; + + /** + * @param array $data + */ + public function __construct(array $data = array()) + { + $this->_config = isset($data['config']) ? $data['config'] : Mage::getSingleton('Mage_Backend_Model_Acl_Config'); + $this->_objectFactory = isset($data['objectFactory']) ? $data['objectFactory'] : Mage::getConfig(); + } + + /** + * Populate ACL with resources from external storage + * + * @param Magento_Acl $acl + */ + public function populateAcl(Magento_Acl $acl) + { + $this->_addResourceTree($acl, $this->_config->getAclResources(), null); + } + + /** + * Add list of nodes and their children to acl + * + * @param Magento_Acl $acl + * @param DOMNodeList $resources + * @param Magento_Acl_Resource $parent + */ + protected function _addResourceTree(Magento_Acl $acl, DOMNodeList $resources, Magento_Acl_Resource $parent = null) + { + /** @var $resourceConfig DOMElement */ + foreach ($resources as $resourceConfig) { + if (!($resourceConfig instanceof DOMElement)){ + continue; + } + /** @var $resource Magento_Acl_Resource */ + $resource = $this->_objectFactory->getModelInstance( + 'Magento_Acl_Resource', + $resourceConfig->getAttribute('id') + ); + $acl->addResource($resource, $parent); + if ($resourceConfig->hasChildNodes()) { + $this->_addResourceTree($acl, $resourceConfig->childNodes, $resource); + } + } + } +} diff --git a/app/code/core/Mage/Backend/Model/Auth.php b/app/code/core/Mage/Backend/Model/Auth.php index b5fcbb17535..ea6cfca12de 100644 --- a/app/code/core/Mage/Backend/Model/Auth.php +++ b/app/code/core/Mage/Backend/Model/Auth.php @@ -93,14 +93,14 @@ class Mage_Backend_Model_Auth */ protected function _initCredentialStorage() { - $config = Mage::getConfig()->getNode('global/backend/auth'); - if ($config && $config instanceof Varien_Simplexml_Element) { - $storage = Mage::getModel($config->credential_storage->__toString()); - if ($storage instanceof Mage_Backend_Model_Auth_Credential_StorageInterface) { - $this->_credentialStorage = $storage; - return; - } + $areaConfig = Mage::getConfig()->getAreaConfig(Mage::helper('Mage_Backend_Helper_Data')->getAreaCode()); + $storage = Mage::getModel($areaConfig['auth']['credential_storage']); + + if ($storage instanceof Mage_Backend_Model_Auth_Credential_StorageInterface) { + $this->_credentialStorage = $storage; + return; } + self::throwException( Mage::helper('Mage_Backend_Helper_Data')->__('There are no authentication credential storage.') ); diff --git a/app/code/core/Mage/Backend/Model/Auth/Session.php b/app/code/core/Mage/Backend/Model/Auth/Session.php index ba25e0d3cd3..df2fd34d39e 100644 --- a/app/code/core/Mage/Backend/Model/Auth/Session.php +++ b/app/code/core/Mage/Backend/Model/Auth/Session.php @@ -43,12 +43,29 @@ class Mage_Backend_Model_Auth_Session extends Mage_Core_Model_Session_Abstract i */ protected $_isFirstPageAfterLogin; + /** + * Access Control List builder + * + * @var Mage_Core_Model_Acl_Builder + */ + protected $_aclBuilder; + /** * Class constructor * + * @param array $data */ - public function __construct() + public function __construct(array $data = array()) { + if (isset($data['aclBuilder'])) { + $this->_aclBuilder = $data['aclBuilder']; + } else { + $areaConfig = Mage::getConfig()->getAreaConfig(Mage::helper('Mage_Backend_Helper_Data')->getAreaCode()); + $this->_aclBuilder = Mage::getModel('Mage_Core_Model_Acl_Builder', array( + 'areaConfig' => $areaConfig, + 'objectFactory' => Mage::getConfig() + )); + } $this->init('admin'); } @@ -87,7 +104,7 @@ class Mage_Backend_Model_Auth_Session extends Mage_Core_Model_Session_Abstract i return $this; } if (!$this->getAcl() || $user->getReloadAclFlag()) { - $this->setAcl(Mage::getResourceModel('Mage_Admin_Model_Resource_Acl')->loadAcl()); + $this->setAcl($this->_aclBuilder->getAcl()); } if ($user->getReloadAclFlag()) { $user->unsetData('password'); @@ -99,8 +116,8 @@ class Mage_Backend_Model_Auth_Session extends Mage_Core_Model_Session_Abstract i /** * Check current user permission on resource and privilege * - * Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('admin/catalog') - * Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('catalog') + * Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Catalog::catalog') + * Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Catalog::catalog') * * @param string $resource * @param string $privilege @@ -112,10 +129,6 @@ class Mage_Backend_Model_Auth_Session extends Mage_Core_Model_Session_Abstract i $acl = $this->getAcl(); if ($user && $acl) { - if (!preg_match('/^admin/', $resource)) { - $resource = 'admin/' . $resource; - } - try { return $acl->isAllowed($user->getAclRole(), $resource, $privilege); } catch (Exception $e) { @@ -191,7 +204,7 @@ class Mage_Backend_Model_Auth_Session extends Mage_Core_Model_Session_Abstract i } $this->setIsFirstPageAfterLogin(true); - $this->setAcl(Mage::getResourceModel('Mage_Admin_Model_Resource_Acl')->loadAcl()); + $this->setAcl($this->_aclBuilder->getAcl()); $this->setUpdatedAt(time()); } return $this; diff --git a/app/code/core/Mage/Backend/Model/Menu.php b/app/code/core/Mage/Backend/Model/Menu.php index 9f96e86368f..b169e696306 100644 --- a/app/code/core/Mage/Backend/Model/Menu.php +++ b/app/code/core/Mage/Backend/Model/Menu.php @@ -80,7 +80,6 @@ class Mage_Backend_Model_Menu extends ArrayObject $index = intval($index); if (!isset($this[$index])) { $this->offsetSet($index, $item); - $item->setPath($this->getFullPath()); $this->_logger->log(sprintf('Add of item with id %s was processed', $item->getId())); } else { $this->add($item, $parentId, $index + 1); @@ -188,30 +187,6 @@ class Mage_Backend_Model_Menu extends ArrayObject return $this->offsetGet(max(array_keys($this->getArrayCopy())))->getId() == $item->getId(); } - /** - * Set path in tree - * - * @param $path - */ - public function setPath($path) - { - $this->_path = $path . '/'; - /** @var $child Mage_Backend_Model_Menu_Item */ - foreach ($this as $child) { - $child->setPath($this->getFullPath()); - } - } - - /** - * Retrieve full path to node in tree - * - * @return string - */ - public function getFullPath() - { - return $this->_path; - } - /** * Find first menu item that user is able to access * diff --git a/app/code/core/Mage/Backend/Model/Menu/Builder/Command/Add.php b/app/code/core/Mage/Backend/Model/Menu/Builder/Command/Add.php index ea6bcfd907a..e676ab50d70 100644 --- a/app/code/core/Mage/Backend/Model/Menu/Builder/Command/Add.php +++ b/app/code/core/Mage/Backend/Model/Menu/Builder/Command/Add.php @@ -37,7 +37,8 @@ class Mage_Backend_Model_Menu_Builder_Command_Add extends Mage_Backend_Model_Men protected $_requiredParams = array( "id", "title", - "module" + "module", + "resource" ); /** diff --git a/app/code/core/Mage/Backend/Model/Menu/Config/menu.xsd b/app/code/core/Mage/Backend/Model/Menu/Config/menu.xsd index 525f58b3412..94b344ef7a9 100644 --- a/app/code/core/Mage/Backend/Model/Menu/Config/menu.xsd +++ b/app/code/core/Mage/Backend/Model/Menu/Config/menu.xsd @@ -48,7 +48,7 @@ <xs:attribute name="action" type="typeAction" use="optional" /> <xs:attribute name="parent" type="typeId" use="optional" /> <xs:attribute name="toolTip" type="typeTitle" use="optional" /> - <xs:attribute name="resource" type="typeResource" use="optional" /> + <xs:attribute name="resource" type="typeResource" use="required" /> <xs:attribute name="dependsOnModule" type="typeModule" use="optional" /> <xs:attribute name="dependsOnConfig" type="typeDependsConfig" use="optional" /> </xs:complexType> @@ -152,7 +152,7 @@ </xs:documentation> </xs:annotation> <xs:restriction base="xs:string"> - <xs:pattern value="[A-Za-z0-9_/]{3,}" /> + <xs:pattern value="[A-Z]+[a-z0-9]{1,}_[A-Z]+[A-Z0-9a-z]{1,}::[A-Za-z_0-9]{1,}" /> </xs:restriction> </xs:simpleType> diff --git a/app/code/core/Mage/Backend/Model/Menu/Item.php b/app/code/core/Mage/Backend/Model/Menu/Item.php index edadaedca97..7958e281805 100644 --- a/app/code/core/Mage/Backend/Model/Menu/Item.php +++ b/app/code/core/Mage/Backend/Model/Menu/Item.php @@ -205,39 +205,11 @@ class Mage_Backend_Model_Menu_Item { if (!$this->_submenu) { $this->_submenu = $this->_menuFactory - ->getMenuInstance( - array('path' => $this->getFullPath()) - ); + ->getMenuInstance(); } return $this->_submenu; } - /** - * Retrieve full path from root element - * - * @return string - */ - public function getFullPath() - { - /* - * TODO: Remove id manipulation after acl is transfered to ids - */ - $id = $this->_id; - $start = strrpos($this->_id, ':'); - if ($start) { - if ($this->_path) { - $path = str_replace('/', '_', $this->_path); - $start = strpos($this->_id, $path) + strlen($path); - } else { - if ($start) { - $start++; - } - } - $id = substr($this->_id, $start); - } - return $this->_path . $id; - } - /** * Retrieve menu item url * @@ -457,23 +429,9 @@ class Mage_Backend_Model_Menu_Item public function isAllowed() { try { - $aclResource = 'admin/' . ($this->_resource ? (string)$this->_resource : $this->getFullPath()); - return $this->_acl->isAllowed($aclResource); + return $this->_acl->isAllowed((string)$this->_resource); } catch (Exception $e) { return false; } } - - /** - * Set path in structure - * - * @param string $path - */ - public function setPath($path) - { - $this->_path = $path; - if ($this->_submenu) { - $this->_submenu->setPath($this->getFullPath()); - } - } } diff --git a/app/code/core/Mage/Backend/Model/Menu/Item/Validator.php b/app/code/core/Mage/Backend/Model/Menu/Item/Validator.php index 605d75e8efc..68252a0ab24 100644 --- a/app/code/core/Mage/Backend/Model/Menu/Item/Validator.php +++ b/app/code/core/Mage/Backend/Model/Menu/Item/Validator.php @@ -31,7 +31,7 @@ class Mage_Backend_Model_Menu_Item_Validator * @var array */ protected $_required = array( - 'acl', 'appConfig', 'menuFactory', 'urlModel', 'storeConfig', 'id', 'title', 'module' + 'acl', 'appConfig', 'menuFactory', 'urlModel', 'storeConfig', 'id', 'title', 'module', 'resource' ); /** @@ -68,6 +68,12 @@ class Mage_Backend_Model_Menu_Item_Validator $idValidator->addValidator(new Zend_Validate_StringLength(array('min' => 3))); $idValidator->addValidator(new Zend_Validate_Regex('/^[A-Za-z0-9\/:_]+$/')); + $resourceValidator = new Zend_Validate(); + $resourceValidator->addValidator(new Zend_Validate_StringLength(array('min' => 8))); + $resourceValidator->addValidator( + new Zend_Validate_Regex('/^[A-Z]+[a-z0-9]{1,}_[A-Z]+[A-Z0-9a-z]{1,}::[A-Za-z_0-9]{1,}$/') + ); + $attributeValidator = new Zend_Validate(); $attributeValidator->addValidator(new Zend_Validate_StringLength(array('min' => 3))); $attributeValidator->addValidator(new Zend_Validate_Regex('/^[A-Za-z0-9\/_]+$/')); @@ -75,8 +81,7 @@ class Mage_Backend_Model_Menu_Item_Validator $textValidator = new Zend_Validate_StringLength(array('min' => 3, 'max' => 50)); $titleValidator = $tooltipValidator = $textValidator; - $actionValidator = $resourceValidator = $resourceValidator = $moduleDependencyValidator - = $configDependencyValidator = $attributeValidator; + $actionValidator = $moduleDependencyValidator = $configDependencyValidator = $attributeValidator; $this->_validators['id'] = $idValidator; $this->_validators['title'] = $titleValidator; diff --git a/app/code/core/Mage/Backend/Model/Url.php b/app/code/core/Mage/Backend/Model/Url.php index 0ecf527c687..0c286cde472 100644 --- a/app/code/core/Mage/Backend/Model/Url.php +++ b/app/code/core/Mage/Backend/Model/Url.php @@ -269,10 +269,9 @@ class Mage_Backend_Model_Url extends Mage_Core_Model_Url */ public function getStartupPageUrl() { - $aclResource = 'admin/' . $this->_startupMenuItemId; - if ($this->_getSession()->isAllowed($aclResource)) { - $menuItem = $this->_getMenu()->get($this->_startupMenuItemId); - if ($menuItem && $menuItem->getAction()) { + $menuItem = $this->_getMenu()->get($this->_startupMenuItemId); + if (!is_null($menuItem)) { + if ($menuItem->isAllowed() && $menuItem->getAction()) { return $menuItem->getAction(); } } diff --git a/app/code/core/Mage/Backend/etc/config.xml b/app/code/core/Mage/Backend/etc/config.xml index fccbf08764c..f7d25e40708 100644 --- a/app/code/core/Mage/Backend/etc/config.xml +++ b/app/code/core/Mage/Backend/etc/config.xml @@ -46,11 +46,12 @@ </admin> </routers> <frontName>backend</frontName> + <auth/> + <acl> + <resourceLoader>Mage_Backend_Model_Acl_Loader_Resource</resourceLoader> + </acl> </adminhtml> </areas> - <backend> - <auth/> - </backend> <cache> <types> <config translate="description" module="Mage_Backend"> diff --git a/app/code/core/Mage/Backup/Helper/Data.php b/app/code/core/Mage/Backup/Helper/Data.php index aa9be5557f1..be23f143c01 100644 --- a/app/code/core/Mage/Backup/Helper/Data.php +++ b/app/code/core/Mage/Backup/Helper/Data.php @@ -150,7 +150,7 @@ class Mage_Backup_Helper_Data extends Mage_Core_Helper_Abstract * @return boolean */ public function isRollbackAllowed(){ - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('system/tools/backup/rollback' ); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Backup::rollback' ); } /** diff --git a/app/code/core/Mage/Backup/etc/adminhtml/acl.xml b/app/code/core/Mage/Backup/etc/adminhtml/acl.xml new file mode 100644 index 00000000000..1cf97ed1cb2 --- /dev/null +++ b/app/code/core/Mage/Backup/etc/adminhtml/acl.xml @@ -0,0 +1,42 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Mage + * @package Mage_Backup + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config> + <acl> + <resources> + <resource id="Mage_Adminhtml::admin"> + <resource id="Mage_Adminhtml::system"> + <resource id="Mage_Adminhtml::tools"> + <resource id="Mage_Backup::backup" module="Mage_Backup" title="Backups"> + <resource id="Mage_Backup::rollback" module="Mage_Backup" title="Rollback" /> + </resource> + </resource> + </resource> + </resource> + </resources> + </acl> +</config> diff --git a/app/code/core/Mage/Backup/etc/adminhtml/menu.xml b/app/code/core/Mage/Backup/etc/adminhtml/menu.xml index 940e89ea1e1..0a73365af4c 100644 --- a/app/code/core/Mage/Backup/etc/adminhtml/menu.xml +++ b/app/code/core/Mage/Backup/etc/adminhtml/menu.xml @@ -27,6 +27,6 @@ --> <config> <menu> - <add id="Mage_Backup::system_tools_backup" title="Backups" module="Mage_Backup" parent="Mage_Adminhtml::system_tools" action="adminhtml/system_backup" /> + <add id="Mage_Backup::system_tools_backup" title="Backups" module="Mage_Backup" parent="Mage_Adminhtml::system_tools" action="adminhtml/system_backup" resource="Mage_Backup::backup"/> </menu> </config> diff --git a/app/code/core/Mage/Captcha/Block/Captcha/Zend.php b/app/code/core/Mage/Captcha/Block/Captcha/Zend.php index bc1b4b6336b..9d41e5ebb5a 100755 --- a/app/code/core/Mage/Captcha/Block/Captcha/Zend.php +++ b/app/code/core/Mage/Captcha/Block/Captcha/Zend.php @@ -57,10 +57,15 @@ class Mage_Captcha_Block_Captcha_Zend extends Mage_Core_Block_Template */ public function getRefreshUrl() { - return Mage::getUrl( - Mage::app()->getStore()->isAdmin() ? 'adminhtml/refresh/refresh' : 'captcha/refresh', - array('_secure' => Mage::app()->getStore()->isCurrentlySecure()) - ); + $urlPath = 'captcha/refresh'; + $params = array('_secure' => Mage::app()->getStore()->isCurrentlySecure()); + + if (Mage::app()->getStore()->isAdmin()) { + $urlPath = 'adminhtml/refresh/refresh'; + $params = array_merge($params, array('_nosecret' => true)); + } + + return Mage::app()->getStore()->getUrl($urlPath, $params); } /** diff --git a/app/code/core/Mage/Captcha/etc/config.xml b/app/code/core/Mage/Captcha/etc/config.xml index e8cbbc299c1..65e0539927b 100755 --- a/app/code/core/Mage/Captcha/etc/config.xml +++ b/app/code/core/Mage/Captcha/etc/config.xml @@ -71,6 +71,14 @@ </captcha> </observers> </controller_action_predispatch_customer_account_createpost> + <controller_action_predispatch_adminhtml_auth_forgotpassword> + <observers> + <captcha> + <class>Mage_Captcha_Model_Observer</class> + <method>checkUserForgotPasswordBackend</method> + </captcha> + </observers> + </controller_action_predispatch_adminhtml_auth_forgotpassword> <admin_user_authenticate_before> <observers> <captcha> @@ -126,6 +134,15 @@ </captcha> </updates> </layout> + <translate> + <modules> + <Mage_Captcha> + <files> + <default>Mage_Captcha.csv</default> + </files> + </Mage_Captcha> + </modules> + </translate> </frontend> <admin> <routers> @@ -146,6 +163,15 @@ </captcha> </updates> </layout> + <translate> + <modules> + <Mage_Captcha> + <files> + <default>Mage_Captcha.csv</default> + </files> + </Mage_Captcha> + </modules> + </translate> <events> <controller_action_predispatch_adminhtml_auth_forgotpassword> <observers> diff --git a/app/code/core/Mage/Catalog/etc/adminhtml.xml b/app/code/core/Mage/Catalog/etc/adminhtml.xml deleted file mode 100644 index 8c62c0c41ff..00000000000 --- a/app/code/core/Mage/Catalog/etc/adminhtml.xml +++ /dev/null @@ -1,77 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License (AFL 3.0) - * that is bundled with this package in the file LICENSE_AFL.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/afl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @category Mage - * @package Mage_Catalog - * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - */ ---> -<config> - <acl> - <resources> - <admin> - <children> - <system> - <children> - <config> - <children> - <catalog translate="title" module="Mage_Catalog"> - <title>Catalog Section</title> - </catalog> - </children> - </config> - </children> - </system> - <catalog translate="title" module="Mage_Catalog"> - <title>Catalog</title> - <sort_order>30</sort_order> - <children> - <attributes translate="title"> - <title>Attributes</title> - <children> - <attributes translate="title"> - <title>Manage Attributes</title> - </attributes> - <sets translate="title"> - <title>Manage Attribute Sets</title> - </sets> - </children> - </attributes> - <categories translate="title"> - <title>Manage Categories</title> - </categories> - <products translate="title"> - <title>Manage Products</title> - </products> - <update_attributes translate="title"> - <title>Update Attributes</title> - </update_attributes> - <urlrewrite translate="title"> - <title>URL Rewrite Management</title> - </urlrewrite> - </children> - </catalog> - </children> - </admin> - </resources> - </acl> -</config> diff --git a/app/code/core/Mage/Catalog/etc/adminhtml/acl.xml b/app/code/core/Mage/Catalog/etc/adminhtml/acl.xml new file mode 100644 index 00000000000..d6208a07bc0 --- /dev/null +++ b/app/code/core/Mage/Catalog/etc/adminhtml/acl.xml @@ -0,0 +1,50 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Mage + * @package Mage_Catalog + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config> + <acl> + <resources> + <resource id="Mage_Adminhtml::admin"> + <resource id="Mage_Adminhtml::system"> + <resource id="Mage_Adminhtml::config"> + <resource id="Mage_Catalog::config_catalog" module="Mage_Catalog" title="Catalog Section" /> + </resource> + </resource> + <resource id="Mage_Catalog::catalog" module="Mage_Catalog" title="Catalog" sortOrder="30"> + <resource id="Mage_Catalog::catalog_attributes" title="Attributes"> + <resource id="Mage_Catalog::attributes_attributes" title="Manage Attributes" /> + <resource id="Mage_Catalog::sets" title="Manage Attribute Sets" /> + </resource> + <resource id="Mage_Catalog::categories" title="Manage Categories" /> + <resource id="Mage_Catalog::products" title="Manage Products" /> + <resource id="Mage_Catalog::update_attributes" title="Update Attributes" /> + <resource id="Mage_Catalog::urlrewrite" title="URL Rewrite Management" /> + </resource> + </resource> + </resources> + </acl> +</config> diff --git a/app/code/core/Mage/Catalog/etc/adminhtml/menu.xml b/app/code/core/Mage/Catalog/etc/adminhtml/menu.xml index 6d49646a895..45c7f684e02 100644 --- a/app/code/core/Mage/Catalog/etc/adminhtml/menu.xml +++ b/app/code/core/Mage/Catalog/etc/adminhtml/menu.xml @@ -27,12 +27,12 @@ --> <config> <menu> - <add id="Mage_Catalog::catalog" title="Catalog" module="Mage_Catalog" sortOrder="30" dependsOnModule="Mage_Catalog" /> - <add id="Mage_Catalog::catalog_products" title="Manage Products" module="Mage_Catalog" sortOrder="0" parent="Mage_Catalog::catalog" action="adminhtml/catalog_product/" /> - <add id="Mage_Catalog::catalog_categories" title="Manage Categories" module="Mage_Catalog" sortOrder="10" parent="Mage_Catalog::catalog" action="adminhtml/catalog_category/" /> - <add id="Mage_Catalog::catalog_attributes" title="Attributes" module="Mage_Catalog" sortOrder="20" parent="Mage_Catalog::catalog" /> - <add id="Mage_Catalog::catalog_attributes_attributes" title="Manage Attributes" module="Mage_Catalog" parent="Mage_Catalog::catalog_attributes" action="adminhtml/catalog_product_attribute/" /> - <add id="Mage_Catalog::catalog_attributes_sets" title="Manage Attribute Sets" module="Mage_Catalog" parent="Mage_Catalog::catalog_attributes" action="adminhtml/catalog_product_set/" /> - <add id="Mage_Catalog::catalog_urlrewrite" title="URL Rewrite Management" module="Mage_Catalog" sortOrder="30" parent="Mage_Catalog::catalog" action="adminhtml/urlrewrite/index" /> + <add id="Mage_Catalog::catalog" title="Catalog" module="Mage_Catalog" sortOrder="30" dependsOnModule="Mage_Catalog" resource="Mage_Catalog::catalog"/> + <add id="Mage_Catalog::catalog_products" title="Manage Products" module="Mage_Catalog" sortOrder="0" parent="Mage_Catalog::catalog" action="adminhtml/catalog_product/" resource="Mage_Catalog::products"/> + <add id="Mage_Catalog::catalog_categories" title="Manage Categories" module="Mage_Catalog" sortOrder="10" parent="Mage_Catalog::catalog" action="adminhtml/catalog_category/" resource="Mage_Catalog::categories"/> + <add id="Mage_Catalog::catalog_attributes" title="Attributes" module="Mage_Catalog" sortOrder="20" parent="Mage_Catalog::catalog" resource="Mage_Catalog::catalog_attributes"/> + <add id="Mage_Catalog::catalog_attributes_attributes" title="Manage Attributes" module="Mage_Catalog" parent="Mage_Catalog::catalog_attributes" action="adminhtml/catalog_product_attribute/" resource="Mage_Catalog::attributes_attributes"/> + <add id="Mage_Catalog::catalog_attributes_sets" title="Manage Attribute Sets" module="Mage_Catalog" parent="Mage_Catalog::catalog_attributes" action="adminhtml/catalog_product_set/" resource="Mage_Catalog::sets"/> + <add id="Mage_Catalog::catalog_urlrewrite" title="URL Rewrite Management" module="Mage_Catalog" sortOrder="30" parent="Mage_Catalog::catalog" action="adminhtml/urlrewrite/index" resource="Mage_Catalog::urlrewrite"/> </menu> </config> diff --git a/app/code/core/Mage/Catalog/etc/system.xml b/app/code/core/Mage/Catalog/etc/system.xml index 84116a88f58..a1ce6680a03 100644 --- a/app/code/core/Mage/Catalog/etc/system.xml +++ b/app/code/core/Mage/Catalog/etc/system.xml @@ -42,6 +42,7 @@ <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>1</show_in_store> + <resource>Mage_Catalog::config_catalog</resource> <groups> <frontend translate="label"> <label>Frontend</label> diff --git a/app/code/core/Mage/CatalogInventory/etc/adminhtml/acl.xml b/app/code/core/Mage/CatalogInventory/etc/adminhtml/acl.xml new file mode 100644 index 00000000000..250db2e00e5 --- /dev/null +++ b/app/code/core/Mage/CatalogInventory/etc/adminhtml/acl.xml @@ -0,0 +1,40 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Mage + * @package Mage_CatalogInventory + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config> + <acl> + <resources> + <resource id="Mage_Adminhtml::admin"> + <resource id="Mage_Adminhtml::system"> + <resource id="Mage_Adminhtml::config"> + <resource id="Mage_CatalogInventory::cataloginventory" module="Mage_CatalogInventory" title="Inventory Section" /> + </resource> + </resource> + </resource> + </resources> + </acl> +</config> diff --git a/app/code/core/Mage/CatalogInventory/etc/system.xml b/app/code/core/Mage/CatalogInventory/etc/system.xml index 66bea2f2daa..d8794a20c35 100644 --- a/app/code/core/Mage/CatalogInventory/etc/system.xml +++ b/app/code/core/Mage/CatalogInventory/etc/system.xml @@ -35,6 +35,7 @@ <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>1</show_in_store> + <resource>Mage_CatalogInventory::cataloginventory</resource> <groups> <options translate="label"> <label>Stock Options</label> diff --git a/app/code/core/Mage/CatalogRule/etc/adminhtml.xml b/app/code/core/Mage/CatalogRule/etc/adminhtml.xml deleted file mode 100644 index 6d0738acb89..00000000000 --- a/app/code/core/Mage/CatalogRule/etc/adminhtml.xml +++ /dev/null @@ -1,46 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License (AFL 3.0) - * that is bundled with this package in the file LICENSE_AFL.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/afl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @category Mage - * @package Mage_CatalogRule - * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - */ ---> -<config> - <acl> - <resources> - <admin> - <children> - <promo translate="title" module="Mage_CatalogRule"> - <title>Promotions</title> - <sort_order>50</sort_order> - <children> - <catalog translate="title"> - <title>Catalog Price Rules</title> - </catalog> - </children> - </promo> - </children> - </admin> - </resources> - </acl> -</config> diff --git a/app/code/core/Mage/CatalogRule/etc/adminhtml/acl.xml b/app/code/core/Mage/CatalogRule/etc/adminhtml/acl.xml new file mode 100644 index 00000000000..6d28d642217 --- /dev/null +++ b/app/code/core/Mage/CatalogRule/etc/adminhtml/acl.xml @@ -0,0 +1,38 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Mage + * @package Mage_CatalogRule + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config> + <acl> + <resources> + <resource id="Mage_Adminhtml::admin"> + <resource id="Mage_CatalogRule::promo" module="Mage_CatalogRule" title="Promotions" sortOrder="50"> + <resource id="Mage_CatalogRule::promo_catalog" title="Catalog Price Rules" /> + </resource> + </resource> + </resources> + </acl> +</config> diff --git a/app/code/core/Mage/CatalogRule/etc/adminhtml/menu.xml b/app/code/core/Mage/CatalogRule/etc/adminhtml/menu.xml index 4373d055e64..c72f436a30a 100644 --- a/app/code/core/Mage/CatalogRule/etc/adminhtml/menu.xml +++ b/app/code/core/Mage/CatalogRule/etc/adminhtml/menu.xml @@ -27,7 +27,7 @@ --> <config> <menu> - <add id="Mage_CatalogRule::promo" title="Promotions" module="Mage_CatalogRule" sortOrder="50" /> - <add id="Mage_CatalogRule::promo_catalog" title="Catalog Price Rules" module="Mage_CatalogRule" parent="Mage_CatalogRule::promo" action="adminhtml/promo_catalog/" dependsOnModule="Mage_Catalog" /> + <add id="Mage_CatalogRule::promo" title="Promotions" module="Mage_CatalogRule" sortOrder="50" resource="Mage_CatalogRule::promo"/> + <add id="Mage_CatalogRule::promo_catalog" title="Catalog Price Rules" module="Mage_CatalogRule" parent="Mage_CatalogRule::promo" action="adminhtml/promo_catalog/" dependsOnModule="Mage_Catalog" resource="Mage_CatalogRule::promo_catalog"/> </menu> </config> diff --git a/app/code/core/Mage/CatalogSearch/etc/adminhtml/acl.xml b/app/code/core/Mage/CatalogSearch/etc/adminhtml/acl.xml new file mode 100644 index 00000000000..218d7aa8e3d --- /dev/null +++ b/app/code/core/Mage/CatalogSearch/etc/adminhtml/acl.xml @@ -0,0 +1,38 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Mage + * @package Mage_CatalogSearch + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config> + <acl> + <resources> + <resource id="Mage_Adminhtml::admin"> + <resource id="Mage_Catalog::catalog"> + <resource id="Mage_CatalogSearch::search" module="Mage_CatalogSearch" title="Search Terms" /> + </resource> + </resource> + </resources> + </acl> +</config> diff --git a/app/code/core/Mage/CatalogSearch/etc/adminhtml/menu.xml b/app/code/core/Mage/CatalogSearch/etc/adminhtml/menu.xml index 7c8241008ce..99e39e4a6f7 100644 --- a/app/code/core/Mage/CatalogSearch/etc/adminhtml/menu.xml +++ b/app/code/core/Mage/CatalogSearch/etc/adminhtml/menu.xml @@ -27,6 +27,6 @@ --> <config> <menu> - <add id="Mage_CatalogSearch::catalog_search" title="Search Terms" module="Mage_CatalogSearch" sortOrder="40" parent="Mage_Catalog::catalog" action="adminhtml/catalog_search/" /> + <add id="Mage_CatalogSearch::catalog_search" title="Search Terms" module="Mage_CatalogSearch" sortOrder="40" parent="Mage_Catalog::catalog" action="adminhtml/catalog_search/" resource="Mage_CatalogSearch::search"/> </menu> </config> diff --git a/app/code/core/Mage/Centinel/etc/system.xml b/app/code/core/Mage/Centinel/etc/system.xml index 67eec97b25f..ef866476252 100644 --- a/app/code/core/Mage/Centinel/etc/system.xml +++ b/app/code/core/Mage/Centinel/etc/system.xml @@ -35,6 +35,7 @@ <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>1</show_in_store> + <resource>Mage_Payment::payment_services</resource> <groups> <centinel translate="label"> <label>3D Secure Credit Card Validation</label> diff --git a/app/code/core/Mage/Checkout/etc/adminhtml.xml b/app/code/core/Mage/Checkout/etc/adminhtml.xml deleted file mode 100644 index 1c93d695954..00000000000 --- a/app/code/core/Mage/Checkout/etc/adminhtml.xml +++ /dev/null @@ -1,57 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License (AFL 3.0) - * that is bundled with this package in the file LICENSE_AFL.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/afl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @category Mage - * @package Mage_Checkout - * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - */ ---> -<config> - <acl> - <resources> - <admin> - <children> - <sales> - <children> - <checkoutagreement translate="title" module="Mage_Checkout"> - <title>Terms and Conditions</title> - <sort_order>50</sort_order> - </checkoutagreement> - </children> - </sales> - <system> - <children> - <config> - <children> - <checkout translate="title" module="Mage_Checkout"> - <title>Checkout Section</title> - <sort_order>70</sort_order> - </checkout> - </children> - </config> - </children> - </system> - </children> - </admin> - </resources> - </acl> -</config> diff --git a/app/code/core/Mage/Checkout/etc/adminhtml/acl.xml b/app/code/core/Mage/Checkout/etc/adminhtml/acl.xml new file mode 100644 index 00000000000..44bdbb4e3e5 --- /dev/null +++ b/app/code/core/Mage/Checkout/etc/adminhtml/acl.xml @@ -0,0 +1,43 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Mage + * @package Mage_Checkout + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config> + <acl> + <resources> + <resource id="Mage_Adminhtml::admin"> + <resource id="Mage_Sales::sales"> + <resource id="Mage_Checkout::checkoutagreement" module="Mage_Checkout" title="Terms and Conditions" sortOrder="50" /> + </resource> + <resource id="Mage_Adminhtml::system"> + <resource id="Mage_Adminhtml::config"> + <resource id="Mage_Checkout::checkout" module="Mage_Checkout" title="Checkout Section" sortOrder="70" /> + </resource> + </resource> + </resource> + </resources> + </acl> +</config> diff --git a/app/code/core/Mage/Checkout/etc/adminhtml/menu.xml b/app/code/core/Mage/Checkout/etc/adminhtml/menu.xml index 4a1abe1c98f..418299db121 100644 --- a/app/code/core/Mage/Checkout/etc/adminhtml/menu.xml +++ b/app/code/core/Mage/Checkout/etc/adminhtml/menu.xml @@ -27,6 +27,6 @@ --> <config> <menu> - <add id="Mage_Checkout::sales_checkoutagreement" title="Terms and conditions" module="Mage_Checkout" sortOrder="100" parent="Mage_Sales::sales" action="adminhtml/checkout_agreement/" /> + <add id="Mage_Checkout::sales_checkoutagreement" title="Terms and conditions" module="Mage_Checkout" sortOrder="100" parent="Mage_Sales::sales" action="adminhtml/checkout_agreement/" resource="Mage_Checkout::checkoutagreement"/> </menu> </config> diff --git a/app/code/core/Mage/Checkout/etc/system.xml b/app/code/core/Mage/Checkout/etc/system.xml index 5a4fd7da5e2..5fafec5802d 100644 --- a/app/code/core/Mage/Checkout/etc/system.xml +++ b/app/code/core/Mage/Checkout/etc/system.xml @@ -35,6 +35,7 @@ <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>0</show_in_store> + <resource>Mage_Checkout::checkout</resource> <groups> <options translate="label"> <label>Checkout Options</label> diff --git a/app/code/core/Mage/Cms/Model/Wysiwyg/Config.php b/app/code/core/Mage/Cms/Model/Wysiwyg/Config.php index c36ac23c766..2732f5f885b 100644 --- a/app/code/core/Mage/Cms/Model/Wysiwyg/Config.php +++ b/app/code/core/Mage/Cms/Model/Wysiwyg/Config.php @@ -82,7 +82,7 @@ class Mage_Cms_Model_Wysiwyg_Config extends Varien_Object $config->setData('directives_url_quoted', preg_quote($config->getData('directives_url'))); - if (Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('cms/media_gallery')) { + if (Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Cms::media_gallery')) { $config->addData(array( 'add_images' => true, 'files_browser_window_url' => Mage::getSingleton('Mage_Adminhtml_Model_Url')->getUrl('*/cms_wysiwyg_images/index'), diff --git a/app/code/core/Mage/Cms/etc/adminhtml/acl.xml b/app/code/core/Mage/Cms/etc/adminhtml/acl.xml new file mode 100644 index 00000000000..2fedb544ed1 --- /dev/null +++ b/app/code/core/Mage/Cms/etc/adminhtml/acl.xml @@ -0,0 +1,48 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Mage + * @package Mage_Cms + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config> + <acl> + <resources> + <resource id="Mage_Adminhtml::admin"> + <resource id="Mage_Cms::cms" module="Mage_Cms" title="CMS" sortOrder="70"> + <resource id="Mage_Cms::block" title="Static Blocks" sortOrder="10" /> + <resource id="Mage_Cms::page" title="Pages" sortOrder="0"> + <resource id="Mage_Cms::save" title="Save Page" sortOrder="0" /> + <resource id="Mage_Cms::page_delete" title="Delete Page" sortOrder="10" /> + </resource> + <resource id="Mage_Cms::media_gallery" title="Media Gallery" sortOrder="20" /> + </resource> + <resource id="Mage_Adminhtml::system"> + <resource id="Mage_Adminhtml::config"> + <resource id="Mage_Cms::config_cms" module="Mage_Cms" title="Content Management" /> + </resource> + </resource> + </resource> + </resources> + </acl> +</config> diff --git a/app/code/core/Mage/Cms/etc/adminhtml/menu.xml b/app/code/core/Mage/Cms/etc/adminhtml/menu.xml index e3c332a3858..58ec288935e 100644 --- a/app/code/core/Mage/Cms/etc/adminhtml/menu.xml +++ b/app/code/core/Mage/Cms/etc/adminhtml/menu.xml @@ -27,8 +27,8 @@ --> <config> <menu> - <add id="Mage_Cms::cms" title="CMS" module="Mage_Cms" sortOrder="70" /> - <add id="Mage_Cms::cms_page" title="Pages" module="Mage_Cms" sortOrder="0" parent="Mage_Cms::cms" action="adminhtml/cms_page" /> - <add id="Mage_Cms::cms_block" title="Static Blocks" module="Mage_Cms" sortOrder="10" parent="Mage_Cms::cms" action="adminhtml/cms_block" /> + <add id="Mage_Cms::cms" title="CMS" module="Mage_Cms" sortOrder="70" resource="Mage_Cms::cms"/> + <add id="Mage_Cms::cms_page" title="Pages" module="Mage_Cms" sortOrder="0" parent="Mage_Cms::cms" action="adminhtml/cms_page" resource="Mage_Cms::page"/> + <add id="Mage_Cms::cms_block" title="Static Blocks" module="Mage_Cms" sortOrder="10" parent="Mage_Cms::cms" action="adminhtml/cms_block" resource="Mage_Cms::block"/> </menu> </config> diff --git a/app/code/core/Mage/Cms/etc/system.xml b/app/code/core/Mage/Cms/etc/system.xml index 031262c0304..2787b3c08da 100644 --- a/app/code/core/Mage/Cms/etc/system.xml +++ b/app/code/core/Mage/Cms/etc/system.xml @@ -79,6 +79,7 @@ <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>1</show_in_store> + <resource>Mage_Cms::config_cms</resource> <groups> <wysiwyg translate="label"> <label>WYSIWYG Options</label> diff --git a/app/code/core/Mage/Connect/controllers/Adminhtml/Extension/CustomController.php b/app/code/core/Mage/Connect/controllers/Adminhtml/Extension/CustomController.php index bf0451f87bc..d397bf895cc 100644 --- a/app/code/core/Mage/Connect/controllers/Adminhtml/Extension/CustomController.php +++ b/app/code/core/Mage/Connect/controllers/Adminhtml/Extension/CustomController.php @@ -199,6 +199,6 @@ class Mage_Connect_Adminhtml_Extension_CustomController extends Mage_Adminhtml_C */ protected function _isAllowed() { - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('system/extensions/custom'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Adminhtml::custom'); } } diff --git a/app/code/core/Mage/Connect/etc/adminhtml/acl.xml b/app/code/core/Mage/Connect/etc/adminhtml/acl.xml new file mode 100644 index 00000000000..de52eabb805 --- /dev/null +++ b/app/code/core/Mage/Connect/etc/adminhtml/acl.xml @@ -0,0 +1,32 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Mage + * @package Mage_Connect + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config> + <acl> + <resources /> + </acl> +</config> diff --git a/app/code/core/Mage/Connect/etc/adminhtml/menu.xml b/app/code/core/Mage/Connect/etc/adminhtml/menu.xml index e470289d19c..4bf130610ab 100644 --- a/app/code/core/Mage/Connect/etc/adminhtml/menu.xml +++ b/app/code/core/Mage/Connect/etc/adminhtml/menu.xml @@ -27,8 +27,8 @@ --> <config> <menu> - <add id="Mage_Connect::system_extensions" title="Magento Connect" module="Mage_Connect" sortOrder="80" parent="Mage_Adminhtml::system" /> - <add id="Mage_Connect::system_extensions_local" title="Magento Connect Manager" module="Mage_Connect" parent="Mage_Connect::system_extensions" action="adminhtml/extension_local" /> - <add id="Mage_Connect::system_extensions_custom" title="Package Extensions" module="Mage_Connect" parent="Mage_Connect::system_extensions" action="adminhtml/extension_custom" /> + <add id="Mage_Connect::system_extensions" title="Magento Connect" module="Mage_Connect" sortOrder="80" parent="Mage_Adminhtml::system" resource="Mage_Adminhtml::extensions"/> + <add id="Mage_Connect::system_extensions_local" title="Magento Connect Manager" module="Mage_Connect" parent="Mage_Connect::system_extensions" action="adminhtml/extension_local" resource="Mage_Adminhtml::local"/> + <add id="Mage_Connect::system_extensions_custom" title="Package Extensions" module="Mage_Connect" parent="Mage_Connect::system_extensions" action="adminhtml/extension_custom" resource="Mage_Adminhtml::custom"/> </menu> </config> diff --git a/app/code/core/Mage/Connect/etc/config.xml b/app/code/core/Mage/Connect/etc/config.xml index c0bdac15db2..255df2fb061 100644 --- a/app/code/core/Mage/Connect/etc/config.xml +++ b/app/code/core/Mage/Connect/etc/config.xml @@ -53,5 +53,14 @@ </connect> </updates> </layout> + <translate> + <modules> + <Mage_Connect> + <files> + <default>Mage_Connect.csv</default> + </files> + </Mage_Connect> + </modules> + </translate> </adminhtml> </config> diff --git a/app/code/core/Mage/Contacts/etc/adminhtml/acl.xml b/app/code/core/Mage/Contacts/etc/adminhtml/acl.xml new file mode 100644 index 00000000000..0a0988770b2 --- /dev/null +++ b/app/code/core/Mage/Contacts/etc/adminhtml/acl.xml @@ -0,0 +1,40 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Mage + * @package Mage_Contacts + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config> + <acl> + <resources> + <resource id="Mage_Adminhtml::admin"> + <resource id="Mage_Adminhtml::system"> + <resource id="Mage_Adminhtml::config"> + <resource id="Mage_Contacts::contacts" module="Mage_Contacts" title="Contacts Section" /> + </resource> + </resource> + </resource> + </resources> + </acl> +</config> diff --git a/app/code/core/Mage/Contacts/etc/system.xml b/app/code/core/Mage/Contacts/etc/system.xml index d16e08e7dd4..58297827226 100644 --- a/app/code/core/Mage/Contacts/etc/system.xml +++ b/app/code/core/Mage/Contacts/etc/system.xml @@ -35,6 +35,7 @@ <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>1</show_in_store> + <resource>Mage_Contacts::contacts</resource> <groups> <contacts translate="label"> <label>Contact Us</label> diff --git a/app/code/core/Mage/Core/Model/Acl/Builder.php b/app/code/core/Mage/Core/Model/Acl/Builder.php new file mode 100644 index 00000000000..64a7ed01ecb --- /dev/null +++ b/app/code/core/Mage/Core/Model/Acl/Builder.php @@ -0,0 +1,98 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Mage + * @package Mage_Core + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +/** + * Access Control List Builder. Retrieves required role/rule/resource loaders from configuration and uses them + * to populate provided ACL object. If loaders are not defined - default loader is used that does not do anything + * to ACL + */ +class Mage_Core_Model_Acl_Builder +{ + /** + * Area configuration + * + * @var Varien_Simplexml_Element + */ + protected $_config; + + /** + * Application config object + * + * @var Mage_Core_Model_Config + */ + protected $_objectFactory; + + /** + * @param array $data + * @throws InvalidArgumentException + */ + public function __construct(array $data = array()) + { + if (!isset($data['areaConfig'])) { + throw new InvalidArgumentException('Area Config must be passed to ACL builder'); + } + $this->_areaConfig = $data['areaConfig']; + if (!isset($data['objectFactory'])) { + throw new InvalidArgumentException('Object Factory must be passed to ACL builder'); + } + $this->_objectFactory = $data['objectFactory']; + } + + /** + * Build Access Control List + * + * @return Magento_Acl + * @throws LogicException + */ + public function getAcl() + { + try { + $acl = $this->_objectFactory->getModelInstance('Magento_Acl'); + $this->_objectFactory->getModelInstance($this->_getLoaderClass('resource'))->populateAcl($acl); + $this->_objectFactory->getModelInstance($this->_getLoaderClass('role'))->populateAcl($acl); + $this->_objectFactory->getModelInstance($this->_getLoaderClass('rule'))->populateAcl($acl); + } catch (Exception $e) { + throw new LogicException('Could not create acl object: ' . $e->getMessage()); + } + + return $acl; + } + + /** + * Retrieve ACL loader class from config or NullLoader if not defined + * + * @param string $loaderType + * @return string + */ + protected function _getLoaderClass($loaderType) + { + $loaderClass = (string) (isset($this->_areaConfig['acl'][$loaderType . 'Loader']) + ? $this->_areaConfig['acl'][$loaderType . 'Loader'] + : ''); + + return $loaderClass ?: 'Magento_Acl_Loader_Default'; + } +} diff --git a/app/code/core/Mage/Core/Model/Config.php b/app/code/core/Mage/Core/Model/Config.php index e424cfca3b3..68d16e939cc 100644 --- a/app/code/core/Mage/Core/Model/Config.php +++ b/app/code/core/Mage/Core/Model/Config.php @@ -277,16 +277,33 @@ class Mage_Core_Model_Config extends Mage_Core_Model_Config_Base public function loadBase() { $etcDir = $this->getOptions()->getEtcDir(); - $files = glob($etcDir.DS.'*.xml'); + $files = array(); + $deferred = array(); + foreach (scandir($etcDir) as $filename) { + if ('.' == $filename || '..' == $filename || '.xml' != substr($filename, -4)) { + continue; + } + $file = "{$etcDir}/{$filename}"; + if ('local.xml' === $filename) { + $deferred[] = $file; + $this->_isLocalConfigLoaded = true; + $localConfig = $this->getOptions()->getData('local_config'); + if (preg_match('/^[a-z\d_-]+\/[a-z\d_-]+\.xml$/', $localConfig)) { + $deferred[] = "{$etcDir}/$localConfig"; + } + } else { + $files[] = $file; + } + } + $files = array_merge($files, $deferred); + $this->loadFile(current($files)); - while ($file = next($files)) { + array_shift($files); + foreach ($files as $file) { $merge = clone $this->_prototype; $merge->loadFile($file); $this->extend($merge); } - if (in_array($etcDir.DS.'local.xml', $files)) { - $this->_isLocalConfigLoaded = true; - } return $this; } @@ -1512,6 +1529,21 @@ class Mage_Core_Model_Config extends Mage_Core_Model_Config_Base return $this->_allowedAreas; } + /** + * Retrieve area config by area code + * + * @param string $areaCode + * @return array + */ + public function getAreaConfig($areaCode) + { + $areas = $this->getAreas(); + if (!isset($areas[$areaCode])) { + throw new InvalidArgumentException('Requested area (' . $areaCode . ') doesn\'t exist'); + } + return $areas[$areaCode]; + } + /** * Load allowed areas from config * diff --git a/app/code/core/Mage/Core/etc/system.xml b/app/code/core/Mage/Core/etc/system.xml index e23646333fd..7be3d797017 100644 --- a/app/code/core/Mage/Core/etc/system.xml +++ b/app/code/core/Mage/Core/etc/system.xml @@ -57,6 +57,7 @@ <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>1</show_in_store> + <resource>Mage_Adminhtml::advanced</resource> <groups> <!--datashare translate="label"> <label>Datasharing</label> @@ -108,6 +109,7 @@ <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>1</show_in_store> + <resource>Mage_Adminhtml::trans_email</resource> <groups> <ident_custom1 translate="label"> <label>Custom Email 1</label> @@ -270,6 +272,7 @@ <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>1</show_in_store> + <resource>Mage_Adminhtml::config_design</resource> <groups> <theme translate="label"> <label>Design Theme</label> @@ -386,6 +389,7 @@ <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>1</show_in_store> + <resource>Mage_Adminhtml::dev</resource> <groups> <restrict translate="label"> <label>Developer Client Restrictions</label> @@ -612,6 +616,7 @@ <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>1</show_in_store> + <resource>Mage_Adminhtml::config_general</resource> <groups> <country translate="label"> <label>Countries Options</label> @@ -763,6 +768,7 @@ <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>1</show_in_store> + <resource>Mage_Adminhtml::config_system</resource> <groups> <smtp translate="label"> <label>Mail Sending Settings</label> @@ -907,6 +913,7 @@ <show_in_default>1</show_in_default> <show_in_website>0</show_in_website> <show_in_store>0</show_in_store> + <resource>Mage_Adminhtml::config_admin</resource> <groups> <emails translate="label"> <label>Admin User Emails</label> @@ -1085,6 +1092,7 @@ <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>1</show_in_store> + <resource>Mage_Adminhtml::web</resource> <groups> <url translate="label"> <label>Url Options</label> 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 a1e9e974aad..125eb1ae17d 100644 --- a/app/code/core/Mage/CurrencySymbol/controllers/Adminhtml/System/CurrencysymbolController.php +++ b/app/code/core/Mage/CurrencySymbol/controllers/Adminhtml/System/CurrencysymbolController.php @@ -95,6 +95,6 @@ class Mage_CurrencySymbol_Adminhtml_System_CurrencysymbolController extends Mage */ protected function _isAllowed() { - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('system/currency/symbols'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_CurrencySymbol::symbols'); } } diff --git a/app/code/core/Mage/CurrencySymbol/etc/adminhtml.xml b/app/code/core/Mage/CurrencySymbol/etc/adminhtml.xml deleted file mode 100644 index 6563150b577..00000000000 --- a/app/code/core/Mage/CurrencySymbol/etc/adminhtml.xml +++ /dev/null @@ -1,54 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License (AFL 3.0) - * that is bundled with this package in the file LICENSE_AFL.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/afl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @category Mage - * @package Mage_CurrencySymbol - * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - */ ---> -<config> - <acl> - <resources> - <admin> - <children> - <system> - <children> - <currency translate="title"> - <title>Manage Currency</title> - <children> - <rates translate="title"> - <title>Rates</title> - <sort_order>50</sort_order> - </rates> - <symbols translate="title"> - <title>Symbols</title> - <sort_order>100</sort_order> - </symbols> - </children> - </currency> - </children> - </system> - </children> - </admin> - </resources> - </acl> -</config> diff --git a/app/code/core/Mage/CurrencySymbol/etc/adminhtml/acl.xml b/app/code/core/Mage/CurrencySymbol/etc/adminhtml/acl.xml new file mode 100644 index 00000000000..b350d96b17f --- /dev/null +++ b/app/code/core/Mage/CurrencySymbol/etc/adminhtml/acl.xml @@ -0,0 +1,41 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Mage + * @package Mage_CurrencySymbol + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config> + <acl> + <resources> + <resource id="Mage_Adminhtml::admin"> + <resource id="Mage_Adminhtml::system"> + <resource id="Mage_CurrencySymbol::system_currency" title="Manage Currency"> + <resource id="Mage_CurrencySymbol::currency_rates" title="Rates" sortOrder="50" /> + <resource id="Mage_CurrencySymbol::symbols" title="Symbols" sortOrder="100" /> + </resource> + </resource> + </resource> + </resources> + </acl> +</config> diff --git a/app/code/core/Mage/CurrencySymbol/etc/adminhtml/menu.xml b/app/code/core/Mage/CurrencySymbol/etc/adminhtml/menu.xml index ab42b57f7b0..6a92750f7b0 100644 --- a/app/code/core/Mage/CurrencySymbol/etc/adminhtml/menu.xml +++ b/app/code/core/Mage/CurrencySymbol/etc/adminhtml/menu.xml @@ -27,8 +27,8 @@ --> <config> <menu> - <update id="Mage_Adminhtml::system_currency" title="Manage Currency" module="Mage_CurrencySymbol" sortOrder="50" parent="Mage_Adminhtml::system" /> - <add id="Mage_CurrencySymbol::system_currency_rates" title="Rates" module="Mage_CurrencySymbol" sortOrder="50" parent="Mage_Adminhtml::system_currency" action="adminhtml/system_currency" /> - <add id="Mage_CurrencySymbol::system_currency_symbols" title="Symbols" module="Mage_CurrencySymbol" sortOrder="100" parent="Mage_Adminhtml::system_currency" action="adminhtml/system_currencysymbol" /> + <update id="Mage_Adminhtml::system_currency" title="Manage Currency" module="Mage_CurrencySymbol" sortOrder="50" parent="Mage_Adminhtml::system"/> + <add id="Mage_CurrencySymbol::system_currency_rates" title="Rates" module="Mage_CurrencySymbol" sortOrder="50" parent="Mage_Adminhtml::system_currency" action="adminhtml/system_currency" resource="Mage_CurrencySymbol::currency_rates"/> + <add id="Mage_CurrencySymbol::system_currency_symbols" title="Symbols" module="Mage_CurrencySymbol" sortOrder="100" parent="Mage_Adminhtml::system_currency" action="adminhtml/system_currencysymbol" resource="Mage_CurrencySymbol::symbols"/> </menu> </config> diff --git a/app/code/core/Mage/Customer/etc/adminhtml/acl.xml b/app/code/core/Mage/Customer/etc/adminhtml/acl.xml new file mode 100644 index 00000000000..b7e0a246f7a --- /dev/null +++ b/app/code/core/Mage/Customer/etc/adminhtml/acl.xml @@ -0,0 +1,45 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Mage + * @package Mage_Customer + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config> + <acl> + <resources> + <resource id="Mage_Adminhtml::admin"> + <resource id="Mage_Customer::customer" module="Mage_Customer" title="Customers" sortOrder="40"> + <resource id="Mage_Customer::group" title="Customer Groups" sortOrder="10" /> + <resource id="Mage_Customer::manage" title="Manage Customers" sortOrder="0" /> + <resource id="Mage_Customer::online" title="Online Customers" sortOrder="100" /> + </resource> + <resource id="Mage_Adminhtml::system"> + <resource id="Mage_Adminhtml::config"> + <resource id="Mage_Customer::config_customer" module="Mage_Customer" title="Customers Section" sortOrder="50" /> + </resource> + </resource> + </resource> + </resources> + </acl> +</config> diff --git a/app/code/core/Mage/Customer/etc/adminhtml/menu.xml b/app/code/core/Mage/Customer/etc/adminhtml/menu.xml index eb32bb0456e..9ebb05f29b6 100644 --- a/app/code/core/Mage/Customer/etc/adminhtml/menu.xml +++ b/app/code/core/Mage/Customer/etc/adminhtml/menu.xml @@ -27,9 +27,9 @@ --> <config> <menu> - <add id="Mage_Customer::customer" title="Customers" module="Mage_Customer" sortOrder="40" /> - <add id="Mage_Customer::customer_manage" title="Manage Customers" module="Mage_Customer" sortOrder="0" parent="Mage_Customer::customer" action="adminhtml/customer/" /> - <add id="Mage_Customer::customer_group" title="Customer Groups" module="Mage_Customer" sortOrder="10" parent="Mage_Customer::customer" action="adminhtml/customer_group/" /> - <add id="Mage_Customer::customer_online" title="Online Customers" module="Mage_Customer" sortOrder="100" parent="Mage_Customer::customer" action="adminhtml/customer_online/" /> + <add id="Mage_Customer::customer" title="Customers" module="Mage_Customer" sortOrder="40" resource="Mage_Customer::customer"/> + <add id="Mage_Customer::customer_manage" title="Manage Customers" module="Mage_Customer" sortOrder="0" parent="Mage_Customer::customer" action="adminhtml/customer/" resource="Mage_Customer::manage"/> + <add id="Mage_Customer::customer_group" title="Customer Groups" module="Mage_Customer" sortOrder="10" parent="Mage_Customer::customer" action="adminhtml/customer_group/" resource="Mage_Customer::group"/> + <add id="Mage_Customer::customer_online" title="Online Customers" module="Mage_Customer" sortOrder="100" parent="Mage_Customer::customer" action="adminhtml/customer_online/" resource="Mage_Customer::online"/> </menu> </config> diff --git a/app/code/core/Mage/Customer/etc/system.xml b/app/code/core/Mage/Customer/etc/system.xml index 3ece31747c2..3a83eadb10e 100644 --- a/app/code/core/Mage/Customer/etc/system.xml +++ b/app/code/core/Mage/Customer/etc/system.xml @@ -41,6 +41,7 @@ <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>1</show_in_store> + <resource>Mage_Customer::config_customer</resource> <groups> <account_share translate="label"> <label>Account Sharing Options</label> diff --git a/app/code/core/Mage/Dataflow/etc/config.xml b/app/code/core/Mage/Dataflow/etc/config.xml index e70f14abb2b..f105837d6ca 100644 --- a/app/code/core/Mage/Dataflow/etc/config.xml +++ b/app/code/core/Mage/Dataflow/etc/config.xml @@ -45,4 +45,15 @@ </dataflow_setup> </resources> </global> + <adminhtml> + <translate> + <modules> + <Mage_Dataflow> + <files> + <default>Mage_Dataflow.csv</default> + </files> + </Mage_Dataflow> + </modules> + </translate> + </adminhtml> </config> diff --git a/app/code/core/Mage/DesignEditor/controllers/Adminhtml/System/Design/EditorController.php b/app/code/core/Mage/DesignEditor/controllers/Adminhtml/System/Design/EditorController.php index 30da890e3af..8f8c33e0fb4 100644 --- a/app/code/core/Mage/DesignEditor/controllers/Adminhtml/System/Design/EditorController.php +++ b/app/code/core/Mage/DesignEditor/controllers/Adminhtml/System/Design/EditorController.php @@ -80,6 +80,6 @@ class Mage_DesignEditor_Adminhtml_System_Design_EditorController extends Mage_Ad */ protected function _isAllowed() { - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('system/design/editor'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_DesignEditor::editor'); } } diff --git a/app/code/core/Mage/DesignEditor/etc/adminhtml/acl.xml b/app/code/core/Mage/DesignEditor/etc/adminhtml/acl.xml new file mode 100644 index 00000000000..9960cbde586 --- /dev/null +++ b/app/code/core/Mage/DesignEditor/etc/adminhtml/acl.xml @@ -0,0 +1,40 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Mage + * @package Mage_DesignEditor + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config> + <acl> + <resources> + <resource id="Mage_Adminhtml::admin"> + <resource id="Mage_Adminhtml::system"> + <resource id="Mage_Adminhtml::design"> + <resource id="Mage_DesignEditor::editor" module="Mage_DesignEditor" title="Editor" sortOrder="20" /> + </resource> + </resource> + </resource> + </resources> + </acl> +</config> diff --git a/app/code/core/Mage/DesignEditor/etc/adminhtml/menu.xml b/app/code/core/Mage/DesignEditor/etc/adminhtml/menu.xml index 8a46113f28a..ecb8eff98ba 100644 --- a/app/code/core/Mage/DesignEditor/etc/adminhtml/menu.xml +++ b/app/code/core/Mage/DesignEditor/etc/adminhtml/menu.xml @@ -27,6 +27,6 @@ --> <config> <menu> - <add id="Mage_DesignEditor::system_design_editor" title="Editor" module="Mage_DesignEditor" sortOrder="20" parent="Mage_Adminhtml::system_design" action="adminhtml/system_design_editor" /> + <add id="Mage_DesignEditor::system_design_editor" title="Editor" module="Mage_DesignEditor" sortOrder="20" parent="Mage_Adminhtml::system_design" action="adminhtml/system_design_editor" resource="Mage_DesignEditor::editor"/> </menu> </config> diff --git a/app/code/core/Mage/Directory/etc/system.xml b/app/code/core/Mage/Directory/etc/system.xml index 0985619a60b..d1a599b9622 100644 --- a/app/code/core/Mage/Directory/etc/system.xml +++ b/app/code/core/Mage/Directory/etc/system.xml @@ -34,6 +34,7 @@ <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>1</show_in_store> + <resource>Mage_Adminhtml::currency</resource> <groups> <options translate="label"> <label>Currency Options</label> diff --git a/app/code/core/Mage/Downloadable/controllers/Adminhtml/Downloadable/FileController.php b/app/code/core/Mage/Downloadable/controllers/Adminhtml/Downloadable/FileController.php index d12c023901e..beade69fe9f 100644 --- a/app/code/core/Mage/Downloadable/controllers/Adminhtml/Downloadable/FileController.php +++ b/app/code/core/Mage/Downloadable/controllers/Adminhtml/Downloadable/FileController.php @@ -87,7 +87,7 @@ class Mage_Downloadable_Adminhtml_Downloadable_FileController extends Mage_Admin */ protected function _isAllowed() { - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('catalog/products'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Catalog::products'); } } diff --git a/app/code/core/Mage/Downloadable/etc/adminhtml.xml b/app/code/core/Mage/Downloadable/etc/adminhtml.xml deleted file mode 100644 index 87cc34e2acf..00000000000 --- a/app/code/core/Mage/Downloadable/etc/adminhtml.xml +++ /dev/null @@ -1,48 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License (AFL 3.0) - * that is bundled with this package in the file LICENSE_AFL.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/afl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @category Mage - * @package Mage_Downloadable - * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - */ ---> -<config> - <acl> - <resources> - <admin> - <children> - <system> - <children> - <config> - <children> - <downloadable translate="title" module="Mage_Downloadable"> - <title>Downloadable Product Section</title> - </downloadable> - </children> - </config> - </children> - </system> - </children> - </admin> - </resources> - </acl> -</config> diff --git a/app/code/core/Mage/Downloadable/etc/adminhtml/acl.xml b/app/code/core/Mage/Downloadable/etc/adminhtml/acl.xml new file mode 100644 index 00000000000..112f61f63d9 --- /dev/null +++ b/app/code/core/Mage/Downloadable/etc/adminhtml/acl.xml @@ -0,0 +1,40 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Mage + * @package Mage_Downloadable + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config> + <acl> + <resources> + <resource id="Mage_Adminhtml::admin"> + <resource id="Mage_Adminhtml::system"> + <resource id="Mage_Adminhtml::config"> + <resource id="Mage_Downloadable::downloadable" module="Mage_Downloadable" title="Downloadable Product Section" /> + </resource> + </resource> + </resource> + </resources> + </acl> +</config> diff --git a/app/code/core/Mage/Downloadable/etc/adminhtml/menu.xml b/app/code/core/Mage/Downloadable/etc/adminhtml/menu.xml index 88bb9ce02f3..2942ce0525f 100644 --- a/app/code/core/Mage/Downloadable/etc/adminhtml/menu.xml +++ b/app/code/core/Mage/Downloadable/etc/adminhtml/menu.xml @@ -27,6 +27,6 @@ --> <config> <menu> - <add id="Mage_Downloadable::report_products_downloads" title="Downloads" module="Mage_Reports" parent="Mage_Reports::report_products" action="adminhtml/report_product/downloads" /> + <add id="Mage_Downloadable::report_products_downloads" title="Downloads" module="Mage_Reports" parent="Mage_Reports::report_products" action="adminhtml/report_product/downloads" resource="Mage_Reports::downloads"/> </menu> </config> diff --git a/app/code/core/Mage/Eav/Model/Entity/Abstract.php b/app/code/core/Mage/Eav/Model/Entity/Abstract.php index a246587a682..9b20da79bd1 100644 --- a/app/code/core/Mage/Eav/Model/Entity/Abstract.php +++ b/app/code/core/Mage/Eav/Model/Entity/Abstract.php @@ -569,11 +569,8 @@ abstract class Mage_Eav_Model_Entity_Abstract extends Mage_Core_Model_Resource_A */ public function attributesCompare($attribute1, $attribute2) { - $sortPath = sprintf('attribute_set_info/%s/sort', $this->_sortingSetId); - $groupSortPath = sprintf('attribute_set_info/%s/group_sort', $this->_sortingSetId); - - $sort1 = ($attribute1->getData($groupSortPath) * 1000) + ($attribute1->getData($sortPath) * 0.0001); - $sort2 = ($attribute2->getData($groupSortPath) * 1000) + ($attribute2->getData($sortPath) * 0.0001); + $sort1 = $attribute1->getSortWeight((int)$this->_sortingSetId); + $sort2 = $attribute2->getSortWeight((int)$this->_sortingSetId); if ($sort1 > $sort2) { return 1; diff --git a/app/code/core/Mage/Eav/Model/Entity/Attribute.php b/app/code/core/Mage/Eav/Model/Entity/Attribute.php index 80cceafbc5b..2265fb02672 100644 --- a/app/code/core/Mage/Eav/Model/Entity/Attribute.php +++ b/app/code/core/Mage/Eav/Model/Entity/Attribute.php @@ -324,4 +324,21 @@ class Mage_Eav_Model_Entity_Attribute extends Mage_Eav_Model_Entity_Attribute_Ab } return $this->getFrontendLabel(); } + + /** + * Get attribute sort weight + * + * @param int $setId + * @return float + */ + public function getSortWeight($setId) + { + $groupSortWeight = isset($this->_data['attribute_set_info'][$setId]['group_sort']) + ? (float) $this->_data['attribute_set_info'][$setId]['group_sort'] * 1000 + : 0.0; + $sortWeight = isset($this->_data['attribute_set_info'][$setId]['sort']) + ? (float)$this->_data['attribute_set_info'][$setId]['sort'] * 0.0001 + : 0.0; + return $groupSortWeight + $sortWeight; + } } diff --git a/app/code/core/Mage/GoogleAnalytics/etc/adminhtml/acl.xml b/app/code/core/Mage/GoogleAnalytics/etc/adminhtml/acl.xml new file mode 100644 index 00000000000..7f30ee0ba34 --- /dev/null +++ b/app/code/core/Mage/GoogleAnalytics/etc/adminhtml/acl.xml @@ -0,0 +1,40 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Mage + * @package Mage_GoogleAnalytics + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config> + <acl> + <resources> + <resource id="Mage_Adminhtml::admin"> + <resource id="Mage_Adminhtml::system"> + <resource id="Mage_Adminhtml::config"> + <resource id="Mage_GoogleCheckout::google" module="Mage_GoogleAnalytics" title="Google API" /> + </resource> + </resource> + </resource> + </resources> + </acl> +</config> diff --git a/app/code/core/Mage/GoogleAnalytics/etc/system.xml b/app/code/core/Mage/GoogleAnalytics/etc/system.xml index 1c225eed508..da9bcb49fc2 100644 --- a/app/code/core/Mage/GoogleAnalytics/etc/system.xml +++ b/app/code/core/Mage/GoogleAnalytics/etc/system.xml @@ -35,6 +35,7 @@ <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>1</show_in_store> + <resource>Mage_GoogleCheckout::google</resource> <groups> <analytics translate="label"> <label>Google Analytics</label> diff --git a/app/code/core/Mage/GoogleCheckout/etc/adminhtml.xml b/app/code/core/Mage/GoogleCheckout/etc/adminhtml.xml deleted file mode 100644 index a519c218b40..00000000000 --- a/app/code/core/Mage/GoogleCheckout/etc/adminhtml.xml +++ /dev/null @@ -1,48 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License (AFL 3.0) - * that is bundled with this package in the file LICENSE_AFL.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/afl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @category Mage - * @package Mage_GoogleCheckout - * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - */ ---> -<config> - <acl> - <resources> - <admin> - <children> - <system> - <children> - <config> - <children> - <google translate="title" module="Mage_GoogleCheckout"> - <title>Google API</title> - </google> - </children> - </config> - </children> - </system> - </children> - </admin> - </resources> - </acl> -</config> diff --git a/app/code/core/Mage/GoogleCheckout/etc/adminhtml/acl.xml b/app/code/core/Mage/GoogleCheckout/etc/adminhtml/acl.xml new file mode 100644 index 00000000000..01eb140f3c1 --- /dev/null +++ b/app/code/core/Mage/GoogleCheckout/etc/adminhtml/acl.xml @@ -0,0 +1,40 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Mage + * @package Mage_GoogleCheckout + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config> + <acl> + <resources> + <resource id="Mage_Adminhtml::admin"> + <resource id="Mage_Adminhtml::system"> + <resource id="Mage_Adminhtml::config"> + <resource id="Mage_GoogleCheckout::google" module="Mage_GoogleCheckout" title="Google API" /> + </resource> + </resource> + </resource> + </resources> + </acl> +</config> diff --git a/app/code/core/Mage/GoogleCheckout/etc/system.xml b/app/code/core/Mage/GoogleCheckout/etc/system.xml index 1ff8a511222..15c88e21aa6 100644 --- a/app/code/core/Mage/GoogleCheckout/etc/system.xml +++ b/app/code/core/Mage/GoogleCheckout/etc/system.xml @@ -35,6 +35,7 @@ <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>0</show_in_store> + <resource>Mage_GoogleCheckout::google</resource> <groups> <checkout translate="label"> <label>Google Checkout</label> diff --git a/app/code/core/Mage/GoogleOptimizer/Block/Adminhtml/Cms/Page/Edit/Tab/Googleoptimizer.php b/app/code/core/Mage/GoogleOptimizer/Block/Adminhtml/Cms/Page/Edit/Tab/Googleoptimizer.php index 2dbd459e84d..17f23c9228c 100644 --- a/app/code/core/Mage/GoogleOptimizer/Block/Adminhtml/Cms/Page/Edit/Tab/Googleoptimizer.php +++ b/app/code/core/Mage/GoogleOptimizer/Block/Adminhtml/Cms/Page/Edit/Tab/Googleoptimizer.php @@ -48,7 +48,7 @@ class Mage_GoogleOptimizer_Block_Adminhtml_Cms_Page_Edit_Tab_Googleoptimizer /* * Checking if user have permissions to save information */ - if ($this->_isAllowedAction('save')) { + if ($this->_isAllowedAction('Mage_Cms::save')) { $isElementDisabled = false; } else { $isElementDisabled = true; @@ -242,11 +242,11 @@ class Mage_GoogleOptimizer_Block_Adminhtml_Cms_Page_Edit_Tab_Googleoptimizer /** Check permission for passed action * - * @param string $action + * @param string $resourceId * @return bool */ - protected function _isAllowedAction($action) + protected function _isAllowedAction($resourceId) { - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('cms/page/' . $action); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed($resourceId); } } diff --git a/app/code/core/Mage/GoogleShopping/controllers/Adminhtml/Googleshopping/ItemsController.php b/app/code/core/Mage/GoogleShopping/controllers/Adminhtml/Googleshopping/ItemsController.php index 05e93e3901e..a63c6913424 100644 --- a/app/code/core/Mage/GoogleShopping/controllers/Adminhtml/Googleshopping/ItemsController.php +++ b/app/code/core/Mage/GoogleShopping/controllers/Adminhtml/Googleshopping/ItemsController.php @@ -334,6 +334,6 @@ class Mage_GoogleShopping_Adminhtml_Googleshopping_ItemsController extends Mage_ */ protected function _isAllowed() { - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('catalog/googleshopping/items'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_GoogleShopping::items'); } } diff --git a/app/code/core/Mage/GoogleShopping/controllers/Adminhtml/Googleshopping/TypesController.php b/app/code/core/Mage/GoogleShopping/controllers/Adminhtml/Googleshopping/TypesController.php index e194491fc4d..fcf415c8cdb 100644 --- a/app/code/core/Mage/GoogleShopping/controllers/Adminhtml/Googleshopping/TypesController.php +++ b/app/code/core/Mage/GoogleShopping/controllers/Adminhtml/Googleshopping/TypesController.php @@ -294,6 +294,6 @@ class Mage_GoogleShopping_Adminhtml_Googleshopping_TypesController extends Mage_ */ protected function _isAllowed() { - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('catalog/googleshopping/types'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_GoogleShopping::types'); } } diff --git a/app/code/core/Mage/GoogleShopping/etc/adminhtml.xml b/app/code/core/Mage/GoogleShopping/etc/adminhtml.xml deleted file mode 100644 index 5909846a6c2..00000000000 --- a/app/code/core/Mage/GoogleShopping/etc/adminhtml.xml +++ /dev/null @@ -1,55 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License (AFL 3.0) - * that is bundled with this package in the file LICENSE_AFL.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/afl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @category Mage - * @package Mage_GoogleShopping - * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - */ ---> -<config> - <acl> - <resources> - <admin> - <children> - <catalog> - <children> - <googleshopping translate="title" module="Mage_GoogleShopping"> - <title>Google Content</title> - <sort_order>500</sort_order> - <children> - <types translate="title"> - <title>Manage Attributes</title> - <sort_order>0</sort_order> - </types> - <items translate="title"> - <title>Manage Items</title> - <sort_order>5</sort_order> - </items> - </children> - </googleshopping> - </children> - </catalog> - </children> - </admin> - </resources> - </acl> -</config> diff --git a/app/code/core/Mage/GoogleShopping/etc/adminhtml/acl.xml b/app/code/core/Mage/GoogleShopping/etc/adminhtml/acl.xml new file mode 100644 index 00000000000..7e6ca160950 --- /dev/null +++ b/app/code/core/Mage/GoogleShopping/etc/adminhtml/acl.xml @@ -0,0 +1,41 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Mage + * @package Mage_GoogleShopping + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config> + <acl> + <resources> + <resource id="Mage_Adminhtml::admin"> + <resource id="Mage_Catalog::catalog"> + <resource id="Mage_GoogleShopping::googleshopping" module="Mage_GoogleShopping" title="Google Content" sortOrder="500"> + <resource id="Mage_GoogleShopping::types" title="Manage Attributes" sortOrder="0" /> + <resource id="Mage_GoogleShopping::items" title="Manage Items" sortOrder="5" /> + </resource> + </resource> + </resource> + </resources> + </acl> +</config> diff --git a/app/code/core/Mage/GoogleShopping/etc/adminhtml/menu.xml b/app/code/core/Mage/GoogleShopping/etc/adminhtml/menu.xml index 06f4f8ba446..cb878cffea1 100644 --- a/app/code/core/Mage/GoogleShopping/etc/adminhtml/menu.xml +++ b/app/code/core/Mage/GoogleShopping/etc/adminhtml/menu.xml @@ -27,8 +27,8 @@ --> <config> <menu> - <add id="Mage_GoogleShopping::catalog_googleshopping" title="Google Content" module="Mage_GoogleShopping" sortOrder="70" parent="Mage_Catalog::catalog" /> - <add id="Mage_GoogleShopping::catalog_googleshopping_types" title="Manage Attributes" module="Mage_GoogleShopping" parent="Mage_GoogleShopping::catalog_googleshopping" action="adminhtml/googleshopping_types" /> - <add id="Mage_GoogleShopping::catalog_googleshopping_items" title="Manage Items" module="Mage_GoogleShopping" parent="Mage_GoogleShopping::catalog_googleshopping" action="adminhtml/googleshopping_items" /> + <add id="Mage_GoogleShopping::catalog_googleshopping" title="Google Content" module="Mage_GoogleShopping" sortOrder="70" parent="Mage_Catalog::catalog" resource="Mage_GoogleShopping::googleshopping"/> + <add id="Mage_GoogleShopping::catalog_googleshopping_types" title="Manage Attributes" module="Mage_GoogleShopping" parent="Mage_GoogleShopping::catalog_googleshopping" action="adminhtml/googleshopping_types" resource="Mage_GoogleShopping::types"/> + <add id="Mage_GoogleShopping::catalog_googleshopping_items" title="Manage Items" module="Mage_GoogleShopping" parent="Mage_GoogleShopping::catalog_googleshopping" action="adminhtml/googleshopping_items" resource="Mage_GoogleShopping::items"/> </menu> </config> diff --git a/app/code/core/Mage/ImportExport/Model/Import/Entity/Product.php b/app/code/core/Mage/ImportExport/Model/Import/Entity/Product.php index 7ea54146ce5..1b0469945a4 100644 --- a/app/code/core/Mage/ImportExport/Model/Import/Entity/Product.php +++ b/app/code/core/Mage/ImportExport/Model/Import/Entity/Product.php @@ -1184,7 +1184,9 @@ class Mage_ImportExport_Model_Import_Entity_Product extends Mage_ImportExport_Mo $rowData['attribute_set_id'] = $this->_newSku[$rowSku]['attr_set_id']; $rowData[self::COL_ATTR_SET] = $this->_newSku[$rowSku]['attr_set_code']; } - if (!empty($rowData['_product_websites'])) { // 2. Product-to-Website phase + + // 2. Product-to-Website phase + if (!empty($rowData['_product_websites'])) { $websites[$rowSku][$this->_websiteCodeToId[$rowData['_product_websites']]] = true; } @@ -1197,7 +1199,8 @@ class Mage_ImportExport_Model_Import_Entity_Product extends Mage_ImportExport_Mo $categories[$rowSku][$this->_categories[$categoryPath]] = true; } - if (!empty($rowData['_tier_price_website'])) { // 4.1. Tier prices phase + // 4.1. Tier prices phase + if (!empty($rowData['_tier_price_website'])) { $tierPrices[$rowSku][] = array( 'all_groups' => $rowData['_tier_price_customer_group'] == self::VALUE_ALL, 'customer_group_id' => ($rowData['_tier_price_customer_group'] == self::VALUE_ALL) @@ -1208,7 +1211,9 @@ class Mage_ImportExport_Model_Import_Entity_Product extends Mage_ImportExport_Mo ? 0 : $this->_websiteCodeToId[$rowData['_tier_price_website']] ); } - if (!empty($rowData['_group_price_website'])) { // 4.2. Group prices phase + + // 4.2. Group prices phase + if (!empty($rowData['_group_price_website'])) { $groupPrices[$rowSku][] = array( 'all_groups' => $rowData['_group_price_customer_group'] == self::VALUE_ALL, 'customer_group_id' => ($rowData['_group_price_customer_group'] == self::VALUE_ALL) @@ -1218,8 +1223,10 @@ class Mage_ImportExport_Model_Import_Entity_Product extends Mage_ImportExport_Mo ? 0 : $this->_websiteCodeToId[$rowData['_group_price_website']] ); } + + // 5. Media gallery phase foreach ($this->_imagesArrayKeys as $imageCol) { - if (!empty($rowData[$imageCol])) { // 5. Media gallery phase + if (!empty($rowData[$imageCol])) { if (!array_key_exists($rowData[$imageCol], $uploadedGalleryFiles)) { $uploadedGalleryFiles[$rowData[$imageCol]] = $this->_uploadMediaFiles($rowData[$imageCol]); } @@ -1235,6 +1242,7 @@ class Mage_ImportExport_Model_Import_Entity_Product extends Mage_ImportExport_Mo 'value' => $rowData['_media_image'] ); } + // 6. Attributes phase $rowStore = self::SCOPE_STORE == $rowScope ? $this->_storeCodeToId[$rowData[self::COL_STORE]] : 0; $productType = $rowData[self::COL_TYPE]; @@ -1256,8 +1264,12 @@ class Mage_ImportExport_Model_Import_Entity_Product extends Mage_ImportExport_Mo continue; } } - $rowData = $this->_productTypeModels[$productType]->prepareAttributesForSave($rowData); - $product = Mage::getModel('Mage_ImportExport_Model_Import_Proxy_Product', $rowData); + + $rowData = $this->_productTypeModels[$productType]->prepareAttributesWithDefaultValueForSave( + $rowData, + !isset($this->_oldSku[$rowSku]) + ); + $product = Mage::getModel('Mage_ImportExport_Model_Import_Proxy_Product', $rowData); foreach ($rowData as $attrCode => $attrValue) { $attribute = $resource->getAttribute($attrCode); @@ -1298,9 +1310,11 @@ class Mage_ImportExport_Model_Import_Entity_Product extends Mage_ImportExport_Mo $attributes[$attrTable][$rowSku][$attrId][$storeId] = $attrValue; } } - $attribute->setBackendModel($backModel); // restore 'backend_model' to avoid 'default' setting + // restore 'backend_model' to avoid 'default' setting + $attribute->setBackendModel($backModel); } } + $this->_saveProductEntity($entityRowsIn, $entityRowsUp) ->_saveProductWebsites($websites) ->_saveProductCategories($categories) @@ -1606,6 +1620,7 @@ class Mage_ImportExport_Model_Import_Entity_Product extends Mage_ImportExport_Mo continue; } + $row = array(); $row['product_id'] = $this->_newSku[$rowData[self::COL_SKU]]['entity_id']; $row['stock_id'] = 1; diff --git a/app/code/core/Mage/ImportExport/Model/Import/Entity/Product/Type/Abstract.php b/app/code/core/Mage/ImportExport/Model/Import/Entity/Product/Type/Abstract.php index 3f6f1b8b830..ab0b2b8db88 100644 --- a/app/code/core/Mage/ImportExport/Model/Import/Entity/Product/Type/Abstract.php +++ b/app/code/core/Mage/ImportExport/Model/Import/Entity/Product/Type/Abstract.php @@ -282,12 +282,15 @@ abstract class Mage_ImportExport_Model_Import_Entity_Product_Type_Abstract } /** - * Prepare attributes values for save: remove non-existent, remove empty values, remove static. + * Prepare attributes values for save: exclude non-existent, static or with empty values attributes; + * set default values if needed * * @param array $rowData + * @param bool $withDefaultValue + * * @return array */ - public function prepareAttributesForSave(array $rowData) + public function prepareAttributesWithDefaultValueForSave(array $rowData, $withDefaultValue = true) { $resultAttrs = array(); @@ -296,18 +299,34 @@ abstract class Mage_ImportExport_Model_Import_Entity_Product_Type_Abstract if (isset($rowData[$attrCode]) && strlen($rowData[$attrCode])) { $resultAttrs[$attrCode] = ('select' == $attrParams['type'] || 'multiselect' == $attrParams['type']) - ? $attrParams['options'][strtolower($rowData[$attrCode])] - : $rowData[$attrCode]; + ? $attrParams['options'][strtolower($rowData[$attrCode])] + : $rowData[$attrCode]; } elseif (array_key_exists($attrCode, $rowData)) { $resultAttrs[$attrCode] = $rowData[$attrCode]; - } elseif (null !== $attrParams['default_value']) { + } elseif ($withDefaultValue && null !== $attrParams['default_value']) { $resultAttrs[$attrCode] = $attrParams['default_value']; } } } + return $resultAttrs; } + /** + * Prepare attributes values for save: remove non-existent, remove empty values, remove static. + * + * @deprecated + * @see Mage_ImportExport_Model_Import_Entity_Product_Type_Abstract::prepareAttributesWithDefaultValueForSave() + * + * @param array $rowData + * + * @return array + */ + public function prepareAttributesForSave(array $rowData) + { + return $this->prepareAttributesWithDefaultValueForSave($rowData); + } + /** * Save product type specific data. * diff --git a/app/code/core/Mage/ImportExport/controllers/Adminhtml/ExportController.php b/app/code/core/Mage/ImportExport/controllers/Adminhtml/ExportController.php index 1f2cc3bbf54..da109220819 100644 --- a/app/code/core/Mage/ImportExport/controllers/Adminhtml/ExportController.php +++ b/app/code/core/Mage/ImportExport/controllers/Adminhtml/ExportController.php @@ -65,7 +65,7 @@ class Mage_ImportExport_Adminhtml_ExportController extends Mage_Adminhtml_Contro */ protected function _isAllowed() { - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('system/convert/export'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_ImportExport::export'); } /** diff --git a/app/code/core/Mage/ImportExport/controllers/Adminhtml/ImportController.php b/app/code/core/Mage/ImportExport/controllers/Adminhtml/ImportController.php index c3284de20fa..f796e486e22 100644 --- a/app/code/core/Mage/ImportExport/controllers/Adminhtml/ImportController.php +++ b/app/code/core/Mage/ImportExport/controllers/Adminhtml/ImportController.php @@ -65,7 +65,7 @@ class Mage_ImportExport_Adminhtml_ImportController extends Mage_Adminhtml_Contro */ protected function _isAllowed() { - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('system/convert/import'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_ImportExport::import'); } /** diff --git a/app/code/core/Mage/ImportExport/etc/adminhtml.xml b/app/code/core/Mage/ImportExport/etc/adminhtml.xml deleted file mode 100644 index 51d33a0c95d..00000000000 --- a/app/code/core/Mage/ImportExport/etc/adminhtml.xml +++ /dev/null @@ -1,53 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License (AFL 3.0) - * that is bundled with this package in the file LICENSE_AFL.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/afl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @category Mage - * @package Mage_ImportExport - * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - */ ---> -<config> - <acl> - <resources> - <admin> - <children> - <system> - <children> - <convert module="Mage_ImportExport"> - <children> - <import translate="title"> - <title>Import</title> - <sort_order>10</sort_order> - </import> - <export translate="title"> - <title>Export</title> - <sort_order>20</sort_order> - </export> - </children> - </convert> - </children> - </system> - </children> - </admin> - </resources> - </acl> -</config> diff --git a/app/code/core/Mage/ImportExport/etc/adminhtml/acl.xml b/app/code/core/Mage/ImportExport/etc/adminhtml/acl.xml new file mode 100644 index 00000000000..648bd22364b --- /dev/null +++ b/app/code/core/Mage/ImportExport/etc/adminhtml/acl.xml @@ -0,0 +1,41 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Mage + * @package Mage_ImportExport + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config> + <acl> + <resources> + <resource id="Mage_Adminhtml::admin"> + <resource id="Mage_Adminhtml::system"> + <resource id="Mage_Adminhtml::convert" module="Mage_ImportExport"> + <resource id="Mage_ImportExport::import" title="Import" sortOrder="10" /> + <resource id="Mage_ImportExport::export" title="Export" sortOrder="20" /> + </resource> + </resource> + </resource> + </resources> + </acl> +</config> diff --git a/app/code/core/Mage/ImportExport/etc/adminhtml/menu.xml b/app/code/core/Mage/ImportExport/etc/adminhtml/menu.xml index cba1090c952..64082f29514 100644 --- a/app/code/core/Mage/ImportExport/etc/adminhtml/menu.xml +++ b/app/code/core/Mage/ImportExport/etc/adminhtml/menu.xml @@ -27,7 +27,7 @@ --> <config> <menu> - <add id="Mage_ImportExport::system_convert_import" title="Import" module="Mage_ImportExport" sortOrder="10" parent="Mage_Adminhtml::system_convert" action="adminhtml/import" /> - <add id="Mage_ImportExport::system_convert_export" title="Export" module="Mage_ImportExport" sortOrder="20" parent="Mage_Adminhtml::system_convert" action="adminhtml/export" /> + <add id="Mage_ImportExport::system_convert_import" title="Import" module="Mage_ImportExport" sortOrder="10" parent="Mage_Adminhtml::system_convert" action="adminhtml/import" resource="Mage_ImportExport::import"/> + <add id="Mage_ImportExport::system_convert_export" title="Export" module="Mage_ImportExport" sortOrder="20" parent="Mage_Adminhtml::system_convert" action="adminhtml/export" resource="Mage_ImportExport::export"/> </menu> </config> diff --git a/app/code/core/Mage/ImportExport/etc/config.xml b/app/code/core/Mage/ImportExport/etc/config.xml index 87258070f33..7827227edda 100644 --- a/app/code/core/Mage/ImportExport/etc/config.xml +++ b/app/code/core/Mage/ImportExport/etc/config.xml @@ -125,6 +125,15 @@ </importexport> </updates> </layout> + <translate> + <modules> + <Mage_ImportExport> + <files> + <default>Mage_ImportExport.csv</default> + </files> + </Mage_ImportExport> + </modules> + </translate> </adminhtml> <default> <general> diff --git a/app/code/core/Mage/Index/Block/Adminhtml/Notifications.php b/app/code/core/Mage/Index/Block/Adminhtml/Notifications.php index a5038407c83..e212a9a9690 100644 --- a/app/code/core/Mage/Index/Block/Adminhtml/Notifications.php +++ b/app/code/core/Mage/Index/Block/Adminhtml/Notifications.php @@ -63,7 +63,7 @@ class Mage_Index_Block_Adminhtml_Notifications extends Mage_Adminhtml_Block_Temp */ protected function _toHtml() { - if (Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('system/index')) { + if (Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Index::index')) { return parent::_toHtml(); } return ''; diff --git a/app/code/core/Mage/Index/controllers/Adminhtml/ProcessController.php b/app/code/core/Mage/Index/controllers/Adminhtml/ProcessController.php index b4d47c07a7d..6abde0485ab 100644 --- a/app/code/core/Mage/Index/controllers/Adminhtml/ProcessController.php +++ b/app/code/core/Mage/Index/controllers/Adminhtml/ProcessController.php @@ -238,6 +238,6 @@ class Mage_Index_Adminhtml_ProcessController extends Mage_Adminhtml_Controller_A */ protected function _isAllowed() { - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('system/index'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Index::index'); } } diff --git a/app/code/core/Mage/Index/etc/adminhtml/acl.xml b/app/code/core/Mage/Index/etc/adminhtml/acl.xml new file mode 100644 index 00000000000..604c4d335e6 --- /dev/null +++ b/app/code/core/Mage/Index/etc/adminhtml/acl.xml @@ -0,0 +1,38 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Mage + * @package Mage_Index + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config> + <acl> + <resources> + <resource id="Mage_Adminhtml::admin"> + <resource id="Mage_Adminhtml::system"> + <resource id="Mage_Index::index" title="Index Management" /> + </resource> + </resource> + </resources> + </acl> +</config> diff --git a/app/code/core/Mage/Index/etc/adminhtml/menu.xml b/app/code/core/Mage/Index/etc/adminhtml/menu.xml index 55b25fa7064..d8ab9683ad2 100644 --- a/app/code/core/Mage/Index/etc/adminhtml/menu.xml +++ b/app/code/core/Mage/Index/etc/adminhtml/menu.xml @@ -27,6 +27,6 @@ --> <config> <menu> - <add id="Mage_Index::system_index" title="Index Management" module="Mage_Index" sortOrder="92" parent="Mage_Adminhtml::system" action="adminhtml/process/list" /> + <add id="Mage_Index::system_index" title="Index Management" module="Mage_Index" sortOrder="92" parent="Mage_Adminhtml::system" action="adminhtml/process/list" resource="Mage_Index::index"/> </menu> </config> diff --git a/app/code/core/Mage/Newsletter/etc/adminhtml.xml b/app/code/core/Mage/Newsletter/etc/adminhtml.xml deleted file mode 100644 index 307a014ec74..00000000000 --- a/app/code/core/Mage/Newsletter/etc/adminhtml.xml +++ /dev/null @@ -1,66 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License (AFL 3.0) - * that is bundled with this package in the file LICENSE_AFL.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/afl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @category Mage - * @package Mage_Newsletter - * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - */ ---> -<config> - <acl> - <resources> - <admin> - <children> - <system> - <children> - <config> - <children> - <newsletter translate="title" module="Mage_Newsletter"> - <title>Newsletter Section</title> - </newsletter> - </children> - </config> - </children> - </system> - <newsletter translate="title" module="Mage_Newsletter"> - <title>Newsletter</title> - <sort_order>60</sort_order> - <children> - <problem translate="title"> - <title>Newsletter Problem Reports</title> - </problem> - <queue translate="title"> - <title>Newsletter Queue</title> - </queue> - <subscriber translate="title"> - <title>Newsletter Subscribers</title> - </subscriber> - <template translate="title"> - <title>Newsletter Templates</title> - </template> - </children> - </newsletter> - </children> - </admin> - </resources> - </acl> -</config> diff --git a/app/code/core/Mage/Newsletter/etc/adminhtml/acl.xml b/app/code/core/Mage/Newsletter/etc/adminhtml/acl.xml new file mode 100644 index 00000000000..4d9e501df81 --- /dev/null +++ b/app/code/core/Mage/Newsletter/etc/adminhtml/acl.xml @@ -0,0 +1,46 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Mage + * @package Mage_Newsletter + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config> + <acl> + <resources> + <resource id="Mage_Adminhtml::admin"> + <resource id="Mage_Adminhtml::system"> + <resource id="Mage_Adminhtml::config"> + <resource id="Mage_Newsletter::newsletter" module="Mage_Newsletter" title="Newsletter Section" /> + </resource> + </resource> + <resource id="Mage_Newsletter::admin_newsletter" module="Mage_Newsletter" title="Newsletter" sortOrder="60"> + <resource id="Mage_Newsletter::problem" title="Newsletter Problem Reports" /> + <resource id="Mage_Newsletter::queue" title="Newsletter Queue" /> + <resource id="Mage_Newsletter::subscriber" title="Newsletter Subscribers" /> + <resource id="Mage_Newsletter::template" title="Newsletter Templates" /> + </resource> + </resource> + </resources> + </acl> +</config> diff --git a/app/code/core/Mage/Newsletter/etc/adminhtml/menu.xml b/app/code/core/Mage/Newsletter/etc/adminhtml/menu.xml index 526556d0564..5ed62029c31 100644 --- a/app/code/core/Mage/Newsletter/etc/adminhtml/menu.xml +++ b/app/code/core/Mage/Newsletter/etc/adminhtml/menu.xml @@ -27,10 +27,10 @@ --> <config> <menu> - <add id="Mage_Newsletter::newsletter" title="Newsletter" module="Mage_Newsletter" sortOrder="60" /> - <add id="Mage_Newsletter::newsletter_template" title="Newsletter Templates" module="Mage_Newsletter" parent="Mage_Newsletter::newsletter" action="adminhtml/newsletter_template/" /> - <add id="Mage_Newsletter::newsletter_queue" title="Newsletter Queue" module="Mage_Newsletter" parent="Mage_Newsletter::newsletter" action="adminhtml/newsletter_queue/" /> - <add id="Mage_Newsletter::newsletter_subscriber" title="Newsletter Subscribers" module="Mage_Newsletter" parent="Mage_Newsletter::newsletter" action="adminhtml/newsletter_subscriber/" /> - <add id="Mage_Newsletter::newsletter_problem" title="Newsletter Problem Reports" module="Mage_Newsletter" parent="Mage_Newsletter::newsletter" action="adminhtml/newsletter_problem/" /> + <add id="Mage_Newsletter::newsletter" title="Newsletter" module="Mage_Newsletter" sortOrder="60" resource="Mage_Newsletter::admin_newsletter"/> + <add id="Mage_Newsletter::newsletter_template" title="Newsletter Templates" module="Mage_Newsletter" parent="Mage_Newsletter::newsletter" action="adminhtml/newsletter_template/" resource="Mage_Newsletter::template"/> + <add id="Mage_Newsletter::newsletter_queue" title="Newsletter Queue" module="Mage_Newsletter" parent="Mage_Newsletter::newsletter" action="adminhtml/newsletter_queue/" resource="Mage_Newsletter::queue"/> + <add id="Mage_Newsletter::newsletter_subscriber" title="Newsletter Subscribers" module="Mage_Newsletter" parent="Mage_Newsletter::newsletter" action="adminhtml/newsletter_subscriber/" resource="Mage_Newsletter::subscriber"/> + <add id="Mage_Newsletter::newsletter_problem" title="Newsletter Problem Reports" module="Mage_Newsletter" parent="Mage_Newsletter::newsletter" action="adminhtml/newsletter_problem/" resource="Mage_Newsletter::problem"/> </menu> </config> diff --git a/app/code/core/Mage/Newsletter/etc/system.xml b/app/code/core/Mage/Newsletter/etc/system.xml index 3cd2bc00cd5..374d9c405aa 100644 --- a/app/code/core/Mage/Newsletter/etc/system.xml +++ b/app/code/core/Mage/Newsletter/etc/system.xml @@ -35,6 +35,7 @@ <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>1</show_in_store> + <resource>Mage_Newsletter::newsletter</resource> <groups> <subscription translate="label"> <label>Subscription Options</label> diff --git a/app/code/core/Mage/Oauth/Block/Adminhtml/Oauth/AuthorizedTokens/Grid.php b/app/code/core/Mage/Oauth/Block/Adminhtml/Oauth/AuthorizedTokens/Grid.php index 9ff15e3e6ff..3a03cc74f92 100644 --- a/app/code/core/Mage/Oauth/Block/Adminhtml/Oauth/AuthorizedTokens/Grid.php +++ b/app/code/core/Mage/Oauth/Block/Adminhtml/Oauth/AuthorizedTokens/Grid.php @@ -220,6 +220,6 @@ class Mage_Oauth_Block_Adminhtml_Oauth_AuthorizedTokens_Grid extends Mage_Adminh { /** @var $session Mage_Backend_Model_Auth_Session */ $session = Mage::getSingleton('Mage_Backend_Model_Auth_Session'); - return $session->isAllowed('system/oauth/authorizedTokens'); + return $session->isAllowed('Mage_Oauth::authorizedTokens'); } } diff --git a/app/code/core/Mage/Oauth/Block/Adminhtml/Oauth/Consumer.php b/app/code/core/Mage/Oauth/Block/Adminhtml/Oauth/Consumer.php index e28be22fd96..ab9159248bc 100644 --- a/app/code/core/Mage/Oauth/Block/Adminhtml/Oauth/Consumer.php +++ b/app/code/core/Mage/Oauth/Block/Adminhtml/Oauth/Consumer.php @@ -47,7 +47,7 @@ class Mage_Oauth_Block_Adminhtml_Oauth_Consumer extends Mage_Adminhtml_Block_Wid //check allow edit /** @var $session Mage_Backend_Model_Auth_Session */ $session = Mage::getSingleton('Mage_Backend_Model_Auth_Session'); - if (!$session->isAllowed('system/oauth/consumer/edit')) { + if (!$session->isAllowed('Mage_Oauth::consumer_edit')) { $this->_removeButton('add'); } } diff --git a/app/code/core/Mage/Oauth/Block/Adminhtml/Oauth/Consumer/Edit.php b/app/code/core/Mage/Oauth/Block/Adminhtml/Oauth/Consumer/Edit.php index fd21fa23c62..16f646b03c0 100644 --- a/app/code/core/Mage/Oauth/Block/Adminhtml/Oauth/Consumer/Edit.php +++ b/app/code/core/Mage/Oauth/Block/Adminhtml/Oauth/Consumer/Edit.php @@ -79,7 +79,7 @@ class Mage_Oauth_Block_Adminhtml_Oauth_Consumer_Edit extends Mage_Adminhtml_Bloc /** @var $session Mage_Backend_Model_Auth_Session */ $session = Mage::getSingleton('Mage_Backend_Model_Auth_Session'); - if (!$this->getModel() || !$this->getModel()->getId() || !$session->isAllowed('system/oauth/consumer/delete')) { + if (!$this->getModel() || !$this->getModel()->getId() || !$session->isAllowed('Mage_Oauth::consumer_delete')) { $this->_removeButton('delete'); } } diff --git a/app/code/core/Mage/Oauth/Block/Adminhtml/Oauth/Consumer/Grid.php b/app/code/core/Mage/Oauth/Block/Adminhtml/Oauth/Consumer/Grid.php index d41c42f728e..19f635941a3 100644 --- a/app/code/core/Mage/Oauth/Block/Adminhtml/Oauth/Consumer/Grid.php +++ b/app/code/core/Mage/Oauth/Block/Adminhtml/Oauth/Consumer/Grid.php @@ -54,7 +54,7 @@ class Mage_Oauth_Block_Adminhtml_Oauth_Consumer_Grid extends Mage_Adminhtml_Bloc /** @var $session Mage_Backend_Model_Auth_Session */ $session = Mage::getSingleton('Mage_Backend_Model_Auth_Session'); - $this->_editAllow = $session->isAllowed('system/oauth/consumer/edit'); + $this->_editAllow = $session->isAllowed('Mage_Oauth::consumer_edit'); } /** 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 8121597945f..a43dcafb885 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 @@ -181,6 +181,6 @@ class Mage_Oauth_Adminhtml_Oauth_Admin_TokenController extends Mage_Adminhtml_Co { /** @var $session Mage_Backend_Model_Auth_Session */ $session = Mage::getSingleton('Mage_Backend_Model_Auth_Session'); - return $session->isAllowed('system/acl/admin_token'); + return $session->isAllowed('Mage_Oauth::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 fa4ee1cb315..cf5ca728612 100644 --- a/app/code/core/Mage/Oauth/controllers/Adminhtml/Oauth/AuthorizedTokensController.php +++ b/app/code/core/Mage/Oauth/controllers/Adminhtml/Oauth/AuthorizedTokensController.php @@ -163,7 +163,7 @@ class Mage_Oauth_Adminhtml_Oauth_AuthorizedTokensController extends Mage_Adminht { /** @var $session Mage_Backend_Model_Auth_Session */ $session = Mage::getSingleton('Mage_Backend_Model_Auth_Session'); - return $session->isAllowed('system/oauth/authorizedTokens'); + return $session->isAllowed('Mage_Oauth::authorizedTokens'); } /** 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 6bf614d2c7c..771274f770b 100644 --- a/app/code/core/Mage/Oauth/controllers/Adminhtml/Oauth/ConsumerController.php +++ b/app/code/core/Mage/Oauth/controllers/Adminhtml/Oauth/ConsumerController.php @@ -234,17 +234,25 @@ class Mage_Oauth_Adminhtml_Oauth_ConsumerController extends Mage_Adminhtml_Contr protected function _isAllowed() { $action = $this->getRequest()->getActionName(); - if ('index' == $action) { - $action = null; - } else { - if ('new' == $action || 'save' == $action) { - $action = 'edit'; - } - $action = '/' . $action; + $resourceId = null; + switch ($action) { + case 'delete': + $resourceId = 'Mage_Oauth::consumer_delete'; + break; + + case 'new': + case 'save': + $resourceId = 'Mage_Oauth::consumer_edit'; + break; + + default: + $resourceId = 'Mage_Oauth::consumer'; + break; } + /** @var $session Mage_Backend_Model_Auth_Session*/ $session = Mage::getSingleton('Mage_Backend_Model_Auth_Session'); - return $session->isAllowed('system/oauth/consumer' . $action); + return $session->isAllowed($resourceId); } /** diff --git a/app/code/core/Mage/Oauth/etc/adminhtml.xml b/app/code/core/Mage/Oauth/etc/adminhtml.xml deleted file mode 100644 index 804ae7dfc20..00000000000 --- a/app/code/core/Mage/Oauth/etc/adminhtml.xml +++ /dev/null @@ -1,75 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License (AFL 3.0) - * that is bundled with this package in the file LICENSE_AFL.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/afl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @category Mage - * @package Mage_Oauth - * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - */ ---> -<config> - <acl> - <resources> - <admin> - <children> - <system> - <children> - <api> - <children> - <consumer translate="title" module="Mage_Oauth"> - <title>OAuth Consumers</title> - <sort_order>20</sort_order> - <children> - <edit translate="title"> - <title>Edit</title> - <sort_order>30</sort_order> - </edit> - <delete translate="title"> - <title>Delete</title> - <sort_order>40</sort_order> - </delete> - </children> - </consumer> - <authorizedTokens translate="title" module="Mage_Oauth"> - <title>OAuth Authorized Tokens</title> - <sort_order>30</sort_order> - </authorizedTokens> - <oauth_admin_token translate="title" module="Mage_Oauth"> - <title>OAuth Admin My Apps</title> - <sort_order>40</sort_order> - </oauth_admin_token> - </children> - </api> - <config> - <children> - <oauth translate="title"> - <title>OAuth</title> - <sort_order>20</sort_order> - </oauth> - </children> - </config> - </children> - </system> - </children> - </admin> - </resources> - </acl> -</config> diff --git a/app/code/core/Mage/Oauth/etc/adminhtml/acl.xml b/app/code/core/Mage/Oauth/etc/adminhtml/acl.xml new file mode 100644 index 00000000000..e6bc65fef87 --- /dev/null +++ b/app/code/core/Mage/Oauth/etc/adminhtml/acl.xml @@ -0,0 +1,48 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Mage + * @package Mage_Oauth + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config> + <acl> + <resources> + <resource id="Mage_Adminhtml::admin"> + <resource id="Mage_Adminhtml::system"> + <resource id="Mage_Api::api"> + <resource id="Mage_Oauth::consumer" module="Mage_Oauth" title="OAuth Consumers" sortOrder="20"> + <resource id="Mage_Oauth::consumer_edit" title="Edit" sortOrder="30" /> + <resource id="Mage_Oauth::consumer_delete" title="Delete" sortOrder="40" /> + </resource> + <resource id="Mage_Oauth::authorizedTokens" module="Mage_Oauth" title="OAuth Authorized Tokens" sortOrder="30" /> + <resource id="Mage_Oauth::oauth_admin_token" module="Mage_Oauth" title="OAuth Admin My Apps" sortOrder="40" /> + </resource> + <resource id="Mage_Adminhtml::config"> + <resource id="Mage_Oauth::oauth" title="OAuth" sortOrder="20" /> + </resource> + </resource> + </resource> + </resources> + </acl> +</config> diff --git a/app/code/core/Mage/Oauth/etc/adminhtml/menu.xml b/app/code/core/Mage/Oauth/etc/adminhtml/menu.xml index 9f3d6d85506..15e4139496f 100644 --- a/app/code/core/Mage/Oauth/etc/adminhtml/menu.xml +++ b/app/code/core/Mage/Oauth/etc/adminhtml/menu.xml @@ -27,8 +27,8 @@ --> <config> <menu> - <add id="Mage_Oauth::system_api_oauth_consumer" title="REST - OAuth Consumers" module="Mage_Oauth" sortOrder="50" parent="Mage_Api::system_api" action="adminhtml/oauth_consumer" /> - <add id="Mage_Oauth::system_api_oauth_authorized_tokens" title="REST - OAuth Authorized Tokens" module="Mage_Oauth" sortOrder="60" parent="Mage_Api::system_api" action="adminhtml/oauth_authorizedTokens" /> - <add id="Mage_Oauth::system_api_oauth_admin_token" title="REST - My Apps" module="Mage_Oauth" sortOrder="70" parent="Mage_Api::system_api" action="adminhtml/oauth_admin_token" /> + <add id="Mage_Oauth::system_api_oauth_consumer" title="REST - OAuth Consumers" module="Mage_Oauth" sortOrder="50" parent="Mage_Api::system_api" action="adminhtml/oauth_consumer" resource="Mage_Oauth::consumer"/> + <add id="Mage_Oauth::system_api_oauth_authorized_tokens" title="REST - OAuth Authorized Tokens" module="Mage_Oauth" sortOrder="60" parent="Mage_Api::system_api" action="adminhtml/oauth_authorizedTokens" resource="Mage_Oauth::authorizedTokens"/> + <add id="Mage_Oauth::system_api_oauth_admin_token" title="REST - My Apps" module="Mage_Oauth" sortOrder="70" parent="Mage_Api::system_api" action="adminhtml/oauth_admin_token" resource="Mage_Oauth::oauth_admin_token"/> </menu> </config> diff --git a/app/code/core/Mage/Oauth/etc/system.xml b/app/code/core/Mage/Oauth/etc/system.xml index 27c005c865a..87701205af0 100644 --- a/app/code/core/Mage/Oauth/etc/system.xml +++ b/app/code/core/Mage/Oauth/etc/system.xml @@ -35,6 +35,7 @@ <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>1</show_in_store> + <resource>Mage_Oauth::oauth</resource> <groups> <cleanup translate="label"> <label>Cleanup Settings</label> diff --git a/app/code/core/Mage/Ogone/etc/config.xml b/app/code/core/Mage/Ogone/etc/config.xml index 0dadf3f65c9..4da32eaab70 100644 --- a/app/code/core/Mage/Ogone/etc/config.xml +++ b/app/code/core/Mage/Ogone/etc/config.xml @@ -115,6 +115,15 @@ </args> </ogone> </routers> + <translate> + <modules> + <Mage_Ogone> + <files> + <default>Mage_Ogone.csv</default> + </files> + </Mage_Ogone> + </modules> + </translate> </frontend> <default> <payment> diff --git a/app/code/core/Mage/PageCache/Block/Adminhtml/Cache/Additional.php b/app/code/core/Mage/PageCache/Block/Adminhtml/Cache/Additional.php index 3f6f3ae5f0a..762e72fc541 100644 --- a/app/code/core/Mage/PageCache/Block/Adminhtml/Cache/Additional.php +++ b/app/code/core/Mage/PageCache/Block/Adminhtml/Cache/Additional.php @@ -51,6 +51,6 @@ class Mage_PageCache_Block_Adminhtml_Cache_Additional extends Mage_Adminhtml_Blo public function canShowButton() { return Mage::helper('Mage_PageCache_Helper_Data')->isEnabled() - && Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('page_cache'); + && Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_PageCache::page_cache'); } } diff --git a/app/code/core/Mage/PageCache/controllers/Adminhtml/PageCacheController.php b/app/code/core/Mage/PageCache/controllers/Adminhtml/PageCacheController.php index d1175a05979..633f52c0ac0 100644 --- a/app/code/core/Mage/PageCache/controllers/Adminhtml/PageCacheController.php +++ b/app/code/core/Mage/PageCache/controllers/Adminhtml/PageCacheController.php @@ -77,6 +77,6 @@ class Mage_PageCache_Adminhtml_PageCacheController extends Mage_Adminhtml_Contro */ protected function _isAllowed() { - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('page_cache'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_PageCache::page_cache'); } } diff --git a/app/code/core/Mage/PageCache/etc/adminhtml/acl.xml b/app/code/core/Mage/PageCache/etc/adminhtml/acl.xml new file mode 100644 index 00000000000..995fce06bd0 --- /dev/null +++ b/app/code/core/Mage/PageCache/etc/adminhtml/acl.xml @@ -0,0 +1,36 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Mage + * @package Mage_PageCache + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config> + <acl> + <resources> + <resource id="Mage_Adminhtml::admin"> + <resource id="Mage_PageCache::page_cache" module="Mage_PageCache" title="External Page Cache" sortOrder="0" /> + </resource> + </resources> + </acl> +</config> diff --git a/app/code/core/Mage/Payment/etc/adminhtml.xml b/app/code/core/Mage/Payment/etc/adminhtml.xml deleted file mode 100644 index ce1975b700c..00000000000 --- a/app/code/core/Mage/Payment/etc/adminhtml.xml +++ /dev/null @@ -1,51 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License (AFL 3.0) - * that is bundled with this package in the file LICENSE_AFL.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/afl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @category Mage - * @package Mage_Payment - * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - */ ---> -<config> - <acl> - <resources> - <admin> - <children> - <system> - <children> - <config> - <children> - <payment translate="title" module="Mage_Payment"> - <title>Payment Methods Section</title> - </payment> - <payment_services translate="title" module="Mage_Payment"> - <title>Payment Services</title> - </payment_services> - </children> - </config> - </children> - </system> - </children> - </admin> - </resources> - </acl> -</config> diff --git a/app/code/core/Mage/Payment/etc/adminhtml/acl.xml b/app/code/core/Mage/Payment/etc/adminhtml/acl.xml new file mode 100644 index 00000000000..f31e499ddd0 --- /dev/null +++ b/app/code/core/Mage/Payment/etc/adminhtml/acl.xml @@ -0,0 +1,41 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Mage + * @package Mage_Payment + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config> + <acl> + <resources> + <resource id="Mage_Adminhtml::admin"> + <resource id="Mage_Adminhtml::system"> + <resource id="Mage_Adminhtml::config"> + <resource id="Mage_Payment::payment" module="Mage_Payment" title="Payment Methods Section" /> + <resource id="Mage_Payment::payment_services" module="Mage_Payment" title="Payment Services" /> + </resource> + </resource> + </resource> + </resources> + </acl> +</config> diff --git a/app/code/core/Mage/Payment/etc/system.xml b/app/code/core/Mage/Payment/etc/system.xml index a27f7555ceb..cba75207e76 100644 --- a/app/code/core/Mage/Payment/etc/system.xml +++ b/app/code/core/Mage/Payment/etc/system.xml @@ -35,6 +35,7 @@ <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>1</show_in_store> + <resource>Mage_Payment::payment</resource> <groups> <ccsave translate="label"> <label>Saved CC</label> diff --git a/app/code/core/Mage/Paypal/controllers/Adminhtml/Paypal/ReportsController.php b/app/code/core/Mage/Paypal/controllers/Adminhtml/Paypal/ReportsController.php index 8e26881c931..2835b5ac3c6 100644 --- a/app/code/core/Mage/Paypal/controllers/Adminhtml/Paypal/ReportsController.php +++ b/app/code/core/Mage/Paypal/controllers/Adminhtml/Paypal/ReportsController.php @@ -131,13 +131,13 @@ class Mage_Paypal_Adminhtml_Paypal_ReportsController extends Mage_Adminhtml_Cont switch ($this->getRequest()->getActionName()) { case 'index': case 'details': - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('report/salesroot/paypal_settlement_reports/view'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Paypal::paypal_settlement_reports_view'); break; case 'fetch': - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('report/salesroot/paypal_settlement_reports/fetch'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Paypal::fetch'); break; default: - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('report/salesroot/paypal_settlement_reports'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Paypal::paypal_settlement_reports'); break; } } diff --git a/app/code/core/Mage/Paypal/etc/adminhtml.xml b/app/code/core/Mage/Paypal/etc/adminhtml.xml deleted file mode 100644 index afe7cbb44dd..00000000000 --- a/app/code/core/Mage/Paypal/etc/adminhtml.xml +++ /dev/null @@ -1,67 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License (AFL 3.0) - * that is bundled with this package in the file LICENSE_AFL.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/afl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @category Mage - * @package Mage_Paypal - * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - */ ---> -<config> - <acl> - <resources> - <admin> - <children> - <system> - <children> - <config> - <children> - <paypal> - <title>PayPal Section</title> - </paypal> - </children> - </config> - </children> - </system> - <report> - <children> - <salesroot> - <children> - <paypal_settlement_reports translate="title"> - <title>PayPal Settlement Reports</title> - <children> - <view translate="title"> - <title>View</title> - </view> - <fetch translate="title"> - <title>Fetch</title> - </fetch> - </children> - </paypal_settlement_reports> - </children> - </salesroot> - </children> - </report> - </children> - </admin> - </resources> - </acl> -</config> diff --git a/app/code/core/Mage/Paypal/etc/adminhtml/acl.xml b/app/code/core/Mage/Paypal/etc/adminhtml/acl.xml new file mode 100644 index 00000000000..1935ff24d1b --- /dev/null +++ b/app/code/core/Mage/Paypal/etc/adminhtml/acl.xml @@ -0,0 +1,48 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Mage + * @package Mage_Paypal + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config> + <acl> + <resources> + <resource id="Mage_Adminhtml::admin"> + <resource id="Mage_Adminhtml::system"> + <resource id="Mage_Adminhtml::config"> + <resource id="Mage_Paypal::paypal" title="PayPal Section" /> + </resource> + </resource> + <resource id="Mage_Reports::report"> + <resource id="Mage_Reports::salesroot"> + <resource id="Mage_Paypal::paypal_settlement_reports" title="PayPal Settlement Reports"> + <resource id="Mage_Paypal::paypal_settlement_reports_view" title="View" /> + <resource id="Mage_Paypal::fetch" title="Fetch" /> + </resource> + </resource> + </resource> + </resource> + </resources> + </acl> +</config> diff --git a/app/code/core/Mage/Paypal/etc/adminhtml/menu.xml b/app/code/core/Mage/Paypal/etc/adminhtml/menu.xml index 8a302c52422..da079eec18f 100644 --- a/app/code/core/Mage/Paypal/etc/adminhtml/menu.xml +++ b/app/code/core/Mage/Paypal/etc/adminhtml/menu.xml @@ -27,6 +27,6 @@ --> <config> <menu> - <add id="Mage_Paypal::report_salesroot_paypal_settlement_reports" title="PayPal Settlement Reports" module="Mage_Paypal" sortOrder="100" parent="Mage_Reports::report_salesroot" action="adminhtml/paypal_reports" /> + <add id="Mage_Paypal::report_salesroot_paypal_settlement_reports" title="PayPal Settlement Reports" module="Mage_Paypal" sortOrder="100" parent="Mage_Reports::report_salesroot" action="adminhtml/paypal_reports" resource="Mage_Paypal::paypal_settlement_reports"/> </menu> </config> diff --git a/app/code/core/Mage/Persistent/etc/adminhtml.xml b/app/code/core/Mage/Persistent/etc/adminhtml.xml deleted file mode 100644 index 7aeb3491c68..00000000000 --- a/app/code/core/Mage/Persistent/etc/adminhtml.xml +++ /dev/null @@ -1,48 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License (AFL 3.0) - * that is bundled with this package in the file LICENSE_AFL.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/afl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @category Mage - * @package Mage_Persistent - * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - */ ---> -<config> - <acl> - <resources> - <admin> - <children> - <system> - <children> - <config> - <children> - <persistent translate="title" module="Mage_Persistent"> - <title>Persistent Shopping Cart</title> - </persistent> - </children> - </config> - </children> - </system> - </children> - </admin> - </resources> - </acl> -</config> diff --git a/app/code/core/Mage/Persistent/etc/adminhtml/acl.xml b/app/code/core/Mage/Persistent/etc/adminhtml/acl.xml new file mode 100644 index 00000000000..6398272c711 --- /dev/null +++ b/app/code/core/Mage/Persistent/etc/adminhtml/acl.xml @@ -0,0 +1,40 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Mage + * @package Mage_Persistent + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config> + <acl> + <resources> + <resource id="Mage_Adminhtml::admin"> + <resource id="Mage_Adminhtml::system"> + <resource id="Mage_Adminhtml::config"> + <resource id="Mage_Persistent::persistent" module="Mage_Persistent" title="Persistent Shopping Cart" /> + </resource> + </resource> + </resource> + </resources> + </acl> +</config> diff --git a/app/code/core/Mage/Persistent/etc/system.xml b/app/code/core/Mage/Persistent/etc/system.xml index 5f715beaba7..5c915249516 100644 --- a/app/code/core/Mage/Persistent/etc/system.xml +++ b/app/code/core/Mage/Persistent/etc/system.xml @@ -36,7 +36,7 @@ <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>0</show_in_store> - + <resource>Mage_Persistent::persistent</resource> <groups> <options translate="label" module="Mage_Persistent"> <label>General Options</label> diff --git a/app/code/core/Mage/Poll/etc/adminhtml/acl.xml b/app/code/core/Mage/Poll/etc/adminhtml/acl.xml new file mode 100644 index 00000000000..f30a3c22936 --- /dev/null +++ b/app/code/core/Mage/Poll/etc/adminhtml/acl.xml @@ -0,0 +1,38 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Mage + * @package Mage_Poll + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config> + <acl> + <resources> + <resource id="Mage_Adminhtml::admin"> + <resource id="Mage_Cms::cms"> + <resource id="Mage_Poll::poll" module="Mage_Poll" title="Polls" sortOrder="20" /> + </resource> + </resource> + </resources> + </acl> +</config> diff --git a/app/code/core/Mage/Poll/etc/adminhtml/menu.xml b/app/code/core/Mage/Poll/etc/adminhtml/menu.xml index 9a939fa72e6..cca7acadec2 100644 --- a/app/code/core/Mage/Poll/etc/adminhtml/menu.xml +++ b/app/code/core/Mage/Poll/etc/adminhtml/menu.xml @@ -27,6 +27,6 @@ --> <config> <menu> - <add id="Mage_Poll::cms_poll" title="Polls" module="Mage_Poll" sortOrder="20" parent="Mage_Cms::cms" action="adminhtml/poll" /> + <add id="Mage_Poll::cms_poll" title="Polls" module="Mage_Poll" sortOrder="20" parent="Mage_Cms::cms" action="adminhtml/poll" resource="Mage_Poll::poll"/> </menu> </config> diff --git a/app/code/core/Mage/Rating/etc/adminhtml.xml b/app/code/core/Mage/Rating/etc/adminhtml.xml deleted file mode 100644 index b90406640b1..00000000000 --- a/app/code/core/Mage/Rating/etc/adminhtml.xml +++ /dev/null @@ -1,48 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License (AFL 3.0) - * that is bundled with this package in the file LICENSE_AFL.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/afl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @category Mage - * @package Mage_Rating - * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - */ ---> -<config> - <acl> - <resources> - <admin> - <children> - <catalog> - <children> - <reviews_ratings> - <children> - <ratings translate="title" module="Mage_Rating"> - <title>Manage Ratings</title> - </ratings> - </children> - </reviews_ratings> - </children> - </catalog> - </children> - </admin> - </resources> - </acl> -</config> diff --git a/app/code/core/Mage/Rating/etc/adminhtml/acl.xml b/app/code/core/Mage/Rating/etc/adminhtml/acl.xml new file mode 100644 index 00000000000..3a85e9d64a5 --- /dev/null +++ b/app/code/core/Mage/Rating/etc/adminhtml/acl.xml @@ -0,0 +1,40 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Mage + * @package Mage_Rating + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config> + <acl> + <resources> + <resource id="Mage_Adminhtml::admin"> + <resource id="Mage_Catalog::catalog"> + <resource id="Mage_Review::reviews_ratings"> + <resource id="Mage_Rating::ratings" module="Mage_Rating" title="Manage Ratings" /> + </resource> + </resource> + </resource> + </resources> + </acl> +</config> diff --git a/app/code/core/Mage/Reports/etc/adminhtml.xml b/app/code/core/Mage/Reports/etc/adminhtml.xml deleted file mode 100644 index 257fc571b19..00000000000 --- a/app/code/core/Mage/Reports/etc/adminhtml.xml +++ /dev/null @@ -1,153 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License (AFL 3.0) - * that is bundled with this package in the file LICENSE_AFL.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/afl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @category Mage - * @package Mage_Reports - * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - */ ---> -<config> - <acl> - <resources> - <admin> - <children> - <report translate="title" module="Mage_Reports"> - <title>Reports</title> - <sort_order>80</sort_order> - <children> - <salesroot translate="title"> - <title>Sales</title> - <children> - <sales translate="title"> - <title>Sales Report</title> - </sales> - <tax translate="title"> - <title>Tax</title> - </tax> - <shipping translate="title"> - <title>Shipping</title> - </shipping> - <invoiced translate="title"> - <title>Total invoiced</title> - </invoiced> - <refunded translate="title"> - <title>Total refunded</title> - </refunded> - <coupons translate="title"> - <title>Coupons</title> - </coupons> - </children> - </salesroot> - <shopcart translate="title"> - <title>Shopping Cart</title> - <children> - <product translate="title"> - <title>Products in carts</title> - </product> - <abandoned translate="title"> - <title>Abandoned carts</title> - </abandoned> - </children> - </shopcart> - <products translate="title"> - <title>Products</title> - <children> - <bestsellers translate="title"> - <title>Bestsellers</title> - </bestsellers> - <sold translate="title"> - <title>Products Ordered</title> - </sold> - <viewed translate="title"> - <title>Most Viewed</title> - </viewed> - <lowstock translate="title"> - <title>Low stock</title> - </lowstock> - <downloads translate="title"> - <title>Downloads</title> - </downloads> - </children> - </products> - <customers translate="title"> - <title>Customers</title> - <children> - <accounts translate="title"> - <title>New Accounts</title> - </accounts> - <totals translate="title"> - <title>Customers by orders total</title> - </totals> - <orders translate="title"> - <title>Customers by number of orders</title> - </orders> - </children> - </customers> - <review translate="title" module="Mage_Catalog"> - <title>Reviews</title> - <children> - <customer translate="title"> - <title>Customers Reviews</title> - </customer> - <product translate="title"> - <title>Products Reviews</title> - </product> - </children> - </review> - <tags translate="title" module="Mage_Tag"> - <title>Tags</title> - <children> - <customer translate="title" module="Mage_Tag"> - <title>Customers</title> - </customer> - <popular translate="title" module="Mage_Tag"> - <title>Popular</title> - </popular> - <product translate="title" module="Mage_Tag"> - <title>Products</title> - </product> - </children> - </tags> - <search translate="title"> - <title>Search Terms</title> - </search> - <statistics translate="title"> - <title>Statistics</title> - </statistics> - </children> - </report> - <system> - <children> - <config> - <children> - <reports translate="title" module="Mage_Reports"> - <title>Reports</title> - </reports> - </children> - </config> - </children> - </system> - </children> - </admin> - </resources> - </acl> -</config> diff --git a/app/code/core/Mage/Reports/etc/adminhtml/acl.xml b/app/code/core/Mage/Reports/etc/adminhtml/acl.xml new file mode 100644 index 00000000000..96def8beda5 --- /dev/null +++ b/app/code/core/Mage/Reports/etc/adminhtml/acl.xml @@ -0,0 +1,77 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Mage + * @package Mage_Reports + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config> + <acl> + <resources> + <resource id="Mage_Adminhtml::admin"> + <resource id="Mage_Reports::report" module="Mage_Reports" title="Reports" sortOrder="80"> + <resource id="Mage_Reports::salesroot" title="Sales"> + <resource id="Mage_Reports::salesroot_sales" title="Sales Report" /> + <resource id="Mage_Reports::tax" title="Tax" /> + <resource id="Mage_Reports::shipping" title="Shipping" /> + <resource id="Mage_Reports::invoiced" title="Total invoiced" /> + <resource id="Mage_Reports::refunded" title="Total refunded" /> + <resource id="Mage_Reports::coupons" title="Coupons" /> + </resource> + <resource id="Mage_Reports::shopcart" title="Shopping Cart"> + <resource id="Mage_Reports::product" title="Products in carts" /> + <resource id="Mage_Reports::abandoned" title="Abandoned carts" /> + </resource> + <resource id="Mage_Reports::report_products" title="Products"> + <resource id="Mage_Reports::bestsellers" title="Bestsellers" /> + <resource id="Mage_Reports::sold" title="Products Ordered" /> + <resource id="Mage_Reports::viewed" title="Most Viewed" /> + <resource id="Mage_Reports::lowstock" title="Low stock" /> + <resource id="Mage_Reports::downloads" title="Downloads" /> + </resource> + <resource id="Mage_Reports::customers" title="Customers"> + <resource id="Mage_Reports::accounts" title="New Accounts" /> + <resource id="Mage_Reports::totals" title="Customers by orders total" /> + <resource id="Mage_Reports::customers_orders" title="Customers by number of orders" /> + </resource> + <resource id="Mage_Reports::review" module="Mage_Catalog" title="Reviews"> + <resource id="Mage_Reports::review_customer" title="Customers Reviews" /> + <resource id="Mage_Reports::review_product" title="Products Reviews" /> + </resource> + <resource id="Mage_Reports::tags" module="Mage_Tag" title="Tags"> + <resource id="Mage_Reports::tags_customer" module="Mage_Tag" title="Customers" /> + <resource id="Mage_Reports::popular" module="Mage_Tag" title="Popular" /> + <resource id="Mage_Reports::tags_product" module="Mage_Tag" title="Products" /> + </resource> + <resource id="Mage_Reports::report_search" title="Search Terms" /> + <resource id="Mage_Reports::statistics" title="Statistics" /> + </resource> + <resource id="Mage_Adminhtml::system"> + <resource id="Mage_Adminhtml::config"> + <resource id="Mage_Reports::reports" module="Mage_Reports" title="Reports" /> + </resource> + </resource> + </resource> + </resources> + </acl> +</config> diff --git a/app/code/core/Mage/Reports/etc/adminhtml/menu.xml b/app/code/core/Mage/Reports/etc/adminhtml/menu.xml index 923bbb3da39..9a634516137 100644 --- a/app/code/core/Mage/Reports/etc/adminhtml/menu.xml +++ b/app/code/core/Mage/Reports/etc/adminhtml/menu.xml @@ -27,27 +27,27 @@ --> <config> <menu> - <add id="Mage_Reports::report" title="Reports" module="Mage_Reports" sortOrder="80" /> - <add id="Mage_Reports::report_salesroot" title="Sales" module="Mage_Reports" sortOrder="10" parent="Mage_Reports::report" /> - <add id="Mage_Reports::report_salesroot_sales" title="Orders" module="Mage_Reports" parent="Mage_Reports::report_salesroot" action="adminhtml/report_sales/sales" /> - <add id="Mage_Reports::report_salesroot_tax" title="Tax" module="Mage_Reports" parent="Mage_Reports::report_salesroot" action="adminhtml/report_sales/tax" /> - <add id="Mage_Reports::report_salesroot_invoiced" title="Invoiced" module="Mage_Reports" parent="Mage_Reports::report_salesroot" action="adminhtml/report_sales/invoiced" /> - <add id="Mage_Reports::report_salesroot_shipping" title="Shipping" module="Mage_Reports" parent="Mage_Reports::report_salesroot" action="adminhtml/report_sales/shipping" /> - <add id="Mage_Reports::report_salesroot_refunded" title="Refunds" module="Mage_Reports" parent="Mage_Reports::report_salesroot" action="adminhtml/report_sales/refunded" /> - <add id="Mage_Reports::report_salesroot_coupons" title="Coupons" module="Mage_Reports" parent="Mage_Reports::report_salesroot" action="adminhtml/report_sales/coupons" /> - <add id="Mage_Reports::report_shopcart" title="Shopping Cart" module="Mage_Reports" sortOrder="20" parent="Mage_Reports::report" /> - <add id="Mage_Reports::report_shopcart_product" title="Products in carts" module="Mage_Reports" parent="Mage_Reports::report_shopcart" action="adminhtml/report_shopcart/product" /> - <add id="Mage_Reports::report_shopcart_abandoned" title="Abandoned carts" module="Mage_Reports" parent="Mage_Reports::report_shopcart" action="adminhtml/report_shopcart/abandoned" /> - <add id="Mage_Reports::report_products" title="Products" module="Mage_Reports" sortOrder="30" parent="Mage_Reports::report" /> - <add id="Mage_Reports::report_products_bestsellers" title="Bestsellers" module="Mage_Reports" parent="Mage_Reports::report_products" action="adminhtml/report_sales/bestsellers" /> - <add id="Mage_Reports::report_products_sold" title="Products Ordered" module="Mage_Reports" parent="Mage_Reports::report_products" action="adminhtml/report_product/sold" /> - <add id="Mage_Reports::report_products_viewed" title="Most Viewed" module="Mage_Reports" parent="Mage_Reports::report_products" action="adminhtml/report_product/viewed" /> - <add id="Mage_Reports::report_products_lowstock" title="Low stock" module="Mage_Reports" parent="Mage_Reports::report_products" action="adminhtml/report_product/lowstock" /> - <add id="Mage_Reports::report_customers" title="Customers" module="Mage_Reports" sortOrder="40" parent="Mage_Reports::report" /> - <add id="Mage_Reports::report_customers_accounts" title="New Accounts" module="Mage_Reports" parent="Mage_Reports::report_customers" action="adminhtml/report_customer/accounts" /> - <add id="Mage_Reports::report_customers_totals" title="Customers by orders total" module="Mage_Reports" parent="Mage_Reports::report_customers" action="adminhtml/report_customer/totals" /> - <add id="Mage_Reports::report_customers_orders" title="Customers by number of orders" module="Mage_Reports" parent="Mage_Reports::report_customers" action="adminhtml/report_customer/orders" /> - <add id="Mage_Reports::report_search" title="Search Terms" module="Mage_Reports" sortOrder="60" parent="Mage_Reports::report" action="adminhtml/report/search" /> - <add id="Mage_Reports::report_statistics" title="Refresh Statistics" module="Mage_Reports" sortOrder="65535" parent="Mage_Reports::report" action="adminhtml/report_statistics" /> + <add id="Mage_Reports::report" title="Reports" module="Mage_Reports" sortOrder="80" resource="Mage_Reports::report"/> + <add id="Mage_Reports::report_salesroot" title="Sales" module="Mage_Reports" sortOrder="10" parent="Mage_Reports::report" resource="Mage_Reports::salesroot"/> + <add id="Mage_Reports::report_salesroot_sales" title="Orders" module="Mage_Reports" parent="Mage_Reports::report_salesroot" action="adminhtml/report_sales/sales" resource="Mage_Reports::salesroot_sales"/> + <add id="Mage_Reports::report_salesroot_tax" title="Tax" module="Mage_Reports" parent="Mage_Reports::report_salesroot" action="adminhtml/report_sales/tax" resource="Mage_Reports::tax"/> + <add id="Mage_Reports::report_salesroot_invoiced" title="Invoiced" module="Mage_Reports" parent="Mage_Reports::report_salesroot" action="adminhtml/report_sales/invoiced" resource="Mage_Reports::invoiced"/> + <add id="Mage_Reports::report_salesroot_shipping" title="Shipping" module="Mage_Reports" parent="Mage_Reports::report_salesroot" action="adminhtml/report_sales/shipping" resource="Mage_Reports::shipping"/> + <add id="Mage_Reports::report_salesroot_refunded" title="Refunds" module="Mage_Reports" parent="Mage_Reports::report_salesroot" action="adminhtml/report_sales/refunded" resource="Mage_Reports::refunded"/> + <add id="Mage_Reports::report_salesroot_coupons" title="Coupons" module="Mage_Reports" parent="Mage_Reports::report_salesroot" action="adminhtml/report_sales/coupons" resource="Mage_Reports::coupons"/> + <add id="Mage_Reports::report_shopcart" title="Shopping Cart" module="Mage_Reports" sortOrder="20" parent="Mage_Reports::report" resource="Mage_Reports::shopcart"/> + <add id="Mage_Reports::report_shopcart_product" title="Products in carts" module="Mage_Reports" parent="Mage_Reports::report_shopcart" action="adminhtml/report_shopcart/product" resource="Mage_Reports::product"/> + <add id="Mage_Reports::report_shopcart_abandoned" title="Abandoned carts" module="Mage_Reports" parent="Mage_Reports::report_shopcart" action="adminhtml/report_shopcart/abandoned" resource="Mage_Reports::abandoned"/> + <add id="Mage_Reports::report_products" title="Products" module="Mage_Reports" sortOrder="30" parent="Mage_Reports::report" resource="Mage_Reports::report_products"/> + <add id="Mage_Reports::report_products_bestsellers" title="Bestsellers" module="Mage_Reports" parent="Mage_Reports::report_products" action="adminhtml/report_sales/bestsellers" resource="Mage_Reports::bestsellers"/> + <add id="Mage_Reports::report_products_sold" title="Products Ordered" module="Mage_Reports" parent="Mage_Reports::report_products" action="adminhtml/report_product/sold" resource="Mage_Reports::sold"/> + <add id="Mage_Reports::report_products_viewed" title="Most Viewed" module="Mage_Reports" parent="Mage_Reports::report_products" action="adminhtml/report_product/viewed" resource="Mage_Reports::viewed"/> + <add id="Mage_Reports::report_products_lowstock" title="Low stock" module="Mage_Reports" parent="Mage_Reports::report_products" action="adminhtml/report_product/lowstock" resource="Mage_Reports::lowstock"/> + <add id="Mage_Reports::report_customers" title="Customers" module="Mage_Reports" sortOrder="40" parent="Mage_Reports::report" resource="Mage_Reports::customers"/> + <add id="Mage_Reports::report_customers_accounts" title="New Accounts" module="Mage_Reports" parent="Mage_Reports::report_customers" action="adminhtml/report_customer/accounts" resource="Mage_Reports::accounts"/> + <add id="Mage_Reports::report_customers_totals" title="Customers by orders total" module="Mage_Reports" parent="Mage_Reports::report_customers" action="adminhtml/report_customer/totals" resource="Mage_Reports::totals"/> + <add id="Mage_Reports::report_customers_orders" title="Customers by number of orders" module="Mage_Reports" parent="Mage_Reports::report_customers" action="adminhtml/report_customer/orders" resource="Mage_Reports::customers_orders"/> + <add id="Mage_Reports::report_search" title="Search Terms" module="Mage_Reports" sortOrder="60" parent="Mage_Reports::report" action="adminhtml/report/search" resource="Mage_Reports::report_search"/> + <add id="Mage_Reports::report_statistics" title="Refresh Statistics" module="Mage_Reports" sortOrder="65535" parent="Mage_Reports::report" action="adminhtml/report_statistics" resource="Mage_Reports::statistics"/> </menu> </config> diff --git a/app/code/core/Mage/Reports/etc/system.xml b/app/code/core/Mage/Reports/etc/system.xml index e1a5c5ce051..457fa81525a 100644 --- a/app/code/core/Mage/Reports/etc/system.xml +++ b/app/code/core/Mage/Reports/etc/system.xml @@ -74,6 +74,7 @@ <show_in_default>1</show_in_default> <show_in_website>0</show_in_website> <show_in_store>0</show_in_store> + <resource>Mage_Reports::reports</resource> <groups> <dashboard translate="label"> <label>Dashboard</label> diff --git a/app/code/core/Mage/Review/etc/adminhtml.xml b/app/code/core/Mage/Review/etc/adminhtml.xml deleted file mode 100644 index f8d75366d52..00000000000 --- a/app/code/core/Mage/Review/etc/adminhtml.xml +++ /dev/null @@ -1,57 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License (AFL 3.0) - * that is bundled with this package in the file LICENSE_AFL.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/afl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @category Mage - * @package Mage_Review - * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - */ ---> -<config> - <acl> - <resources> - <admin> - <children> - <catalog> - <children> - <reviews_ratings translate="title" module="Mage_Review"> - <title>Reviews and Ratings</title> - <children> - <reviews translate="title"> - <title>Customer Reviews</title> - <children> - <all translate="title"> - <title>All Reviews</title> - </all> - <pending translate="title"> - <title>Pending Reviews</title> - </pending> - </children> - </reviews> - </children> - </reviews_ratings> - </children> - </catalog> - </children> - </admin> - </resources> - </acl> -</config> diff --git a/app/code/core/Mage/Contacts/etc/adminhtml.xml b/app/code/core/Mage/Review/etc/adminhtml/acl.xml similarity index 62% rename from app/code/core/Mage/Contacts/etc/adminhtml.xml rename to app/code/core/Mage/Review/etc/adminhtml/acl.xml index 5b6b5b41974..4ede36b2947 100644 --- a/app/code/core/Mage/Contacts/etc/adminhtml.xml +++ b/app/code/core/Mage/Review/etc/adminhtml/acl.xml @@ -20,7 +20,7 @@ * needs please refer to http://www.magentocommerce.com for more information. * * @category Mage - * @package Mage_Contacts + * @package Mage_Review * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ @@ -28,21 +28,16 @@ <config> <acl> <resources> - <admin> - <children> - <system> - <children> - <config> - <children> - <contacts translate="title" module="Mage_Contacts"> - <title>Contacts Section</title> - </contacts> - </children> - </config> - </children> - </system> - </children> - </admin> + <resource id="Mage_Adminhtml::admin"> + <resource id="Mage_Catalog::catalog"> + <resource id="Mage_Review::reviews_ratings" module="Mage_Review" title="Reviews and Ratings"> + <resource id="Mage_Review::reviews" title="Customer Reviews"> + <resource id="Mage_Review::reviews_all" title="All Reviews" /> + <resource id="Mage_Review::pending" title="Pending Reviews" /> + </resource> + </resource> + </resource> + </resource> </resources> </acl> </config> diff --git a/app/code/core/Mage/Review/etc/adminhtml/menu.xml b/app/code/core/Mage/Review/etc/adminhtml/menu.xml index 95bed523a11..d5a6d5a8d54 100644 --- a/app/code/core/Mage/Review/etc/adminhtml/menu.xml +++ b/app/code/core/Mage/Review/etc/adminhtml/menu.xml @@ -27,13 +27,13 @@ --> <config> <menu> - <add id="Mage_Review::catalog_reviews_ratings" title="Reviews and Ratings" module="Mage_Review" sortOrder="50" parent="Mage_Catalog::catalog" /> - <add id="Mage_Review::catalog_reviews_ratings_reviews" title="Customer Reviews" module="Mage_Review" parent="Mage_Review::catalog_reviews_ratings" /> - <add id="Mage_Review::catalog_reviews_ratings_ratings" title="Manage Ratings" module="Mage_Review" parent="Mage_Review::catalog_reviews_ratings" action="adminhtml/rating/" /> - <add id="Mage_Review::catalog_reviews_ratings_reviews_pending" title="Pending Reviews" module="Mage_Review" parent="Mage_Review::catalog_reviews_ratings_reviews" action="adminhtml/catalog_product_review/pending/" /> - <add id="Mage_Review::catalog_reviews_ratings_reviews_all" title="All Reviews" module="Mage_Review" parent="Mage_Review::catalog_reviews_ratings_reviews" action="adminhtml/catalog_product_review/" /> - <add id="Mage_Review::report_review" title="Reviews" module="Mage_Reports" sortOrder="55" parent="Mage_Reports::report" /> - <add id="Mage_Review::report_review_customer" title="Customers Reviews" module="Mage_Review" parent="Mage_Review::report_review" action="adminhtml/report_review/customer" /> - <add id="Mage_Review::report_review_product" title="Products Reviews" module="Mage_Review" parent="Mage_Review::report_review" action="adminhtml/report_review/product" /> + <add id="Mage_Review::catalog_reviews_ratings" title="Reviews and Ratings" module="Mage_Review" sortOrder="50" parent="Mage_Catalog::catalog" resource="Mage_Review::reviews_ratings"/> + <add id="Mage_Review::catalog_reviews_ratings_reviews" title="Customer Reviews" module="Mage_Review" parent="Mage_Review::catalog_reviews_ratings" resource="Mage_Review::reviews"/> + <add id="Mage_Review::catalog_reviews_ratings_ratings" title="Manage Ratings" module="Mage_Review" parent="Mage_Review::catalog_reviews_ratings" action="adminhtml/rating/" resource="Mage_Rating::ratings"/> + <add id="Mage_Review::catalog_reviews_ratings_reviews_pending" title="Pending Reviews" module="Mage_Review" parent="Mage_Review::catalog_reviews_ratings_reviews" action="adminhtml/catalog_product_review/pending/" resource="Mage_Review::pending"/> + <add id="Mage_Review::catalog_reviews_ratings_reviews_all" title="All Reviews" module="Mage_Review" parent="Mage_Review::catalog_reviews_ratings_reviews" action="adminhtml/catalog_product_review/" resource="Mage_Review::reviews_all"/> + <add id="Mage_Review::report_review" title="Reviews" module="Mage_Reports" sortOrder="55" parent="Mage_Reports::report" resource="Mage_Reports::review"/> + <add id="Mage_Review::report_review_customer" title="Customers Reviews" module="Mage_Review" parent="Mage_Review::report_review" action="adminhtml/report_review/customer" resource="Mage_Reports::review_customer"/> + <add id="Mage_Review::report_review_product" title="Products Reviews" module="Mage_Review" parent="Mage_Review::report_review" action="adminhtml/report_review/product" resource="Mage_Reports::review_product"/> </menu> </config> diff --git a/app/code/core/Mage/Rss/controllers/OrderController.php b/app/code/core/Mage/Rss/controllers/OrderController.php index f04ba9af951..b1ad95858c4 100644 --- a/app/code/core/Mage/Rss/controllers/OrderController.php +++ b/app/code/core/Mage/Rss/controllers/OrderController.php @@ -38,7 +38,7 @@ class Mage_Rss_OrderController extends Mage_Core_Controller_Front_Action { if ('new' === $this->getRequest()->getActionName()) { $this->setCurrentArea('adminhtml'); - if (!self::authenticateAndAuthorizeAdmin($this, 'sales/order')) { + if (!self::authenticateAndAuthorizeAdmin($this, 'Mage_Sales::sales_order')) { return; } } diff --git a/app/code/core/Mage/Rss/etc/adminhtml.xml b/app/code/core/Mage/Rss/etc/adminhtml.xml deleted file mode 100644 index c5b0b918e15..00000000000 --- a/app/code/core/Mage/Rss/etc/adminhtml.xml +++ /dev/null @@ -1,49 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License (AFL 3.0) - * that is bundled with this package in the file LICENSE_AFL.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/afl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @category Mage - * @package Mage_Rss - * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - */ ---> -<config> - <acl> - <resources> - <admin> - <children> - <system> - <children> - <config> - <children> - <rss translate="title"> - <title>RSS Feeds Section</title> - <sort_order>135</sort_order> - </rss> - </children> - </config> - </children> - </system> - </children> - </admin> - </resources> - </acl> -</config> diff --git a/app/code/core/Mage/Rss/etc/adminhtml/acl.xml b/app/code/core/Mage/Rss/etc/adminhtml/acl.xml new file mode 100644 index 00000000000..559ab3a76e0 --- /dev/null +++ b/app/code/core/Mage/Rss/etc/adminhtml/acl.xml @@ -0,0 +1,40 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Mage + * @package Mage_Rss + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config> + <acl> + <resources> + <resource id="Mage_Adminhtml::admin"> + <resource id="Mage_Adminhtml::system"> + <resource id="Mage_Adminhtml::config"> + <resource id="Mage_Rss::rss" title="RSS Feeds Section" sortOrder="135" /> + </resource> + </resource> + </resource> + </resources> + </acl> +</config> diff --git a/app/code/core/Mage/Rss/etc/system.xml b/app/code/core/Mage/Rss/etc/system.xml index e3648571c69..3ef8b8da3c8 100644 --- a/app/code/core/Mage/Rss/etc/system.xml +++ b/app/code/core/Mage/Rss/etc/system.xml @@ -35,6 +35,7 @@ <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>1</show_in_store> + <resource>Mage_Rss::rss</resource> <groups> <config translate="label"> <label>Rss Config</label> diff --git a/app/code/core/Mage/Sales/Block/Adminhtml/Billing/Agreement/View.php b/app/code/core/Mage/Sales/Block/Adminhtml/Billing/Agreement/View.php index 031be56fa90..f917fa9dc54 100644 --- a/app/code/core/Mage/Sales/Block/Adminhtml/Billing/Agreement/View.php +++ b/app/code/core/Mage/Sales/Block/Adminhtml/Billing/Agreement/View.php @@ -44,7 +44,7 @@ class Mage_Sales_Block_Adminhtml_Billing_Agreement_View extends Mage_Adminhtml_B parent::__construct(); - if (!$this->_isAllowed('sales/billing_agreement/actions/manage')) { + if (!$this->_isAllowed('Mage_Sales::actions_manage')) { $this->_removeButton('delete'); } $this->_removeButton('reset'); @@ -58,7 +58,7 @@ class Mage_Sales_Block_Adminhtml_Billing_Agreement_View extends Mage_Adminhtml_B ), -1); $agreement = $this->_getBillingAgreement(); - if ($agreement && $agreement->canCancel() && $this->_isAllowed('sales/billing_agreement/actions/manage')) { + if ($agreement && $agreement->canCancel() && $this->_isAllowed('Mage_Sales::actions_manage')) { $this->_addButton('cancel', array( 'label' => Mage::helper('Mage_Adminhtml_Helper_Data')->__('Cancel'), 'onclick' => "confirmSetLocation(" @@ -102,11 +102,11 @@ class Mage_Sales_Block_Adminhtml_Billing_Agreement_View extends Mage_Adminhtml_B /** * Check current user permissions for specified action * - * @param string $action + * @param string $resourceId * @return bool */ - protected function _isAllowed($action) + protected function _isAllowed($resourceId) { - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed($action); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed($resourceId); } } diff --git a/app/code/core/Mage/Sales/Block/Adminhtml/Recurring/Profile/View/Tab/Orders.php b/app/code/core/Mage/Sales/Block/Adminhtml/Recurring/Profile/View/Tab/Orders.php index 0e35970eac9..8b1846a991f 100644 --- a/app/code/core/Mage/Sales/Block/Adminhtml/Recurring/Profile/View/Tab/Orders.php +++ b/app/code/core/Mage/Sales/Block/Adminhtml/Recurring/Profile/View/Tab/Orders.php @@ -122,7 +122,7 @@ class Mage_Sales_Block_Adminhtml_Recurring_Profile_View_Tab_Orders 'options' => Mage::getSingleton('Mage_Sales_Model_Order_Config')->getStatuses(), )); - if (Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('sales/order/actions/view')) { + if (Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Sales::actions_view')) { $this->addColumn('action', array( 'header' => Mage::helper('Mage_Sales_Helper_Data')->__('Action'), diff --git a/app/code/core/Mage/Sales/Model/Observer.php b/app/code/core/Mage/Sales/Model/Observer.php index 3a2bbad51cd..0561b9b5845 100644 --- a/app/code/core/Mage/Sales/Model/Observer.php +++ b/app/code/core/Mage/Sales/Model/Observer.php @@ -269,7 +269,7 @@ class Mage_Sales_Model_Observer if (!($methodInstance instanceof Mage_Sales_Model_Payment_Method_Billing_AgreementAbstract)) { return; } - if (!Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('sales/order/actions/use')) { + if (!Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Sales::use')) { $observer->getEvent()->getResult()->isAvailable = false; } } diff --git a/app/code/core/Mage/Sales/etc/adminhtml.xml b/app/code/core/Mage/Sales/etc/adminhtml.xml deleted file mode 100644 index 7ddd80ecf20..00000000000 --- a/app/code/core/Mage/Sales/etc/adminhtml.xml +++ /dev/null @@ -1,139 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License (AFL 3.0) - * that is bundled with this package in the file LICENSE_AFL.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/afl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @category Mage - * @package Mage_Sales - * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - */ ---> -<config> - <acl> - <resources> - <admin> - <children> - <sales translate="title" module="Mage_Sales"> - <title>Sales</title> - <children> - <order translate="title"> - <title>Orders</title> - <children> - <actions translate="title"> - <title>Actions</title> - <children> - <create translate="title"><title>Create</title></create> - <view translate="title"><title>View</title></view> - <email translate="title"><title>Send Order Email</title></email> - <reorder translate="title"><title>Reorder</title></reorder> - <edit translate="title"><title>Edit</title></edit> - <cancel translate="title"><title>Cancel</title></cancel> - <review_payment translate="title"><title>Accept or Deny Payment</title></review_payment> - <capture translate="title"><title>Capture</title></capture> - <invoice translate="title"><title>Invoice</title></invoice> - <creditmemo translate="title"><title>Credit Memos</title></creditmemo> - <hold translate="title"><title>Hold</title></hold> - <unhold translate="title"><title>Unhold</title></unhold> - <ship translate="title"><title>Ship</title></ship> - <comment translate="title"><title>Comment</title></comment> - <reorder translate="title"><title>Reorder</title></reorder> - <emails translate="title"><title>Send Sales Emails</title></emails> - </children> - </actions> - </children> - <sort_order>10</sort_order> - </order> - <invoice translate="title"> - <title>Invoices</title> - <sort_order>20</sort_order> - </invoice> - <shipment translate="title"> - <title>Shipments</title> - <sort_order>30</sort_order> - </shipment> - <creditmemo translate="title"> - <title>Credit Memos</title> - <sort_order>40</sort_order> - </creditmemo> - <transactions translate="title"> - <title>Transactions</title> - <children> - <fetch translate="title"><title>Fetch</title></fetch> - </children> - <sort_order>50</sort_order> - </transactions> - <recurring_profile translate="title"> - <title>Recurring Profiles</title> - <sort_order>60</sort_order> - </recurring_profile> - <billing_agreement translate="title"> - <title>Billing Agreements</title> - <children> - <actions translate="title"> - <title>Actions</title> - <children> - <view translate="title"> - <title>View</title> - <sort_order>5</sort_order> - </view> - <manage translate="title"> - <title>Manage</title> - <sort_order>10</sort_order> - </manage> - <use translate="title"> - <title>Place Order Using Billing Agreements</title> - <sort_order>15</sort_order> - </use> - </children> - </actions> - </children> - <sort_order>70</sort_order> - </billing_agreement> - </children> - </sales> - <system> - <children> - <order_statuses> - <title>Order Statuses</title> - <sort_order>15</sort_order> - </order_statuses> - <config> - <children> - <sales translate="title"> - <title>Sales Section</title> - <sort_order>60</sort_order> - </sales> - <sales_email translate="title"> - <title>Sales Emails Section</title> - <sort_order>65</sort_order> - </sales_email> - <sales_pdf translate="title"> - <title>PDF Print-outs</title> - <sort_order>66</sort_order> - </sales_pdf> - </children> - </config> - </children> - </system> - </children> - </admin> - </resources> - </acl> -</config> diff --git a/app/code/core/Mage/Sales/etc/adminhtml/acl.xml b/app/code/core/Mage/Sales/etc/adminhtml/acl.xml new file mode 100644 index 00000000000..8c15b6d337a --- /dev/null +++ b/app/code/core/Mage/Sales/etc/adminhtml/acl.xml @@ -0,0 +1,78 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Mage + * @package Mage_Sales + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config> + <acl> + <resources> + <resource id="Mage_Adminhtml::admin"> + <resource id="Mage_Sales::sales" module="Mage_Sales" title="Sales"> + <resource id="Mage_Sales::sales_order" title="Orders" sortOrder="10"> + <resource id="Mage_Sales::actions" title="Actions"> + <resource id="Mage_Sales::create" title="Create" /> + <resource id="Mage_Sales::actions_view" title="View" /> + <resource id="Mage_Sales::email" title="Send Order Email" /> + <resource id="Mage_Sales::reorder" title="Reorder" /> + <resource id="Mage_Sales::actions_edit" title="Edit" /> + <resource id="Mage_Sales::cancel" title="Cancel" /> + <resource id="Mage_Sales::review_payment" title="Accept or Deny Payment" /> + <resource id="Mage_Sales::capture" title="Capture" /> + <resource id="Mage_Sales::invoice" title="Invoice" /> + <resource id="Mage_Sales::creditmemo" title="Credit Memos" /> + <resource id="Mage_Sales::hold" title="Hold" /> + <resource id="Mage_Sales::unhold" title="Unhold" /> + <resource id="Mage_Sales::ship" title="Ship" /> + <resource id="Mage_Sales::comment" title="Comment" /> + <resource id="Mage_Sales::emails" title="Send Sales Emails" /> + </resource> + </resource> + <resource id="Mage_Sales::sales_invoice" title="Invoices" sortOrder="20" /> + <resource id="Mage_Sales::shipment" title="Shipments" sortOrder="30" /> + <resource id="Mage_Sales::sales_creditmemo" title="Credit Memos" sortOrder="40" /> + <resource id="Mage_Sales::transactions" title="Transactions" sortOrder="50"> + <resource id="Mage_Sales::transactions_fetch" title="Fetch" /> + </resource> + <resource id="Mage_Sales::recurring_profile" title="Recurring Profiles" sortOrder="60" /> + <resource id="Mage_Sales::billing_agreement" title="Billing Agreements" sortOrder="70"> + <resource id="Mage_Sales::billing_agreement_actions" title="Actions"> + <resource id="Mage_Sales::billing_agreement_actions_view" title="View" sortOrder="5" /> + <resource id="Mage_Sales::actions_manage" title="Manage" sortOrder="10" /> + <resource id="Mage_Sales::use" title="Place Order Using Billing Agreements" sortOrder="15" /> + </resource> + </resource> + </resource> + <resource id="Mage_Adminhtml::system"> + <resource id="Mage_Sales::order_statuses" title="Order Statuses" sortOrder="15" /> + <resource id="Mage_Adminhtml::config"> + <resource id="Mage_Sales::config_sales" title="Sales Section" sortOrder="60" /> + <resource id="Mage_Sales::sales_email" title="Sales Emails Section" sortOrder="65" /> + <resource id="Mage_Sales::sales_pdf" title="PDF Print-outs" sortOrder="66" /> + </resource> + </resource> + </resource> + </resources> + </acl> +</config> diff --git a/app/code/core/Mage/Sales/etc/adminhtml/menu.xml b/app/code/core/Mage/Sales/etc/adminhtml/menu.xml index c7ff48acc42..3840ff8c9c7 100644 --- a/app/code/core/Mage/Sales/etc/adminhtml/menu.xml +++ b/app/code/core/Mage/Sales/etc/adminhtml/menu.xml @@ -27,14 +27,14 @@ --> <config> <menu> - <add id="Mage_Sales::sales" title="Sales" module="Mage_Sales" sortOrder="20" dependsOnModule="Mage_Sales" /> - <add id="Mage_Sales::sales_order" title="Orders" module="Mage_Sales" sortOrder="10" parent="Mage_Sales::sales" action="adminhtml/sales_order" /> - <add id="Mage_Sales::sales_invoice" title="Invoices" module="Mage_Sales" sortOrder="20" parent="Mage_Sales::sales" action="adminhtml/sales_invoice" /> - <add id="Mage_Sales::sales_shipment" title="Shipments" module="Mage_Sales" sortOrder="30" parent="Mage_Sales::sales" action="adminhtml/sales_shipment" /> - <add id="Mage_Sales::sales_creditmemo" title="Credit Memos" module="Mage_Sales" sortOrder="40" parent="Mage_Sales::sales" action="adminhtml/sales_creditmemo" /> - <add id="Mage_Sales::sales_transactions" title="Transactions" module="Mage_Sales" sortOrder="50" parent="Mage_Sales::sales" action="adminhtml/sales_transactions" /> - <add id="Mage_Sales::sales_recurring_profile" title="Recurring Profiles (beta)" module="Mage_Sales" sortOrder="60" parent="Mage_Sales::sales" action="adminhtml/sales_recurring_profile" /> - <add id="Mage_Sales::sales_billing_agreement" title="Billing Agreements" module="Mage_Sales" sortOrder="70" parent="Mage_Sales::sales" action="adminhtml/sales_billing_agreement" /> - <add id="Mage_Sales::system_order_statuses" title="Order Statuses" module="Mage_Sales" sortOrder="105" parent="Mage_Adminhtml::system" action="adminhtml/sales_order_status" /> + <add id="Mage_Sales::sales" title="Sales" module="Mage_Sales" sortOrder="20" dependsOnModule="Mage_Sales" resource="Mage_Sales::sales"/> + <add id="Mage_Sales::sales_order" title="Orders" module="Mage_Sales" sortOrder="10" parent="Mage_Sales::sales" action="adminhtml/sales_order" resource="Mage_Sales::sales_order"/> + <add id="Mage_Sales::sales_invoice" title="Invoices" module="Mage_Sales" sortOrder="20" parent="Mage_Sales::sales" action="adminhtml/sales_invoice" resource="Mage_Sales::sales_invoice"/> + <add id="Mage_Sales::sales_shipment" title="Shipments" module="Mage_Sales" sortOrder="30" parent="Mage_Sales::sales" action="adminhtml/sales_shipment" resource="Mage_Sales::shipment"/> + <add id="Mage_Sales::sales_creditmemo" title="Credit Memos" module="Mage_Sales" sortOrder="40" parent="Mage_Sales::sales" action="adminhtml/sales_creditmemo" resource="Mage_Sales::sales_creditmemo"/> + <add id="Mage_Sales::sales_transactions" title="Transactions" module="Mage_Sales" sortOrder="50" parent="Mage_Sales::sales" action="adminhtml/sales_transactions" resource="Mage_Sales::transactions"/> + <add id="Mage_Sales::sales_recurring_profile" title="Recurring Profiles (beta)" module="Mage_Sales" sortOrder="60" parent="Mage_Sales::sales" action="adminhtml/sales_recurring_profile" resource="Mage_Sales::recurring_profile"/> + <add id="Mage_Sales::sales_billing_agreement" title="Billing Agreements" module="Mage_Sales" sortOrder="70" parent="Mage_Sales::sales" action="adminhtml/sales_billing_agreement" resource="Mage_Sales::billing_agreement"/> + <add id="Mage_Sales::system_order_statuses" title="Order Statuses" module="Mage_Sales" sortOrder="105" parent="Mage_Adminhtml::system" action="adminhtml/sales_order_status" resource="Mage_Sales::order_statuses"/> </menu> </config> diff --git a/app/code/core/Mage/Sales/etc/system.xml b/app/code/core/Mage/Sales/etc/system.xml index 627b285dc15..7a34c558e5a 100644 --- a/app/code/core/Mage/Sales/etc/system.xml +++ b/app/code/core/Mage/Sales/etc/system.xml @@ -42,6 +42,7 @@ <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>1</show_in_store> + <resource>Mage_Sales::config_sales</resource> <groups> <general translate="label"> <label>General</label> @@ -272,6 +273,7 @@ <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>1</show_in_store> + <resource>Mage_Sales::sales_email</resource> <groups> <order translate="label"> <label>Order</label> @@ -799,6 +801,7 @@ <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>1</show_in_store> + <resource>Mage_Sales::sales_pdf</resource> <groups> <invoice translate="label"> <label>Invoice</label> diff --git a/app/code/core/Mage/SalesRule/etc/adminhtml/acl.xml b/app/code/core/Mage/SalesRule/etc/adminhtml/acl.xml new file mode 100644 index 00000000000..efddacf6d2e --- /dev/null +++ b/app/code/core/Mage/SalesRule/etc/adminhtml/acl.xml @@ -0,0 +1,43 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Mage + * @package Mage_SalesRule + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config> + <acl> + <resources> + <resource id="Mage_Adminhtml::admin"> + <resource id="Mage_CatalogRule::promo"> + <resource id="Mage_SalesRule::quote" module="Mage_SalesRule" title="Shopping Cart Price Rules" /> + </resource> + <resource id="Mage_Adminhtml::system"> + <resource id="Mage_Adminhtml::config"> + <resource id="Mage_SalesRule::config_promo" module="Mage_SalesRule" title="Shopping Cart Price Rules" /> + </resource> + </resource> + </resource> + </resources> + </acl> +</config> diff --git a/app/code/core/Mage/SalesRule/etc/adminhtml/menu.xml b/app/code/core/Mage/SalesRule/etc/adminhtml/menu.xml index ad3e13f20b3..f1111248fa9 100644 --- a/app/code/core/Mage/SalesRule/etc/adminhtml/menu.xml +++ b/app/code/core/Mage/SalesRule/etc/adminhtml/menu.xml @@ -27,6 +27,6 @@ --> <config> <menu> - <add id="Mage_SalesRule::promo_quote" title="Shopping Cart Price Rules" module="Mage_SalesRule" parent="Mage_CatalogRule::promo" action="adminhtml/promo_quote/" dependsOnModule="Mage_Sales" /> + <add id="Mage_SalesRule::promo_quote" title="Shopping Cart Price Rules" module="Mage_SalesRule" parent="Mage_CatalogRule::promo" action="adminhtml/promo_quote/" dependsOnModule="Mage_Sales" resource="Mage_SalesRule::quote"/> </menu> </config> diff --git a/app/code/core/Mage/Sendfriend/etc/system.xml b/app/code/core/Mage/Sendfriend/etc/system.xml index 106c95a4f95..b1ebd0e928b 100644 --- a/app/code/core/Mage/Sendfriend/etc/system.xml +++ b/app/code/core/Mage/Sendfriend/etc/system.xml @@ -35,6 +35,7 @@ <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>1</show_in_store> + <resource>Mage_Adminhtml::sendfriend</resource> <groups> <email translate="label"> <label>Email Templates</label> diff --git a/app/code/core/Mage/Shipping/etc/adminhtml.xml b/app/code/core/Mage/Shipping/etc/adminhtml.xml deleted file mode 100644 index 986961e6b33..00000000000 --- a/app/code/core/Mage/Shipping/etc/adminhtml.xml +++ /dev/null @@ -1,53 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License (AFL 3.0) - * that is bundled with this package in the file LICENSE_AFL.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/afl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @category Mage - * @package Mage_Shipping - * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - */ ---> -<config> - <acl> - <resources> - <admin> - <children> - <system> - <children> - <config> - <children> - <shipping translate="title" module="Mage_Shipping"> - <title>Shipping Settings Section</title> - <sort_order>0</sort_order> - </shipping> - <carriers translate="title" module="Mage_Shipping"> - <title>Shipping Methods Section</title> - <sort_order>0</sort_order> - </carriers> - </children> - </config> - </children> - </system> - </children> - </admin> - </resources> - </acl> -</config> diff --git a/app/code/core/Mage/Shipping/etc/adminhtml/acl.xml b/app/code/core/Mage/Shipping/etc/adminhtml/acl.xml new file mode 100644 index 00000000000..b6f564d5e32 --- /dev/null +++ b/app/code/core/Mage/Shipping/etc/adminhtml/acl.xml @@ -0,0 +1,41 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Mage + * @package Mage_Shipping + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config> + <acl> + <resources> + <resource id="Mage_Adminhtml::admin"> + <resource id="Mage_Adminhtml::system"> + <resource id="Mage_Adminhtml::config"> + <resource id="Mage_Shipping::config_shipping" module="Mage_Shipping" title="Shipping Settings Section" sortOrder="0" /> + <resource id="Mage_Shipping::carriers" module="Mage_Shipping" title="Shipping Methods Section" sortOrder="0" /> + </resource> + </resource> + </resource> + </resources> + </acl> +</config> diff --git a/app/code/core/Mage/Shipping/etc/system.xml b/app/code/core/Mage/Shipping/etc/system.xml index dd2d39f2d84..6540deee6e0 100644 --- a/app/code/core/Mage/Shipping/etc/system.xml +++ b/app/code/core/Mage/Shipping/etc/system.xml @@ -35,6 +35,7 @@ <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>0</show_in_store> + <resource>Mage_Shipping::config_shipping</resource> <groups> <option translate="label"> <label>Options</label> @@ -134,6 +135,7 @@ <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>1</show_in_store> + <resource>Mage_Shipping::carriers</resource> <groups> <flatrate translate="label"> <label>Flat Rate</label> diff --git a/app/code/core/Mage/Sitemap/etc/adminhtml.xml b/app/code/core/Mage/Sitemap/etc/adminhtml.xml deleted file mode 100644 index f4343f8c42c..00000000000 --- a/app/code/core/Mage/Sitemap/etc/adminhtml.xml +++ /dev/null @@ -1,55 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License (AFL 3.0) - * that is bundled with this package in the file LICENSE_AFL.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/afl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @category Mage - * @package Mage_Sitemap - * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - */ ---> -<config> - <acl> - <resources> - <admin> - <children> - <catalog> - <children> - <sitemap translate="title" module="Mage_Sitemap"> - <title>Google Sitemap</title> - </sitemap> - </children> - </catalog> - <system> - <children> - <config> - <children> - <sitemap translate="title" module="Mage_Shipping"> - <title>Google Sitemap Section</title> - </sitemap> - </children> - </config> - </children> - </system> - </children> - </admin> - </resources> - </acl> -</config> diff --git a/app/code/core/Mage/Sitemap/etc/adminhtml/acl.xml b/app/code/core/Mage/Sitemap/etc/adminhtml/acl.xml new file mode 100644 index 00000000000..ef9171252f0 --- /dev/null +++ b/app/code/core/Mage/Sitemap/etc/adminhtml/acl.xml @@ -0,0 +1,43 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Mage + * @package Mage_Sitemap + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config> + <acl> + <resources> + <resource id="Mage_Adminhtml::admin"> + <resource id="Mage_Catalog::catalog"> + <resource id="Mage_Sitemap::sitemap" module="Mage_Sitemap" title="Google Sitemap" /> + </resource> + <resource id="Mage_Adminhtml::system"> + <resource id="Mage_Adminhtml::config"> + <resource id="Mage_Sitemap::config_sitemap" module="Mage_Shipping" title="Google Sitemap Section" /> + </resource> + </resource> + </resource> + </resources> + </acl> +</config> diff --git a/app/code/core/Mage/Sitemap/etc/adminhtml/menu.xml b/app/code/core/Mage/Sitemap/etc/adminhtml/menu.xml index dbd771f5008..41185891068 100644 --- a/app/code/core/Mage/Sitemap/etc/adminhtml/menu.xml +++ b/app/code/core/Mage/Sitemap/etc/adminhtml/menu.xml @@ -27,6 +27,6 @@ --> <config> <menu> - <add id="Mage_Sitemap::catalog_sitemap" title="Google Sitemap" module="Mage_Sitemap" sortOrder="180" parent="Mage_Catalog::catalog" action="adminhtml/sitemap/" /> + <add id="Mage_Sitemap::catalog_sitemap" title="Google Sitemap" module="Mage_Sitemap" sortOrder="180" parent="Mage_Catalog::catalog" action="adminhtml/sitemap/" resource="Mage_Sitemap::sitemap"/> </menu> </config> diff --git a/app/code/core/Mage/Sitemap/etc/system.xml b/app/code/core/Mage/Sitemap/etc/system.xml index fbc73c9c3dc..e5ea8aeb646 100644 --- a/app/code/core/Mage/Sitemap/etc/system.xml +++ b/app/code/core/Mage/Sitemap/etc/system.xml @@ -35,6 +35,7 @@ <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>1</show_in_store> + <resource>Mage_Sitemap::config_sitemap</resource> <groups> <category translate="label"> <label>Categories Options</label> diff --git a/app/code/core/Mage/Tag/etc/adminhtml.xml b/app/code/core/Mage/Tag/etc/adminhtml.xml deleted file mode 100644 index ac52acafd85..00000000000 --- a/app/code/core/Mage/Tag/etc/adminhtml.xml +++ /dev/null @@ -1,52 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License (AFL 3.0) - * that is bundled with this package in the file LICENSE_AFL.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/afl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @category Mage - * @package Mage_Tag - * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - */ ---> -<config> - <acl> - <resources> - <admin> - <children> - <catalog> - <children> - <tag translate="title" module="Mage_Tag"> - <title>Tags</title> - <children> - <all translate="title"> - <title>All Tags</title> - </all> - <pending translate="title"> - <title>Pending Tags</title> - </pending> - </children> - </tag> - </children> - </catalog> - </children> - </admin> - </resources> - </acl> -</config> diff --git a/app/code/core/Mage/Tag/etc/adminhtml/acl.xml b/app/code/core/Mage/Tag/etc/adminhtml/acl.xml new file mode 100644 index 00000000000..e8cd8105356 --- /dev/null +++ b/app/code/core/Mage/Tag/etc/adminhtml/acl.xml @@ -0,0 +1,41 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Mage + * @package Mage_Tag + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config> + <acl> + <resources> + <resource id="Mage_Adminhtml::admin"> + <resource id="Mage_Catalog::catalog"> + <resource id="Mage_Tag::tag" module="Mage_Tag" title="Tags"> + <resource id="Mage_Tag::tag_all" title="All Tags" /> + <resource id="Mage_Tag::tag_pending" title="Pending Tags" /> + </resource> + </resource> + </resource> + </resources> + </acl> +</config> diff --git a/app/code/core/Mage/Tag/etc/adminhtml/menu.xml b/app/code/core/Mage/Tag/etc/adminhtml/menu.xml index 540c436caa6..923536a5d12 100644 --- a/app/code/core/Mage/Tag/etc/adminhtml/menu.xml +++ b/app/code/core/Mage/Tag/etc/adminhtml/menu.xml @@ -27,12 +27,12 @@ --> <config> <menu> - <add id="Mage_Tag::catalog_tag" title="Tags" module="Mage_Tag" sortOrder="60" parent="Mage_Catalog::catalog" /> - <add id="Mage_Tag::catalog_tag_all" title="All Tags" module="Mage_Tag" parent="Mage_Tag::catalog_tag" action="adminhtml/tag/index" /> - <add id="Mage_Tag::catalog_tag_pending" title="Pending Tags" module="Mage_Tag" parent="Mage_Tag::catalog_tag" action="adminhtml/tag/pending" /> - <add id="Mage_Tag::report_tags" title="Tags" module="Mage_Tag" sortOrder="50" parent="Mage_Reports::report" /> - <add id="Mage_Tag::report_tags_customer" title="Customers" module="Mage_Tag" parent="Mage_Tag::report_tags" action="adminhtml/report_tag/customer" /> - <add id="Mage_Tag::report_tags_product" title="Products" module="Mage_Tag" parent="Mage_Tag::report_tags" action="adminhtml/report_tag/product" /> - <add id="Mage_Tag::report_tags_popular" title="Popular" module="Mage_Tag" parent="Mage_Tag::report_tags" action="adminhtml/report_tag/popular" /> + <add id="Mage_Tag::catalog_tag" title="Tags" module="Mage_Tag" sortOrder="60" parent="Mage_Catalog::catalog" resource="Mage_Tag::tag"/> + <add id="Mage_Tag::catalog_tag_all" title="All Tags" module="Mage_Tag" parent="Mage_Tag::catalog_tag" action="adminhtml/tag/index" resource="Mage_Tag::tag_all"/> + <add id="Mage_Tag::catalog_tag_pending" title="Pending Tags" module="Mage_Tag" parent="Mage_Tag::catalog_tag" action="adminhtml/tag/pending" resource="Mage_Tag::tag_pending"/> + <add id="Mage_Tag::report_tags" title="Tags" module="Mage_Tag" sortOrder="50" parent="Mage_Reports::report" resource="Mage_Reports::tags"/> + <add id="Mage_Tag::report_tags_customer" title="Customers" module="Mage_Tag" parent="Mage_Tag::report_tags" action="adminhtml/report_tag/customer" resource="Mage_Reports::tags_customer"/> + <add id="Mage_Tag::report_tags_product" title="Products" module="Mage_Tag" parent="Mage_Tag::report_tags" action="adminhtml/report_tag/product" resource="Mage_Reports::tags_product"/> + <add id="Mage_Tag::report_tags_popular" title="Popular" module="Mage_Tag" parent="Mage_Tag::report_tags" action="adminhtml/report_tag/popular" resource="Mage_Reports::popular"/> </menu> </config> diff --git a/app/code/core/Mage/Tax/etc/adminhtml.xml b/app/code/core/Mage/Tax/etc/adminhtml.xml deleted file mode 100644 index c3403379e68..00000000000 --- a/app/code/core/Mage/Tax/etc/adminhtml.xml +++ /dev/null @@ -1,79 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License (AFL 3.0) - * that is bundled with this package in the file LICENSE_AFL.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/afl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @category Mage - * @package Mage_Tax - * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - */ ---> -<config> - <acl> - <resources> - <admin> - <children> - <sales> - <children> - <tax translate="title" module="Mage_Tax"> - <title>Tax</title> - <sort_order>500</sort_order> - <children> - <classes_customer translate="title"> - <title>Customer Tax Classes</title> - <sort_order>0</sort_order> - </classes_customer> - <classes_product translate="title"> - <title>Product Tax Classes</title> - <sort_order>10</sort_order> - </classes_product> - <import_export translate="title"> - <title>Import / Export Tax Rates</title> - <sort_order>20</sort_order> - </import_export> - <rates translate="title"> - <title>Manage Tax Zones & Rates</title> - <sort_order>30</sort_order> - </rates> - <rules translate="title"> - <title>Manage Tax Rules</title> - <sort_order>40</sort_order> - </rules> - </children> - </tax> - </children> - </sales> - <system> - <children> - <config> - <children> - <tax translate="title"> - <title>Tax Section</title> - <sort_order>55</sort_order> - </tax> - </children> - </config> - </children> - </system> - </children> - </admin> - </resources> - </acl> -</config> diff --git a/app/code/core/Mage/Tax/etc/adminhtml/acl.xml b/app/code/core/Mage/Tax/etc/adminhtml/acl.xml new file mode 100644 index 00000000000..20ead3d37a6 --- /dev/null +++ b/app/code/core/Mage/Tax/etc/adminhtml/acl.xml @@ -0,0 +1,49 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Mage + * @package Mage_Tax + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config> + <acl> + <resources> + <resource id="Mage_Adminhtml::admin"> + <resource id="Mage_Sales::sales"> + <resource id="Mage_Tax::sales_tax" module="Mage_Tax" title="Tax" sortOrder="500"> + <resource id="Mage_Tax::classes_customer" title="Customer Tax Classes" sortOrder="0" /> + <resource id="Mage_Tax::classes_product" title="Product Tax Classes" sortOrder="10" /> + <resource id="Mage_Tax::import_export" title="Import / Export Tax Rates" sortOrder="20" /> + <resource id="Mage_Tax::tax_rates" title="Manage Tax Zones & Rates" sortOrder="30" /> + <resource id="Mage_Tax::rules" title="Manage Tax Rules" sortOrder="40" /> + </resource> + </resource> + <resource id="Mage_Adminhtml::system"> + <resource id="Mage_Adminhtml::config"> + <resource id="Mage_Tax::config_tax" title="Tax Section" sortOrder="55" /> + </resource> + </resource> + </resource> + </resources> + </acl> +</config> diff --git a/app/code/core/Mage/Tax/etc/adminhtml/menu.xml b/app/code/core/Mage/Tax/etc/adminhtml/menu.xml index 45c01318879..897ae6a4dab 100644 --- a/app/code/core/Mage/Tax/etc/adminhtml/menu.xml +++ b/app/code/core/Mage/Tax/etc/adminhtml/menu.xml @@ -27,11 +27,11 @@ --> <config> <menu> - <add id="Mage_Tax::sales_tax" title="Tax" module="Mage_Tax" sortOrder="500" parent="Mage_Sales::sales" /> - <add id="Mage_Tax::sales_tax_rules" title="Manage Tax Rules" module="Mage_Tax" parent="Mage_Tax::sales_tax" action="adminhtml/tax_rule" /> - <add id="Mage_Tax::sales_tax_rates" title="Manage Tax Zones & Rates" module="Mage_Tax" parent="Mage_Tax::sales_tax" action="adminhtml/tax_rate" /> - <add id="Mage_Tax::sales_tax_import_export" title="Import / Export Tax Rates" module="Mage_Tax" parent="Mage_Tax::sales_tax" action="adminhtml/tax_rate/importExport" /> - <add id="Mage_Tax::sales_tax_classes_customer" title="Customer Tax Classes" module="Mage_Tax" parent="Mage_Tax::sales_tax" action="adminhtml/tax_class_customer" /> - <add id="Mage_Tax::sales_tax_classes_product" title="Product Tax Classes" module="Mage_Tax" parent="Mage_Tax::sales_tax" action="adminhtml/tax_class_product" /> + <add id="Mage_Tax::sales_tax" title="Tax" module="Mage_Tax" sortOrder="500" parent="Mage_Sales::sales" resource="Mage_Tax::sales_tax"/> + <add id="Mage_Tax::sales_tax_rules" title="Manage Tax Rules" module="Mage_Tax" parent="Mage_Tax::sales_tax" action="adminhtml/tax_rule" resource="Mage_Tax::rules"/> + <add id="Mage_Tax::sales_tax_rates" title="Manage Tax Zones & Rates" module="Mage_Tax" parent="Mage_Tax::sales_tax" action="adminhtml/tax_rate" resource="Mage_Tax::tax_rates"/> + <add id="Mage_Tax::sales_tax_import_export" title="Import / Export Tax Rates" module="Mage_Tax" parent="Mage_Tax::sales_tax" action="adminhtml/tax_rate/importExport" resource="Mage_Tax::import_export"/> + <add id="Mage_Tax::sales_tax_classes_customer" title="Customer Tax Classes" module="Mage_Tax" parent="Mage_Tax::sales_tax" action="adminhtml/tax_class_customer" resource="Mage_Tax::classes_customer"/> + <add id="Mage_Tax::sales_tax_classes_product" title="Product Tax Classes" module="Mage_Tax" parent="Mage_Tax::sales_tax" action="adminhtml/tax_class_product" resource="Mage_Tax::classes_product"/> </menu> </config> diff --git a/app/code/core/Mage/Tax/etc/system.xml b/app/code/core/Mage/Tax/etc/system.xml index d32370cfbbb..33e0ec5e08f 100644 --- a/app/code/core/Mage/Tax/etc/system.xml +++ b/app/code/core/Mage/Tax/etc/system.xml @@ -35,6 +35,7 @@ <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>1</show_in_store> + <resource>Mage_Tax::config_tax</resource> <groups> <classes translate="label"> <label>Tax Classes</label> diff --git a/app/code/core/Mage/User/Block/Role/Tab/Edit.php b/app/code/core/Mage/User/Block/Role/Tab/Edit.php index 5ef8a6e9b3d..fd0ec4af82a 100644 --- a/app/code/core/Mage/User/Block/Role/Tab/Edit.php +++ b/app/code/core/Mage/User/Block/Role/Tab/Edit.php @@ -84,21 +84,20 @@ class Mage_User_Block_Role_Tab_Edit extends Mage_Backend_Block_Widget_Form $rid = Mage::app()->getRequest()->getParam('rid', false); - $resources = Mage::getModel('Mage_Admin_Model_Config')->getAclResourceList(); - + /** @var $acl Magento_Acl */ + $acl = Mage::getModel('Mage_Backend_Model_Auth_Session')->getAcl(); $rulesSet = Mage::getResourceModel('Mage_User_Model_Resource_Rules_Collection')->getByRoles($rid)->load(); - $selrids = array(); + $selectedResourceIds = array(); foreach ($rulesSet->getItems() as $item) { $itemResourceId = $item->getResource_id(); - if (array_key_exists(strtolower($itemResourceId), $resources) && $item->getPermission() == 'allow') { - $resources[$itemResourceId]['checked'] = true; - array_push($selrids, $itemResourceId); + if ($acl->has($itemResourceId) && $item->getPermission() == 'allow') { + array_push($selectedResourceIds, $itemResourceId); } } - $this->setSelectedResources($selrids); + $this->setSelectedResources($selectedResourceIds); $this->setTemplate('role/edit.phtml'); } @@ -110,7 +109,7 @@ class Mage_User_Block_Role_Tab_Edit extends Mage_Backend_Block_Widget_Form */ public function isEverythingAllowed() { - return in_array('all', $this->getSelectedResources()); + return in_array(Mage_Backend_Model_Acl_Config::ACL_RESOURCE_ALL, $this->getSelectedResources()); } /** @@ -120,9 +119,10 @@ class Mage_User_Block_Role_Tab_Edit extends Mage_Backend_Block_Widget_Form */ public function getResTreeJson() { - $resources = Mage::getSingleton('Mage_Admin_Model_Config')->getAclResourceTree(); + /** @var $resources DOMNodeList */ + $resources = Mage::getSingleton('Mage_Backend_Model_Acl_Config')->getAclResources(); - $rootArray = $this->_getNodeJson($resources->admin, 1); + $rootArray = $this->_getNodeJson($resources->item(1), 1); $json = Mage::helper('Mage_Core_Helper_Data')->jsonEncode( isset($rootArray['children']) ? $rootArray['children'] : array() @@ -140,7 +140,7 @@ class Mage_User_Block_Role_Tab_Edit extends Mage_Backend_Block_Widget_Form */ protected function _sortTree($nodeA, $nodeB) { - return $nodeA['sort_order']<$nodeB['sort_order'] ? -1 : ($nodeA['sort_order']>$nodeB['sort_order'] ? 1 : 0); + return $nodeA['sortOrder']<$nodeB['sortOrder'] ? -1 : ($nodeA['sortOrder']>$nodeB['sortOrder'] ? 1 : 0); } /** @@ -150,29 +150,28 @@ class Mage_User_Block_Role_Tab_Edit extends Mage_Backend_Block_Widget_Form * @param int $level * @return array */ - protected function _getNodeJson($node, $level = 0) + protected function _getNodeJson(DomElement $node, $level = 0) { $item = array(); $selres = $this->getSelectedResources(); - if ($level != 0) { - $item['text'] = Mage::helper('Mage_User_Helper_Data')->__((string)$node->title); + $item['text'] = Mage::helper('Mage_User_Helper_Data')->__((string)$node->getAttribute('title')); // @codingStandardsIgnoreStart - $item['sort_order'] = isset($node->sort_order) ? (string)$node->sort_order : 0; + $item['sortOrder'] = $node->hasAttribute('sortOrder') ? (string)$node->getAttribute('sortOrder') : 0; // @codingStandardsIgnoreEnd - $item['id'] = (string)$node->attributes()->aclpath; + $item['id'] = (string)$node->getAttribute('id'); if (in_array($item['id'], $selres)) { $item['checked'] = true; } } - $children = $this->_getNodeChildren($node); + $children = $node->childNodes; if (!empty($children)) { $item['children'] = array(); //$item['cls'] = 'fiche-node'; foreach ($children as $child) { - if (!in_array($child->getName(), array('title', 'sort_order'))) { - if (!(string)$child->title) { + if ($child instanceof DOMElement) { + if (!(string)$child->getAttribute('title')) { continue; } if ($level != 0) { @@ -186,19 +185,4 @@ class Mage_User_Block_Role_Tab_Edit extends Mage_Backend_Block_Widget_Form } return $item; } - - /** - * Retrieve children of a node - * - * @param Varien_Simplexml_Element $node - * @return Varien_Simplexml_Element - */ - protected function _getNodeChildren(Varien_Simplexml_Element $node) - { - if (isset($node->children)) { - return $node->children->children(); - } else { - return $node->children(); - } - } } diff --git a/app/code/core/Mage/User/Model/Acl/Loader/Role.php b/app/code/core/Mage/User/Model/Acl/Loader/Role.php new file mode 100644 index 00000000000..79810abb093 --- /dev/null +++ b/app/code/core/Mage/User/Model/Acl/Loader/Role.php @@ -0,0 +1,84 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Mage + * @package Mage_User + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +class Mage_User_Model_Acl_Loader_Role implements Magento_Acl_Loader +{ + /** + * @var Mage_Core_Model_Resource + */ + protected $_resource; + + public function __construct(array $data = array()) + { + $this->_resource = isset($data['resource']) + ? $data['resource'] + : Mage::getSingleton('Mage_Core_Model_Resource'); + + $this->_objectFactory = isset($data['objectFactory']) + ? $data['objectFactory'] + : Mage::getConfig(); + } + + /** + * Populate ACL with roles from external storage + * + * @param Magento_Acl $acl + */ + public function populateAcl(Magento_Acl $acl) + { + $roleTableName = $this->_resource->getTableName('admin_role'); + $adapter = $this->_resource->getConnection('read'); + + $select = $adapter->select() + ->from($roleTableName) + ->order('tree_level'); + + foreach ($adapter->fetchAll($select) as $role) { + $parent = ($role['parent_id'] > 0) ? Mage_User_Model_Acl_Role_Group::ROLE_TYPE . $role['parent_id'] : null; + switch ($role['role_type']) { + case Mage_User_Model_Acl_Role_Group::ROLE_TYPE: + $roleId = $role['role_type'] . $role['role_id']; + $acl->addRole( + $this->_objectFactory->getModelInstance('Mage_User_Model_Acl_Role_Group', $roleId), + $parent + ); + break; + + case Mage_User_Model_Acl_Role_User::ROLE_TYPE: + $roleId = $role['role_type'] . $role['user_id']; + if (!$acl->hasRole($roleId)) { + $acl->addRole( + $this->_objectFactory->getModelInstance('Mage_User_Model_Acl_Role_User', $roleId), + $parent + ); + } else { + $acl->addRoleParent($roleId, $parent); + } + break; + } + } + } +} diff --git a/app/code/core/Mage/User/Model/Acl/Loader/Rule.php b/app/code/core/Mage/User/Model/Acl/Loader/Rule.php new file mode 100644 index 00000000000..41369f17433 --- /dev/null +++ b/app/code/core/Mage/User/Model/Acl/Loader/Rule.php @@ -0,0 +1,72 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Mage + * @package Mage_User + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +class Mage_User_Model_Acl_Loader_Rule implements Magento_Acl_Loader +{ + /** + * @var Mage_Core_Model_Resource + */ + protected $_resource; + + public function __construct(array $data = array()) + { + $this->_resource = isset($data['resource']) + ? $data['resource'] + : Mage::getSingleton('Mage_Core_Model_Resource'); + } + + /** + * Populate ACL with rules from external storage + * + * @param Magento_Acl $acl + */ + public function populateAcl(Magento_Acl $acl) + { + $ruleTable = $this->_resource->getTableName("admin_rule"); + + $adapter = $this->_resource->getConnection('read'); + + $select = $adapter->select() + ->from(array('r' => $ruleTable)); + + $rulesArr = $adapter->fetchAll($select); + + foreach ($rulesArr as $rule) { + $role = $rule['role_type'] . $rule['role_id']; + $resource = $rule['resource_id']; + $privileges = !empty($rule['privileges']) ? explode(',', $rule['privileges']) : null; + + if ( $rule['permission'] == 'allow') { + if ($resource === Mage_Backend_Model_Acl_Config::ACL_RESOURCE_ALL) { + $acl->allow($role, null, $privileges); + } + $acl->allow($role, $resource, $privileges); + } else if ( $rule['permission'] == 'deny' ) { + $acl->deny($role, $resource, $privileges); + } + } + } +} diff --git a/app/code/core/Mage/Admin/Model/Acl/Role/Generic.php b/app/code/core/Mage/User/Model/Acl/Role/Generic.php similarity index 82% rename from app/code/core/Mage/Admin/Model/Acl/Role/Generic.php rename to app/code/core/Mage/User/Model/Acl/Role/Generic.php index 232e528f4c6..0fb905eaa7b 100644 --- a/app/code/core/Mage/Admin/Model/Acl/Role/Generic.php +++ b/app/code/core/Mage/User/Model/Acl/Role/Generic.php @@ -19,7 +19,7 @@ * needs please refer to http://www.magentocommerce.com for more information. * * @category Mage - * @package Mage_Admin + * @package Mage_User * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ @@ -27,12 +27,8 @@ /** * User acl role - * - * @category Mage - * @package Mage_Admin - * @author Magento Core Team <core@magentocommerce.com> */ -class Mage_Admin_Model_Acl_Role_Generic extends Zend_Acl_Role +class Mage_User_Model_Acl_Role_Generic extends Zend_Acl_Role { } diff --git a/app/code/core/Mage/Admin/Model/Acl/Role/Group.php b/app/code/core/Mage/User/Model/Acl/Role/Group.php similarity index 81% rename from app/code/core/Mage/Admin/Model/Acl/Role/Group.php rename to app/code/core/Mage/User/Model/Acl/Role/Group.php index 4afcea59df5..bd4e7dce1e7 100644 --- a/app/code/core/Mage/Admin/Model/Acl/Role/Group.php +++ b/app/code/core/Mage/User/Model/Acl/Role/Group.php @@ -19,7 +19,7 @@ * needs please refer to http://www.magentocommerce.com for more information. * * @category Mage - * @package Mage_Admin + * @package Mage_User * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ @@ -27,12 +27,12 @@ /** * Acl Group model - * - * @category Mage - * @package Mage_Admin - * @author Magento Core Team <core@magentocommerce.com> */ -class Mage_Admin_Model_Acl_Role_Group extends Mage_Admin_Model_Acl_Role_Generic +class Mage_User_Model_Acl_Role_Group extends Mage_User_Model_Acl_Role_Generic { - + /** + * All the group roles are prepended by G + * + */ + const ROLE_TYPE = 'G'; } diff --git a/app/code/core/Mage/Admin/Model/Acl/Role/User.php b/app/code/core/Mage/User/Model/Acl/Role/User.php similarity index 81% rename from app/code/core/Mage/Admin/Model/Acl/Role/User.php rename to app/code/core/Mage/User/Model/Acl/Role/User.php index 728b20b199b..0c86884f7f6 100644 --- a/app/code/core/Mage/Admin/Model/Acl/Role/User.php +++ b/app/code/core/Mage/User/Model/Acl/Role/User.php @@ -19,7 +19,7 @@ * needs please refer to http://www.magentocommerce.com for more information. * * @category Mage - * @package Mage_Admin + * @package Mage_User * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ @@ -27,12 +27,12 @@ /** * User acl role - * - * @category Mage - * @package Mage_Admin - * @author Magento Core Team <core@magentocommerce.com> */ -class Mage_Admin_Model_Acl_Role_User extends Mage_Admin_Model_Acl_Role_Generic +class Mage_User_Model_Acl_Role_User extends Mage_User_Model_Acl_Role_Generic { - + /** + * All the user roles are prepended by U + * + */ + const ROLE_TYPE = 'U'; } diff --git a/app/code/core/Mage/User/Model/Resource/Rules.php b/app/code/core/Mage/User/Model/Resource/Rules.php index 9aca4478578..11b95c032fa 100755 --- a/app/code/core/Mage/User/Model/Resource/Rules.php +++ b/app/code/core/Mage/User/Model/Resource/Rules.php @@ -65,23 +65,23 @@ class Mage_User_Model_Resource_Rules extends Mage_Core_Model_Resource_Db_Abstrac if ($postedResources) { $row = array( 'role_type' => 'G', - 'resource_id' => 'all', + 'resource_id' => Mage_Backend_Model_Acl_Config::ACL_RESOURCE_ALL, 'privileges' => '', // not used yet - 'assert_id' => 0, 'role_id' => $roleId, 'permission' => 'allow' ); // If all was selected save it only and nothing else. - if ($postedResources === array('all')) { + if ($postedResources === array(Mage_Backend_Model_Acl_Config::ACL_RESOURCE_ALL)) { $insertData = $this->_prepareDataForTable(new Varien_Object($row), $this->getMainTable()); $adapter->insert($this->getMainTable(), $insertData); } else { - $res = Mage::getModel('Mage_Admin_Model_Config')->getAclResourceList(true); - foreach ($res as $resName) { - $row['permission'] = (in_array($resName, $postedResources) ? 'allow' : 'deny'); - $row['resource_id'] = trim($resName, '/'); + $acl = Mage::getModel('Mage_Backend_Model_Auth_Session')->getAcl(); + /** @var $resource Magento_Acl_Resource */ + foreach ($acl->getResources() as $resourceId) { + $row['permission'] = in_array($resourceId, $postedResources) ? 'allow' : 'deny'; + $row['resource_id'] = $resourceId; $insertData = $this->_prepareDataForTable(new Varien_Object($row), $this->getMainTable()); $adapter->insert($this->getMainTable(), $insertData); diff --git a/app/code/core/Mage/User/controllers/Adminhtml/User/RoleController.php b/app/code/core/Mage/User/controllers/Adminhtml/User/RoleController.php index 041f4651c61..f40f4e6c0d5 100644 --- a/app/code/core/Mage/User/controllers/Adminhtml/User/RoleController.php +++ b/app/code/core/Mage/User/controllers/Adminhtml/User/RoleController.php @@ -177,7 +177,7 @@ class Mage_User_Adminhtml_User_RoleController extends Mage_Backend_Controller_Ac $isAll = $this->getRequest()->getParam('all'); if ($isAll) { - $resource = array("all"); + $resource = array(Mage_Backend_Model_Acl_Config::ACL_RESOURCE_ALL); } $role = $this->_initRole('role_id'); @@ -286,6 +286,6 @@ class Mage_User_Adminhtml_User_RoleController extends Mage_Backend_Controller_Ac */ protected function _isAllowed() { - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('system/acl/roles'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_User::acl_roles'); } } diff --git a/app/code/core/Mage/User/controllers/Adminhtml/UserController.php b/app/code/core/Mage/User/controllers/Adminhtml/UserController.php index 8a219f7181f..1721d97ce04 100644 --- a/app/code/core/Mage/User/controllers/Adminhtml/UserController.php +++ b/app/code/core/Mage/User/controllers/Adminhtml/UserController.php @@ -214,7 +214,7 @@ class Mage_User_Adminhtml_UserController extends Mage_Backend_Controller_ActionA protected function _isAllowed() { - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('system/acl/users'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_User::acl_users'); } } diff --git a/app/code/core/Mage/User/data/user_setup/data-install-1.6.0.0.php b/app/code/core/Mage/User/data/user_setup/data-install-1.6.0.0.php index eb66287d664..08c5a9edbc8 100644 --- a/app/code/core/Mage/User/data/user_setup/data-install-1.6.0.0.php +++ b/app/code/core/Mage/User/data/user_setup/data-install-1.6.0.0.php @@ -39,9 +39,8 @@ $admGroupRole = Mage::getModel('Mage_User_Model_Role')->setData(array( Mage::getModel('Mage_User_Model_Rules')->setData(array( 'role_id' => $admGroupRole->getId(), - 'resource_id' => 'all', + 'resource_id' => 'Mage_Adminhtml::all', 'privileges' => null, - 'assert_id' => 0, 'role_type' => 'G', 'permission' => 'allow' )) diff --git a/app/code/core/Mage/User/etc/adminhtml.xml b/app/code/core/Mage/User/etc/adminhtml.xml deleted file mode 100644 index 2bd53767de4..00000000000 --- a/app/code/core/Mage/User/etc/adminhtml.xml +++ /dev/null @@ -1,55 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License (AFL 3.0) - * that is bundled with this package in the file LICENSE_AFL.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/afl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @category Mage - * @package Mage_User - * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - */ ---> -<config> - <acl> - <resources> - <admin> - <children> - <system> - <children> - <acl translate="title" module="Mage_User"> - <title>Permissions</title> - <sort_order>0</sort_order> - <children> - <roles translate="title"> - <title>Roles</title> - <sort_order>10</sort_order> - </roles> - <users translate="title"> - <title>Users</title> - <sort_order>20</sort_order> - </users> - </children> - </acl> - </children> - </system> - </children> - </admin> - </resources> - </acl> -</config> diff --git a/app/code/core/Mage/User/etc/adminhtml/acl.xml b/app/code/core/Mage/User/etc/adminhtml/acl.xml new file mode 100644 index 00000000000..baae0c4854f --- /dev/null +++ b/app/code/core/Mage/User/etc/adminhtml/acl.xml @@ -0,0 +1,41 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Mage + * @package Mage_User + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config> + <acl> + <resources> + <resource id="Mage_Adminhtml::admin"> + <resource id="Mage_Adminhtml::system"> + <resource id="Mage_User::acl" module="Mage_User" title="Permissions" sortOrder="0"> + <resource id="Mage_User::acl_roles" title="Roles" sortOrder="10" /> + <resource id="Mage_User::acl_users" title="Users" sortOrder="20" /> + </resource> + </resource> + </resource> + </resources> + </acl> +</config> diff --git a/app/code/core/Mage/User/etc/adminhtml/menu.xml b/app/code/core/Mage/User/etc/adminhtml/menu.xml index 51a2b19a44c..78b01e04e36 100644 --- a/app/code/core/Mage/User/etc/adminhtml/menu.xml +++ b/app/code/core/Mage/User/etc/adminhtml/menu.xml @@ -27,8 +27,8 @@ --> <config> <menu> - <add id="Mage_User::system_acl" title="Permissions" module="Mage_User" sortOrder="70" parent="Mage_Adminhtml::system" /> - <add id="Mage_User::system_acl_users" title="Users" module="Mage_User" parent="Mage_User::system_acl" action="adminhtml/user" /> - <add id="Mage_User::system_acl_roles" title="Roles" module="Mage_User" parent="Mage_User::system_acl" action="adminhtml/user_role" /> + <add id="Mage_User::system_acl" title="Permissions" module="Mage_User" sortOrder="70" parent="Mage_Adminhtml::system" resource="Mage_User::acl"/> + <add id="Mage_User::system_acl_users" title="Users" module="Mage_User" parent="Mage_User::system_acl" action="adminhtml/user" resource="Mage_User::acl_users"/> + <add id="Mage_User::system_acl_roles" title="Roles" module="Mage_User" parent="Mage_User::system_acl" action="adminhtml/user_role" resource="Mage_User::acl_roles"/> </menu> </config> diff --git a/app/code/core/Mage/User/etc/config.xml b/app/code/core/Mage/User/etc/config.xml index b34e84729f1..c63015a8916 100644 --- a/app/code/core/Mage/User/etc/config.xml +++ b/app/code/core/Mage/User/etc/config.xml @@ -28,12 +28,23 @@ <config> <modules> <Mage_User> - <version>1.6.1.0</version> + <version>1.6.1.1</version> <active>true</active> <codePool>core</codePool> </Mage_User> </modules> <global> + <areas> + <adminhtml> + <auth> + <credential_storage>Mage_User_Model_User</credential_storage> + </auth> + <acl> + <ruleLoader>Mage_User_Model_Acl_Loader_Rule</ruleLoader> + <roleLoader>Mage_User_Model_Acl_Loader_Role</roleLoader> + </acl> + </adminhtml> + </areas> <resources> <user_setup> <setup> @@ -50,11 +61,6 @@ </admin_emails_forgot_email_template> </email> </template> - <backend> - <auth> - <credential_storage>Mage_User_Model_User</credential_storage> - </auth> - </backend> </global> <default> <admin> diff --git a/app/code/core/Mage/User/sql/user_setup/upgrade-1.6.1.0-1.6.1.1.php b/app/code/core/Mage/User/sql/user_setup/upgrade-1.6.1.0-1.6.1.1.php new file mode 100644 index 00000000000..926d7234b0d --- /dev/null +++ b/app/code/core/Mage/User/sql/user_setup/upgrade-1.6.1.0-1.6.1.1.php @@ -0,0 +1,35 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Mage + * @package Mage_User + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +/** @var $installer Mage_Core_Model_Resource_Setup */ +$installer = $this; +$installer->startSetup(); + +// Add reset password link token column +$installer->getConnection()->dropTable($installer->getTable('admin_assert')); +$installer->getConnection()->dropColumn($installer->getTable('admin_rule'), 'assert_id'); + +$installer->endSetup(); diff --git a/app/code/core/Mage/Weee/etc/config.xml b/app/code/core/Mage/Weee/etc/config.xml index 7ed2f54b3c6..8773f1f8ee4 100644 --- a/app/code/core/Mage/Weee/etc/config.xml +++ b/app/code/core/Mage/Weee/etc/config.xml @@ -154,6 +154,15 @@ </observers> </adminhtml_catalog_product_edit_element_types> </events> + <translate> + <modules> + <Mage_Weee> + <files> + <default>Mage_Weee.csv</default> + </files> + </Mage_Weee> + </modules> + </translate> </adminhtml> <default> <sales> @@ -189,5 +198,14 @@ </weee> </updates> </layout> + <translate> + <modules> + <Mage_Weee> + <files> + <default>Mage_Weee.csv</default> + </files> + </Mage_Weee> + </modules> + </translate> </frontend> </config> 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 b33603ce040..f371d1a17c0 100644 --- a/app/code/core/Mage/Widget/controllers/Adminhtml/Widget/InstanceController.php +++ b/app/code/core/Mage/Widget/controllers/Adminhtml/Widget/InstanceController.php @@ -304,6 +304,6 @@ class Mage_Widget_Adminhtml_Widget_InstanceController extends Mage_Adminhtml_Con */ protected function _isAllowed() { - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('cms/widget_instance'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_Widget::widget_instance'); } } diff --git a/app/code/core/Mage/Widget/etc/adminhtml.xml b/app/code/core/Mage/Widget/etc/adminhtml/acl.xml similarity index 69% rename from app/code/core/Mage/Widget/etc/adminhtml.xml rename to app/code/core/Mage/Widget/etc/adminhtml/acl.xml index fbe413f42b7..04bde344dac 100644 --- a/app/code/core/Mage/Widget/etc/adminhtml.xml +++ b/app/code/core/Mage/Widget/etc/adminhtml/acl.xml @@ -28,18 +28,11 @@ <config> <acl> <resources> - <admin> - <children> - <cms> - <children> - <widget_instance translate="title" module="Mage_Widget"> - <title>Widgets</title> - <sort_order>15</sort_order> - </widget_instance> - </children> - </cms> - </children> - </admin> + <resource id="Mage_Adminhtml::admin"> + <resource id="Mage_Cms::cms"> + <resource id="Mage_Widget::widget_instance" module="Mage_Widget" title="Widgets" sortOrder="15" /> + </resource> + </resource> </resources> </acl> </config> diff --git a/app/code/core/Mage/Widget/etc/adminhtml/menu.xml b/app/code/core/Mage/Widget/etc/adminhtml/menu.xml index 5f68b0a238a..0c587e21a33 100644 --- a/app/code/core/Mage/Widget/etc/adminhtml/menu.xml +++ b/app/code/core/Mage/Widget/etc/adminhtml/menu.xml @@ -27,6 +27,6 @@ --> <config> <menu> - <add id="Mage_Widget::cms_widget_instance" title="Widgets" module="Mage_Widget" sortOrder="15" parent="Mage_Cms::cms" action="adminhtml/widget_instance" /> + <add id="Mage_Widget::cms_widget_instance" title="Widgets" module="Mage_Widget" sortOrder="15" parent="Mage_Cms::cms" action="adminhtml/widget_instance" resource="Mage_Widget::widget_instance"/> </menu> </config> diff --git a/app/code/core/Mage/Wishlist/etc/adminhtml.xml b/app/code/core/Mage/Wishlist/etc/adminhtml.xml deleted file mode 100644 index 357419f25b7..00000000000 --- a/app/code/core/Mage/Wishlist/etc/adminhtml.xml +++ /dev/null @@ -1,48 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License (AFL 3.0) - * that is bundled with this package in the file LICENSE_AFL.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/afl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @category Mage - * @package Mage_Wishlist - * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - */ ---> -<config> - <acl> - <resources> - <admin> - <children> - <system> - <children> - <config> - <children> - <wishlist translate="title" module="Mage_Wishlist"> - <title>Wishlist Section</title> - </wishlist> - </children> - </config> - </children> - </system> - </children> - </admin> - </resources> - </acl> -</config> diff --git a/app/code/core/Mage/Wishlist/etc/adminhtml/acl.xml b/app/code/core/Mage/Wishlist/etc/adminhtml/acl.xml new file mode 100644 index 00000000000..8c43ba1050b --- /dev/null +++ b/app/code/core/Mage/Wishlist/etc/adminhtml/acl.xml @@ -0,0 +1,40 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Mage + * @package Mage_Wishlist + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config> + <acl> + <resources> + <resource id="Mage_Adminhtml::admin"> + <resource id="Mage_Adminhtml::system"> + <resource id="Mage_Adminhtml::config"> + <resource id="Mage_Wishlist::config_wishlist" module="Mage_Wishlist" title="Wishlist Section" /> + </resource> + </resource> + </resource> + </resources> + </acl> +</config> diff --git a/app/code/core/Mage/Wishlist/etc/system.xml b/app/code/core/Mage/Wishlist/etc/system.xml index 19ab364e4c6..42065e34f59 100644 --- a/app/code/core/Mage/Wishlist/etc/system.xml +++ b/app/code/core/Mage/Wishlist/etc/system.xml @@ -35,6 +35,7 @@ <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>1</show_in_store> + <resource>Mage_Wishlist::config_wishlist</resource> <groups> <email translate="label"> <label>Share Options</label> diff --git a/app/code/core/Mage/XmlConnect/controllers/Adminhtml/MobileController.php b/app/code/core/Mage/XmlConnect/controllers/Adminhtml/MobileController.php index 204bddad294..1ca55fb41f1 100644 --- a/app/code/core/Mage/XmlConnect/controllers/Adminhtml/MobileController.php +++ b/app/code/core/Mage/XmlConnect/controllers/Adminhtml/MobileController.php @@ -777,7 +777,7 @@ class Mage_XmlConnect_Adminhtml_MobileController extends Mage_Adminhtml_Controll */ protected function _isAllowed() { - return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('xmlconnect'); + return Mage::getSingleton('Mage_Backend_Model_Auth_Session')->isAllowed('Mage_XmlConnect::xmlconnect'); } /** diff --git a/app/code/core/Mage/XmlConnect/etc/adminhtml.xml b/app/code/core/Mage/XmlConnect/etc/adminhtml.xml deleted file mode 100644 index 924f7d04351..00000000000 --- a/app/code/core/Mage/XmlConnect/etc/adminhtml.xml +++ /dev/null @@ -1,59 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License (AFL 3.0) - * that is bundled with this package in the file LICENSE_AFL.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/afl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @category Mage - * @package Mage_XmlConnect - * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - */ ---> -<config> - <acl> - <resources> - <admin translate="title" module="Mage_XmlConnect"> - <children> - <xmlconnect translate="title" module="Mage_XmlConnect"> - <title>Mobile</title> - <sort_order>100</sort_order> - <children> - <mobile translate="title" module="Mage_XmlConnect"> - <title>Manage Apps</title> - <sort_order>10</sort_order> - </mobile> - <history translate="title" module="Mage_XmlConnect"> - <title>Submission History</title> - <sort_order>20</sort_order> - </history> - <templates translate="title" module="Mage_XmlConnect"> - <title>Message Templates</title> - <sort_order>30</sort_order> - </templates> - <queue translate="title" module="Mage_XmlConnect"> - <title>Message Queue</title> - <sort_order>40</sort_order> - </queue> - </children> - </xmlconnect> - </children> - </admin> - </resources> - </acl> -</config> diff --git a/app/code/core/Mage/GoogleAnalytics/etc/adminhtml.xml b/app/code/core/Mage/XmlConnect/etc/adminhtml/acl.xml similarity index 56% rename from app/code/core/Mage/GoogleAnalytics/etc/adminhtml.xml rename to app/code/core/Mage/XmlConnect/etc/adminhtml/acl.xml index ccd25751f23..061f91b1cd0 100644 --- a/app/code/core/Mage/GoogleAnalytics/etc/adminhtml.xml +++ b/app/code/core/Mage/XmlConnect/etc/adminhtml/acl.xml @@ -20,7 +20,7 @@ * needs please refer to http://www.magentocommerce.com for more information. * * @category Mage - * @package Mage_GoogleAnalytics + * @package Mage_XmlConnect * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ @@ -28,21 +28,14 @@ <config> <acl> <resources> - <admin> - <children> - <system> - <children> - <config> - <children> - <google translate="title" module="Mage_GoogleAnalytics"> - <title>Google API</title> - </google> - </children> - </config> - </children> - </system> - </children> - </admin> + <resource id="Mage_Adminhtml::admin" module="Mage_XmlConnect"> + <resource id="Mage_XmlConnect::xmlconnect" module="Mage_XmlConnect" title="Mobile" sortOrder="100"> + <resource id="Mage_XmlConnect::mobile" module="Mage_XmlConnect" title="Manage Apps" sortOrder="10" /> + <resource id="Mage_XmlConnect::history" module="Mage_XmlConnect" title="Submission History" sortOrder="20" /> + <resource id="Mage_XmlConnect::templates" module="Mage_XmlConnect" title="Message Templates" sortOrder="30" /> + <resource id="Mage_XmlConnect::xmlconnect_queue" module="Mage_XmlConnect" title="Message Queue" sortOrder="40" /> + </resource> + </resource> </resources> </acl> </config> diff --git a/app/code/core/Mage/XmlConnect/etc/adminhtml/menu.xml b/app/code/core/Mage/XmlConnect/etc/adminhtml/menu.xml index 542582c94e2..bdd7f9ea95a 100644 --- a/app/code/core/Mage/XmlConnect/etc/adminhtml/menu.xml +++ b/app/code/core/Mage/XmlConnect/etc/adminhtml/menu.xml @@ -27,10 +27,10 @@ --> <config> <menu> - <add id="Mage_XmlConnect::xmlconnect" title="Mobile" module="Mage_XmlConnect" sortOrder="35" /> - <add id="Mage_XmlConnect::xmlconnect_mobile" title="Manage Apps" module="Mage_XmlConnect" sortOrder="10" parent="Mage_XmlConnect::xmlconnect" action="adminhtml/mobile" /> - <add id="Mage_XmlConnect::xmlconnect_history" title="Submission History" module="Mage_XmlConnect" sortOrder="20" parent="Mage_XmlConnect::xmlconnect" action="adminhtml/mobile/history" /> - <add id="Mage_XmlConnect::xmlconnect_templates" title="Message Templates" module="Mage_XmlConnect" sortOrder="30" parent="Mage_XmlConnect::xmlconnect" action="adminhtml/mobile/template" /> - <add id="Mage_XmlConnect::xmlconnect_queue" title="Message Queue" module="Mage_XmlConnect" sortOrder="40" parent="Mage_XmlConnect::xmlconnect" action="adminhtml/mobile/queue" /> + <add id="Mage_XmlConnect::xmlconnect" title="Mobile" module="Mage_XmlConnect" sortOrder="35" resource="Mage_XmlConnect::xmlconnect"/> + <add id="Mage_XmlConnect::xmlconnect_mobile" title="Manage Apps" module="Mage_XmlConnect" sortOrder="10" parent="Mage_XmlConnect::xmlconnect" action="adminhtml/mobile" resource="Mage_XmlConnect::mobile"/> + <add id="Mage_XmlConnect::xmlconnect_history" title="Submission History" module="Mage_XmlConnect" sortOrder="20" parent="Mage_XmlConnect::xmlconnect" action="adminhtml/mobile/history" resource="Mage_XmlConnect::history"/> + <add id="Mage_XmlConnect::xmlconnect_templates" title="Message Templates" module="Mage_XmlConnect" sortOrder="30" parent="Mage_XmlConnect::xmlconnect" action="adminhtml/mobile/template" resource="Mage_XmlConnect::templates"/> + <add id="Mage_XmlConnect::xmlconnect_queue" title="Message Queue" module="Mage_XmlConnect" sortOrder="40" parent="Mage_XmlConnect::xmlconnect" action="adminhtml/mobile/queue" resource="Mage_XmlConnect::xmlconnect_queue"/> </menu> </config> diff --git a/dev/tests/integration/framework/Magento/Test/Bootstrap.php b/dev/tests/integration/framework/Magento/Test/Bootstrap.php index 249eca8d2c1..6ca290dd140 100644 --- a/dev/tests/integration/framework/Magento/Test/Bootstrap.php +++ b/dev/tests/integration/framework/Magento/Test/Bootstrap.php @@ -591,7 +591,7 @@ class Magento_Test_Bootstrap $roleUser->setData(array( 'parent_id' => $roleAdmin->getId(), 'tree_level' => $roleAdmin->getTreeLevel() + 1, - 'role_type' => Mage_Admin_Model_Acl::ROLE_TYPE_USER, + 'role_type' => Mage_User_Model_Acl_Role_User::ROLE_TYPE, 'user_id' => $user->getId(), 'role_name' => $user->getFirstname(), )); diff --git a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/System/Config/FormTest.php b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/System/Config/FormTest.php index 68a0471dfd1..9f5317211f4 100644 --- a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/System/Config/FormTest.php +++ b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/System/Config/FormTest.php @@ -106,4 +106,57 @@ class Mage_Adminhtml_Block_System_Config_FormTest extends PHPUnit_Framework_Test array($section, $group, $field, array($fieldPath => 'value'), false), ); } + + public function testInitFormAddsFieldsets() + { + new Mage_Core_Controller_Front_Action(Mage::app()->getRequest(), Mage::app()->getResponse()); + Mage::app()->getRequest()->setParam('section', 'general'); + $block = new Mage_Adminhtml_Block_System_Config_Form(); + $block->setLayout(Mage::app()->getLayout()); + $block->initForm(); + $expectedIds = array( + 'general_country' => array( + 'general_country_default' => 'select', + 'general_country_allow' => 'select', + 'general_country_optional_zip_countries' => 'select', + 'general_country_eu_countries' => 'select' + ), + 'general_region' => array( + 'general_region_state_required' => 'select', + 'general_region_display_all' => 'select' + ), + 'general_locale' => array( + 'general_locale_timezone' => 'select', + 'general_locale_code' => 'select', + 'general_locale_firstday' => 'select', + 'general_locale_weekend' => 'select' + ), + 'general_restriction' => array( + 'general_restriction_is_active' => 'select', + 'general_restriction_mode' => 'select', + 'general_restriction_http_redirect' => 'select', + 'general_restriction_cms_page' => 'select', + 'general_restriction_http_status' => 'select' + ), + 'general_store_information' => array( + 'general_store_information_name' => 'text', + 'general_store_information_phone' => 'text', + 'general_store_information_merchant_country' => 'select', + 'general_store_information_merchant_vat_number' => 'text', + 'general_store_information_validate_vat_number' => 'text', + 'general_store_information_address' => 'textarea', + ) + ); + $elements = $block->getForm()->getElements(); + foreach ($elements as $element) { + $this->assertInstanceOf('Varien_Data_Form_Element_Fieldset', $element); + $this->assertArrayHasKey($element->getId(), $expectedIds); + $fields = $element->getSortedElements(); + $this->assertEquals(count($expectedIds[$element->getId()]), count($fields)); + foreach ($element->getElements() as $field) { + $this->assertArrayHasKey($field->getId(), $expectedIds[$element->getId()]); + $this->assertEquals($expectedIds[$element->getId()][$field->getId()], $field->getType()); + } + }; + } } diff --git a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/System/Store/Edit/Form/GroupTest.php b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/System/Store/Edit/Form/GroupTest.php new file mode 100644 index 00000000000..02aff81abc6 --- /dev/null +++ b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/System/Store/Edit/Form/GroupTest.php @@ -0,0 +1,72 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Magento + * @package Magento_Adminhtml + * @subpackage integration_tests + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +/** + * @magentoAppIsolation enabled + */ +class Mage_Adminhtml_Block_System_Store_Edit_Form_GroupTest extends PHPUnit_Framework_TestCase +{ + /** @var Mage_Adminhtml_Block_System_Store_Edit_Form_Group */ + protected $_block; + + public static function setUpBeforeClass() + { + $registryData = array( + 'store_type' => 'group', + 'store_data' => new Mage_Core_Model_Store_Group(), + 'store_action' => 'add' + ); + foreach ($registryData as $key => $value) { + Mage::register($key, $value); + } + } + + public static function tearDownAfterClass() + { + Mage::unregister('store_type'); + Mage::unregister('store_data'); + Mage::unregister('store_action'); + } + + public function setUp() + { + $layout = new Mage_Core_Model_Layout(); + + $this->_block = new Mage_Adminhtml_Block_System_Store_Edit_Form_Group(); + $this->_block->setLayout($layout); + + $this->_block->toHtml(); + } + + public function testPrepareForm() + { + $form = $this->_block->getForm(); + $this->assertEquals('group_fieldset', $form->getElement('group_fieldset')->getId()); + $this->assertEquals('group_name', $form->getElement('group_name')->getId()); + $this->assertEquals('group', $form->getElement('store_type')->getValue()); + } +} diff --git a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/System/Store/Edit/Form/StoreTest.php b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/System/Store/Edit/Form/StoreTest.php new file mode 100644 index 00000000000..e3390aeb415 --- /dev/null +++ b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/System/Store/Edit/Form/StoreTest.php @@ -0,0 +1,72 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Magento + * @package Magento_Adminhtml + * @subpackage integration_tests + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +/** + * @magentoAppIsolation enabled + */ +class Mage_Adminhtml_Block_System_Store_Edit_Form_StoreTest extends PHPUnit_Framework_TestCase +{ + /** @var Mage_Adminhtml_Block_System_Store_Edit_Form_Store */ + protected $_block; + + public static function setUpBeforeClass() + { + $registryData = array( + 'store_type' => 'store', + 'store_data' => new Mage_Core_Model_Store(), + 'store_action' => 'add' + ); + foreach ($registryData as $key => $value) { + Mage::register($key, $value); + } + } + + public static function tearDownAfterClass() + { + Mage::unregister('store_type'); + Mage::unregister('store_data'); + Mage::unregister('store_action'); + } + + public function setUp() + { + $layout = new Mage_Core_Model_Layout(); + + $this->_block = new Mage_Adminhtml_Block_System_Store_Edit_Form_Store(); + $this->_block->setLayout($layout); + + $this->_block->toHtml(); + } + + public function testPrepareForm() + { + $form = $this->_block->getForm(); + $this->assertEquals('store_fieldset', $form->getElement('store_fieldset')->getId()); + $this->assertEquals('store_name', $form->getElement('store_name')->getId()); + $this->assertEquals('store', $form->getElement('store_type')->getValue()); + } +} diff --git a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/System/Store/Edit/Form/WebsiteTest.php b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/System/Store/Edit/Form/WebsiteTest.php new file mode 100644 index 00000000000..9c510fffb4c --- /dev/null +++ b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/System/Store/Edit/Form/WebsiteTest.php @@ -0,0 +1,72 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Magento + * @package Magento_Adminhtml + * @subpackage integration_tests + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +/** + * @magentoAppIsolation enabled + */ +class Mage_Adminhtml_Block_System_Store_Edit_Form_WebsiteTest extends PHPUnit_Framework_TestCase +{ + /** @var Mage_Adminhtml_Block_System_Store_Edit_Form_Website */ + protected $_block; + + public static function setUpBeforeClass() + { + $registryData = array( + 'store_type' => 'website', + 'store_data' => new Mage_Core_Model_Website(), + 'store_action' => 'add' + ); + foreach ($registryData as $key => $value) { + Mage::register($key, $value); + } + } + + public static function tearDownAfterClass() + { + Mage::unregister('store_type'); + Mage::unregister('store_data'); + Mage::unregister('store_action'); + } + + public function setUp() + { + $layout = new Mage_Core_Model_Layout(); + + $this->_block = new Mage_Adminhtml_Block_System_Store_Edit_Form_Website(); + $this->_block->setLayout($layout); + + $this->_block->toHtml(); + } + + public function testPrepareForm() + { + $form = $this->_block->getForm(); + $this->assertEquals('website_fieldset', $form->getElement('website_fieldset')->getId()); + $this->assertEquals('website_name', $form->getElement('website_name')->getId()); + $this->assertEquals('website', $form->getElement('store_type')->getValue()); + } +} diff --git a/dev/tests/integration/testsuite/Mage/Adminhtml/Block/System/Store/EditTest.php b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/System/Store/EditTest.php new file mode 100644 index 00000000000..9351a8ea6fc --- /dev/null +++ b/dev/tests/integration/testsuite/Mage/Adminhtml/Block/System/Store/EditTest.php @@ -0,0 +1,155 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Magento + * @package Magento_Adminhtml + * @subpackage integration_tests + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +class Mage_Adminhtml_Block_System_Store_EditTest extends PHPUnit_Framework_TestCase +{ + public function tearDown() + { + Mage::unregister('store_type'); + Mage::unregister('store_data'); + Mage::unregister('store_action'); + } + + /** + * @param $registryData + */ + protected function _initStoreTypesInRegistry($registryData) + { + foreach ($registryData as $key => $value) { + Mage::register($key, $value); + } + } + + /** + * @param $registryData + * @param $expected + * @dataProvider getStoreTypesForLayout + */ + public function testStoreTypeFormCreated($registryData, $expected) + { + $this->_initStoreTypesInRegistry($registryData); + + $layout = new Mage_Core_Model_Layout(); + $block = $layout->createBlock('Mage_Adminhtml_Block_System_Store_Edit', 'block'); + $block->setArea(Mage_Core_Model_App_Area::AREA_ADMINHTML); + + $this->assertInstanceOf($expected, $block->getChildBlock('form')); + } + + /** + * @return array + */ + public function getStoreTypesForLayout() + { + return array( + array( + array('store_type'=>'website', 'store_data'=> new Mage_Core_Model_Website()), + 'Mage_Adminhtml_Block_System_Store_Edit_Form_Website' + ), + array( + array('store_type'=>'group', 'store_data'=> new Mage_Core_Model_Store_Group()), + 'Mage_Adminhtml_Block_System_Store_Edit_Form_Group' + ), + array( + array('store_type'=>'store', 'store_data'=> new Mage_Core_Model_Store()), + 'Mage_Adminhtml_Block_System_Store_Edit_Form_Store' + ) + ); + } + /** + * @param $registryData + * @param $expected + * @dataProvider getStoreDataForBlock + */ + public function testGetHeaderText($registryData, $expected) + { + $this->_initStoreTypesInRegistry($registryData); + + $layout = new Mage_Core_Model_Layout(); + $block = $layout->createBlock('Mage_Adminhtml_Block_System_Store_Edit', 'block'); + $block->setArea(Mage_Core_Model_App_Area::AREA_ADMINHTML); + + $this->assertEquals($expected, $block->getHeaderText()); + } + + /** + * @return array + */ + public function getStoreDataForBlock() + { + return array( + array( + array( + 'store_type' => 'website', + 'store_data' => new Mage_Core_Model_Website(), + 'store_action' => 'add' + ), + 'New Website' + ), + array( + array( + 'store_type' => 'website', + 'store_data' => new Mage_Core_Model_Website(), + 'store_action' => 'edit' + ), + 'Edit Website' + ), + array( + array( + 'store_type' => 'group', + 'store_data' => new Mage_Core_Model_Store_Group(), + 'store_action' => 'add' + ), + 'New Store' + ), + array( + array( + 'store_type' => 'group', + 'store_data' => new Mage_Core_Model_Store_Group(), + 'store_action' => 'edit' + ), + 'Edit Store' + ), + array( + array( + 'store_type' => 'store', + 'store_data' => new Mage_Core_Model_Store(), + 'store_action' => 'add' + ), + 'New Store View' + ), + array( + array( + 'store_type' => 'store', + 'store_data' => new Mage_Core_Model_Store(), + 'store_action' => 'edit' + ), + 'Edit Store View' + ) + ); + } +} diff --git a/dev/tests/integration/testsuite/Mage/Backend/Model/MenuTest.php b/dev/tests/integration/testsuite/Mage/Backend/Model/MenuTest.php index d1ae170c39e..9e7c41b4cc4 100644 --- a/dev/tests/integration/testsuite/Mage/Backend/Model/MenuTest.php +++ b/dev/tests/integration/testsuite/Mage/Backend/Model/MenuTest.php @@ -59,6 +59,7 @@ class Mage_Backend_Model_MenuTest extends PHPUnit_Framework_TestCase 'id' => 'Mage_Backend::system2', 'title' => 'Extended System', 'module' => 'Mage_Backend', + 'resource' => 'Mage_Backend::system2' ))); //Add submenu @@ -66,7 +67,8 @@ class Mage_Backend_Model_MenuTest extends PHPUnit_Framework_TestCase 'id' => 'Mage_Backend::system2_acl', 'title' => 'Acl', 'module' => 'Mage_Backend', - 'action' => 'admin/backend/acl/index' + 'action' => 'admin/backend/acl/index', + 'resource' => 'Mage_Backend::system2_acl', )), 'Mage_Backend::system2'); // Modify existing menu item diff --git a/dev/tests/integration/testsuite/Mage/Captcha/Block/Captcha/ZendTest.php b/dev/tests/integration/testsuite/Mage/Captcha/Block/Captcha/ZendTest.php new file mode 100644 index 00000000000..f0ba3903a6c --- /dev/null +++ b/dev/tests/integration/testsuite/Mage/Captcha/Block/Captcha/ZendTest.php @@ -0,0 +1,60 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Magento + * @package Magento_Captcha + * @subpackage integration_tests + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +class Mage_Captcha_Block_Captcha_ZendTest extends PHPUnit_Framework_TestCase +{ + /** + * @var Mage_Captcha_Block_Captcha_Zend + */ + protected $_block; + + public function setUp() + { + $this->_block = Mage::app()->getLayout() + ->createBlock('Mage_Captcha_Block_Captcha_Zend'); + } + + /** + * @magentoDbIsolation enabled + * @magentoAppIsolation enabled + */ + public function testGetRefreshUrlWhenFrontendStore() + { + $this->assertContains('captcha/refresh', $this->_block->getRefreshUrl()); + } + + /** + * @magentoDbIsolation enabled + * @magentoAppIsolation enabled + */ + public function testGetRefreshUrlWhenIsAdminStore() + { + Mage::app()->getStore('admin')->setUrlClassName('Mage_Backend_Model_Url'); + Mage::app()->setCurrentStore(Mage::app()->getStore('admin')); + + $this->assertContains('backend/admin/refresh/refresh', $this->_block->getRefreshUrl()); + } +} diff --git a/dev/tests/integration/testsuite/Mage/Core/Block/FlushTest.php b/dev/tests/integration/testsuite/Mage/Core/Block/FlushTest.php deleted file mode 100644 index 41de3b79668..00000000000 --- a/dev/tests/integration/testsuite/Mage/Core/Block/FlushTest.php +++ /dev/null @@ -1,83 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @category Magento - * @package Mage_Core - * @subpackage integration_tests - * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ - -class Mage_Core_Block_FlushTest extends PHPUnit_Framework_TestCase -{ - /** - * @var Mage_Core_Model_Layout - */ - protected $_layout; - - /** - * @var Mage_Core_Block_Text_List - */ - protected $_block; - - protected function setUp() - { - $this->_layout = new Mage_Core_Model_Layout; - $this->_block = $this->_layout->createBlock('Mage_Core_Block_Flush'); - } - - protected function tearDown() - { - $this->_block = null; - $this->_layout = null; - } - - public function testToHtml() - { - $children = array( - array('block1', 'Mage_Core_Block_Text', 'text1'), - array('block2', 'Mage_Core_Block_Text', 'text2'), - array('block3', 'Mage_Core_Block_Text', 'text3'), - ); - foreach ($children as $child) { - $this->_layout->addBlock($child[1], $child[0], $this->_block->getNameInLayout())->setText($child[2]); - } - ob_start(); - $this->_block->toHtml(); - $html = ob_get_clean(); - $this->assertEquals('text1text2text3', $html); - } - - public function testToHtmlWithContainer() - { - $listName = $this->_block->getNameInLayout(); - $block1 = $this->_layout->addBlock('Mage_Core_Block_Text', '', $listName); - $this->_layout->addContainer('container', 'Container', array(), $listName); - $block2 = $this->_layout->addBlock('Mage_Core_Block_Text', '', 'container'); - $block3 = $this->_layout->addBlock('Mage_Core_Block_Text', '', $listName); - $block1->setText('text1'); - $block2->setText('text2'); - $block3->setText('text3'); - ob_start(); - $this->_block->toHtml(); - $html = ob_get_clean(); - $this->assertEquals('text1text2text3', $html); - } -} diff --git a/dev/tests/integration/testsuite/Mage/Core/Model/ConfigTest.php b/dev/tests/integration/testsuite/Mage/Core/Model/ConfigTest.php index 0aefb9f8e65..7ee836945ab 100644 --- a/dev/tests/integration/testsuite/Mage/Core/Model/ConfigTest.php +++ b/dev/tests/integration/testsuite/Mage/Core/Model/ConfigTest.php @@ -75,6 +75,36 @@ class Mage_Core_Model_ConfigTest extends PHPUnit_Framework_TestCase $this->assertInstanceOf('Varien_Simplexml_Element', $model->getNode('global')); } + /** + * @param string $etcDir + * @param string $option + * @param string $expectedNode + * @param string $expectedValue + * @dataProvider loadBaseLocalConfigDataProvider + */ + public function testLoadBaseLocalConfig($etcDir, $option, $expectedNode, $expectedValue) + { + $model = new Mage_Core_Model_Config; + $model->setOptions(array('etc_dir' => __DIR__ . "/_files/local_config/{$etcDir}", 'local_config' => $option)); + $model->loadBase(); + $this->assertInstanceOf('Varien_Simplexml_Element', $model->getNode($expectedNode)); + $this->assertEquals($expectedValue, (string)$model->getNode($expectedNode)); + } + + /** + * @return array + */ + public function loadBaseLocalConfigDataProvider() + { + return array( + array('no_local_config_no_custom_config', '', 'a/value', 'b'), + array('no_local_config_custom_config', 'custom/local.xml', 'a', ''), + array('local_config_no_custom_config', '', 'value', 'local'), + array('local_config_custom_config', 'custom/local.xml', 'value', 'custom'), + array('local_config_custom_config', 'custom/invalid.pattern.xml', 'value', 'local'), + ); + } + public function testLoadLocales() { $model = new Mage_Core_Model_Config(); @@ -193,13 +223,6 @@ class Mage_Core_Model_ConfigTest extends PHPUnit_Framework_TestCase $this->assertEquals('', $model->determineOmittedNamespace('nonexistent', true)); } - public function testLoadModulesConfiguration() - { - $config = $this->_createModel(true)->loadModulesConfiguration('adminhtml.xml'); - $this->assertInstanceOf('Mage_Core_Model_Config_Base', $config); - $this->assertInstanceOf('Mage_Core_Model_Config_Element', $config->getNode('acl')); - } - public function testGetModuleConfigurationFiles() { $files = $this->_createModel(true)->getModuleConfigurationFiles('config.xml'); @@ -413,6 +436,15 @@ class Mage_Core_Model_ConfigTest extends PHPUnit_Framework_TestCase return $model; } + /** + * @magentoAppIsolation enabled + * @expectedException InvalidArgumentException + */ + public function testGetAreaConfigThrowsExceptionIfNonexistentAreaIsRequested() + { + Mage::app()->getConfig()->getAreaConfig('non_existent_area_code'); + } + /** * Check if areas loaded correctly from configuration * diff --git a/dev/tests/integration/testsuite/Mage/Core/Model/_files/local_config/local_config_custom_config/custom/invalid.pattern.xml b/dev/tests/integration/testsuite/Mage/Core/Model/_files/local_config/local_config_custom_config/custom/invalid.pattern.xml new file mode 100644 index 00000000000..dcf4a69257e --- /dev/null +++ b/dev/tests/integration/testsuite/Mage/Core/Model/_files/local_config/local_config_custom_config/custom/invalid.pattern.xml @@ -0,0 +1,29 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Magento + * @package Magento_Core + * @subpackage integration_tests + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +intentionally non-well-formed XML diff --git a/dev/tests/integration/testsuite/Mage/Core/Model/_files/local_config/local_config_custom_config/custom/local.xml b/dev/tests/integration/testsuite/Mage/Core/Model/_files/local_config/local_config_custom_config/custom/local.xml new file mode 100644 index 00000000000..e9e3f0f6195 --- /dev/null +++ b/dev/tests/integration/testsuite/Mage/Core/Model/_files/local_config/local_config_custom_config/custom/local.xml @@ -0,0 +1,31 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Magento + * @package Magento_Core + * @subpackage integration_tests + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<root> + <value>custom</value> +</root> diff --git a/dev/tests/integration/testsuite/Mage/Core/Model/_files/local_config/local_config_custom_config/local.xml b/dev/tests/integration/testsuite/Mage/Core/Model/_files/local_config/local_config_custom_config/local.xml new file mode 100644 index 00000000000..6423e1af670 --- /dev/null +++ b/dev/tests/integration/testsuite/Mage/Core/Model/_files/local_config/local_config_custom_config/local.xml @@ -0,0 +1,31 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Magento + * @package Magento_Core + * @subpackage integration_tests + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<root> + <value>local</value> +</root> diff --git a/dev/tests/integration/testsuite/Mage/Core/Model/_files/local_config/local_config_no_custom_config/local.xml b/dev/tests/integration/testsuite/Mage/Core/Model/_files/local_config/local_config_no_custom_config/local.xml new file mode 100644 index 00000000000..6423e1af670 --- /dev/null +++ b/dev/tests/integration/testsuite/Mage/Core/Model/_files/local_config/local_config_no_custom_config/local.xml @@ -0,0 +1,31 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Magento + * @package Magento_Core + * @subpackage integration_tests + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<root> + <value>local</value> +</root> diff --git a/dev/tests/integration/testsuite/Mage/Core/Model/_files/local_config/local_config_no_custom_config/z.xml b/dev/tests/integration/testsuite/Mage/Core/Model/_files/local_config/local_config_no_custom_config/z.xml new file mode 100644 index 00000000000..28a506dc9a4 --- /dev/null +++ b/dev/tests/integration/testsuite/Mage/Core/Model/_files/local_config/local_config_no_custom_config/z.xml @@ -0,0 +1,31 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Magento + * @package Magento_Core + * @subpackage integration_tests + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<root> + <value>z</value> +</root> diff --git a/dev/tests/integration/testsuite/Mage/Core/Model/_files/local_config/no_local_config_custom_config/a.xml b/dev/tests/integration/testsuite/Mage/Core/Model/_files/local_config/no_local_config_custom_config/a.xml new file mode 100644 index 00000000000..ad6ef1b5c72 --- /dev/null +++ b/dev/tests/integration/testsuite/Mage/Core/Model/_files/local_config/no_local_config_custom_config/a.xml @@ -0,0 +1,31 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Magento + * @package Magento_Core + * @subpackage integration_tests + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<root> + <a/> +</root> diff --git a/dev/tests/integration/testsuite/Mage/Core/Model/_files/local_config/no_local_config_custom_config/custom/local.xml b/dev/tests/integration/testsuite/Mage/Core/Model/_files/local_config/no_local_config_custom_config/custom/local.xml new file mode 100644 index 00000000000..dcf4a69257e --- /dev/null +++ b/dev/tests/integration/testsuite/Mage/Core/Model/_files/local_config/no_local_config_custom_config/custom/local.xml @@ -0,0 +1,29 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Magento + * @package Magento_Core + * @subpackage integration_tests + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +intentionally non-well-formed XML diff --git a/dev/tests/integration/testsuite/Mage/Core/Model/_files/local_config/no_local_config_no_custom_config/a.xml b/dev/tests/integration/testsuite/Mage/Core/Model/_files/local_config/no_local_config_no_custom_config/a.xml new file mode 100644 index 00000000000..5d31ca102d3 --- /dev/null +++ b/dev/tests/integration/testsuite/Mage/Core/Model/_files/local_config/no_local_config_no_custom_config/a.xml @@ -0,0 +1,33 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Magento + * @package Magento_Core + * @subpackage integration_tests + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<root> + <a> + <value>a</value> + </a> +</root> diff --git a/dev/tests/integration/testsuite/Mage/Core/Model/_files/local_config/no_local_config_no_custom_config/b.xml b/dev/tests/integration/testsuite/Mage/Core/Model/_files/local_config/no_local_config_no_custom_config/b.xml new file mode 100644 index 00000000000..d2b14768151 --- /dev/null +++ b/dev/tests/integration/testsuite/Mage/Core/Model/_files/local_config/no_local_config_no_custom_config/b.xml @@ -0,0 +1,33 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Magento + * @package Magento_Core + * @subpackage integration_tests + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<root> + <a> + <value>b</value> + </a> +</root> diff --git a/dev/tests/integration/testsuite/Mage/Newsletter/Model/TemplateTest.php b/dev/tests/integration/testsuite/Mage/Newsletter/Model/TemplateTest.php index 7d01b8914aa..9b5e38efce0 100644 --- a/dev/tests/integration/testsuite/Mage/Newsletter/Model/TemplateTest.php +++ b/dev/tests/integration/testsuite/Mage/Newsletter/Model/TemplateTest.php @@ -45,16 +45,6 @@ class Mage_Newsletter_Model_TemplateTest extends PHPUnit_Framework_TestCase $this->_model = null; } - public function getProcessedTemplateDataProvider() - { - return array( - 'install' => array('install', 'default', 'default/default/default'), - 'backend' => array('adminhtml', 'admin', 'default/default/default'), - 'frontend' => array('frontend', 'default', 'default/iphone/default'), - 'frontend store' => array('frontend', 'fixturestore', 'default/default/blue'), - ); - } - /** * @magentoConfigFixture install/design/theme/full_name default/default/default * @magentoConfigFixture adminhtml/design/theme/full_name default/default/default @@ -76,24 +66,23 @@ class Mage_Newsletter_Model_TemplateTest extends PHPUnit_Framework_TestCase $this->_model->revertDesign(); } - public function getIsValidToSendDataProvider() + /** + * @return array + */ + public function getProcessedTemplateDataProvider() { return array( - array('john.doe@example.com', 'john.doe', 'Test Subject', true), - array('john.doe@example.com', 'john.doe', '', false), - array('john.doe@example.com', '', 'Test Subject', false), - array('john.doe@example.com', '', '', false), - array('', 'john.doe', 'Test Subject', false), - array('', '', 'Test Subject', false), - array('', 'john.doe', '', false), - array('', '', '', false), + 'install' => array('install', 'default', 'default/default/default'), + 'backend' => array('adminhtml', 'admin', 'default/default/default'), + 'frontend' => array('frontend', 'default', 'default/iphone/default'), + 'frontend store' => array('frontend', 'fixturestore', 'default/default/blue'), ); } /** * @magentoConfigFixture current_store system/smtp/disable 0 * @magentoAppIsolation enabled - * @dataProvider getIsValidToSendDataProvider + * @dataProvider isValidToSendDataProvider */ public function testIsValidToSend($senderEmail, $senderName, $subject, $isValid) { @@ -102,4 +91,21 @@ class Mage_Newsletter_Model_TemplateTest extends PHPUnit_Framework_TestCase ->setTemplateSubject($subject); $this->assertSame($isValid, $this->_model->isValidForSend()); } + + /** + * @return array + */ + public function isValidToSendDataProvider() + { + return array( + array('john.doe@example.com', 'john.doe', 'Test Subject', true), + array('john.doe@example.com', 'john.doe', '', false), + array('john.doe@example.com', '', 'Test Subject', false), + array('john.doe@example.com', '', '', false), + array('', 'john.doe', 'Test Subject', false), + array('', '', 'Test Subject', false), + array('', 'john.doe', '', false), + array('', '', '', false), + ); + } } diff --git a/dev/tests/integration/testsuite/Mage/Review/Model/Resource/Review/Product/CollectionTest.php b/dev/tests/integration/testsuite/Mage/Review/Model/Resource/Review/Product/CollectionTest.php index b618e8b5c82..8a8e9785a22 100644 --- a/dev/tests/integration/testsuite/Mage/Review/Model/Resource/Review/Product/CollectionTest.php +++ b/dev/tests/integration/testsuite/Mage/Review/Model/Resource/Review/Product/CollectionTest.php @@ -32,10 +32,11 @@ class Mage_Review_Model_Resource_Review_Product_CollectionTest extends PHPUnit_F * 1) check that filter was applied * 2) check that elements are ordered correctly * - * @magentoDataFixture Mage/Review/_files/different_reviews.php + * @magentoDataFixtureDisabled Mage/Review/_files/different_reviews.php */ public function testGetResultingIds() { + $this->markTestIncomplete('Bug MAGETWO-2595'); $collection = new Mage_Review_Model_Resource_Review_Product_Collection(); $collection->addStatusFilter(Mage_Review_Model_Review::STATUS_APPROVED) ->setOrder('rdt.title', Mage_Review_Model_Resource_Review_Product_Collection::SORT_ORDER_ASC); diff --git a/dev/tests/integration/testsuite/Mage/Review/_files/different_reviews.php b/dev/tests/integration/testsuite/Mage/Review/_files/different_reviews.php index a1bd27bd7e6..d241d2d9f69 100644 --- a/dev/tests/integration/testsuite/Mage/Review/_files/different_reviews.php +++ b/dev/tests/integration/testsuite/Mage/Review/_files/different_reviews.php @@ -25,6 +25,8 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +throw new LogicException('Bug MAGETWO-2595'); + require __DIR__ . '/../../Catalog/_files/product_simple.php'; $review = new Mage_Review_Model_Review(array( diff --git a/dev/tests/integration/testsuite/Mage/User/Block/Role/Tab/EditTest.php b/dev/tests/integration/testsuite/Mage/User/Block/Role/Tab/EditTest.php index 239b5003859..6c0f88a96bc 100644 --- a/dev/tests/integration/testsuite/Mage/User/Block/Role/Tab/EditTest.php +++ b/dev/tests/integration/testsuite/Mage/User/Block/Role/Tab/EditTest.php @@ -41,6 +41,10 @@ class Mage_User_Block_Role_Tab_EditTest extends PHPUnit_Framework_TestCase $roleAdmin->load(Magento_Test_Bootstrap::ADMIN_ROLE_NAME, 'role_name'); Mage::app()->getRequest()->setParam('rid', $roleAdmin->getId()); + $aclMock = $this->getMock('Magento_Acl'); + $aclMock->expects($this->any())->method('has')->will($this->returnValue(true)); + Mage::getSingleton('Mage_Backend_Model_Auth_Session')->setAcl($aclMock); + $this->_block = new Mage_User_Block_Role_Tab_Edit(); } @@ -49,10 +53,16 @@ class Mage_User_Block_Role_Tab_EditTest extends PHPUnit_Framework_TestCase $this->_block = null; } + /** + * @magentoAppIsolation enabled + */ public function testConstructor() { $this->assertNotEmpty($this->_block->getSelectedResources()); - $this->assertContains('all', $this->_block->getSelectedResources()); + $this->assertContains( + Mage_Backend_Model_Acl_Config::ACL_RESOURCE_ALL, + $this->_block->getSelectedResources() + ); } public function testGetResTreeJson() diff --git a/dev/tests/integration/testsuite/Mage/User/Model/RulesTest.php b/dev/tests/integration/testsuite/Mage/User/Model/RulesTest.php index 47988298db3..323568936f0 100644 --- a/dev/tests/integration/testsuite/Mage/User/Model/RulesTest.php +++ b/dev/tests/integration/testsuite/Mage/User/Model/RulesTest.php @@ -51,7 +51,7 @@ class Mage_User_Model_RulesTest extends PHPUnit_Framework_TestCase public function testCRUD() { $this->_model->setRoleType('G') - ->setResourceId("all") + ->setResourceId(Mage_Backend_Model_Acl_Config::ACL_RESOURCE_ALL) ->setPrivileges("") ->setAssertId(0) ->setRoleId(1) @@ -72,7 +72,7 @@ class Mage_User_Model_RulesTest extends PHPUnit_Framework_TestCase $rules = $ruleSelect->query()->fetchAll(); $this->assertEquals(1, count($rules)); - $this->assertEquals('all', $rules[0]['resource_id']); + $this->assertEquals(Mage_Backend_Model_Acl_Config::ACL_RESOURCE_ALL, $rules[0]['resource_id']); $this->assertEquals(1, $rules[0]['role_id']); $this->assertEquals('allow', $rules[0]['permission']); } @@ -87,7 +87,7 @@ class Mage_User_Model_RulesTest extends PHPUnit_Framework_TestCase $ruleSelect = $adapter->select() ->from($this->_model->getResource()->getMainTable()); - $resources = array('all'); + $resources = array(Mage_Backend_Model_Acl_Config::ACL_RESOURCE_ALL); $this->_model->setRoleId(1) ->setResources($resources) @@ -95,7 +95,7 @@ class Mage_User_Model_RulesTest extends PHPUnit_Framework_TestCase $rules = $ruleSelect->query()->fetchAll(); $this->assertEquals(1, count($rules)); - $this->assertEquals('all', $rules[0]['resource_id']); + $this->assertEquals(Mage_Backend_Model_Acl_Config::ACL_RESOURCE_ALL, $rules[0]['resource_id']); $this->assertEquals(1, $rules[0]['role_id']); $this->assertEquals('allow', $rules[0]['permission']); } diff --git a/dev/tests/integration/testsuite/integrity/modular/AclConfigFilesTest.php b/dev/tests/integration/testsuite/integrity/modular/AclConfigFilesTest.php new file mode 100644 index 00000000000..b100d93180a --- /dev/null +++ b/dev/tests/integration/testsuite/integrity/modular/AclConfigFilesTest.php @@ -0,0 +1,109 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Magento + * @package Mage_Core + * @subpackage integration_tests + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +class Integrity_Modular_AclConfigFilesTest extends PHPUnit_Framework_TestCase +{ + /** + * Configuration acl file list + * + * @var array + */ + protected $_fileList = array(); + + /** + * Path to scheme file + * + * @var string + */ + protected $_schemeFile; + + public function setUp() + { + $readerMock = $this->getMock('Mage_Backend_Model_Acl_Config_Reader', array('getShemaFile'), array(), '', false); + $this->_schemeFile = $readerMock->getSchemaFile(); + $this->_prepareFileList(); + } + + /** + * Prepare file list of ACL resources + * + * @return void + */ + protected function _prepareFileList() + { + if (empty($this->_fileList)) { + $this->_fileList = glob(Mage::getBaseDir('app') . '/*/*/*/*/etc/adminhtml/acl.xml'); + } + } + + /** + * Test each acl configuration file + * @param string $file + * @dataProvider aclConfigFileDataProvider + */ + public function testAclConfigFile($file) + { + $domConfig = new Magento_Config_Dom(file_get_contents($file)); + $result = $domConfig->validate($this->_schemeFile, $errors); + $message = "Invalid XML-file: {$file}\n"; + foreach ($errors as $error) { + $message .= "{$error->message} Line: {$error->line}\n"; + } + $this->assertTrue($result, $message); + } + + /** + * @return array + */ + public function aclConfigFileDataProvider() + { + $this->_prepareFileList(); + $dataProviderResult = array(); + foreach ($this->_fileList as $file) { + $dataProviderResult[$file] = array($file); + } + return $dataProviderResult; + } + + /** + * Test merged ACL configuration + */ + public function testMergedConfiguration() + { + /** @var $dom DOMDocument **/ + $dom = Mage::getModel('Mage_Backend_Model_Acl_Config_Reader', $this->_fileList)->getAclResources(); + + $domConfig = new Mage_Backend_Model_Acl_Config_Reader_Dom($dom->saveXML()); + $errors = array(); + $result = $domConfig->validate($this->_schemeFile, $errors); + $message = "Invalid merged ACL config\n"; + foreach ($errors as $error) { + $message .= "{$error->message} Line: {$error->line}\n"; + } + $this->assertTrue($result, $message); + } +} diff --git a/dev/tests/performance/config.php.dist b/dev/tests/performance/config.php.dist index 8eb318e0511..e3685930115 100644 --- a/dev/tests/performance/config.php.dist +++ b/dev/tests/performance/config.php.dist @@ -28,6 +28,11 @@ return array( 'application' => array( 'url_host' => '127.0.0.1', 'url_path' => '/magento/', + 'admin' => array( + 'frontname' => 'backend', + 'username' => 'admin', + 'password' => '123123q', // must be at least of 7 both numeric and alphanumeric chars + ), /* Optional installation configuration. If omitted, no installation occurs. */ 'installation' => array( /** @@ -49,8 +54,7 @@ return array( 'admin_lastname' => 'Admin', 'admin_firstname' => 'Admin', 'admin_email' => 'admin@example.com', - 'admin_username' => 'admin', - 'admin_password' => '123123q', // must be at least of 7 both numeric and alphanumeric chars + 'admin_no_form_key' => 'yes', ), 'fixture_files' => 'testsuite/fixtures/*.php', ), @@ -72,7 +76,7 @@ return array( 'testsuite/product_view.jmx' => array( 'product_url_key' => 'product-1.html', 'product_name' => 'Product 1', - ), + ) ), ), 'report_dir' => 'report', diff --git a/dev/tests/performance/framework/Magento/Config.php b/dev/tests/performance/framework/Magento/Config.php index f294c0b0cfc..23454226f8e 100644 --- a/dev/tests/performance/framework/Magento/Config.php +++ b/dev/tests/performance/framework/Magento/Config.php @@ -44,6 +44,11 @@ class Magento_Config */ protected $_applicationUrlPath; + /** + * @var array + */ + protected $_adminOptions = array(); + /** * @var string */ @@ -84,18 +89,21 @@ class Magento_Config } $baseDir = str_replace('\\', '/', realpath($baseDir)); $this->_reportDir = $baseDir . '/' . $configData['report_dir']; - $this->_applicationUrlHost = $configData['application']['url_host']; - $this->_applicationUrlPath = $configData['application']['url_path']; - if (isset($configData['application']['installation'])) { - $installConfig = $configData['application']['installation']; + $applicationOptions = $configData['application']; + $this->_applicationUrlHost = $applicationOptions['url_host']; + $this->_applicationUrlPath = $applicationOptions['url_path']; + $this->_adminOptions = $applicationOptions['admin']; + + if (isset($applicationOptions['installation'])) { + $installConfig = $applicationOptions['installation']; $this->_installOptions = $installConfig['options']; if (isset($installConfig['fixture_files'])) { $this->_fixtureFiles = glob($baseDir . '/' . $installConfig['fixture_files'], GLOB_BRACE); } } - if (isset($configData['scenario']['jmeter_jar_file'])) { + if (!empty($configData['scenario']['jmeter_jar_file'])) { $this->_jMeterPath = $configData['scenario']['jmeter_jar_file']; } else { $this->_jMeterPath = getenv('jmeter_jar_file') ?: self::DEFAULT_JMETER_JAR_FILE; @@ -143,12 +151,21 @@ class Magento_Config */ protected function _validateData(array $configData) { + // Validate 1st-level options data $requiredKeys = array('application', 'scenario', 'report_dir'); foreach ($requiredKeys as $requiredKeyName) { if (empty($configData[$requiredKeyName])) { throw new Magento_Exception("Configuration array must define '$requiredKeyName' key."); } } + + // Validate admin options data + $requiredAdminKeys = array('frontname', 'username', 'password'); + foreach ($requiredAdminKeys as $requiredKeyName) { + if (empty($configData['application']['admin'][$requiredKeyName])) { + throw new Magento_Exception("Admin options array must define '$requiredKeyName' key."); + } + } } /** @@ -171,6 +188,16 @@ class Magento_Config return $this->_applicationUrlPath; } + /** + * Retrieve admin options - backend path and admin user credentials + * + * @return array + */ + public function getAdminOptions() + { + return $this->_adminOptions; + } + /** * Retrieve application installation options * diff --git a/dev/tests/performance/framework/Magento/Scenario.php b/dev/tests/performance/framework/Magento/Scenario.php index c2004351785..1358203b6f9 100644 --- a/dev/tests/performance/framework/Magento/Scenario.php +++ b/dev/tests/performance/framework/Magento/Scenario.php @@ -36,6 +36,9 @@ class Magento_Scenario const PARAM_PATH = 'path'; const PARAM_LOOPS = 'loops'; const PARAM_USERS = 'users'; + const PARAM_ADMIN_USERNAME = 'admin_username'; + const PARAM_ADMIN_PASSWORD = 'admin_password'; + const PARAM_ADMIN_FRONTNAME = 'admin_frontname'; /** * @var Magento_Shell diff --git a/dev/tests/performance/framework/bootstrap.php b/dev/tests/performance/framework/bootstrap.php index 77133255704..86d36448e8c 100644 --- a/dev/tests/performance/framework/bootstrap.php +++ b/dev/tests/performance/framework/bootstrap.php @@ -39,8 +39,15 @@ $config = new Magento_Config($configData, $testsBaseDir); $installOptions = $config->getInstallOptions(); if ($installOptions) { + // Populate install options with global options $baseUrl = 'http://' . $config->getApplicationUrlHost() . $config->getApplicationUrlPath(); $installOptions = array_merge($installOptions, array('url' => $baseUrl, 'secure_base_url' => $baseUrl)); + $adminOptions = $config->getAdminOptions(); + foreach ($adminOptions as $key => $val) { + $installOptions['admin_' . $key] = $val; + } + + // Install application $installer = new Magento_Installer($magentoBaseDir . '/dev/shell/install.php', new Magento_Shell(true)); echo 'Uninstalling application' . PHP_EOL; $installer->uninstall(); diff --git a/dev/tests/performance/framework/tests/unit/testsuite/Magento/ConfigTest.php b/dev/tests/performance/framework/tests/unit/testsuite/Magento/ConfigTest.php index 7974a43fe3b..c4c160b1ace 100644 --- a/dev/tests/performance/framework/tests/unit/testsuite/Magento/ConfigTest.php +++ b/dev/tests/performance/framework/tests/unit/testsuite/Magento/ConfigTest.php @@ -39,6 +39,11 @@ class Magento_ConfigTest extends PHPUnit_Framework_TestCase 'application' => array( 'url_host' => '127.0.0.1', 'url_path' => '/', + 'admin' => array( + 'frontname' => 'backend', + 'username' => 'admin', + 'password' => 'password1', + ), 'installation' => array( 'options' => array( 'option1' => 'value 1', @@ -113,6 +118,16 @@ class Magento_ConfigTest extends PHPUnit_Framework_TestCase $this->assertEquals('/', $this->_object->getApplicationUrlPath()); } + public function testGetAdminOptions() + { + $expectedOptions = array( + 'frontname' => 'backend', + 'username' => 'admin', + 'password' => 'password1', + ); + $this->assertEquals($expectedOptions, $this->_object->getAdminOptions()); + } + public function testGetInstallOptions() { $expectedOptions = array('option1' => 'value 1', 'option2' => 'value 2'); @@ -166,7 +181,7 @@ class Magento_ConfigTest extends PHPUnit_Framework_TestCase $object = new Magento_Config($configData, $baseDir); $this->assertEquals($expectedPath, $object->getJMeterPath()); - $configData['scenario']['jmeter_jar_file'] = null; + $configData['scenario']['jmeter_jar_file'] = ''; putenv("jmeter_jar_file={$expectedPath}"); $object = new Magento_Config($configData, $baseDir); $this->assertEquals($expectedPath, $object->getJMeterPath()); diff --git a/dev/tests/performance/run_scenarios.php b/dev/tests/performance/run_scenarios.php index 1ee8ab86bf3..2a519377efc 100755 --- a/dev/tests/performance/run_scenarios.php +++ b/dev/tests/performance/run_scenarios.php @@ -29,10 +29,15 @@ try { /** @var $config Magento_Config */ $config = require_once __DIR__ . '/framework/bootstrap.php'; + + $adminOptions = $config->getAdminOptions(); $scenario = new Magento_Scenario(new Magento_Shell(true), $config->getJMeterPath(), $config->getReportDir()); $scenarioParamsGlobal = array( Magento_Scenario::PARAM_HOST => $config->getApplicationUrlHost(), - Magento_Scenario::PARAM_PATH => $config->getApplicationUrlPath() + Magento_Scenario::PARAM_PATH => $config->getApplicationUrlPath(), + Magento_Scenario::PARAM_ADMIN_FRONTNAME => $adminOptions['frontname'], + Magento_Scenario::PARAM_ADMIN_USERNAME => $adminOptions['username'], + Magento_Scenario::PARAM_ADMIN_PASSWORD => $adminOptions['password'], ); $scenarioTotalCount = count($config->getScenarios()); $scenarioFailCount = 0; diff --git a/dev/tests/performance/testsuite/add_to_cart.jmx b/dev/tests/performance/testsuite/_samples/add_to_cart.jmx similarity index 100% rename from dev/tests/performance/testsuite/add_to_cart.jmx rename to dev/tests/performance/testsuite/_samples/add_to_cart.jmx diff --git a/dev/tests/performance/testsuite/checkout.jmx b/dev/tests/performance/testsuite/_samples/checkout.jmx similarity index 100% rename from dev/tests/performance/testsuite/checkout.jmx rename to dev/tests/performance/testsuite/_samples/checkout.jmx diff --git a/dev/tests/performance/testsuite/_samples/product_edit.jmx b/dev/tests/performance/testsuite/_samples/product_edit.jmx new file mode 100644 index 00000000000..809a36dbb89 --- /dev/null +++ b/dev/tests/performance/testsuite/_samples/product_edit.jmx @@ -0,0 +1,347 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Magento + * @package performance_tests + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<jmeterTestPlan version="1.2" properties="2.3"> + <hashTree> + <TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="Admin - Edit Product" enabled="true"> + <stringProp name="TestPlan.comments"></stringProp> + <boolProp name="TestPlan.functional_mode">false</boolProp> + <boolProp name="TestPlan.serialize_threadgroups">false</boolProp> + <elementProp name="TestPlan.user_defined_variables" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true"> + <collectionProp name="Arguments.arguments"> + <elementProp name="HOST" elementType="Argument"> + <stringProp name="Argument.name">HOST</stringProp> + <stringProp name="Argument.value">${__P(host,localhost)}</stringProp> + <stringProp name="Argument.metadata">=</stringProp> + </elementProp> + <elementProp name="ADMIN_PATH" elementType="Argument"> + <stringProp name="Argument.name">ADMIN_PATH</stringProp> + <stringProp name="Argument.value">${__P(path,/)}${__P(admin_frontname,backend)}/</stringProp> + <stringProp name="Argument.metadata">=</stringProp> + </elementProp> + <elementProp name="USERS" elementType="Argument"> + <stringProp name="Argument.name">USERS</stringProp> + <stringProp name="Argument.value">${__P(users,1)}</stringProp> + <stringProp name="Argument.metadata">=</stringProp> + </elementProp> + <elementProp name="LOOPS" elementType="Argument"> + <stringProp name="Argument.name">LOOPS</stringProp> + <stringProp name="Argument.value">${__P(loops,1)}</stringProp> + <stringProp name="Argument.metadata">=</stringProp> + </elementProp> + <elementProp name="ADMIN_USERNAME" elementType="Argument"> + <stringProp name="Argument.name">ADMIN_USERNAME</stringProp> + <stringProp name="Argument.value">${__P(admin_username,admin)}</stringProp> + <stringProp name="Argument.metadata">=</stringProp> + </elementProp> + <elementProp name="ADMIN_PASSWORD" elementType="Argument"> + <stringProp name="Argument.name">ADMIN_PASSWORD</stringProp> + <stringProp name="Argument.value">${__P(admin_password,123123q)}</stringProp> + <stringProp name="Argument.metadata">=</stringProp> + </elementProp> + <elementProp name="product_sku" elementType="Argument"> + <stringProp name="Argument.name">product_sku</stringProp> + <stringProp name="Argument.value">${__P(product_sku,product_1)}</stringProp> + <stringProp name="Argument.metadata">=</stringProp> + </elementProp> + </collectionProp> + </elementProp> + <stringProp name="TestPlan.user_define_classpath"></stringProp> + </TestPlan> + <hashTree> + <ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="Test Plan" enabled="true"> + <stringProp name="ThreadGroup.on_sample_error">stopthread</stringProp> + <elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="Loop Controller" enabled="true"> + <boolProp name="LoopController.continue_forever">false</boolProp> + <stringProp name="LoopController.loops">${LOOPS}</stringProp> + </elementProp> + <stringProp name="ThreadGroup.num_threads">${USERS}</stringProp> + <stringProp name="ThreadGroup.ramp_time">1</stringProp> + <longProp name="ThreadGroup.start_time">1304708488000</longProp> + <longProp name="ThreadGroup.end_time">1304708488000</longProp> + <boolProp name="ThreadGroup.scheduler">false</boolProp> + <stringProp name="ThreadGroup.duration"></stringProp> + <stringProp name="ThreadGroup.delay"></stringProp> + </ThreadGroup> + <hashTree> + <HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="Admin - Login" enabled="true"> + <elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" enabled="true"> + <collectionProp name="Arguments.arguments"/> + </elementProp> + <stringProp name="HTTPSampler.domain">${HOST}</stringProp> + <stringProp name="HTTPSampler.port"></stringProp> + <stringProp name="HTTPSampler.connect_timeout"></stringProp> + <stringProp name="HTTPSampler.response_timeout"></stringProp> + <stringProp name="HTTPSampler.protocol">http</stringProp> + <stringProp name="HTTPSampler.contentEncoding"></stringProp> + <stringProp name="HTTPSampler.path">${ADMIN_PATH}</stringProp> + <stringProp name="HTTPSampler.method">GET</stringProp> + <boolProp name="HTTPSampler.follow_redirects">true</boolProp> + <boolProp name="HTTPSampler.auto_redirects">false</boolProp> + <boolProp name="HTTPSampler.use_keepalive">true</boolProp> + <boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp> + <stringProp name="HTTPSampler.implementation">Java</stringProp> + <boolProp name="HTTPSampler.monitor">false</boolProp> + <stringProp name="HTTPSampler.embedded_url_re"></stringProp> + </HTTPSamplerProxy> + <hashTree> + <ResponseAssertion guiclass="AssertionGui" testclass="ResponseAssertion" testname="Assert login form shown" enabled="true"> + <collectionProp name="Asserion.test_strings"> + <stringProp name="1661392365">Log in to Admin Panel</stringProp> + </collectionProp> + <stringProp name="Assertion.test_field">Assertion.response_data</stringProp> + <boolProp name="Assertion.assume_success">false</boolProp> + <intProp name="Assertion.test_type">2</intProp> + </ResponseAssertion> + <hashTree/> + <RegexExtractor guiclass="RegexExtractorGui" testclass="RegexExtractor" testname="Extract form key" enabled="true"> + <stringProp name="RegexExtractor.useHeaders">false</stringProp> + <stringProp name="RegexExtractor.refname">form_key</stringProp> + <stringProp name="RegexExtractor.regex"><input name="form_key" type="hidden" value="([^'"]+)" /></stringProp> + <stringProp name="RegexExtractor.template">$1$</stringProp> + <stringProp name="RegexExtractor.default"></stringProp> + <stringProp name="RegexExtractor.match_number">1</stringProp> + </RegexExtractor> + <hashTree/> + <ResponseAssertion guiclass="AssertionGui" testclass="ResponseAssertion" testname="Assert form_key extracted" enabled="true"> + <collectionProp name="Asserion.test_strings"> + <stringProp name="2845929">^.+$</stringProp> + </collectionProp> + <stringProp name="Assertion.test_field">Assertion.response_data</stringProp> + <boolProp name="Assertion.assume_success">false</boolProp> + <intProp name="Assertion.test_type">1</intProp> + <stringProp name="Assertion.scope">variable</stringProp> + <stringProp name="Scope.variable">form_key</stringProp> + </ResponseAssertion> + <hashTree/> + </hashTree> + <HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="Admin - Submit Login Form" enabled="true"> + <elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" enabled="true"> + <collectionProp name="Arguments.arguments"> + <elementProp name="login[username]" elementType="HTTPArgument"> + <boolProp name="HTTPArgument.always_encode">false</boolProp> + <stringProp name="Argument.value">${ADMIN_USERNAME}</stringProp> + <stringProp name="Argument.metadata">=</stringProp> + <boolProp name="HTTPArgument.use_equals">true</boolProp> + <stringProp name="Argument.name">login[username]</stringProp> + </elementProp> + <elementProp name="login[password]" elementType="HTTPArgument"> + <boolProp name="HTTPArgument.always_encode">false</boolProp> + <stringProp name="Argument.value">${ADMIN_PASSWORD}</stringProp> + <stringProp name="Argument.metadata">=</stringProp> + <boolProp name="HTTPArgument.use_equals">true</boolProp> + <stringProp name="Argument.name">login[password]</stringProp> + </elementProp> + </collectionProp> + </elementProp> + <stringProp name="HTTPSampler.domain">${HOST}</stringProp> + <stringProp name="HTTPSampler.port"></stringProp> + <stringProp name="HTTPSampler.connect_timeout"></stringProp> + <stringProp name="HTTPSampler.response_timeout"></stringProp> + <stringProp name="HTTPSampler.protocol">http</stringProp> + <stringProp name="HTTPSampler.contentEncoding"></stringProp> + <stringProp name="HTTPSampler.path">${ADMIN_PATH}</stringProp> + <stringProp name="HTTPSampler.method">POST</stringProp> + <boolProp name="HTTPSampler.follow_redirects">true</boolProp> + <boolProp name="HTTPSampler.auto_redirects">false</boolProp> + <boolProp name="HTTPSampler.use_keepalive">true</boolProp> + <boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp> + <stringProp name="HTTPSampler.implementation">Java</stringProp> + <boolProp name="HTTPSampler.monitor">false</boolProp> + <stringProp name="HTTPSampler.embedded_url_re"></stringProp> + </HTTPSamplerProxy> + <hashTree> + <ResponseAssertion guiclass="AssertionGui" testclass="ResponseAssertion" testname="Assert logged-in" enabled="true"> + <collectionProp name="Asserion.test_strings"> + <stringProp name="-1356192049">Logged in as ${ADMIN_USERNAME}</stringProp> + </collectionProp> + <stringProp name="Assertion.test_field">Assertion.response_data</stringProp> + <boolProp name="Assertion.assume_success">false</boolProp> + <intProp name="Assertion.test_type">2</intProp> + </ResponseAssertion> + <hashTree/> + </hashTree> + <HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="Admin - Manage Products - Search by SKU" enabled="true"> + <elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" enabled="true"> + <collectionProp name="Arguments.arguments"> + <elementProp name="ajax" elementType="HTTPArgument"> + <boolProp name="HTTPArgument.always_encode">false</boolProp> + <stringProp name="Argument.value">true</stringProp> + <stringProp name="Argument.metadata">=</stringProp> + <boolProp name="HTTPArgument.use_equals">true</boolProp> + <stringProp name="Argument.name">ajax</stringProp> + </elementProp> + <elementProp name="isAjax" elementType="HTTPArgument"> + <boolProp name="HTTPArgument.always_encode">false</boolProp> + <stringProp name="Argument.value">true</stringProp> + <stringProp name="Argument.metadata">=</stringProp> + <boolProp name="HTTPArgument.use_equals">true</boolProp> + <stringProp name="Argument.name">isAjax</stringProp> + </elementProp> + <elementProp name="form_key" elementType="HTTPArgument"> + <boolProp name="HTTPArgument.always_encode">false</boolProp> + <stringProp name="Argument.value">${form_key}</stringProp> + <stringProp name="Argument.metadata">=</stringProp> + <boolProp name="HTTPArgument.use_equals">true</boolProp> + <stringProp name="Argument.name">form_key</stringProp> + </elementProp> + </collectionProp> + </elementProp> + <stringProp name="HTTPSampler.domain">${HOST}</stringProp> + <stringProp name="HTTPSampler.port"></stringProp> + <stringProp name="HTTPSampler.connect_timeout"></stringProp> + <stringProp name="HTTPSampler.response_timeout"></stringProp> + <stringProp name="HTTPSampler.protocol">http</stringProp> + <stringProp name="HTTPSampler.contentEncoding"></stringProp> + <stringProp name="HTTPSampler.path">${ADMIN_PATH}admin/catalog_product/grid/product_filter/${grid_product_filter}/</stringProp> + <stringProp name="HTTPSampler.method">GET</stringProp> + <boolProp name="HTTPSampler.follow_redirects">true</boolProp> + <boolProp name="HTTPSampler.auto_redirects">false</boolProp> + <boolProp name="HTTPSampler.use_keepalive">true</boolProp> + <boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp> + <stringProp name="HTTPSampler.implementation">Java</stringProp> + <boolProp name="HTTPSampler.monitor">false</boolProp> + <stringProp name="HTTPSampler.embedded_url_re"></stringProp> + </HTTPSamplerProxy> + <hashTree> + <BeanShellPreProcessor guiclass="TestBeanGUI" testclass="BeanShellPreProcessor" testname="Compose grid filter (base64)" enabled="true"> + <stringProp name="filename"></stringProp> + <stringProp name="parameters"></stringProp> + <boolProp name="resetInterpreter">false</boolProp> + <stringProp name="script">import org.apache.commons.codec.binary.Base64; + +String productSku = "sku=".concat(vars.get("product_sku")); +byte[] gridProductFilterRaw = Base64.encodeBase64(productSku.getBytes()); +String gridProductFilter = new String(gridProductFilterRaw, "ASCII"); +vars.put("grid_product_filter", gridProductFilter);</stringProp> + </BeanShellPreProcessor> + <hashTree/> + <ResponseAssertion guiclass="AssertionGui" testclass="ResponseAssertion" testname="Assert product found" enabled="true"> + <collectionProp name="Asserion.test_strings"> + <stringProp name="1081473401">Total 1 records found</stringProp> + </collectionProp> + <stringProp name="Assertion.test_field">Assertion.response_data</stringProp> + <boolProp name="Assertion.assume_success">false</boolProp> + <intProp name="Assertion.test_type">2</intProp> + </ResponseAssertion> + <hashTree/> + <RegexExtractor guiclass="RegexExtractorGui" testclass="RegexExtractor" testname="Extract product ID" enabled="true"> + <stringProp name="RegexExtractor.useHeaders">false</stringProp> + <stringProp name="RegexExtractor.refname">product_id</stringProp> + <stringProp name="RegexExtractor.regex"><a href="http.+/edit/id/(\d+)/">Edit</a></stringProp> + <stringProp name="RegexExtractor.template">$1$</stringProp> + <stringProp name="RegexExtractor.default"></stringProp> + <stringProp name="RegexExtractor.match_number">1</stringProp> + </RegexExtractor> + <hashTree/> + <ResponseAssertion guiclass="AssertionGui" testclass="ResponseAssertion" testname="Assert product ID" enabled="true"> + <collectionProp name="Asserion.test_strings"> + <stringProp name="89649215">^\d+$</stringProp> + </collectionProp> + <stringProp name="Assertion.test_field">Assertion.response_data</stringProp> + <boolProp name="Assertion.assume_success">false</boolProp> + <intProp name="Assertion.test_type">1</intProp> + <stringProp name="Assertion.scope">variable</stringProp> + <stringProp name="Scope.variable">product_id</stringProp> + </ResponseAssertion> + <hashTree/> + </hashTree> + <HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="Admin - Edit Product" enabled="true"> + <elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" enabled="true"> + <collectionProp name="Arguments.arguments"/> + </elementProp> + <stringProp name="HTTPSampler.domain">${HOST}</stringProp> + <stringProp name="HTTPSampler.port"></stringProp> + <stringProp name="HTTPSampler.connect_timeout"></stringProp> + <stringProp name="HTTPSampler.response_timeout"></stringProp> + <stringProp name="HTTPSampler.protocol">http</stringProp> + <stringProp name="HTTPSampler.contentEncoding"></stringProp> + <stringProp name="HTTPSampler.path">${ADMIN_PATH}admin/catalog_product/edit/id/${product_id}/</stringProp> + <stringProp name="HTTPSampler.method">GET</stringProp> + <boolProp name="HTTPSampler.follow_redirects">true</boolProp> + <boolProp name="HTTPSampler.auto_redirects">false</boolProp> + <boolProp name="HTTPSampler.use_keepalive">true</boolProp> + <boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp> + <stringProp name="HTTPSampler.implementation">Java</stringProp> + <boolProp name="HTTPSampler.monitor">false</boolProp> + <stringProp name="HTTPSampler.embedded_url_re"></stringProp> + </HTTPSamplerProxy> + <hashTree> + <ResponseAssertion guiclass="AssertionGui" testclass="ResponseAssertion" testname="Assert success" enabled="true"> + <collectionProp name="Asserion.test_strings"> + <stringProp name="1584505032">General</stringProp> + <stringProp name="758911215">Custom Options</stringProp> + <stringProp name="-16631492">Inventory</stringProp> + <stringProp name="-1734538585">${product_sku}</stringProp> + </collectionProp> + <stringProp name="Assertion.test_field">Assertion.response_data</stringProp> + <boolProp name="Assertion.assume_success">false</boolProp> + <intProp name="Assertion.test_type">2</intProp> + </ResponseAssertion> + <hashTree/> + </hashTree> + <CookieManager guiclass="CookiePanel" testclass="CookieManager" testname="HTTP Cookie Manager" enabled="true"> + <collectionProp name="CookieManager.cookies"/> + <boolProp name="CookieManager.clearEachIteration">true</boolProp> + </CookieManager> + <hashTree/> + </hashTree> + <ResultCollector guiclass="ViewResultsFullVisualizer" testclass="ResultCollector" testname="View Results Tree" enabled="true"> + <boolProp name="ResultCollector.error_logging">false</boolProp> + <objProp> + <name>saveConfig</name> + <value class="SampleSaveConfiguration"> + <time>true</time> + <latency>true</latency> + <timestamp>true</timestamp> + <success>true</success> + <label>true</label> + <code>true</code> + <message>true</message> + <threadName>true</threadName> + <dataType>true</dataType> + <encoding>false</encoding> + <assertions>true</assertions> + <subresults>true</subresults> + <responseData>false</responseData> + <samplerData>false</samplerData> + <xml>true</xml> + <fieldNames>false</fieldNames> + <responseHeaders>false</responseHeaders> + <requestHeaders>false</requestHeaders> + <responseDataOnError>false</responseDataOnError> + <saveAssertionResultsFailureMessage>false</saveAssertionResultsFailureMessage> + <assertionsResultsToSave>0</assertionsResultsToSave> + <bytes>true</bytes> + </value> + </objProp> + <stringProp name="filename"></stringProp> + </ResultCollector> + <hashTree/> + </hashTree> + </hashTree> +</jmeterTestPlan> diff --git a/dev/tests/static/testsuite/Legacy/ConfigTest.php b/dev/tests/static/testsuite/Legacy/ConfigTest.php index 3f03e50ddd7..78527100598 100644 --- a/dev/tests/static/testsuite/Legacy/ConfigTest.php +++ b/dev/tests/static/testsuite/Legacy/ConfigTest.php @@ -67,4 +67,53 @@ class Legacy_ConfigTest extends PHPUnit_Framework_TestCase { return Utility_Files::init()->getConfigFiles('config.xml'); } + + /** + * Check if all localization files are declared in appropriate configuration files + * + * @param string $configFile + * @param array $localeFiles + * @param string $moduleName + * @dataProvider modulesDataProvider + */ + public function testLocaleDeclarations($configFile, array $localeFiles, $moduleName) + { + $xml = simplexml_load_file($configFile); + $errors = array(); + foreach ($localeFiles as $localeFile) { + $result = $xml->xpath("//translate/modules/{$moduleName}/files[* = \"{$localeFile}\"]"); + if (empty($result)) { + $errors[] = "'$localeFile' file is not declared in '$moduleName' module"; + } + } + $this->assertEmpty($errors, join("\n", $errors)); + } + + /** + * @return array + */ + public function modulesDataProvider() + { + $data = array(); + $root = Utility_Files::init()->getPathToSource(); + $modulePaths = glob($root . "/app/code/*/*/*", GLOB_ONLYDIR); + foreach ($modulePaths as $modulePath) { + $localeFiles = glob($modulePath . "/locale/*/*.csv"); + $configFile = $modulePath . '/etc/config.xml'; + if (empty($localeFiles) || !file_exists($configFile)) { + continue; + } + foreach ($localeFiles as &$file) { + $file = basename($file); + } + $localeFiles = array_unique($localeFiles); + + $modulePath = str_replace($root, '', $modulePath); + if (preg_match('#^/app/code/[\w_]+/([\w_]+)/([\w_]+)#', $modulePath, $matches)) { + $module = $matches[1] . '_' . $matches[2]; + $data[$module] = array($configFile, $localeFiles, $module); + } + } + return $data; + } } diff --git a/dev/tests/static/testsuite/Legacy/ObsoleteAclTest.php b/dev/tests/static/testsuite/Legacy/ObsoleteAclTest.php new file mode 100644 index 00000000000..b8ce3f944eb --- /dev/null +++ b/dev/tests/static/testsuite/Legacy/ObsoleteAclTest.php @@ -0,0 +1,54 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category tests + * @package static + * @subpackage Legacy + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +/** + * Legacy tests to find obsolete acl declaration + */ +class Legacy_ObsoleteAclTest extends PHPUnit_Framework_TestCase +{ + /** + * @param string $aclFile + * @dataProvider aclFilesDataProvider + */ + public function testAclDeclaration($aclFile) + { + $aclXml = simplexml_load_file($aclFile); + $xpath = '/config/acl/*[boolean(./children) or boolean(./title)]'; + $this->assertEmpty( + $aclXml->xpath($xpath), + 'Obsolete acl structure detected in file ' . $aclFile . '.' + ); + } + + /** + * @return array + */ + public function aclFilesDataProvider() + { + return Utility_Files::init()->getConfigFiles(); + } +} diff --git a/dev/tests/static/testsuite/Legacy/ObsoleteCodeTest.php b/dev/tests/static/testsuite/Legacy/ObsoleteCodeTest.php index a7f5fdafad2..6e899a5a47a 100644 --- a/dev/tests/static/testsuite/Legacy/ObsoleteCodeTest.php +++ b/dev/tests/static/testsuite/Legacy/ObsoleteCodeTest.php @@ -148,6 +148,14 @@ class Legacy_ObsoleteCodeTest extends PHPUnit_Framework_TestCase 'Backwards-incompatible change: method _setActiveMenu()' . ' must be invoked with menu item identifier than xpath for menu item' ); + + $this->_assertNotRegExp( + '#Mage::getSingleton\([\'"]Mage_Backend_Model_Auth_Session[\'"]\)' + . '([\s]+)?->isAllowed\([\'"]([\w\d/_]+)[\'"]\)#Ui', + $content, + 'Backwards-incompatible change: method isAllowed()' + . ' must be invoked with acl item identifier than xpath for acl item' + ); } /** diff --git a/dev/tests/static/testsuite/Legacy/_files/obsolete_classes.php b/dev/tests/static/testsuite/Legacy/_files/obsolete_classes.php index eeeb1c1068c..4c6f2c28eda 100644 --- a/dev/tests/static/testsuite/Legacy/_files/obsolete_classes.php +++ b/dev/tests/static/testsuite/Legacy/_files/obsolete_classes.php @@ -25,7 +25,14 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ return array( + 'Mage_Admin_Model_Acl' => array('suggestion' => 'Magento_Acl'), 'Mage_Admin_Model_Acl_Role', + 'Mage_Admin_Model_Acl_Resource' => array('suggestion' => 'Magento_Acl_Resource'), + 'Mage_Admin_Model_Acl_Role_Registry' => array('suggestion' => 'Magento_Acl_Role_Registry'), + 'Mage_Admin_Model_Acl_Role_Generic' => array('suggestion' => 'Mage_User_Model_Acl_Role_Generic'), + 'Mage_Admin_Model_Acl_Role_Group' => array('suggestion' => 'Mage_User_Model_Acl_Role_Group'), + 'Mage_Admin_Model_Acl_Role_User' => array('suggestion' => 'Mage_User_Model_Acl_Role_User'), + 'Mage_Admin_Model_Resource_Acl' => array('suggestion' => 'Mage_User_Model_Resource_Acl'), 'Mage_Admin_Model_Observer', 'Mage_Admin_Model_Session' => array('suggestion' => 'Mage_Backend_Model_Auth_Session'), 'Mage_Admin_Model_Resource_Acl_Role', @@ -93,6 +100,7 @@ return array( 'Mage_Catalog_Model_Entity_Product_Attribute_Frontend_Image', 'Mage_Catalog_Model_Resource_Product_Attribute_Frontend_Image', 'Mage_Catalog_Model_Resource_Product_Attribute_Frontend_Tierprice', + 'Mage_Core_Block_Flush', 'Mage_Core_Block_Template_Facade', 'Mage_Core_Controller_Varien_Router_Admin' => array('suggestion' => 'Mage_Backend_Controller_Router_Default'), 'Mage_Core_Model_Design_Source_Apply', diff --git a/dev/tests/static/testsuite/Legacy/_files/obsolete_methods.php b/dev/tests/static/testsuite/Legacy/_files/obsolete_methods.php index 5271a57ff6b..b68f844959c 100644 --- a/dev/tests/static/testsuite/Legacy/_files/obsolete_methods.php +++ b/dev/tests/static/testsuite/Legacy/_files/obsolete_methods.php @@ -178,6 +178,10 @@ return array( 'forsedSave', 'generateBlocks' => array('suggestion' => 'generateElements()'), 'getAccount' => array('class_scope' => 'Mage_GoogleAnalytics_Block_Ga'), + 'getAclAssert' => array('class_scope' => 'Mage_Admin_Model_Config'), + 'getAclPrivilegeSet' => array('class_scope' => 'Mage_Admin_Model_Config'), + 'getAclResourceList' => array('class_scope' => 'Mage_Admin_Model_Config'), + 'getAclResourceTree' => array('class_scope' => 'Mage_Admin_Model_Config'), 'getAddNewButtonHtml' => array('class_scope' => 'Mage_Adminhtml_Block_Catalog_Product'), 'getAddToCartItemUrl' => array('class_scope' => 'Mage_Wishlist_Block_Customer_Sidebar'), 'getAddToCartUrlBase64' => array('suggestion' => '_getAddToCartUrl'), diff --git a/dev/tests/static/testsuite/Php/_files/whitelist/core.txt b/dev/tests/static/testsuite/Php/_files/whitelist/core.txt index b2b2bab2472..80327ab1323 100644 --- a/dev/tests/static/testsuite/Php/_files/whitelist/core.txt +++ b/dev/tests/static/testsuite/Php/_files/whitelist/core.txt @@ -1,5 +1,7 @@ app/bootstrap.php app/code/core/Mage/Adminhtml/Model/Observer.php +app/code/core/Mage/Adminhtml/Block/System/Store/Edit +app/code/core/Mage/Adminhtml/Block/System/Store/Edit.php app/code/core/Mage/Core/Block/Abstract.php app/code/core/Mage/Core/Model/Config/Module.php app/code/core/Mage/Core/Model/Design.php diff --git a/dev/tests/unit/testsuite/Mage/Admin/Model/ConfigTest.php b/dev/tests/unit/testsuite/Mage/Admin/Model/ConfigTest.php deleted file mode 100644 index d0c7a1f58b5..00000000000 --- a/dev/tests/unit/testsuite/Mage/Admin/Model/ConfigTest.php +++ /dev/null @@ -1,105 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @category Magento - * @package Mage_Backend - * @subpackage unit_tests - * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ - -/** - * Test class for Mage_Core_Model_Layout_Element - */ -class Mage_Admin_Model_ConfigTest extends PHPUnit_Framework_TestCase -{ - /** - * @var Mage_Admin_Model_Config - */ - protected $_config; - - public function setUp() - { - $config = $this->getMock('Mage_Core_Model_Config', array('loadModulesConfiguration'), array(), '', false); - $userHelper = $this->getMock("Mage_User_Helper_Data"); - $userHelper->expects($this->any())->method('__')->will($this->returnValue('User_Translation')); - - $backendHelper = $this->getMock('Mage_Backend_Helper_Data', array(), array(), '', false); - $backendHelper->expects($this->any())->method('__')->will($this->returnValue('Backend_Translation')); - - $this->_config = new Mage_Admin_Model_Config( - array( - 'app' => $this->getMock('Mage_Core_Model_App'), - 'appConfig' => $config, - 'helpers' => array( - 'Mage_User' => $userHelper, - 'Mage_Backend' => $backendHelper - ) - ) - ); - - $this->_config->getAdminhtmlConfig()->loadFile(__DIR__ . '/_files/adminhtml.xml'); - } - - public function testGetAclResourceTree() - { - $tree = $this->_config->getAclResourceTree(); - $this->assertEquals('admin', $tree->admin->getAttribute('aclpath')); - $this->assertEquals('Mage_Backend', $tree->admin->getAttribute('module_c')); - $this->assertEquals( - 'admin/system/acl/users', - $tree->admin->children->system->children->acl->children->users->getAttribute('aclpath') - ); - $this->assertEquals( - 'Mage_User', - $tree->admin->children->system->children->acl->children->users->getAttribute('module_c') - ); - } - - public function testGetAclResourceList() - { - $list = $this->_config->getAclResourceList(); - $this->assertEquals( - $list, - array( - 'admin/system/acl/users' => array('name' => 'User_Translation', 'level' => 6), - 'admin/system/acl/roles' => array('name' => 'User_Translation', 'level' => 6), - 'admin/system/acl' => array('name' => 'User_Translation', 'level' => 4), - 'admin/system' => array('name' => 'Backend_Translation', 'level' => 2), - 'admin' => array('name' => 'Backend_Translation', 'level' => 0) - ) - ); - } - - public function testGetAclResourceListShortFormat() - { - $list = $this->_config->getAclResourceList(true); - $this->assertEquals( - $list, - array( - 'admin/system/acl/users', - 'admin/system/acl/roles', - 'admin/system/acl', - 'admin/system', - 'admin' - ) - ); - } -} diff --git a/dev/tests/unit/testsuite/Mage/Admin/Model/_files/adminhtml.xml b/dev/tests/unit/testsuite/Mage/Admin/Model/_files/adminhtml.xml deleted file mode 100644 index d49dc60e7dd..00000000000 --- a/dev/tests/unit/testsuite/Mage/Admin/Model/_files/adminhtml.xml +++ /dev/null @@ -1,56 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License (AFL 3.0) - * that is bundled with this package in the file LICENSE_AFL.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/afl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @category Magento - * @package Mage_Admin - * @subpackage unit_tests - * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - */ ---> -<config> - <acl> - <resources> - <admin> - <children> - <system> - <children> - <acl translate="title" module="Mage_User"> - <title>Permissions</title> - <sort_order>0</sort_order> - <children> - <roles translate="title"> - <title>Roles</title> - <sort_order>10</sort_order> - </roles> - <users translate="title"> - <title>Users</title> - <sort_order>20</sort_order> - </users> - </children> - </acl> - </children> - </system> - </children> - </admin> - </resources> - </acl> -</config> diff --git a/dev/tests/unit/testsuite/Mage/Backend/Model/Acl/Config/ReaderTest.php b/dev/tests/unit/testsuite/Mage/Backend/Model/Acl/Config/ReaderTest.php new file mode 100644 index 00000000000..f177cdbd5cd --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/Backend/Model/Acl/Config/ReaderTest.php @@ -0,0 +1,69 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Magento + * @package Mage_Backend + * @subpackage unit_tests + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +class Mage_Backend_Model_Acl_Config_ReaderTest extends PHPUnit_Framework_TestCase +{ + /** + * @var Mage_Backend_Model_Acl_Config_Reader + */ + protected $_model; + + public function setUp() + { + $files = array( + realpath(__DIR__) . '/../../_files/acl_1.xml', + realpath(__DIR__) . '/../../_files/acl_2.xml' + ); + $this->_model = new Mage_Backend_Model_Acl_Config_Reader($files); + } + + public function testReaderImplementRequiredInterface() + { + $this->assertInstanceOf('Mage_Backend_Model_Acl_Config_ReaderInterface', $this->_model); + } + + public function testGetAclResources() + { + /** @var $resources DOMDocument */ + $resources = $this->_model->getAclResources(); + $this->assertNotEmpty($resources); + $this->assertInstanceOf('DOMDocument', $resources); + } + + public function testGetAclResourcesMergedCorrectly() + { + $expectedFile = realpath(__DIR__) . '/../../_files/acl_merged.xml'; + $expectedResources = new DOMDocument(); + $expectedResources->load($expectedFile); + + $actualResources = $this->_model->getAclResources(); + + $this->assertNotEmpty($actualResources); + $this->assertEqualXMLStructure($expectedResources->documentElement, $actualResources->documentElement, true); + $this->assertEquals($expectedResources, $actualResources); + } +} diff --git a/dev/tests/unit/testsuite/Mage/Backend/Model/Acl/ConfigTest.php b/dev/tests/unit/testsuite/Mage/Backend/Model/Acl/ConfigTest.php new file mode 100644 index 00000000000..89cacc8f923 --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/Backend/Model/Acl/ConfigTest.php @@ -0,0 +1,173 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Magento + * @package Mage_Backend + * @subpackage unit_tests + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +class Mage_Backend_Model_Acl_ConfigTest extends PHPUnit_Framework_TestCase +{ + /** + * @var Mage_Backend_Model_Acl_Config + */ + protected $_model; + + /** + * @var PHPUnit_Framework_MockObject_MockObject + */ + protected $_configMock; + + /** + * @var PHPUnit_Framework_MockObject_MockObject + */ + protected $_cacheMock; + + /** + * @var PHPUnit_Framework_MockObject_MockObject + */ + protected $_readerMock; + + public function setUp() + { + $this->_readerMock = $this->getMock('Mage_Backend_Model_Acl_Config_Reader', array(), array(), '', false); + $this->_configMock = $this->getMock('Mage_Core_Model_Config', array(), array(), '', false); + $this->_cacheMock = $this->getMock('Mage_Core_Model_Cache', array(), array(), '', false); + + $this->_model = new Mage_Backend_Model_Acl_Config(array( + 'config' => $this->_configMock, + 'cache' => $this->_cacheMock + )); + } + + public function testGetAclResourcesWhenCacheLoadCorruptedValue() + { + $originalAclResources = new DOMDocument(); + $originalAclResources->loadXML('<?xml version="1.0" encoding="utf-8"?><config><acl></acl></config>'); + + $this->_configMock->expects($this->once())->method('getModelInstance') + ->with($this->equalTo('Mage_Backend_Model_Acl_Config_Reader')) + ->will($this->returnValue($this->_readerMock)); + + $this->_cacheMock->expects($this->exactly(2))->method('canUse') + ->with($this->equalTo('config'))->will($this->returnValue(true)); + + $this->_cacheMock->expects($this->once())->method('load') + ->with($this->equalTo(Mage_Backend_Model_Acl_Config::CACHE_ID)) + ->will($this->returnValue(1234)); + + $this->_cacheMock->expects($this->once())->method('save') + ->with($this->equalTo($originalAclResources->saveXML())); + + $this->_readerMock->expects($this->once())->method('getAclResources') + ->will($this->returnValue($originalAclResources)); + + $this->_model->getAclResources(); + } + + public function testGetAclResourcesWithEnabledAndCleanedUpCache() + { + $originalAclResources = new DOMDocument(); + $originalAclResources->loadXML( + '<?xml version="1.0" encoding="utf-8"?>' + . '<config>' + . '<acl>' + . '<resources>' + . '<resource id="res"></resource>' + . '</resources>' + . '</acl>' + . '</config>' + ); + + $this->_configMock->expects($this->once())->method('getModelInstance') + ->with($this->equalTo('Mage_Backend_Model_Acl_Config_Reader')) + ->will($this->returnValue($this->_readerMock)); + + $this->_cacheMock->expects($this->exactly(2))->method('canUse') + ->with($this->equalTo('config'))->will($this->returnValue(true)); + + $this->_cacheMock->expects($this->once())->method('load') + ->with($this->equalTo(Mage_Backend_Model_Acl_Config::CACHE_ID)) + ->will($this->returnValue(null)); + + $this->_cacheMock->expects($this->once())->method('save') + ->with($this->equalTo($originalAclResources->saveXML())); + + $this->_readerMock->expects($this->once())->method('getAclResources') + ->will($this->returnValue($originalAclResources)); + + $aclResources = $this->_model->getAclResources(); + + $this->assertInstanceOF('DOMNodeList', $aclResources); + $this->assertEquals(1, $aclResources->length); + $this->assertEquals('res', $aclResources->item(0)->getAttribute('id')); + } + + public function testGetAclResourcesWithEnabledAndGeneratedCache() + { + $this->_configMock->expects($this->never())->method('getModelInstance'); + + $this->_cacheMock->expects($this->exactly(2))->method('canUse') + ->with($this->equalTo('config'))->will($this->returnValue(true)); + + $this->_cacheMock->expects($this->exactly(2))->method('load') + ->with($this->equalTo(Mage_Backend_Model_Acl_Config::CACHE_ID)) + ->will($this->returnValue('<?xml version="1.0" encoding="utf-8"?><config><acl></acl></config>')); + + $this->_cacheMock->expects($this->never())->method('save'); + $this->_readerMock->expects($this->never())->method('getAclResources'); + + $firstCall = $this->_model->getAclResources(); + $secondCall = $this->_model->getAclResources(); + + $this->assertNotEmpty($firstCall); + $this->assertNotEmpty($secondCall); + + $this->assertEquals($firstCall, $secondCall); + } + + public function testGetAclResourcesWithDisabledCache() + { + $aclResources = new DOMDocument(); + $aclResources->loadXML('<?xml version="1.0" encoding="utf-8"?><config><acl></acl></config>'); + + $this->_configMock->expects($this->once())->method('getModelInstance') + ->with($this->equalTo('Mage_Backend_Model_Acl_Config_Reader')) + ->will($this->returnValue($this->_readerMock)); + + $this->_cacheMock->expects($this->exactly(4))->method('canUse') + ->with($this->equalTo('config'))->will($this->returnValue(false)); + + $this->_cacheMock->expects($this->never())->method('load'); + $this->_cacheMock->expects($this->never())->method('save'); + + $this->_readerMock->expects($this->exactly(2))->method('getAclResources') + ->will($this->returnValue($aclResources)); + + $firstCall = $this->_model->getAclResources(); + $secondCall = $this->_model->getAclResources(); + + $this->assertNotEmpty($firstCall); + $this->assertNotEmpty($secondCall); + } +} + diff --git a/dev/tests/unit/testsuite/Mage/Backend/Model/Acl/Loader/ResourceTest.php b/dev/tests/unit/testsuite/Mage/Backend/Model/Acl/Loader/ResourceTest.php new file mode 100644 index 00000000000..ab5b5525ea7 --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/Backend/Model/Acl/Loader/ResourceTest.php @@ -0,0 +1,85 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Magento + * @package Mage_Backend + * @subpackage unit_tests + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +class Mage_Backend_Model_Acl_Loader_ResourceTest extends PHPUnit_Framework_TestCase +{ + /** + * @var Mage_Backend_Model_Acl_Loader_Resource + */ + protected $_model; + + /** + * @var PHPUnit_Framework_MockObject_MockObject + */ + protected $_configMock; + + /** + * @var PHPUnit_Framework_MockObject_MockObject + */ + protected $_objectFactoryMock; + + public function setUp() + { + $this->_configMock = $this->getMock( + 'Mage_Backend_Model_Acl_Config', array('getAclResources'), array(), '', false + ); + $this->_objectFactoryMock = $this->getMock('Mage_Core_Model_Config', array(), array(), '', false); + $this->_model = new Mage_Backend_Model_Acl_Loader_Resource(array( + 'config' => $this->_configMock, + 'objectFactory' => $this->_objectFactoryMock + )); + } + + public function testPopulateAclAddsResourcesToAcl() + { + $this->_objectFactoryMock->expects($this->any()) + ->method('getModelInstance') + ->with('Magento_Acl_Resource', $this->anything()) + ->will($this->returnCallback( + function($class, $id) { + return new $class($id); + } + ) + ); + + $resourcesDocument = new DOMDocument(); + $resourcesDocument->load(realpath(__DIR__) . '/../../_files/acl.xml'); + $xpath = new DOMXPath($resourcesDocument); + + $this->_configMock->expects($this->once()) + ->method('getAclResources') + ->will($this->returnValue($xpath->query('/config/acl/resources/*'))); + + $aclMock = $this->getMock('Magento_Acl'); + + $aclMock->expects($this->exactly(5)) + ->method('addResource') + ->with($this->isInstanceOf('Magento_Acl_Resource')); + + $this->_model->populateAcl($aclMock); + } +} diff --git a/dev/tests/unit/testsuite/Mage/Backend/Model/Menu/Builder/Command/AddTest.php b/dev/tests/unit/testsuite/Mage/Backend/Model/Menu/Builder/Command/AddTest.php index fd6743dba9d..db11e307fd5 100644 --- a/dev/tests/unit/testsuite/Mage/Backend/Model/Menu/Builder/Command/AddTest.php +++ b/dev/tests/unit/testsuite/Mage/Backend/Model/Menu/Builder/Command/AddTest.php @@ -33,7 +33,11 @@ class Mage_Backend_Model_Menu_Builder_Command_AddTest extends PHPUnit_Framework_ protected $_model; protected $_params = array( - 'id' => 'item', 'title' => 'item', 'module' => 'Mage_Backend', 'parent' => 'parent' + 'id' => 'item', + 'title' => 'item', + 'module' => 'Mage_Backend', + 'parent' => 'parent', + 'resource' => 'Mage_Backend::item' ); public function setUp() diff --git a/dev/tests/unit/testsuite/Mage/Backend/Model/Menu/BuilderTest.php b/dev/tests/unit/testsuite/Mage/Backend/Model/Menu/BuilderTest.php index 581fce4cb49..5411a1e92bf 100644 --- a/dev/tests/unit/testsuite/Mage/Backend/Model/Menu/BuilderTest.php +++ b/dev/tests/unit/testsuite/Mage/Backend/Model/Menu/BuilderTest.php @@ -100,14 +100,23 @@ class Mage_Backend_Model_Menu_BuilderTest extends PHPUnit_Framework_TestCase $this->_model->processCommand( new Mage_Backend_Model_Menu_Builder_Command_Add( - array('id' => 'item1', 'title' => 'Item 1', 'module' => 'Mage_Backend', 'sortOrder' => 2) + array( + 'id' => 'item1', + 'title' => 'Item 1', + 'module' => 'Mage_Backend', + 'sortOrder' => 2, + 'resource' => 'Mage_Backend::item1') ) ); $this->_model->processCommand( new Mage_Backend_Model_Menu_Builder_Command_Add( array( - 'id' => 'item2', 'parent' => 'item1', 'title' => 'two', - 'module' => 'Mage_Backend', 'sortOrder' => 4 + 'id' => 'item2', + 'parent' => 'item1', + 'title' => 'two', + 'module' => 'Mage_Backend', + 'sortOrder' => 4, + 'resource' => 'Mage_Backend::item2' ) ) ); @@ -120,7 +129,8 @@ class Mage_Backend_Model_Menu_BuilderTest extends PHPUnit_Framework_TestCase $this->_model->processCommand(new Mage_Backend_Model_Menu_Builder_Command_Add(array( 'id' => 1, 'title' => 'Item 1', - 'module' => 'Mage_Backend' + 'module' => 'Mage_Backend', + 'resource' => 'Mage_Backend::i1' ) )); $this->_model->processCommand( @@ -148,7 +158,8 @@ class Mage_Backend_Model_Menu_BuilderTest extends PHPUnit_Framework_TestCase 'id' => 'item1', 'parent' => 'not_exists', 'title' => 'Item 1', - 'module' => 'Mage_Backend' + 'module' => 'Mage_Backend', + 'resource' => 'Mage_Backend::item1' ) )); diff --git a/dev/tests/unit/testsuite/Mage/Backend/Model/Menu/Item/ValidatorTest.php b/dev/tests/unit/testsuite/Mage/Backend/Model/Menu/Item/ValidatorTest.php index fe1b4515e46..a6161eae8f2 100644 --- a/dev/tests/unit/testsuite/Mage/Backend/Model/Menu/Item/ValidatorTest.php +++ b/dev/tests/unit/testsuite/Mage/Backend/Model/Menu/Item/ValidatorTest.php @@ -71,7 +71,7 @@ class Mage_Backend_Model_Menu_Item_ValidatorTest extends PHPUnit_Framework_TestC 'id' => 'item', 'title' => 'Item Title', 'action' => '/system/config', - 'resource' => 'system/config', + 'resource' => 'Mage_Backend::system_config', 'dependsOnModule' => 'Mage_Backend', 'dependsOnConfig' => 'system/config/isEnabled', 'toolTip' => 'Item tooltip', @@ -122,7 +122,8 @@ class Mage_Backend_Model_Menu_Item_ValidatorTest extends PHPUnit_Framework_TestC array('storeConfig'), array('id'), array('title'), - array('module') + array('module'), + array('resource'), ); } @@ -225,18 +226,21 @@ class Mage_Backend_Model_Menu_Item_ValidatorTest extends PHPUnit_Framework_TestC array( 'id' => 'item1', 'title' => 'Item 1', - 'action' => 'adminhtml/controller/item1' + 'action' => 'adminhtml/controller/item1', + 'resource' => 'Namespace_Module::item1' ), array( 'id' => 'item2', 'title' => 'Item 2', - 'action' => 'adminhtml/controller/item2' + 'action' => 'adminhtml/controller/item2', + 'resource' => 'Namespace_Module::item2' ) ), array( 'id' => 'item1', 'title' => 'Item 1', - 'action' => 'adminhtml/controller/item1' + 'action' => 'adminhtml/controller/item1', + 'resource' => 'Namespace_Module::item1' ) ), array( @@ -244,18 +248,21 @@ class Mage_Backend_Model_Menu_Item_ValidatorTest extends PHPUnit_Framework_TestC array( 'id' => 'Namespace_Module::item1', 'title' => 'Item 1', - 'action' => 'adminhtml/controller/item1' + 'action' => 'adminhtml/controller/item1', + 'resource' => 'Namespace_Module::item1' ), array( 'id' => 'Namespace_Module::item2', 'title' => 'Item 2', - 'action' => 'adminhtml/controller/item2' + 'action' => 'adminhtml/controller/item2', + 'resource' => 'Namespace_Module::item1' ) ), array( 'id' => 'Namespace_Module::item1', 'title' => 'Item 1', - 'action' => 'adminhtml/controller/item1' + 'action' => 'adminhtml/controller/item1', + 'resource' => 'Namespace_Module::item1' ) ) ); diff --git a/dev/tests/unit/testsuite/Mage/Backend/Model/Menu/ItemTest.php b/dev/tests/unit/testsuite/Mage/Backend/Model/Menu/ItemTest.php index 0553927e109..59ff754e979 100644 --- a/dev/tests/unit/testsuite/Mage/Backend/Model/Menu/ItemTest.php +++ b/dev/tests/unit/testsuite/Mage/Backend/Model/Menu/ItemTest.php @@ -74,7 +74,7 @@ class Mage_Backend_Model_Menu_ItemTest extends PHPUnit_Framework_TestCase 'id' => 'item', 'title' => 'Item Title', 'action' => '/system/config', - 'resource' => 'system/config', + 'resource' => 'Mage_Backend::config', 'dependsOnModule' => 'Mage_Backend', 'dependsOnConfig' => 'system/config/isEnabled', 'tooltip' => 'Item tooltip', @@ -82,7 +82,7 @@ class Mage_Backend_Model_Menu_ItemTest extends PHPUnit_Framework_TestCase public function setUp() { - $this->_aclMock = $this->getMock('Mage_Backend_Model_Auth_Session'); + $this->_aclMock = $this->getMock('Mage_Backend_Model_Auth_Session', array(), array(), '', false); $this->_appConfigMock = $this->getMock('Mage_Core_Model_Config', array(), array(), '', false); $this->_storeConfigMock = $this->getMock('Mage_Core_Model_Store_Config'); $this->_menuFactoryMock = $this->getMock('Mage_Backend_Model_Menu_Factory', array(), array(), '', false); @@ -119,12 +119,6 @@ class Mage_Backend_Model_Menu_ItemTest extends PHPUnit_Framework_TestCase new Mage_Backend_Model_Menu_Item($this->_params); } - public function testGetFullPathReturnsPathWithItemId() - { - $item = new Mage_Backend_Model_Menu_Item($this->_params); - $this->assertEquals('item', $item->getFullPath()); - } - public function testGetUrlWithEmptyActionReturnsHashSign() { $this->_params['action'] = ''; @@ -247,7 +241,7 @@ class Mage_Backend_Model_Menu_ItemTest extends PHPUnit_Framework_TestCase { $this->_aclMock->expects($this->once()) ->method('isAllowed') - ->with('admin/system/config') + ->with('Mage_Backend::config') ->will($this->returnValue(true)); $item = new Mage_Backend_Model_Menu_Item($this->_params); $this->assertTrue($item->isAllowed()); @@ -257,7 +251,7 @@ class Mage_Backend_Model_Menu_ItemTest extends PHPUnit_Framework_TestCase { $this->_aclMock->expects($this->once()) ->method('isAllowed') - ->with('admin/system/config') + ->with('Mage_Backend::config') ->will($this->throwException(new Magento_Exception())); $item = new Mage_Backend_Model_Menu_Item($this->_params); $this->assertFalse($item->isAllowed()); @@ -270,7 +264,7 @@ class Mage_Backend_Model_Menu_ItemTest extends PHPUnit_Framework_TestCase $this->_menuFactoryMock->expects($this->once()) ->method('getMenuInstance') ->with( - array('path' => 'item') + array() ) ->will($this->returnValue($menuMock)); @@ -278,22 +272,6 @@ class Mage_Backend_Model_Menu_ItemTest extends PHPUnit_Framework_TestCase $item->getChildren(); $item->getChildren(); } - - public function testSetParentUpdatesAllChildren() - { - $menuMock = $this->getMock('Mage_Backend_Model_Menu', array(), array(), '', false); - $menuMock->expects($this->once()) - ->method('setPath') - ->with($this->equalTo('root/item')); - - $this->_menuFactoryMock->expects($this->once()) - ->method('getMenuInstance') - ->will($this->returnValue($menuMock)); - - $item = new Mage_Backend_Model_Menu_Item($this->_params); - $item->getChildren(); - $item->setPath('root/'); - } } class Mage_Test_Module_Config diff --git a/dev/tests/unit/testsuite/Mage/Backend/Model/MenuTest.php b/dev/tests/unit/testsuite/Mage/Backend/Model/MenuTest.php index 38f54040920..371c53a1f16 100644 --- a/dev/tests/unit/testsuite/Mage/Backend/Model/MenuTest.php +++ b/dev/tests/unit/testsuite/Mage/Backend/Model/MenuTest.php @@ -274,21 +274,9 @@ class Mage_Backend_Model_MenuTest extends PHPUnit_Framework_TestCase $this->assertFalse($this->_model->isLast($this->_items['item3'])); } - public function testSetPathUpdatesAllChildren() - { - $this->_items['item1']->expects($this->exactly(2))->method('setPath'); - $this->_model->add($this->_items['item1']); - - $this->_items['item2']->expects($this->exactly(2))->method('setPath'); - $this->_model->add($this->_items['item2']); - - $this->_model->setpath('root'); - } - public function testGetFirstAvailableReturnsLeafNode() { $item = $this->getMock('Mage_Backend_Model_Menu_Item', array(), array(), '', false); - $item->expects($this->once())->method('setPath'); $item->expects($this->never())->method('getFirstAvailable'); $this->_model->add($item); diff --git a/dev/tests/unit/testsuite/Mage/Backend/Model/_files/acl.xml b/dev/tests/unit/testsuite/Mage/Backend/Model/_files/acl.xml new file mode 100644 index 00000000000..dac1a88dd0c --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/Backend/Model/_files/acl.xml @@ -0,0 +1,40 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Mage + * @package Mage_Adminhtml + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config> + <acl> + <resources> + <resource id="Mage_Adminhtml::all" title="Allow everything" /> + <resource id="Mage_Adminhtml::admin" module="Mage_Adminhtml" title="Magento Admin"> + <resource id="Mage_Adminhtml::dashboard" title="Dashboard" sortOrder="0" /> + <resource id="Mage_Adminhtml::system" title="System" sortOrder="90"> + <resource id="Mage_Adminhtml::store" title="Manage Stores" /> + </resource> + </resource> + </resources> + </acl> +</config> diff --git a/dev/tests/unit/testsuite/Mage/Backend/Model/_files/acl_1.xml b/dev/tests/unit/testsuite/Mage/Backend/Model/_files/acl_1.xml new file mode 100644 index 00000000000..3b6b5481e65 --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/Backend/Model/_files/acl_1.xml @@ -0,0 +1,40 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Magento + * @package Mage_Backend + * @subpackage unit_tests + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config> + <acl> + <resources> + <resource id="Dummy1::all" title="Allow everything" module="Dummy1" /> + <resource id="Dummy1::parent" title="Dummy Parent Resource" module="Dummy1"> + <resource id="Dummy1::first" title="Dummy Resource #1" module="Dummy1" sortOrder="0" /> + <resource id="Dummy1::second" title="Dummy Resource #2" module="Dummy1" sortOrder="10"/> + <resource id="Dummy1::third" title="Dummy Resource #3" module="Dummy1" sortOrder="50" /> + </resource> + </resources> + </acl> +</config> diff --git a/dev/tests/unit/testsuite/Mage/Backend/Model/_files/acl_2.xml b/dev/tests/unit/testsuite/Mage/Backend/Model/_files/acl_2.xml new file mode 100644 index 00000000000..ff4475e9282 --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/Backend/Model/_files/acl_2.xml @@ -0,0 +1,42 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Magento + * @package Mage_Backend + * @subpackage unit_tests + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config> + <acl> + <resources> + <resource id="Dummy1::parent"> + <resource id="Dummy1::first"> + <resource id="Dummy2::parent" title="Dummy 2 Resource Parent" module="Dummy2" sortOrder="0"> + <resource id="Dummy2::first" title="Dummy 2 Resource #1" module="Dummy2" sortOrder="10" /> + <resource id="Dummy2::second" title="Dummy 2 Resource #2" module="Dummy2" sortOrder="20" /> + </resource> + </resource> + </resource> + </resources> + </acl> +</config> diff --git a/dev/tests/unit/testsuite/Mage/Backend/Model/_files/acl_merged.xml b/dev/tests/unit/testsuite/Mage/Backend/Model/_files/acl_merged.xml new file mode 100644 index 00000000000..dac8b4564ee --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/Backend/Model/_files/acl_merged.xml @@ -0,0 +1,45 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Magento + * @package Mage_Backend + * @subpackage unit_tests + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config> + <acl> + <resources> + <resource id="Dummy1::all" title="Allow everything" module="Dummy1" /> + <resource id="Dummy1::parent" title="Dummy Parent Resource" module="Dummy1"> + <resource id="Dummy1::first" title="Dummy Resource #1" module="Dummy1" sortOrder="0"> + <resource id="Dummy2::parent" title="Dummy 2 Resource Parent" module="Dummy2" sortOrder="0"> + <resource id="Dummy2::first" title="Dummy 2 Resource #1" module="Dummy2" sortOrder="10" /> + <resource id="Dummy2::second" title="Dummy 2 Resource #2" module="Dummy2" sortOrder="20" /> + </resource> + </resource> + <resource id="Dummy1::second" title="Dummy Resource #2" module="Dummy1" sortOrder="10"/> + <resource id="Dummy1::third" title="Dummy Resource #3" module="Dummy1" sortOrder="50" /> + </resource> + </resources> + </acl> +</config> diff --git a/dev/tests/unit/testsuite/Mage/Backend/Model/_files/menu_1.xml b/dev/tests/unit/testsuite/Mage/Backend/Model/_files/menu_1.xml index 1b2a7d6631c..372dea81abb 100644 --- a/dev/tests/unit/testsuite/Mage/Backend/Model/_files/menu_1.xml +++ b/dev/tests/unit/testsuite/Mage/Backend/Model/_files/menu_1.xml @@ -28,8 +28,8 @@ --> <config> <menu> - <add id="elem_one_zero" toolTip='toolTip 1' title="Title one.zero" module="Module_One" sortOrder="90" action="adminhtml/system" resource="/one/two" dependsOnModule="Module_One" dependsOnConfig="/one/two"/> - <add id="elem_one_one" toolTip='toolTip 2' title="Title one.one" module="Module_One" sortOrder="90" action="adminhtml/system" parent="elem_one_zero" /> + <add id="elem_one_zero" toolTip='toolTip 1' title="Title one.zero" module="Module_One" sortOrder="90" action="adminhtml/system" resource="Module_One::one_zero" dependsOnModule="Module_One" dependsOnConfig="/one/two"/> + <add id="elem_one_one" toolTip='toolTip 2' title="Title one.one" module="Module_One" sortOrder="90" action="adminhtml/system" parent="elem_one_zero" resource="Module_One::one_one" /> <update id="elem_one_zero" toolTip='toolTip 3' title="Title one.zero update" module="Module_One_Update" sortOrder="90" action="adminhtml/system" parent="elem_one_zero" /> <remove id="elem_one_one" /> </menu> diff --git a/dev/tests/unit/testsuite/Mage/Backend/Model/_files/menu_2.xml b/dev/tests/unit/testsuite/Mage/Backend/Model/_files/menu_2.xml index d41777ec5c9..0ac39ff8247 100644 --- a/dev/tests/unit/testsuite/Mage/Backend/Model/_files/menu_2.xml +++ b/dev/tests/unit/testsuite/Mage/Backend/Model/_files/menu_2.xml @@ -28,8 +28,8 @@ --> <config> <menu> - <add id="elem_two_zero" toolTip='toolTip 4' title="Title two.zero" module="Module_Two" sortOrder="90" action="adminhtml/system" /> - <add id="elem_two_two" toolTip='toolTip 5' title="Title two.two" module="Module_Two" sortOrder="90" action="adminhtml/system" parent="elem_two_zero" /> + <add id="elem_two_zero" toolTip='toolTip 4' title="Title two.zero" module="Module_Two" sortOrder="90" action="adminhtml/system" resource="Module_Two::two_zero" /> + <add id="elem_two_two" toolTip='toolTip 5' title="Title two.two" module="Module_Two" sortOrder="90" action="adminhtml/system" parent="elem_two_zero" resource="Module_Two::two_two" /> <update id="elem_two_zero" toolTip='toolTip 6' title="Title two.zero update" module="Module_Two_Update" sortOrder="90" action="adminhtml/system" parent="elem_two_zero" /> <remove id="elem_two_two" /> </menu> diff --git a/dev/tests/unit/testsuite/Mage/Backend/Model/_files/menu_merged.php b/dev/tests/unit/testsuite/Mage/Backend/Model/_files/menu_merged.php index fb4cac2c49e..71eb492136f 100644 --- a/dev/tests/unit/testsuite/Mage/Backend/Model/_files/menu_merged.php +++ b/dev/tests/unit/testsuite/Mage/Backend/Model/_files/menu_merged.php @@ -34,7 +34,7 @@ 'module' => 'Module_One', 'sortOrder' => 90, 'action' => 'adminhtml/system', - 'resource' => '/one/two', + 'resource' => 'Module_One::one_zero', 'dependsOnModule' => 'Module_One', 'dependsOnConfig' => '/one/two', ), @@ -46,6 +46,7 @@ 'module' => 'Module_One', 'sortOrder' => 90, 'action' => 'adminhtml/system', + 'resource' => 'Module_One::one_one', 'parent' => 'elem_one_zero', ), array ( @@ -68,6 +69,7 @@ 'title' => 'Title two.zero', 'toolTip' => 'toolTip 4', 'module' => 'Module_Two', + 'resource' => 'Module_Two::two_zero', 'sortOrder' => 90, 'action' => 'adminhtml/system', ), @@ -79,6 +81,7 @@ 'module' => 'Module_Two', 'sortOrder' => 90, 'action' => 'adminhtml/system', + 'resource' => 'Module_Two::two_two', 'parent' => 'elem_two_zero', ), array ( diff --git a/dev/tests/unit/testsuite/Mage/Backend/Model/_files/menu_merged.xml b/dev/tests/unit/testsuite/Mage/Backend/Model/_files/menu_merged.xml index 0324bf7a178..3c31473bf1c 100644 --- a/dev/tests/unit/testsuite/Mage/Backend/Model/_files/menu_merged.xml +++ b/dev/tests/unit/testsuite/Mage/Backend/Model/_files/menu_merged.xml @@ -28,12 +28,12 @@ --> <config> <menu> - <add id="elem_one_zero" toolTip='toolTip 1' title="Title one.zero" module="Module_One" sortOrder="90" action="adminhtml/system" resource="/one/two" dependsOnModule="Module_One" dependsOnConfig="/one/two"/> - <add id="elem_one_one" toolTip='toolTip 2' title="Title one.one" module="Module_One" sortOrder="90" action="adminhtml/system" parent="elem_one_zero" /> + <add id="elem_one_zero" toolTip='toolTip 1' title="Title one.zero" module="Module_One" sortOrder="90" action="adminhtml/system" resource="Module_One::one_zero" dependsOnModule="Module_One" dependsOnConfig="/one/two" /> + <add id="elem_one_one" toolTip='toolTip 2' title="Title one.one" module="Module_One" sortOrder="90" action="adminhtml/system" parent="elem_one_zero" resource="Module_One::one_one" /> <update id="elem_one_zero" toolTip='toolTip 3' title="Title one.zero update" module="Module_One_Update" sortOrder="90" action="adminhtml/system" parent="elem_one_zero" /> <remove id="elem_one_one" /> - <add id="elem_two_zero" toolTip='toolTip 4' title="Title two.zero" module="Module_Two" sortOrder="90" action="adminhtml/system" /> - <add id="elem_two_two" toolTip='toolTip 5' title="Title two.two" module="Module_Two" sortOrder="90" action="adminhtml/system" parent="elem_two_zero" /> + <add id="elem_two_zero" toolTip='toolTip 4' title="Title two.zero" module="Module_Two" sortOrder="90" action="adminhtml/system" resource="Module_Two::two_zero" /> + <add id="elem_two_two" toolTip='toolTip 5' title="Title two.two" module="Module_Two" sortOrder="90" action="adminhtml/system" parent="elem_two_zero" resource="Module_Two::two_two" /> <update id="elem_two_zero" toolTip='toolTip 6' title="Title two.zero update" module="Module_Two_Update" sortOrder="90" action="adminhtml/system" parent="elem_two_zero" /> <remove id="elem_two_two" /> </menu> diff --git a/dev/tests/unit/testsuite/Mage/Core/Model/Acl/BuilderTest.php b/dev/tests/unit/testsuite/Mage/Core/Model/Acl/BuilderTest.php new file mode 100644 index 00000000000..c0bbfecdcf1 --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/Core/Model/Acl/BuilderTest.php @@ -0,0 +1,142 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Magento + * @package Mage_Core + * @subpackage unit_tests + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +class Mage_Core_Model_Acl_BuilderTest extends PHPUnit_Framework_TestCase +{ + /** + * @var PHPUnit_Framework_MockObject_MockObject + */ + protected $_objectFactoryMock; + + /** + * @var PHPUnit_Framework_MockObject_MockObject + */ + protected $_aclMock; + + /** + * @var stdClass + */ + protected $_areaConfigMock; + + public function setUp() + { + $this->_aclMock = $this->getMock('Magento_Acl'); + $this->_objectFactoryMock = $this->getMock('Mage_Core_Model_Config', array(), array(), '', false); + $this->_objectFactoryMock->expects($this->at(0)) + ->method('getModelInstance') + ->with($this->equalTo('Magento_Acl')) + ->will($this->returnValue($this->_aclMock)); + $this->_areaConfigMock = new StdClass(); + } + + protected function _createModel($config) + { + return new Mage_Core_Model_Acl_Builder(array( + 'objectFactory' => $this->_objectFactoryMock, + 'areaConfig' => $config + )); + } + + public function testGetAclUsesDefaultLoadersWhenNothingSetInConfiguration() + { + $defaultLoaderMock = $this->getMock('Magento_Acl_Loader_Default'); + $defaultLoaderMock->expects($this->exactly(3)) + ->method('populateAcl') + ->with($this->equalTo($this->_aclMock)); + + $this->_objectFactoryMock->expects($this->at(1)) + ->method('getModelInstance') + ->with($this->equalTo('Magento_Acl_Loader_Default')) + ->will($this->returnValue($defaultLoaderMock)); + $this->_objectFactoryMock->expects($this->at(2)) + ->method('getModelInstance') + ->with($this->equalTo('Magento_Acl_Loader_Default')) + ->will($this->returnValue($defaultLoaderMock)); + $this->_objectFactoryMock->expects($this->at(3)) + ->method('getModelInstance') + ->with($this->equalTo('Magento_Acl_Loader_Default')) + ->will($this->returnValue($defaultLoaderMock)); + $model = $this->_createModel(array( + 'acl' => array( + 'resourceLoader' => null, + 'ruleLoader' => null, + 'roleLoader' => null, + ) + )); + + $this->assertEquals($this->_aclMock, $model->getAcl()); + } + + public function testGetAclUsesLoadersProvidedInconfigurationToPopulateAcl() + { + $defaultLoaderMock = $this->getMock('Magento_Acl_Loader_Default'); + $defaultLoaderMock->expects($this->exactly(3)) + ->method('populateAcl') + ->with($this->equalTo($this->_aclMock)); + + $this->_objectFactoryMock->expects($this->at(1)) + ->method('getModelInstance') + ->with($this->equalTo('test1')) + ->will($this->returnValue($defaultLoaderMock)); + $this->_objectFactoryMock->expects($this->at(2)) + ->method('getModelInstance') + ->with($this->equalTo('test2')) + ->will($this->returnValue($defaultLoaderMock)); + $this->_objectFactoryMock->expects($this->at(3)) + ->method('getModelInstance') + ->with($this->equalTo('test3')) + ->will($this->returnValue($defaultLoaderMock)); + + $model = $this->_createModel(array( + 'acl' => array( + 'resourceLoader' => 'test1', + 'roleLoader' => 'test2', + 'ruleLoader' => 'test3', + ) + )); + + $this->assertEquals($this->_aclMock, $model->getAcl()); + } + + /** + * @expectedException LogicException + */ + public function testGetAclRethrowsException() + { + $this->_objectFactoryMock->expects($this->once()) + ->method('getModelInstance') + ->will($this->throwException(new InvalidArgumentException())); + $model = $this->_createModel(array( + 'acl' => array( + 'resourceLoader' => 'default', + 'roleLoader' => 'default', + 'ruleLoader' => 'default', + ) + )); + $model->getAcl(); + } +} diff --git a/dev/tests/unit/testsuite/Mage/Eav/Model/Entity/AbstractTest.php b/dev/tests/unit/testsuite/Mage/Eav/Model/Entity/AbstractTest.php new file mode 100644 index 00000000000..82d268a88d9 --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/Eav/Model/Entity/AbstractTest.php @@ -0,0 +1,99 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Magento + * @package Mage_Eav + * @subpackage unit_tests + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +class Mage_Eav_Model_Entity_AbstractTest extends PHPUnit_Framework_TestCase +{ + /** + * Entity model to be tested + * @var Mage_Eav_Model_Entity_Abstract|PHPUnit_Framework_MockObject_MockObject + */ + protected $_model; + + protected function setUp() + { + $this->_model = $this->getMockForAbstractClass('Mage_Eav_Model_Entity_Abstract'); + } + + protected function tearDown() + { + $this->_model = null; + } + + /** + * @param array $attribute1SetInfo + * @param array $attribute2SetInfo + * @param float $expected + * @dataProvider compareAttributesDataProvider + */ + public function testCompareAttributes($attribute1Sort, $attribute2Sort, $expected) + { + $attribute1 = $this->getMock('Mage_Eav_Model_Entity_Attribute', null, array(), '', false); + $attribute1->setAttributeSetInfo(array(0 => $attribute1Sort)); + $attribute2 = $this->getMock('Mage_Eav_Model_Entity_Attribute', null, array(), '', false); + $attribute2->setAttributeSetInfo(array(0 => $attribute2Sort)); + $this->assertEquals($expected, $this->_model->attributesCompare($attribute1, $attribute2)); + } + + public static function compareAttributesDataProvider() + { + return array( + 'attribute1 bigger than attribute2' => array( + 'attribute1Sort' => array( + 'group_sort' => 7, + 'sort' => 5 + ), + 'attribute2Sort' => array( + 'group_sort' => 5, + 'sort' => 10 + ), + 'expected' => 1 + ), + 'attribute1 smaller than attribute2' => array( + 'attribute1Sort' => array( + 'group_sort' => 7, + 'sort' => 5 + ), + 'attribute2Sort' => array( + 'group_sort' => 7, + 'sort' => 10 + ), + 'expected' => -1 + ), + 'attribute1 equals to attribute2' => array( + 'attribute1Sort' => array( + 'group_sort' => 7, + 'sort' => 5 + ), + 'attribute2Sort' => array( + 'group_sort' => 7, + 'sort' => 5 + ), + 'expected' => 0 + ), + ); + } +} diff --git a/dev/tests/unit/testsuite/Mage/Eav/Model/Entity/AttributeTest.php b/dev/tests/unit/testsuite/Mage/Eav/Model/Entity/AttributeTest.php index d6cf3351106..10113219e97 100644 --- a/dev/tests/unit/testsuite/Mage/Eav/Model/Entity/AttributeTest.php +++ b/dev/tests/unit/testsuite/Mage/Eav/Model/Entity/AttributeTest.php @@ -27,6 +27,22 @@ class Mage_Eav_Model_Entity_AttributeTest extends PHPUnit_Framework_TestCase { + /** + * Attribute model to be tested + * @var Mage_Eav_Model_Entity_Attribute|PHPUnit_Framework_MockObject_MockObject + */ + protected $_model; + + protected function setUp() + { + $this->_model = $this->getMock('Mage_Eav_Model_Entity_Attribute', null, array(), '', false); + } + + protected function tearDown() + { + $this->_model = null; + } + /** * @param string $givenFrontendInput * @param string $expectedBackendType @@ -34,8 +50,7 @@ class Mage_Eav_Model_Entity_AttributeTest extends PHPUnit_Framework_TestCase */ public function testGetBackendTypeByInput($givenFrontendInput, $expectedBackendType) { - $model = $this->getMock('Mage_Eav_Model_Entity_Attribute', null, array(), '', false); - $this->assertEquals($expectedBackendType, $model->getBackendTypeByInput($givenFrontendInput)); + $this->assertEquals($expectedBackendType, $this->_model->getBackendTypeByInput($givenFrontendInput)); } public static function dataGetBackendTypeByInput() @@ -63,8 +78,7 @@ class Mage_Eav_Model_Entity_AttributeTest extends PHPUnit_Framework_TestCase */ public function testGetDefaultValueByInput($givenFrontendInput, $expectedDefaultValue) { - $model = $this->getMock('Mage_Eav_Model_Entity_Attribute', null, array(), '', false); - $this->assertEquals($expectedDefaultValue, $model->getDefaultValueByInput($givenFrontendInput)); + $this->assertEquals($expectedDefaultValue, $this->_model->getDefaultValueByInput($givenFrontendInput)); } public static function dataGetDefaultValueByInput() @@ -84,4 +98,48 @@ class Mage_Eav_Model_Entity_AttributeTest extends PHPUnit_Framework_TestCase array('boolean', 'default_value_yesno'), ); } + + /** + * @param array|null $sortWeights + * @param float $expected + * @dataProvider getSortWeightDataProvider + */ + public function testGetSortWeight($sortWeights, $expected) + { + $setId = 123; + $this->_model->setAttributeSetInfo(array($setId => $sortWeights)); + $this->assertEquals($expected, $this->_model->getSortWeight($setId)); + } + + /** + * @return array + */ + public function getSortWeightDataProvider() + { + return array( + 'empty set info' => array( + 'sortWeights' => null, + 'expectedWeight' => 0 + ), + 'no group sort' => array( + 'sortWeights' => array( + 'sort' => 5 + ), + 'expectedWeight' => 0.0005 + ), + 'no sort' => array( + 'sortWeights' => array( + 'group_sort' => 7 + ), + 'expectedWeight' => 7000 + ), + 'group sort and sort' => array( + 'sortWeights' => array( + 'group_sort' => 7, + 'sort' => 5 + ), + 'expectedWeight' => 7000.0005 + ), + ); + } } diff --git a/dev/tests/unit/testsuite/Mage/User/Model/Acl/Loader/RoleTest.php b/dev/tests/unit/testsuite/Mage/User/Model/Acl/Loader/RoleTest.php new file mode 100644 index 00000000000..e7bbd271edc --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/User/Model/Acl/Loader/RoleTest.php @@ -0,0 +1,118 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Mage + * @package Mage_User + * @subpackage unit_tests + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +class Mage_User_Model_Acl_Loader_RoleTest extends PHPUnit_Framework_TestCase +{ + /** + * @var Mage_User_Model_Acl_Loader_Role + */ + protected $_model; + + /** + * @var PHPUnit_Framework_MockObject_MockObject + */ + protected $_resourceMock; + + /** + * @var PHPUnit_Framework_MockObject_MockObject + */ + protected $_objectFactoryMock; + + /** + * @var PHPUnit_Framework_MockObject_MockObject + */ + protected $_adapterMock; + + public function setUp() + { + $this->_resourceMock = $this->getMock('Mage_Core_Model_Resource'); + $this->_objectFactoryMock = $this->getMock('Mage_Core_Model_Config', array(), array(), '', false); + + $this->_resourceMock->expects($this->once()) + ->method('getTableName') + ->with($this->equalTo('admin_role')) + ->will($this->returnArgument(1)); + + + $selectMock = $this->getMock('Varien_Db_Select', array(), array(), '', false); + $selectMock->expects($this->any()) + ->method('from') + ->will($this->returnValue($selectMock)); + + $this->_adapterMock = $this->getMock('Varien_Db_Adapter_Pdo_Mysql', array(), array(), '', false); + $this->_adapterMock->expects($this->once()) + ->method('select') + ->will($this->returnValue($selectMock)); + + $this->_resourceMock->expects($this->once()) + ->method('getConnection') + ->will($this->returnValue($this->_adapterMock)); + + $this->_model = new Mage_User_Model_Acl_Loader_Role(array( + 'resource' => $this->_resourceMock, + 'objectFactory' => $this->_objectFactoryMock + )); + } + + public function testPopulateAclAddsRolesAndTheirChildren() + { + $this->_adapterMock->expects($this->once()) + ->method('fetchAll') + ->will($this->returnValue(array( + array('role_id' => 1, 'role_type' => 'G', 'parent_id' => null), + array('role_id' => 2, 'role_type' => 'U', 'parent_id' => 1, 'user_id' => 1), + ))); + + + $this->_objectFactoryMock->expects($this->at(0))->method('getModelInstance')->with($this->anything(), 'G1'); + $this->_objectFactoryMock->expects($this->at(1))->method('getModelInstance')->with($this->anything(), 'U1'); + + $aclMock = $this->getMock('Magento_Acl'); + $aclMock->expects($this->at(0))->method('addRole')->with($this->anything(), null); + $aclMock->expects($this->at(2))->method('addRole')->with($this->anything(), 'G1'); + + $this->_model->populateAcl($aclMock); + } + + public function testPopulateAclAddsMultipleParents() + { + $this->_adapterMock->expects($this->once()) + ->method('fetchAll') + ->will($this->returnValue(array( + array('role_id' => 1, 'role_type' => 'U', 'parent_id' => 1, 'user_id' => 1), + ))); + + $this->_objectFactoryMock->expects($this->never())->method('getModelInstance'); + + $aclMock = $this->getMock('Magento_Acl'); + $aclMock->expects($this->at(0))->method('hasRole')->with('U1') + ->will($this->returnValue(true)); + $aclMock->expects($this->at(1))->method('addRoleParent')->with('U1', 'G1'); + + $this->_model->populateAcl($aclMock); + } +} diff --git a/dev/tests/unit/testsuite/Mage/User/Model/Acl/Loader/RuleTest.php b/dev/tests/unit/testsuite/Mage/User/Model/Acl/Loader/RuleTest.php new file mode 100644 index 00000000000..51b5e6ad1c8 --- /dev/null +++ b/dev/tests/unit/testsuite/Mage/User/Model/Acl/Loader/RuleTest.php @@ -0,0 +1,81 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Mage + * @package Mage_User + * @subpackage unit_tests + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +class Mage_User_Model_Acl_Loader_RuleTest extends PHPUnit_Framework_TestCase +{ + /** + * @var Mage_User_Model_Acl_Loader_Rule + */ + protected $_model; + + /** + * @var PHPUnit_Framework_MockObject_MockObject + */ + protected $_resourceMock; + + public function setUp() + { + $this->_resourceMock = $this->getMock('Mage_Core_Model_Resource'); + $this->_model = new Mage_User_Model_Acl_Loader_Rule(array( + 'resource' => $this->_resourceMock + )); + } + + public function testPopulateAcl() + { + $this->_resourceMock->expects($this->any())->method('getTable')->will($this->returnArgument(1)); + + $selectMock = $this->getMock('Varien_Db_Select', array(), array(), '', false); + $selectMock->expects($this->any()) + ->method('from') + ->will($this->returnValue($selectMock)); + + $adapterMock = $this->getMock('Varien_Db_Adapter_Pdo_Mysql', array(), array(), '', false); + $adapterMock->expects($this->once()) + ->method('select') + ->will($this->returnValue($selectMock)); + $adapterMock->expects($this->once()) + ->method('fetchAll') + ->will($this->returnValue(array( + array('role_id' => 1, 'role_type' => 'G', 'resource_id' => 'Mage_Adminhtml::all', 'permission' => 'allow'), + array('role_id' => 2, 'role_type' => 'U', 'resource_id' => 1, 'permission' => 'allow'), + array('role_id' => 3, 'role_type' => 'U', 'resource_id' => 1, 'permission' => 'deny'), + ))); + + $this->_resourceMock->expects($this->once()) + ->method('getConnection') + ->will($this->returnValue($adapterMock)); + + $aclMock = $this->getMock('Magento_Acl'); + $aclMock->expects($this->at(0))->method('allow')->with('G1', null, null); + $aclMock->expects($this->at(1))->method('allow')->with('G1', 'Mage_Adminhtml::all', null); + $aclMock->expects($this->at(2))->method('allow')->with('U2', 1, null); + $aclMock->expects($this->at(3))->method('deny')->with('U3', 1, null); + + $this->_model->populateAcl($aclMock); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Acl/Loader/DefaultTest.php b/dev/tests/unit/testsuite/Magento/Acl/Loader/DefaultTest.php new file mode 100644 index 00000000000..be05acce085 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Acl/Loader/DefaultTest.php @@ -0,0 +1,48 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Magento + * @package unit_tests + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +class Magento_Acl_Loader_DefaultTest extends PHPUnit_Framework_TestCase +{ + /** + * @var Magento_Acl_Loader_Default + */ + protected $_model; + + public function setUp() + { + $this->_model = new Magento_Acl_Loader_Default(); + } + + public function testPopulateAclDoesntChangeAclObject() + { + $aclMock = $this->getMock('Magento_Acl'); + $aclMock->expects($this->never())->method('addRole'); + $aclMock->expects($this->never())->method('addResource'); + $aclMock->expects($this->never())->method('allow'); + $aclMock->expects($this->never())->method('deny'); + $this->_model->populateAcl($aclMock); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Config/_files/dom/ids_merged.xml b/dev/tests/unit/testsuite/Magento/Config/_files/dom/ids_merged.xml index 0a9d5ae17ef..ae2233d8324 100644 --- a/dev/tests/unit/testsuite/Magento/Config/_files/dom/ids_merged.xml +++ b/dev/tests/unit/testsuite/Magento/Config/_files/dom/ids_merged.xml @@ -30,7 +30,7 @@ <node> <entity>entity_value2</entity> <subnode id="my_id1" some_attribute="attribute_value1"/> - <subnode id="my_id2" some_attribute="attribute_value_new"> + <subnode id="my_id2" some_attribute="attribute_value_new" extra_attribute="extra_attribute_value"> <child><![CDATA[<test_value>]]></child> </subnode> <subnode id="my_id3" some_attribute="attribute_value3"/> diff --git a/dev/tests/unit/testsuite/Magento/Config/_files/dom/ids_new.xml b/dev/tests/unit/testsuite/Magento/Config/_files/dom/ids_new.xml index 91ad6d7772b..9cf24f45d0d 100644 --- a/dev/tests/unit/testsuite/Magento/Config/_files/dom/ids_new.xml +++ b/dev/tests/unit/testsuite/Magento/Config/_files/dom/ids_new.xml @@ -30,7 +30,7 @@ <node> <entity>entity_value2</entity> <subnode id="my_id3" some_attribute="attribute_value3"/> - <subnode id="my_id2" some_attribute="attribute_value_new"> + <subnode id="my_id2" some_attribute="attribute_value_new" extra_attribute="extra_attribute_value"> <child><![CDATA[<test_value>]]></child> </subnode> </node> diff --git a/dev/tests/unit/testsuite/tools/migration/Acl/GeneratorRemoveTest.php b/dev/tests/unit/testsuite/tools/migration/Acl/GeneratorRemoveTest.php new file mode 100644 index 00000000000..0d2a246a049 --- /dev/null +++ b/dev/tests/unit/testsuite/tools/migration/Acl/GeneratorRemoveTest.php @@ -0,0 +1,103 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Tools + * @package unit_tests + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +require_once realpath(dirname(__FILE__) . '/../../../../../../') . '/tools/migration/Acl/Generator.php'; +require_once realpath(dirname(__FILE__) . '/../../../../../../') . '/tools/migration/Acl/FileWriter.php'; +require_once realpath(dirname(__FILE__) . '/../../../../../../') . '/tools/migration/Acl/Formatter.php'; + +/** + * Tools_Migration_Acl_Generator remove test case + */ +class Tools_Migration_Acl_GeneratorRemoveTest extends PHPUnit_Framework_TestCase +{ + /** + * @var $model Tools_Migration_Acl_Generator + */ + protected $_model; + + /** + * @var string + */ + protected $_emptyFile; + + /** + * @var string + */ + protected $_notEmptyFile; + + /** + * @var PHPUnit_Framework_MockObject_MockObject + */ + protected $_xmlFormatterMock; + + /** + * @var PHPUnit_Framework_MockObject_MockObject + */ + protected $_fileWriterMock; + + public function setUp() + { + $fixturePath = realpath(__DIR__) . DIRECTORY_SEPARATOR . '_files'; + $path = $fixturePath . DIRECTORY_SEPARATOR . 'remove' . DIRECTORY_SEPARATOR; + + $this->_emptyFile = $path . 'empty.xml'; + $this->_notEmptyFile = $path . 'not_empty.xml'; + + $this->_xmlFormatterMock = $this->getMock('Tools_Migration_Acl_Formatter'); + $this->_fileWriterMock = $this->getMock('Tools_Migration_Acl_FileWriter'); + $this->_fileWriterMock->expects($this->once())->method('remove')->with($this->equalTo($this->_emptyFile)); + $this->_model = new Tools_Migration_Acl_Generator($this->_xmlFormatterMock, $this->_fileWriterMock); + } + + public function tearDown() + { + unset($this->_model); + } + + public function testRemoveAdminhtmlFiles() + { + $domEmpty = new DOMDocument(); + $domEmpty->load($this->_emptyFile); + + $domNotEmpty = new DOMDocument(); + $domNotEmpty->load($this->_notEmptyFile); + + $adminhtmlDomList = array( + $this->_emptyFile => $domEmpty, + $this->_notEmptyFile => $domNotEmpty, + ); + + $this->_model->setAdminhtmlDomList($adminhtmlDomList); + $expected = array( + 'removed' => array($this->_emptyFile), + 'not_removed' => array($this->_notEmptyFile), + 'artifacts' => array('AclXPathToAclId.log' => json_encode(array())), + ); + + $result = $this->_model->removeAdminhtmlFiles(); + $this->assertEquals($expected, $result); + } +} diff --git a/dev/tests/unit/testsuite/tools/migration/Acl/GeneratorSaveTest.php b/dev/tests/unit/testsuite/tools/migration/Acl/GeneratorSaveTest.php new file mode 100644 index 00000000000..b4bed22eeec --- /dev/null +++ b/dev/tests/unit/testsuite/tools/migration/Acl/GeneratorSaveTest.php @@ -0,0 +1,144 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Tools + * @package unit_tests + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +require_once realpath(dirname(__FILE__) . '/../../../../../../') . '/tools/migration/Acl/Generator.php'; +require_once realpath(dirname(__FILE__) . '/../../../../../../') . '/tools/migration/Acl/FileWriter.php'; +require_once realpath(dirname(__FILE__) . '/../../../../../../') . '/tools/migration/Acl/Formatter.php'; + +/** + * Tools_Migration_Acl test case + */ +class Tools_Migration_Acl_GeneratorSaveTest extends PHPUnit_Framework_TestCase +{ + /** + * @var $model Tools_Migration_Acl_Generator + */ + protected $_model; + + /** + * @var string + */ + protected $_fixturePath; + + /** + * @var string + */ + protected $_originFile; + + /** + * @var string + */ + protected $_aclFile; + + /** + * @var PHPUnit_Framework_MockObject_MockObject + */ + protected $_xmlFormatterMock; + + /** + * @var PHPUnit_Framework_MockObject_MockObject + */ + protected $_fileWriterMock; + + public function setUp() + { + $this->_xmlFormatterMock = $this->getMock('Tools_Migration_Acl_Formatter'); + $this->_fileWriterMock = $this->getMock('Tools_Migration_Acl_FileWriter'); + $this->_model = new Tools_Migration_Acl_Generator($this->_xmlFormatterMock, $this->_fileWriterMock); + + $this->_fixturePath = realpath(__DIR__) . DIRECTORY_SEPARATOR . '_files'; + $path = $this->_fixturePath . DIRECTORY_SEPARATOR . 'save' . DIRECTORY_SEPARATOR; + + $this->_originFile = $path . 'adminhtml.xml'; + $this->_aclFile = $path . 'adminhtml' . DIRECTORY_SEPARATOR . 'acl.xml'; + + $dom = new DOMDocument(); + $config = $dom->createElement('config'); + $dom->appendChild($config); + $acl = $dom->createElement('acl'); + $config->appendChild($acl); + $resources = $dom->createElement('resources'); + $acl->appendChild($resources); + + $resource1 = $dom->createElement('resource'); + $resource1->setAttribute('id', 'Map_Module::admin'); + $resources->appendChild($resource1); + + $resource2 = $dom->createElement('resource'); + $resource2->setAttribute('id', 'Module_One::customer'); + $resource2->setAttribute('title', 'Customers'); + $resource2->setAttribute('sortOrder', '40'); + $resource1->appendChild($resource2); + + $resource3 = $dom->createElement('resource'); + $resource3->setAttribute('id', 'Module_Two::group'); + $resource3->setAttribute('title', 'Customer Groups'); + $resource3->setAttribute('sortOrder', '10'); + $resource2->appendChild($resource3); + + $this->_model->setParsedDomList(array($this->_originFile => $dom)); + } + + public function tearDown() + { + unset($this->_model); + unset($this->_xmlFormatterMock); + unset($this->_fileWriterMock); + } + + public function testSaveAclFiles() + { + $domList = $this->_model->getParsedDomList(); + $dom = clone $domList[$this->_originFile]; + $dom->preserveWhiteSpace = false; + $dom->formatOutput = true; + + $this->_xmlFormatterMock->expects($this->once()) + ->method('parseString') + ->with($dom->saveXml(), array( + 'indent' => true, + 'input-xml' => true, + 'output-xml' => true, + 'add-xml-space' => false, + 'indent-spaces' => 4, + 'wrap' => 1000 + )) + ->will($this->returnCallback( + function($string) { + return 'formatted' . $string; + } + )); + + $this->_fileWriterMock->expects($this->once()) + ->method('write') + ->with( + $this->equalTo($this->_aclFile), + $this->stringStartsWith('formatted') + ); + + $this->_model->saveAclFiles(); + } +} diff --git a/dev/tests/unit/testsuite/tools/migration/Acl/GeneratorTest.php b/dev/tests/unit/testsuite/tools/migration/Acl/GeneratorTest.php new file mode 100644 index 00000000000..2ac0377e242 --- /dev/null +++ b/dev/tests/unit/testsuite/tools/migration/Acl/GeneratorTest.php @@ -0,0 +1,411 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Tools + * @package unit_tests + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +require_once realpath(dirname(__FILE__) . '/../../../../../../') . '/tools/migration/Acl/Generator.php'; +require_once realpath(dirname(__FILE__) . '/../../../../../../') . '/tools/migration/Acl/FileWriter.php'; +require_once realpath(dirname(__FILE__) . '/../../../../../../') . '/tools/migration/Acl/Formatter.php'; + +/** + * Tools_Migration_Acl_Generator test case + */ +class Tools_Migration_Acl_GeneratorTest extends PHPUnit_Framework_TestCase +{ + /** + * @var $model Tools_Migration_Acl_Generator + */ + protected $_model; + + /** + * @var string + */ + protected $_fixturePath; + + /** + * Adminhtml file list + * + * @var array + */ + protected $_adminhtmlFiles = array(); + + /** + * @var PHPUnit_Framework_MockObject_MockObject + */ + protected $_xmlFormatterMock; + + /** + * @var PHPUnit_Framework_MockObject_MockObject + */ + protected $_fileWriterMock; + + public function setUp() + { + $this->_xmlFormatterMock = $this->getMock('Tools_Migration_Acl_Formatter'); + $this->_fileWriterMock = $this->getMock('Tools_Migration_Acl_FileWriter'); + $this->_model = new Tools_Migration_Acl_Generator($this->_xmlFormatterMock, $this->_fileWriterMock); + + $this->_fixturePath = realpath(__DIR__) . DIRECTORY_SEPARATOR . '_files'; + + $prefix = $this->_fixturePath . DIRECTORY_SEPARATOR + . 'app' . DIRECTORY_SEPARATOR + . 'code' . DIRECTORY_SEPARATOR; + $suffix = DIRECTORY_SEPARATOR . 'etc' . DIRECTORY_SEPARATOR . 'adminhtml.xml'; + + $this->_adminhtmlFiles = array( + $prefix . 'local' . DIRECTORY_SEPARATOR . 'Namespace' . DIRECTORY_SEPARATOR . 'Module' . $suffix, + $prefix . 'community' . DIRECTORY_SEPARATOR . 'Namespace' . DIRECTORY_SEPARATOR . 'Module' . $suffix, + $prefix . 'core' . DIRECTORY_SEPARATOR . 'Enterprise' . DIRECTORY_SEPARATOR . 'Module' . $suffix, + $prefix . 'core' . DIRECTORY_SEPARATOR . 'Mage' . DIRECTORY_SEPARATOR . 'Module' . $suffix, + ); + + $this->_model->setAdminhtmlFiles($this->_adminhtmlFiles); + + $this->_model->setBasePath($this->_fixturePath); + } + + public function testGetCommentText() + { + $expected = PHP_EOL; + $expected .= '/**' . PHP_EOL; + $expected .= ' * {license_notice}' . PHP_EOL; + $expected .= ' *' . PHP_EOL; + $expected .= ' * @category Category' . PHP_EOL; + $expected .= ' * @package Module_Name' . PHP_EOL; + $expected .= ' * @copyright {copyright}' . PHP_EOL; + $expected .= ' * @license {license_link}' . PHP_EOL; + $expected .= ' */' . PHP_EOL; + + $this->assertEquals($expected, $this->_model->getCommentText('Category', 'Module_Name')); + } + + /** + * @param $filePath + * @param $expectedModuleName + * + * @dataProvider getModuleNameDataProvider + */ + public function testGetModuleName($filePath, $expectedModuleName) + { + $this->assertEquals($expectedModuleName, $this->_model->getModuleName($filePath), 'Incorrect Module Name'); + } + + /** + * @param $filePath + * @param $expectedCategory + * + * @dataProvider getCategoryDataProvider + */ + public function testGetCategory($filePath, $expectedCategory) + { + $this->assertEquals($expectedCategory, $this->_model->getCategory($filePath), 'Incorrect Category Name'); + } + + /** + * @return array + */ + public function getModuleNameDataProvider() + { + return array( + array( + 'filePath' => DIRECTORY_SEPARATOR + . 'app ' . DIRECTORY_SEPARATOR + . 'core ' . DIRECTORY_SEPARATOR + . 'Enterprise' . DIRECTORY_SEPARATOR + . 'ModuleOne' . DIRECTORY_SEPARATOR + . 'etc' . DIRECTORY_SEPARATOR + . 'adminhtml.xml', + 'moduleName' => 'Enterprise_ModuleOne', + ), + array( + 'filePath' => DIRECTORY_SEPARATOR + . 'app ' . DIRECTORY_SEPARATOR + . 'core ' . DIRECTORY_SEPARATOR + . 'Mage' . DIRECTORY_SEPARATOR + . 'ModuleOne' . DIRECTORY_SEPARATOR + . 'etc' . DIRECTORY_SEPARATOR + . 'adminhtml.xml', + 'moduleName' => 'Mage_ModuleOne', + ), + ); + } + + /** + * @return array + */ + public function getCategoryDataProvider() + { + return array( + array( + 'filePath' => DIRECTORY_SEPARATOR + . 'app ' . DIRECTORY_SEPARATOR + . 'core ' . DIRECTORY_SEPARATOR + . 'Enterprise' . DIRECTORY_SEPARATOR + . 'ModuleOne' . DIRECTORY_SEPARATOR + . 'etc' . DIRECTORY_SEPARATOR + . 'adminhtml.xml', + 'category' => 'Enterprise', + ), + array( + 'filePath' => DIRECTORY_SEPARATOR + . 'app ' . DIRECTORY_SEPARATOR + . 'core ' . DIRECTORY_SEPARATOR + . 'Mage' . DIRECTORY_SEPARATOR + . 'ModuleOne' . DIRECTORY_SEPARATOR + . 'etc' . DIRECTORY_SEPARATOR + . 'adminhtml.xml', + 'category' => 'Mage', + ), + ); + } + + public function testIsForwardedNode() + { + $this->assertTrue($this->_model->isForwardNode('children')); + $this->assertFalse($this->_model->isForwardNode('admin')); + } + + public function testIsMetaNode() + { + $metaNodes = array( + 'meta_one' => 'MetaOne', + 'meta_two' => 'MetaTwo', + ); + $this->_model->setMetaNodeNames($metaNodes); + $this->assertEquals($metaNodes, $this->_model->getMetaNodeNames()); + + $this->assertTrue($this->_model->isMetaNode('meta_one')); + $this->assertTrue($this->_model->isMetaNode('meta_two')); + $this->assertFalse($this->_model->isMetaNode('meta_three')); + } + + public function testIsValidNodeType() + { + $this->assertFalse($this->_model->isValidNodeType(0)); + $this->assertFalse($this->_model->isValidNodeType(null)); + $this->assertTrue($this->_model->isValidNodeType(1)); + } + + /** + * @param $expectedPath + * @param $codePool + * @param $namespace + * @dataProvider getEtcPatternDataProvider + */ + public function testGetEtcPattern($expectedPath, $codePool, $namespace) + { + $this->assertStringEndsWith($expectedPath, $this->_model->getEtcDirPattern($codePool, $namespace)); + } + + /** + * @return array + */ + public function getEtcPatternDataProvider() + { + return array( + array( + 'expectedPath' => DIRECTORY_SEPARATOR + . 'app' . DIRECTORY_SEPARATOR + . 'code' . DIRECTORY_SEPARATOR + . '*' . DIRECTORY_SEPARATOR + . '*' . DIRECTORY_SEPARATOR + . '*' . DIRECTORY_SEPARATOR + . 'etc' . DIRECTORY_SEPARATOR, + 'codePool' => '*', + 'namespace' => '*', + ), + array( + 'expectedPath' => DIRECTORY_SEPARATOR + . 'app' . DIRECTORY_SEPARATOR + . 'code' . DIRECTORY_SEPARATOR + . 'core' . DIRECTORY_SEPARATOR + . 'Mage' . DIRECTORY_SEPARATOR + . '*' . DIRECTORY_SEPARATOR + . 'etc' . DIRECTORY_SEPARATOR, + 'codePool' => 'core', + 'namespace' => 'Mage', + ), + ); + } + + public function testCreateNode() + { + $dom = new DOMDocument(); + $parent = $dom->createElement('parent'); + $parent->setAttribute('xpath', 'root'); + $dom->appendChild($parent); + $nodeName = 'testNode'; + $newNode = $this->_model->createNode($dom, $nodeName, $parent, 'Some_Module'); + + $this->assertEquals(1, $parent->childNodes->length); + $this->assertEquals($newNode, $parent->childNodes->item(0)); + $this->assertEquals($nodeName, $newNode->getAttribute('id')); + $this->assertEquals('root/testNode', $newNode->getAttribute('xpath')); + } + + public function testSetMetaInfo() + { + $metaNodeName = array( + 'sort_order' => 'test_SortOrder', + 'title' => 'test_Title', + ); + $this->_model->setMetaNodeNames($metaNodeName); + + $dom = new DOMDocument(); + $parent = $dom->createElement('parent'); + $parent->setAttribute('xpath', 'root'); + $parent->setAttribute('id', 'root_id'); + $dom->appendChild($parent); + + $dataNodeSortOrder = $dom->createElement('sort_order', '100'); + $dataNodeTitle = $dom->createElement('title', 'TestTitle'); + + $this->_model->setMetaInfo($parent, $dataNodeSortOrder, 'Module_Name'); + $this->assertEmpty($this->_model->getAclResourceMaps()); + $this->_model->setMetaInfo($parent, $dataNodeTitle, 'Module_Name'); + + $this->assertEquals(100, $parent->getAttribute('test_SortOrder'), 'Incorrect set of sort order'); + $this->assertEquals('TestTitle', $parent->getAttribute('test_Title'), 'Incorrect set of title'); + $maps = array('root' => 'Module_Name::root_id'); + $this->assertEquals($maps, $this->_model->getAclResourceMaps()); //test setting of id maps + } + + public function testGetAdminhtmlFiles() + { + $this->_model->setAdminhtmlFiles(null); + $this->assertEquals($this->_adminhtmlFiles, + $this->_model->getAdminhtmlFiles(), + 'Incorrect file adminhtml file searching' + ); + } + + /** + * @covers Tools_Migration_Acl_Generator::parseNode + * @covers Tools_Migration_Acl_Generator::generateId + */ + public function testParseNode() + { + $dom = new DOMDocument(); + $dom->formatOutput = true; + $parentNode = $dom->createElement('root'); + $dom->appendChild($parentNode); + $moduleName = 'Module_Name'; + + $sourceDom = new DOMDocument(); + $sourceDom->load($this->_fixturePath . DIRECTORY_SEPARATOR . 'parse_node_source.xml'); + $nodeList = $sourceDom->getElementsByTagName('resources'); + $this->_model->parseNode($nodeList->item(0), $dom, $parentNode, $moduleName); + $expectedDom = new DOMDocument(); + $expectedDom->load($this->_fixturePath . DIRECTORY_SEPARATOR . 'parse_node_result.xml'); + $this->assertEquals($expectedDom->saveXML($expectedDom->documentElement), $dom->saveXML($dom->documentElement)); + } + + public function testGetResultDomDocument() + { + $dom = $this->_model->getResultDomDocument('Module_Name', 'Category'); + $expectedDom = new DOMDocument(); + $expectedDom->formatOutput = true; + + $file = $this->_fixturePath . DIRECTORY_SEPARATOR . 'template_document.xml'; + $expectedDom->load($file); + $this->assertContains('{license_notice}', $dom->saveXML()); + $this->assertEquals($expectedDom->saveXML($expectedDom->documentElement), $dom->saveXML($dom->documentElement)); + } + + public function testParseAdminhtmlFiles() + { + $this->_model->parseAdminhtmlFiles(); + $this->assertCount(4, $this->_model->getParsedDomList()); + $this->assertCount(4, $this->_model->getAdminhtmlDomList()); + } + + /** + * @covers Tools_Migration_Acl_Generator::updateAclResourceIds() + * @covers Tools_Migration_Acl_Generator::updateChildAclNodes() (removing of xpath attribute) + */ + public function testUpdateAclResourceIds() + { + $this->_model->parseAdminhtmlFiles(); + + $domList = $this->_model->getParsedDomList(); + + /** @var $dom DOMDocument **/ + foreach ($domList as $dom) { + $xpath = new DOMXPath($dom); + $resources = $xpath->query('//resources[@xpath]'); + $this->assertEquals(1, $resources->length); + } + $this->_model->updateAclResourceIds(); + /** + * check that all xpath attributes are removed + */ + /** @var $dom DOMDocument **/ + foreach ($domList as $dom) { + $xpath = new DOMXPath($dom); + $resources = $xpath->query('//*[@xpath]'); + $this->assertEquals(0, $resources->length); + } + } + + public function testUpdateChildAclNodes() + { + $dom = new DOMDocument(); + $fileActual = $this->_fixturePath . DIRECTORY_SEPARATOR . 'update_child_acl_nodes_source.xml'; + $fileExpected = $this->_fixturePath . DIRECTORY_SEPARATOR . 'update_child_acl_nodes_result.xml'; + $dom->load($fileActual); + $rootNode = $dom->getElementsByTagName('resources')->item(0); + + $aclResourcesMaps = array( + '/admin' => 'Map_Module::admin', + '/admin/customer/manage' => 'Map_Module::manage', + '/admin/system' => 'Map_Module::system', + '/admin/system/config' => 'Map_Module::config', + ); + + $this->_model->setAclResourceMaps($aclResourcesMaps); + $this->_model->updateChildAclNodes($rootNode); + + $expectedDom = new DOMDocument(); + $expectedDom->load($fileExpected); + $expectedRootNode = $expectedDom->getElementsByTagName('resources')->item(0); + + $this->assertEquals($expectedDom->saveXML($expectedRootNode), $dom->saveXML($rootNode)); + } + + public function testIsNodeEmpty() + { + $dom = new DOMDocument(); + $node = $dom->createElement('node', 'test'); + $dom->appendChild($node); + $this->assertTrue($this->_model->isNodeEmpty($node)); + + $comment = $dom->createComment('comment'); + $node->appendChild($comment); + $this->assertTrue($this->_model->isNodeEmpty($node)); + + $subNode = $dom->createElement('subnode'); + $node->appendChild($subNode); + $this->assertFalse($this->_model->isNodeEmpty($node)); + } +} diff --git a/dev/tests/unit/testsuite/tools/migration/Acl/Menu/GeneratorTest.php b/dev/tests/unit/testsuite/tools/migration/Acl/Menu/GeneratorTest.php new file mode 100644 index 00000000000..183d80a24e7 --- /dev/null +++ b/dev/tests/unit/testsuite/tools/migration/Acl/Menu/GeneratorTest.php @@ -0,0 +1,276 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Tools + * @package unit_tests + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +require_once realpath(dirname(__FILE__) . '/../../../../../../../') . '/tools/migration/Acl/Menu/Generator.php'; + +/** + * Tools_Migration_Acl_Menu_Generator_Menu generate test case + */ +class Tools_Migration_Acl_Menu_GeneratorTest extends PHPUnit_Framework_TestCase +{ + /** + * @var $model Tools_Migration_Acl_Menu_Generator + */ + protected $_model; + + /** + * @var string + */ + protected $_fixturePath; + + /** + * @var array + */ + protected $_menuFiles = array(); + + /** + * @var array + */ + protected $_menuIdToXPath = array(); + + /** + * @var PHPUnit_Framework_MockObject_MockObject + */ + protected $_fileWriterMock; + + + public function setUp() + { + $this->_fixturePath = realpath(__DIR__ . '/../') . DIRECTORY_SEPARATOR . '_files'; + + $aclXPathToId = array( + 'config/acl/resources/admin/system' => 'Module_Name::acl_resource', + 'config/acl/resources/admin/area_config/design/node' => 'Module_Name::acl_resource_design', + 'config/acl/resources/admin/area_config' => 'Module_Name::acl_resource_area', + 'config/acl/resources/admin/some_other_resource' => 'Module_Name::some_other_resource', + ); + $this->_fileWriterMock = $this->getMock('Tools_Migration_Acl_FileWriter'); + + $this->_model = new Tools_Migration_Acl_Menu_Generator( + $this->_fixturePath, + array(1), + $aclXPathToId, + $this->_fileWriterMock, + false + ); + + $prefix = $this->_fixturePath . DIRECTORY_SEPARATOR + . 'app' . DIRECTORY_SEPARATOR + . 'code' . DIRECTORY_SEPARATOR; + $suffix = DIRECTORY_SEPARATOR . 'etc' . DIRECTORY_SEPARATOR . 'adminhtml' . DIRECTORY_SEPARATOR . 'menu.xml'; + + $this->_menuFiles = array( + $prefix . 'community' . DIRECTORY_SEPARATOR . 'Namespace' . DIRECTORY_SEPARATOR . 'Module' . $suffix, + $prefix . 'core' . DIRECTORY_SEPARATOR . 'Enterprise' . DIRECTORY_SEPARATOR . 'Module' . $suffix, + $prefix . 'core' . DIRECTORY_SEPARATOR . 'Mage' . DIRECTORY_SEPARATOR . 'Module' . $suffix, + $prefix . 'local' . DIRECTORY_SEPARATOR . 'Namespace' . DIRECTORY_SEPARATOR . 'Module' . $suffix, + ); + + $this->_menuIdToXPath = array( + 'Module_Name::system' => '/some/resource', + 'Module_Name::system_config' => 'system/config', + 'Module_Name::area_config_design_node' => 'area_config/design/node', + 'Some_Module::area_config_design' => 'area_config/design', + 'Mage_Module::area_config' => 'area_config', + 'Local_Module::area_config_design_node_email_template' => 'area_config/design/node/email_template', + ); + } + + public function testGetEtcPattern() + { + $path = $this->_fixturePath . DIRECTORY_SEPARATOR + . 'app' . DIRECTORY_SEPARATOR + . 'code' . DIRECTORY_SEPARATOR + . '*' . DIRECTORY_SEPARATOR + . '*' . DIRECTORY_SEPARATOR + . '*' . DIRECTORY_SEPARATOR + . 'etc' . DIRECTORY_SEPARATOR; + + $this->assertEquals($path, $this->_model->getEtcDirPattern()); + } + + public function testGetMenuFiles() + { + $this->assertEquals($this->_menuFiles, $this->_model->getMenuFiles()); + } + + public function testParseMenuNode() + { + $menuFile = $this->_menuFiles[0]; + $dom = new DOMDocument(); + $dom->load($menuFile); + $node = $dom->getElementsByTagName('menu')->item(0); + $expected = array( + 'Module_Name::system' => array( + 'parent' => '', + 'resource' => '/some/resource', + ), + 'Module_Name::system_config' => array( + 'parent' => 'Module_Name::system', + 'resource' => '', + ), + 'Module_Name::area_config_design_node' => array( + 'parent' => 'Some_Module::area_config_design', + 'resource' => '', + ), + ); + + $this->assertEmpty($this->_model->getMenuIdMaps()); + $this->_model->parseMenuNode($node); + $this->assertEquals($expected, $this->_model->getMenuIdMaps()); + } + + public function testParseMenuFiles() + { + $this->_model->parseMenuFiles(); + /** + * Check that all nodes from all fixture files were read + */ + $this->assertEquals(6, count($this->_model->getMenuIdMaps())); + + /** + * Check that dom list is initialized + */ + $domList = $this->_model->getMenuDomList(); + $this->assertEquals(4, count($domList)); + $this->assertEquals($this->_menuFiles, array_keys($domList)); + $this->assertInstanceOf('DOMDocument', current($domList)); + } + + public function testInitParentItems() + { + $this->_model->parseMenuFiles(); + $menuId = 'Local_Module::area_config_design_node_email_template'; + + $maps = $this->_model->getMenuIdMaps(); + $this->assertArrayNotHasKey('parents', $maps[$menuId]); + + $this->_model->initParentItems($menuId); + + $expected = array( + 'Module_Name::area_config_design_node', + 'Some_Module::area_config_design', + 'Mage_Module::area_config', + ); + $maps = $this->_model->getMenuIdMaps(); + $this->assertEquals($expected, $maps[$menuId]['parents']); + } + + /** + * @covers Tools_Migration_Acl_Menu_Generator::buildMenuItemsXPath + * @covers Tools_Migration_Acl_Menu_Generator::buildXPath + */ + public function testBuildMenuItemsXPath() + { + $this->_model->parseMenuFiles(); + $this->assertEmpty($this->_model->getIdToXPath()); + + $this->_model->buildMenuItemsXPath(); + $maps = $this->_model->getIdToXPath(); + + $this->assertEquals($this->_menuIdToXPath, $maps); + } + + public function testMapMenuToAcl() + { + $this->assertEmpty($this->_model->getMenuIdToAclId()); + $this->_model->setIdToXPath($this->_menuIdToXPath); + $result = $this->_model->mapMenuToAcl(); + $map = $this->_model->getMenuIdToAclId(); + $expectedMap = array( + 'Module_Name::area_config_design_node' => 'Module_Name::acl_resource_design', + 'Mage_Module::area_config' => 'Module_Name::acl_resource_area', + ); + $this->assertEquals($expectedMap, $map); + $this->assertEquals(array_keys($expectedMap), $result['mapped']); + $this->assertEquals(4, count($result['not_mapped'])); + $this->assertEquals($expectedMap, json_decode(current($result['artifacts']), true)); + } + + public function testUpdateMenuAttributes() + { + $menuFileSource = $this->_fixturePath . DIRECTORY_SEPARATOR . 'update_menu_attributes_source.xml'; + $menuFileResult = $this->_fixturePath . DIRECTORY_SEPARATOR . 'update_menu_attributes_result.xml'; + + $domSource = new DOMDocument(); + $domSource->load($menuFileSource); + + $domExpected = new DOMDocument(); + $domExpected->load($menuFileResult); + + $domList = array( + $menuFileSource => $domSource, + ); + $menuIdToAclId = array( + 'item1' => 'acl1', + 'item2' => 'acl2', + 'item3' => 'acl3', + ); + $aclXPathToId = array( + 'config/acl/resources/admin/some/resource' => 'acl4', + 'config/acl/resources/admin/some_other_resource' => 'acl5', + ); + $this->_model->setMenuDomList($domList); + $this->_model->setMenuIdToAclId($menuIdToAclId); + $this->_model->setAclXPathToId($aclXPathToId); + + $errors = $this->_model->updateMenuAttributes(); + + $this->assertEquals($domExpected->saveXML(), $domSource->saveXML()); + $this->assertEquals(2, count($errors)); + + $this->assertContains('item4 is not mapped', $errors[0]); + $this->assertContains($menuFileSource, $errors[0]); + + $this->assertContains('no ACL resource with XPath', $errors[1]); + $this->assertContains($menuFileSource, $errors[1]); + } + + public function testSaveMenuFiles() + { + $dom = new DOMDocument(); + $menuDomList = array( + 'file1' => $dom, + 'file2' => $dom, + 'file3' => $dom, + ); + $this->_model->setMenuDomList($menuDomList); + + $this->_fileWriterMock->expects($this->at(0)) + ->method('write') + ->with($this->equalTo('file1'), $this->equalTo($dom->saveXML())); + + $this->_fileWriterMock->expects($this->at(1)) + ->method('write') + ->with($this->equalTo('file2'), $this->equalTo($dom->saveXML())); + + $this->_fileWriterMock->expects($this->at(2)) + ->method('write') + ->with($this->equalTo('file3'), $this->equalTo($dom->saveXML())); + + $this->_model->saveMenuFiles(); + } +} diff --git a/app/code/core/Mage/PageCache/etc/adminhtml.xml b/dev/tests/unit/testsuite/tools/migration/Acl/_files/app/code/community/Namespace/Module/etc/adminhtml.xml similarity index 78% rename from app/code/core/Mage/PageCache/etc/adminhtml.xml rename to dev/tests/unit/testsuite/tools/migration/Acl/_files/app/code/community/Namespace/Module/etc/adminhtml.xml index 66ff55a2eac..11b4d887037 100644 --- a/app/code/core/Mage/PageCache/etc/adminhtml.xml +++ b/dev/tests/unit/testsuite/tools/migration/Acl/_files/app/code/community/Namespace/Module/etc/adminhtml.xml @@ -20,7 +20,7 @@ * needs please refer to http://www.magentocommerce.com for more information. * * @category Mage - * @package Mage_PageCache + * @package Mage_Customer * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ @@ -29,12 +29,6 @@ <acl> <resources> <admin> - <children> - <page_cache translate="title" module="Mage_PageCache"> - <title>External Page Cache</title> - <sort_order>0</sort_order> - </page_cache> - </children> </admin> </resources> </acl> diff --git a/dev/tests/unit/testsuite/tools/migration/Acl/_files/app/code/community/Namespace/Module/etc/adminhtml/menu.xml b/dev/tests/unit/testsuite/tools/migration/Acl/_files/app/code/community/Namespace/Module/etc/adminhtml/menu.xml new file mode 100644 index 00000000000..a8b6ad1b337 --- /dev/null +++ b/dev/tests/unit/testsuite/tools/migration/Acl/_files/app/code/community/Namespace/Module/etc/adminhtml/menu.xml @@ -0,0 +1,35 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Mage + * @package Module_Name + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config> + <menu> + <add id="Module_Name::system" title="Title 1" module="Module_Name" sortOrder="50" action="adminhtml/level_one" resource='/some/resource' /> + <add id="Module_Name::system_config" title="Title 2" module="Module_Name" sortOrder="60" parent="Module_Name::system" action="adminhtml/level_two" /> + <update id="Module_Name::system_config" resource='/some_other_resource' /> + <add id="Module_Name::area_config_design_node" title="Title 3" module="Module_Name" sortOrder="70" parent="Some_Module::area_config_design" action="adminhtml/level_three" /> + </menu> +</config> diff --git a/app/code/core/Mage/Index/etc/adminhtml.xml b/dev/tests/unit/testsuite/tools/migration/Acl/_files/app/code/core/Enterprise/Module/etc/adminhtml.xml similarity index 74% rename from app/code/core/Mage/Index/etc/adminhtml.xml rename to dev/tests/unit/testsuite/tools/migration/Acl/_files/app/code/core/Enterprise/Module/etc/adminhtml.xml index 60a8b933d50..11b4d887037 100644 --- a/app/code/core/Mage/Index/etc/adminhtml.xml +++ b/dev/tests/unit/testsuite/tools/migration/Acl/_files/app/code/core/Enterprise/Module/etc/adminhtml.xml @@ -20,7 +20,7 @@ * needs please refer to http://www.magentocommerce.com for more information. * * @category Mage - * @package Mage_Index + * @package Mage_Customer * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ @@ -29,15 +29,6 @@ <acl> <resources> <admin> - <children> - <system> - <children> - <index translate="title"> - <title>Index Management</title> - </index> - </children> - </system> - </children> </admin> </resources> </acl> diff --git a/dev/tests/unit/testsuite/tools/migration/Acl/_files/app/code/core/Enterprise/Module/etc/adminhtml/menu.xml b/dev/tests/unit/testsuite/tools/migration/Acl/_files/app/code/core/Enterprise/Module/etc/adminhtml/menu.xml new file mode 100644 index 00000000000..e4516876e59 --- /dev/null +++ b/dev/tests/unit/testsuite/tools/migration/Acl/_files/app/code/core/Enterprise/Module/etc/adminhtml/menu.xml @@ -0,0 +1,32 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Some + * @package Some_Module + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config> + <menu> + <add id="Some_Module::area_config_design" title="Title 1" module="Some_Module" sortOrder="50" parent="Mage_Module::area_config" action="adminhtml/level_one" /> + </menu> +</config> diff --git a/app/code/core/Mage/CatalogSearch/etc/adminhtml.xml b/dev/tests/unit/testsuite/tools/migration/Acl/_files/app/code/core/Mage/Module/etc/adminhtml.xml similarity index 72% rename from app/code/core/Mage/CatalogSearch/etc/adminhtml.xml rename to dev/tests/unit/testsuite/tools/migration/Acl/_files/app/code/core/Mage/Module/etc/adminhtml.xml index 579d150d9c7..11b4d887037 100644 --- a/app/code/core/Mage/CatalogSearch/etc/adminhtml.xml +++ b/dev/tests/unit/testsuite/tools/migration/Acl/_files/app/code/core/Mage/Module/etc/adminhtml.xml @@ -20,7 +20,7 @@ * needs please refer to http://www.magentocommerce.com for more information. * * @category Mage - * @package Mage_CatalogSearch + * @package Mage_Customer * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ @@ -29,15 +29,6 @@ <acl> <resources> <admin> - <children> - <catalog> - <children> - <search translate="title" module="Mage_CatalogSearch"> - <title>Search Terms</title> - </search> - </children> - </catalog> - </children> </admin> </resources> </acl> diff --git a/dev/tests/unit/testsuite/tools/migration/Acl/_files/app/code/core/Mage/Module/etc/adminhtml/menu.xml b/dev/tests/unit/testsuite/tools/migration/Acl/_files/app/code/core/Mage/Module/etc/adminhtml/menu.xml new file mode 100644 index 00000000000..febc477dc9b --- /dev/null +++ b/dev/tests/unit/testsuite/tools/migration/Acl/_files/app/code/core/Mage/Module/etc/adminhtml/menu.xml @@ -0,0 +1,32 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Mage + * @package Mage_Module + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config> + <menu> + <add id="Mage_Module::area_config" title="Title 1" module="Mage_Module" sortOrder="50" action="adminhtml/level_one" /> + </menu> +</config> diff --git a/app/code/core/Mage/Poll/etc/adminhtml.xml b/dev/tests/unit/testsuite/tools/migration/Acl/_files/app/code/local/Namespace/Module/etc/adminhtml.xml similarity index 71% rename from app/code/core/Mage/Poll/etc/adminhtml.xml rename to dev/tests/unit/testsuite/tools/migration/Acl/_files/app/code/local/Namespace/Module/etc/adminhtml.xml index b992439786e..11b4d887037 100644 --- a/app/code/core/Mage/Poll/etc/adminhtml.xml +++ b/dev/tests/unit/testsuite/tools/migration/Acl/_files/app/code/local/Namespace/Module/etc/adminhtml.xml @@ -20,7 +20,7 @@ * needs please refer to http://www.magentocommerce.com for more information. * * @category Mage - * @package Mage_Poll + * @package Mage_Customer * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ @@ -29,16 +29,6 @@ <acl> <resources> <admin> - <children> - <cms> - <children> - <poll translate="title" module="Mage_Poll"> - <title>Polls</title> - <sort_order>20</sort_order> - </poll> - </children> - </cms> - </children> </admin> </resources> </acl> diff --git a/dev/tests/unit/testsuite/tools/migration/Acl/_files/app/code/local/Namespace/Module/etc/adminhtml/menu.xml b/dev/tests/unit/testsuite/tools/migration/Acl/_files/app/code/local/Namespace/Module/etc/adminhtml/menu.xml new file mode 100644 index 00000000000..0e67f4c1e00 --- /dev/null +++ b/dev/tests/unit/testsuite/tools/migration/Acl/_files/app/code/local/Namespace/Module/etc/adminhtml/menu.xml @@ -0,0 +1,32 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Local + * @package Local_Module + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config> + <menu> + <add id="Local_Module::area_config_design_node_email_template" title="Title 1" module="Local_Module" sortOrder="50" parent="Module_Name::area_config_design_node" action="adminhtml/level_one" /> + </menu> +</config> diff --git a/dev/tests/unit/testsuite/tools/migration/Acl/_files/parse_node_result.xml b/dev/tests/unit/testsuite/tools/migration/Acl/_files/parse_node_result.xml new file mode 100644 index 00000000000..43230d756c7 --- /dev/null +++ b/dev/tests/unit/testsuite/tools/migration/Acl/_files/parse_node_result.xml @@ -0,0 +1,41 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Dummy + * @package Module_Dummy + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<root> + <resource xpath="/admin" id="admin"> + <resource xpath="/admin/customer" id="customer" module="Mage_Customer" title="Customers" moduleOwner="Module_Name" sortOrder="40"> + <resource xpath="/admin/customer/group" id="group" title="Customer Groups" moduleOwner="Module_Name" sortOrder="10"/> + <resource xpath="/admin/customer/manage" id="manage" title="Manage Customers" moduleOwner="Module_Name" sortOrder="0"/> + <resource xpath="/admin/customer/online" id="online" title="Online Customers" moduleOwner="Module_Name" sortOrder="100"/> + </resource> + <resource xpath="/admin/system" id="system"> + <resource xpath="/admin/system/config" id="config"> + <resource xpath="/admin/system/config/customer" id="config_customer" module="Mage_Customer" title="Customers Section" moduleOwner="Module_Name" sortOrder="50"/> + </resource> + </resource> + </resource> +</root> diff --git a/app/code/core/Mage/SalesRule/etc/adminhtml.xml b/dev/tests/unit/testsuite/tools/migration/Acl/_files/parse_node_source.xml similarity index 55% rename from app/code/core/Mage/SalesRule/etc/adminhtml.xml rename to dev/tests/unit/testsuite/tools/migration/Acl/_files/parse_node_source.xml index 79a0484a12f..c69faace2e2 100644 --- a/app/code/core/Mage/SalesRule/etc/adminhtml.xml +++ b/dev/tests/unit/testsuite/tools/migration/Acl/_files/parse_node_source.xml @@ -19,8 +19,8 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Mage - * @package Mage_SalesRule + * @category Dummy + * @package Module_Dummy * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ @@ -30,20 +30,32 @@ <resources> <admin> <children> - <promo> + <customer translate="title" module="Mage_Customer"> + <title>Customers</title> + <sort_order>40</sort_order> <children> - <quote translate="title" module="Mage_SalesRule"> - <title>Shopping Cart Price Rules</title> - </quote> + <group translate="title"> + <title>Customer Groups</title> + <sort_order>10</sort_order> + </group> + <manage translate="title"> + <title>Manage Customers</title> + <sort_order>0</sort_order> + </manage> + <online translate="title"> + <title>Online Customers</title> + <sort_order>100</sort_order> + </online> </children> - </promo> + </customer> <system> <children> <config> <children> - <promo translate="title" module="Mage_SalesRule"> - <title>Shopping Cart Price Rules</title> - </promo> + <customer translate="title" module="Mage_Customer"> + <title>Customers Section</title> + <sort_order>50</sort_order> + </customer> </children> </config> </children> diff --git a/app/code/core/Mage/Cms/etc/adminhtml.xml b/dev/tests/unit/testsuite/tools/migration/Acl/_files/remove/empty.xml similarity index 51% rename from app/code/core/Mage/Cms/etc/adminhtml.xml rename to dev/tests/unit/testsuite/tools/migration/Acl/_files/remove/empty.xml index c53d9b63acb..bdfe0cbbd07 100644 --- a/app/code/core/Mage/Cms/etc/adminhtml.xml +++ b/dev/tests/unit/testsuite/tools/migration/Acl/_files/remove/empty.xml @@ -19,8 +19,8 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Mage - * @package Mage_Cms + * @category Dummy + * @package Module_Dummy * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ @@ -30,41 +30,32 @@ <resources> <admin> <children> - <cms translate="title" module="Mage_Cms"> - <title>CMS</title> - <sort_order>70</sort_order> + <customer translate="title" module="Mage_Customer"> + <title>Customers</title> + <sort_order>40</sort_order> <children> - <block translate="title"> - <title>Static Blocks</title> + <group translate="title"> + <title>Customer Groups</title> <sort_order>10</sort_order> - </block> - <page translate="title"> - <title>Pages</title> + </group> + <manage translate="title"> + <title>Manage Customers</title> <sort_order>0</sort_order> - <children> - <save translate="title"> - <title>Save Page</title> - <sort_order>0</sort_order> - </save> - <delete translate="title"> - <title>Delete Page</title> - <sort_order>10</sort_order> - </delete> - </children> - </page> - <media_gallery translate="title"> - <title>Media Gallery</title> - <sort_order>20</sort_order> - </media_gallery> + </manage> + <online translate="title"> + <title>Online Customers</title> + <sort_order>100</sort_order> + </online> </children> - </cms> + </customer> <system> <children> <config> <children> - <cms translate="title" module="Mage_Cms"> - <title>Content Management</title> - </cms> + <customer translate="title" module="Mage_Customer"> + <title>Customers Section</title> + <sort_order>50</sort_order> + </customer> </children> </config> </children> @@ -72,5 +63,21 @@ </children> </admin> </resources> + <privilegeSets> + <default> + <view> + <descr>View entity</descr> + </view> + <edit> + <descr>Edit entity</descr> + </edit> + <delete> + <descr/> + </delete> + <create> + <descr/> + </create> + </default> + </privilegeSets> </acl> </config> diff --git a/dev/tests/unit/testsuite/tools/migration/Acl/_files/remove/not_empty.xml b/dev/tests/unit/testsuite/tools/migration/Acl/_files/remove/not_empty.xml new file mode 100644 index 00000000000..86cf355563f --- /dev/null +++ b/dev/tests/unit/testsuite/tools/migration/Acl/_files/remove/not_empty.xml @@ -0,0 +1,85 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Dummy + * @package Module_Dummy + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config> + <acl> + <resources> + <admin> + <children> + <customer translate="title" module="Mage_Customer"> + <title>Customers</title> + <sort_order>40</sort_order> + <children> + <group translate="title"> + <title>Customer Groups</title> + <sort_order>10</sort_order> + </group> + <manage translate="title"> + <title>Manage Customers</title> + <sort_order>0</sort_order> + </manage> + <online translate="title"> + <title>Online Customers</title> + <sort_order>100</sort_order> + </online> + </children> + </customer> + <system> + <children> + <config> + <children> + <customer translate="title" module="Mage_Customer"> + <title>Customers Section</title> + <sort_order>50</sort_order> + </customer> + </children> + </config> + </children> + </system> + </children> + </admin> + </resources> + <privilegeSets> + <default> + <view> + <descr>View entity</descr> + </view> + <edit> + <descr>Edit entity</descr> + </edit> + <delete> + <descr/> + </delete> + <create> + <descr/> + </create> + </default> + </privilegeSets> + <some_other_node> + </some_other_node> + </acl> +</config> diff --git a/app/code/core/Mage/Customer/etc/adminhtml.xml b/dev/tests/unit/testsuite/tools/migration/Acl/_files/save/adminhtml.xml similarity index 98% rename from app/code/core/Mage/Customer/etc/adminhtml.xml rename to dev/tests/unit/testsuite/tools/migration/Acl/_files/save/adminhtml.xml index e665b98ccdc..c69faace2e2 100644 --- a/app/code/core/Mage/Customer/etc/adminhtml.xml +++ b/dev/tests/unit/testsuite/tools/migration/Acl/_files/save/adminhtml.xml @@ -19,8 +19,8 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Mage - * @package Mage_Customer + * @category Dummy + * @package Module_Dummy * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ diff --git a/dev/tests/unit/testsuite/tools/migration/Acl/_files/template_document.xml b/dev/tests/unit/testsuite/tools/migration/Acl/_files/template_document.xml new file mode 100644 index 00000000000..ea183ee9d55 --- /dev/null +++ b/dev/tests/unit/testsuite/tools/migration/Acl/_files/template_document.xml @@ -0,0 +1,32 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Category + * @package Module_Name + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config> + <acl> + <resources xpath="config/acl/resources"/> + </acl> +</config> diff --git a/dev/tests/unit/testsuite/tools/migration/Acl/_files/update_child_acl_nodes_result.xml b/dev/tests/unit/testsuite/tools/migration/Acl/_files/update_child_acl_nodes_result.xml new file mode 100644 index 00000000000..c2b70a3abea --- /dev/null +++ b/dev/tests/unit/testsuite/tools/migration/Acl/_files/update_child_acl_nodes_result.xml @@ -0,0 +1,45 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Category + * @package Module_Name + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config> + <acl> + <resources> + <resource id="Map_Module::admin"> + <resource id="Module_One::customer" title="Customers" module="Module_One" sortOrder="40" > + <resource id="Module_Two::group" title="Customer Groups" module="Module_Two" sortOrder="10" /> + <resource id="Map_Module::manage" title="Manage Customers" module="Module_Three" sortOrder="0"/> + <resource id="Module_Four::online" title="Online Customers" module="Module_Four" sortOrder="100"/> + </resource> + <resource id="Map_Module::system"> + <resource id="Map_Module::config"> + <resource id="Module_Five::customer" title="Customers Section" module="Module_Five" sortOrder="50"/> + </resource> + </resource> + </resource> + </resources> + </acl> +</config> diff --git a/dev/tests/unit/testsuite/tools/migration/Acl/_files/update_child_acl_nodes_source.xml b/dev/tests/unit/testsuite/tools/migration/Acl/_files/update_child_acl_nodes_source.xml new file mode 100644 index 00000000000..11143930994 --- /dev/null +++ b/dev/tests/unit/testsuite/tools/migration/Acl/_files/update_child_acl_nodes_source.xml @@ -0,0 +1,45 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Category + * @package Module_Name + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config> + <acl> + <resources> + <resource id="admin" xpath="/admin"> + <resource id="customer" xpath="/admin/customer" title="Customers" moduleOwner="Module_One" module="Module_One" sortOrder="40"> + <resource id="group" xpath="/admin/customer/group" moduleOwner="Module_Two" title="Customer Groups" module="Module_Two" sortOrder="10"/> + <resource id="manage" xpath="/admin/customer/manage" moduleOwner="Module_Three" title="Manage Customers" module="Module_Three" sortOrder="0"/> + <resource id="online" xpath="/admin/customer/online" moduleOwner="Module_Four" title="Online Customers" module="Module_Four" sortOrder="100"/> + </resource> + <resource id="system" xpath="/admin/system"> + <resource id="config" xpath="/admin/system/config"> + <resource id="customer" xpath="/admin/system/config/customer" title="Customers Section" moduleOwner="Module_Five" module="Module_Five" sortOrder="50"/> + </resource> + </resource> + </resource> + </resources> + </acl> +</config> diff --git a/dev/tests/unit/testsuite/tools/migration/Acl/_files/update_menu_attributes_result.xml b/dev/tests/unit/testsuite/tools/migration/Acl/_files/update_menu_attributes_result.xml new file mode 100644 index 00000000000..883174c8e81 --- /dev/null +++ b/dev/tests/unit/testsuite/tools/migration/Acl/_files/update_menu_attributes_result.xml @@ -0,0 +1,38 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Mage + * @package Module_Name + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config> + <menu> + <add id="item1" resource="acl4"/> + <add id="item2" resource="acl2"/> + <update id="item2" resource="acl5"/> + <add id="item3" resource="acl3"/> + <update id="item3"/> + <add id="item4"/> + <update id="item3" resource="dummy_resource"/> + </menu> +</config> diff --git a/dev/tests/unit/testsuite/tools/migration/Acl/_files/update_menu_attributes_source.xml b/dev/tests/unit/testsuite/tools/migration/Acl/_files/update_menu_attributes_source.xml new file mode 100644 index 00000000000..51519b75d0e --- /dev/null +++ b/dev/tests/unit/testsuite/tools/migration/Acl/_files/update_menu_attributes_source.xml @@ -0,0 +1,38 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Mage + * @package Module_Name + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config> + <menu> + <add id="item1" resource='some/resource' /> + <add id="item2" /> + <update id="item2" resource='some_other_resource' /> + <add id="item3" /> + <update id="item3" /> + <add id="item4" /> + <update id="item3" resource='dummy_resource'/> + </menu> +</config> diff --git a/dev/tools/migration/Acl/FileWriter.php b/dev/tools/migration/Acl/FileWriter.php new file mode 100644 index 00000000000..3761d63f578 --- /dev/null +++ b/dev/tools/migration/Acl/FileWriter.php @@ -0,0 +1,50 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Magento + * @package tools + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +class Tools_Migration_Acl_FileWriter +{ + /** + * @param string $fileName + * @param string $contents + */ + public function write($fileName, $contents) + { + if (false == is_dir(dirname($fileName))) { + mkdir(dirname($fileName), 0777, true); + } + file_put_contents($fileName, $contents); + } + + /** + * Remove file + * + * @param $fileName + */ + public function remove($fileName) + { + unlink($fileName); + } +} diff --git a/dev/tools/migration/Acl/Formatter.php b/dev/tools/migration/Acl/Formatter.php new file mode 100644 index 00000000000..5f94c09e836 --- /dev/null +++ b/dev/tools/migration/Acl/Formatter.php @@ -0,0 +1,38 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Magento + * @package tools + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +class Tools_Migration_Acl_Formatter +{ + /** + * @param string $string + * @param string $parameters + */ + public function parseString($string, $paramenters) + { + $tidy = tidy_parse_string($string, $paramenters); + return $tidy->value; + } +} diff --git a/dev/tools/migration/Acl/Generator.php b/dev/tools/migration/Acl/Generator.php new file mode 100644 index 00000000000..3dda9e046d4 --- /dev/null +++ b/dev/tools/migration/Acl/Generator.php @@ -0,0 +1,788 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Magento + * @package tools + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +require_once ( __DIR__ . '/Menu/Generator.php'); +require_once ( __DIR__ . '/FileWriter.php'); + +class Tools_Migration_Acl_Generator +{ + /** + * @var bool + */ + protected $_printHelp = false; + + /** + * Meta node names + * + * @var array + */ + protected $_metaNodeNames = array(); + + /** + * Adminhtml files + * + * @var array|null + */ + protected $_adminhtmlFiles = null; + + /** + * Parsed dom list + * + * @var array + */ + protected $_parsedDomList = array(); + + /** + * Map ACL resource xpath to id + * @var array + */ + protected $_aclResourceMaps = array(); + + /** + * Map Menu ids + * + * @var array + */ + protected $_menuIdMaps = array(); + + /** + * Base application path + * + * @var string|null + */ + protected $_basePath = null; + + /** + * Adminhtml DOMDocument list + * + * @var array + */ + protected $_adminhtmlDomList = array(); + + /** + * @var string + */ + protected $_artifactsPath; + + /** + * Is preview mode + * + * @var bool + */ + protected $_isPreviewMode = false; + + /** + * List of unique ACL ids + * + * @var array + */ + protected $_uniqueName = array(); + + /** + * @var Tools_Migration_Acl_Formatter + */ + protected $_xmlFormatter; + + /** + * @var Tools_Migration_Acl_FileWriter + */ + protected $_fileWriter; + + /** + * @param Tools_Migration_Acl_Formatter $xmlFormatter + * @param Tools_Migration_Acl_FileWriter $fileWriter + * @param array $options configuration options + */ + public function __construct( + Tools_Migration_Acl_Formatter $xmlFormatter, + Tools_Migration_Acl_FileWriter $fileWriter, + $options = array() + ) { + $this->_xmlFormatter = $xmlFormatter; + $this->_fileWriter = $fileWriter; + $this->_printHelp = array_key_exists('h', $options); + $this->_isPreviewMode = array_key_exists('p', $options); + + $this->_metaNodeNames = array( + 'sort_order' => 'sortOrder', + 'title' => 'title' + ); + + $this->_basePath = realpath(dirname(__FILE__) . '/../../../..'); + + $this->_artifactsPath = realpath(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'log' . DIRECTORY_SEPARATOR; + } + + /** + * Get Comment text + * + * @param $category string + * @param $package string + * @return string + */ + public function getCommentText($category, $package) + { + $comment = PHP_EOL; + $comment .= '/**' . PHP_EOL; + $comment .= ' * {license_notice}' . PHP_EOL; + $comment .= ' *' . PHP_EOL; + $comment .= ' * @category ' . $category . PHP_EOL; + $comment .= ' * @package ' . $package . PHP_EOL; + $comment .= ' * @copyright {copyright}' . PHP_EOL; + $comment .= ' * @license {license_link}' . PHP_EOL; + $comment .= ' */' . PHP_EOL; + + return $comment; + } + + /** + * Get module name from file name + * + * @param $fileName string + * @return string + */ + public function getModuleName($fileName) + { + $parts = array_reverse(explode(DIRECTORY_SEPARATOR, $fileName)); + $module = $parts[3] . '_' . $parts[2]; + return $module; + } + + /** + * Get category name from file name + * + * @param $fileName string + * @return string + */ + public function getCategory($fileName) + { + $parts = array_reverse(explode(DIRECTORY_SEPARATOR, $fileName)); + return $parts[3]; + } + + /** + * Get is forward node + * + * @param string $nodeName + * @return bool + */ + public function isForwardNode($nodeName) + { + return in_array($nodeName, $this->getForwardNodeNames()); + } + + /** + * Get is meta-info node + * + * @param string $nodeName + * @return bool + */ + public function isMetaNode($nodeName) + { + return isset($this->_metaNodeNames[$nodeName]); + } + + /** + * @return array + */ + public function getForwardNodeNames() + { + return array( + 'children', + ); + } + + /** + * @param array $metaNodeNames + */ + public function setMetaNodeNames($metaNodeNames) + { + $this->_metaNodeNames = $metaNodeNames; + } + + /** + * @return array + */ + public function getMetaNodeNames() + { + return $this->_metaNodeNames; + } + + /** + * Get is valid node type + * + * @param int $nodeType + * @return bool + */ + public function isValidNodeType($nodeType) + { + return in_array($nodeType, $this->getValidNodeTypes()); + } + + /** + * Get valid node types + * + * @return array + */ + public function getValidNodeTypes() + { + return array( + 1, //DOMElement + ); + } + + /** + * Get etc directory pattern + * + * @param string $codePool + * @param string $namespace + * @return string + */ + public function getEtcDirPattern($codePool = '*', $namespace = '*') + { + return $this->getBasePath() . DIRECTORY_SEPARATOR + . 'app' . DIRECTORY_SEPARATOR + . 'code' . DIRECTORY_SEPARATOR + . $codePool . DIRECTORY_SEPARATOR //code pool + . $namespace . DIRECTORY_SEPARATOR //namespace + . '*' . DIRECTORY_SEPARATOR //module name + . 'etc' . DIRECTORY_SEPARATOR; + } + + /** + * @param string $basePath + */ + public function setBasePath($basePath) + { + $this->_basePath = $basePath; + } + + /** + * @return string + */ + public function getBasePath() + { + return $this->_basePath; + } + + /** + * Create node + * + * @param DOMDocument $resultDom + * @param string $nodeName + * @param DOMNode $parent + * @param string $moduleName + * + * @return DOMNode + */ + public function createNode(DOMDocument $resultDom, $nodeName, DOMNode $parent, $moduleName) + { + $newNode = $resultDom->createElement('resource'); + $xpath = $parent->getAttribute('xpath'); + $newNode->setAttribute('xpath', $xpath . '/' . $nodeName); + $parent->appendChild($newNode); + $newNode->setAttribute('id', $this->generateId($newNode, $xpath, $nodeName)); + if ($moduleName) { + $newNode->setAttribute('module', $moduleName); + } + return $newNode; + } + + /** + * Generate unique id for ACL item + * + * @param DOMNode $node + * @param $xpath string + * @param $resourceId string + * @return mixed + */ + public function generateId(DOMNode $node, $xpath, $resourceId) + { + if (isset($this->_uniqueName[$resourceId]) && $this->_uniqueName[$resourceId] != $xpath) { + $parts = explode('/', $node->parentNode->getAttribute('xpath')); + $suffix = end($parts); + $resourceId = $this->generateId($node->parentNode, $xpath, $suffix . '_' . $resourceId); + } + $this->_uniqueName[$resourceId] = $xpath; + return $resourceId; + } + + /** + * Set meta node + * + * @param DOMNode $node + * @param DOMNode $dataNode + * @param string $module + */ + public function setMetaInfo(DOMNode $node, DOMNode $dataNode, $module) + { + $node->setAttribute($this->_metaNodeNames[$dataNode->nodeName], $dataNode->nodeValue); + if ($dataNode->nodeName == 'title') { + $node->setAttribute('moduleOwner', $module); + $resourceId = $node->getAttribute('moduleOwner') . '::' . $node->getAttribute('id'); + $xpath = $node->getAttribute('xpath'); + $this->_aclResourceMaps[$xpath] = $resourceId; + } + } + + /** + * @return array + */ + public function getAclResourceMaps() + { + return $this->_aclResourceMaps; + } + + /** + * @return array + */ + public function getAdminhtmlFiles() + { + if (null === $this->_adminhtmlFiles) { + $localFiles = glob($this->getEtcDirPattern('local') . 'adminhtml.xml'); + $communityFiles = glob($this->getEtcDirPattern('community') . 'adminhtml.xml'); + $coreEnterpriseFiles = glob($this->getEtcDirPattern('core', 'Enterprise') . 'adminhtml.xml'); + $coreMageFiles = glob($this->getEtcDirPattern('core', 'Mage') . 'adminhtml.xml'); + $this->_adminhtmlFiles = array_merge($localFiles, $communityFiles, $coreEnterpriseFiles, $coreMageFiles); + } + return $this->_adminhtmlFiles; + } + + /** + * @param array $adminhtmlFiles + */ + public function setAdminhtmlFiles($adminhtmlFiles) + { + $this->_adminhtmlFiles = $adminhtmlFiles; + } + + /** + * @return array + */ + public function getParsedDomList() + { + return $this->_parsedDomList; + } + + /** + * Parse node + * + * @param DOMNode $node - data source + * @param DOMDocument $dom - result DOMDocument + * @param DOMNode $parentNode - parent node from result document + * @param $moduleName + */ + public function parseNode(DOMNode $node, DOMDocument $dom, DOMNode $parentNode, $moduleName) + { + if ($this->isRestrictedNode($node->nodeName)) { + return; + } + + foreach ($node->childNodes as $item) { + if (false == $this->isValidNodeType($item->nodeType) || $this->isRestrictedNode($item->nodeName)) { + continue; + } + + if ($this->isForwardNode($item->nodeName)) { + $this->parseNode($item, $dom, $parentNode, $moduleName); + } elseif ($this->isMetaNode($item->nodeName)) { + $this->setMetaInfo($parentNode, $item, $moduleName); + } else { + $newNode = $this->createNode($dom, $item->nodeName, $parentNode, $item->getAttribute('module')); + if ($item->childNodes->length > 0) { + $this->parseNode($item, $dom, $newNode, $moduleName); + } + } + } + } + + /** + * Check if node is restricted + * + * @param $nodeName string + * @return bool + */ + public function isRestrictedNode($nodeName) + { + return in_array($nodeName, $this->getRestrictedNodeNames()); + } + + /** + * Print help message + */ + public function printHelpMessage() + { + $output = './acl.php -- [-hp]' . PHP_EOL; + $output .= 'additional parameters:' . PHP_EOL; + $output .= ' -h print usage' . PHP_EOL; + $output .= ' -p preview result' . PHP_EOL; + echo $output; + } + + /** + * Get template for result DOMDocument + * @param $module + * @param $category + * @return DOMDocument + */ + public function getResultDomDocument($module, $category) + { + $resultDom = new DOMDocument(); + $resultDom->formatOutput = true; + + $comment = $resultDom->createComment($this->getCommentText($category, $module)); + $resultDom->appendChild($comment); + + $config = $resultDom->createElement('config'); + $resultDom->appendChild($config); + + $acl = $resultDom->createElement('acl'); + $config->appendChild($acl); + + $parent = $resultDom->createElement('resources'); + $parent->setAttribute('xpath', 'config/acl/resources'); + $acl->appendChild($parent); + return $resultDom; + } + + /** + * Parse adminhtml.xml files + */ + public function parseAdminhtmlFiles() + { + foreach ($this->getAdminhtmlFiles() as $file) { + $module = $this->getModuleName($file); + $category = $this->getCategory($file); + $resultDom = $this->getResultDomDocument($module, $category); + + $adminhtmlDom = new DOMDocument(); + $adminhtmlDom->load($file); + $this->_adminhtmlDomList[$file] = $adminhtmlDom; + + $xpath = new DOMXPath($adminhtmlDom); + $resourcesList = $xpath->query('//config/acl/*'); + /** @var $aclNode DOMNode **/ + foreach ($resourcesList as $aclNode) { + $this->parseNode($aclNode, $resultDom, $resultDom->getElementsByTagName('resources')->item(0), $module); + } + $this->_parsedDomList[$file] = $resultDom; + + } + } + + /** + * Update ACL resource id + */ + public function updateAclResourceIds() + { + /** @var $dom DOMDocument **/ + foreach ($this->_parsedDomList as $dom) { + $list = $dom->getElementsByTagName('resources'); + /** @var $node DOMNode **/ + foreach ($list as $node) { + $node->removeAttribute('xpath'); + if ($node->childNodes->length > 0) { + $this->updateChildAclNodes($node); + } + } + } + } + + /** + * @param $node DOMNode + */ + public function updateChildAclNodes($node) + { + /** @var $item DOMNode **/ + foreach ($node->childNodes as $item) { + if (false == $this->isValidNodeType($item->nodeType)) { + continue; + } + $xpath = $item->getAttribute('xpath'); + $resourceId = $item->getAttribute('moduleOwner') . '::' . $item->getAttribute('id'); + if (isset($this->_aclResourceMaps[$xpath])) { + $resourceId = $this->_aclResourceMaps[$xpath]; + } + $item->setAttribute('id', $resourceId); + $item->removeAttribute('xpath'); + $item->removeAttribute('moduleOwner'); + + if ($item->childNodes->length > 0) { + $this->updateChildAclNodes($item); + } + } + } + + /** + * @param array $aclResourceMaps + */ + public function setAclResourceMaps($aclResourceMaps) + { + $this->_aclResourceMaps = $aclResourceMaps; + } + + /** + * Save ACL files + * + * @throws Exception if tidy extension is not installed + */ + public function saveAclFiles() + { + if ($this->_isPreviewMode) { + return; + } + + /** @var $dom DOMDocument **/ + foreach ($this->_parsedDomList as $originFile => $dom) { + $file = str_replace('adminhtml.xml', 'adminhtml' . DIRECTORY_SEPARATOR . 'acl.xml', $originFile); + $dom->preserveWhiteSpace = false; + $dom->formatOutput = true; + + $output = $this->_xmlFormatter->parseString($dom->saveXml(), array( + 'indent' => true, + 'input-xml' => true, + 'output-xml' => true, + 'add-xml-space' => false, + 'indent-spaces' => 4, + 'wrap' => 1000 + )); + $this->_fileWriter->write($file, $output); + } + } + + /** + * @param array $parsedDomList + */ + public function setParsedDomList($parsedDomList) + { + $this->_parsedDomList = $parsedDomList; + } + + /** + * @param array $adminhtmlDomList + */ + public function setAdminhtmlDomList($adminhtmlDomList) + { + $this->_adminhtmlDomList = $adminhtmlDomList; + } + + /** + * @return array + */ + public function getAdminhtmlDomList() + { + return $this->_adminhtmlDomList; + } + + /** + * Remove empty files + */ + public function removeAdminhtmlFiles() + { + $output = array( + 'removed' => array(), + 'not_removed' => array(), + ); + + /** @var $dom DOMDocument **/ + foreach ($this->_adminhtmlDomList as $file => $dom) { + $xpath = new DOMXpath($dom); + $nodeList = $xpath->query('/config/acl'); + if ($nodeList->length == 0) { + continue; + } + $acl = $nodeList->item(0); + $countNodes = $acl->childNodes->length - 1; + for ($i = $countNodes; $i >= 0 ; $i--) { + $node = $acl->childNodes->item($i); + if (in_array($node->nodeName, $this->getNodeToRemove())) { + $acl->removeChild($node); + } + } + if ($this->isNodeEmpty($acl)) { + if (false == $this->_isPreviewMode) { + $this->_fileWriter->remove($file); + } + $output['removed'][] = $file; + } else { + $output['not_removed'][] = $file; + } + } + + $output['artifacts']['AclXPathToAclId.log'] = json_encode($this->_aclResourceMaps); + return $output; + } + + /** + * Check if node is empty + * + * @param DOMNode $node + * @return bool + */ + public function isNodeEmpty(DOMNode $node) + { + $output = true; + foreach ($node->childNodes as $item) { + if ($this->isValidNodeType($item->nodeType)) { + $output = false; + break; + } + } + return $output; + } + + /** + * @param string $artifactsPath + */ + public function setArtifactsPath($artifactsPath) + { + $this->_artifactsPath = $artifactsPath; + } + + /** + * Run migration process + */ + public function run() + { + if ($this->_printHelp) { + $this->printHelpMessage(); + return; + } + $this->parseAdminhtmlFiles(); + + $this->updateAclResourceIds(); + + $this->saveAclFiles(); + + $result = $this->removeAdminhtmlFiles(); + + $menuResult = $this->processMenu(); + + $artifacts = array_merge($result['artifacts'], $menuResult['artifacts']); + + $this->saveArtifacts($artifacts); + + $this->printStatistic($result, $menuResult, $artifacts); + } + + /** + * Print statistic + * + * @param $result + * @param $menuResult + * @param $artifacts + */ + public function printStatistic($result, $menuResult, $artifacts) + { + $output = PHP_EOL; + if (true == $this->_isPreviewMode) { + $output .= '!!! PREVIEW MODE. ORIGIN DATA NOT CHANGED!!!' . PHP_EOL; + } + + $output .= PHP_EOL; + + $output .= 'Removed adminhtml.xml: ' . count($result['removed']) . ' files ' . PHP_EOL; + $output .= 'Not Removed adminhtml.xml: ' . count($result['not_removed']) . ' files ' . PHP_EOL; + if (count($result['not_removed'])) { + foreach ($result['not_removed'] as $fileName) { + $output .= ' - ' . $fileName . PHP_EOL; + } + } + + $output .= PHP_EOL; + $output .= 'Mapped Menu Items: ' . count($menuResult['mapped']) . PHP_EOL; + $output .= 'Not Mapped Menu Items: ' .count($menuResult['not_mapped']) . PHP_EOL; + + if (count($menuResult['not_mapped'])) { + foreach ($menuResult['not_mapped'] as $menuId) { + $output .= ' - ' . $menuId . PHP_EOL; + } + } + + $output .= 'Menu Update Errors: ' .count($menuResult['menu_update_errors']) . PHP_EOL; + if (count($menuResult['menu_update_errors'])) { + foreach ($menuResult['menu_update_errors'] as $errorText) { + $output .= ' - ' . $errorText . PHP_EOL; + } + } + + $output .= PHP_EOL; + $output .= 'Artifacts: ' . PHP_EOL; + foreach (array_keys($artifacts) as $file) { + $output .= ' - ' . $this->_artifactsPath . $file . PHP_EOL; + } + + echo $output; + } + + /** + * Save artifacts files + * + * @param $artifacts + */ + public function saveArtifacts($artifacts) + { + foreach ($artifacts as $file => $data) { + $this->_fileWriter->write($this->_artifactsPath . $file, $data); + } + } + + /** + * Run process of menu updating + * + * @return array + */ + public function processMenu() + { + $menu = new Tools_Migration_Acl_Menu_Generator( + $this->getBasePath(), + $this->getValidNodeTypes(), + $this->_aclResourceMaps, + $this->_isPreviewMode + ); + return $menu->run(); + } + + /** + * @return array + */ + public function getRestrictedNodeNames() + { + return array( + 'privilegeSets', + ); + } + + /** + * @return array + */ + public function getNodeToRemove() + { + return array( + 'resources', + 'privilegeSets', + ); + } +} diff --git a/dev/tools/migration/Acl/Menu/Generator.php b/dev/tools/migration/Acl/Menu/Generator.php new file mode 100644 index 00000000000..62f4666f675 --- /dev/null +++ b/dev/tools/migration/Acl/Menu/Generator.php @@ -0,0 +1,426 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Magento + * @package tools + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +class Tools_Migration_Acl_Menu_Generator +{ + /** + * @var array + */ + protected $_menuFiles; + + /** + * @var string + */ + protected $_basePath; + + /** + * @var string + */ + protected $_validNodeTypes; + + /** + * @var array + */ + protected $_menuIdMaps = array(); + + /** + * @var array + */ + protected $_idToXPath = array(); + + /** + * @var array + */ + protected $_aclXPathToId = array(); + + /** + * @var array + */ + protected $_menuIdToAclId = array(); + + /** + * @var array + */ + protected $_menuDomList = array(); + + /** + * @var array + */ + protected $_updateNodes = array(); + + /** + * Is preview mode + * + * @var bool + */ + protected $_isPreviewMode; + + /** + * @var Tools_Migration_Acl_FileWriter + */ + protected $_fileWriter; + + + /** + * @param $basePath + * @param $validNodeTypes + * @param $aclXPathToId + * @param Tools_Migration_Acl_FileWriter $fileWriter + * @param bool $preview + */ + public function __construct( + $basePath, + $validNodeTypes, + $aclXPathToId, + Tools_Migration_Acl_FileWriter $fileWriter, + $preview = true + ) { + $this->_fileWriter = $fileWriter; + $this->_basePath = $basePath; + $this->_validNodeTypes = $validNodeTypes; + $this->_aclXPathToId = $aclXPathToId; + $this->_updateNodes = array( + 'add' => array( + 'required' => true, + 'attribute' => 'resource', + ), + 'update' => array( + 'required' => false, + 'attribute' => 'resource', + ), + ); + + $this->_isPreviewMode = $preview; + } + + /** + * Get etc directory pattern + * + * @return null|string + */ + public function getEtcDirPattern() + { + return $this->_basePath . DIRECTORY_SEPARATOR + . 'app' . DIRECTORY_SEPARATOR + . 'code' . DIRECTORY_SEPARATOR + . '*' . DIRECTORY_SEPARATOR //code pool + . '*' . DIRECTORY_SEPARATOR //namespace + . '*' . DIRECTORY_SEPARATOR //module name + . 'etc' . DIRECTORY_SEPARATOR; + } + + /** + * @return array|null + */ + public function getMenuFiles() + { + if (null === $this->_menuFiles) { + $pattern = $this->getEtcDirPattern() . 'adminhtml' . DIRECTORY_SEPARATOR . 'menu.xml'; + $this->_menuFiles = (glob($pattern)); + } + return $this->_menuFiles; + } + + /** + * Parse menu item node + * + * @param DOMNode $node + */ + public function parseMenuNode(DOMNode $node) + { + /** @var $childNode DOMNode **/ + foreach ($node->childNodes as $childNode) { + if (false == in_array($childNode->nodeType, $this->_validNodeTypes) || 'add' != $childNode->nodeName) { + continue; + } + $this->_menuIdMaps[$childNode->getAttribute('id')]['parent'] = $childNode->getAttribute('parent'); + $this->_menuIdMaps[$childNode->getAttribute('id')]['resource'] = $childNode->getAttribute('resource'); + } + } + + /** + * @return array + */ + public function getMenuIdMaps() + { + return $this->_menuIdMaps; + } + + /** + * Parse menu files + */ + public function parseMenuFiles() + { + foreach ($this->getMenuFiles() as $file) { + $dom = new DOMDocument(); + $dom->load($file); + $this->_menuDomList[$file] = $dom; + $menus = $dom->getElementsByTagName('menu'); + + /** @var $menuNode DOMNode **/ + foreach ($menus as $menuNode) { + $this->parseMenuNode($menuNode); + } + } + } + + /** + * @return array + */ + public function getMenuDomList() + { + return $this->_menuDomList; + } + + /** + * @param $menuId + */ + public function initParentItems($menuId) + { + $this->_menuIdMaps[$menuId]['parents'] = array(); + $parentId = $this->_menuIdMaps[$menuId]['parent']; + while ($parentId) { + $this->_menuIdMaps[$menuId]['parents'][] = $parentId; + if (false == isset($this->_menuIdMaps[$parentId])) { + return; + } + $parentId = $this->_menuIdMaps[$parentId]['parent']; + } + } + + /** + * Build xpath elements + * + * @param $menuId + */ + public function buildXPath($menuId) + { + $parents = $this->_menuIdMaps[$menuId]['parents'] ? + $this->_menuIdMaps[$menuId]['parents'] : + array(); + $resource = $this->_menuIdMaps[$menuId]['resource']; + if (!$resource) { + $parts = array(); + $parents = array_reverse($parents); + $parents[] = $menuId; + + foreach ($parents as $parent) { + $parentParts = explode('::', $parent); + $idPart = $parentParts[1]; + $prevParts = implode('_', $parts); + $start = strpos($prevParts, $idPart) + strlen($prevParts); + $id = substr($idPart, $start); + $parts[] = trim($id, '_'); + } + $resource = implode('/', $parts); + } + + $this->_idToXPath[$menuId] = $resource; + } + + /** + * @return array + */ + public function getIdToXPath() + { + return $this->_idToXPath; + } + + /** + * Initialize menu items XPath + */ + public function buildMenuItemsXPath() + { + foreach (array_keys($this->_menuIdMaps) as $menuId) { + $this->initParentItems($menuId); + $this->buildXPath($menuId); + } + } + + /** + * Map menu item id to ACL resource id + * + * @return array + */ + public function mapMenuToAcl() + { + $output = array( + 'mapped' => array(), + 'not_mapped' => array(), + ); + $aclPrefix = 'config/acl/resources/admin/'; + foreach ($this->_idToXPath as $menuId => $menuXPath) { + $key = $aclPrefix . $menuXPath; + if (isset($this->_aclXPathToId[$key])) { + $this->_menuIdToAclId[$menuId] = $this->_aclXPathToId[$key]; + $output['mapped'][] = $menuId; + } else { + $output['not_mapped'][] = $menuId; + } + } + + $output['artifacts']['MenuIdToAclId.log'] = json_encode($this->_menuIdToAclId); + return $output; + } + + /** + * @return array + */ + public function getMenuIdToAclId() + { + return $this->_menuIdToAclId; + } + + /** + * @param array $idToXPath + */ + public function setIdToXPath($idToXPath) + { + $this->_idToXPath = $idToXPath; + } + + /** + * Update attributes of menu items to set ACL resource id + * + * @return array + */ + public function updateMenuAttributes() + { + $errors = array(); + $aclPrefix = 'config/acl/resources/admin/'; + /** @var $dom DOMDocument **/ + foreach ($this->_menuDomList as $file => $dom) { + $menu = $dom->getElementsByTagName('menu')->item(0); + /** @var $childNode DOMNode **/ + foreach ($menu->childNodes as $childNode) { + + if (!$this->_isNodeValidToUpdate($childNode)) { + continue; + } + + $attributeName = $this->_updateNodes[$childNode->nodeName]['attribute']; + $required = $this->_updateNodes[$childNode->nodeName]['required']; + $resource = $childNode->getAttribute($attributeName); + $menuId = $childNode->getAttribute('id'); + + if (false == array_key_exists($menuId, $this->_menuIdToAclId)) { + $errors[] = 'File: ' . $file . ' :: Menu: ' . $menuId . ' is not mapped to ACL id'; + continue; + } + $aclId = $this->_menuIdToAclId[$menuId]; + + if ($resource) { + $aclXPath = $aclPrefix . $resource; + if (false == array_key_exists($aclXPath, $this->_aclXPathToId)) { + $errors[] = 'File: ' . $file . ' :: Menu: ' . $menuId + . '. There is no ACL resource with XPath ' . $aclXPath; + continue; + } + $aclId = $this->_aclXPathToId[$aclXPath]; + } + if ($required || $resource) { + $childNode->setAttribute($attributeName, $aclId); + } + } + } + + return $errors; + } + + /** + * Check if node has to be updated + * + * @param DOMNode $node + * @return bool + */ + protected function _isNodeValidToUpdate(DOMNode $node) + { + if (false == in_array($node->nodeType, $this->_validNodeTypes) || + false == array_key_exists($node->nodeName, $this->_updateNodes) + ) { + return false; + } + + return true; + } + + /** + * @param array $menuIdToAclId + */ + public function setMenuIdToAclId($menuIdToAclId) + { + $this->_menuIdToAclId = $menuIdToAclId; + } + + /** + * @param array $aclXPathToId + */ + public function setAclXPathToId($aclXPathToId) + { + $this->_aclXPathToId = $aclXPathToId; + } + + /** + * @param array $menuDomList + */ + public function setMenuDomList($menuDomList) + { + $this->_menuDomList = $menuDomList; + } + + /** + * Save menu XML files + */ + public function saveMenuFiles() + { + if (true == $this->_isPreviewMode) { + return; + } + /** @var $dom DOMDocument **/ + foreach ($this->_menuDomList as $file => $dom) { + $dom->formatOutput = true; + $this->_fileWriter->write($file, $dom->saveXML()); + } + } + + /** + * @return array + */ + public function run() + { + $this->parseMenuFiles(); + + $this->buildMenuItemsXPath(); + + $result = $this->mapMenuToAcl(); + + $result['menu_update_errors'] = $this->updateMenuAttributes(); + + $this->saveMenuFiles(); + + return $result; + } +} diff --git a/dev/tools/migration/Acl/log/AclXPathToAclId.log b/dev/tools/migration/Acl/log/AclXPathToAclId.log new file mode 100644 index 00000000000..8995da77ec0 --- /dev/null +++ b/dev/tools/migration/Acl/log/AclXPathToAclId.log @@ -0,0 +1 @@ +{"config\/acl\/resources\/admin\/catalog\/feed":"Find_Feed::feed","config\/acl\/resources\/admin\/catalog\/feed\/import_products":"Find_Feed::import_products","config\/acl\/resources\/admin\/catalog\/feed\/import_items":"Find_Feed::import_items","config\/acl\/resources\/admin\/system\/config\/feed":"Find_Feed::config_feed","config\/acl\/resources\/admin\/system\/config\/moneybookers":"Phoenix_Moneybookers::moneybookers","config\/acl\/resources\/admin\/system\/config\/facebook":"Social_Facebook::facebook","config\/acl\/resources\/admin\/cms\/enterprise_banner":"Enterprise_Banner::enterprise_banner","config\/acl\/resources\/admin\/catalog\/events":"Enterprise_CatalogEvent::events","config\/acl\/resources\/admin\/system\/config\/enterprise_catalogpermissions":"Enterprise_CatalogPermissions::enterprise_catalogpermissions","config\/acl\/resources\/admin\/catalog\/enterprise_catalogpermissions":"Enterprise_CatalogPermissions::catalog_enterprise_catalogpermissions","config\/acl\/resources\/admin\/sales\/enterprise_checkout":"Enterprise_Checkout::enterprise_checkout","config\/acl\/resources\/admin\/sales\/enterprise_checkout\/view":"Enterprise_Checkout::view","config\/acl\/resources\/admin\/sales\/enterprise_checkout\/update":"Enterprise_Checkout::update","config\/acl\/resources\/admin\/cms\/page\/save_revision":"Enterprise_Cms::save_revision","config\/acl\/resources\/admin\/cms\/page\/delete_revision":"Enterprise_Cms::delete_revision","config\/acl\/resources\/admin\/cms\/page\/publish_revision":"Enterprise_Cms::publish_revision","config\/acl\/resources\/admin\/cms\/hierarchy":"Enterprise_Cms::hierarchy","config\/acl\/resources\/admin\/customer\/customersegment":"Enterprise_CustomerSegment::customersegment","config\/acl\/resources\/admin\/report\/customers\/segment":"Enterprise_CustomerSegment::segment","config\/acl\/resources\/admin\/customer\/attributes":"Enterprise_Customer::attributes","config\/acl\/resources\/admin\/customer\/attributes\/customer_attributes":"Enterprise_Customer::customer_attributes","config\/acl\/resources\/admin\/customer\/attributes\/customer_address_attributes":"Enterprise_Customer::customer_address_attributes","config\/acl\/resources\/admin\/system\/config\/giftcardaccount":"Enterprise_GiftCardAccount::giftcardaccount","config\/acl\/resources\/admin\/customer\/giftcardaccount":"Enterprise_GiftCardAccount::customer_giftcardaccount","config\/acl\/resources\/admin\/system\/config\/giftcard":"Enterprise_GiftCard::giftcard","config\/acl\/resources\/admin\/system\/config\/enterprise_giftregistry":"Enterprise_GiftRegistry::enterprise_giftregistry","config\/acl\/resources\/admin\/customer\/enterprise_giftregistry":"Enterprise_GiftRegistry::customer_enterprise_giftregistry","config\/acl\/resources\/admin\/sales\/enterprise_giftwrapping":"Enterprise_GiftWrapping::enterprise_giftwrapping","config\/acl\/resources\/admin\/system\/convert\/enterprise_scheduled_operation":"Enterprise_ImportExport::enterprise_scheduled_operation","config\/acl\/resources\/admin\/customer\/enterprise_invitation":"Enterprise_Invitation::enterprise_invitation","config\/acl\/resources\/admin\/report\/enterprise_invitation":"Enterprise_Invitation::report_enterprise_invitation","config\/acl\/resources\/admin\/report\/enterprise_invitation\/general":"Enterprise_Invitation::general","config\/acl\/resources\/admin\/report\/enterprise_invitation\/customer":"Enterprise_Invitation::enterprise_invitation_customer","config\/acl\/resources\/admin\/report\/enterprise_invitation\/order":"Enterprise_Invitation::order","config\/acl\/resources\/admin\/system\/config\/enterprise_invitation":"Enterprise_Invitation::config_enterprise_invitation","config\/acl\/resources\/admin\/system\/config\/logging":"Enterprise_Logging::logging","config\/acl\/resources\/admin\/system\/enterprise_logging":"Enterprise_Logging::enterprise_logging","config\/acl\/resources\/admin\/system\/enterprise_logging\/events":"Enterprise_Logging::enterprise_logging_events","config\/acl\/resources\/admin\/system\/enterprise_logging\/backups":"Enterprise_Logging::backups","config\/acl\/resources\/admin\/system\/crypt_key":"Enterprise_Pci::crypt_key","config\/acl\/resources\/admin\/system\/acl\/locks":"Enterprise_Pci::locks","config\/acl\/resources\/admin\/catalog\/products\/read_product_price":"Enterprise_PricePermissions::read_product_price","config\/acl\/resources\/admin\/catalog\/products\/read_product_price\/edit_product_price":"Enterprise_PricePermissions::edit_product_price","config\/acl\/resources\/admin\/catalog\/products\/edit_product_status":"Enterprise_PricePermissions::edit_product_status","config\/acl\/resources\/admin\/promo\/catalog\/edit":"Enterprise_PromotionPermissions::edit","config\/acl\/resources\/admin\/promo\/quote\/edit":"Enterprise_PromotionPermissions::quote_edit","config\/acl\/resources\/admin\/promo\/enterprise_reminder\/edit":"Enterprise_PromotionPermissions::enterprise_reminder_edit","config\/acl\/resources\/admin\/promo\/enterprise_reminder":"Enterprise_Reminder::enterprise_reminder","config\/acl\/resources\/admin\/system\/config\/promo":"Mage_SalesRule::config_promo","config\/acl\/resources\/admin\/customer\/manage\/reward_balance":"Enterprise_Reward::reward_balance","config\/acl\/resources\/admin\/sales\/order\/actions\/create\/reward_spend":"Enterprise_Reward::reward_spend","config\/acl\/resources\/admin\/customer\/rates":"Enterprise_Reward::rates","config\/acl\/resources\/admin\/system\/config\/enterprise_reward":"Enterprise_Reward::enterprise_reward","config\/acl\/resources\/admin\/sales\/enterprise_rma":"Enterprise_Rma::enterprise_rma","config\/acl\/resources\/admin\/sales\/enterprise_rma\/rma_manage":"Enterprise_Rma::rma_manage","config\/acl\/resources\/admin\/sales\/enterprise_rma\/rma_attribute":"Enterprise_Rma::rma_attribute","config\/acl\/resources\/admin\/sales\/archive":"Enterprise_SalesArchive::archive","config\/acl\/resources\/admin\/sales\/archive\/orders":"Enterprise_SalesArchive::orders","config\/acl\/resources\/admin\/sales\/archive\/orders\/add":"Enterprise_SalesArchive::add","config\/acl\/resources\/admin\/sales\/archive\/orders\/remove":"Enterprise_SalesArchive::remove","config\/acl\/resources\/admin\/sales\/archive\/invoices":"Enterprise_SalesArchive::invoices","config\/acl\/resources\/admin\/sales\/archive\/shipments":"Enterprise_SalesArchive::shipments","config\/acl\/resources\/admin\/sales\/archive\/creditmemos":"Enterprise_SalesArchive::creditmemos","config\/acl\/resources\/admin\/system\/enterprise_staging":"Enterprise_Staging::enterprise_staging","config\/acl\/resources\/admin\/system\/enterprise_staging\/staging_grid":"Enterprise_Staging::staging_grid","config\/acl\/resources\/admin\/system\/enterprise_staging\/staging_backup":"Enterprise_Staging::staging_backup","config\/acl\/resources\/admin\/system\/enterprise_staging\/staging_log":"Enterprise_Staging::staging_log","config\/acl\/resources\/admin\/system\/config\/content_staging":"Enterprise_Staging::content_staging","config\/acl\/resources\/admin\/catalog\/targetrule":"Enterprise_TargetRule::targetrule","config\/acl\/resources\/admin\/report\/customers\/wishlist":"Enterprise_Wishlist::wishlist","config\/acl\/resources\/admin\/system\/adminnotification":"Mage_AdminNotification::adminnotification","config\/acl\/resources\/admin\/system\/adminnotification\/show_toolbar":"Mage_AdminNotification::show_toolbar","config\/acl\/resources\/admin\/system\/adminnotification\/show_list":"Mage_AdminNotification::show_list","config\/acl\/resources\/admin\/system\/adminnotification\/mark_as_read":"Mage_AdminNotification::mark_as_read","config\/acl\/resources\/admin\/system\/adminnotification\/remove":"Mage_AdminNotification::adminnotification_remove","config\/acl\/resources\/all":"Mage_Adminhtml::all","config\/acl\/resources\/admin":"Mage_Adminhtml::admin","config\/acl\/resources\/admin\/dashboard":"Mage_Adminhtml::dashboard","config\/acl\/resources\/admin\/system":"Mage_Adminhtml::system","config\/acl\/resources\/admin\/system\/store":"Mage_Adminhtml::store","config\/acl\/resources\/admin\/system\/design":"Mage_Adminhtml::design","config\/acl\/resources\/admin\/system\/design\/schedule":"Mage_Adminhtml::schedule","config\/acl\/resources\/admin\/system\/config":"Mage_Adminhtml::config","config\/acl\/resources\/admin\/system\/config\/general":"Mage_Adminhtml::config_general","config\/acl\/resources\/admin\/system\/config\/web":"Mage_Adminhtml::web","config\/acl\/resources\/admin\/system\/config\/design":"Mage_Adminhtml::config_design","config\/acl\/resources\/admin\/system\/config\/system":"Mage_Adminhtml::config_system","config\/acl\/resources\/admin\/system\/config\/advanced":"Mage_Adminhtml::advanced","config\/acl\/resources\/admin\/system\/config\/trans_email":"Mage_Adminhtml::trans_email","config\/acl\/resources\/admin\/system\/config\/dev":"Mage_Adminhtml::dev","config\/acl\/resources\/admin\/system\/config\/currency":"Mage_Adminhtml::currency","config\/acl\/resources\/admin\/system\/config\/sendfriend":"Mage_Adminhtml::sendfriend","config\/acl\/resources\/admin\/system\/config\/admin":"Mage_Adminhtml::config_admin","config\/acl\/resources\/admin\/system\/currency":"Mage_CurrencySymbol::system_currency","config\/acl\/resources\/admin\/system\/email_template":"Mage_Adminhtml::email_template","config\/acl\/resources\/admin\/system\/variable":"Mage_Adminhtml::variable","config\/acl\/resources\/admin\/system\/myaccount":"Mage_Adminhtml::myaccount","config\/acl\/resources\/admin\/system\/tools":"Mage_Adminhtml::tools","config\/acl\/resources\/admin\/system\/convert":"Mage_Adminhtml::convert","config\/acl\/resources\/admin\/system\/convert\/gui":"Mage_Adminhtml::gui","config\/acl\/resources\/admin\/system\/convert\/profiles":"Mage_Adminhtml::profiles","config\/acl\/resources\/admin\/system\/cache":"Mage_Adminhtml::cache","config\/acl\/resources\/admin\/system\/extensions":"Mage_Adminhtml::extensions","config\/acl\/resources\/admin\/system\/extensions\/local":"Mage_Adminhtml::local","config\/acl\/resources\/admin\/system\/extensions\/custom":"Mage_Adminhtml::custom","config\/acl\/resources\/admin\/global_search":"Mage_Adminhtml::global_search","config\/acl\/resources\/admin\/system\/api\/rest_roles":"Mage_Api2::rest_roles","config\/acl\/resources\/admin\/system\/api\/rest_roles\/add":"Mage_Api2::rest_roles_add","config\/acl\/resources\/admin\/system\/api\/rest_roles\/edit":"Mage_Api2::rest_roles_edit","config\/acl\/resources\/admin\/system\/api\/rest_roles\/delete":"Mage_Api2::delete","config\/acl\/resources\/admin\/system\/api\/rest_attributes":"Mage_Api2::rest_attributes","config\/acl\/resources\/admin\/system\/api\/rest_attributes\/edit":"Mage_Api2::rest_attributes_edit","config\/acl\/resources\/admin\/system\/api":"Mage_Api::api","config\/acl\/resources\/admin\/system\/api\/users":"Mage_Api::users","config\/acl\/resources\/admin\/system\/api\/roles":"Mage_Api::roles","config\/acl\/resources\/admin\/system\/config\/api":"Mage_Api::config_api","config\/acl\/resources\/admin\/system\/tools\/backup":"Mage_Backup::backup","config\/acl\/resources\/admin\/system\/tools\/backup\/rollback":"Mage_Backup::rollback","config\/acl\/resources\/admin\/system\/config\/cataloginventory":"Mage_CatalogInventory::cataloginventory","config\/acl\/resources\/admin\/promo":"Mage_CatalogRule::promo","config\/acl\/resources\/admin\/promo\/catalog":"Mage_CatalogRule::promo_catalog","config\/acl\/resources\/admin\/catalog\/search":"Mage_CatalogSearch::search","config\/acl\/resources\/admin\/system\/config\/catalog":"Mage_Catalog::config_catalog","config\/acl\/resources\/admin\/catalog":"Mage_Catalog::catalog","config\/acl\/resources\/admin\/catalog\/attributes":"Mage_Catalog::catalog_attributes","config\/acl\/resources\/admin\/catalog\/attributes\/attributes":"Mage_Catalog::attributes_attributes","config\/acl\/resources\/admin\/catalog\/attributes\/sets":"Mage_Catalog::sets","config\/acl\/resources\/admin\/catalog\/categories":"Mage_Catalog::categories","config\/acl\/resources\/admin\/catalog\/products":"Mage_Catalog::products","config\/acl\/resources\/admin\/catalog\/update_attributes":"Mage_Catalog::update_attributes","config\/acl\/resources\/admin\/catalog\/urlrewrite":"Mage_Catalog::urlrewrite","config\/acl\/resources\/admin\/sales\/checkoutagreement":"Mage_Checkout::checkoutagreement","config\/acl\/resources\/admin\/system\/config\/checkout":"Mage_Checkout::checkout","config\/acl\/resources\/admin\/cms":"Mage_Cms::cms","config\/acl\/resources\/admin\/cms\/block":"Mage_Cms::block","config\/acl\/resources\/admin\/cms\/page":"Mage_Cms::page","config\/acl\/resources\/admin\/cms\/page\/save":"Mage_Cms::save","config\/acl\/resources\/admin\/cms\/page\/delete":"Mage_Cms::page_delete","config\/acl\/resources\/admin\/cms\/media_gallery":"Mage_Cms::media_gallery","config\/acl\/resources\/admin\/system\/config\/cms":"Mage_Cms::config_cms","config\/acl\/resources\/admin\/system\/config\/contacts":"Mage_Contacts::contacts","config\/acl\/resources\/admin\/system\/currency\/rates":"Mage_CurrencySymbol::currency_rates","config\/acl\/resources\/admin\/system\/currency\/symbols":"Mage_CurrencySymbol::symbols","config\/acl\/resources\/admin\/customer":"Mage_Customer::customer","config\/acl\/resources\/admin\/customer\/group":"Mage_Customer::group","config\/acl\/resources\/admin\/customer\/manage":"Mage_Customer::manage","config\/acl\/resources\/admin\/customer\/online":"Mage_Customer::online","config\/acl\/resources\/admin\/system\/config\/customer":"Mage_Customer::config_customer","config\/acl\/resources\/admin\/system\/design\/editor":"Mage_DesignEditor::editor","config\/acl\/resources\/admin\/system\/config\/downloadable":"Mage_Downloadable::downloadable","config\/acl\/resources\/admin\/system\/config\/google":"Mage_GoogleCheckout::google","config\/acl\/resources\/admin\/catalog\/googleshopping":"Mage_GoogleShopping::googleshopping","config\/acl\/resources\/admin\/catalog\/googleshopping\/types":"Mage_GoogleShopping::types","config\/acl\/resources\/admin\/catalog\/googleshopping\/items":"Mage_GoogleShopping::items","config\/acl\/resources\/admin\/system\/convert\/import":"Mage_ImportExport::import","config\/acl\/resources\/admin\/system\/convert\/export":"Mage_ImportExport::export","config\/acl\/resources\/admin\/system\/index":"Mage_Index::index","config\/acl\/resources\/admin\/system\/config\/newsletter":"Mage_Newsletter::newsletter","config\/acl\/resources\/admin\/newsletter":"Mage_Newsletter::admin_newsletter","config\/acl\/resources\/admin\/newsletter\/problem":"Mage_Newsletter::problem","config\/acl\/resources\/admin\/newsletter\/queue":"Mage_Newsletter::queue","config\/acl\/resources\/admin\/newsletter\/subscriber":"Mage_Newsletter::subscriber","config\/acl\/resources\/admin\/newsletter\/template":"Mage_Newsletter::template","config\/acl\/resources\/admin\/system\/api\/consumer":"Mage_Oauth::consumer","config\/acl\/resources\/admin\/system\/api\/consumer\/edit":"Mage_Oauth::consumer_edit","config\/acl\/resources\/admin\/system\/api\/consumer\/delete":"Mage_Oauth::consumer_delete","config\/acl\/resources\/admin\/system\/api\/authorizedTokens":"Mage_Oauth::authorizedTokens","config\/acl\/resources\/admin\/system\/api\/oauth_admin_token":"Mage_Oauth::oauth_admin_token","config\/acl\/resources\/admin\/system\/config\/oauth":"Mage_Oauth::oauth","config\/acl\/resources\/admin\/page_cache":"Mage_PageCache::page_cache","config\/acl\/resources\/admin\/system\/config\/payment":"Mage_Payment::payment","config\/acl\/resources\/admin\/system\/config\/payment_services":"Mage_Payment::payment_services","config\/acl\/resources\/admin\/system\/config\/paypal":"Mage_Paypal::paypal","config\/acl\/resources\/admin\/report\/salesroot\/paypal_settlement_reports":"Mage_Paypal::paypal_settlement_reports","config\/acl\/resources\/admin\/report\/salesroot\/paypal_settlement_reports\/view":"Mage_Paypal::paypal_settlement_reports_view","config\/acl\/resources\/admin\/report\/salesroot\/paypal_settlement_reports\/fetch":"Mage_Paypal::fetch","config\/acl\/resources\/admin\/system\/config\/persistent":"Mage_Persistent::persistent","config\/acl\/resources\/admin\/cms\/poll":"Mage_Poll::poll","config\/acl\/resources\/admin\/catalog\/reviews_ratings\/ratings":"Mage_Rating::ratings","config\/acl\/resources\/admin\/report":"Mage_Reports::report","config\/acl\/resources\/admin\/report\/salesroot":"Mage_Reports::salesroot","config\/acl\/resources\/admin\/report\/salesroot\/sales":"Mage_Reports::salesroot_sales","config\/acl\/resources\/admin\/report\/salesroot\/tax":"Mage_Reports::tax","config\/acl\/resources\/admin\/report\/salesroot\/shipping":"Mage_Reports::shipping","config\/acl\/resources\/admin\/report\/salesroot\/invoiced":"Mage_Reports::invoiced","config\/acl\/resources\/admin\/report\/salesroot\/refunded":"Mage_Reports::refunded","config\/acl\/resources\/admin\/report\/salesroot\/coupons":"Mage_Reports::coupons","config\/acl\/resources\/admin\/report\/shopcart":"Mage_Reports::shopcart","config\/acl\/resources\/admin\/report\/shopcart\/product":"Mage_Reports::product","config\/acl\/resources\/admin\/report\/shopcart\/abandoned":"Mage_Reports::abandoned","config\/acl\/resources\/admin\/report\/products":"Mage_Reports::report_products","config\/acl\/resources\/admin\/report\/products\/bestsellers":"Mage_Reports::bestsellers","config\/acl\/resources\/admin\/report\/products\/sold":"Mage_Reports::sold","config\/acl\/resources\/admin\/report\/products\/viewed":"Mage_Reports::viewed","config\/acl\/resources\/admin\/report\/products\/lowstock":"Mage_Reports::lowstock","config\/acl\/resources\/admin\/report\/products\/downloads":"Mage_Reports::downloads","config\/acl\/resources\/admin\/report\/customers":"Mage_Reports::customers","config\/acl\/resources\/admin\/report\/customers\/accounts":"Mage_Reports::accounts","config\/acl\/resources\/admin\/report\/customers\/totals":"Mage_Reports::totals","config\/acl\/resources\/admin\/report\/customers\/orders":"Mage_Reports::customers_orders","config\/acl\/resources\/admin\/report\/review":"Mage_Reports::review","config\/acl\/resources\/admin\/report\/review\/customer":"Mage_Reports::review_customer","config\/acl\/resources\/admin\/report\/review\/product":"Mage_Reports::review_product","config\/acl\/resources\/admin\/report\/tags":"Mage_Reports::tags","config\/acl\/resources\/admin\/report\/tags\/customer":"Mage_Reports::tags_customer","config\/acl\/resources\/admin\/report\/tags\/popular":"Mage_Reports::popular","config\/acl\/resources\/admin\/report\/tags\/product":"Mage_Reports::tags_product","config\/acl\/resources\/admin\/report\/search":"Mage_Reports::report_search","config\/acl\/resources\/admin\/report\/statistics":"Mage_Reports::statistics","config\/acl\/resources\/admin\/system\/config\/reports":"Mage_Reports::reports","config\/acl\/resources\/admin\/catalog\/reviews_ratings":"Mage_Review::reviews_ratings","config\/acl\/resources\/admin\/catalog\/reviews_ratings\/reviews":"Mage_Review::reviews","config\/acl\/resources\/admin\/catalog\/reviews_ratings\/reviews\/all":"Mage_Review::reviews_all","config\/acl\/resources\/admin\/catalog\/reviews_ratings\/reviews\/pending":"Mage_Review::pending","config\/acl\/resources\/admin\/system\/config\/rss":"Mage_Rss::rss","config\/acl\/resources\/admin\/promo\/quote":"Mage_SalesRule::quote","config\/acl\/resources\/admin\/sales":"Mage_Sales::sales","config\/acl\/resources\/admin\/sales\/order":"Mage_Sales::sales_order","config\/acl\/resources\/admin\/sales\/order\/actions":"Mage_Sales::actions","config\/acl\/resources\/admin\/sales\/order\/actions\/create":"Mage_Sales::create","config\/acl\/resources\/admin\/sales\/order\/actions\/view":"Mage_Sales::actions_view","config\/acl\/resources\/admin\/sales\/order\/actions\/email":"Mage_Sales::email","config\/acl\/resources\/admin\/sales\/order\/actions\/reorder":"Mage_Sales::reorder","config\/acl\/resources\/admin\/sales\/order\/actions\/edit":"Mage_Sales::actions_edit","config\/acl\/resources\/admin\/sales\/order\/actions\/cancel":"Mage_Sales::cancel","config\/acl\/resources\/admin\/sales\/order\/actions\/review_payment":"Mage_Sales::review_payment","config\/acl\/resources\/admin\/sales\/order\/actions\/capture":"Mage_Sales::capture","config\/acl\/resources\/admin\/sales\/order\/actions\/invoice":"Mage_Sales::invoice","config\/acl\/resources\/admin\/sales\/order\/actions\/creditmemo":"Mage_Sales::creditmemo","config\/acl\/resources\/admin\/sales\/order\/actions\/hold":"Mage_Sales::hold","config\/acl\/resources\/admin\/sales\/order\/actions\/unhold":"Mage_Sales::unhold","config\/acl\/resources\/admin\/sales\/order\/actions\/ship":"Mage_Sales::ship","config\/acl\/resources\/admin\/sales\/order\/actions\/comment":"Mage_Sales::comment","config\/acl\/resources\/admin\/sales\/order\/actions\/emails":"Mage_Sales::emails","config\/acl\/resources\/admin\/sales\/invoice":"Mage_Sales::sales_invoice","config\/acl\/resources\/admin\/sales\/shipment":"Mage_Sales::shipment","config\/acl\/resources\/admin\/sales\/creditmemo":"Mage_Sales::sales_creditmemo","config\/acl\/resources\/admin\/sales\/transactions":"Mage_Sales::transactions","config\/acl\/resources\/admin\/sales\/transactions\/fetch":"Mage_Sales::transactions_fetch","config\/acl\/resources\/admin\/sales\/recurring_profile":"Mage_Sales::recurring_profile","config\/acl\/resources\/admin\/sales\/billing_agreement":"Mage_Sales::billing_agreement","config\/acl\/resources\/admin\/sales\/billing_agreement\/actions":"Mage_Sales::billing_agreement_actions","config\/acl\/resources\/admin\/sales\/billing_agreement\/actions\/view":"Mage_Sales::billing_agreement_actions_view","config\/acl\/resources\/admin\/sales\/billing_agreement\/actions\/manage":"Mage_Sales::actions_manage","config\/acl\/resources\/admin\/sales\/billing_agreement\/actions\/use":"Mage_Sales::use","config\/acl\/resources\/admin\/system\/order_statuses":"Mage_Sales::order_statuses","config\/acl\/resources\/admin\/system\/config\/sales":"Mage_Sales::config_sales","config\/acl\/resources\/admin\/system\/config\/sales_email":"Mage_Sales::sales_email","config\/acl\/resources\/admin\/system\/config\/sales_pdf":"Mage_Sales::sales_pdf","config\/acl\/resources\/admin\/system\/config\/shipping":"Mage_Shipping::config_shipping","config\/acl\/resources\/admin\/system\/config\/carriers":"Mage_Shipping::carriers","config\/acl\/resources\/admin\/catalog\/sitemap":"Mage_Sitemap::sitemap","config\/acl\/resources\/admin\/system\/config\/sitemap":"Mage_Sitemap::config_sitemap","config\/acl\/resources\/admin\/catalog\/tag":"Mage_Tag::tag","config\/acl\/resources\/admin\/catalog\/tag\/all":"Mage_Tag::tag_all","config\/acl\/resources\/admin\/catalog\/tag\/pending":"Mage_Tag::tag_pending","config\/acl\/resources\/admin\/sales\/tax":"Mage_Tax::sales_tax","config\/acl\/resources\/admin\/sales\/tax\/classes_customer":"Mage_Tax::classes_customer","config\/acl\/resources\/admin\/sales\/tax\/classes_product":"Mage_Tax::classes_product","config\/acl\/resources\/admin\/sales\/tax\/import_export":"Mage_Tax::import_export","config\/acl\/resources\/admin\/sales\/tax\/rates":"Mage_Tax::tax_rates","config\/acl\/resources\/admin\/sales\/tax\/rules":"Mage_Tax::rules","config\/acl\/resources\/admin\/system\/config\/tax":"Mage_Tax::config_tax","config\/acl\/resources\/admin\/system\/acl":"Mage_User::acl","config\/acl\/resources\/admin\/system\/acl\/roles":"Mage_User::acl_roles","config\/acl\/resources\/admin\/system\/acl\/users":"Mage_User::acl_users","config\/acl\/resources\/admin\/cms\/widget_instance":"Mage_Widget::widget_instance","config\/acl\/resources\/admin\/system\/config\/wishlist":"Mage_Wishlist::config_wishlist","config\/acl\/resources\/admin\/xmlconnect":"Mage_XmlConnect::xmlconnect","config\/acl\/resources\/admin\/xmlconnect\/mobile":"Mage_XmlConnect::mobile","config\/acl\/resources\/admin\/xmlconnect\/history":"Mage_XmlConnect::history","config\/acl\/resources\/admin\/xmlconnect\/templates":"Mage_XmlConnect::templates","config\/acl\/resources\/admin\/xmlconnect\/queue":"Mage_XmlConnect::xmlconnect_queue"} \ No newline at end of file diff --git a/dev/tools/migration/Acl/log/MenuIdToAclId.log b/dev/tools/migration/Acl/log/MenuIdToAclId.log new file mode 100644 index 00000000000..a3c32d85670 --- /dev/null +++ b/dev/tools/migration/Acl/log/MenuIdToAclId.log @@ -0,0 +1 @@ +{"Find_Feed::catalog_feed":"Find_Feed::feed","Find_Feed::catalog_feed_import_products":"Find_Feed::import_products","Find_Feed::catalog_feed_import_items":"Find_Feed::import_items","Enterprise_Banner::cms_enterprise_banner":"Enterprise_Banner::enterprise_banner","Enterprise_CatalogEvent::catalog_enterprise_catalogevent":"Mage_Catalog::categories","Enterprise_CatalogEvent::catalog_enterprise_catalogevent_events":"Enterprise_CatalogEvent::events","Enterprise_Cms::cms_enterprise_page":"Mage_Cms::page","Enterprise_Cms::cms_enterprise_page_page":"Mage_Cms::page","Enterprise_Cms::cms_enterprise_page_hierarchy":"Enterprise_Cms::hierarchy","Enterprise_CustomerSegment::customer_customersegment":"Enterprise_CustomerSegment::customersegment","Enterprise_CustomerSegment::report_customers_segment":"Enterprise_CustomerSegment::segment","Enterprise_Customer::customer_attributes":"Enterprise_Customer::attributes","Enterprise_Customer::customer_attributes_customer_attributes":"Enterprise_Customer::customer_attributes","Enterprise_Customer::customer_attributes_customer_address_attributes":"Enterprise_Customer::customer_address_attributes","Enterprise_GiftCardAccount::customer_giftcardaccount":"Enterprise_GiftCardAccount::customer_giftcardaccount","Enterprise_GiftRegistry::customer_enterprise_giftregistry":"Enterprise_GiftRegistry::customer_enterprise_giftregistry","Enterprise_GiftWrapping::sales_enterprise_giftwrapping":"Enterprise_GiftWrapping::enterprise_giftwrapping","Enterprise_ImportExport::system_convert_enterprise_scheduled_operation":"Enterprise_ImportExport::enterprise_scheduled_operation","Enterprise_Invitation::customer_enterprise_invitation":"Enterprise_Invitation::enterprise_invitation","Enterprise_Invitation::report_enterprise_invitation":"Enterprise_Invitation::report_enterprise_invitation","Enterprise_Invitation::report_enterprise_invitation_general":"Enterprise_Invitation::report_enterprise_invitation","Enterprise_Invitation::report_enterprise_invitation_customer":"Enterprise_Invitation::report_enterprise_invitation","Enterprise_Invitation::report_enterprise_invitation_order":"Enterprise_Invitation::report_enterprise_invitation","Enterprise_Logging::system_enterprise_logging":"Enterprise_Logging::enterprise_logging","Enterprise_Logging::system_enterprise_logging_events":"Enterprise_Logging::enterprise_logging_events","Enterprise_Logging::system_enterprise_logging_backups":"Enterprise_Logging::backups","Enterprise_Pci::system_crypt_key":"Enterprise_Pci::crypt_key","Enterprise_Pci::system_acl_locks":"Enterprise_Pci::locks","Enterprise_Reminder::promo_reminder":"Enterprise_Reminder::enterprise_reminder","Enterprise_Reward::customer_reward":"Enterprise_Reward::rates","Enterprise_Rma::sales_enterprise_rma":"Enterprise_Rma::enterprise_rma","Enterprise_Rma::sales_enterprise_rma_rma":"Enterprise_Rma::enterprise_rma","Enterprise_Rma::sales_enterprise_rma_rma_item_attribute":"Enterprise_Rma::enterprise_rma","Enterprise_SalesArchive::sales_archive":"Enterprise_SalesArchive::archive","Enterprise_SalesArchive::sales_archive_orders":"Enterprise_SalesArchive::orders","Enterprise_SalesArchive::sales_archive_invoices":"Enterprise_SalesArchive::invoices","Enterprise_SalesArchive::sales_archive_shipments":"Enterprise_SalesArchive::shipments","Enterprise_SalesArchive::sales_archive_creditmemos":"Enterprise_SalesArchive::creditmemos","Enterprise_Staging::system_enterprise_staging":"Enterprise_Staging::enterprise_staging","Enterprise_Staging::system_enterprise_staging_staging_grid":"Enterprise_Staging::staging_grid","Enterprise_Staging::system_enterprise_staging_staging_backup":"Enterprise_Staging::staging_backup","Enterprise_Staging::system_enterprise_staging_staging_log":"Enterprise_Staging::staging_log","Enterprise_TargetRule::catalog_targetrule":"Enterprise_TargetRule::targetrule","Enterprise_Wishlist::report_customers_wishlist":"Enterprise_Wishlist::wishlist","Mage_AdminNotification::system_adminnotification":"Mage_AdminNotification::adminnotification","Mage_Adminhtml::dashboard":"Mage_Adminhtml::dashboard","Mage_Adminhtml::system":"Mage_Adminhtml::system","Mage_Adminhtml::system_myaccount":"Mage_Adminhtml::myaccount","Mage_Adminhtml::system_tools":"Mage_Adminhtml::tools","Mage_Adminhtml::system_design":"Mage_Adminhtml::design","Mage_Adminhtml::system_design_schedule":"Mage_Adminhtml::schedule","Mage_Adminhtml::system_convert":"Mage_Adminhtml::convert","Mage_Adminhtml::system_convert_gui":"Mage_Adminhtml::gui","Mage_Adminhtml::system_convert_profiles":"Mage_Adminhtml::profiles","Mage_Adminhtml::system_currency":"Mage_CurrencySymbol::system_currency","Mage_Adminhtml::system_email_template":"Mage_Adminhtml::email_template","Mage_Adminhtml::system_variable":"Mage_Adminhtml::variable","Mage_Adminhtml::system_cache":"Mage_Adminhtml::cache","Mage_Adminhtml::system_store":"Mage_Adminhtml::store","Mage_Adminhtml::system_config":"Mage_Adminhtml::config","Mage_Api2::system_api_rest_roles":"Mage_Api2::rest_roles","Mage_Api2::system_api_rest_attributes":"Mage_Api2::rest_attributes","Mage_Api::system_api":"Mage_Api::api","Mage_Api::system_api_users":"Mage_Api::users","Mage_Api::system_api_roles":"Mage_Api::roles","Mage_Backup::system_tools_backup":"Mage_Backup::backup","Mage_CatalogRule::promo":"Mage_CatalogRule::promo","Mage_CatalogRule::promo_catalog":"Mage_CatalogRule::promo_catalog","Mage_CatalogSearch::catalog_search":"Mage_CatalogSearch::search","Mage_Catalog::catalog":"Mage_Catalog::catalog","Mage_Catalog::catalog_products":"Mage_Catalog::products","Mage_Catalog::catalog_categories":"Mage_Catalog::categories","Mage_Catalog::catalog_attributes":"Mage_Catalog::catalog_attributes","Mage_Catalog::catalog_attributes_attributes":"Mage_Catalog::attributes_attributes","Mage_Catalog::catalog_attributes_sets":"Mage_Catalog::sets","Mage_Catalog::catalog_urlrewrite":"Mage_Catalog::urlrewrite","Mage_Checkout::sales_checkoutagreement":"Mage_Checkout::checkoutagreement","Mage_Cms::cms":"Mage_Cms::cms","Mage_Cms::cms_page":"Mage_Cms::page","Mage_Cms::cms_block":"Mage_Cms::block","Mage_Connect::system_extensions":"Mage_Adminhtml::extensions","Mage_Connect::system_extensions_local":"Mage_Adminhtml::local","Mage_Connect::system_extensions_custom":"Mage_Adminhtml::custom","Mage_CurrencySymbol::system_currency_rates":"Mage_CurrencySymbol::currency_rates","Mage_CurrencySymbol::system_currency_symbols":"Mage_CurrencySymbol::symbols","Mage_Customer::customer":"Mage_Customer::customer","Mage_Customer::customer_manage":"Mage_Customer::manage","Mage_Customer::customer_group":"Mage_Customer::group","Mage_Customer::customer_online":"Mage_Customer::online","Mage_DesignEditor::system_design_editor":"Mage_DesignEditor::editor","Mage_Downloadable::report_products_downloads":"Mage_Reports::downloads","Mage_GoogleShopping::catalog_googleshopping":"Mage_GoogleShopping::googleshopping","Mage_GoogleShopping::catalog_googleshopping_types":"Mage_GoogleShopping::types","Mage_GoogleShopping::catalog_googleshopping_items":"Mage_GoogleShopping::items","Mage_ImportExport::system_convert_import":"Mage_ImportExport::import","Mage_ImportExport::system_convert_export":"Mage_ImportExport::export","Mage_Index::system_index":"Mage_Index::index","Mage_Newsletter::newsletter":"Mage_Newsletter::admin_newsletter","Mage_Newsletter::newsletter_template":"Mage_Newsletter::template","Mage_Newsletter::newsletter_queue":"Mage_Newsletter::queue","Mage_Newsletter::newsletter_subscriber":"Mage_Newsletter::subscriber","Mage_Newsletter::newsletter_problem":"Mage_Newsletter::problem","Mage_Oauth::system_api_oauth_admin_token":"Mage_Oauth::oauth_admin_token","Mage_Paypal::report_salesroot_paypal_settlement_reports":"Mage_Paypal::paypal_settlement_reports","Mage_Poll::cms_poll":"Mage_Poll::poll","Mage_Reports::report":"Mage_Reports::report","Mage_Reports::report_salesroot":"Mage_Reports::salesroot","Mage_Reports::report_salesroot_sales":"Mage_Reports::salesroot_sales","Mage_Reports::report_salesroot_tax":"Mage_Reports::tax","Mage_Reports::report_salesroot_invoiced":"Mage_Reports::invoiced","Mage_Reports::report_salesroot_shipping":"Mage_Reports::shipping","Mage_Reports::report_salesroot_refunded":"Mage_Reports::refunded","Mage_Reports::report_salesroot_coupons":"Mage_Reports::coupons","Mage_Reports::report_shopcart":"Mage_Reports::shopcart","Mage_Reports::report_shopcart_product":"Mage_Reports::product","Mage_Reports::report_shopcart_abandoned":"Mage_Reports::abandoned","Mage_Reports::report_products":"Mage_Reports::report_products","Mage_Reports::report_products_bestsellers":"Mage_Reports::bestsellers","Mage_Reports::report_products_sold":"Mage_Reports::sold","Mage_Reports::report_products_viewed":"Mage_Reports::viewed","Mage_Reports::report_products_lowstock":"Mage_Reports::lowstock","Mage_Reports::report_customers":"Mage_Reports::customers","Mage_Reports::report_customers_accounts":"Mage_Reports::accounts","Mage_Reports::report_customers_totals":"Mage_Reports::totals","Mage_Reports::report_customers_orders":"Mage_Reports::customers_orders","Mage_Reports::report_search":"Mage_Reports::report_search","Mage_Reports::report_statistics":"Mage_Reports::statistics","Mage_Review::catalog_reviews_ratings":"Mage_Review::reviews_ratings","Mage_Review::catalog_reviews_ratings_reviews":"Mage_Review::reviews","Mage_Review::catalog_reviews_ratings_ratings":"Mage_Rating::ratings","Mage_Review::catalog_reviews_ratings_reviews_pending":"Mage_Review::pending","Mage_Review::catalog_reviews_ratings_reviews_all":"Mage_Review::reviews_all","Mage_Review::report_review":"Mage_Reports::review","Mage_Review::report_review_customer":"Mage_Reports::review_customer","Mage_Review::report_review_product":"Mage_Reports::review_product","Mage_SalesRule::promo_quote":"Mage_SalesRule::quote","Mage_Sales::sales":"Mage_Sales::sales","Mage_Sales::sales_order":"Mage_Sales::sales_order","Mage_Sales::sales_invoice":"Mage_Sales::sales_invoice","Mage_Sales::sales_shipment":"Mage_Sales::shipment","Mage_Sales::sales_creditmemo":"Mage_Sales::sales_creditmemo","Mage_Sales::sales_transactions":"Mage_Sales::transactions","Mage_Sales::sales_recurring_profile":"Mage_Sales::recurring_profile","Mage_Sales::sales_billing_agreement":"Mage_Sales::billing_agreement","Mage_Sales::system_order_statuses":"Mage_Sales::order_statuses","Mage_Sitemap::catalog_sitemap":"Mage_Sitemap::sitemap","Mage_Tag::catalog_tag":"Mage_Tag::tag","Mage_Tag::catalog_tag_all":"Mage_Tag::tag_all","Mage_Tag::catalog_tag_pending":"Mage_Tag::tag_pending","Mage_Tag::report_tags":"Mage_Reports::tags","Mage_Tag::report_tags_customer":"Mage_Reports::tags_customer","Mage_Tag::report_tags_product":"Mage_Reports::tags_product","Mage_Tag::report_tags_popular":"Mage_Reports::popular","Mage_Tax::sales_tax":"Mage_Tax::sales_tax","Mage_Tax::sales_tax_rules":"Mage_Tax::rules","Mage_Tax::sales_tax_rates":"Mage_Tax::tax_rates","Mage_Tax::sales_tax_import_export":"Mage_Tax::import_export","Mage_Tax::sales_tax_classes_customer":"Mage_Tax::classes_customer","Mage_Tax::sales_tax_classes_product":"Mage_Tax::classes_product","Mage_User::system_acl":"Mage_User::acl","Mage_User::system_acl_users":"Mage_User::acl_users","Mage_User::system_acl_roles":"Mage_User::acl_roles","Mage_Widget::cms_widget_instance":"Mage_Widget::widget_instance","Mage_XmlConnect::xmlconnect":"Mage_XmlConnect::xmlconnect","Mage_XmlConnect::xmlconnect_mobile":"Mage_XmlConnect::mobile","Mage_XmlConnect::xmlconnect_history":"Mage_XmlConnect::history","Mage_XmlConnect::xmlconnect_templates":"Mage_XmlConnect::templates","Mage_XmlConnect::xmlconnect_queue":"Mage_XmlConnect::xmlconnect_queue"} \ No newline at end of file diff --git a/dev/tools/migration/acl.php b/dev/tools/migration/acl.php new file mode 100644 index 00000000000..09b99325e44 --- /dev/null +++ b/dev/tools/migration/acl.php @@ -0,0 +1,42 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Tools + * @package acl + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +require_once ('./Acl/Generator.php'); +require_once ('./Acl/FileWriter.php'); +require_once ('./Acl/Formatter.php'); + +$shortOpts = 'ph'; +$options = getopt($shortOpts); +try { + $tool = new Tools_Migration_Acl_Generator( + new Tools_Migration_Acl_Formatter(), + new Tools_Migration_Acl_FileWriter(), $options + ); + $tool->run(); +} catch (Exception $exp) { + echo $exp->getMessage(); +} + diff --git a/downloader/Maged/Model/Session.php b/downloader/Maged/Model/Session.php index eed4443a0fd..fd027677bbc 100644 --- a/downloader/Maged/Model/Session.php +++ b/downloader/Maged/Model/Session.php @@ -138,7 +138,7 @@ class Maged_Model_Session extends Maged_Model $this->addMessage('error', 'Invalid user name or password'); $this->controller()->setAction('login'); } elseif ($this->getUserId() || ($user && $user->getId())) { - if ($this->_session->isAllowed('all')) { + if ($this->_session->isAllowed('Mage_Adminhtml::all')) { return true; } else { $this->logout(); diff --git a/index.php b/index.php index 65f5ca00090..1529468d3de 100644 --- a/index.php +++ b/index.php @@ -30,5 +30,10 @@ require_once 'app/bootstrap.php'; $mageRunCode = isset($_SERVER['MAGE_RUN_CODE']) ? $_SERVER['MAGE_RUN_CODE'] : ''; /* Run store or run website */ $mageRunType = isset($_SERVER['MAGE_RUN_TYPE']) ? $_SERVER['MAGE_RUN_TYPE'] : 'store'; +/* Additional local.xml file from environment variable */ +$options = array(); +if (!empty($_SERVER['MAGE_LOCAL_CONFIG'])) { + $options['local_config'] = $_SERVER['MAGE_LOCAL_CONFIG']; +} -Mage::run($mageRunCode, $mageRunType); +Mage::run($mageRunCode, $mageRunType, $options); diff --git a/index.php.sample b/index.php.sample index 763066a3f28..29098a49ef4 100644 --- a/index.php.sample +++ b/index.php.sample @@ -26,30 +26,14 @@ $bootstrapFile = 'app/bootstrap.php'; -if (!file_exists($bootstrapFile)) { - if (is_dir('downloader')) { - header("Location: downloader"); - } else { - echo "{$bootstrapFile} was not found"; - } - exit; -} - -if (file_exists('maintenance.flag')) { - include_once dirname(__FILE__) . '/pub/errors/503.php'; - exit; -} - -require_once $bootstrapFile; - -#Magento_Profiler::enable(); -#Magento_Profiler::registerOutput(new Magento_Profiler_Output_Html()); -#Magento_Profiler::registerOutput(new Magento_Profiler_Output_Firebug()); -#Magento_Profiler::registerOutput(new Magento_Profiler_Output_Csvfile(__DIR__ . '/var/log/profiler.csv')); - /* Store or website code */ $mageRunCode = isset($_SERVER['MAGE_RUN_CODE']) ? $_SERVER['MAGE_RUN_CODE'] : ''; /* Run store or run website */ $mageRunType = isset($_SERVER['MAGE_RUN_TYPE']) ? $_SERVER['MAGE_RUN_TYPE'] : 'store'; +/* Additional local.xml file from environment variable */ +$options = array(); +if (!empty($_SERVER['MAGE_LOCAL_CONFIG'])) { + $options['local_config'] = $_SERVER['MAGE_LOCAL_CONFIG']; +} -Mage::run($mageRunCode, $mageRunType); +Mage::run($mageRunCode, $mageRunType, $options); diff --git a/app/code/core/Mage/Admin/Model/Acl.php b/lib/Magento/Acl.php similarity index 65% rename from app/code/core/Mage/Admin/Model/Acl.php rename to lib/Magento/Acl.php index 57ad0e01ff7..e951668087d 100644 --- a/app/code/core/Mage/Admin/Model/Acl.php +++ b/lib/Magento/Acl.php @@ -18,34 +18,18 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Mage - * @package Mage_Admin + * @category Magento + * @package Framework + * @subpackage Acl * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - /** - * Acl model - * - * @category Mage - * @package Mage_Admin - * @author Magento Core Team <core@magentocommerce.com> + * Access Control List. Is used to store and check permissions of users. */ -class Mage_Admin_Model_Acl extends Zend_Acl +class Magento_Acl extends Zend_Acl { - /** - * All the group roles are prepended by G - * - */ - const ROLE_TYPE_GROUP = 'G'; - - /** - * All the user roles are prepended by U - * - */ - const ROLE_TYPE_USER = 'U'; - /** * Permission level to deny access * @@ -63,18 +47,10 @@ class Mage_Admin_Model_Acl extends Zend_Acl * */ const RULE_PERM_ALLOW = 2; - - /** - * Get role registry object or create one - * - * @return Mage_Admin_Model_Acl_Role_Registry - */ - protected function _getRoleRegistry() + + public function __construct() { - if (null === $this->_roleRegistry) { - $this->_roleRegistry = Mage::getModel('Mage_Admin_Model_Acl_Role_Registry'); - } - return $this->_roleRegistry; + $this->_roleRegistry = new Magento_Acl_Role_Registry(); } /** @@ -82,7 +58,7 @@ class Mage_Admin_Model_Acl extends Zend_Acl * * @param Zend_Acl_Role $role * @param Zend_Acl_Role $parent - * @return Mage_Admin_Model_Acl + * @return Magento_Acl */ public function addRoleParent($role, $parent) { diff --git a/lib/Magento/Acl/Loader.php b/lib/Magento/Acl/Loader.php new file mode 100644 index 00000000000..9fcd98a61b3 --- /dev/null +++ b/lib/Magento/Acl/Loader.php @@ -0,0 +1,41 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Magento + * @package Framework + * @subpackage ACL + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +/** + * Access Control List loader. All classes implementing this interface should have ability to populate ACL object + * with data (roles/rules/resources) persisted in external storage. + */ +interface Magento_Acl_Loader +{ + /** + * Populate ACL with data from external storage + * + * @abstract + * @param Magento_Acl $acl + */ + public function populateAcl(Magento_Acl $acl); +} diff --git a/lib/Magento/Acl/Loader/Default.php b/lib/Magento/Acl/Loader/Default.php new file mode 100644 index 00000000000..9ef3e65c86d --- /dev/null +++ b/lib/Magento/Acl/Loader/Default.php @@ -0,0 +1,44 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Magento + * @package Framework + * @subpackage Acl + * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +/** + * Default acl loader. Used as a fallback when no loaders were defined. Doesn't change ACL object passed. + */ +class Magento_Acl_Loader_Default implements Magento_Acl_Loader +{ + + /** + * Don't do anything to acl object. + * + * @param Magento_Acl $acl + * @return mixed + */ + public function populateAcl(Magento_Acl $acl) + { + // Do nothing + } +} diff --git a/app/code/core/Mage/Admin/Model/Acl/Resource.php b/lib/Magento/Acl/Resource.php similarity index 80% rename from app/code/core/Mage/Admin/Model/Acl/Resource.php rename to lib/Magento/Acl/Resource.php index 54ce97615e0..a4508bd3fec 100644 --- a/app/code/core/Mage/Admin/Model/Acl/Resource.php +++ b/lib/Magento/Acl/Resource.php @@ -18,21 +18,17 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Mage - * @package Mage_Admin + * @category Magento + * @package Framework + * @subpackage Acl * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - /** * Acl resource - * - * @category Mage - * @package Mage_Admin - * @author Magento Core Team <core@magentocommerce.com> */ -class Mage_Admin_Model_Acl_Resource extends Zend_Acl_Resource +class Magento_Acl_Resource extends Zend_Acl_Resource { } diff --git a/app/code/core/Mage/Admin/Model/Acl/Role/Registry.php b/lib/Magento/Acl/Role/Registry.php similarity index 88% rename from app/code/core/Mage/Admin/Model/Acl/Role/Registry.php rename to lib/Magento/Acl/Role/Registry.php index 41c56f9d4d3..4aa8bd07131 100644 --- a/app/code/core/Mage/Admin/Model/Acl/Role/Registry.php +++ b/lib/Magento/Acl/Role/Registry.php @@ -18,28 +18,25 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Mage - * @package Mage_Admin + * @category Magento + * @package Framework + * @subpackage Acl * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - /** - * Acl role registry - * - * @category Mage - * @package Mage_Admin - * @author Magento Core Team <core@magentocommerce.com> + * Acl role registry. Contains list of roles and their relations. */ -class Mage_Admin_Model_Acl_Role_Registry extends Zend_Acl_Role_Registry +class Magento_Acl_Role_Registry extends Zend_Acl_Role_Registry { /** * Add parent to the $role node * * @param Zend_Acl_Role_Interface|string $role * @param array|Zend_Acl_Role_Interface|string $parents - * @return Mage_Auth_Model_Acl_Role_Registry + * @return Magento_Acl_Role_Registry + * @throws Zend_Acl_Role_Registry_Exception */ function addParent($role, $parents) { diff --git a/lib/Magento/Config/Dom.php b/lib/Magento/Config/Dom.php index 527083f11d3..bf0f076d354 100644 --- a/lib/Magento/Config/Dom.php +++ b/lib/Magento/Config/Dom.php @@ -92,11 +92,7 @@ class Magento_Config_Dom /* Update matched node attributes and value */ if ($matchedNode) { foreach ($node->attributes as $attribute) { - if ($matchedNode->getAttribute($attribute->name)) { - $matchedNode->setAttribute($attribute->name, $attribute->value); - } else { - $matchedNode->setAttributeNode($attribute); - } + $matchedNode->setAttribute($attribute->name, $attribute->value); } /* Merge child nodes */ if ($node->hasChildNodes()) { diff --git a/pub/index.php b/pub/index.php index 417ade6b700..fe96361b525 100644 --- a/pub/index.php +++ b/pub/index.php @@ -30,6 +30,10 @@ require_once '../app/bootstrap.php'; $mageRunCode = isset($_SERVER['MAGE_RUN_CODE']) ? $_SERVER['MAGE_RUN_CODE'] : ''; /* Run store or run website */ $mageRunType = isset($_SERVER['MAGE_RUN_TYPE']) ? $_SERVER['MAGE_RUN_TYPE'] : 'store'; +/* Additional local.xml file from environment variable */ +$options = array(); +if (!empty($_SERVER['MAGE_LOCAL_CONFIG'])) { + $options['local_config'] = $_SERVER['MAGE_LOCAL_CONFIG']; +} -Mage::run($mageRunCode, $mageRunType); - +Mage::run($mageRunCode, $mageRunType, $options); -- GitLab