/** * * * @param $items_id integer ID * @param $options array * *@return bool true if form is ok * **/ function showForm($items_id, $itemtype, $options = array()) { global $DB, $CFG_GLPI; $query = "SELECT * FROM `" . $this->getTable() . "`\n WHERE `items_id`='" . $items_id . "'\n AND `itemtype`='" . $itemtype . "'\n LIMIT 1"; $result = $DB->query($query); if ($DB->numrows($result) == '0') { $this->getEmpty(); } else { $data = $DB->fetch_assoc($result); $this->getFromDB($data['id']); } $this->showFormHeader($options); echo "<tr class='tab_bg_1'>"; echo "<td width='350'>" . __('Interface and IP to use for checks (only if have many IPs)', 'monitoring') . " :</td>"; echo "<td>"; echo "<input type='hidden' name='itemtype' value='" . $itemtype . "'/>"; echo "<input type='hidden' name='items_id' value='" . $items_id . "'/>"; if ($this->fields['networkports_id'] == '') { $this->fields['networkports_id'] = 0; } $a_networkport = array(); $a_networkport['0'] = Dropdown::EMPTY_VALUE; $query = "SELECT `glpi_networkports`.* FROM `glpi_networkports`\n LEFT JOIN `glpi_networknames`\n ON `glpi_networknames`.`items_id`=`glpi_networkports`.`id`\n AND `glpi_networknames`.`itemtype`='NetworkPort'\n LEFT JOIN `glpi_ipaddresses`\n ON `glpi_ipaddresses`.`items_id`=`glpi_networknames`.`id`\n AND `glpi_ipaddresses`.`itemtype`='NetworkName'\n WHERE `glpi_networkports`.`items_id`='" . $items_id . "'\n AND `glpi_networkports`.`itemtype`='" . $itemtype . "'\n AND `glpi_ipaddresses`.`name` IS NOT NULL\n AND `glpi_ipaddresses`.`name` != '127.0.0.1'\n AND `glpi_ipaddresses`.`name` != '::1'\n AND `glpi_ipaddresses`.`name` != ''\n ORDER BY `name`"; $result = $DB->query($query); while ($data = $DB->fetch_array($result)) { $a_networkport[$data['id']] = $data['name']; } $rand = Dropdown::showFromArray("networkports_id", $a_networkport, array('value' => $this->fields['networkports_id'])); echo "</td>"; echo "<td colspan='2'>"; // Specify ip address or 'first ip address' $params = array('networkports_id' => '__VALUE__', 'rand' => $rand, 'ipaddresses_id' => $this->fields['ipaddresses_id']); Ajax::updateItemOnEvent("dropdown_networkports_id" . $rand, "ipaddresses", $CFG_GLPI["root_doc"] . "/plugins/monitoring/ajax/dropdownipaddress.php", $params); echo "<div id='ipaddresses'>"; PluginMonitoringHostaddress::dropdownIP($this->fields['ipaddresses_id'], $this->fields['networkports_id']); echo "</div>"; echo "</td>"; echo "</tr>"; $this->showFormButtons($options); return true; }
You should have received a copy of the GNU Affero General Public License along with Monitoring. If not, see <http://www.gnu.org/licenses/>. ------------------------------------------------------------------------ @package Plugin Monitoring for GLPI @author David Durieux @co-author @comment @copyright Copyright (c) 2011-2013 Plugin Monitoring for GLPI team @license AGPL License 3.0 or (at your option) any later version http://www.gnu.org/licenses/agpl-3.0-standalone.html @link https://forge.indepnet.net/projects/monitoring/ @since 2013 ------------------------------------------------------------------------ */ if (strpos($_SERVER['PHP_SELF'], "dropdownipaddress.php")) { include "../../../inc/includes.php"; header("Content-Type: text/html; charset=UTF-8"); Html::header_nocache(); } Session::checkCentralAccess(); if (!isset($_POST['ipaddresses_id'])) { $_POST['ipaddresses_id'] = 0; } if (!isset($_POST['networkports_id'])) { $_POST['networkports_id'] = 0; } PluginMonitoringHostaddress::dropdownIP($_POST['ipaddresses_id'], $_POST['networkports_id']);