@@ -238,10 +238,6 @@ public static function hook_update_ticket(CommonDBTM $item) {
238
238
* @see CommonGLPI::display()
239
239
*/
240
240
public function display ($ options = []) {
241
- $ itemtype = $ options ['sub_itemtype ' ];
242
- if (!in_array ($ itemtype , [Ticket::class, PluginFormcreatorFormAnswer::class])) {
243
- html::displayRightError ();
244
- }
245
241
Html::requireJs ('tinymce ' );
246
242
if (plugin_formcreator_replaceHelpdesk () == PluginFormcreatorEntityconfig::CONFIG_SIMPLIFIED_SERVICE_CATALOG ) {
247
243
$ this ->displaySimplified ($ options );
@@ -251,13 +247,10 @@ public function display($options = []) {
251
247
}
252
248
253
249
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 ();
261
254
}
262
255
263
256
// if ticket(s) exist(s), show it/them
@@ -267,6 +260,9 @@ public function displayExtended($options = []) {
267
260
}
268
261
unset($ options ['_item ' ]);
269
262
263
+ // Header if the item + link to the list of items
264
+ $ this ->showNavigationHeader ($ options );
265
+
270
266
$ item ->showTabsContent ($ options );
271
267
}
272
268
@@ -276,20 +272,17 @@ public function displayExtended($options = []) {
276
272
public function displaySimplified ($ options = []) {
277
273
global $ CFG_GLPI ;
278
274
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 ();
286
279
}
287
280
288
281
// in case of left tab layout, we couldn't see "right error" message
289
282
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 )) {
293
286
// This triggers from a profile switch.
294
287
// If we don't have right, redirect instead to central page
295
288
if (isset ($ _SESSION ['_redirected_from_profile_selector ' ])
@@ -302,8 +295,10 @@ public function displaySimplified($options = []) {
302
295
}
303
296
}
304
297
305
- if (!isset ($ options [ ' id ' ])) {
298
+ if (!isset ($ this -> fields [ ' original_id ' ])) {
306
299
$ options ['id ' ] = 0 ;
300
+ } else {
301
+ $ options ['id ' ] = $ item ->getID ();
307
302
}
308
303
309
304
// Header if the item + link to the list of items
@@ -657,6 +652,7 @@ public static function giveItem($itemtype, $option_id, $data, $num) {
657
652
$ content = '' ;
658
653
}
659
654
$ link = self ::getFormURLWithID ($ id ) . "&sub_itemtype= " .$ data ['raw ' ]['sub_itemtype ' ];
655
+ $ link = self ::getFormURLWithID ($ data ['id ' ]);
660
656
$ key = 'id ' ;
661
657
$ tooltip = Html::showToolTip (nl2br (Html::Clean ($ content )), [
662
658
'applyto ' => $ itemtype .$ data ['raw ' ][$ key ],
0 commit comments