Skip to content
This repository was archived by the owner on Apr 29, 2019. It is now read-only.

Commit cb3cb4a

Browse files
MAGETWO-85040: Magento 2.2.3 Publication
1 parent 3c4cb60 commit cb3cb4a

File tree

141 files changed

+27265
-23814
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

141 files changed

+27265
-23814
lines changed

app/code/Magento/Backend/Block/Cache.php

+22-17
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,29 @@ protected function _construct()
2222
$this->_headerText = __('Cache Storage Management');
2323
parent::_construct();
2424
$this->buttonList->remove('add');
25-
$this->buttonList->add(
26-
'flush_magento',
27-
[
28-
'label' => __('Flush Magento Cache'),
29-
'onclick' => 'setLocation(\'' . $this->getFlushSystemUrl() . '\')',
30-
'class' => 'primary flush-cache-magento'
31-
]
32-
);
3325

34-
$message = __('The cache storage may contain additional data. Are you sure that you want to flush it?');
35-
$this->buttonList->add(
36-
'flush_system',
37-
[
38-
'label' => __('Flush Cache Storage'),
39-
'onclick' => 'confirmSetLocation(\'' . $message . '\', \'' . $this->getFlushStorageUrl() . '\')',
40-
'class' => 'flush-cache-storage'
41-
]
42-
);
26+
if ($this->_authorization->isAllowed('Magento_Backend::flush_magento_cache')) {
27+
$this->buttonList->add(
28+
'flush_magento',
29+
[
30+
'label' => __('Flush Magento Cache'),
31+
'onclick' => 'setLocation(\'' . $this->getFlushSystemUrl() . '\')',
32+
'class' => 'primary flush-cache-magento'
33+
]
34+
);
35+
}
36+
37+
if ($this->_authorization->isAllowed('Magento_Backend::flush_cache_storage')) {
38+
$message = __('The cache storage may contain additional data. Are you sure that you want to flush it?');
39+
$this->buttonList->add(
40+
'flush_system',
41+
[
42+
'label' => __('Flush Cache Storage'),
43+
'onclick' => 'confirmSetLocation(\'' . $message . '\', \'' . $this->getFlushStorageUrl() . '\')',
44+
'class' => 'flush-cache-storage'
45+
]
46+
);
47+
}
4348
}
4449

4550
/**
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Backend\Block\Cache;
8+
9+
use Magento\Framework\AuthorizationInterface;
10+
use Magento\Framework\View\Element\Block\ArgumentInterface;
11+
12+
/**
13+
* Class Permissions
14+
*/
15+
class Permissions implements ArgumentInterface
16+
{
17+
/**
18+
* @var AuthorizationInterface
19+
*/
20+
private $authorization;
21+
22+
/**
23+
* Permissions constructor.
24+
*
25+
* @param AuthorizationInterface $authorization
26+
*/
27+
public function __construct(AuthorizationInterface $authorization)
28+
{
29+
$this->authorization = $authorization;
30+
}
31+
32+
/**
33+
* @return bool
34+
*/
35+
public function hasAccessToFlushCatalogImages()
36+
{
37+
return $this->authorization->isAllowed('Magento_Backend::flush_catalog_images');
38+
}
39+
/**
40+
* @return bool
41+
*/
42+
public function hasAccessToFlushJsCss()
43+
{
44+
return $this->authorization->isAllowed('Magento_Backend::flush_js_css');
45+
}
46+
/**
47+
* @return bool
48+
*/
49+
public function hasAccessToFlushStaticFiles()
50+
{
51+
return $this->authorization->isAllowed('Magento_Backend::flush_static_files');
52+
}
53+
/**
54+
* @return bool
55+
*/
56+
public function hasAccessToAdditionalActions()
57+
{
58+
return ($this->hasAccessToFlushCatalogImages()
59+
|| $this->hasAccessToFlushJsCss()
60+
|| $this->hasAccessToFlushStaticFiles());
61+
}
62+
}

