. @package archires @author Nelly Mahu-Lasson, Xavier Caillaud @copyright Copyright (c) 2016-2018 Archires plugin 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.glpi-project.org/projects/archires @since version 2.2 -------------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { die("Sorry. You can't access directly to this file"); } class PluginArchiresNetworkInterfaceColor extends CommonDBTM { static $rightname = "plugin_archires"; function getFromDBbyNetworkInterface($networkinterfaces_id) { global $DB; $query = ['FROM' => $this->getTable(), 'WHERE' => ['networkinterfaces_id' => $networkinterfaces_id]]; if ($result = $DB->request($query)) { if (count($result) != 1) { return false; } $this->fields = $result->next(); if (is_array($this->fields) && count($this->fields)) { return true; } } return false; } function addNetworkInterfaceColor($networkinterfaces_id,$color) { global $DB; if ($networkinterfaces_id != '-1') { if ($this->getFromDBbyNetworkInterface($networkinterfaces_id)) { $this->update(['id' => $this->fields['id'], 'color' => $color]); } else { $this->add(['networkinterfaces_id' => $networkinterfaces_id, 'color' => $color]); } } else { $query = ['FROM' => 'glpi_networkinterfaces']; $result = $DB->request($query); $i = 0; while ($i < count($result)) { $row = $result->next(); $networkinterface_table = $rox['id']; if ($this->getFromDBbyNetworkInterface($networkinterface_table)) { $this->update(['id' => $this->fields['id'], 'color' => $color]); } else { $this->add(['networkinterfaces_id' => $networkinterface_table, 'color' => $color]); } $i++; } } } function showConfigForm($canupdate=false) { global $DB; if ($canupdate) { echo "
| "; Html::getCheckAllAsCheckbox('mass'.__CLASS__.$rand); echo " | "; } echo "".__('Type of network', 'archires')." | "; echo "".__('Color', 'archires')." | "; echo " |
|---|---|---|---|
| "; Html::showMassiveActionCheckBox(__CLASS__, $ID); echo " | "; } echo "".Dropdown::getDropdownName("glpi_networkinterfaces", $ligne["networkinterfaces_id"])." | <"; echo "td bgcolor='".$ligne["color"]."'>".$ligne["color"].""; } echo "