* FIX #32909 Restrict salary/HR field edit to authorized users On the user card, a user with only "modify own info" (user->self->write) could edit thm, tjm, salary, salaryextra and weeklyhours, even though the display of these fields is gated on salaries->readall / hrm->employee->read. Guard the write of these fields with the same permission used for display, so self-service users can no longer change compensation data they are not allowed to see. Signed-off-by: Sanjiv Kumar Bhagat <reach.sanjiv.bhagat@gmail.com> * Update card.php * Update salary edit permissions logic --------- Signed-off-by: Sanjiv Kumar Bhagat <reach.sanjiv.bhagat@gmail.com> Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
This commit is contained in:
parent
6e101143e0
commit
dc2a01ff28
1 changed files with 27 additions and 18 deletions
|
|
@ -161,6 +161,9 @@ if ($id > 0) {
|
|||
$permissiontoeditpasswordandsend = ((($user->id == $id) && $user->hasRight("user", "self", "password")) || (($user->id != $id) && $user->hasRight("user", "user", "password")))&& (empty($user->socid) || $user->socid == $object->socid);
|
||||
}
|
||||
|
||||
// Salary and other HR fields must only be editable by users allowed to see them (same rights as the display, see issue #32909)
|
||||
$permissiontoeditsalary = ((isModEnabled('salaries') && $user->hasRight("salaries", "read") && in_array($id, $childids)) || (isModEnabled('salaries') && $user->hasRight("salaries", "readall")) || (isModEnabled('hrm') && $user->hasRight("hrm", "employee", "read")));
|
||||
|
||||
$passwordismodified = false;
|
||||
$ldap = null;
|
||||
|
||||
|
|
@ -333,14 +336,17 @@ if (empty($reshook)) {
|
|||
$object->fk_user_holiday_validator = GETPOSTINT("fk_user_holiday_validator") > 0 ? GETPOSTINT("fk_user_holiday_validator") : 0;
|
||||
$object->employee = GETPOSTINT('employee');
|
||||
|
||||
$object->thm = GETPOST("thm", 'alphanohtml') != '' ? GETPOST("thm", 'alphanohtml') : '';
|
||||
$object->thm = price2num($object->thm);
|
||||
$object->tjm = GETPOST("tjm", 'alphanohtml') != '' ? GETPOST("tjm", 'alphanohtml') : '';
|
||||
$object->tjm = price2num($object->tjm);
|
||||
$object->salary = GETPOST("salary", 'alphanohtml') != '' ? GETPOST("salary", 'alphanohtml') : '';
|
||||
$object->salary = price2num($object->salary);
|
||||
$object->salaryextra = GETPOST("salaryextra", 'alphanohtml') != '' ? GETPOST("salaryextra", 'alphanohtml') : '';
|
||||
$object->weeklyhours = GETPOST("weeklyhours", 'alphanohtml') != '' ? GETPOST("weeklyhours", 'alphanohtml') : '';
|
||||
// Only users allowed to see salary/HR fields can modify them (issue #32909)
|
||||
if ($permissiontoeditsalary) {
|
||||
$object->thm = GETPOST("thm", 'alphanohtml') != '' ? GETPOST("thm", 'alphanohtml') : '';
|
||||
$object->thm = price2num($object->thm);
|
||||
$object->tjm = GETPOST("tjm", 'alphanohtml') != '' ? GETPOST("tjm", 'alphanohtml') : '';
|
||||
$object->tjm = price2num($object->tjm);
|
||||
$object->salary = GETPOST("salary", 'alphanohtml') != '' ? GETPOST("salary", 'alphanohtml') : '';
|
||||
$object->salary = price2num($object->salary);
|
||||
$object->salaryextra = GETPOST("salaryextra", 'alphanohtml') != '' ? GETPOST("salaryextra", 'alphanohtml') : '';
|
||||
$object->weeklyhours = GETPOST("weeklyhours", 'alphanohtml') != '' ? GETPOST("weeklyhours", 'alphanohtml') : '';
|
||||
}
|
||||
|
||||
$object->color = GETPOST("color", 'alphanohtml') != '' ? GETPOST("color", 'alphanohtml') : '';
|
||||
|
||||
|
|
@ -524,16 +530,19 @@ if (empty($reshook)) {
|
|||
$object->fk_user_holiday_validator = GETPOSTINT("fk_user_holiday_validator") > 0 ? GETPOSTINT("fk_user_holiday_validator") : 0;
|
||||
$object->employee = GETPOSTINT('employee');
|
||||
|
||||
$object->thm = GETPOST("thm", 'alphanohtml') != '' ? GETPOST("thm", 'alphanohtml') : '';
|
||||
$object->thm = price2num($object->thm);
|
||||
$object->tjm = GETPOST("tjm", 'alphanohtml') != '' ? GETPOST("tjm", 'alphanohtml') : '';
|
||||
$object->tjm = price2num($object->tjm);
|
||||
$object->salary = GETPOST("salary", 'alphanohtml') != '' ? GETPOST("salary", 'alphanohtml') : '';
|
||||
$object->salary = price2num($object->salary);
|
||||
$object->salaryextra = GETPOST("salaryextra", 'alphanohtml') != '' ? GETPOST("salaryextra", 'alphanohtml') : '';
|
||||
$object->salaryextra = price2num($object->salaryextra);
|
||||
$object->weeklyhours = GETPOST("weeklyhours", 'alphanohtml') != '' ? GETPOST("weeklyhours", 'alphanohtml') : '';
|
||||
$object->weeklyhours = price2num($object->weeklyhours);
|
||||
// Only users allowed to see salary/HR fields can modify them (issue #32909)
|
||||
if ($permissiontoeditsalary) {
|
||||
$object->thm = GETPOST("thm", 'alphanohtml') != '' ? GETPOST("thm", 'alphanohtml') : '';
|
||||
$object->thm = price2num($object->thm);
|
||||
$object->tjm = GETPOST("tjm", 'alphanohtml') != '' ? GETPOST("tjm", 'alphanohtml') : '';
|
||||
$object->tjm = price2num($object->tjm);
|
||||
$object->salary = GETPOST("salary", 'alphanohtml') != '' ? GETPOST("salary", 'alphanohtml') : '';
|
||||
$object->salary = price2num($object->salary);
|
||||
$object->salaryextra = GETPOST("salaryextra", 'alphanohtml') != '' ? GETPOST("salaryextra", 'alphanohtml') : '';
|
||||
$object->salaryextra = price2num($object->salaryextra);
|
||||
$object->weeklyhours = GETPOST("weeklyhours", 'alphanohtml') != '' ? GETPOST("weeklyhours", 'alphanohtml') : '';
|
||||
$object->weeklyhours = price2num($object->weeklyhours);
|
||||
}
|
||||
|
||||
$object->color = GETPOST("color", 'alphanohtml') != '' ? GETPOST("color", 'alphanohtml') : '';
|
||||
$object->dateemployment = $dateemployment;
|
||||
|
|
|
|||
Loading…
Reference in a new issue