diff --git a/src/MassiveAction.php b/src/MassiveAction.php index aecb3c53806..e6854ec6e50 100644 --- a/src/MassiveAction.php +++ b/src/MassiveAction.php @@ -173,6 +173,8 @@ class MassiveAction */ private $current_itemtype; + private $from_single_item = false; + /** * Constructor of massive actions. * There is three stages and each one have its own objectives: @@ -192,6 +194,8 @@ public function __construct(array $POST, array $GET, $stage, ?int $items_id = nu /** @var array $CFG_GLPI */ global $CFG_GLPI; + $this->from_single_item = $GET['_from_single_item'] ?? false; + if (!empty($POST)) { if (!isset($POST['is_deleted'])) { $POST['is_deleted'] = 0; @@ -1923,4 +1927,12 @@ public function itemDone($itemtype, $id, $result) $this->updateProgressBars(); } + + /** + * @return bool True if massive actions are running from a single item context such as the item's form. + */ + public function isFromSingleItem(): bool + { + return $this->from_single_item; + } } diff --git a/src/Unmanaged.php b/src/Unmanaged.php index e9bcb9f1a53..3a70d3eb2c3 100644 --- a/src/Unmanaged.php +++ b/src/Unmanaged.php @@ -323,7 +323,7 @@ public static function processMassiveActionsForOneItemtype( $itemtype = $_POST['itemtype']; $new_asset_id = $unmanaged->convert($id, $itemtype); $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK); - if (count($ids) === 1) { + if ($ma->isFromSingleItem()) { $ma->setRedirect($itemtype::getFormURLWithID($new_asset_id)); } else { $ma->setRedirect($item::getSearchURL()); diff --git a/templates/components/form/header_content.html.twig b/templates/components/form/header_content.html.twig index f1873967208..2ad66697e91 100644 --- a/templates/components/form/header_content.html.twig +++ b/templates/components/form/header_content.html.twig @@ -65,7 +65,7 @@ {% if item.canEdit(item.fields['id']) %}
diff --git a/templates/components/itilobject/layout.html.twig b/templates/components/itilobject/layout.html.twig index 03db4ce385d..c1360fe2a43 100644 --- a/templates/components/itilobject/layout.html.twig +++ b/templates/components/itilobject/layout.html.twig @@ -109,7 +109,7 @@ {% endfor %}