Skip to content

Commit

Permalink
fix(issue): fix navigation through items of a list
Browse files Browse the repository at this point in the history
Signed-off-by: Thierry Bugier <tbugier@teclib.com>
  • Loading branch information
btry committed Dec 11, 2020
1 parent 63abdff commit 63be320
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 30 deletions.
9 changes: 1 addition & 8 deletions front/issue.form.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@
Html::displayNotFoundError();
}

if (!isset($_REQUEST['sub_itemtype'])) {
Html::displayNotFoundError();
}

// force layout of glpi
$layout = $_SESSION['glpilayout'];
$_SESSION['glpilayout'] = "lefttab";
Expand All @@ -60,10 +56,7 @@
Html::redirect($CFG_GLPI['root_doc']."/front/helpdesk.public.php");
}

$issue->getFromDBByCrit([
'original_id' => (int) $_REQUEST['id'],
'sub_itemtype' => $_REQUEST['sub_itemtype'],
]);
$issue->getFromDB((int) $_REQUEST['id']);
$issue->display($_REQUEST);

if (plugin_formcreator_replaceHelpdesk()) {
Expand Down
40 changes: 18 additions & 22 deletions inc/issue.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -238,10 +238,6 @@ public static function hook_update_ticket(CommonDBTM $item) {
* @see CommonGLPI::display()
*/
public function display($options = []) {
$itemtype = $options['sub_itemtype'];
if (!in_array($itemtype, [Ticket::class, PluginFormcreatorFormAnswer::class])) {
html::displayRightError();
}
Html::requireJs('tinymce');
if (plugin_formcreator_replaceHelpdesk() == PluginFormcreatorEntityconfig::CONFIG_SIMPLIFIED_SERVICE_CATALOG) {
$this->displaySimplified($options);
Expand All @@ -251,13 +247,10 @@ public function display($options = []) {
}

public function displayExtended($options = []) {
$item = new $options['sub_itemtype'];

if (isset($options['id'])
&& !$item->isNewID($options['id'])) {
if (!$item->getFromDB($options['id'])) {
Html::displayNotFoundError();
}
$itemtype = $this->fields['sub_itemtype'];
$item = new $itemtype();
if (!$item->getFromDB($this->fields['original_id'])) {
Html::displayNotFoundError();
}

// if ticket(s) exist(s), show it/them
Expand All @@ -267,6 +260,9 @@ public function displayExtended($options = []) {
}
unset($options['_item']);

// Header if the item + link to the list of items
$this->showNavigationHeader($options);

$item->showTabsContent($options);
}

Expand All @@ -276,20 +272,17 @@ public function displayExtended($options = []) {
public function displaySimplified($options = []) {
global $CFG_GLPI;

$item = new $options['sub_itemtype'];

if (isset($options['id'])
&& !$item->isNewID($options['id'])) {
if (!$item->getFromDB($options['id'])) {
Html::displayNotFoundError();
}
$itemtype = $this->fields['sub_itemtype'];
$item = new $itemtype();
if (!$item->getFromDB($this->fields['original_id'])) {
Html::displayNotFoundError();
}

// in case of left tab layout, we couldn't see "right error" message
if ($item->get_item_to_display_tab) {
if (isset($options["id"])
&& $options["id"]
&& !$item->can($options["id"], READ)) {
if (isset($this->fields['original_id'])
&& $this->fields['original_id']
&& !$item->can($this->fields['original_id'], READ)) {
// This triggers from a profile switch.
// If we don't have right, redirect instead to central page
if (isset($_SESSION['_redirected_from_profile_selector'])
Expand All @@ -302,8 +295,10 @@ public function displaySimplified($options = []) {
}
}

if (!isset($options['id'])) {
if (!isset($this->fields['original_id'])) {
$options['id'] = 0;
} else {
$options['id'] = $item->getID();
}

// Header if the item + link to the list of items
Expand Down Expand Up @@ -657,6 +652,7 @@ public static function giveItem($itemtype, $option_id, $data, $num) {
$content = '';
}
$link = self::getFormURLWithID($id) . "&sub_itemtype=".$data['raw']['sub_itemtype'];
$link = self::getFormURLWithID($data['id']);
$key = 'id';
$tooltip = Html::showToolTip(nl2br(Html::Clean($content)), [
'applyto' => $itemtype.$data['raw'][$key],
Expand Down

0 comments on commit 63be320

Please sign in to comment.