From 5bb3714ef718f740373c4e8a352e7df70ea129ee Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 2 Jul 2026 12:39:23 +0200 Subject: [PATCH] Fix: use the same condition everywhere --- htdocs/user/card.php | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/htdocs/user/card.php b/htdocs/user/card.php index da29cd14f57..a23f6286d32 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -161,8 +161,12 @@ 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"))); +// Permission to read salary and hourly rate +$permissiontoseesalary = (empty($user->socid) && ( + (isModEnabled('salaries') && $user->hasRight("salaries", "read") && ($id == 0 || in_array($id, $childids))) // If user is a manager of employee + || (isModEnabled('salaries') && $user->hasRight("salaries", "readall")) + || (isModEnabled('hrm') && $user->hasRight("hrm", "employee", "read"))) + || (!isModEnabled('salaries') && !isModEnabled('hrm') && ($id == 0 || in_array($id, $childids)))); $passwordismodified = false; $ldap = null; @@ -337,7 +341,7 @@ if (empty($reshook)) { $object->employee = GETPOSTINT('employee'); // Only users allowed to see salary/HR fields can modify them (issue #32909) - if ($permissiontoeditsalary) { + if ($permissiontoseesalary) { $object->thm = GETPOST("thm", 'alphanohtml') != '' ? GETPOST("thm", 'alphanohtml') : ''; $object->thm = price2num($object->thm); $object->tjm = GETPOST("tjm", 'alphanohtml') != '' ? GETPOST("tjm", 'alphanohtml') : ''; @@ -531,7 +535,7 @@ if (empty($reshook)) { $object->employee = GETPOSTINT('employee'); // Only users allowed to see salary/HR fields can modify them (issue #32909) - if ($permissiontoeditsalary) { + if ($permissiontoseesalary) { $object->thm = GETPOST("thm", 'alphanohtml') != '' ? GETPOST("thm", 'alphanohtml') : ''; $object->thm = price2num($object->thm); $object->tjm = GETPOST("tjm", 'alphanohtml') != '' ? GETPOST("tjm", 'alphanohtml') : ''; @@ -1484,9 +1488,7 @@ if ($action == 'create' || $action == 'adduserldap') { print ''; print ''; - if ((isModEnabled('salaries') && $user->hasRight("salaries", "read") && in_array($id, $childids)) - || (isModEnabled('salaries') && $user->hasRight("salaries", "readall")) - || (isModEnabled('hrm') && $user->hasRight("hrm", "employee", "read"))) { + if ($permissiontoseesalary) { $langs->load("salaries"); // THM @@ -1810,9 +1812,7 @@ if ($action == 'create' || $action == 'adduserldap') { print "\n"; // Sensitive salary/value information - if ((empty($user->socid) && in_array($id, $childids)) // A user can always see salary/value information for its subordinates - || (isModEnabled('salaries') && $user->hasRight("salaries", "readall")) - || (isModEnabled('hrm') && $user->hasRight("hrm", "employee", "read"))) { + if ($permissiontoseesalary) { $langs->load("salaries"); // Salary @@ -3027,9 +3027,7 @@ if ($action == 'create' || $action == 'adduserldap') { print "\n"; // Sensitive salary/value information - if ((empty($user->socid) && in_array($id, $childids)) // A user can always see salary/value information for its subordinates - || (isModEnabled('salaries') && $user->hasRight("salaries", "readall")) - || (isModEnabled('hrm') && $user->hasRight("hrm", "employee", "read"))) { + if ($permissiontoseesalary) { $langs->load("salaries"); // Salary