|
1 | 1 | <?php
|
2 | 2 | /**
|
3 |
| - * Copyright © Magento, Inc. All rights reserved. |
4 |
| - * See COPYING.txt for license details. |
| 3 | + * Copyright 2014 Adobe |
| 4 | + * All Rights Reserved. |
5 | 5 | */
|
6 | 6 | namespace Magento\Backend\Controller\Adminhtml\System\Account;
|
7 | 7 |
|
|
12 | 12 | use Magento\Framework\Exception\State\UserLockedException;
|
13 | 13 | use Magento\Security\Model\SecurityCookie;
|
14 | 14 | use Magento\Framework\App\Action\HttpPostActionInterface;
|
| 15 | +use \Magento\User\Model\User; |
15 | 16 |
|
16 | 17 | /**
|
17 | 18 | * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
|
@@ -86,19 +87,9 @@ public function execute()
|
86 | 87 | $user->save();
|
87 | 88 | $user->sendNotificationEmailsIfRequired();
|
88 | 89 |
|
89 |
| - // Check which fields were modified after saving |
90 |
| - $modifiedFields = []; |
91 |
| - $propertiesToCheck = ['password', 'username', 'firstname', 'lastname', 'email']; |
92 |
| - |
93 |
| - foreach ($propertiesToCheck as $property) { |
94 |
| - if ($user->getOrigData($property) !== $user->{'get' . ucfirst($property)}()) { |
95 |
| - $modifiedFields[] = $property; |
96 |
| - } |
97 |
| - } |
98 |
| - |
| 90 | + $modifiedFields = $this->getModifiedFields($user); |
99 | 91 | if (!empty($modifiedFields)) {
|
100 | 92 | $countModifiedFields = count($modifiedFields);
|
101 |
| - $successMessage = ''; |
102 | 93 | // validate how many fields were modified to display them correctly
|
103 | 94 | if ($countModifiedFields > 1) {
|
104 | 95 | $lastModifiedField = array_pop($modifiedFields);
|
@@ -139,4 +130,22 @@ public function execute()
|
139 | 130 | $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
|
140 | 131 | return $resultRedirect->setPath("*/*/");
|
141 | 132 | }
|
| 133 | + |
| 134 | + /** |
| 135 | + * Get user modified fields |
| 136 | + * |
| 137 | + * @param User $user |
| 138 | + * @return array |
| 139 | + */ |
| 140 | + private function getModifiedFields(User $user) |
| 141 | + { |
| 142 | + $modifiedFields = []; |
| 143 | + $propertiesToCheck = ['password', 'username', 'firstname', 'lastname', 'email']; |
| 144 | + foreach ($propertiesToCheck as $property) { |
| 145 | + if ($user->getOrigData($property) !== $user->{'get' . ucfirst($property)}()) { |
| 146 | + $modifiedFields[] = $property; |
| 147 | + } |
| 148 | + } |
| 149 | + return $modifiedFields; |
| 150 | + } |
142 | 151 | }
|
0 commit comments