@@ -238,10 +238,6 @@ public static function hook_update_ticket(CommonDBTM $item) {
238238 * @see CommonGLPI::display()
239239 */
240240 public function display ($ options = []) {
241- $ itemtype = $ options ['sub_itemtype ' ];
242- if (!in_array ($ itemtype , [Ticket::class, PluginFormcreatorFormAnswer::class])) {
243- html::displayRightError ();
244- }
245241 Html::requireJs ('tinymce ' );
246242 if (plugin_formcreator_replaceHelpdesk () == PluginFormcreatorEntityconfig::CONFIG_SIMPLIFIED_SERVICE_CATALOG ) {
247243 $ this ->displaySimplified ($ options );
@@ -251,13 +247,10 @@ public function display($options = []) {
251247 }
252248
253249 public function displayExtended ($ options = []) {
254- $ item = new $ options ['sub_itemtype ' ];
255-
256- if (isset ($ options ['id ' ])
257- && !$ item ->isNewID ($ options ['id ' ])) {
258- if (!$ item ->getFromDB ($ options ['id ' ])) {
259- Html::displayNotFoundError ();
260- }
250+ $ itemtype = $ this ->fields ['sub_itemtype ' ];
251+ $ item = new $ itemtype ();
252+ if (!$ item ->getFromDB ($ this ->fields ['original_id ' ])) {
253+ Html::displayNotFoundError ();
261254 }
262255
263256 // if ticket(s) exist(s), show it/them
@@ -267,6 +260,9 @@ public function displayExtended($options = []) {
267260 }
268261 unset($ options ['_item ' ]);
269262
263+ // Header if the item + link to the list of items
264+ $ this ->showNavigationHeader ($ options );
265+
270266 $ item ->showTabsContent ($ options );
271267 }
272268
@@ -276,20 +272,17 @@ public function displayExtended($options = []) {
276272 public function displaySimplified ($ options = []) {
277273 global $ CFG_GLPI ;
278274
279- $ item = new $ options ['sub_itemtype ' ];
280-
281- if (isset ($ options ['id ' ])
282- && !$ item ->isNewID ($ options ['id ' ])) {
283- if (!$ item ->getFromDB ($ options ['id ' ])) {
284- Html::displayNotFoundError ();
285- }
275+ $ itemtype = $ this ->fields ['sub_itemtype ' ];
276+ $ item = new $ itemtype ();
277+ if (!$ item ->getFromDB ($ this ->fields ['original_id ' ])) {
278+ Html::displayNotFoundError ();
286279 }
287280
288281 // in case of left tab layout, we couldn't see "right error" message
289282 if ($ item ->get_item_to_display_tab ) {
290- if (isset ($ options [ " id " ])
291- && $ options [ " id " ]
292- && !$ item ->can ($ options [ " id " ], READ )) {
283+ if (isset ($ this -> fields [ ' original_id ' ])
284+ && $ this -> fields [ ' original_id ' ]
285+ && !$ item ->can ($ this -> fields [ ' original_id ' ], READ )) {
293286 // This triggers from a profile switch.
294287 // If we don't have right, redirect instead to central page
295288 if (isset ($ _SESSION ['_redirected_from_profile_selector ' ])
@@ -302,8 +295,10 @@ public function displaySimplified($options = []) {
302295 }
303296 }
304297
305- if (!isset ($ options [ ' id ' ])) {
298+ if (!isset ($ this -> fields [ ' original_id ' ])) {
306299 $ options ['id ' ] = 0 ;
300+ } else {
301+ $ options ['id ' ] = $ item ->getID ();
307302 }
308303
309304 // Header if the item + link to the list of items
@@ -657,6 +652,7 @@ public static function giveItem($itemtype, $option_id, $data, $num) {
657652 $ content = '' ;
658653 }
659654 $ link = self ::getFormURLWithID ($ id ) . "&sub_itemtype= " .$ data ['raw ' ]['sub_itemtype ' ];
655+ $ link = self ::getFormURLWithID ($ data ['id ' ]);
660656 $ key = 'id ' ;
661657 $ tooltip = Html::showToolTip (nl2br (Html::Clean ($ content )), [
662658 'applyto ' => $ itemtype .$ data ['raw ' ][$ key ],
0 commit comments