@@ -1093,10 +1093,12 @@ public function prepareInputForUpdate($input)
10931093 }
10941094
10951095 // Security on default entity update
1096- if (isset ($ input ['entities_id ' ])) {
1097- if (!in_array ($ input ['entities_id ' ], Profile_User::getUserEntities ($ input ['id ' ]))) {
1098- unset($ input ['entities_id ' ]);
1099- }
1096+ if (
1097+ isset ($ input ['entities_id ' ])
1098+ && ($ input ['entities_id ' ] > 0 )
1099+ && (!in_array ($ input ['entities_id ' ], Profile_User::getUserEntities ($ input ['id ' ])))
1100+ ) {
1101+ unset($ input ['entities_id ' ]);
11001102 }
11011103
11021104 // Security on default group update
@@ -2921,9 +2923,14 @@ public function showForm($ID, array $options = [])
29212923 $ entrand = mt_rand ();
29222924 echo "</td><td><label for='dropdown_entities_id $ entrand'> " . __ ('Default entity ' ) . "</label></td><td> " ;
29232925 $ entities = $ this ->getEntities ();
2926+ $ toadd = [];
2927+ if (!in_array (0 , $ entities )) {
2928+ $ toadd = [0 => __ ('Full structure ' )];
2929+ }
29242930 Entity::dropdown (['value ' => $ this ->fields ["entities_id " ],
29252931 'rand ' => $ entrand ,
2926- 'entity ' => $ entities
2932+ 'entity ' => $ entities ,
2933+ 'toadd ' => $ toadd ,
29272934 ]);
29282935 echo "</td></tr> " ;
29292936
@@ -3309,9 +3316,14 @@ public function showMyForm($target, $ID)
33093316 ) {
33103317 $ entrand = mt_rand ();
33113318 echo "<td><label for='dropdown_entities_id $ entrand'> " . __ ('Default entity ' ) . "</td><td> " ;
3319+ $ toadd = [];
3320+ if (!in_array (0 , $ entities )) {
3321+ $ toadd = [0 => __ ('Full structure ' )];
3322+ }
33123323 Entity::dropdown (['value ' => $ this ->fields ['entities_id ' ],
33133324 'rand ' => $ entrand ,
3314- 'entity ' => $ entities
3325+ 'entity ' => $ entities ,
3326+ 'toadd ' => $ toadd ,
33153327 ]);
33163328 } else {
33173329 echo "<td colspan='2'> " ;
0 commit comments