Skip to content

Commit 9b8849d

Browse files
authored
Merge pull request #4403 from magento-tsg-csl3/2.3-develop-pr26
[TSG-CSL3] For 2.3 (pr26)
2 parents d80ef8f + d69b930 commit 9b8849d

File tree

17 files changed

+624
-37
lines changed

17 files changed

+624
-37
lines changed

app/code/Magento/Backend/Block/Dashboard/Bar.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
*/
66
namespace Magento\Backend\Block\Dashboard;
77

8+
use Magento\Store\Model\Store;
9+
810
/**
911
* Adminhtml dashboard bar block
1012
*
@@ -23,6 +25,8 @@ class Bar extends \Magento\Backend\Block\Dashboard\AbstractDashboard
2325
protected $_currentCurrencyCode = null;
2426

2527
/**
28+
* Get totals
29+
*
2630
* @return array
2731
*/
2832
public function getTotals()
@@ -31,6 +35,8 @@ public function getTotals()
3135
}
3236

3337
/**
38+
* Add total
39+
*
3440
* @param string $label
3541
* @param float $value
3642
* @param bool $isQuantity
@@ -73,6 +79,7 @@ public function setCurrency($currency)
7379
* Retrieve currency model if not set then return currency model for current store
7480
*
7581
* @return \Magento\Directory\Model\Currency
82+
* @SuppressWarnings(PHPMD.RequestAwareBlockMethod)
7683
*/
7784
public function getCurrency()
7885
{
@@ -90,7 +97,8 @@ public function getCurrency()
9097
$this->getRequest()->getParam('group')
9198
)->getWebsite()->getBaseCurrency();
9299
} else {
93-
$this->_currentCurrencyCode = $this->_storeManager->getStore()->getBaseCurrency();
100+
$this->_currentCurrencyCode = $this->_storeManager->getStore(Store::DEFAULT_STORE_ID)
101+
->getBaseCurrency();
94102
}
95103
}
96104

app/code/Magento/Backend/view/adminhtml/templates/store/switcher.phtml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
<?php if ($block->hasDefaultOption()) : ?>
3737
<li class="store-switcher-all <?php if (!($block->getDefaultSelectionName() != $block->getCurrentSelectionName())) : ?>disabled<?php endif; ?> <?php if (!$block->hasScopeSelected()) : ?>current<?php endif; ?>">
3838
<?php if ($block->getDefaultSelectionName() != $block->getCurrentSelectionName()) : ?>
39-
?>
4039
<a data-role="store-view-id" data-value="" href="#">
4140
<?= $block->escapeHtml($block->getDefaultSelectionName()) ?>
4241
</a>

app/code/Magento/Eav/Model/Attribute/Data/Text.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ private function validateLength(\Magento\Eav\Model\Attribute $attribute, string
168168
*/
169169
private function validateInputRule(string $value): array
170170
{
171-
$result = $this->_validateInputRule($value);
171+
$result = $this->_validateInputRule(trim($value));
172172
return \is_array($result) ? $result : [];
173173
}
174174
}

app/code/Magento/Eav/Test/Unit/Model/Attribute/Data/TextTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
use Magento\Framework\Exception\LocalizedException;
1010
use Magento\Framework\Stdlib\StringUtils;
1111

