예제 #1
0
 }
 $comp = new Computer();
 $result = $DBread->query($Sql);
 for ($prev = -1, $i = 0; $data = $DBread->fetch_array($result); $i++) {
     if ($prev != $data["entity"]) {
         $prev = $data["entity"];
         echo "<tr class='tab_bg_4'><td class='center' colspan='{$colspan}'>" . Dropdown::getDropdownName("glpi_entities", $prev) . "</td></tr>\n";
     }
     echo "<tr class='tab_bg_2'>";
     if ($canedit) {
         echo "<td><input type='checkbox' name='item[" . $data["AID"] . "]' value='1'></td>";
     }
     echo "<td class='b'>" . $data["AID"] . "</td>";
     if ($comp->getFromDB($data["AID"])) {
         echo "<td>";
         echo $comp->getLink(true);
         echo "</td><td>";
         echo Dropdown::getDropdownName("glpi_manufacturers", $comp->getField('manufacturers_id'));
         echo "</td><td>";
         echo Dropdown::getDropdownName("glpi_computermodels", $comp->getField('computermodels_id'));
         echo "</td><td>" . $comp->getField('serial');
         echo "</td><td>" . $comp->getField('otherserial') . "</td>";
     } else {
         echo "<td colspan='5'>" . $data["Aname"] . "</td>";
     }
     if ($col) {
         echo "<td>" . $data["Aaddr"] . "</td>";
     }
     echo "<td>" . getLastOcsUpdate($data['AID']) . "</td>";
     if ($canedit) {
         echo "<td><input type='checkbox' name='item[" . $data["BID"] . "]' value='1'></td>";
 function showForCollectWmi($collects_wmis_id)
 {
     $pfCollect_Wmi = new PluginFusioninventoryCollect_Wmi();
     $computer = new Computer();
     $pfCollect_Wmi->getFromDB($collects_wmis_id);
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr>";
     echo "<th colspan='3'>";
     echo $pfCollect_Wmi->fields['class'];
     echo "</th>";
     echo "</tr>";
     echo "<tr>";
     echo "<th>" . __('Computer') . "</th>";
     echo "<th>" . __('Property', 'fusioninventory') . "</th>";
     echo "<th>" . __('Value', 'fusioninventory') . "</th>";
     echo "</tr>";
     $a_data = $this->find("`plugin_fusioninventory_collects_wmis_id`='" . $collects_wmis_id . "'", "`property`");
     foreach ($a_data as $data) {
         echo "<tr class='tab_bg_1'>";
         echo '<td>';
         $computer->getFromDB($data['computers_id']);
         echo $computer->getLink(1);
         echo '</td>';
         echo '<td>';
         echo $data['property'];
         echo '</td>';
         echo '<td>';
         echo $data['value'];
         echo '</td>';
         echo "</tr>";
     }
     echo '</table>';
 }
예제 #3
0
 /**
  * Display form for antivirus
  *
  * @param $ID                id of the antivirus
  * @param $options array
  *
  * @return bool TRUE if form is ok
  **/
 function showForm($ID, $options = array())
 {
     global $CFG_GLPI;
     if (!Session::haveRight("computer", UPDATE)) {
         return false;
     }
     $comp = new Computer();
     if ($ID > 0) {
         $this->check($ID, READ);
         $comp->getFromDB($this->fields['computers_id']);
     } else {
         $this->check(-1, CREATE, $options);
         $comp->getFromDB($options['computers_id']);
     }
     $this->showFormHeader($options);
     if ($this->isNewID($ID)) {
         echo "<input type='hidden' name='computers_id' value='" . $options['computers_id'] . "'>";
     }
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Computer') . "</td>";
     echo "<td>" . $comp->getLink() . "</td>";
     if (Plugin::haveImport()) {
         echo "<td>" . __('Automatic inventory') . "</td>";
         echo "<td>";
         if ($ID && $this->fields['is_dynamic']) {
             Plugin::doHook("autoinventory_information", $this);
         } else {
             _e('No');
         }
         echo "</td>";
     } else {
         echo "<td colspan='2'></td>";
     }
     echo "</tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Name') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, "name");
     echo "</td>";
     echo "<td>" . __('Active') . "</td>";
     echo "<td>";
     Dropdown::showYesNo('is_active', $this->fields['is_active']);
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Manufacturer') . "</td>";
     echo "<td>";
     Dropdown::show('Manufacturer', array('value' => $this->fields["manufacturers_id"]));
     echo "</td>";
     echo "<td>" . __('Up to date') . "</td>";
     echo "<td>";
     Dropdown::showYesNo('is_uptodate', $this->fields['is_uptodate']);
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Antivirus version') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, "antivirus_version");
     echo "</td>";
     echo "<td>" . __('Signature database version') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, "signature_version");
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Expiration date') . "</td>";
     echo "<td>";
     Html::showDateField("date_expiration", array('value' => $this->fields['date_expiration']));
     echo "</td>";
     echo "<td colspan='2'></td>";
     echo "</tr>";
     $this->showFormButtons($options);
     return true;
 }
 /**
  * Print the version form
  *
  * @param $ID integer ID of the item
  * @param $options array
  *     - target for the Form
  *     - computers_id ID of the computer for add process
  *
  * @return true if displayed  false if item not found or not right to display
  **/
 function showForm($ID, $options = array())
 {
     global $CFG_GLPI, $LANG;
     $computers_id = -1;
     if (isset($options['computers_id'])) {
         $computers_id = $options['computers_id'];
     }
     if (!haveRight("computer", "w")) {
         return false;
     }
     $comp = new Computer();
     if ($ID > 0) {
         $this->check($ID, 'r');
         $comp->getFromDB($this->fields['computers_id']);
     } else {
         $comp->getFromDB($computers_id);
         // Create item
         $input = array('entities_id' => $comp->getEntityID());
         $this->check(-1, 'w', $input);
     }
     $this->showTabs($options);
     $this->showFormHeader($options);
     if ($ID > 0) {
         $computers_id = $this->fields["computers_id"];
     } else {
         echo "<input type='hidden' name='computers_id' value='{$computers_id}'>";
     }
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['help'][25] . "&nbsp;:</td>";
     echo "<td colspan='3'>" . $comp->getLink() . "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['common'][16] . "&nbsp;:</td>";
     echo "<td>";
     autocompletionTextField($this, "name");
     echo "</td><td>" . $LANG['computers'][62] . "&nbsp;:</td>";
     echo "<td>";
     Dropdown::show('VirtualMachineType', array('value' => $this->fields['virtualmachinetypes_id']));
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['computers'][60] . "&nbsp;:</td>";
     echo "<td>";
     Dropdown::show('VirtualMachineSystem', array('value' => $this->fields['virtualmachinesystems_id']));
     echo "</td><td>" . $LANG['computers'][63] . "&nbsp;:</td>";
     echo "<td>";
     Dropdown::show('VirtualMachineState', array('value' => $this->fields['virtualmachinestates_id']));
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['computers'][58] . "&nbsp;:</td>";
     echo "<td>";
     autocompletionTextField($this, "uuid");
     echo "</td>";
     echo "<td>" . $LANG['computers'][61] . "&nbsp;:</td>";
     echo "<td>";
     autocompletionTextField($this, "vcpu");
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['computers'][24] . "&nbsp;:</td>";
     echo "<td>";
     autocompletionTextField($this, "ram");
     echo "</td>";
     echo "<td>" . $LANG['computers'][64] . "&nbsp;:</td>";
     echo "<td>";
     if ($link_computer = self::findVirtualMachine($this->fields)) {
         $computer = new Computer();
         if ($computer->can($link_computer, 'r')) {
             $url = "<a href='computer.form.php?id=" . $link_computer . "'>";
             $url .= $computer->fields["name"] . "</a>";
             $tooltip = $LANG['common'][16] . "&nbsp;: " . $computer->fields['name'];
             $tooltip .= "<br>" . $LANG['common'][19] . "&nbsp;: ";
             $tooltip .= "<br>" . $computer->fields['serial'];
             $tooltip .= "<br>" . $computer->fields['comment'];
             $url .= "&nbsp; " . showToolTip($tooltip, array('display' => false));
         } else {
             $url = $this->fields['name'];
         }
         echo $url;
     }
     echo "</td>";
     echo "</tr>";
     $this->showFormButtons($options);
     $this->addDivForTabs();
     return true;
 }
예제 #5
0
파일: hook.php 프로젝트: geldarr/hack-space
/**
 *
 * Preview for test a Rule
 * @since 0.84
 * @param $params           input data
 * @return $output array
 */
function plugin_ocsinventoryng_preProcessRulePreviewResults($params)
{
    $output = $params['output'];
    switch ($params['params']['rule_itemtype']) {
        case 'RuleImportComputer':
            //If ticket is assign to an object, display this information first
            if (isset($output["action"])) {
                echo "<tr class='tab_bg_2'>";
                echo "<td>" . __('Action type') . "</td>";
                echo "<td>";
                switch ($output["action"]) {
                    case PluginOcsinventoryngOcsServer::LINK_RESULT_LINK:
                        _e('Link possible');
                        break;
                    case PluginOcsinventoryngOcsServer::LINK_RESULT_NO_IMPORT:
                        _e('Import refused');
                        break;
                    case PluginOcsinventoryngOcsServer::LINK_RESULT_IMPORT:
                        _e('New computer created in GLPI');
                        break;
                }
                echo "</td>";
                echo "</tr>";
                if ($output["action"] != PluginOcsinventoryngOcsServer::LINK_RESULT_NO_IMPORT && isset($output["found_computers"])) {
                    echo "<tr class='tab_bg_2'>";
                    $item = new Computer();
                    if ($item->getFromDB($output["found_computers"][0])) {
                        echo "<td>" . __('Link with computer') . "</td>";
                        echo "<td>" . $item->getLink(array('comments' => true)) . "</td>";
                    }
                    echo "</tr>";
                }
            }
            break;
    }
    return $output;
}
    $state_sql = " AND `states_id` = '" . $state . "' ";
}
$query = "SELECT `last_fusioninventory_update`, `computers_id`\n      FROM `glpi_plugin_fusioninventory_inventorycomputercomputers`\n   LEFT JOIN `glpi_computers` ON `computers_id`=`glpi_computers`.`id`\nWHERE ((NOW() > ADDDATE(last_fusioninventory_update, INTERVAL " . $nbdays . " DAY)\n      OR last_fusioninventory_update IS NULL)\n   " . $state_sql . ")" . getEntitiesRestrictRequest("AND", "glpi_computers") . "\n\nORDER BY last_fusioninventory_update DESC";
$result = $DB->query($query);
echo "<table class='tab_cadre_fixe' cellpadding='5' width='950'>";
echo "<tr class='tab_bg_1'>";
echo "<th colspan='5'>" . __('Number of items') . " : " . $DB->numrows($result) . "</th>";
echo "</tr>";
echo "<tr class='tab_bg_1'>";
echo "<th>" . __('Name') . "</th>";
echo "<th>" . __('Last inventory') . "</th>";
echo "<th>" . __('Serial Number') . "</th>";
echo "<th>" . __('Inventory number') . "</th>";
echo "<th>" . __('Status') . "</th>";
echo "</tr>";
while ($data = $DB->fetch_array($result)) {
    echo "<tr class='tab_bg_1'>";
    echo "<td>";
    $computer->getFromDB($data['computers_id']);
    echo $computer->getLink(1);
    echo "</td>";
    echo "<td>" . Html::convDateTime($data['last_fusioninventory_update']) . "</td>";
    echo "<td>" . $computer->fields['serial'] . "</td>";
    echo "<td>" . $computer->fields['otherserial'] . "</td>";
    echo "<td>";
    echo Dropdown::getDropdownName(getTableForItemType("State"), $computer->fields['states_id']);
    echo "</td>";
    echo "</tr>";
}
echo "</table>";
Html::footer();
 /**
  * Display detail networkport based on glpi core networkport and fusioninventory
  * networkport
  *
  * @param array $data with id ant fusionid
  * @param boolean $monitoring true if monitoring installed && actived
  * @param boolean $aggrega true if this port is aggregate port
  *
  * @return nothing
  */
 function showNetworkPortDetail($data, $monitoring, $aggrega = 0)
 {
     global $CFG_GLPI, $DB;
     $nw = new NetworkPort_NetworkPort();
     $networkName = new NetworkName();
     $networkPort = new NetworkPort();
     $pfNetworkPort = new PluginFusioninventoryNetworkPort();
     $iPAddress = new IPAddress();
     $networkPort->getFromDB($data['id']);
     $pfNetworkPort->getFromDB($data['fusionid']);
     $background_img = "";
     if ($pfNetworkPort->fields["trunk"] == "1" && (strstr($pfNetworkPort->fields["ifstatus"], "up") || $pfNetworkPort->fields["ifstatus"] == 1)) {
         $background_img = " style='background-image: url(\"" . $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/pics/port_trunk.png\"); '";
     } else {
         if (PluginFusioninventoryNetworkPort::isPortHasMultipleMac($data['id']) && (strstr($pfNetworkPort->fields["ifstatus"], "up") || $pfNetworkPort->fields["ifstatus"] == 1)) {
             $background_img = " style='background-image: url(\"" . $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/pics/multiple_mac_addresses.png\"); '";
         } else {
             if (strstr($pfNetworkPort->fields["ifstatus"], "up") || $pfNetworkPort->fields["ifstatus"] == 1) {
                 $background_img = " style='background-image: url(\"" . $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/pics/connected_trunk.png\"); '";
             }
         }
     }
     echo "<tr class='tab_bg_1 center' height='40'" . $background_img . ">";
     if ($aggrega) {
         echo "<td style='background-color: #f2f2f2;'></td><td>";
     }
     if (!$aggrega) {
         if ($networkPort->fields['instantiation_type'] == 'NetworkPortAggregate') {
             echo "<td>";
         } else {
             echo "<td colspan='2'>";
         }
     }
     echo "<a href='networkport.form.php?id=" . $networkPort->fields["id"] . "'>" . $networkPort->fields["name"] . "</a>";
     Html::showToolTip($pfNetworkPort->fields['ifdescr']);
     if (!$aggrega) {
         if ($networkPort->fields['instantiation_type'] == 'NetworkPortAggregate') {
             echo "<td><i><font style='color: grey'>" . __('Aggregation port') . "</font></i></td>";
         }
     }
     if ($monitoring == '1') {
         echo "<td>";
         $state = PluginMonitoringNetworkport::isMonitoredNetworkport($data['id']);
         if (Session::haveRight("plugin_monitoring_componentscatalog", UPDATE)) {
             $checked = '';
             if ($state) {
                 $checked = 'checked';
             }
             echo "<input type='checkbox' name='networkports_id[]' value='" . $data['id'] . "' " . $checked . "/>";
         } else {
             if (Session::haveRight("plugin_monitoring_componentscatalog", READ)) {
                 echo Dropdown::getYesNo($state);
             }
         }
         echo "</td>";
     }
     $a_pref = DisplayPreference::getForTypeUser('PluginFusioninventoryNetworkport', Session::getLoginUserID());
     foreach ($a_pref as $data_array) {
         switch ($data_array) {
             case 3:
                 echo "<td>" . $pfNetworkPort->fields["ifmtu"] . "</td>";
                 break;
             case 5:
                 echo "<td>" . $this->byteSize($pfNetworkPort->fields["ifspeed"], 1000) . "bps</td>";
                 break;
             case 6:
                 echo "<td>";
                 if (strstr($pfNetworkPort->fields["ifstatus"], "up") || strstr($pfNetworkPort->fields["ifinternalstatus"], "1")) {
                     echo "<img src='" . $CFG_GLPI['root_doc'] . "/pics/greenbutton.png'/>";
                 } else {
                     if (strstr($pfNetworkPort->fields["ifstatus"], "down") || strstr($pfNetworkPort->fields["ifinternalstatus"], "2")) {
                         echo "<img src='" . $CFG_GLPI['root_doc'] . "/pics/redbutton.png'/>";
                     } else {
                         if (strstr($pfNetworkPort->fields["ifstatus"], "testing") || strstr($pfNetworkPort->fields["ifinternalstatus"], "3")) {
                             echo "<img src='" . $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/pics/yellowbutton.png'/>";
                         }
                     }
                 }
                 echo "</td>";
                 break;
             case 7:
                 echo "<td>" . $pfNetworkPort->fields["iflastchange"] . "</td>";
                 break;
             case 8:
                 echo "<td>";
                 if ($pfNetworkPort->fields["ifinoctets"] == "0") {
                     echo "-";
                 } else {
                     echo $this->byteSize($pfNetworkPort->fields["ifinoctets"], 1000) . "o";
                 }
                 echo " / ";
                 if ($pfNetworkPort->fields["ifinoctets"] == "0") {
                     echo "-";
                 } else {
                     echo $this->byteSize($pfNetworkPort->fields["ifoutoctets"], 1000) . "o";
                 }
                 echo "</td>";
                 break;
             case 9:
                 $color = '';
                 if ($pfNetworkPort->fields["ifinerrors"] != "0" || $pfNetworkPort->fields["ifouterrors"] != "0") {
                     $color = "background='#cf9b9b' class='tab_bg_1_2'";
                 }
                 if ($pfNetworkPort->fields["ifinerrors"] == "0") {
                     echo "<td " . $color . ">-";
                 } else {
                     echo "<td " . $color . ">";
                     echo $pfNetworkPort->fields["ifinerrors"];
                 }
                 echo " / ";
                 if ($pfNetworkPort->fields["ifouterrors"] == "0") {
                     echo "-";
                 } else {
                     echo $pfNetworkPort->fields["ifouterrors"];
                 }
                 echo "</td>";
                 break;
             case 10:
                 if ($pfNetworkPort->fields["portduplex"] == 2) {
                     echo "<td background='#cf9b9b' class='tab_bg_1_2'>";
                     echo __('Half', 'fusioninventory');
                     echo '</td>';
                 } else {
                     if ($pfNetworkPort->fields["portduplex"] == 3) {
                         echo '<td>';
                         echo __('Full', 'fusioninventory');
                         echo '</td>';
                     } else {
                         echo "<td></td>";
                     }
                 }
                 break;
             case 11:
                 // ** internal mac
                 echo "<td>" . $networkPort->fields["mac"] . "</td>";
                 break;
             case 13:
                 // ** Mac address and link to device which are connected to this port
                 $opposite_port = $nw->getOppositeContact($data["id"]);
                 if ($opposite_port != "" && $opposite_port != 0) {
                     $networkPortOpposite = new NetworkPort();
                     if ($networkPortOpposite->getFromDB($opposite_port)) {
                         $data_device = $networkPortOpposite->fields;
                         $item = new $data_device["itemtype"]();
                         $item->getFromDB($data_device["items_id"]);
                         $link1 = $item->getLink(1);
                         $link = str_replace($item->getName(0), $data_device["mac"], $item->getLink());
                         // * GetIP
                         $a_networknames = current($networkName->find("`itemtype`='NetworkPort'\n                                          AND `items_id`='" . $item->getID() . "'", "", 1));
                         $a_ipaddresses = current($iPAddress->find("`itemtype`='NetworkName'\n                                          AND `items_id`='" . $a_networknames['id'] . "'", "", 1));
                         $link2 = str_replace($item->getName(0), $a_ipaddresses['name'], $item->getLink());
                         if ($data_device["itemtype"] == 'PluginFusioninventoryUnmanaged') {
                             $icon = $this->getItemtypeIcon($item->fields["item_type"]);
                             if ($item->getField("accepted") == "1") {
                                 echo "<td style='background:#bfec75'\n                                     class='tab_bg_1_2'>" . $icon . $link1;
                             } else {
                                 echo "<td background='#cf9b9b'\n                                     class='tab_bg_1_2'>" . $icon . $link1;
                             }
                             if (!empty($link)) {
                                 echo "<br/>" . $link;
                             }
                             if (!empty($link2)) {
                                 echo "<br/>" . $link2;
                             }
                             if ($item->getField("hub") == "1") {
                                 $this->displayHubConnections($data_device["items_id"], $background_img);
                             }
                             echo "</td>";
                         } else {
                             $icon = $this->getItemtypeIcon($data_device["itemtype"]);
                             echo "<td>" . $icon . $link1;
                             if (!empty($link)) {
                                 echo "<br/>" . $link;
                             }
                             if (!empty($link2)) {
                                 echo "<br/>" . $link2;
                             }
                             if ($data_device["itemtype"] == 'Phone') {
                                 $query_devicephone = "SELECT *\n                                   FROM `glpi_networkports`\n                                   WHERE `itemtype`='Phone'\n                                       AND `items_id`='" . $data_device["items_id"] . "'\n                                       AND `id`!='" . $data_device["id"] . "'\n                                   LIMIT 1";
                                 $result_devicephone = $DB->query($query_devicephone);
                                 if ($DB->numrows($result_devicephone) > 0) {
                                     $data_devicephone = $DB->fetch_assoc($result_devicephone);
                                     $computer_ports_id = $nw->getOppositeContact($data_devicephone["id"]);
                                     if ($computer_ports_id) {
                                         $networkport = new NetworkPort();
                                         $networkport->getFromDB($computer_ports_id);
                                         if ($networkport->fields['itemtype'] == 'Computer') {
                                             echo "<hr/>";
                                             echo "<img src='" . $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/pics/computer_icon.png' " . "style='float:left'/> ";
                                             $computer = new Computer();
                                             $computer->getFromDB($networkport->fields["items_id"]);
                                             $link1 = $computer->getLink(1);
                                             $link = str_replace($computer->getName(0), $networkport->fields["mac"], $computer->getLink());
                                             $link2 = str_replace($computer->getName(0), $networkport->fields["ip"], $computer->getLink());
                                             echo $icon . $link1;
                                             if (!empty($link)) {
                                                 echo "<br/>" . $link;
                                             }
                                             if (!empty($link2)) {
                                                 echo "<br/>" . $link2;
                                             }
                                         }
                                     }
                                 }
                             }
                             echo "</td>";
                         }
                     } else {
                         echo "<td></td>";
                     }
                 } else {
                     echo "<td></td>";
                 }
                 break;
             case 14:
                 // ** Connection status
                 echo "<td>";
                 if (strstr($pfNetworkPort->fields["ifstatus"], "up") || strstr($pfNetworkPort->fields["ifstatus"], "1")) {
                     echo "<img src='" . $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/pics/wired_on.png'/>";
                 } else {
                     if (strstr($pfNetworkPort->fields["ifstatus"], "down") || strstr($pfNetworkPort->fields["ifstatus"], "2")) {
                         echo "<img src='" . $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/pics/wired_off.png'/>";
                     } else {
                         if (strstr($pfNetworkPort->fields["ifstatus"], "testing") || strstr($pfNetworkPort->fields["ifstatus"], "3")) {
                             echo "<img src='" . $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/pics/yellowbutton.png'/>";
                         } else {
                             if (strstr($pfNetworkPort->fields["ifstatus"], "dormant") || strstr($pfNetworkPort->fields["ifstatus"], "5")) {
                                 echo "<img src='" . $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/pics/orangebutton.png'/>";
                             }
                         }
                     }
                 }
                 echo "</td>";
                 break;
             case 12:
                 echo "<td>";
                 $canedit = Session::haveRight('networking', UPDATE);
                 $used = array();
                 $query_vlan = "SELECT * FROM glpi_networkports_vlans\n                              WHERE networkports_id='" . $data["id"] . "'";
                 $result_vlan = $DB->query($query_vlan);
                 if ($DB->numrows($result_vlan) > 0) {
                     echo "<table cellpadding='0' cellspacing='0'>";
                     while ($line = $DB->fetch_array($result_vlan)) {
                         $used[] = $line["vlans_id"];
                         $vlan = new Vlan();
                         $vlan->getFromDB($line["vlans_id"]);
                         if ($line['tagged'] == '1') {
                             $state = 'T';
                         } else {
                             $state = 'U';
                         }
                         echo "<tr><td>" . $vlan->fields['name'] . " [" . $vlan->fields['tag'] . "] " . $state;
                         echo "</td><td>";
                         if ($canedit) {
                             echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/networkport.form.php?unassign_vlan=unassigned&amp;id=" . $line["id"] . "'>";
                             echo "<img src=\"" . $CFG_GLPI["root_doc"] . "/pics/delete.png\" alt='" . __('Delete', 'fusioninventory') . "' title='" . __('Delete', 'fusioninventory') . "'></a>";
                         } else {
                             echo "&nbsp;";
                         }
                         echo "</td>";
                         echo "</tr>";
                     }
                     echo "</table>";
                 } else {
                     echo "&nbsp;";
                 }
                 echo "</td>";
                 break;
             case 15:
                 echo "<td align='center'>";
                 if ($pfNetworkPort->fields['ifstatus'] == 1) {
                     echo __('Connected');
                 } else {
                     if ($pfNetworkPort->fields['lastup'] == "0000-00-00 00:00:00") {
                         echo '-';
                     } else {
                         $time = strtotime(date('Y-m-d H:i:s')) - strtotime($pfNetworkPort->fields['lastup']);
                         echo Html::timestampToString($time, FALSE);
                     }
                 }
                 echo "</td>";
                 break;
             case 16:
                 echo "<td>" . $pfNetworkPort->fields["ifalias"] . "</td>";
                 break;
         }
     }
     echo "</tr>";
 }
 /**
  * Print the version form
  *
  * @param $ID integer ID of the item
  * @param $options array
  *     - target for the Form
  *     - computers_id ID of the computer for add process
  *
  * @return true if displayed  false if item not found or not right to display
  **/
 function showForm($ID, $options = array())
 {
     global $CFG_GLPI, $LANG;
     $computers_id = -1;
     if (isset($options['computers_id'])) {
         $computers_id = $options['computers_id'];
     }
     if (!haveRight("computer", "w")) {
         return false;
     }
     $comp = new Computer();
     if ($ID > 0) {
         $this->check($ID, 'r');
         $comp->getFromDB($this->fields['computers_id']);
     } else {
         $comp->getFromDB($computers_id);
         // Create item
         $input = array('entities_id' => $comp->getEntityID());
         $this->check(-1, 'w', $input);
     }
     $this->showTabs($options);
     $this->showFormHeader($options);
     if ($ID > 0) {
         $computers_id = $this->fields["computers_id"];
     } else {
         echo "<input type='hidden' name='computers_id' value='{$computers_id}'>";
     }
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['help'][25] . "&nbsp;:</td>";
     echo "<td colspan='3'>" . $comp->getLink() . "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['common'][16] . "&nbsp;:</td>";
     echo "<td>";
     autocompletionTextField($this, "name");
     echo "</td><td>" . $LANG['computers'][6] . "&nbsp;:</td>";
     echo "<td>";
     autocompletionTextField($this, "device");
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['computers'][5] . "&nbsp;:</td>";
     echo "<td>";
     autocompletionTextField($this, "mountpoint");
     echo "</td><td>" . $LANG['computers'][4] . "&nbsp;:</td>";
     echo "<td>";
     Dropdown::show('FileSystem', array('value' => $this->fields["filesystems_id"]));
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['computers'][3] . "&nbsp;:</td>";
     echo "<td>";
     autocompletionTextField($this, "totalsize");
     echo "&nbsp;" . $LANG['common'][82] . "</td>";
     echo "<td>" . $LANG['computers'][2] . "&nbsp;:</td>";
     echo "<td>";
     autocompletionTextField($this, "freesize");
     echo "&nbsp;" . $LANG['common'][82] . "</td></tr>";
     $this->showFormButtons($options);
     $this->addDivForTabs();
     return true;
 }
