File tree Expand file tree Collapse file tree 7 files changed +71
-10
lines changed
Sales/view/frontend/templates/order
Controller/Adminhtml/User
dev/tests/integration/testsuite/Magento/User/Controller/Adminhtml/User Expand file tree Collapse file tree 7 files changed +71
-10
lines changed Original file line number Diff line number Diff line change 36
36
<span><?php /* @escapeNotVerified */ echo __ ('View Order ' ) ?> </span>
37
37
</a>
38
38
<?php if ($ this ->helper ('Magento\Sales\Helper\Reorder ' )->canReorder ($ _order ->getEntityId ())) : ?>
39
- <a href="<?php /* @escapeNotVerified */ echo $ block ->getReorderUrl ($ _order ) ?> " class="action order">
39
+ <a href="#" data-post='<?php /* @escapeNotVerified */ echo
40
+ $ this ->helper (\Magento \Framework \Data \Helper \PostHelper::class)
41
+ ->getPostData ($ block ->getReorderUrl ($ _order ))
42
+ ?> ' class="action order">
40
43
<span><?php /* @escapeNotVerified */ echo __ ('Reorder ' ) ?> </span>
41
44
</a>
42
45
<?php endif ?>
Original file line number Diff line number Diff line change 10
10
<div class="actions">
11
11
<?php $ _order = $ block ->getOrder () ?>
12
12
<?php if ($ this ->helper ('Magento\Sales\Helper\Reorder ' )->canReorder ($ _order ->getEntityId ())) : ?>
13
- <a class="action reorder" href="<?php /* @escapeNotVerified */ echo $ block ->getReorderUrl ($ _order ) ?> ">
13
+ <a href="#" data-post='<?php /* @escapeNotVerified */ echo
14
+ $ this ->helper (\Magento \Framework \Data \Helper \PostHelper::class)
15
+ ->getPostData ($ block ->getReorderUrl ($ _order ))
16
+ ?> ' class="action order">
14
17
<span><?php /* @escapeNotVerified */ echo __ ('Reorder ' ) ?> </span>
15
18
</a>
16
19
<?php endif ?>
Original file line number Diff line number Diff line change 46
46
<span><?php /* @escapeNotVerified */ echo __ ('View Order ' ) ?> </span>
47
47
</a>
48
48
<?php if ($ this ->helper ('Magento\Sales\Helper\Reorder ' )->canReorder ($ _order ->getEntityId ())) : ?>
49
- <a href="<?php /* @escapeNotVerified */ echo $ block ->getReorderUrl ($ _order ) ?> " class="action order">
49
+ <a href="#" data-post='<?php /* @escapeNotVerified */ echo
50
+ $ this ->helper (\Magento \Framework \Data \Helper \PostHelper::class)
51
+ ->getPostData ($ block ->getReorderUrl ($ _order ))
52
+ ?> ' class="action order">
50
53
<span><?php /* @escapeNotVerified */ echo __ ('Reorder ' ) ?> </span>
51
54
</a>
52
55
<?php endif ?>
Original file line number Diff line number Diff line change @@ -48,11 +48,25 @@ protected function _construct()
48
48
parent ::_construct ();
49
49
50
50
$ this ->buttonList ->update ('save ' , 'label ' , __ ('Save User ' ));
51
- $ this ->buttonList ->update ('delete ' , ' label ' , __ ( ' Delete User ' ) );
51
+ $ this ->buttonList ->remove ('delete ' );
52
52
53
53
$ objId = $ this ->getRequest ()->getParam ($ this ->_objectId );
54
54
55
55
if (!empty ($ objId )) {
56
+ $ this ->addButton (
57
+ 'delete ' ,
58
+ [
59
+ 'label ' => __ ('Delete User ' ),
60
+ 'class ' => 'delete ' ,
61
+ 'onclick ' => sprintf (
62
+ 'deleteConfirm("%s", "%s", %s) ' ,
63
+ __ ('Are you sure you want to do this? ' ),
64
+ $ this ->getUrl ('adminhtml/*/delete ' ),
65
+ json_encode (['data ' => ['user_id ' => $ objId ]])
66
+ ),
67
+ ]
68
+ );
69
+
56
70
$ deleteConfirmMsg = __ ("Are you sure you want to revoke the user\'s tokens? " );
57
71
$ this ->addButton (
58
72
'invalidate ' ,
Original file line number Diff line number Diff line change @@ -13,9 +13,9 @@ class Delete extends \Magento\User\Controller\Adminhtml\User
13
13
*/
14
14
public function execute ()
15
15
{
16
- $ currentUser = $ this ->_objectManager ->get (' Magento\Backend\Model\Auth\Session ' )->getUser ();
16
+ $ currentUser = $ this ->_objectManager ->get (\ Magento \Backend \Model \Auth \Session::class )->getUser ();
17
17
18
- if ($ userId = $ this ->getRequest ()->getParam ('user_id ' )) {
18
+ if ($ userId = ( int ) $ this ->getRequest ()->getPost ('user_id ' )) {
19
19
if ($ currentUser ->getId () == $ userId ) {
20
20
$ this ->messageManager ->addError (__ ('You cannot delete your own account. ' ));
21
21
$ this ->_redirect ('adminhtml/*/edit ' , ['user_id ' => $ userId ]);
Original file line number Diff line number Diff line change
1
+ <?php
2
+ /**
3
+ * Copyright © 2016 Magento. All rights reserved.
4
+ * See COPYING.txt for license details.
5
+ */
6
+ namespace Magento \User \Controller \Adminhtml \User ;
7
+
8
+ /**
9
+ * Test class for \Magento\User\Controller\Adminhtml\User\Delete
10
+ * @magentoAppArea adminhtml
11
+ */
12
+ class DeleteTest extends \Magento \TestFramework \TestCase \AbstractBackendController
13
+ {
14
+ /**
15
+ * @covers \Magento\User\Controller\Adminhtml\User\Delete::execute
16
+ */
17
+ public function testDeleteActionWithError ()
18
+ {
19
+ $ user = \Magento \TestFramework \Helper \Bootstrap::getObjectManager ()
20
+ ->create (\Magento \User \Model \User::class);
21
+ /** @var \Magento\Framework\Message\ManagerInterface $messageManager */
22
+ $ messageManager = \Magento \TestFramework \Helper \Bootstrap::getObjectManager ()
23
+ ->get (\Magento \Framework \Message \ManagerInterface::class);
24
+ $ user ->load (1 );
25
+ $ this ->getRequest ()->setPostValue ('user_id ' , $ user ->getId () . '_suffix_ignored_in_mysql_casting_to_int ' );
26
+
27
+ $ this ->dispatch ('backend/admin/user/delete ' );
28
+ $ message = $ messageManager ->getMessages ()->getLastAddedMessage ()->getText ();
29
+ $ this ->assertEquals ('You cannot delete your own account. ' , $ message );
30
+ }
31
+ }
Original file line number Diff line number Diff line change 3
3
* See COPYING.txt for license details.
4
4
*/
5
5
define ( [
6
- 'Magento_Ui/js/modal/confirm'
7
- ] , function ( confirm ) {
6
+ 'Magento_Ui/js/modal/confirm' ,
7
+ 'mage/dataPost'
8
+ ] , function ( confirm , dataPost ) {
8
9
'use strict' ;
9
10
10
11
/**
@@ -19,14 +20,20 @@ define([
19
20
* Helper for onclick action.
20
21
* @param {String } message
21
22
* @param {String } url
23
+ * @param {Object } postData
22
24
* @returns {boolean }
23
25
*/
24
- window . deleteConfirm = function ( message , url ) {
26
+ window . deleteConfirm = function ( message , url , postData ) {
25
27
confirm ( {
26
28
content : message ,
27
29
actions : {
28
30
confirm : function ( ) {
29
- setLocation ( url ) ;
31
+ if ( postData !== undefined ) {
32
+ postData . action = url ;
33
+ dataPost ( ) . postData ( postData ) ;
34
+ } else {
35
+ setLocation ( url ) ;
36
+ }
30
37
}
31
38
}
32
39
} ) ;
You can’t perform that action at this time.
0 commit comments