app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Date.php

+6-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public function getHtml()
127127

128128
/**
129129
* @param string|null $index
130-
* @return string
130+
* @return array|string|int|float|null
131131
*/
132132
public function getEscapedValue($index = null)
133133
{
@@ -138,6 +138,11 @@ public function getEscapedValue($index = null)
138138
$this->_localeDate->getDateFormat(\IntlDateFormatter::SHORT)
139139
);
140140
}
141+
142+
if (is_string($value)) {
143+
return $this->escapeHtml($value);
144+
}
145+
141146
return $value;
142147
}
143148

app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Datetime.php

+7-2
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,8 @@ public function getHtml()
140140
/**
141141
* Return escaped value for calendar
142142
*
143-
* @param string $index
144-
* @return string
143+
* @param string|null $index
144+
* @return array|string|int|float|null
145145
*/
146146
public function getEscapedValue($index = null)
147147
{
@@ -150,6 +150,11 @@ public function getEscapedValue($index = null)
150150
if ($value instanceof \DateTimeInterface) {
151151
return $this->_localeDate->formatDateTime($value);
152152
}
153+
154+
if (is_string($value)) {
155+
return $this->escapeHtml($value);
156+
}
157+
153158
return $value;
154159
}
155160

app/code/Magento/Backend/Block/Widget/Grid/Massaction.php

+75
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,15 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
67
namespace Magento\Backend\Block\Widget\Grid;
78

9+
use Magento\Backend\Block\Template\Context;
10+
use Magento\Framework\App\ObjectManager;
11+
use Magento\Framework\AuthorizationInterface;
12+
use Magento\Framework\DataObject;
13+
use Magento\Framework\Json\EncoderInterface;
14+
815
/**
916
* Grid widget massaction default block
1017
*
@@ -14,4 +21,72 @@
1421
*/
1522
class Massaction extends \Magento\Backend\Block\Widget\Grid\Massaction\AbstractMassaction
1623
{
24+
/**
25+
* @var AuthorizationInterface
26+
*/
27+
private $authorization;
28+
29+
/**
30+
* Map bind item id to a particular acl type
31+
* itemId => acl
32+
*
33+
* @var array
34+
*/
35+
private $restrictions = [
36+
'enable' => 'Magento_Backend::toggling_cache_type',
37+
'disable' => 'Magento_Backend::toggling_cache_type',
38+
'refresh' => 'Magento_Backend::refresh_cache_type',
39+
];
40+
41+
/**
42+
* Massaction constructor.
43+
*
44+
* @param Context $context
45+
* @param EncoderInterface $jsonEncoder
46+
* @param array $data
47+
* @param AuthorizationInterface $authorization
48+
*/
49+
public function __construct(
50+
Context $context,
51+
EncoderInterface $jsonEncoder,
52+
array $data = [],
53+
AuthorizationInterface $authorization = null
54+
) {
55+
$this->authorization = $authorization ?: ObjectManager::getInstance()->get(AuthorizationInterface::class);
56+
57+
parent::__construct($context, $jsonEncoder, $data);
58+
}
59+
60+
/**
61+
* {@inheritdoc}
62+
*
63+
* @param string $itemId
64+
* @param array|DataObject $item
65+
*
66+
* @return $this
67+
*/
68+
public function addItem($itemId, $item)
69+
{
70+
if (!$this->isRestricted($itemId)) {
71+
parent::addItem($itemId, $item);
72+
}
73+
74+
return $this;
75+
}
76+
77+
/**
78+
* Check if access to action restricted
79+
*
80+
* @param string $itemId
81+
*
82+
* @return bool
83+
*/
84+
private function isRestricted(string $itemId): bool
85+
{
86+
if (!key_exists($itemId, $this->restrictions)) {
87+
return false;
88+
}
89+
90+
return !$this->authorization->isAllowed($this->restrictions[$itemId]);
91+
}
1792
}

app/code/Magento/Backend/Controller/Adminhtml/Cache/CleanImages.php

