Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(user): default entity value = Full structure #18132

Open
wants to merge 7 commits into
base: 10.0/bugfixes
Choose a base branch
from
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
7 changes: 5 additions & 2 deletions src/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -578,11 +578,14 @@ public static function changeProfile($ID)
Search::resetSaveSearch();
$active_entity_done = false;

// Try to load default entity if it is a root entity
// Try to load default entity if it is a root entity
foreach ($data['entities'] as $val) {
if ($val['id'] == $_SESSION["glpidefault_entity"]) {
if ($_SESSION["glpidefault_entity"] == 0 && count($data['entities']) > 1) {
$val['is_recursive'] = true;
}
if (self::changeActiveEntities($val['id'], $val['is_recursive'])) {
$active_entity_done = true;
$active_entity_done = true;
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -2923,10 +2923,10 @@ public function showForm($ID, array $options = [])
$entrand = mt_rand();
echo "</td><td><label for='dropdown_entities_id$entrand'>" . __('Default entity') . "</label></td><td>";
$entities = $this->getEntities();
$toadd = [];
if (!in_array(0, $entities)) {
$toadd = [0 => __('Full structure')];
if (isset($entities[0])) {
unset($entities[0]);
}
$toadd = [0 => __('Full structure')];
Entity::dropdown(['value' => $this->fields["entities_id"],
'rand' => $entrand,
'entity' => $entities,
Expand Down Expand Up @@ -3316,10 +3316,10 @@ public function showMyForm($target, $ID)
) {
$entrand = mt_rand();
echo "<td><label for='dropdown_entities_id$entrand'>" . __('Default entity') . "</td><td>";
$toadd = [];
if (!in_array(0, $entities)) {
$toadd = [0 => __('Full structure')];
if (isset($entities[0])) {
unset($entities[0]);
}
$toadd = [0 => __('Full structure')];
Entity::dropdown(['value' => $this->fields['entities_id'],
'rand' => $entrand,
'entity' => $entities,
Expand Down