function defineTabs($ID, $withtemplate)
 {
     global $LANG, $CFG_GLPI;
     $ptcm = new PluginFusioninventoryConfigModules();
     $ong = array();
     if ($ID > 0) {
         $ong[1] = $LANG['title'][27];
         if ($ptcm->isActivated('remotehttpagent') and PluginFusioninventory::haveRight("remotecontrol", "w")) {
             $ong[2] = $LANG['plugin_fusioninventory']["task"][2];
         }
         $ong[3] = $LANG['title'][38];
     }
     return $ong;
 }
 function dropdownNetworkPrinterSNMP($agent_id)
 {
     // Dropdown with printer and network devices who have model and auth
     global $DB, $LANG;
     $ptcm = new PluginFusioninventoryConfigModules();
     $pfia = new PluginFusioninventoryAgents();
     $dropdownOptions = "";
     $pfia->getFromDB($agent_id);
     if ($ptcm->getValue("snmp") == '1' and $pfia->fields['module_snmpquery'] == '1') {
         // Networking
         $dropdownOptions = "<optgroup label=\"" . $LANG['help'][26] . "\">";
         $query = "SELECT `glpi_networking`.`ID` AS `gID`,\n                           `glpi_networking`.`name` AS `name`, `serial`, `otherserial`,\n                                `FK_snmp_connection`, `FK_model_infos`\n                         FROM `glpi_networking`\n                         LEFT JOIN `glpi_plugin_fusioninventory_networking`\n                              ON `FK_networking`=`glpi_networking`.`ID`\n                         INNER join `glpi_plugin_fusioninventory_model_infos`\n                              ON `FK_model_infos`=`glpi_plugin_fusioninventory_model_infos`.`ID`\n                         WHERE `glpi_networking`.`deleted`='0'\n                              AND `FK_model_infos`!='0'\n                              AND `FK_snmp_connection`!='0'\n                         GROUP BY FK_networking";
         $result = $DB->query($query);
         while ($data = $DB->fetch_array($result)) {
             $dropdownOptions .= "<option value='" . NETWORKING_TYPE . "-" . $data['gID'] . "'>" . $data['name'] . " - " . $data['serial'] . " - " . $data['otherserial'] . "</option>";
         }
         $dropdownOptions .= "</optgroup>";
         // Printers
         $dropdownOptions .= "<optgroup label=\"" . $LANG['help'][27] . "\">";
         $query = "SELECT `glpi_printers`.`ID` AS `gID`,\n                           `glpi_printers`.`name` AS `name`, `serial`, `otherserial`,\n                                `FK_snmp_connection`, `FK_model_infos`\n                         FROM `glpi_printers`\n                         LEFT JOIN `glpi_plugin_fusioninventory_printers`\n                              ON `FK_printers`=`glpi_printers`.`ID`\n                         LEFT JOIN `glpi_networking_ports`\n                                 ON `on_device`=`glpi_printers`.`ID`\n                                    AND `device_type`='" . PRINTER_TYPE . "'\n                         INNER join `glpi_plugin_fusioninventory_model_infos`\n                              ON `FK_model_infos`=`glpi_plugin_fusioninventory_model_infos`.`ID`\n                         WHERE `glpi_printers`.`deleted`='0'\n                              AND `FK_model_infos`!='0'\n                              AND `FK_snmp_connection`!='0'\n                         GROUP BY FK_printers";
         $result = $DB->query($query);
         while ($data = $DB->fetch_array($result)) {
             $dropdownOptions .= "<option value='" . NETWORKING_TYPE . "-" . $data['gID'] . "'>" . $data['name'] . " - " . $data['serial'] . " - " . $data['otherserial'] . "</option>";
         }
         $dropdownOptions .= "</optgroup>";
     }
     return $dropdownOptions;
 }
 function showForm($target, $ID = '')
 {
     global $DB, $CFG_GLPI, $LANG;
     if ($ID != '') {
         $this->getFromDB($ID);
     } else {
         $this->getEmpty();
     }
     $CommonItem = new CommonItem();
     $ptcm = new PluginFusioninventoryConfigModules();
     echo "<div align='center'><form method='post' name='' id=''  action=\"" . $target . "\">";
     echo "<table class='tab_cadre' cellpadding='5' width='950'>";
     echo "<tr>";
     echo "<th colspan='4'>";
     echo $LANG['plugin_fusioninventory']["agents"][0];
     echo " :</th>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG["common"][16] . " :</td>";
     echo "<td align='center'>";
     echo "<input type='text' name='name' size='40' value='" . $this->fields["name"] . "'/>";
     echo "</td>";
     if ($ptcm->getValue('inventoryocs') == "1") {
         echo "<td>" . $LANG['plugin_fusioninventory']['config'][3] . " :</td>";
         echo "<td align='center'>";
         Dropdown::showYesNo("module_inventory", $this->fields["module_inventory"]);
         echo "</td>";
     } else {
         echo "<td colspan='2'></td>";
     }
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['plugin_fusioninventory']["agents"][5] . " :</td>";
     echo "<td align='center'>";
     echo $this->fields["fusioninventory_agent_version"];
     echo "</td>";
     if ($ptcm->getValue('netdiscovery') == "1") {
         echo "<td>" . $LANG['plugin_fusioninventory']['config'][4] . " :</td>";
         echo "<td align='center'>";
         Dropdown::showYesNo("module_netdiscovery", $this->fields["module_netdiscovery"]);
         echo "</td>";
     } else {
         echo "<td colspan='2'></td>";
     }
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['plugin_fusioninventory']["agents"][6] . " :</td>";
     echo "<td align='center'>";
     Dropdown::showYesNo("lock", $this->fields["lock"]);
     echo "</td>";
     if ($ptcm->getValue('snmp') == "1") {
         echo "<td>" . $LANG['plugin_fusioninventory']['config'][7] . " :</td>";
         echo "<td align='center'>";
         Dropdown::showYesNo("module_snmpquery", $this->fields["module_snmpquery"]);
         echo "</td>";
     } else {
         echo "<td colspan='2'></td>";
     }
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['plugin_fusioninventory']["agents"][23] . " :</td>";
     echo "<td align='center'>";
     if ($this->fields["on_device"] != "0" and $this->fields["on_device"] != "") {
         $CommonItem->getFromDB(COMPUTER_TYPE, $this->fields["on_device"]);
         echo $CommonItem->getLink(1);
         echo "<input type='hidden' name='on_device' value='" . $this->fields["on_device"] . "'/>";
     } else {
         Computer_Item::dropdownConnect(COMPUTER_TYPE, COMPUTER_TYPE, 'on_device', $_SESSION['glpiactive_entity']);
     }
     echo "</td>";
     if ($ptcm->getValue('wol') == "1") {
         echo "<td>" . $LANG['plugin_fusioninventory']['config'][6] . " :</td>";
         echo "<td align='center'>";
         Dropdown::showYesNo("module_wakeonlan", $this->fields["module_wakeonlan"]);
         echo "</td>";
     } else {
         echo "<td colspan='2'></td>";
     }
     echo "<tr class='tab_bg_1'>";
     echo "<td>Token :</td>";
     echo "<td align='center' colspan='3'>";
     echo $this->fields["token"];
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_2'>";
     if (PluginFusioninventory::haveRight("agents", "w")) {
         if ($ID == '') {
             echo "<td align='center' colspan='4'>";
             echo "<div align='center'><input type='submit' name='add' value=\"" . $LANG["buttons"][8] . "\" class='submit' >";
             echo "</td>";
         } else {
             echo "<td align='center' colspan='2'>";
             echo "<input type='hidden' name='ID' value='" . $ID . "'/>";
             echo "<div align='center'><input type='submit' name='update' value=\"" . $LANG["buttons"][7] . "\" class='submit' >";
             echo "</td>";
             echo "<td align='center' colspan='2'>";
             echo "<input type='submit' name='delete' value=\"" . $LANG["buttons"][6] . "\" class='submit'>";
             echo "</td>";
         }
     }
     echo "</tr>";
     echo "</table></form></div>";
 }
