Skip to content

Commit

Permalink
try to fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cedric-anne committed Jan 24, 2024
1 parent bdf2677 commit ca092dd
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions src/Profile.php
Original file line number Diff line number Diff line change
Expand Up @@ -422,20 +422,23 @@ public function prepareInputForUpdate($input)


// Check if profile edit right was removed
$can_edit_profile = $this->fields['profile'] & UPDATE == UPDATE;
$updated_value = $input['_profile'][UPDATE . "_0"] ?? null;
$update_profiles_right_was_removed = $updated_value !== null && !(bool) $updated_value;
if (
$can_edit_profile
&& $update_profiles_right_was_removed
&& $this->isLastSuperAdminProfile()
) {
Session::addMessageAfterRedirect(
__("Can't remove update right on this profile as it is the only remaining profile with this right."),
false,
ERROR
);
unset($input['_profile']);
// `$this->fields['profile']` will not be present if the `profile` right is not present in DB for the current profile
if (array_key_exists('profile', $this->fields)) {
$can_edit_profile = $this->fields['profile'] & UPDATE == UPDATE;
$updated_value = $input['_profile'][UPDATE . "_0"] ?? null;
$update_profiles_right_was_removed = $updated_value !== null && !(bool) $updated_value;
if (
$can_edit_profile
&& $update_profiles_right_was_removed
&& $this->isLastSuperAdminProfile()
) {
Session::addMessageAfterRedirect(
__("Can't remove update right on this profile as it is the only remaining profile with this right."),
false,
ERROR
);
unset($input['_profile']);
}
}

if (isset($input['interface']) && $input['interface'] == 'helpdesk' && $this->isLastSuperAdminProfile()) {
Expand Down

0 comments on commit ca092dd

Please sign in to comment.