Skip to content

Commit c4f3032

Browse files
committed
fix(issue): redirections when browsing tickets on helpdesk
1 parent 3f35008 commit c4f3032

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

inc/issue.class.php

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,8 @@ public function displaySimplified(CommonDBTM $item, $options = []): void {
403403
}
404404

405405
public function setListUrl(CommonDBTM $item) {
406+
global $DB;
407+
406408
switch ($item::getType()) {
407409
case self::getType():
408410
$_SESSION['glpilisturl'][self::getType()] = $this->getSearchURL();
@@ -414,7 +416,29 @@ public function setListUrl(CommonDBTM $item) {
414416
break;
415417

416418
case Ticket::getType():
417-
$_SESSION['glpilisturl'][self::getType()] = $this->getFormURLWithID($this->getID());
419+
$iterator = $DB->request([
420+
'COUNT' => 'count',
421+
'FROM' => Item_Ticket::getTable(),
422+
'WHERE' => [
423+
'items_id' => new QuerySubQuery([
424+
'SELECT' => 'items_id',
425+
'FROM' => Item_Ticket::getTable(),
426+
'WHERE' => [
427+
'itemtype' => PluginFormcreatorFormAnswer::getType(),
428+
'tickets_id' => $item->getID(),
429+
],
430+
]),
431+
]
432+
]);
433+
$count = 0;
434+
if ($iterator->count() == 1) {
435+
$count = $iterator->current()['count'];
436+
}
437+
if ($count > 1) {
438+
$_SESSION['glpilisturl'][self::getType()] = $this->getFormURLWithID($this->getID());
439+
} else {
440+
$_SESSION['glpilisturl'][self::getType()] = $this->getSearchURL();
441+
}
418442
}
419443
}
420444

setup.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ function plugin_formcreator_redirect() {
412412
}
413413
}
414414

415-
if (plugin_formcreator_replaceHelpdesk() === false) {
415+
if (Session::getCurrentInterface() != 'helpdesk') {
416416
return;
417417
}
418418

0 commit comments

Comments
 (0)