|
1 | 1 | <?php
|
2 |
| -declare(strict_types=1); |
3 |
| - |
4 | 2 | /**
|
5 |
| - * Adminhtml AdminNotification Severity Renderer |
6 |
| - * |
7 | 3 | * Copyright © Magento, Inc. All rights reserved.
|
8 | 4 | * See COPYING.txt for license details.
|
9 | 5 | */
|
| 6 | +declare(strict_types=1); |
10 | 7 |
|
11 | 8 | namespace Magento\AdminNotification\Block\Grid\Renderer;
|
12 | 9 |
|
| 10 | +use Magento\AdminNotification\Controller\Adminhtml\Notification\MarkAsRead; |
| 11 | +use Magento\AdminNotification\Controller\Adminhtml\Notification\Remove; |
13 | 12 | use Magento\Backend\Block\Context;
|
14 | 13 | use Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer;
|
15 | 14 | use Magento\Framework\App\ActionInterface;
|
@@ -45,33 +44,41 @@ public function __construct(Context $context, Data $urlHelper, array $data = [])
|
45 | 44 | */
|
46 | 45 | public function render(DataObject $row)
|
47 | 46 | {
|
48 |
| - $readDetailsHtml = $row->getUrl() ? '<a class="action-details" target="_blank" href="' . |
| 47 | + $readDetailsHtml = $row->getUrl() ? |
| 48 | + '<a class="action-details" target="_blank" href="' . |
49 | 49 | $this->escapeUrl($row->getUrl())
|
50 | 50 | . '">' .
|
51 | 51 | __('Read Details') . '</a>' : '';
|
52 | 52 |
|
53 |
| - $markAsReadHtml = !$row->getIsRead() ? '<a class="action-mark" href="' . $this->getUrl( |
54 |
| - '*/*/markAsRead/', |
55 |
| - ['_current' => true, 'id' => $row->getNotificationId()] |
56 |
| - ) . '">' . __( |
57 |
| - 'Mark as Read' |
58 |
| - ) . '</a>' : ''; |
| 53 | + $markAsReadHtml = !$row->getIsRead() |
| 54 | + && $this->_authorization->isAllowed(MarkAsRead::ADMIN_RESOURCE) ? |
| 55 | + '<a class="action-mark" href="' . $this->escapeUrl($this->getUrl( |
| 56 | + '*/*/markAsRead/', |
| 57 | + ['_current' => true, 'id' => $row->getNotificationId()] |
| 58 | + )) . '">' . __( |
| 59 | + 'Mark as Read' |
| 60 | + ) . '</a>' : ''; |
| 61 | + |
| 62 | + $removeUrl = $this->getUrl( |
| 63 | + '*/*/remove/', |
| 64 | + [ |
| 65 | + '_current' => true, |
| 66 | + 'id' => $row->getNotificationId(), |
| 67 | + ActionInterface::PARAM_NAME_URL_ENCODED => $this->_urlHelper->getEncodedUrl() |
| 68 | + ] |
| 69 | + ); |
| 70 | + |
| 71 | + $removeHtml = $this->_authorization->isAllowed(Remove::ADMIN_RESOURCE) ? |
| 72 | + '<a class="action-delete" href="' |
| 73 | + . $this->escapeUrl($removeUrl) |
| 74 | + .'" onClick="deleteConfirm('. __('\'Are you sure?\'') .', this.href); return false;">' |
| 75 | + . __('Remove') . '</a>' : ''; |
59 | 76 |
|
60 |
| - $encodedUrl = $this->_urlHelper->getEncodedUrl(); |
61 | 77 | return sprintf(
|
62 |
| - '%s%s<a class="action-delete" href="%s" onClick="deleteConfirm(\'%s\', this.href); return false;">%s</a>', |
| 78 | + '%s%s%s', |
63 | 79 | $readDetailsHtml,
|
64 | 80 | $markAsReadHtml,
|
65 |
| - $this->getUrl( |
66 |
| - '*/*/remove/', |
67 |
| - [ |
68 |
| - '_current' => true, |
69 |
| - 'id' => $row->getNotificationId(), |
70 |
| - ActionInterface::PARAM_NAME_URL_ENCODED => $encodedUrl |
71 |
| - ] |
72 |
| - ), |
73 |
| - __('Are you sure?'), |
74 |
| - __('Remove') |
| 81 | + $removeHtml, |
75 | 82 | );
|
76 | 83 | }
|
77 | 84 | }
|
0 commit comments