예제 #9
0
function plugin_fusioninventory_giveItem($type, $id, $data, $num)
{
    global $CFG_GLPI;
    $searchopt =& Search::getOptions($type);
    $table = $searchopt[$id]["table"];
    $field = $searchopt[$id]["field"];
    switch ($table . '.' . $field) {
        case "glpi_plugin_fusioninventory_taskjobs.status":
            $pfTaskjobstate = new PluginFusioninventoryTaskjobstate();
            return $pfTaskjobstate->stateTaskjob($data['raw']['id'], '200', 'htmlvar', 'simple');
            break;
        case "glpi_plugin_fusioninventory_agents.version":
            $array = importArrayFromDB($data['raw']['ITEM_' . $num]);
            $input = "";
            foreach ($array as $name => $version) {
                $input .= "<strong>" . $name . "</strong> : " . $version . "<br/>";
            }
            $input .= "*";
            $input = str_replace("<br/>*", "", $input);
            return $input;
            break;
        case "glpi_plugin_fusioninventory_credentials.itemtype":
            if ($label = PluginFusioninventoryCredential::getLabelByItemtype($data['raw']['ITEM_' . $num])) {
                return $label;
            } else {
                return '';
            }
            break;
        case 'glpi_plugin_fusioninventory_taskjoblogs.state':
            $pfTaskjoblog = new PluginFusioninventoryTaskjoblog();
            return $pfTaskjoblog->getDivState($data['raw']['ITEM_' . $num]);
            break;
        case 'glpi_plugin_fusioninventory_taskjoblogs.comment':
            $comment = $data['raw']['ITEM_' . $num];
            return PluginFusioninventoryTaskjoblog::convertComment($comment);
            break;
        case 'glpi_plugin_fusioninventory_taskjobstates.plugin_fusioninventory_agents_id':
            $pfAgent = new PluginFusioninventoryAgent();
            $pfAgent->getFromDB($data['raw']['ITEM_' . $num]);
            if (!isset($pfAgent->fields['name'])) {
                return NOT_AVAILABLE;
            }
            $itemtype = PluginFusioninventoryTaskjoblog::getStateItemtype($data['raw']['ITEM_0']);
            if ($itemtype == 'PluginFusioninventoryDeployPackage') {
                $computer = new Computer();
                $computer->getFromDB($pfAgent->fields['computers_id']);
                return $computer->getLink(1);
            }
            return $pfAgent->getLink(1);
            break;
        case 'glpi_plugin_fusioninventory_ignoredimportdevices.ip':
        case 'glpi_plugin_fusioninventory_ignoredimportdevices.mac':
            $array = importArrayFromDB($data['raw']['ITEM_' . $num]);
            return implode("<br/>", $array);
            break;
        case 'glpi_plugin_fusioninventory_ignoredimportdevices.method':
            $a_methods = PluginFusioninventoryStaticmisc::getmethods();
            foreach ($a_methods as $mdata) {
                if ($mdata['method'] == $data['raw']['ITEM_' . $num]) {
                    return $mdata['name'];
                }
            }
            break;
    }
    if ($table == "glpi_plugin_fusioninventory_agentmodules") {
        if ($type == 'Computer') {
            $pfAgentmodule = new PluginFusioninventoryAgentmodule();
            $a_modules = $pfAgentmodule->find("`modulename`='" . $field . "'");
            $data2 = current($a_modules);
            if ($table . "." . $field == "glpi_plugin_fusioninventory_agentmodules." . $data2['modulename']) {
                if (strstr($data['raw']["ITEM_" . $num . "_0"], '"' . $data['raw']["ITEM_" . $num . "_1"] . '"')) {
                    if ($data['raw']['ITEM_' . $num] == '0') {
                        return Dropdown::getYesNo(TRUE);
                    } else {
                        return Dropdown::getYesNo(FALSE);
                    }
                }
                return Dropdown::getYesNo($data['raw']['ITEM_' . $num]);
            }
        } else {
            $pfAgentmodule = new PluginFusioninventoryAgentmodule();
            $a_modules = $pfAgentmodule->find("`modulename`='" . $field . "'");
            foreach ($a_modules as $data2) {
                if ($table . "." . $field == "glpi_plugin_fusioninventory_agentmodules." . $data2['modulename']) {
                    if (strstr($data['raw']["ITEM_" . $num . "_0"], '"' . $data['raw']['id'] . '"')) {
                        if ($data['raw']['ITEM_' . $num] == 0) {
                            return Dropdown::getYesNo('1');
                        } else {
                            return Dropdown::getYesNo('0');
                        }
                    }
                    return Dropdown::getYesNo($data['raw']['ITEM_' . $num]);
                }
            }
        }
    }
    switch ($type) {
        case 'Computer':
            if ($table . '.' . $field == 'glpi_plugin_fusioninventory_networkports.id') {
                if (strstr($data['raw']["ITEM_{$num}"], "\$")) {
                    $split = explode("\$\$\$\$", $data['raw']["ITEM_{$num}"]);
                    $ports = array();
                    foreach ($split as $portconcat) {
                        $split2 = explode("....", $portconcat);
                        if (isset($split2[1])) {
                            $ports[] = $split2[1];
                        }
                    }
                    $out = implode("<br/>", $ports);
                    return $out;
                }
            }
            break;
            // * Networking List (front/networking.php)
        // * Networking List (front/networking.php)
        case 'NetworkEquipment':
            switch ($table . '.' . $field) {
            }
            break;
        case 'Printer':
            if ($table . '.' . $field == 'glpi_plugin_fusioninventory_networkequipments.name') {
                if (strstr($data['raw']["ITEM_{$num}"], "\$")) {
                    $split = explode("\$\$\$\$", $data['raw']["ITEM_{$num}"]);
                    $out = implode("<br/>", $split);
                    return $out;
                }
            }
            break;
            // * Authentification List (plugins/fusinvsnmp/front/configsecurity.php)
        // * Authentification List (plugins/fusinvsnmp/front/configsecurity.php)
        case 'PluginFusioninventoryConfigSecurity':
            switch ($table . '.' . $field) {
                // ** Hidden auth passphrase (SNMP v3)
                case "glpi_plugin_fusioninventory_configsecurities.auth_passphrase":
                    $out = "";
                    if (empty($data['raw']["ITEM_{$num}"])) {
                    } else {
                        $out = "********";
                    }
                    return $out;
                    break;
                    // ** Hidden priv passphrase (SNMP v3)
                // ** Hidden priv passphrase (SNMP v3)
                case "glpi_plugin_fusioninventory_configsecurities.priv_passphrase":
                    $out = "";
                    if (empty($data['raw']["ITEM_{$num}"])) {
                    } else {
                        $out = "********";
                    }
                    return $out;
                    break;
            }
            break;
            // * Unknown mac addresses connectd on switch - report
            //   (plugins/fusinvsnmp/report/unknown_mac.php)
        // * Unknown mac addresses connectd on switch - report
        //   (plugins/fusinvsnmp/report/unknown_mac.php)
        case 'PluginFusioninventoryUnmanaged':
            switch ($table . '.' . $field) {
                // ** FusionInventory - switch
                case "glpi_plugin_fusioninventory_networkequipments.id":
                    $out = '';
                    $NetworkPort = new NetworkPort();
                    $list = explode("\$\$\$\$", $data['raw']["ITEM_{$num}"]);
                    foreach ($list as $numtmp => $vartmp) {
                        $NetworkPort->getDeviceData($vartmp, 'PluginFusioninventoryUnmanaged');
                        $out .= "<a href=\"" . $CFG_GLPI["root_doc"] . "/";
                        $out .= "plugins/fusioninventory/front/unmanaged.form.php?id=" . $vartmp . "\">";
                        $out .= $NetworkPort->device_name;
                        if ($CFG_GLPI["view_ID"]) {
                            $out .= " (" . $vartmp . ")";
                        }
                        $out .= "</a><br/>";
                    }
                    return "<center>" . $out . "</center>";
                    break;
                    // ** FusionInventory - switch port
                // ** FusionInventory - switch port
                case "glpi_plugin_fusioninventory_networkports.id":
                    $out = '';
                    if (!empty($data['raw']["ITEM_{$num}"])) {
                        $list = explode("\$\$\$\$", $data['raw']["ITEM_{$num}"]);
                        $np = new NetworkPort();
                        foreach ($list as $numtmp => $vartmp) {
                            $np->getFromDB($vartmp);
                            $out .= "<a href='" . $CFG_GLPI['root_doc'] . "/front/networkport.form.php?id=" . $vartmp . "'>";
                            $out .= $np->fields["name"] . "</a><br/>";
                        }
                    }
                    return "<center>" . $out . "</center>";
                    break;
                case "glpi_plugin_fusinvsnmp_unmanageds.type":
                    $out = '<center> ';
                    switch ($data['raw']["ITEM_{$num}"]) {
                        case COMPUTER_TYPE:
                            $out .= __('Computers');
                            break;
                        case NETWORKING_TYPE:
                            $out .= __('Networks');
                            break;
                        case PRINTER_TYPE:
                            $out .= __('Printers');
                            break;
                        case PERIPHERAL_TYPE:
                            $out .= __('Devices');
                            break;
                        case PHONE_TYPE:
                            $out .= __('Phones');
                            break;
                    }
                    $out .= '</center>';
                    return $out;
                    break;
            }
            break;
            // * Ports date connection - report (plugins/fusinvsnmp/report/ports_date_connections.php)
        // * Ports date connection - report (plugins/fusinvsnmp/report/ports_date_connections.php)
        case 'PluginFusioninventoryNetworkPort':
            switch ($table . '.' . $field) {
                // ** Name and link of networking device (switch)
                case "glpi_plugin_fusioninventory_networkports.id":
                    $query = "SELECT `glpi_networkequipments`.`name` AS `name`, `glpi_networkequipments`.`id` AS `id`\n                         FROM `glpi_networkequipments`\n                              LEFT JOIN `glpi_networkports`\n                                        ON `items_id` = `glpi_networkequipments`.`id`\n                              LEFT JOIN `glpi_plugin_fusioninventory_networkports`\n                                        ON `glpi_networkports`.`id`=`networkports_id`\n                         WHERE `glpi_plugin_fusioninventory_networkports`.`id`='" . $data['raw']["ITEM_{$num}"] . "'\n                         LIMIT 0, 1;";
                    $result = $DB->query($query);
                    $data2 = $DB->fetch_assoc($result);
                    $out = "<a href='" . $CFG_GLPI['root_doc'] . "/front/networking.form.php?id=" . $data2["id"] . "'>";
                    $out .= $data2["name"] . "</a>";
                    return "<center>" . $out . "</center>";
                    break;
                    // ** Name and link of port of networking device (port of switch)
                // ** Name and link of port of networking device (port of switch)
                case "glpi_plugin_fusioninventory_networkports.networkports_id":
                    $NetworkPort = new NetworkPort();
                    $NetworkPort->getFromDB($data['raw']["ITEM_{$num}"]);
                    $name = "";
                    if (isset($NetworkPort->fields["name"])) {
                        $name = $NetworkPort->fields["name"];
                    }
                    $out = "<a href='" . $CFG_GLPI['root_doc'] . "/front/networkport.form.php?id=" . $data['raw']["ITEM_{$num}"];
                    $out .= "'>" . $name . "</a>";
                    return "<center>" . $out . "</center>";
                    break;
                    // ** Location of switch
                // ** Location of switch
                case "glpi_locations.id":
                    $out = Dropdown::getDropdownName("glpi_locations", $data['raw']["ITEM_{$num}"]);
                    return "<center>" . $out . "</center>";
                    break;
            }
            break;
            // * range IP list (plugins/fusinvsnmp/front/iprange.php)
        // * range IP list (plugins/fusinvsnmp/front/iprange.php)
        case 'PluginFusioninventoryIPRange':
            switch ($table . '.' . $field) {
                // ** Display entity name
                case "glpi_entities.name":
                    if ($data['raw']["ITEM_{$num}"] == '') {
                        $out = Dropdown::getDropdownName("glpi_entities", $data['raw']["ITEM_{$num}"]);
                        return "<center>" . $out . "</center>";
                    }
                    break;
            }
            break;
        case 'PluginFusioninventoryNetworkPortLog':
            switch ($table . '.' . $field) {
                // ** Display switch and Port
                case "glpi_networkports.id":
                    $Array_device = PluginFusioninventoryNetworkPort::getUniqueObjectfieldsByportID($data['raw']["ITEM_{$num}"]);
                    $item = new $Array_device["itemtype"]();
                    $item->getFromDB($Array_device["items_id"]);
                    $out = "<div align='center'>" . $item->getLink(1);
                    $query = "SELECT *\n                         FROM `glpi_networkports`\n                         WHERE `id`='" . $data['raw']["ITEM_{$num}"] . "';";
                    $result = $DB->query($query);
                    if ($DB->numrows($result) != "0") {
                        $out .= "<br/><a href='" . $CFG_GLPI['root_doc'] . "/front/networkport.form.php?id=";
                        $out .= $data['raw']["ITEM_{$num}"] . "'>" . $DB->result($result, 0, "name") . "</a>";
                    }
                    $out .= "</td>";
                    return $out;
                    break;
                    // ** Display GLPI field of device
                // ** Display GLPI field of device
                case "glpi_plugin_fusinvsnmp_networkportlogs.field":
                    //               $out = $FUSIONINVENTORY_MAPPING[NETWORKING_TYPE][$data['raw']["ITEM_$num"]]['name'];
                    $out = '';
                    $map = new PluginFusioninventoryMapping();
                    $mapfields = $map->get('NetworkEquipment', $data['raw']["ITEM_{$num}"]);
                    if ($mapfields != FALSE) {
                        $out = _get('_LANG[\'plugin_fusinvsnmp\'][\'mapping\'][$mapfields["locale"]]');
                    }
                    return $out;
                    break;
                    // ** Display Old Value (before changement of value)
                // ** Display Old Value (before changement of value)
                case "glpi_plugin_fusinvsnmp_networkportlogs.old_value":
                    // TODO ADD LINK TO DEVICE
                    if (substr_count($data['raw']["ITEM_{$num}"], ":") == 5 && empty($data['raw']["ITEM_3"])) {
                        return "<center><b>" . $data['raw']["ITEM_{$num}"] . "</b></center>";
                    }
                    break;
                    // ** Display New Value (new value modified)
                // ** Display New Value (new value modified)
                case "glpi_plugin_fusinvsnmp_networkportlogs.new_value":
                    if (substr_count($data['raw']["ITEM_{$num}"], ":") == 5 && empty($data['raw']["ITEM_3"])) {
                        return "<center><b>" . $data['raw']["ITEM_{$num}"] . "</b></center>";
                    }
                    break;
            }
            break;
        case "PluginFusioninventoryPrinterLog":
            switch ($table . '.' . $field) {
                case 'glpi_printers.name':
                    // Search pages in printer history to limit SQL queries
                    if (isset($_SESSION['glpi_plugin_fusioninventory_history_start'])) {
                        unset($_SESSION['glpi_plugin_fusioninventory_history_start']);
                    }
                    if (isset($_SESSION['glpi_plugin_fusioninventory_history_end'])) {
                        unset($_SESSION['glpi_plugin_fusioninventory_history_end']);
                    }
                    if (isset($_SESSION['glpi_plugin_fusioninventory_date_start']) and isset($_SESSION['glpi_plugin_fusioninventory_date_end'])) {
                        $query = "SELECT * FROM `glpi_plugin_fusioninventory_printerlogs`\n                     WHERE `printers_id`='" . $data['raw']['ITEM_0_2'] . "'\n                        AND `date`>= '" . $_SESSION['glpi_plugin_fusioninventory_date_start'] . "'\n                        AND `date`<= '" . $_SESSION['glpi_plugin_fusioninventory_date_end'] . " 23:59:59'\n                     ORDER BY date asc\n                     LIMIT 1";
                        $result = $DB->query($query);
                        while ($data2 = $DB->fetch_array($result)) {
                            $_SESSION['glpi_plugin_fusioninventory_history_start'] = $data2;
                        }
                        $query = "SELECT * FROM `glpi_plugin_fusioninventory_printerlogs`\n                     WHERE `printers_id`='" . $data['raw']['ITEM_0_2'] . "'\n                        AND `date`>= '" . $_SESSION['glpi_plugin_fusioninventory_date_start'] . "'\n                        AND `date`<= '" . $_SESSION['glpi_plugin_fusioninventory_date_end'] . " 23:59:59'\n                     ORDER BY date desc\n                     LIMIT 1";
                        $result = $DB->query($query);
                        while ($data2 = $DB->fetch_array($result)) {
                            $_SESSION['glpi_plugin_fusioninventory_history_end'] = $data2;
                        }
                    }
                    return "";
                    break;
            }
            switch ($table) {
                case 'glpi_plugin_fusioninventory_printerlogs':
                    if (isset($_SESSION['glpi_plugin_fusioninventory_history_start'][$field]) and isset($_SESSION['glpi_plugin_fusioninventory_history_end'][$field])) {
                        $counter_start = $_SESSION['glpi_plugin_fusioninventory_history_start'][$field];
                        $counter_end = $_SESSION['glpi_plugin_fusioninventory_history_end'][$field];
                        if ($_SESSION['glpi_plugin_fusioninventory_date_start'] == "1970-01-01") {
                            $counter_start = 0;
                        }
                        $number = $counter_end - $counter_start;
                        if ($number == '0') {
                            return '-';
                        } else {
                            return $number;
                        }
                    } else {
                        return '-';
                    }
                    break;
            }
            break;
    }
    return "";
}
 /**
  * Prints a direct connection to a computer
  *
  * @param $item the Monitor/Phone/Peripheral/Printer
  *
  * @return nothing (print out a table)
  */
 static function showForItem(CommonDBTM $item)
 {
     // Prints a direct connection to a computer
     global $DB, $LANG;
     $comp = new Computer();
     $target = $comp->getFormURL();
     $ID = $item->getField('id');
     if (!$item->can($ID, "r")) {
         return false;
     }
     $canedit = $item->can($ID, "w");
     // Is global connection ?
     $global = $item->getField('is_global');
     $used = array();
     $compids = array();
     $crit = array('FIELDS' => array('id', 'computers_id'), 'itemtype' => $item->getType(), 'items_id' => $ID);
     foreach ($DB->request('glpi_computers_items', $crit) as $data) {
         $compids[$data['id']] = $data['computers_id'];
     }
     echo "<div class='spaced'><table width='50%' class='tab_cadre_fixe'>";
     echo "<tr><th colspan='2'>";
     if (count($compids) == 0) {
         echo $LANG['connect'][4];
     } else {
         if (count($compids) == 1) {
             echo $LANG['connect'][3] . "&nbsp;:&nbsp;" . count($compids);
         } else {
             echo $LANG['connect'][2] . "&nbsp;:&nbsp;" . count($compids);
         }
     }
     echo "</th></tr>";
     if (count($compids) > 0) {
         foreach ($compids as $key => $compid) {
             $comp->getFromDB($compid);
             echo "<tr><td class='b tab_bg_1" . ($comp->getField('is_deleted') ? "_2" : "") . "'>";
             echo $LANG['help'][25] . "&nbsp;:&nbsp;" . $comp->getLink() . "</td>";
             echo "<td class='tab_bg_2" . ($comp->getField('is_deleted') ? "_2" : "") . " center b'>";
             if ($canedit) {
                 echo "<a href=\"{$target}?disconnect=1&amp;computers_id={$compid}&amp;id={$key}\">" . $LANG['buttons'][10] . "</a>";
             } else {
                 echo "&nbsp;";
             }
             $used[] = $compid;
         }
     } else {
         echo "<tr><td class='tab_bg_1 b'>" . $LANG['help'][25] . "&nbsp;:&nbsp;";
         echo "<i>" . $LANG['connect'][1] . "</i></td>";
         echo "<td class='tab_bg_2' class='center'>";
         if ($canedit) {
             echo "<form method='post' action=\"{$target}\">";
             echo "<input type='hidden' name='items_id' value='{$ID}'>";
             echo "<input type='hidden' name='itemtype' value='" . $item->getType() . "'>";
             if ($item->isRecursive()) {
                 self::dropdownConnect('Computer', $item->getType(), "computers_id", getSonsOf("glpi_entities", $item->getEntityID()), 0, $used);
             } else {
                 self::dropdownConnect('Computer', $item->getType(), "computers_id", $item->getEntityID(), 0, $used);
             }
             echo "<input type='submit' name='connect' value=\"" . $LANG['buttons'][9] . "\"\n                   class='submit'>";
             echo "</form>";
         } else {
             echo "&nbsp;";
         }
     }
     if ($global && count($compids) > 0) {
         echo "</td></tr>";
         echo "<tr><td class='tab_bg_1'>&nbsp;</td>";
         echo "<td class='tab_bg_2' class='center'>";
         if ($canedit) {
             echo "<form method='post' action=\"{$target}\">";
             echo "<input type='hidden' name='items_id' value='{$ID}'>";
             echo "<input type='hidden' name='itemtype' value='" . $item->getType() . "'>";
             if ($item->isRecursive()) {
                 self::dropdownConnect('Computer', $item->getType(), "computers_id", getSonsOf("glpi_entities", $item->getEntityID()), 0, $used);
             } else {
                 self::dropdownConnect('Computer', $item->getType(), "computers_id", $item->getEntityID(), 0, $used);
             }
             echo "<input type='submit' name='connect' value=\"" . $LANG['buttons'][9] . "\"\n                   class='submit'>";
             echo "</form>";
         } else {
             echo "&nbsp;";
         }
     }
     echo "</td></tr>";
     echo "</table></div>";
 }
 /**
  * Display form for agent configuration
  *
  * @param $computers_id integer ID of the agent
  * @param $options array
  *
  * @return bool TRUE if form is ok
  *
  **/
 function showForm($computers_id, $options = array())
 {
     if ($computers_id != '') {
         $this->getFromDB($computers_id);
     } else {
         $this->getEmpty();
         $pfConfig = new PluginFusioninventoryConfig();
         unset($this->fields['id']);
         $this->fields['threads_networkdiscovery'] = $pfConfig->getValue('threads_networkdiscovery');
         $this->fields['timeout_networkdiscovery'] = $pfConfig->getValue('timeout_networkdiscovery');
         $this->fields['threads_networkinventory'] = $pfConfig->getValue('threads_networkinventory');
         $this->fields['timeout_networkinventory'] = $pfConfig->getValue('timeout_networkinventory');
         $this->fields['senddico'] = 0;
     }
     $this->initForm($computers_id, $options);
     $this->showFormHeader($options);
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Name') . " :</td>";
     echo "<td align='center'>";
     Html::autocompletionTextField($this, 'name', array('size' => 40));
     echo "</td>";
     echo "<td>" . __('Device_id', 'fusioninventory') . "&nbsp;:</td>";
     echo "<td align='center'>";
     echo $this->fields["device_id"];
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Computer link', 'fusioninventory') . "&nbsp:</td>";
     echo "<td align='center'>";
     if (!empty($this->fields["computers_id"])) {
         $oComputer = new Computer();
         $oComputer->getFromDB($this->fields["computers_id"]);
         echo $oComputer->getLink(1);
         echo Html::hidden('computers_id', array('value' => $this->fields["computers_id"]));
     } else {
         Computer_Item::dropdownConnect("Computer", "Computer", 'computers_id', $_SESSION['glpiactive_entity']);
     }
     echo "</td>";
     echo "<td>" . __('Token') . "&nbsp:</td>";
     echo "<td align='center'>";
     echo $this->fields["token"];
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('locked', 'fusioninventory') . "&nbsp:</td>";
     echo "<td align='center'>";
     Dropdown::showYesNo('lock', $this->fields["lock"]);
     echo "</td>";
     echo "<td>" . __('Version') . "&nbsp:</td>";
     echo "<td align='center'>";
     $a_versions = importArrayFromDB($this->fields["version"]);
     foreach ($a_versions as $module => $version) {
         echo "<strong>" . $module . "</strong>: " . $version . "<br/>";
     }
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Threads number', 'fusioninventory') . "&nbsp;" . "(" . strtolower(__('Network discovery', 'fusioninventory')) . ")&nbsp;:</td>";
     echo "<td align='center'>";
     Dropdown::showNumber("threads_networkdiscovery", array('value' => $this->fields["threads_networkdiscovery"], 'min' => 1, 'max' => 400));
     echo "</td>";
     echo "<td>" . __('Useragent', 'fusioninventory') . "&nbsp:</td>";
     echo "<td align='center'>";
     echo $this->fields["useragent"];
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('SNMP timeout', 'fusioninventory') . "&nbsp;" . "(" . strtolower(__('Network discovery', 'fusioninventory')) . ")&nbsp;:</td>";
     echo "<td align='center'>";
     Dropdown::showNumber("timeout_networkdiscovery", array('value' => $this->fields["timeout_networkdiscovery"], 'min' => 0, 'max' => 60));
     echo "</td>";
     echo "<td>" . __('Last contact', 'fusioninventory') . "&nbsp:</td>";
     echo "<td align='center'>";
     echo Html::convDateTime($this->fields["last_contact"]);
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Threads number', 'fusioninventory') . "&nbsp;" . "(" . strtolower(__('Network inventory (SNMP)', 'fusioninventory')) . ")&nbsp;:</td>";
     echo "<td align='center'>";
     Dropdown::showNumber("threads_networkinventory", array('value' => $this->fields["threads_networkinventory"], 'min' => 1, 'max' => 400));
     echo "</td>";
     echo "<td>" . __('FusionInventory tag', 'fusioninventory') . "&nbsp:</td>";
     echo "<td align='center'>";
     echo $this->fields["tag"];
     echo "</td>";
     echo "</tr>";
     echo "<td>" . __('SNMP timeout', 'fusioninventory') . "&nbsp;" . "(" . strtolower(__('Network inventory (SNMP)', 'fusioninventory')) . ")&nbsp;:</td>";
     echo "<td align='center'>";
     Dropdown::showNumber("timeout_networkinventory", array('value' => $this->fields["timeout_networkinventory"], 'min' => 0, 'max' => 60));
     echo "</td>";
     echo "<td colspan='2'>";
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     $pfConfig = new PluginFusioninventoryConfig();
     echo "<td>" . __('Agent port', 'fusioninventory') . " (" . __('if empty use port configured in general options', 'fusioninventory') . " <i>" . $pfConfig->getValue('agent_port') . "</i>)&nbsp:</td>";
     echo "<td align='center'>";
     echo "<input type='text' name='agent_port' value='" . $this->fields['agent_port'] . "'/>";
     echo "</td>";
     echo "<td colspan='2'>";
     echo "</td>";
     echo "</tr>";
     $this->showFormButtons($options);
     return TRUE;
 }
 function showForCollectFile($collects_files_id)
 {
     $pfCollect_File = new PluginFusioninventoryCollect_File();
     $computer = new Computer();
     $pfCollect_File->getFromDB($collects_files_id);
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr>";
     echo "<th colspan='3'>";
     echo $pfCollect_File->fields['name'];
     echo "</th>";
     echo "</tr>";
     echo "<tr>";
     echo "<th>" . __('Computer') . "</th>";
     echo "<th>" . __('pathfile', 'fusioninventory') . "</th>";
     echo "<th>" . __('Size', 'fusioninventory') . "</th>";
     echo "</tr>";
     $a_data = $this->find("`plugin_fusioninventory_collects_files_id`='" . $collects_files_id . "'", "`pathfile`");
     foreach ($a_data as $data) {
         echo "<tr class='tab_bg_1'>";
         echo '<td>';
         $computer->getFromDB($data['computers_id']);
         echo $computer->getLink(1);
         echo '</td>';
         echo '<td>';
         echo $data['pathfile'];
         echo '</td>';
         echo '<td>';
         echo Toolbox::getSize($data['size']);
         echo '</td>';
         echo "</tr>";
     }
     echo '</table>';
 }
 function showForCollectRegistry($collects_registries_id)
 {
     $pfCollect_Registry = new PluginFusioninventoryCollect_Registry();
     $computer = new Computer();
     $pfCollect_Registry->getFromDB($collects_registries_id);
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr>";
     echo "<th colspan='3'>";
     echo $pfCollect_Registry->fields['hive'] . $pfCollect_Registry->fields['path'];
     echo "</th>";
     echo "</tr>";
     echo "<tr>";
     echo "<th>" . __('Computer') . "</th>";
     echo "<th>" . __('Value', 'fusioninventory') . "</th>";
     echo "<th>" . __('Data', 'fusioninventory') . "</th>";
     echo "</tr>";
     $a_data = $this->find("`plugin_fusioninventory_collects_registries_id`='" . $collects_registries_id . "'", "`key`");
     foreach ($a_data as $data) {
         echo "<tr class='tab_bg_1'>";
         echo '<td>';
         $computer->getFromDB($data['computers_id']);
         echo $computer->getLink(1);
         echo '</td>';
         echo '<td>';
         echo $data['key'];
         echo '</td>';
         echo '<td>';
         echo $data['value'];
         echo '</td>';
         echo "</tr>";
     }
     echo '</table>';
 }
 /**
  * Print the version form
  *
  * @param $ID        integer ID of the item
  * @param $options   array
  *     - target for the Form
  *     - computers_id ID of the computer for add process
  *
  * @return true if displayed  false if item not found or not right to display
  **/
 function showForm($ID, $options = array())
 {
     global $CFG_GLPI;
     if (!Session::haveRight("computer", UPDATE)) {
         return false;
     }
     $comp = new Computer();
     if ($ID > 0) {
         $this->check($ID, READ);
         $comp->getFromDB($this->fields['computers_id']);
     } else {
         $this->check(-1, CREATE, $options);
         $comp->getFromDB($options['computers_id']);
     }
     $this->showFormHeader($options);
     if ($this->isNewID($ID)) {
         echo "<input type='hidden' name='computers_id' value='" . $options['computers_id'] . "'>";
     }
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Computer') . "</td>";
     echo "<td>" . $comp->getLink() . "</td>";
     if (Plugin::haveImport()) {
         echo "<td>" . __('Automatic inventory') . "</td>";
         echo "<td>";
         if ($ID && $this->fields['is_dynamic']) {
             Plugin::doHook("autoinventory_information", $this);
         } else {
             _e('No');
         }
         echo "</td>";
     } else {
         echo "<td colspan='2'></td>";
     }
     echo "</tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Name') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, "name");
     echo "</td><td>" . __('Partition') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, "device");
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Mount point') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, "mountpoint");
     echo "</td><td>" . __('File system') . "</td>";
     echo "<td>";
     FileSystem::dropdown(array('value' => $this->fields["filesystems_id"]));
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Global size') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, "totalsize");
     echo "&nbsp;" . __('Mio') . "</td>";
     echo "<td>" . __('Free size') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, "freesize");
     echo "&nbsp;" . __('Mio') . "</td></tr>";
     $this->showFormButtons($options);
     return true;
 }