+7
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@
1111

1212
class CleanImages extends \Magento\Backend\Controller\Adminhtml\Cache
1313
{
14+
/**
15+
* Authorization level of a basic admin session
16+
*
17+
* @see _isAllowed()
18+
*/
19+
const ADMIN_RESOURCE = 'Magento_Backend::flush_catalog_images';
20+
1421
/**
1522
* Clean JS/css files cache
1623
*

app/code/Magento/Backend/Controller/Adminhtml/Cache/CleanMedia.php

+7
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@
1111

1212
class CleanMedia extends \Magento\Backend\Controller\Adminhtml\Cache
1313
{
14+
/**
15+
* Authorization level of a basic admin session
16+
*
17+
* @see _isAllowed()
18+
*/
19+
const ADMIN_RESOURCE = 'Magento_Backend::flush_js_css';
20+
1421
/**
1522
* Clean JS/css files cache
1623
*

app/code/Magento/Backend/Controller/Adminhtml/Cache/CleanStaticFiles.php

+7
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@
1010

1111
class CleanStaticFiles extends \Magento\Backend\Controller\Adminhtml\Cache
1212
{
13+
/**
14+
* Authorization level of a basic admin session
15+
*
16+
* @see _isAllowed()
17+
*/
18+
const ADMIN_RESOURCE = 'Magento_Backend::flush_static_files';
19+
1320
/**
1421
* Clean static files cache
1522
*

app/code/Magento/Backend/Controller/Adminhtml/Cache/FlushAll.php

+7
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@
88

99
class FlushAll extends \Magento\Backend\Controller\Adminhtml\Cache
1010
{
11+
/**
12+
* Authorization level of a basic admin session
13+
*
14+
* @see _isAllowed()
15+
*/
16+
const ADMIN_RESOURCE = 'Magento_Backend::flush_cache_storage';
17+
1118
/**
1219
* Flush cache storage
1320
*

app/code/Magento/Backend/Controller/Adminhtml/Cache/FlushSystem.php

+7
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@
88

99
class FlushSystem extends \Magento\Backend\Controller\Adminhtml\Cache
1010
{
11+
/**
12+
* Authorization level of a basic admin session
13+
*
14+
* @see _isAllowed()
15+
*/
16+
const ADMIN_RESOURCE = 'Magento_Backend::flush_magento_cache';
17+
1118
/**
1219
* Flush all magento cache
1320
*

app/code/Magento/Backend/Controller/Adminhtml/Cache/MassDisable.php

+7
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@
1616
*/
1717
class MassDisable extends \Magento\Backend\Controller\Adminhtml\Cache
1818
{
19+
/**
20+
* Authorization level of a basic admin session
21+
*
22+
* @see _isAllowed()
23+
*/
24+
const ADMIN_RESOURCE = 'Magento_Backend::toggling_cache_type';
25+
1926
/**
2027
* @var State
2128
*/

app/code/Magento/Backend/Controller/Adminhtml/Cache/MassEnable.php

+7
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@
1616
*/
1717
class MassEnable extends \Magento\Backend\Controller\Adminhtml\Cache
1818
{
19+
/**
20+
* Authorization level of a basic admin session
21+
*
22+
* @see _isAllowed()
23+
*/
24+
const ADMIN_RESOURCE = 'Magento_Backend::toggling_cache_type';
25+
1926
/**
2027
* @var State
2128
*/

app/code/Magento/Backend/Controller/Adminhtml/Cache/MassRefresh.php

+7
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@
1111

1212
class MassRefresh extends \Magento\Backend\Controller\Adminhtml\Cache
1313
{
14+
/**
15+
* Authorization level of a basic admin session
16+
*
17+
* @see _isAllowed()
18+
*/
19+
const ADMIN_RESOURCE = 'Magento_Backend::refresh_cache_type';
20+
1421
/**
1522
* Mass action for cache refresh
1623
*

0 commit comments

Comments
 (0)