prevent demotion of last admin

This commit is contained in:
Nayef Alebrahim 2020-01-24 23:21:39 +03:00
parent ebd62aa1a6
commit 43ab8cb158
No known key found for this signature in database
GPG Key ID: 7F1502304671A40F
1 changed files with 7 additions and 0 deletions

View File

@ -295,6 +295,13 @@ class UserController extends AbstractController
if ($user_id > 0) {
// edit user
unset($clean['password']); // password update is executed separately
if (
count($this->db->select(PSM_DB_PREFIX . 'users', array('level' => PSM_USER_ADMIN))) == 1 &&
$this->getUser()->getUserLevel() == PSM_USER_ADMIN
) {
$this->addMessage(psm_get_lang('users', 'error_user_admin_cant_be_deleted'), 'warning');
$clean['level'] = PSM_USER_ADMIN;
}
$this->db->save(PSM_DB_PREFIX . 'users', $clean, array('user_id' => $user_id));
$this->addMessage(psm_get_lang('users', 'updated'), 'success');