From 5024bf1b11cc612fe5b3756bff77e61e4a0bc9e1 Mon Sep 17 00:00:00 2001 From: Stanislas Date: Wed, 21 Feb 2024 11:59:52 +0100 Subject: [PATCH] =?UTF-8?q?Fix(Container):=20deactivate=20domtab=20that=20?= =?UTF-8?q?no=20longer=20works=20and=20stop=20offer=E2=80=A6=20(#741)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix(Container): deactivate domtab that no longer works and handle ITILSolution * remove ITILSolution for type 'tab' * fix comment * Update inc/container.class.php --------- Co-authored-by: Romain B <8530352+Rom1-B@users.noreply.github.com> --- inc/container.class.php | 42 +++++++++++++++++++++++++++-------------- inc/field.class.php | 4 +++- inc/toolbox.class.php | 1 + 3 files changed, 32 insertions(+), 15 deletions(-) diff --git a/inc/container.class.php b/inc/container.class.php index a6444efb..acf0f448 100644 --- a/inc/container.class.php +++ b/inc/container.class.php @@ -323,6 +323,27 @@ public static function installUserData(Migration $migration, $version) } } + + //Ticket Solution tab no longer exist disable it + //Problem Solution tab no longer exist disable it + //Change Analysis / Solution / Plans no longer exist disable it + $DB->update( + 'glpi_plugin_fields_containers', + [ + 'is_active' => 0, + ], + [ + 'type' => 'domtab', + [ + 'OR' => [ + ['subtype' => ['LIKE', 'Ticket$2']], + ['subtype' => ['LIKE', 'Problem$2']], + ['subtype' => ['LIKE', 'Change$%']], + ], + ], + ] + ); + // Ensure data is update before regenerating files. $migration->executeMigration(); @@ -878,11 +899,17 @@ public function showForm($ID, $options = []) public static function showFormItemtype($params = []) { $is_domtab = isset($params['type']) && $params['type'] == 'domtab'; + $values = self::getItemtypes($is_domtab); + + //remove ITISolution from values if type is tab + if (!isset($params['type']) || (isset($params['type']) && $params['type'] == 'tab')) { + unset($values[__('Assistance')]['ITILSolution']); + } $rand = $params['rand']; Dropdown::showFromArray( "itemtypes", - self::getItemtypes($is_domtab), + $values, [ 'rand' => $rand, 'multiple' => !$is_domtab, @@ -1986,19 +2013,6 @@ private static function getSubtypes($item) { $tabs = []; switch ($item::getType()) { - case Ticket::getType(): - case Problem::getType(): - $tabs = [ - $item::getType() . '$2' => __('Solution') - ]; - break; - case Change::getType(): - $tabs = [ - 'Change$1' => __('Analysis'), - 'Change$2' => __('Solution'), - 'Change$3' => __('Plans') - ]; - break; case Entity::getType(): $tabs = [ 'Entity$2' => __('Address'), diff --git a/inc/field.class.php b/inc/field.class.php index 5739e94e..4707d053 100644 --- a/inc/field.class.php +++ b/inc/field.class.php @@ -864,12 +864,12 @@ public static function showForTab($params) $item = $params['item']; $functions = array_column(debug_backtrace(), 'function'); - $subtype = isset($_SESSION['glpi_tabs'][strtolower($item::getType())]) ? $_SESSION['glpi_tabs'][strtolower($item::getType())] : ""; $type = substr($subtype, -strlen('$main')) === '$main' || in_array('showForm', $functions) || in_array('showPrimaryForm', $functions) || in_array('showFormHelpdesk', $functions) + || $item::getType() == ITILSolution::class ? 'dom' : 'domtab'; if ($subtype == -1) { @@ -918,6 +918,7 @@ public static function showForTab($params) strpos($current_url, ".form.php") === false && strpos($current_url, ".injector.php") === false && strpos($current_url, ".public.php") === false + && strpos($current_url, "ajax/timeline.php") === false // ITILSolution load from timeline ) { return false; } @@ -1046,6 +1047,7 @@ function(evt) { ); } + public static function prepareHtmlFields( $fields, $item, diff --git a/inc/toolbox.class.php b/inc/toolbox.class.php index 1c8ef656..64b654c2 100644 --- a/inc/toolbox.class.php +++ b/inc/toolbox.class.php @@ -236,6 +236,7 @@ public static function getGlpiItemtypes(): array Ticket::class, Problem::class, Change::class, + ITILSolution::class, TicketRecurrent::class, RecurrentChange::class, PlanningExternalEvent::class,