Skip to content

[MAGETWO-54158]:+ Corrected ACL rules for the sendfriend module and s… #9628

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions app/code/Magento/Backend/etc/acl.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@
<resource id="Magento_Backend::stores" title="Stores" translate="title" sortOrder="80">
<resource id="Magento_Backend::stores_settings" title="Settings" translate="title" sortOrder="10">
<resource id="Magento_Backend::store" title="All Stores" translate="title" sortOrder="10"/>
<resource id="Magento_Config::config" title="Configuration" translate="title" sortOrder="20">
<resource id="Magento_Backend::advanced" title="Advanced Section" translate="title" sortOrder="90" />
<resource id="Magento_Backend::currency" title="Currency Setup Section" translate="title" sortOrder="120" />
<resource id="Magento_Backend::dev" title="Developer Section" translate="title" sortOrder="110" />
<resource id="Magento_Backend::web" title="Web Section" translate="title" sortOrder="30" />
<resource id="Magento_Backend::trans_email" title="Store Email Addresses Section" translate="title" sortOrder="100" />
</resource>
</resource>
<resource id="Magento_Backend::stores_attributes" title="Attributes" translate="title" sortOrder="40" />
<resource id="Magento_Backend::stores_other_settings" title="Other Settings" translate="title" sortOrder="50" />
Expand Down
56 changes: 56 additions & 0 deletions app/code/Magento/Config/Setup/UpgradeData.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php
/**
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Config\Setup;

use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\UpgradeDataInterface;

/**
* @codeCoverageIgnore
*/
class UpgradeData implements UpgradeDataInterface
{

/**
Copy link
Contributor

Choose a reason for hiding this comment

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

{@inheritdoc} is sufficient in this case.

* {@inheritdoc}
*/
public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
{
if (version_compare($context->getVersion(), '2.0.1', '<')) {
$this->upgradeAcl($setup);
}
}

/**
* ACL roles were moved to Magento_Backend
* for backward compatibility, roles that are already defined as Magento_Config should be updated to Magento_Backend
*
* @param ModuleDataSetupInterface $setup
* @return void
*/
private function upgradeAcl(ModuleDataSetupInterface $setup)
{

$aclUpdates = [
'Magento_Config::dev' => 'Magento_Backend::dev',
'Magento_Config::web' => 'Magento_Backend::web',
'Magento_Config::trans_email' => 'Magento_Backend::trans_email',
'Magento_Config::currency' => 'Magento_Backend::currency',
'Magento_Config::advanced' => 'Magento_Backend::advanced',
];

foreach ($aclUpdates as $aclKey => $aclUpdate) {
$setup->getConnection()->update(
$setup->getTable('authorization_rule'),
['resource_id' => $aclUpdate],
['resource_id = ?' => $aclKey]
);
}

}
}
6 changes: 0 additions & 6 deletions app/code/Magento/Config/etc/acl.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,10 @@
<resource id="Magento_Backend::stores">
<resource id="Magento_Backend::stores_settings">
<resource id="Magento_Config::config" title="Configuration" translate="title" sortOrder="20">
<resource id="Magento_Config::advanced" title="Advanced Section" translate="title" sortOrder="90" />
<resource id="Magento_Config::config_admin" title="Advanced Admin Section" translate="title" sortOrder="100" />
<resource id="Magento_Config::config_design" title="Design Section" translate="title" sortOrder="40" />
<resource id="Magento_Config::config_general" title="General Section" translate="title" sortOrder="20" />
<resource id="Magento_Config::config_system" title="System Section" translate="title" sortOrder="80" />
<resource id="Magento_Config::currency" title="Currency Setup Section" translate="title" sortOrder="120" />
<resource id="Magento_Config::dev" title="Developer Section" translate="title" sortOrder="110" />
<resource id="Magento_Config::web" title="Web Section" translate="title" sortOrder="30" />
<resource id="Magento_Config::trans_email" title="Store Email Addresses Section" translate="title" sortOrder="100" />
<resource id="Magento_Config::sendfriend" title="Email to a Friend" translate="title" sortOrder="140" />
</resource>
</resource>
</resource>
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Config/etc/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Magento_Config" setup_version="2.0.0"/>
<module name="Magento_Config" setup_version="2.0.1"/>
</config>
46 changes: 46 additions & 0 deletions app/code/Magento/SendFriend/Setup/UpgradeData.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php
/**
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\SendFriend\Setup;

use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\UpgradeDataInterface;

/**
* @codeCoverageIgnore
*/
class UpgradeData implements UpgradeDataInterface
{

/**
* {@inheritdoc}
*/
public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
{
if (version_compare($context->getVersion(), '2.0.1', '<')) {
$this->upgradeAcl($setup);
}
}

/**
* ACL roles were moved to Magento_Backend
* for backward compatibility, roles that are already defined as Magento_Config should be updated to Magento_Backend
*
* @param ModuleDataSetupInterface $setup
* @return void
*/
private function upgradeAcl(ModuleDataSetupInterface $setup)
{

$setup->getConnection()->update(
$setup->getTable('authorization_rule'),
['resource_id' => 'Magento_Backend::sendfriend'],
['resource_id = ?' => 'Magento_Config::sendfriend']
);

}
}
22 changes: 22 additions & 0 deletions app/code/Magento/SendFriend/etc/acl.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0"?>
<!--
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Acl/etc/acl.xsd">
<acl>
<resources>
<resource id="Magento_Backend::admin">
<resource id="Magento_Backend::stores">
<resource id="Magento_Backend::stores_settings">
<resource id="Magento_Config::config">
<resource id="Magento_Backend::sendfriend" title="Email to a Friend" translate="title" sortOrder="140" />
</resource>
</resource>
</resource>
</resource>
</resources>
</acl>
</config>
2 changes: 1 addition & 1 deletion app/code/Magento/SendFriend/etc/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Magento_SendFriend" setup_version="2.0.0">
<module name="Magento_SendFriend" setup_version="2.0.1">
<sequence>
<module name="Magento_Catalog"/>
</sequence>
Expand Down