12+
/**
13+
* Eav text attribute model test
14+
*/
1215
class TextTest extends \PHPUnit\Framework\TestCase
1316
{
1417
/**
@@ -135,6 +138,7 @@ public function alphanumDataProvider(): array
135138
['QazWsx12345', [
136139
__('"%1" length must be equal or less than %2 characters.', 'Test', 10)]
137140
],
141+
[' 12345 ', true],
138142
];
139143
}
140144

app/code/Magento/Review/Block/Adminhtml/Edit.php

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
namespace Magento\Review\Block\Adminhtml;
77

88
/**
9-
* Review edit form
9+
* Review edit form.
1010
*/
1111
class Edit extends \Magento\Backend\Block\Widget\Form\Container
1212
{
@@ -77,7 +77,13 @@ protected function _construct()
7777
'previous',
7878
[
7979
'label' => __('Previous'),
80-
'onclick' => 'setLocation(\'' . $this->getUrl('review/*/*', ['id' => $prevId]) . '\')'
80+
'onclick' => 'setLocation(\'' . $this->getUrl(
81+
'review/*/*',
82+
[
83+
'id' => $prevId,
84+
'ret' => $this->getRequest()->getParam('ret'),
85+
]
86+
) . '\')'
8187
],
8288
3,
8389
10
@@ -93,7 +99,10 @@ protected function _construct()
9399
'button' => [
94100
'event' => 'save',
95101
'target' => '#edit_form',
96-
'eventData' => ['action' => ['args' => ['next_item' => $prevId]]],
102+
'eventData' => ['action' => ['args' => [
103+
'next_item' => $prevId,
104+
'ret' => $this->getRequest()->getParam('ret'),
105+
]]],
97106
],
98107
],
99108
]
@@ -113,7 +122,10 @@ protected function _construct()
113122
'button' => [
114123
'event' => 'save',
115124
'target' => '#edit_form',
116-
'eventData' => ['action' => ['args' => ['next_item' => $nextId]]],
125+
'eventData' => ['action' => ['args' => [
126+
'next_item' => $nextId,
127+
'ret' => $this->getRequest()->getParam('ret'),
128+
]]],
117129
],
118130
],
119131
]
@@ -126,7 +138,13 @@ protected function _construct()
126138
'next',
127139
[
128140
'label' => __('Next'),
129-
'onclick' => 'setLocation(\'' . $this->getUrl('review/*/*', ['id' => $nextId]) . '\')'
141+
'onclick' => 'setLocation(\'' . $this->getUrl(
142+
'review/*/*',
143+
[
144+
'id' => $nextId,
145+
'ret' => $this->getRequest()->getParam('ret'),
146+
]
147+
) . '\')'
130148
],
131149
3,
132150
105
@@ -168,7 +186,7 @@ protected function _construct()
168186
) . '\', ' . '\'' . $this->getUrl(
169187
'*/*/delete',
170188
[$this->_objectId => $this->getRequest()->getParam($this->_objectId), 'ret' => 'pending']
171-
) . '\'' . ')'
189+
) . '\', {data: {}})'
172190
);
173191
$this->_coreRegistry->register('ret', 'pending');
174192
}

app/code/Magento/Review/Controller/Adminhtml/Product.php

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,15 @@
1212
use Magento\Review\Model\RatingFactory;
1313

1414
/**
15-
* Reviews admin controller
15+
* Reviews admin controller.
1616
*/
1717
abstract class Product extends Action
1818
{
19+
/**
20+
* Authorization resource
21+
*/
22+
public const ADMIN_RESOURCE = 'Magento_Review::reviews_all';
23+
1924
/**
2025
* Array of actions which can be processed without secret key validation
2126
*
@@ -61,19 +66,4 @@ public function __construct(
6166
$this->ratingFactory = $ratingFactory;
6267
parent::__construct($context);
6368
}
64-
65-
/**
66-
* @return bool
67-
*/
68-
protected function _isAllowed()
69-
{
70-
switch ($this->getRequest()->getActionName()) {
71-
case 'pending':
72-
return $this->_authorization->isAllowed('Magento_Review::pending');
73-
break;
74-
default:
75-
return $this->_authorization->isAllowed('Magento_Review::reviews_all');
76-
break;
77-
}
78-
}
7969
}

app/code/Magento/Review/Controller/Adminhtml/Product/Delete.php

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,24 @@
55
*/
66
namespace Magento\Review\Controller\Adminhtml\Product;
77

8+
use Magento\Framework\App\Action\HttpPostActionInterface;
89
use Magento\Review\Controller\Adminhtml\Product as ProductController;
910
use Magento\Framework\Controller\ResultFactory;
11+
use Magento\Review\Model\Review;
1012

