Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@
"sort-packages": true,
"audit": {
"abandoned": "report"
},
"allow-plugins": {
"phpstan/extension-installer": true
}
},
"autoload": {
Expand Down
19 changes: 19 additions & 0 deletions src/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -1417,6 +1417,25 @@ public function applyRightRules()
$right->delete($db_profile);
}
}

// Check if user has any profile left after deletion, if not add default profile
$remaining_profiles = Profile_User::getForUser($this->fields["id"], false);
if (count($remaining_profiles) == 0) {
$default_profile = Profile::getDefault();
if ($default_profile > 0) {
$affectation = [
'entities_id' => 0, // Root entity
'profiles_id' => $default_profile,
'is_recursive' => 1,
'users_id' => $this->fields['id'],
'is_dynamic' => 1,
'is_default_profile' => 1,
];
$right = new Profile_User();
$right->add($affectation);
}
}

$this->must_process_ruleright = false;
}
return $return;
Expand Down
Loading