Skip to content

Commit

Permalink
Clean menu if no ipdiscover
Browse files Browse the repository at this point in the history
  • Loading branch information
tsmr committed Apr 28, 2020
1 parent ce66ef1 commit 31d52fa
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions inc/menu.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,22 +155,27 @@ function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) {

switch ($item->getType()) {
case __CLASS__ :
$dbu = new DbUtils();
$dbu = new DbUtils();
$ocsServers = $dbu->getAllDataFromTable('glpi_plugin_ocsinventoryng_ocsservers',
["is_active" => 1]);
["is_active" => 1]);
if (!empty($ocsServers)) {

$ong[0] = __('Server Setup', 'ocsinventoryng');

$ong[1] = __('Inventory Import', 'ocsinventoryng');

$ong[2] = __('IPDiscover Import', 'ocsinventoryng');
if (isset($_SESSION["plugin_ocsinventoryng_ocsservers_id"])
&& $_SESSION["plugin_ocsinventoryng_ocsservers_id"] > 0) {
if (PluginOcsinventoryngOcsServer::checkOCSconnection($_SESSION["plugin_ocsinventoryng_ocsservers_id"])) {
$ocsClient = new PluginOcsinventoryngOcsServer();
$client = $ocsClient->getDBocs($_SESSION["plugin_ocsinventoryng_ocsservers_id"]);
$ipdiscover = $client->getIntConfig('IPDISCOVER');
if ($ipdiscover) {
$ong[2] = __('IPDiscover Import', 'ocsinventoryng');
}
}
}

//if (isset($_POST["plugin_ocsinventoryng_ocsservers_id"])) {
// $_SESSION["plugin_ocsinventoryng_ocsservers_id"] = $_POST["plugin_ocsinventoryng_ocsservers_id"];
//} else {
// $_SESSION["plugin_ocsinventoryng_ocsservers_id"] = PluginOcsinventoryngOcsServer::getFirstServer();
//}

if (isset($_SESSION["plugin_ocsinventoryng_ocsservers_id"])
&& $_SESSION["plugin_ocsinventoryng_ocsservers_id"] > 0) {
Expand Down

0 comments on commit 31d52fa

Please sign in to comment.