------------------------------------------------------------------------

  @package   FusionInventory
  @author    David Durieux
  @co-author
  @copyright Copyright (c) 2010-2014 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      http://forge.fusioninventory.org/projects/fusioninventory-for-glpi/
  @since     2014

  ------------------------------------------------------------------------
*/
include "../../../inc/includes.php";
$pfEntity = new PluginFusioninventoryEntity();
if (isset($_POST["add"])) {
    $pfEntity->add($_POST);
    Html::back();
} else {
    if (isset($_POST["update"])) {
        $pfEntity->update($_POST);
        Html::back();
    } else {
        if (isset($_REQUEST["purge"])) {
            $pfEntity->delete($_POST);
            Html::back();
        }
    }
}
 /**
  * Get URL for module (for REST)
  *
  * @param $module value name of module
  *
  * @return nothing
  *
  **/
 static function getUrlForModule($modulename, $entities_id = -1)
 {
     // Get current entity URL if it exists ...
     $pfEntity = new PluginFusioninventoryEntity();
     $baseUrl = $pfEntity->getValue('agent_base_url', $entities_id);
     if (!empty($baseUrl)) {
         PluginFusioninventoryToolbox::logIfExtradebug("pluginFusioninventory-agent-url", "Entity " . $entities_id . ", agent base URL: " . $baseUrl);
         if ($baseUrl != 'N/A') {
             return $baseUrl . '/plugins/fusioninventory/b/' . strtolower($modulename) . '/';
         }
     }
     // ... else use global plugin configuration parameter.
     $config = new PluginFusioninventoryConfig();
     if (strlen($pfEntity->getValue('agent_base_url', $entities_id)) < 10) {
         PluginFusioninventoryCommunicationRest::sendError();
         exit;
         // die ("agent_base_url is unset!\n");
     }
     PluginFusioninventoryToolbox::logIfExtradebug("pluginFusioninventory-agent-url", "Global configuration URL: " . $pfEntity->getValue('agent_base_url', $entities_id));
     # Construct the path to the JSON back from the agent_base_url.
     # agent_base_url is the initial URL used by the agent
     return $pfEntity->getValue('agent_base_url', $entities_id) . '/plugins/fusioninventory/b/' . strtolower($modulename) . '/';
 }
 /**
  * Update computer to not change entity (transfer not allowed)
  *
  * @test
  */
 public function updateComputerNoTranfer()
 {
     global $DB;
     $DB->connect();
     $transfer = new Transfer();
     $computer = new Computer();
     $pfiComputerInv = new PluginFusioninventoryInventoryComputerInventory();
     $pfEntity = new PluginFusioninventoryEntity();
     // Manual transfer computer to entity 2
     $transfer->getFromDB(1);
     $item_to_transfer = array("Computer" => array(1 => 1));
     $transfer->moveItems($item_to_transfer, 2, $transfer->fields);
     $computer->getFromDB(1);
     $this->assertEquals(2, $computer->fields['entities_id'], 'Transfer move computer');
     $this->AgentEntity(1, 2, 'Transfer computer on entity 2');
     // Define entity 2 not allowed to transfer
     $ents_id = $pfEntity->add(array('entities_id' => 2, 'transfers_id_auto' => 0));
     $this->assertEquals(2, $ents_id, 'Entity 2 defined with no transfer');
     // Update computer and computer must not be transfered (keep in entoty 2)
     $a_inventory = array();
     $a_inventory['CONTENT']['HARDWARE'] = array('NAME' => 'pc1');
     $a_inventory['CONTENT']['BIOS'] = array('SSN' => 'xxyyzz');
     $pfiComputerInv->import("pc-2013-02-13", "", $a_inventory);
     // Update
     $this->assertEquals(1, countElementsInTable('glpi_computers'), 'Must have only 1 computer');
     $computer->getFromDB(1);
     $this->assertEquals(2, $computer->fields['entities_id'], 'Computer must not be transfered');
     $this->AgentEntity(1, 2, 'Agent must stay with entity 2');
 }
 /**
  * If rule have found computer or rule give to create computer
  *
  * @param $items_id integer id of the computer found (or 0 if must be created)
  * @param $itemtype value Computer type here
  *
  * @return nothing
  *
  **/
 function rulepassed($items_id, $itemtype)
 {
     global $DB, $PLUGIN_FUSIONINVENTORY_XML, $PF_ESXINVENTORY, $CFG_GLPI;
     PluginFusioninventoryToolbox::logIfExtradebug("pluginFusioninventory-rules", "Rule passed : " . $items_id . ", " . $itemtype . "\n");
     $pfFormatconvert = new PluginFusioninventoryFormatconvert();
     $a_computerinventory = $pfFormatconvert->replaceids($this->arrayinventory);
     $entities_id = $_SESSION["plugin_fusioninventory_entity"];
     if ($itemtype == 'Computer') {
         $pfInventoryComputerLib = new PluginFusioninventoryInventoryComputerLib();
         $pfAgent = new PluginFusioninventoryAgent();
         $computer = new Computer();
         if ($items_id == '0') {
             if ($entities_id == -1) {
                 $entities_id = 0;
                 $_SESSION["plugin_fusioninventory_entity"] = 0;
             }
             $_SESSION['glpiactiveentities'] = array($entities_id);
             $_SESSION['glpiactiveentities_string'] = $entities_id;
             $_SESSION['glpiactive_entity'] = $entities_id;
         } else {
             $computer->getFromDB($items_id);
             $a_computerinventory['Computer']['states_id'] = $computer->fields['states_id'];
             $input = array();
             PluginFusioninventoryInventoryComputerInventory::addDefaultStateIfNeeded($input);
             if (isset($input['states_id'])) {
                 $a_computerinventory['Computer']['states_id'] = $input['states_id'];
             }
             if ($entities_id == -1) {
                 $entities_id = $computer->fields['entities_id'];
                 $_SESSION["plugin_fusioninventory_entity"] = $computer->fields['entities_id'];
             }
             $_SESSION['glpiactiveentities'] = array($entities_id);
             $_SESSION['glpiactiveentities_string'] = $entities_id;
             $_SESSION['glpiactive_entity'] = $entities_id;
             if ($computer->fields['entities_id'] != $entities_id) {
                 $pfEntity = new PluginFusioninventoryEntity();
                 $pfInventoryComputerComputer = new PluginFusioninventoryInventoryComputerComputer();
                 $moveentity = FALSE;
                 if ($pfEntity->getValue('transfers_id_auto', $computer->fields['entities_id']) > 0) {
                     if (!$pfInventoryComputerComputer->getLock($items_id)) {
                         $moveentity = TRUE;
                     }
                 }
                 if ($moveentity) {
                     $pfEntity = new PluginFusioninventoryEntity();
                     $transfer = new Transfer();
                     $transfer->getFromDB($pfEntity->getValue('transfers_id_auto', $entities_id));
                     $item_to_transfer = array("Computer" => array($items_id => $items_id));
                     $transfer->moveItems($item_to_transfer, $entities_id, $transfer->fields);
                 } else {
                     $_SESSION["plugin_fusioninventory_entity"] = $computer->fields['entities_id'];
                     $_SESSION['glpiactiveentities'] = array($computer->fields['entities_id']);
                     $_SESSION['glpiactiveentities_string'] = $computer->fields['entities_id'];
                     $_SESSION['glpiactive_entity'] = $computer->fields['entities_id'];
                     $entities_id = $computer->fields['entities_id'];
                 }
             }
         }
         $a_computerinventory = $pfFormatconvert->extraCollectInfo($a_computerinventory, $items_id);
         $a_computerinventory = $pfFormatconvert->computerSoftwareTransformation($a_computerinventory, $entities_id);
         $no_history = FALSE;
         // * New
         $setdynamic = 1;
         if ($items_id == '0') {
             $input = array();
             $input['entities_id'] = $entities_id;
             PluginFusioninventoryInventoryComputerInventory::addDefaultStateIfNeeded($input);
             if (isset($input['states_id'])) {
                 $a_computerinventory['Computer']['states_id'] = $input['states_id'];
             } else {
                 $a_computerinventory['Computer']['states_id'] = 0;
             }
             $items_id = $computer->add($input);
             $no_history = TRUE;
             $setdynamic = 0;
         }
         if (isset($_SESSION['plugin_fusioninventory_locations_id'])) {
             $a_computerinventory['Computer']['locations_id'] = $_SESSION['plugin_fusioninventory_locations_id'];
             unset($_SESSION['plugin_fusioninventory_locations_id']);
         }
         $serialized = gzcompress(serialize($a_computerinventory));
         $a_computerinventory['fusioninventorycomputer']['serialized_inventory'] = Toolbox::addslashes_deep($serialized);
         if (!$PF_ESXINVENTORY) {
             $pfAgent->setAgentWithComputerid($items_id, $this->device_id, $entities_id);
         }
         $pfConfig = new PluginFusioninventoryConfig();
         $query = "INSERT INTO `glpi_plugin_fusioninventory_dblockinventories`\n            SET `value`='" . $items_id . "'";
         $CFG_GLPI["use_log_in_files"] = FALSE;
         if (!$DB->query($query)) {
             $communication = new PluginFusioninventoryCommunication();
             $communication->setMessage("<?xml version='1.0' encoding='UTF-8'?>\n         <REPLY>\n         <ERROR>ERROR: SAME COMPUTER IS CURRENTLY UPDATED</ERROR>\n         </REPLY>");
             $communication->sendMessage($_SESSION['plugin_fusioninventory_compressmode']);
             exit;
         }
         $CFG_GLPI["use_log_in_files"] = TRUE;
         // * For benchs
         //$start = microtime(TRUE);
         PluginFusioninventoryInventoryComputerStat::increment();
         $pfInventoryComputerLib->updateComputer($a_computerinventory, $items_id, $no_history, $setdynamic);
         $query = "DELETE FROM `glpi_plugin_fusioninventory_dblockinventories`\n               WHERE `value`='" . $items_id . "'";
         $DB->query($query);
         $plugin = new Plugin();
         if ($plugin->isActivated('monitoring')) {
             Plugin::doOneHook("monitoring", "ReplayRulesForItem", array('Computer', $items_id));
         }
         // * For benchs
         //Toolbox::logInFile("exetime", (microtime(TRUE) - $start)." (".$items_id.")\n".
         //  memory_get_usage()."\n".
         //  memory_get_usage(TRUE)."\n".
         //  memory_get_peak_usage()."\n".
         //  memory_get_peak_usage()."\n");
         if (isset($_SESSION['plugin_fusioninventory_rules_id'])) {
             $pfRulematchedlog = new PluginFusioninventoryRulematchedlog();
             $inputrulelog = array();
             $inputrulelog['date'] = date('Y-m-d H:i:s');
             $inputrulelog['rules_id'] = $_SESSION['plugin_fusioninventory_rules_id'];
             if (isset($_SESSION['plugin_fusioninventory_agents_id'])) {
                 $inputrulelog['plugin_fusioninventory_agents_id'] = $_SESSION['plugin_fusioninventory_agents_id'];
             }
             $inputrulelog['items_id'] = $items_id;
             $inputrulelog['itemtype'] = $itemtype;
             $inputrulelog['method'] = 'inventory';
             $pfRulematchedlog->add($inputrulelog, array(), FALSE);
             $pfRulematchedlog->cleanOlddata($items_id, $itemtype);
             unset($_SESSION['plugin_fusioninventory_rules_id']);
         }
         // Write XML file
         if (!empty($PLUGIN_FUSIONINVENTORY_XML)) {
             PluginFusioninventoryToolbox::writeXML($items_id, $PLUGIN_FUSIONINVENTORY_XML->asXML(), 'computer');
         }
     } else {
         if ($itemtype == 'PluginFusioninventoryUnmanaged') {
             $a_computerinventory = $pfFormatconvert->computerSoftwareTransformation($a_computerinventory, $entities_id);
             $class = new $itemtype();
             if ($items_id == "0") {
                 if ($entities_id == -1) {
                     $entities_id = 0;
                     $_SESSION["plugin_fusioninventory_entity"] = 0;
                 }
                 $input = array();
                 $input['date_mod'] = date("Y-m-d H:i:s");
                 $items_id = $class->add($input);
                 if (isset($_SESSION['plugin_fusioninventory_rules_id'])) {
                     $pfRulematchedlog = new PluginFusioninventoryRulematchedlog();
                     $inputrulelog = array();
                     $inputrulelog['date'] = date('Y-m-d H:i:s');
                     $inputrulelog['rules_id'] = $_SESSION['plugin_fusioninventory_rules_id'];
                     if (isset($_SESSION['plugin_fusioninventory_agents_id'])) {
                         $inputrulelog['plugin_fusioninventory_agents_id'] = $_SESSION['plugin_fusioninventory_agents_id'];
                     }
                     $inputrulelog['items_id'] = $items_id;
                     $inputrulelog['itemtype'] = $itemtype;
                     $inputrulelog['method'] = 'inventory';
                     $pfRulematchedlog->add($inputrulelog);
                     $pfRulematchedlog->cleanOlddata($items_id, $itemtype);
                     unset($_SESSION['plugin_fusioninventory_rules_id']);
                 }
             }
             $class->getFromDB($items_id);
             $_SESSION["plugin_fusioninventory_entity"] = $class->fields['entities_id'];
             $input = array();
             $input['id'] = $class->fields['id'];
             // Write XML file
             if (!empty($PLUGIN_FUSIONINVENTORY_XML)) {
                 PluginFusioninventoryToolbox::writeXML($items_id, $PLUGIN_FUSIONINVENTORY_XML->asXML(), 'PluginFusioninventoryUnmanaged');
             }
             if (isset($a_computerinventory['Computer']['name'])) {
                 $input['name'] = $a_computerinventory['Computer']['name'];
             }
             $input['item_type'] = "Computer";
             if (isset($a_computerinventory['Computer']['domains_id'])) {
                 $input['domain'] = $a_computerinventory['Computer']['domains_id'];
             }
             if (isset($a_computerinventory['Computer']['serial'])) {
                 $input['serial'] = $a_computerinventory['Computer']['serial'];
             }
             $class->update($input);
         }
     }
 }
 /**
  * @test
  */
 public function getCollectURLRootEntity()
 {
     global $DB;
     $DB->connect();
     $_SESSION['glpiactive_entity'] = 0;
     $_SESSION["plugin_fusioninventory_entity"] = 0;
     $_SESSION["glpiname"] = 'Plugin_FusionInventory';
     $entities_id = 1;
     $agents_id = 1;
     $config = new PluginFusioninventoryConfig();
     $config->loadCache();
     $pfEntity = new PluginFusioninventoryEntity();
     $pfEntity->delete(array('id' => 2));
     // Get answer
     $input = array('action' => 'getConfig', 'task' => array('COLLECT' => '1.0.0'), 'machineid' => 'toto-device');
     $response = PluginFusioninventoryCommunicationRest::communicate($input);
     $this->assertEquals('http://127.0.0.1/glpi085/plugins/fusioninventory/b/collect/', $response['schedule'][0]['remote'], 'Wrong URL');
 }
 /**
  * Display informations about computer (bios...)
  *
  * @param type $computers_id
  */
 static function showInfo($item)
 {
     global $CFG_GLPI;
     // Manage locks pictures
     PluginFusioninventoryLock::showLockIcon('Computer');
     $pfInventoryComputerComputer = new PluginFusioninventoryInventoryComputerComputer();
     $a_computerextend = current($pfInventoryComputerComputer->find("`computers_id`='" . $item->getID() . "'", "", 1));
     if (empty($a_computerextend)) {
         return;
     }
     echo '<table class="tab_glpi" width="100%">';
     echo '<tr>';
     echo '<th colspan="2">' . __('FusionInventory', 'fusioninventory') . '</th>';
     echo '</tr>';
     echo '<tr class="tab_bg_1">';
     echo '<td>';
     echo __('Last inventory', 'fusioninventory');
     echo '</td>';
     echo '<td>';
     echo Html::convDateTime($a_computerextend['last_fusioninventory_update']);
     echo '</td>';
     echo '</tr>';
     if ($a_computerextend['remote_addr'] != '') {
         echo '<tr class="tab_bg_1">';
         echo '<td>' . __('Public contact address', 'fusioninventory') . '</td>';
         echo '<td>' . $a_computerextend['remote_addr'] . '</td>';
         echo '</tr>';
     }
     $pfAgent = new PluginFusioninventoryAgent();
     $pfAgent->showInfoForComputer($item->getID());
     if ($a_computerextend['bios_date'] != '') {
         echo '<tr class="tab_bg_1">';
         echo '<td>' . __('BIOS date', 'fusioninventory') . '</td>';
         echo '<td>' . Html::convDate($a_computerextend['bios_date']) . '</td>';
         echo '</tr>';
     }
     if ($a_computerextend['bios_version'] != '') {
         echo '<tr class="tab_bg_1">';
         echo '<td>' . __('BIOS version', 'fusioninventory') . '</td>';
         echo '<td>' . $a_computerextend['bios_version'] . '</td>';
         echo '</tr>';
     }
     if ($a_computerextend['bios_manufacturers_id'] > 0) {
         echo '<tr class="tab_bg_1">';
         echo '<td>' . __('Manufacturer') . '&nbsp;:</td>';
         echo '<td>';
         echo Dropdown::getDropdownName("glpi_manufacturers", $a_computerextend['bios_manufacturers_id']);
         echo '</td>';
         echo '</tr>';
     }
     if ($a_computerextend['plugin_fusioninventory_computerarchs_id'] != '') {
         echo '<tr class="tab_bg_1">';
         echo "<td>" . __('Architecture', 'fusioninventory') . "</td>";
         echo '<td>';
         echo Dropdown::getDropdownName('glpi_plugin_fusioninventory_computerarchs', $a_computerextend['plugin_fusioninventory_computerarchs_id']);
         echo '</td>';
         echo '</tr>';
     }
     if ($a_computerextend['operatingsystem_installationdate'] != '') {
         echo '<tr class="tab_bg_1">';
         echo "<td>" . __('Operating system') . " - " . __('Installation') . " (" . strtolower(__('Date')) . ")</td>";
         echo '<td>' . Html::convDate($a_computerextend['operatingsystem_installationdate']) . '</td>';
         echo '</tr>';
     }
     if ($a_computerextend['winowner'] != '') {
         echo '<tr class="tab_bg_1">';
         echo '<td>' . __('Owner', 'fusioninventory') . '</td>';
         echo '<td>' . $a_computerextend['winowner'] . '</td>';
         echo '</tr>';
     }
     if ($a_computerextend['wincompany'] != '') {
         echo '<tr class="tab_bg_1">';
         echo '<td>' . __('Company', 'fusioninventory') . '</td>';
         echo '<td>' . $a_computerextend['wincompany'] . '</td>';
         echo '</tr>';
     }
     if ($a_computerextend['oscomment'] != '') {
         echo '<tr class="tab_bg_1">';
         echo "<td>" . __('Comments') . "</td>";
         echo '<td>' . $a_computerextend['oscomment'] . '</td>';
         echo '</tr>';
     }
     // Display automatic entity transfer
     if (Session::isMultiEntitiesMode()) {
         echo '<tr class="tab_bg_1">';
         echo '<td>' . __('Automatic entity transfer', 'fusioninventory') . '</td>';
         echo '<td>';
         $pfEntity = new PluginFusioninventoryEntity();
         if ($pfEntity->getValue('transfers_id_auto', $item->fields['entities_id']) == 0) {
             echo __('No, locked (by entity configuration)', 'fusioninventory');
         } else {
             if ($a_computerextend['is_entitylocked'] == 1) {
                 echo __('No, locked manually', 'fusioninventory');
                 echo " [ <a href='" . $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/front/computerentitylock.form.php?id=" . $a_computerextend['id'] . "&lock=0'>" . __('Unlock it', 'fusioninventory') . "</a> ]";
             } else {
                 echo __('Yes');
                 echo " [ <a href='" . $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/front/computerentitylock.form.php?id=" . $a_computerextend['id'] . "&lock=1'>" . __('Lock it', 'fusioninventory') . "</a> ]";
             }
         }
         echo '</td>';
         echo '</tr>';
     }
     echo '</table>';
 }
 /**
  * Display the menu of FusionInventory
  *
  *@param type value "big" or "mini"
  *
  *@return nothing
  **/
 static function displayMenu($type = "big")
 {
     global $CFG_GLPI;
     if (PLUGIN_FUSIONINVENTORY_OFFICIAL_RELEASE != 1) {
         echo "<center>";
         echo "<a href='http://forge.fusioninventory.org/projects/fusioninventory-for-glpi/" . "wiki/Beta_test'>";
         echo "<img src='" . $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/pics/beta.png'/></a>";
         echo "&nbsp;<a href='https://www.transifex.com/projects/p/FusionInventory/resource/" . "plugin-fusioninventory-084/'>";
         echo "<img src='" . $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/pics/Translate.png'/>" . "</a>";
         echo "<H1>Version '" . PLUGIN_FUSIONINVENTORY_REALVERSION . "'</H1></center><br/>\n";
     }
     $pfEntity = new PluginFusioninventoryEntity();
     if (strlen($pfEntity->getValue('agent_base_url', 0)) < 10 && !strstr($_SERVER['PHP_SELF'], 'front/config.form.php')) {
         echo "<div class='msgboxmonit msgboxmonit-red'>";
         print "<center><a href=\"" . $CFG_GLPI['root_doc'] . "/front/entity.form.php?id=0&forcetab=PluginFusioninventoryEntity\$0\">";
         print __('The server needs to kown the URL the agents use to access the server. Please ' . 'configure it in the General Configuration page.', 'fusioninventory');
         print "</a></center>";
         echo "</div>";
         exit;
     }
     $width_status = 0;
     echo "<div align='center' style='height: 35px; display: inline-block; width: 100%; margin: 0 auto;'>";
     echo "<table width='100%'>";
     echo "<tr>";
     echo "<td align='center'>";
     echo "<table>";
     echo "<tr>";
     echo "<td>";
     /*
      * General
      */
     $a_menu = array();
     if (Session::haveRight('plugin_fusioninventory_agent', READ)) {
         $a_menu[0]['name'] = __('Agents management', 'fusioninventory');
         $a_menu[0]['pic'] = $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/pics/menu_agents.png";
         $a_menu[0]['link'] = Toolbox::getItemTypeSearchURL('PluginFusioninventoryAgent');
     }
     if (Session::haveRight('plugin_fusioninventory_group', READ)) {
         $a_menu[2]['name'] = __('Groups of computers', 'fusioninventory');
         $a_menu[2]['pic'] = $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/pics/menu_group.png";
         $a_menu[2]['link'] = $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/front/deploygroup.php";
     }
     if (Session::haveRight('config', UPDATE) || Session::haveRight('plugin_fusioninventory_configuration', UPDATE)) {
         $a_menu[3]['name'] = __('General configuration', 'fusioninventory');
         $a_menu[3]['pic'] = $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/pics/menu_agents.png";
         $a_menu[3]['link'] = $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/front/config.form.php";
     }
     if (!empty($a_menu)) {
         $width_status = PluginFusioninventoryMenu::htmlMenu(__('General', 'fusioninventory'), $a_menu, $type, $width_status);
     }
     /*
      * Tasks
      */
     $a_menu = array();
     if (Session::haveRight('plugin_fusioninventory_task', READ)) {
         //$a_menu[1]['name'] = __('Task management', 'fusioninventory')." (".__s('Summary').")";
         //$a_menu[1]['pic']  = $CFG_GLPI['root_doc']."/plugins/fusioninventory/pics/menu_task.png";
         //$a_menu[1]['link'] = $CFG_GLPI['root_doc'].
         //                        "/plugins/fusioninventory/front/tasksummary.php";
         $a_menu[2]['name'] = __('Task management', 'fusioninventory');
         $a_menu[2]['pic'] = $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/pics/menu_task.png";
         $a_menu[2]['link'] = Toolbox::getItemTypeSearchURL('PluginFusioninventoryTask');
         $a_menu[3]['name'] = __('Monitoring / Logs', 'fusioninventory');
         $a_menu[3]['pic'] = $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/pics/menu_runningjob.png";
         $a_menu[3]['link'] = Toolbox::getItemTypeSearchURL('PluginFusioninventoryTaskJob');
     }
     if (Session::haveRight('plugin_fusioninventory_importxml', CREATE)) {
         $a_menu[0]['name'] = __('Import agent XML file', 'fusioninventory');
         $a_menu[0]['pic'] = $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/pics/menu_importxml.png";
         $a_menu[0]['link'] = $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/front/inventorycomputerimportxml.php";
     }
     if (Session::haveRight("plugin_fusioninventory_collect", READ)) {
         $a_menu[11]['name'] = __('Additional computer information', 'fusioninventory');
         $a_menu[11]['pic'] = $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/pics/menu_task.png";
         $a_menu[11]['link'] = Toolbox::getItemTypeSearchURL('PluginFusioninventoryCollect');
     }
     if (Session::haveRight('plugin_fusioninventory_task', READ)) {
         $a_menu[12]['name'] = __('Time slot', 'fusioninventory');
         $a_menu[12]['pic'] = $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/pics/menu_timeslot.png";
         $a_menu[12]['link'] = Toolbox::getItemTypeSearchURL('PluginFusioninventoryTimeslot');
     }
     if (!empty($a_menu)) {
         $width_status = PluginFusioninventoryMenu::htmlMenu(__('Tasks', 'fusioninventory'), $a_menu, $type, $width_status);
     }
     /*
      * Rules
      */
     $a_menu = array();
     if (Session::haveRight('plugin_fusioninventory_ruleimport', READ)) {
         $a_menu[1]['name'] = __('Equipment import and link rules', 'fusioninventory');
         $a_menu[1]['pic'] = $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/pics/menu_rules.png";
         $a_menu[1]['link'] = Toolbox::getItemTypeSearchURL('PluginFusioninventoryInventoryRuleImport');
     }
     if (Session::haveRight('plugin_fusioninventory_ignoredimportdevice', READ)) {
         $a_menu[2]['name'] = __('Ignored import devices', 'fusioninventory');
         $a_menu[2]['pic'] = $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/pics/menu_rules.png";
         $a_menu[2]['link'] = Toolbox::getItemTypeSearchURL('PluginFusioninventoryIgnoredimportdevice');
     }
     if (Session::haveRight('plugin_fusioninventory_ruleentity', READ)) {
         $a_menu[3]['name'] = __('Computer entity rules', 'fusioninventory');
         $a_menu[3]['pic'] = $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/pics/menu_rules.png";
         $a_menu[3]['link'] = $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/front/inventoryruleentity.php";
     }
     if (Session::haveRight('plugin_fusioninventory_rulelocation', READ)) {
         $a_menu[4]['name'] = __('Computer location rules', 'fusioninventory');
         $a_menu[4]['pic'] = $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/pics/menu_rules.png";
         $a_menu[4]['link'] = $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/front/inventoryrulelocation.php";
     }
     if (Session::haveRight("plugin_fusioninventory_rulecollect", READ)) {
         $a_menu[5]['name'] = __('Additional computer information rules', 'fusioninventory');
         $a_menu[5]['pic'] = $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/pics/menu_rules.png";
         $a_menu[5]['link'] = $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/front/collectrule.php";
     }
     if (Session::haveRight("plugin_fusioninventory_rulecollect", READ)) {
         $a_menu[6]['name'] = __('Dictionnary of computer architectures', 'fusioninventory');
         $a_menu[6]['pic'] = $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/pics/menu_rules.png";
         $a_menu[6]['link'] = $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/front/ruledictionnarycomputerarch.php";
     }
     if (Session::haveRight('plugin_fusioninventory_blacklist', READ)) {
         $a_menu[7]['name'] = _n('Blacklist', 'Blacklists', 1);
         $a_menu[7]['pic'] = $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/pics/menu_blacklist.png";
         $a_menu[7]['link'] = $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/front/inventorycomputerblacklist.php";
     }
     if (!empty($a_menu)) {
         $width_status = PluginFusioninventoryMenu::htmlMenu(__('Rules', 'fusioninventory'), $a_menu, $type, $width_status);
     }
     /*
      * Network
      */
     $a_menu = array();
     if (Session::haveRight('plugin_fusioninventory_iprange', READ)) {
         $a_menu[] = array('name' => __('IP Ranges', 'fusioninventory'), 'pic' => $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/pics/menu_rangeip.png", 'link' => Toolbox::getItemTypeSearchURL('PluginFusioninventoryIPRange'));
     }
     if (Session::haveRight('plugin_fusioninventory_credentialip', READ)) {
         $a_menu[] = array('name' => __('Remote devices to inventory (VMware)', 'fusioninventory'), 'pic' => $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/pics/menu_credentialips.png", 'link' => Toolbox::getItemTypeSearchURL('PluginFusioninventoryCredentialip'));
     }
     if (Session::haveRight('plugin_fusioninventory_configsecurity', READ)) {
         $a_menu[] = array('name' => __('SNMP authentication', 'fusioninventory'), 'pic' => $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/pics/menu_authentification.png", 'link' => $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/front/configsecurity.php");
     }
     if (Session::haveRight('plugin_fusioninventory_credential', READ)) {
         $a_menu[] = array('name' => __('Authentication for remote devices (VMware)', 'fusioninventory'), 'pic' => $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/pics/menu_authentification.png", 'link' => Toolbox::getItemTypeSearchURL('PluginFusioninventoryCredential'));
     }
     if (Session::haveRight('plugin_fusioninventory_task', READ)) {
         $a_menu[] = array('name' => __('Discovery status', 'fusioninventory'), 'pic' => $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/pics/menu_discovery_status.png", 'link' => $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/front/statediscovery.php");
         $a_menu[] = array('name' => __('Network inventory status', 'fusioninventory'), 'pic' => $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/pics/menu_inventory_status.png", 'link' => $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/front/stateinventory.php");
     }
     if (Session::haveRight('plugin_fusioninventory_model', READ)) {
         $a_menu[] = array('name' => __('SNMP models creation', 'fusioninventory'), 'pic' => $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/pics/menu_constructmodel.png", 'link' => $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/front/constructmodel.php");
     }
     if (!empty($a_menu)) {
         $width_status = PluginFusioninventoryMenu::htmlMenu(__('Networking', 'fusioninventory'), $a_menu, $type, $width_status);
     }
     /*
      * Deploy
      */
     $a_menu = array();
     if (Session::haveRight('plugin_fusioninventory_package', READ)) {
         $a_menu[] = array('name' => __('Package management', 'fusioninventory'), 'pic' => $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/pics/menu_package.png", 'link' => $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/front/deploypackage.php");
     }
     if (Session::haveRight('plugin_fusioninventory_deploymirror', READ)) {
         $a_menu[1]['name'] = __('Mirror servers', 'fusioninventory');
         $a_menu[1]['pic'] = $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/pics/menu_files.png";
         $a_menu[1]['link'] = $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/front/deploymirror.php";
     }
     if (!empty($a_menu)) {
         $width_status = PluginFusioninventoryMenu::htmlMenu(__('Deploy', 'fusioninventory'), $a_menu, $type, $width_status);
     }
     /*
      * Guide
      */
     $a_menu = array();
     $a_menu[] = array('name' => "FI> " . __('Computer inv.', 'fusioninventory'), 'pic' => "", 'link' => $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/front/menu_inventory.php");
     $a_menu[] = array('name' => "FI> " . __('SNMP inv.', 'fusioninventory'), 'pic' => "", 'link' => $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/front/menu_snmpinventory.php");
     if (!empty($a_menu)) {
         $width_status = PluginFusioninventoryMenu::htmlMenu(__('Guide', 'fusioninventory'), $a_menu, $type, $width_status);
     }
     echo "</td>";
     echo "</tr>";
     echo "</table>";
     echo "</td>";
     echo "</tr>";
     echo "</table>";
     echo "</div><br/><br/><br/>";
 }