Merge pull request #19345 from hregis/fix_lost_superadmin_grade_after_edit_user
FIX lost superadmin grade after edit user card
This commit is contained in:
commit
fc489380a1
@ -448,19 +448,15 @@ if (empty($reshook)) {
|
|||||||
$object->lang = GETPOST('default_lang', 'aZ09');
|
$object->lang = GETPOST('default_lang', 'aZ09');
|
||||||
|
|
||||||
// Do we update also ->entity ?
|
// Do we update also ->entity ?
|
||||||
if (!empty($conf->multicompany->enabled)) { // If multicompany is not enabled, we never update the entity of a user.
|
if (!empty($conf->multicompany->enabled && $user->entity == 0 && !empty($user->admin))) { // If multicompany is not enabled, we never update the entity of a user.
|
||||||
if (!empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
|
if (GETPOST('superadmin', 'int')) {
|
||||||
$object->entity = 1; // all users are in master entity
|
$object->entity = 0;
|
||||||
} else {
|
} else {
|
||||||
// A user should not be able to move a user into another entity. Only superadmin should be able to do this.
|
if (!empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
|
||||||
if ($user->entity == 0 && $user->admin) {
|
$object->entity = 1; // all users are in master entity
|
||||||
if (GETPOST("superadmin")) {
|
} else {
|
||||||
// We try to set the user as superadmin.
|
// We try to change the entity of user
|
||||||
$object->entity = 0;
|
$object->entity = (GETPOSTISSET('entity') ? GETPOSTINT('entity') : $object->entity);
|
||||||
} else {
|
|
||||||
// We try to change the entity of user
|
|
||||||
$object->entity = (GETPOSTISSET('entity') ? GETPOSTINT('entity') : $object->entity);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1773,7 +1773,9 @@ class User extends CommonObject
|
|||||||
$sql .= ", salaryextra= ".($this->salaryextra != '' ? "'".$this->db->escape($this->salaryextra)."'" : "null");
|
$sql .= ", salaryextra= ".($this->salaryextra != '' ? "'".$this->db->escape($this->salaryextra)."'" : "null");
|
||||||
}
|
}
|
||||||
$sql .= ", weeklyhours= ".($this->weeklyhours != '' ? "'".$this->db->escape($this->weeklyhours)."'" : "null");
|
$sql .= ", weeklyhours= ".($this->weeklyhours != '' ? "'".$this->db->escape($this->weeklyhours)."'" : "null");
|
||||||
$sql .= ", entity = ".((int) $this->entity);
|
if (!empty($user->admin) && empty($user->entity) && $user->id != $this->id) {
|
||||||
|
$sql .= ", entity = ".((int) $this->entity); // entity flag can be set/unset only by an another superadmin user
|
||||||
|
}
|
||||||
$sql .= ", default_range = ".($this->default_range > 0 ? $this->default_range : 'null');
|
$sql .= ", default_range = ".($this->default_range > 0 ? $this->default_range : 'null');
|
||||||
$sql .= ", default_c_exp_tax_cat = ".($this->default_c_exp_tax_cat > 0 ? $this->default_c_exp_tax_cat : 'null');
|
$sql .= ", default_c_exp_tax_cat = ".($this->default_c_exp_tax_cat > 0 ? $this->default_c_exp_tax_cat : 'null');
|
||||||
$sql .= ", fk_warehouse = ".($this->fk_warehouse > 0 ? $this->fk_warehouse : "null");
|
$sql .= ", fk_warehouse = ".($this->fk_warehouse > 0 ? $this->fk_warehouse : "null");
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user