Skip to content

Commit

Permalink
fix(user): can not update is_active field
Browse files Browse the repository at this point in the history
  • Loading branch information
Rom1-B authored Dec 2, 2024
1 parent bc19bb0 commit dcd96b0
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
6 changes: 5 additions & 1 deletion src/Dropdown.php
Original file line number Diff line number Diff line change
Expand Up @@ -2178,7 +2178,11 @@ public static function showFromArray($name, array $elements, $options = [])
$to_display[] = $elements[$value];
}
}
$output .= '<span class="form-control" readonly style="width: ' . $param["width"] . '">' . implode(', ', $to_display) . '</span>';
$output .= '<span class="form-control" readonly style="width: ' . $param["width"] . '"';
if ($param['tooltip']) {
$output .= ' title="' . htmlspecialchars($param['tooltip'], ENT_QUOTES) . '"';
}
$output .= '>' . implode(', ', $to_display) . '</span>';
} else {
$output .= "<select name='$field_name' id='$field_id'";

Expand Down
7 changes: 6 additions & 1 deletion src/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -2765,7 +2765,12 @@ public function showForm($ID, array $options = [])
if (!GLPI_DEMO_MODE) {
$activerand = mt_rand();
echo "<td><label for='dropdown_is_active$activerand'>" . __('Active') . "</label></td><td>";
Dropdown::showYesNo('is_active', $this->fields['is_active'], -1, ['rand' => $activerand]);
$params = ['rand' => $activerand];
if (!$higherrights) {
$params['readonly'] = true;
$params['tooltip'] = __('Not enough rights to change this field');
}
Dropdown::showYesNo('is_active', $this->fields['is_active'], -1, $params);
echo "</td>";
} else {
echo "<td colspan='2'></td>";
Expand Down
14 changes: 12 additions & 2 deletions src/UserEmail.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,12 @@ public static function showForUser(User $user)
) {
return;
}
$canedit = ($user->can($users_id, UPDATE) || ($users_id == Session::getLoginUserID()));
$canedit = (
(
$user->can($users_id, UPDATE)
&& ($user->currentUserHaveMoreRightThan($users_id)))
|| ($users_id == Session::getLoginUserID())
);

parent::showChildsForItemForm($user, '_useremails', $canedit);
}
Expand All @@ -273,7 +278,12 @@ public static function showAddEmailButton(User $user)
if (!$user->can($users_id, READ) && ($users_id != Session::getLoginUserID())) {
return false;
}
$canedit = ($user->can($users_id, UPDATE) || ($users_id == Session::getLoginUserID()));
$canedit = (
(
$user->can($users_id, UPDATE)
&& ($user->currentUserHaveMoreRightThan($users_id)))
|| ($users_id == Session::getLoginUserID())
);

parent::showAddChildButtonForItemForm($user, '_useremails', $canedit);

Expand Down

0 comments on commit dcd96b0

Please sign in to comment.