Skip to content

Commit b99b84b

Browse files
author
OlgaVasyltsun
committed
MAGETWO-98202: Additional Permissions for Design settings
1 parent 0999f07 commit b99b84b

File tree

10 files changed

+22
-44
lines changed

10 files changed

+22
-44
lines changed

app/code/Magento/Catalog/Model/Category.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -936,16 +936,14 @@ public function beforeDelete()
936936
}
937937

938938
/**
939-
* @inheritDoc
939+
* @inheritdoc
940940
*/
941941
public function beforeSave()
942942
{
943943
//Validate changing of design.
944944
$userType = $this->userContext->getUserType();
945-
if ((
946-
$userType === UserContextInterface::USER_TYPE_ADMIN
947-
|| $userType === UserContextInterface::USER_TYPE_INTEGRATION
948-
)
945+
if (($userType === UserContextInterface::USER_TYPE_ADMIN
946+
|| $userType === UserContextInterface::USER_TYPE_INTEGRATION)
949947
&& !$this->authorization->isAllowed('Magento_Catalog::edit_category_design')
950948
) {
951949
$this->setData('custom_design', $this->getOrigData('custom_design'));

app/code/Magento/Catalog/Model/Product.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -873,10 +873,8 @@ public function beforeSave()
873873

874874
//Validate changing of design.
875875
$userType = $this->userContext->getUserType();
876-
if ((
877-
$userType === UserContextInterface::USER_TYPE_ADMIN
878-
|| $userType === UserContextInterface::USER_TYPE_INTEGRATION
879-
)
876+
if (($userType === UserContextInterface::USER_TYPE_ADMIN
877+
|| $userType === UserContextInterface::USER_TYPE_INTEGRATION)
880878
&& !$this->authorization->isAllowed('Magento_Catalog::edit_product_design')
881879
) {
882880
$this->setData('custom_design', $this->getOrigData('custom_design'));

app/code/Magento/Catalog/Model/ResourceModel/Category.php

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
use Magento\Framework\EntityManager\EntityManager;
1515
use Magento\Catalog\Api\Data\CategoryInterface;
16-
use Magento\Catalog\Model\Category as CategoryEntity;
1716

1817
/**
1918
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
@@ -1077,19 +1076,4 @@ private function getAggregateCount()
10771076
}
10781077
return $this->aggregateCount;
10791078
}
1080-
1081-
/**
1082-
* @inheritdoc
1083-
*
1084-
* @param CategoryEntity|\Magento\Framework\DataObject $object
1085-
*/
1086-
public function validate($object)
1087-
{
1088-
$isValid = parent::validate($object);
1089-
if ($isValid !== true) {
1090-
return $isValid;
1091-
}
1092-
1093-
return true;
1094-
}
10951079
}

app/code/Magento/Catalog/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"magento/module-media-storage": "100.1.*",
2828
"magento/framework": "100.1.*",
2929
"magento/module-ui": "100.1.*",
30-
"magento/module-authorization": "*"
30+
"magento/module-authorization": "100.1.*"
3131
},
3232
"suggest": {
3333
"magento/module-cookie": "100.1.*",

app/code/Magento/Cms/Model/Page/DataProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public function getData()
101101
}
102102

103103
/**
104-
* @inheritDoc
104+
* @inheritdoc
105105
*/
106106
public function getMeta()
107107
{

app/code/Magento/Cms/Model/PageRepository.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,8 @@ public function save(\Magento\Cms\Api\Data\PageInterface $page)
130130
try {
131131
//Validate changing of design.
132132
$userType = $this->userContext->getUserType();
133-
if ((
134-
$userType === UserContextInterface::USER_TYPE_ADMIN
135-
|| $userType === UserContextInterface::USER_TYPE_INTEGRATION
136-
)
133+
if (($userType === UserContextInterface::USER_TYPE_ADMIN
134+
|| $userType === UserContextInterface::USER_TYPE_INTEGRATION)
137135
&& !$this->authorization->isAllowed('Magento_Cms::save_design')
138136
) {
139137
if (!$page->getId()) {

app/code/Magento/Cms/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"magento/module-variable": "100.1.*",
1414
"magento/module-media-storage": "100.1.*",
1515
"magento/framework": "100.1.*",
16-
"magento/module-authorization": "*"
16+
"magento/module-authorization": "100.1.*"
1717
},
1818
"suggest": {
1919
"magento/module-cms-sample-data": "Sample Data version:100.1.*"

dev/tests/integration/testsuite/Magento/Catalog/Model/CategoryRepositoryTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class CategoryRepositoryTest extends \PHPUnit_Framework_TestCase
2222
*
2323
* @var CategoryRepositoryInterface
2424
*/
25-
private $repo;
25+
private $repository;
2626

2727
/**
2828
* @var Auth
@@ -41,13 +41,13 @@ class CategoryRepositoryTest extends \PHPUnit_Framework_TestCase
4141
*/
4242
protected function setUp()
4343
{
44-
$this->repo = Bootstrap::getObjectManager()->create(CategoryRepositoryInterface::class);
44+
$this->repository = Bootstrap::getObjectManager()->create(CategoryRepositoryInterface::class);
4545
$this->auth = Bootstrap::getObjectManager()->get(Auth::class);
4646
$this->aclBuilder = Bootstrap::getObjectManager()->get(Builder::class);
4747
}
4848

4949
/**
50-
* @inheritDoc
50+
* @inheritdoc
5151
*/
5252
protected function tearDown()
5353
{
@@ -66,22 +66,22 @@ protected function tearDown()
6666
*/
6767
public function testSaveDesign()
6868
{
69-
$category = $this->repo->get(333);
69+
$category = $this->repository->get(333);
7070
$this->auth->login(TestBootstrap::ADMIN_NAME, TestBootstrap::ADMIN_PASSWORD);
7171

7272
//Admin doesn't have access to category's design.
7373
$this->aclBuilder->getAcl()->deny(null, 'Magento_Catalog::edit_category_design');
7474

7575
$category->setCustomAttribute('custom_design', 2);
76-
$category = $this->repo->save($category);
76+
$category = $this->repository->save($category);
7777
$this->assertEmpty($category->getCustomAttribute('custom_design'));
7878

7979
//Admin has access to category' design.
8080
$this->aclBuilder->getAcl()
8181
->allow(null, ['Magento_Catalog::categories', 'Magento_Catalog::edit_category_design']);
8282

8383
$category->setCustomAttribute('custom_design', 2);
84-
$category = $this->repo->save($category);
84+
$category = $this->repository->save($category);
8585
$this->assertNotEmpty($category->getCustomAttribute('custom_design'));
8686
$this->assertEquals(2, $category->getCustomAttribute('custom_design')->getValue());
8787
}

dev/tests/integration/testsuite/Magento/Catalog/Model/ProductRepositoryTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ protected function setUp()
4848
}
4949

5050
/**
51-
* @inheritDoc
51+
* @inheritdoc
5252
*/
5353
protected function tearDown()
5454
{

dev/tests/integration/testsuite/Magento/Cms/Model/PageRepositoryTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class PageRepositoryTest extends \PHPUnit_Framework_TestCase
2424
*
2525
* @var PageRepositoryInterface
2626
*/
27-
private $repo;
27+
private $repository;
2828

2929
/**
3030
* @var Auth
@@ -53,15 +53,15 @@ class PageRepositoryTest extends \PHPUnit_Framework_TestCase
5353
*/
5454
protected function setUp()
5555
{
56-
$this->repo = Bootstrap::getObjectManager()->create(PageRepositoryInterface::class);
56+
$this->repository = Bootstrap::getObjectManager()->create(PageRepositoryInterface::class);
5757
$this->auth = Bootstrap::getObjectManager()->get(Auth::class);
5858
$this->criteriaBuilder = Bootstrap::getObjectManager()->get(SearchCriteriaBuilder::class);
5959
$this->aclBuilder = Bootstrap::getObjectManager()->get(Builder::class);
6060
$this->pageCollectionFactory = Bootstrap::getObjectManager()->get(PageCollectionFactory::class);
6161
}
6262

6363
/**
64-
* @inheritDoc
64+
* @inheritdoc
6565
*/
6666
protected function tearDown()
6767
{
@@ -90,14 +90,14 @@ public function testSaveDesign()
9090
$this->aclBuilder->getAcl()->deny(null, 'Magento_Cms::save_design');
9191

9292
$page->setCustomTheme('test');
93-
$page = $this->repo->save($page);
93+
$page = $this->repository->save($page);
9494
$this->assertNotEquals('test', $page->getCustomTheme());
9595

9696
//Admin has access to page' design.
9797
$this->aclBuilder->getAcl()->allow(null, ['Magento_Cms::save', 'Magento_Cms::save_design']);
9898

9999
$page->setCustomTheme('test');
100-
$page = $this->repo->save($page);
100+
$page = $this->repository->save($page);
101101
$this->assertEquals('test', $page->getCustomTheme());
102102
}
103103
}

0 commit comments

Comments
 (0)