diff --git a/htdocs/core/modules/modSalaries.class.php b/htdocs/core/modules/modSalaries.class.php index 759804b409e..3464a5e14b3 100644 --- a/htdocs/core/modules/modSalaries.class.php +++ b/htdocs/core/modules/modSalaries.class.php @@ -101,7 +101,7 @@ class modSalaries extends DolibarrModules $r++; $this->rights[$r][0] = 511; - $this->rights[$r][1] = 'Read payments of employee salaries (yours and your subordinates)'; + $this->rights[$r][1] = 'Read employee salaries and payments (yours and your subordinates)'; $this->rights[$r][2] = 'r'; $this->rights[$r][3] = 0; $this->rights[$r][4] = 'read'; @@ -125,7 +125,7 @@ class modSalaries extends DolibarrModules $r++; $this->rights[$r][0] = 517; - $this->rights[$r][1] = 'Read payments of salariests of every employee'; + $this->rights[$r][1] = 'Read salaries and payments of all employees'; $this->rights[$r][2] = 'r'; $this->rights[$r][3] = 0; $this->rights[$r][4] = 'readall'; diff --git a/htdocs/user/card.php b/htdocs/user/card.php index fcd6baa2c05..999de6db0f7 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -87,6 +87,8 @@ if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) { $caneditgroup = (!empty($user->admin) || $user->rights->user->group_advance->write); } +$childids = $user->getAllChildIds(1); // For later, test on salary visibility + // Define value to know what current user can do on properties of edited user if ($id) { // $user is the current logged user, $id is the user we want to edit @@ -1201,7 +1203,8 @@ if ($action == 'create' || $action == 'adduserldap') { print ''; print ''; - if ((!empty($conf->salaries->enabled) && !empty($user->rights->salaries->read)) + if ((!empty($conf->salaries->enabled) && !empty($user->rights->salaries->read) && in_array($id, $childids)) + || (!empty($conf->salaries->enabled) && !empty($user->rights->salaries->readall)) || (!empty($conf->hrm->enabled) && !empty($user->rights->hrm->employee->read))) { $langs->load("salaries"); @@ -1499,8 +1502,6 @@ if ($action == 'create' || $action == 'adduserldap') { print ''.dol_escape_htmltag($object->job).''; print ''."\n"; - //$childids = $user->getAllChildIds(1); - if ((!empty($conf->salaries->enabled) && !empty($user->rights->salaries->read)) || (!empty($conf->hrm->enabled) && !empty($user->rights->hrm->employee->read))) { // Even a superior can't see this info of its subordinates wihtout $user->rights->salaries->read and $user->rights->hrm->employee->read (setting/viewing is reserverd to HR people). diff --git a/htdocs/user/list.php b/htdocs/user/list.php index 5c8185069c9..ee7adeff3be 100644 --- a/htdocs/user/list.php +++ b/htdocs/user/list.php @@ -851,8 +851,20 @@ while ($i < ($limit ? min($num, $limit) : $num)) { $li = $userstatic->getNomUrl(-1, '', 0, 0, 24, 1, 'login', '', 1); + $canreadhrmdata = 0; + if ((!empty($conf->salaries->enabled) && !empty($user->rights->salaries->read) && in_array($obj->rowid, $childids)) + || (!empty($conf->salaries->enabled) && !empty($user->rights->salaries->readall)) + || (!empty($conf->hrm->enabled) && !empty($user->rights->hrm->employee->read))) { + $canreadhrmdata = 1; + } + $canreadsecretapi = 0; + if ($user->id = $obj->rowid || !empty($user->admin)) { // Current user or admin + $canreadsecretapi = 1; + } + print ''; + // Login if (!empty($arrayfields['u.login']['checked'])) { print ''; print $li; @@ -888,6 +900,7 @@ while ($i < ($limit ? min($num, $limit) : $num)) { $totalarray['nbfield']++; } } + // Employee yes/no if (!empty($arrayfields['u.employee']['checked'])) { print ''.yn($obj->employee).''; if (!$i) { @@ -951,14 +964,22 @@ while ($i < ($limit ? min($num, $limit) : $num)) { } } if (!empty($arrayfields['u.api_key']['checked'])) { - print ''.$obj->api_key.''; + print ''; + if ($obj->api_key) { + if ($canreadsecretapi) { + print $obj->api_key; + } else { + print ''.$langs->trans("Hidden").''; + } + } + print ''; if (!$i) { $totalarray['nbfield']++; } } if (!empty($arrayfields['u.fk_soc']['checked'])) { print ''; - if ($obj->fk_soc) { + if ($obj->fk_soc > 0) { $companystatic->id = $obj->fk_soc; $companystatic->name = $obj->name; $companystatic->canvas = $obj->canvas; @@ -992,7 +1013,15 @@ while ($i < ($limit ? min($num, $limit) : $num)) { // Salary if (!empty($arrayfields['u.salary']['checked'])) { - print ''.($obj->salary ? price($obj->salary) : '').''; + print ''; + if ($obj->salary) { + if ($canreadhrmdata) { + print price($obj->salary); + } else { + print ''.$langs->trans("Hidden").''; + } + } + print ''; if (!$i) { $totalarray['nbfield']++; }