/** * Add AUTHENTICATION string to XML node * *@param $p_sxml_node XML node to authenticate *@param $p_id Authenticate id *@return nothing **/ function addAuth($p_sxml_node, $p_id) { $pfConfigSecurity = new PluginFusioninventoryConfigSecurity(); if ($pfConfigSecurity->getFromDB($p_id)) { $sxml_authentication = $p_sxml_node->addChild('AUTHENTICATION'); $sxml_authentication->addAttribute('ID', $p_id); $sxml_authentication->addAttribute('VERSION', $pfConfigSecurity->getSNMPVersion($pfConfigSecurity->fields['snmpversion'])); if ($pfConfigSecurity->fields['snmpversion'] == '3') { $sxml_authentication->addAttribute('USERNAME', $pfConfigSecurity->fields['username']); if ($pfConfigSecurity->fields['authentication'] == '0') { // $sxml_authentication->addAttribute('AUTHPROTOCOL', ''); } else { $sxml_authentication->addAttribute('AUTHPROTOCOL', $pfConfigSecurity->getSNMPAuthProtocol($pfConfigSecurity->fields['authentication'])); } $sxml_authentication->addAttribute('AUTHPASSPHRASE', $pfConfigSecurity->fields['auth_passphrase']); if ($pfConfigSecurity->fields['encryption'] == '0') { // $sxml_authentication->addAttribute('PRIVPROTOCOL', ''); } else { $sxml_authentication->addAttribute('PRIVPROTOCOL', $pfConfigSecurity->getSNMPEncryption($pfConfigSecurity->fields['encryption'])); } $sxml_authentication->addAttribute('PRIVPASSPHRASE', $pfConfigSecurity->fields['priv_passphrase']); } else { $sxml_authentication->addAttribute('COMMUNITY', $pfConfigSecurity->fields['community']); } } }
function showForm(CommonDBTM $item, $options = array()) { $ID = $item->getField('id'); if ($item->isNewID($ID)) { return false; } if (!$item->can($item->fields['id'], READ)) { return false; } $rand = mt_rand(); $a_data = getAllDatasFromTable('glpi_plugin_fusioninventory_ipranges_configsecurities', "`plugin_fusioninventory_ipranges_id`='" . $item->getID() . "'", false, '`rank`'); $a_used = array(); foreach ($a_data as $data) { $a_used[] = $data['plugin_fusioninventory_configsecurities_id']; } echo "<div class='firstbloc'>"; echo "<form name='iprange_configsecurity_form{$rand}' id='iprange_configsecurity_form{$rand}' method='post'\n action='" . Toolbox::getItemTypeFormURL('PluginFusioninventoryIPRange_ConfigSecurity') . "' >"; echo "<table class='tab_cadre_fixe'>"; echo "<tr class='tab_bg_2'>"; echo "<th colspan='2'>" . __('Add a SNMP authentication') . "</th>"; echo "</tr>"; echo "<tr class='tab_bg_2'>"; echo "<td>"; Dropdown::show('PluginFusioninventoryConfigSecurity', array('used' => $a_used)); echo "</td>"; echo "<td>"; echo Html::hidden('plugin_fusioninventory_ipranges_id', array('value' => $item->getID())); echo "<input type='submit' name='add' value=\"" . _sx('button', 'Associate') . "\" class='submit'>"; echo "</td>"; echo "</tr>"; echo "</table>"; Html::closeForm(); echo "</div>"; // Display list of auth associated with IP range $rand = mt_rand(); echo "<div class='spaced'>"; Html::openMassiveActionsForm('mass' . __CLASS__ . $rand); $massiveactionparams = array('container' => 'mass' . __CLASS__ . $rand); Html::showMassiveActions($massiveactionparams); echo "<table class='tab_cadre_fixe'>"; echo "<tr class='tab_bg_2'>"; echo "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand) . "</th>"; echo "<th>"; echo __('SNMP Authentication', 'fusioninventory'); echo "</th>"; echo "<th>"; echo __('Version', 'fusioninventory'); echo "</th>"; echo "<th>"; echo __('Rank'); echo "</th>"; echo "</tr>"; $pfConfigSecurity = new PluginFusioninventoryConfigSecurity(); foreach ($a_data as $data) { echo "<tr class='tab_bg_2'>"; echo "<td>"; Html::showMassiveActionCheckBox(__CLASS__, $data["id"]); echo "</td>"; echo "<td>"; $pfConfigSecurity->getFromDB($data['plugin_fusioninventory_configsecurities_id']); echo $pfConfigSecurity->getLink(); echo "</td>"; echo "<td>"; echo $pfConfigSecurity->getSNMPVersion($pfConfigSecurity->fields['snmpversion']); echo "</td>"; echo "<td>"; echo $data['rank']; echo "</td>"; echo "</tr>"; } echo "</table>"; $massiveactionparams['ontop'] = false; Html::showMassiveActions($massiveactionparams); echo "</div>"; }