11-
class Delete extends ProductController
13+
/**
14+
* Delete action.
15+
*/
16+
class Delete extends ProductController implements HttpPostActionInterface
1217
{
1318
/**
19+
* @var Review
20+
*/
21+
private $model;
22+
23+
/**
24+
* Execute action.
25+
*
1426
* @return \Magento\Backend\Model\View\Result\Redirect
1527
*/
1628
public function execute()
@@ -19,7 +31,7 @@ public function execute()
1931
$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
2032
$reviewId = $this->getRequest()->getParam('id', false);
2133
try {
22-
$this->reviewFactory->create()->setId($reviewId)->aggregate()->delete();
34+
$this->getModel()->aggregate()->delete();
2335

2436
$this->messageManager->addSuccess(__('The review has been deleted.'));
2537
if ($this->getRequest()->getParam('ret') == 'pending') {
@@ -36,4 +48,46 @@ public function execute()
3648

3749
return $resultRedirect->setPath('review/*/edit/', ['id' => $reviewId]);
3850
}
51+
52+
/**
53+
* @inheritdoc
54+
*/
55+
protected function _isAllowed()
56+
{
57+
if (parent::_isAllowed()) {
58+
return true;
59+
}
60+
61+
if (!$this->_authorization->isAllowed('Magento_Review::pending')) {
62+
return false;
63+
}
64+
65+
if ($this->getModel()->getStatusId() != Review::STATUS_PENDING) {
66+
$this->messageManager->addErrorMessage(
67+
__(
68+
'You don’t have permission to perform this operation.'
69+
. ' The selected review must be in Pending Status.'
70+
)
71+
);
72+
73+
return false;
74+
}
75+
76+
return true;
77+
}
78+
79+
/**
80+
* Returns requested model.
81+
*
82+
* @return Review
83+
*/
84+
private function getModel(): Review
85+
{
86+
if ($this->model === null) {
87+
$this->model = $this->reviewFactory->create()
88+
->load($this->getRequest()->getParam('id', false));
89+
}
90+
91+
return $this->model;
92+
}
3993
}

app/code/Magento/Review/Controller/Adminhtml/Product/Edit.php

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,21 @@
88
use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
99
use Magento\Review\Controller\Adminhtml\Product as ProductController;
1010
use Magento\Framework\Controller\ResultFactory;
11+
use Magento\Review\Model\Review;
1112

13+
/**
14+
* Edit action.
15+
*/
1216
class Edit extends ProductController implements HttpGetActionInterface
1317
{
1418
/**
19+
* @var Review
20+
*/
21+
private $review;
22+
23+
/**
24+
* Execute action.
25+
*
1526
* @return \Magento\Backend\Model\View\Result\Page
1627
*/
1728
public function execute()
@@ -24,4 +35,46 @@ public function execute()
2435
$resultPage->addContent($resultPage->getLayout()->createBlock(\Magento\Review\Block\Adminhtml\Edit::class));
2536
return $resultPage;
2637
}
38+
39+
/**
40+
* @inheritdoc
41+
*/
42+
protected function _isAllowed()
43+
{
44+
if (parent::_isAllowed()) {
45+
return true;
46+
}
47+
48+
if (!$this->_authorization->isAllowed('Magento_Review::pending')) {
49+
return false;
50+
}
51+
52+
if ($this->getModel()->getStatusId() != Review::STATUS_PENDING) {
53+
$this->messageManager->addErrorMessage(
54+
__(
55+
'You don’t have permission to perform this operation.'
56+
. ' The selected review must be in Pending Status.'
57+
)
58+
);
59+
60+
return false;
61+
}
62+
63+
return true;
64+
}
65+
66+
/**
67+
* Returns requested model.
68+
*
69+
* @return Review
70+
*/
71+
private function getModel(): Review
72+
{
73+
if ($this->review === null) {
74+
$this->review = $this->reviewFactory->create()
75+
->load($this->getRequest()->getParam('id', false));
76+
}
77+
78+
return $this->review;
79+
}
2780
}

0 commit comments

Comments
 (0)