if ($state == '2') {
    // agent created
    $ocsinventory = '1';
}
$top0 = gettimeofday();
if (!$ptc->import(gzuncompress($GLOBALS["HTTP_RAW_POST_DATA"]))) {
    //if ($ac->connectionOK($errors)) {
    if (1) {
        $res .= "1'" . $errors . "'";
        $p_xml = gzuncompress($GLOBALS["HTTP_RAW_POST_DATA"]);
        $pxml = @simplexml_load_string($p_xml);
        if (isset($pxml->DEVICEID)) {
            $ptc->setXML("<?xml version='1.0' encoding='ISO-8859-1'?>\n<REPLY>\n</REPLY>");
            $pta = new PluginFusioninventoryAgents();
            $ptt = new PluginFusioninventoryTask();
            $ptcm = new PluginFusioninventoryConfigModules();
            $a_agent = $pta->InfosByKey($pxml->DEVICEID);
            $a_tasks = $ptt->find("`agent_id`='" . $a_agent['ID'] . "'", "date");
            $single = 0;
            $_SESSION['glpi_plugin_fusioninventory_addagentprocess'] = '0';
            foreach ($a_tasks as $task_id => $datas) {
                if ($a_tasks[$task_id]['action'] == 'INVENTORY' and $ptcm->isActivated('inventoryocs') and $a_agent['module_inventory'] == '1') {
                    $ptc->addInventory();
                    $input['ID'] = $task_id;
                    $ptt->delete($input);
                    $ocsinventory = '0';
                    $single = 1;
                }
                if ($a_tasks[$task_id]['action'] == 'NETDISCOVERY' and $ptcm->isActivated('netdiscovery') and $a_agent['module_netdiscovery'] == '1') {
                    $single = 1;
                    $ptc->addDiscovery($pxml, 1);
// ----------------------------------------------------------------------
define('GLPI_ROOT', '../../..');
include GLPI_ROOT . "/inc/includes.php";
checkRight("config", "w");
commonHeader($LANG['plugin_fusioninventory']["functionalities"][0], $_SERVER["PHP_SELF"], "plugins", "fusioninventory", "summary");
if (isset($_POST['update'])) {
    if (empty($_POST['cleaning_days'])) {
        $_POST['cleaning_days'] = 0;
    }
    $_POST['ID'] = 1;
    switch ($_POST['tabs']) {
        case 'config':
            $config1 = new PluginFusioninventoryConfig();
            break;
        case 'configmodules':
            $config1 = new PluginFusioninventoryConfigModules();
            break;
        case 'history':
            $pficsnmph = new PluginFusioninventoryConfigSNMPHistory();
            foreach ($_POST as $key => $val) {
                if (is_int($key)) {
                    $input = array();
                    $input['ID'] = $key;
                    $input['days'] = $val;
                    $pficsnmph->update($input);
                }
            }
            break;
    }
    if (isset($config1)) {
        $config1->update($_POST);
}
checkRight("config", "w");
if (PluginFusioninventory::haveRight("configuration", "r")) {
    switch ($_POST['glpi_tab']) {
        case -1:
            $config = new PluginFusioninventoryConfig();
            $config->showForm($_POST['target'], '1');
            $config_modules = new PluginFusioninventoryConfigModules();
            $config_modules->showForm($_POST['target'], '1');
            $history = new PluginFusioninventorySnmphistory();
            $history->showForm($_POST['target'], '1');
            $ptLockable = new PluginFusioninventoryLockable();
            $ptLockable->showForm($_POST['target']);
            break;
        case 2:
            $config_modules = new PluginFusioninventoryConfigModules();
            $config_modules->showForm($_POST['target'], '1');
            break;
        case 7:
            // Historique
            $history = new PluginFusioninventoryConfigSNMPHistory();
            $history->showForm($_POST['target']);
            break;
        case 8:
            // lockables
            $ptLockable = new PluginFusioninventoryLockable();
            $ptLockable->showForm($_POST['target']);
            break;
        default:
            if (!displayPluginAction(COMPUTER_TYPE, $_POST["ID"], $_POST['glpi_tab'], $_POST["withtemplate"])) {
                $config = new PluginFusioninventoryConfig();
Example #7
0
function plugin_headings_actions_fusioninventory($type)
{
    $configModules = new PluginFusioninventoryConfigModules();
    switch ($type) {
        case COMPUTER_TYPE:
            $array = array();
            if ($configModules->isActivated('remotehttpagent') and PluginFusioninventory::haveRight("remotecontrol", "w")) {
                $array[1] = "plugin_headings_fusioninventory_computerInfo";
            }
            $array[2] = "plugin_headings_fusioninventory_fusioninventoryLocks";
            return $array;
            break;
        case MONITOR_TYPE:
            $array = array();
            $array = array(1 => "plugin_headings_fusioninventory_fusioninventoryLocks");
        case PRINTER_TYPE:
            $array = array();
            if (PluginFusioninventory::haveRight("snmp_printers", "r")) {
                $array[1] = "plugin_headings_fusioninventory_printerInfo";
            }
            $array[2] = "plugin_headings_fusioninventory_fusioninventoryLocks";
            return $array;
            break;
        case NETWORKING_TYPE:
            if (PluginFusioninventory::haveRight("snmp_networking", "r")) {
                $array[1] = "plugin_headings_fusioninventory_networkingInfo";
            }
            $array[2] = "plugin_headings_fusioninventory_fusioninventoryLocks";
            return $array;
            break;
        case PROFILE_TYPE:
            return array(1 => "plugin_headings_fusioninventory");
            break;
    }
    return false;
}