예제 #15
0
 /**
  * Prints a direct connection to a computer
  *
  * @param $item                     CommonDBTM object: the Monitor/Phone/Peripheral/Printer
  * @param $withtemplate    integer  withtemplate param (default '')
  *
  * @return nothing (print out a table)
  **/
 static function showForItem(CommonDBTM $item, $withtemplate = '')
 {
     // Prints a direct connection to a computer
     global $DB;
     $comp = new Computer();
     $ID = $item->getField('id');
     if (!$item->can($ID, READ)) {
         return false;
     }
     $canedit = $item->canEdit($ID);
     $rand = mt_rand();
     // Is global connection ?
     $global = $item->getField('is_global');
     $used = array();
     $compids = array();
     $crit = array('FIELDS' => array('id', 'computers_id', 'is_dynamic'), 'itemtype' => $item->getType(), 'items_id' => $ID, 'is_deleted' => 0);
     foreach ($DB->request('glpi_computers_items', $crit) as $data) {
         $compids[$data['id']] = $data['computers_id'];
         $dynamic[$data['id']] = $data['is_dynamic'];
         $used['Computer'][] = $data['computers_id'];
     }
     $number = count($compids);
     if ($canedit && ($global || !$number)) {
         echo "<div class='firstbloc'>";
         echo "<form name='computeritem_form{$rand}' id='computeritem_form{$rand}' method='post'\n                action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr class='tab_bg_2'><th colspan='2'>" . __('Connect a computer') . "</th></tr>";
         echo "<tr class='tab_bg_1'><td class='right'>";
         echo "<input type='hidden' name='items_id' value='{$ID}'>";
         echo "<input type='hidden' name='itemtype' value='" . $item->getType() . "'>";
         if ($item->isRecursive()) {
             self::dropdownConnect('Computer', $item->getType(), "computers_id", getSonsOf("glpi_entities", $item->getEntityID()), 0, $used);
         } else {
             self::dropdownConnect('Computer', $item->getType(), "computers_id", $item->getEntityID(), 0, $used);
         }
         echo "</td><td class='center'>";
         echo "<input type='submit' name='add' value=\"" . _sx('button', 'Connect') . "\" class='submit'>";
         echo "</td></tr>";
         echo "</table>";
         Html::closeForm();
         echo "</div>";
     }
     echo "<div class='spaced'>";
     if ($canedit && $number) {
         Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
         $massiveactionparams = array('num_displayed' => $number, 'specific_actions' => array('purge' => _x('button', 'Disconnect')), 'container' => 'mass' . __CLASS__ . $rand);
         Html::showMassiveActions($massiveactionparams);
     }
     echo "<table class='tab_cadre_fixehov'>";
     if ($number > 0) {
         $header_begin = "<tr>";
         $header_top = '';
         $header_bottom = '';
         $header_end = '';
         if ($canedit) {
             $header_top .= "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand);
             $header_top .= "</th>";
             $header_bottom .= "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand);
             $header_bottom .= "</th>";
         }
         $header_end .= "<th>" . __('Name') . "</th>";
         if (Plugin::haveImport()) {
             $header_end .= "<th>" . __('Automatic inventory') . "</th>";
         }
         $header_end .= "<th>" . __('Entity') . "</th>";
         $header_end .= "<th>" . __('Serial number') . "</th>";
         $header_end .= "<th>" . __('Inventory number') . "</th>";
         $header_end .= "</tr>";
         echo $header_begin . $header_top . $header_end;
         foreach ($compids as $key => $compid) {
             $comp->getFromDB($compid);
             echo "<tr class='tab_bg_1'>";
             if ($canedit) {
                 echo "<td width='10'>";
                 Html::showMassiveActionCheckBox(__CLASS__, $key);
                 echo "</td>";
             }
             echo "<td " . ($comp->getField('is_deleted') ? "class='tab_bg_2_2'" : "") . ">" . $comp->getLink() . "</td>";
             if (Plugin::haveImport()) {
                 echo "<td>" . Dropdown::getYesNo($dynamic[$key]) . "</td>";
             }
             echo "<td class='center'>" . Dropdown::getDropdownName("glpi_entities", $comp->getField('entities_id'));
             echo "</td>";
             echo "<td class='center'>" . $comp->getField('serial') . "</td>";
             echo "<td class='center'>" . $comp->getField('otherserial') . "</td>";
             echo "</tr>";
         }
         echo $header_begin . $header_bottom . $header_end;
     } else {
         echo "<tr><td class='tab_bg_1 b'><i>" . __('Not connected') . "</i>";
         echo "</td></tr>";
     }
     echo "</table>";
     if ($canedit && $number) {
         $massiveactionparams['ontop'] = false;
         Html::showMassiveActions($massiveactionparams);
         Html::closeForm();
     }
     echo "</div>";
 }
 /**
  * Print the version form
  *
  * @param $ID        integer ID of the item
  * @param $options   array
  *     - target for the Form
  *     - computers_id ID of the computer for add process
  *
  * @return true if displayed  false if item not found or not right to display
  **/
 function showForm($ID, $options = array())
 {
     global $CFG_GLPI;
     if (!Session::haveRight("computer", "w")) {
         return false;
     }
     $comp = new Computer();
     if ($ID > 0) {
         $this->check($ID, 'r');
         $comp->getFromDB($this->fields['computers_id']);
     } else {
         // Create item
         $this->check(-1, 'w', $options);
         $comp->getFromDB($options['computers_id']);
     }
     $this->showTabs($options);
     $this->showFormHeader($options);
     if ($this->isNewID($ID)) {
         echo "<input type='hidden' name='computers_id' value='" . $options['computers_id'] . "'>";
     }
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Computer') . "</td>";
     echo "<td>" . $comp->getLink() . "</td>";
     if (Plugin::haveImport()) {
         echo "<td>" . __('Automatic inventory') . "</td>";
         echo "<td>";
         if ($ID && $this->fields['is_dynamic']) {
             Plugin::doHook("autoinventory_information", $this);
         } else {
             _e('No');
         }
         echo "</td>";
     } else {
         echo "<td colspan='2'></td>";
     }
     echo "</tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Name') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, "name");
     echo "</td><td>" . __('Virtualization system') . "</td>";
     echo "<td>";
     VirtualMachineType::dropdown(array('value' => $this->fields['virtualmachinetypes_id']));
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Virtualization model') . "</td>";
     echo "<td>";
     VirtualMachineSystem::dropdown(array('value' => $this->fields['virtualmachinesystems_id']));
     echo "</td><td>" . __('State of the virtual machine') . "</td>";
     echo "<td>";
     VirtualMachineState::dropdown(array('value' => $this->fields['virtualmachinestates_id']));
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('UUID') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, "uuid");
     echo "</td>";
     echo "<td>" . _x('quantity', 'Processors number') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, "vcpu");
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . sprintf(__('%1$s (%2$s)'), __('Memory'), __('Mio')) . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, "ram");
     echo "</td>";
     echo "<td>" . __('Machine') . "</td>";
     echo "<td>";
     if ($link_computer = self::findVirtualMachine($this->fields)) {
         $computer = new Computer();
         if ($computer->getFromDB($link_computer)) {
             echo $computer->getLink(array('comments' => true));
         } else {
             echo NOT_AVAILABLE;
         }
     }
     echo "</td>";
     echo "</tr>";
     $this->showFormButtons($options);
     $this->addDivForTabs();
     return true;
 }
예제 #17
0
 static function previewRuleImportProcess($output)
 {
     global $LANG;
     //If ticket is assign to an object, display this information first
     if (isset($output["action"])) {
         echo "<tr class='tab_bg_2'>";
         echo "<td>" . $LANG['rulesengine'][11] . "</td>";
         echo "<td>";
         switch ($output["action"]) {
             case self::LINK_RESULT_LINK:
                 echo $LANG['ocsng'][67];
                 break;
             case self::LINK_RESULT_NO_IMPORT:
                 echo $LANG['ocsng'][68];
                 break;
             case self::LINK_RESULT_IMPORT:
                 echo $LANG['ocsng'][69];
                 break;
         }
         echo "</td>";
         echo "</tr>";
         if ($output["action"] != self::LINK_RESULT_NO_IMPORT && isset($output["found_computers"])) {
             echo "<tr class='tab_bg_2'>";
             $item = new Computer();
             if ($item->getFromDB($output["found_computers"][0])) {
                 echo "<td>" . $LANG['rulesengine'][155] . "</td>";
                 echo "<td>" . $item->getLink(true) . "</td>";
             }
             echo "</tr>";
         }
     }
     return $output;
 }