function defineTabs($ID, $withtemplate)
 {
     global $LANG, $CFG_GLPI;
     $ptcm = new PluginFusioninventoryConfigModules();
     $ong = array();
     if ($ID > 0) {
         $ong[1] = $LANG['plugin_fusioninventory']["agents"][9];
         if ($ptcm->isActivated('remotehttpagent') and PluginFusioninventory::haveRight("remotecontrol", "w")) {
             $ong[2] = $LANG['plugin_fusioninventory']["task"][2];
         }
     }
     return $ong;
 }
Exemplo n.º 2
0
 function RemoteStateAgent($target, $ID, $type, $a_modules = array())
 {
     global $LANG, $CFG_GLPI;
     $ptcm = new PluginFusioninventoryConfigModules();
     $pfia = new PluginFusioninventoryAgents();
     if (!$ptcm->isActivated('remotehttpagent') and !PluginFusioninventory::haveRight("remotecontrol", "w")) {
         return;
     }
     if ($type == PLUGIN_FUSIONINVENTORY_SNMP_AGENTS) {
         $pfia->getFromDB($ID);
         $on_device = $ID;
     } else {
         if ($type == COMPUTER_TYPE) {
             $agentlist = $pfia->find("on_device='" . $ID . "'", "", "1");
             foreach ($agentlist as $data) {
                 $pfia->getFromDB($data['ID']);
                 $on_device = $pfia->fields['on_device'];
             }
         } else {
             if ($type == NETWORKING_TYPE or $type == PRINTER_TYPE) {
                 $on_device = $ID;
             }
         }
     }
     echo "<div align='center'><form method='post' name='' id=''  action=\"" . GLPI_ROOT . "/plugins/fusioninventory/front/agents.state.php\">";
     echo "<table  class='tab_cadre_fixe'>";
     echo "<tr>";
     echo "<th colspan='2'>";
     echo $LANG['plugin_fusioninventory']["agents"][14];
     echo " : </th>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td colspan='2' align='center'>";
     $array_actions = array();
     $array_actions[""] = "------";
     switch ($type) {
         case NETWORKING_TYPE:
         case PRINTER_TYPE:
             if (isset($a_modules["INVENTORY"]) and $ptcm->getValue("snmp") == '1') {
                 $array_actions["INVENTORY"] = $LANG['plugin_fusioninventory']['config'][3];
             }
             break;
         case PLUGIN_FUSIONINVENTORY_SNMP_AGENTS:
         case COMPUTER_TYPE:
             if (isset($a_modules["INVENTORY"]) and $ptcm->getValue("inventoryocs") == '1' and isset($pfia->fields['module_inventory']) and $pfia->fields['module_inventory'] == '1' or isset($a_modules["INVENTORY"]) and $ptcm->getValue("snmp") == '1' and isset($pfia->fields['module_snmpquery']) and $pfia->fields['module_snmpquery'] == '1') {
                 $array_actions["INVENTORY"] = $LANG['plugin_fusioninventory']['config'][3];
             }
             if (isset($a_modules["WAKEONLAN"]) and $ptcm->getValue("wol") == '1') {
                 // Code for PLUGIN_FUSIONINVENTORY_SNMP_AGENTS if  ($pfia->fields['module_wakeonlan'] == '1')
                 // so :
                 if ($type == COMPUTER_TYPE) {
                     $array_actions["WAKEONLAN"] = $LANG['plugin_fusioninventory']['config'][6];
                 }
             }
             break;
     }
     //      if ((isset($a_modules["NETDISCOVERY"])) AND ($ptcm->getValue("netdiscovery") == '1') AND ($pfia->fields['module_netdiscovery'] == '1')) {
     //         $array_actions["NETDISCOVERY"] = $LANG['plugin_fusioninventory']['config'][4];
     //      }
     //      if ((isset($a_modules["SNMPQUERY"])) AND ($ptcm->getValue("snmp") == '1') AND ($pfia->fields['module_snmpquery'] == '1')) {
     //         $array_actions["SNMPQUERY"] = $LANG['plugin_fusioninventory']['config'][7];
     //      }
     $rand = Dropdown::showFromArray("agentaction", $array_actions);
     echo "</td>";
     echo "</tr>";
     if (!isset($on_device)) {
         $on_device = $ID;
     }
     $params = array('action' => '__VALUE__', 'on_device' => $on_device, 'device_type' => $type);
     ajaxUpdateItemOnSelectEvent("dropdown_agentaction{$rand}", "updateAgentState_{$rand}", $CFG_GLPI["root_doc"] . "/plugins/fusioninventory/ajax/agentsState.php", $params, false);
     echo "<tr class='tab_bg_1'>";
     echo "<td colspan='2' align='center'>";
     echo "<span id='updateAgentState_{$rand}'>\n";
     echo "&nbsp;";
     echo "</span>\n";
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td align='center'>";
     echo "<input type='hidden' name='on_device' value='" . $ID . "'/>";
     echo "<input type='hidden' name='device_type' value='" . $type . "'/>";
     echo "<input type='submit' name='startagent' value=\"" . $LANG['plugin_fusioninventory']["task"][12] . "\" class='submit' >";
     echo "</td>";
     echo "</tr>";
     echo "</table>";
     echo "</form>";
     echo "</div>";
 }
 //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);
                 $input['ID'] = $task_id;
                 $ptt->delete($input);
             }
             if ($a_tasks[$task_id]['action'] == 'SNMPQUERY' and $ptcm->isActivated('snmp') and $a_agent['module_snmpquery'] == '1') {
                 $single = 1;
                 $ptc->addQuery($pxml, 1);
Exemplo n.º 4
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;
}