Skip to content

Commit 58a9b04

Browse files
feat: Improve browser tabs names
1 parent e075fef commit 58a9b04

File tree

2 files changed

+39
-9
lines changed

2 files changed

+39
-9
lines changed

front/issue.form.php

+32-7
Original file line numberDiff line numberDiff line change
@@ -57,18 +57,43 @@
5757
PluginFormcreatorCommon::saveLayout();
5858
$_SESSION['glpilayout'] = "lefttab";
5959

60-
if (Session::getCurrentInterface() == "helpdesk") {
61-
Html::helpHeader(__('Service catalog', 'formcreator'));
62-
} else {
63-
Html::header(__('Service catalog', 'formcreator'));
64-
}
6560
/** @var PluginFormcreatorIssue $issue */
6661
$issue = PluginFormcreatorIssue::getById((int) $_REQUEST['id']);
67-
if ($issue === false) {
62+
63+
if ($issue) {
64+
$itemtype = $issue->fields['itemtype'];
65+
66+
// Trick to change the displayed id as Html::includeHeader() rely on request data
67+
$old_id = $_GET['id'];
68+
$_GET['id'] = $issue->fields['display_id'];
69+
70+
// Specific case, viewing a ticket from a formanswer result
71+
if ($itemtype == PluginFormcreatorFormAnswer::class && isset($_GET['tickets_id'])) {
72+
$itemtype = Ticket::class;
73+
$_GET['id'] = "f_$_GET[tickets_id]";
74+
}
75+
76+
$header = $itemtype::getTypeName(1);
77+
if (Session::getCurrentInterface() == "helpdesk") {
78+
Html::helpHeader($header);
79+
} else {
80+
Html::header($header);
81+
}
82+
83+
// Reset request param in case some other code depends on it
84+
$_GET['id'] = $old_id;
85+
86+
$issue->display($_REQUEST);
87+
} else {
88+
$header = __('Item not found');
89+
if (Session::getCurrentInterface() == "helpdesk") {
90+
Html::helpHeader($header);
91+
} else {
92+
Html::header($header);
93+
}
6894
PluginFormcreatorCommon::restoreLayout();
6995
Html::displayNotFoundError();
7096
}
71-
$issue->display($_REQUEST);
7297

7398
if (Session::getCurrentInterface() == "helpdesk") {
7499
Html::helpFooter();

inc/issue.class.php

+7-2
Original file line numberDiff line numberDiff line change
@@ -803,8 +803,13 @@ public static function giveItem($itemtype, $option_id, $data, $num) {
803803
default:
804804
$content = '';
805805
}
806-
$link = self::getFormURLWithID($id) . "&itemtype=".$data['raw']['itemtype'];
807-
$link = self::getFormURLWithID($data['id']);
806+
$link = self::getFormURLWithID($data['id']);
807+
808+
// Show "final" item id in the URL
809+
if (Toolbox::isCommonDBTM($subItemtype)) {
810+
$link .= "&" . $subItemtype::getForeignKeyField() . "=$id";
811+
}
812+
808813
$key = 'id';
809814
$tooltip = Html::showToolTip(nl2br(RichText::getTextFromHtml($content)), [
810815
'applyto' => $itemtype.$data['raw'][$key],

0 commit comments

Comments
 (0)