|
114 | 114 | $message .= sprintf('<p class="alert alert-danger">%s</p>', $PMF_LANG['ad_user_error_noId']);
|
115 | 115 | } else {
|
116 | 116 | $userData = [];
|
117 |
| - $userData['display_name'] = Filter::filterInput(INPUT_POST, 'display_name', FILTER_UNSAFE_RAW, ''); |
118 |
| - $userData['email'] = Filter::filterInput(INPUT_POST, 'email', FILTER_VALIDATE_EMAIL, ''); |
119 |
| - $userData['last_modified'] = Filter::filterInput(INPUT_POST, 'last_modified', FILTER_UNSAFE_RAW, ''); |
| 117 | + $userData['display_name'] = Filter::filterInput(INPUT_POST, 'display_name', FILTER_UNSAFE_RAW); |
| 118 | + $userData['email'] = Filter::filterInput(INPUT_POST, 'email', FILTER_VALIDATE_EMAIL); |
| 119 | + $userData['last_modified'] = Filter::filterInput(INPUT_POST, 'last_modified', FILTER_UNSAFE_RAW); |
120 | 120 | $userStatus = Filter::filterInput(INPUT_POST, 'user_status', FILTER_UNSAFE_RAW, $defaultUserStatus);
|
121 | 121 | $isSuperAdmin = Filter::filterInput(INPUT_POST, 'is_superadmin', FILTER_UNSAFE_RAW);
|
122 | 122 | $isSuperAdmin = $isSuperAdmin === 'on';
|
123 | 123 |
|
124 |
| - $user = new User($faqConfig); |
125 |
| - $user->getUserById($userId, true); |
| 124 | + // Sanity check |
| 125 | + if (is_null($userData['email'])) { |
| 126 | + $message .= sprintf('<p class="alert alert-danger">%s</p>', $PMF_LANG['err_noMailAdress']); |
| 127 | + } else { |
| 128 | + $user = new User($faqConfig); |
| 129 | + $user->getUserById($userId, true); |
126 | 130 |
|
127 |
| - $stats = $user->getStatus(); |
| 131 | + $stats = $user->getStatus(); |
128 | 132 |
|
129 |
| - // set new password an send email if user is switched to active |
130 |
| - if ($stats == 'blocked' && $userStatus == 'active') { |
131 |
| - if (!$user->activateUser()) { |
132 |
| - $userStatus = 'invalid_status'; |
| 133 | + // set new password an send email if user is switched to active |
| 134 | + if ($stats == 'blocked' && $userStatus == 'active') { |
| 135 | + if (!$user->activateUser()) { |
| 136 | + $userStatus = 'invalid_status'; |
| 137 | + } |
133 | 138 | }
|
134 |
| - } |
135 |
| - |
136 |
| - // Set super-admin flag |
137 |
| - $user->setSuperAdmin($isSuperAdmin); |
138 | 139 |
|
139 |
| - if ( |
140 |
| - !$user->userdata->set(array_keys($userData), array_values($userData)) || |
141 |
| - !$user->setStatus($userStatus) |
142 |
| - ) { |
143 |
| - $message .= sprintf('<p class="alert alert-danger">%s</p>', $PMF_LANG['ad_msg_mysqlerr']); |
144 |
| - } else { |
145 |
| - $message .= sprintf( |
146 |
| - '<p class="alert alert-success">%s <strong>%s</strong> %s</p>', |
147 |
| - $PMF_LANG['ad_msg_savedsuc_1'], |
148 |
| - Strings::htmlentities($user->getLogin(), ENT_QUOTES), |
149 |
| - $PMF_LANG['ad_msg_savedsuc_2'] |
150 |
| - ); |
151 |
| - $message .= '<script>updateUser(' . $userId . ');</script>'; |
| 140 | + // Set super-admin flag |
| 141 | + $user->setSuperAdmin($isSuperAdmin); |
| 142 | + |
| 143 | + if ( |
| 144 | + !$user->userdata->set(array_keys($userData), array_values($userData)) || |
| 145 | + !$user->setStatus($userStatus) |
| 146 | + ) { |
| 147 | + $message .= sprintf('<p class="alert alert-danger">%s</p>', $PMF_LANG['ad_msg_mysqlerr']); |
| 148 | + } else { |
| 149 | + $message .= sprintf( |
| 150 | + '<p class="alert alert-success">%s <strong>%s</strong> %s</p>', |
| 151 | + $PMF_LANG['ad_msg_savedsuc_1'], |
| 152 | + Strings::htmlentities($user->getLogin(), ENT_QUOTES), |
| 153 | + $PMF_LANG['ad_msg_savedsuc_2'] |
| 154 | + ); |
| 155 | + $message .= '<script>updateUser(' . $userId . ');</script>'; |
| 156 | + } |
152 | 157 | }
|
153 | 158 | }
|
154 | 159 | }
|
|
0 commit comments