. * * ------------------------------------------------------------------------ * * This file is used to manage SNMP credentials associated with IP ranges. * * ------------------------------------------------------------------------ * * @package FusionInventory * @author David Durieux * @copyright Copyright (c) 2010-2016 FusionInventory team * @license AGPL License 3.0 or (at your option) any later version * http://www.gnu.org/licenses/agpl-3.0-standalone.html * @link http://www.fusioninventory.org/ * @link https://github.com/fusioninventory/fusioninventory-for-glpi * */ if (!defined('GLPI_ROOT')) { die("Sorry. You can't access directly to this file"); } /** * Manage SNMP credentials associated with IP ranges. */ class PluginFusioninventoryIPRange_ConfigSecurity extends CommonDBRelation { /** * Itemtype for the first part of relation * * @var string */ static public $itemtype_1 = 'PluginFusioninventoryIPRange'; /** * id field name for the first part of relation * * @var string */ static public $items_id_1 = 'plugin_fusioninventory_ipranges_id'; /** * Restrict the first item to the current entity * * @var string */ static public $take_entity_1 = true; /** * Itemtype for the second part of relation * * @var string */ static public $itemtype_2 = 'PluginFusioninventoryConfigSecurity'; /** * id field name for the second part of relation * * @var string */ static public $items_id_2 = 'plugin_fusioninventory_configsecurities_id'; /** * Not restrict the second item to the current entity * * @var string */ static public $take_entity_2 = false; /** * Get the tab name used for item * * @param object $item the item object * @param integer $withtemplate 1 if is a template form * @return string name of the tab */ function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) { if ($item->fields['id'] > 0) { return __('Associated SNMP credentials', 'fusioninventory'); } return ''; } /** * Display the content of the tab * * @param object $item * @param integer $tabnum number of the tab to display * @param integer $withtemplate 1 if is a template form * @return true */ static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtemplate = 0) { $pfIPRange_ConfigSecurity = new self(); $pfIPRange_ConfigSecurity->showForm($item); return true; } /** * Get standard massive action forbidden (hide in massive action list) * * @return array */ function getForbiddenStandardMassiveAction() { $forbidden = parent::getForbiddenStandardMassiveAction(); $forbidden[] = 'update'; return $forbidden; } /** * Display form * * @param object $item * @param array $options * @return boolean */ function showForm(CommonDBTM $item, $options = []) { $ID = $item->getField('id'); if ($item->isNewID($ID)) { return false; } if (!$item->can($item->fields['id'], READ)) { return false; } $rand = mt_rand(); $a_data = getAllDataFromTable('glpi_plugin_fusioninventory_ipranges_configsecurities', ['plugin_fusioninventory_ipranges_id' => $item->getID()], false, '`rank`'); $a_used = []; foreach ($a_data as $data) { $a_used[] = $data['plugin_fusioninventory_configsecurities_id']; } echo "
"; echo "
"; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo "
".__('Add SNMP credentials')."
"; Dropdown::show('PluginFusioninventoryConfigSecurity', ['used' => $a_used]); echo ""; echo Html::hidden('plugin_fusioninventory_ipranges_id', ['value' => $item->getID()]); echo ""; echo "
"; Html::closeForm(); echo "
"; // Display list of auth associated with IP range $rand = mt_rand(); echo "
"; Html::openMassiveActionsForm('mass'.__CLASS__.$rand); $massiveactionparams = ['container' => 'mass'.__CLASS__.$rand]; Html::showMassiveActions($massiveactionparams); echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; $pfConfigSecurity = new PluginFusioninventoryConfigSecurity(); foreach ($a_data as $data) { echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; } echo "
".Html::getCheckAllAsCheckbox('mass'.__CLASS__.$rand).""; echo __('SNMP credentials', 'fusioninventory'); echo ""; echo __('Version', 'fusioninventory'); echo ""; echo __('By order of priority', 'fusioninventory'); echo "
"; Html::showMassiveActionCheckBox(__CLASS__, $data["id"]); echo ""; $pfConfigSecurity->getFromDB($data['plugin_fusioninventory_configsecurities_id']); echo $pfConfigSecurity->getLink(); echo ""; echo $pfConfigSecurity->getSNMPVersion($pfConfigSecurity->fields['snmpversion']); echo ""; echo $data['rank']; echo "
"; $massiveactionparams['ontop'] =false; Html::showMassiveActions($massiveactionparams); echo "
"; return true; } }