From 4d7b2344d25cdd5e78845cfc38a517f2bf9f10e0 Mon Sep 17 00:00:00 2001 From: David Durieux Date: Sat, 13 Mar 2021 13:34:47 +0100 Subject: [PATCH] Fix tab in packages because changes in GLPI. closes #3114 --- inc/deployinstall.class.php | 105 ------------------------------------ inc/deploypackage.class.php | 40 +++++++------- 2 files changed, 22 insertions(+), 123 deletions(-) delete mode 100644 inc/deployinstall.class.php diff --git a/inc/deployinstall.class.php b/inc/deployinstall.class.php deleted file mode 100644 index cc1cbd15ef..0000000000 --- a/inc/deployinstall.class.php +++ /dev/null @@ -1,105 +0,0 @@ -. - * - * ------------------------------------------------------------------------ - * - * This file is used to manage the deploy package installation. - * - * ------------------------------------------------------------------------ - * - * @package FusionInventory - * @author David Durieux - * @author Alexandre Delaunay - * @copyright Copyright (c) 2010-2016 FusionInventory team - * @license AGPL License 3.0 or (at your option) any later version - * http://www.gnu.org/licenses/agpl-3.0-standalone.html - * @link http://www.fusioninventory.org/ - * @link https://github.com/fusioninventory/fusioninventory-for-glpi - * - */ - -if (!defined('GLPI_ROOT')) { - die("Sorry. You can't access directly to this file"); -} - -/** - * Manage the deploy package installation. - */ -class PluginFusioninventoryDeployinstall extends PluginFusioninventoryDeployCommon { - - - /** - * Get name of this type by language of the user connected - * - * @param integer $nb number of elements - * @return string name of this type - */ - static function getTypeName($nb = 0) { - return __('Package actions', 'fusioninventory'); - } - - - /** - * Get the tab name used for item - * - * @param object $item the item object - * @param integer $withtemplate 1 if is a template form - * @return string name of the tab - */ - function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) { - - switch (get_class($item)) { - - case 'PluginFusioninventoryDeployPackage': - return __('Package actions', 'fusioninventory'); - - } - } - - - /** - * Display the content of the tab - * - * @param object $item - * @param integer $tabnum number of the tab to display - * @param integer $withtemplate 1 if is a template form - * @return boolean - */ - static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtemplate = 0) { - switch (get_class($item)) { - - case 'PluginFusioninventoryDeployPackage': - $item->displayOrderTypeForm(); - return true; - - } - return false; - } -} diff --git a/inc/deploypackage.class.php b/inc/deploypackage.class.php index 9cc64bc541..55d2513839 100644 --- a/inc/deploypackage.class.php +++ b/inc/deploypackage.class.php @@ -461,13 +461,7 @@ function showList() { function defineTabs($options = []) { $ong = []; $this->addDefaultFormTab($ong); - if ($this->fields['id'] > 0) { - $this->addStandardTab('PluginFusioninventoryDeployinstall', $ong, $options); - } - if ($this->fields['plugin_fusioninventory_deploygroups_id'] > 0) { - $this->addStandardTab(__CLASS__, $ong, $options); - } - + $this->addStandardTab(__CLASS__, $ong, $options); $ong['no_all_tab'] = true; return $ong; } @@ -1013,17 +1007,24 @@ function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) { case __CLASS__ : if ($item->canUpdateItem()) { - if ($_SESSION['glpishow_count_on_tabs']) { - $nb = $item->countVisibilities(); - return self::createTabEntry(_n('Target for deploy on demand', - 'Targets for deploy on demand', - $nb, 'fusioninventory'), - $nb); - } else { - return _n('Target for deploy on demand', - 'Targets for deploy on demand', 2, - 'fusioninventory'); + $tabs = []; + if ($item->fields['id'] > 0) { + $tabs[1] = __('Package actions', 'fusioninventory'); } + if ($item->fields['plugin_fusioninventory_deploygroups_id'] > 0) { + if ($_SESSION['glpishow_count_on_tabs']) { + $nb = $item->countVisibilities(); + $tabs[2] = self::createTabEntry(_n('Target for deploy on demand', + 'Targets for deploy on demand', + $nb, 'fusioninventory'), + $nb); + } else { + $tabs[2] = _n('Target for deploy on demand', + 'Targets for deploy on demand', 2, + 'fusioninventory'); + } + } + return $tabs; } case 'Computer': @@ -1049,9 +1050,12 @@ function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) { static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtemplate = 0) { if ($item->getType() == __CLASS__) { - if ($tabnum == 1) { + if ($tabnum == 2) { $item->showVisibility(); return true; + } else if ($tabnum == 1) { + $item->displayOrderTypeForm(); + return true; } } else if ($item->getType() == 'Computer') { $package = new self();