Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix(Container): deactivate domtab that no longer works and stop offer… #741

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -1984,19 +2011,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 @@ -863,12 +863,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 @@ -917,6 +917,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 @@ -1045,6 +1046,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