Skip to content

Commit

Permalink
Fix(Container): deactivate domtab that no longer works and stop offer… (
Browse files Browse the repository at this point in the history
#741)

* 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 <[email protected]>
  • Loading branch information
stonebuzz and Rom1-B authored Feb 21, 2024
1 parent 0540c7e commit 5024bf1
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 15 deletions.
42 changes: 28 additions & 14 deletions inc/container.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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'),
Expand Down
4 changes: 3 additions & 1 deletion inc/field.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -1046,6 +1047,7 @@ function(evt) {
);
}


public static function prepareHtmlFields(
$fields,
$item,
Expand Down
1 change: 1 addition & 0 deletions inc/toolbox.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ public static function getGlpiItemtypes(): array
Ticket::class,
Problem::class,
Change::class,
ITILSolution::class,
TicketRecurrent::class,
RecurrentChange::class,
PlanningExternalEvent::class,
Expand Down

0 comments on commit 5024bf1

Please sign in to comment.