. * * ------------------------------------------------------------------------ * * This file is used to manage the IP ranges for network discovery and * network inventory. * * ------------------------------------------------------------------------ * * @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 the IP ranges for network discovery and network inventory. */ class PluginFusioninventoryIPRange extends CommonDBTM { /** * We activate the history. * * @var boolean */ public $dohistory = true; /** * The right name for this class * * @var string */ static $rightname = 'plugin_fusioninventory_iprange'; /** * Check if can create an IP range * * @return true */ static function canCreate() { return true; } /** * Get name of this type by language of the user connected * * @param integer $nb number of elements * @return string name of this type */ static function getTypeName($nb = 0) { if (isset($_SERVER['HTTP_REFERER']) AND strstr($_SERVER['HTTP_REFERER'], 'iprange')) { if ((isset($_POST['glpi_tab'])) AND ($_POST['glpi_tab'] == 1)) { // Permanent task discovery return __('Communication mode', 'fusioninventory'); } else if ((isset($_POST['glpi_tab'])) AND ($_POST['glpi_tab'] == 2)) { // Permanent task inventory return __('See all informations of task', 'fusioninventory'); } else { return __('IP Ranges', 'fusioninventory'); } } return __('IP Ranges', 'fusioninventory'); } /** * Get comments of the object * * @return string comments in HTML format */ function getComments() { $comment = $this->fields['ip_start']." -> ".$this->fields['ip_end']; return Html::showToolTip($comment, ['display' => false]); } /** * Get search function for the class * * @return array */ function rawSearchOptions() { $tab = []; $tab[] = [ 'id' => 'common', 'name' => __('IP range configuration', 'fusioninventory') ]; $tab[] = [ 'id' => '1', 'table' => $this->getTable(), 'field' => 'name', 'name' => __('Name'), 'datatype' => 'itemlink', 'autocomplete' => true, ]; $tab[] = [ 'id' => '2', 'table' => 'glpi_entities', 'field' => 'completename', 'linkfield' => 'entities_id', 'name' => Entity::getTypeName(1), 'datatype' => 'dropdown', ]; $tab[] = [ 'id' => '3', 'table' => $this->getTable(), 'field' => 'ip_start', 'name' => __('Start of IP range', 'fusioninventory'), ]; $tab[] = [ 'id' => '4', 'table' => $this->getTable(), 'field' => 'ip_end', 'name' => __('End of IP range', 'fusioninventory'), ]; $tab[] = [ 'id' => '5', 'table' => 'glpi_plugin_fusioninventory_configsecurities', 'field' => 'name', 'datatype' => 'dropdown', 'right' => 'all', 'name' => __('SNMP credentials', 'fusioninventory'), 'forcegroupby' => true, 'massiveaction' => false, 'joinparams' => [ 'beforejoin' => [ 'table' => "glpi_plugin_fusioninventory_ipranges_configsecurities", 'joinparams' => [ 'jointype' => 'child', ], ], ], ]; return $tab; } /** * Define tabs to display on form page * * @param array $options * @return array containing the tabs name */ function defineTabs($options = []) { $ong = []; $this->addDefaultFormTab($ong); $ong[$this->getType().'$task'] = _n('Task', 'Tasks', 2); $this->addStandardTab('Log', $ong, $options); return $ong; } /** * 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 boolean */ static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtemplate = 0) { if ($tabnum == 'task') { $pfTask = new PluginFusioninventoryTask(); $pfTask->showJobLogs(); return true; } return false; } /** * Display form * * @param integer $id * @param array $options * @return true */ function showForm($id, $options = []) { $this->initForm($id, $options); $this->showFormHeader($options); echo "