. @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 PluginArchiresView extends CommonDBTM { static $rightname = "plugin_archires"; const PLUGIN_ARCHIRES_NETWORK_COLOR = 0; const PLUGIN_ARCHIRES_VLAN_COLOR = 1; const PLUGIN_ARCHIRES_JPEG_FORMAT = 0; const PLUGIN_ARCHIRES_PNG_FORMAT = 1; const PLUGIN_ARCHIRES_GIF_FORMAT = 2; const PLUGIN_ARCHIRES_SVG_FORMAT = 3; static function getTypeName($nb=0) { return _n('View', 'Views', $nb); } function rawSearchOptions() { $tab = []; $tab[] = ['id' => 'common', 'name' => self::getTypeName(2)]; $tab[] = ['id' => '1', 'table' => $this->getTable(), 'field' =>'name', 'name' => __('Name'), 'datatype' => 'itemlink', 'itemlink_type' => $this->getType()]; $tab[] = ['id' => '2', 'table' => $this->getTable(), 'field' => 'computer', 'name' => _n('Computer', 'Computers', 2), 'datatype' => 'bool']; $tab[] = ['id' => '3', 'table' => $this->getTable(), 'field' => 'networking', 'name' => _n('Network equipment', 'Network equipments', 2, 'archires'), 'datatype' => 'bool']; $tab[] = ['id' => '4', 'table' => $this->getTable(), 'field' => 'printer', 'name' => _n('Printer', 'Printers', 2), 'datatype' => 'bool']; $tab[] = ['id' => '5', 'table' => $this->getTable(), 'field' => 'peripheral', 'name' => _n('Device', 'Devices', 2), 'datatype' => 'bool']; $tab[] = ['id' => '6', 'table' => $this->getTable(), 'field' => 'phone', 'name' => _n('Phone', 'Phones', 2), 'datatype' => 'bool']; $tab[] = ['id' => '7', 'table' => $this->getTable(), 'field' => 'display_ports', 'name' => __('Display sockets', 'archires'), 'datatype' => 'text']; $tab[] = ['id' => '8', 'table' => $this->getTable(), 'field' => 'display_ip', 'name' => __('Display IP/Mask', 'archires'), 'datatype' => 'bool']; $tab[] = ['id' => '9', 'table' => $this->getTable(), 'field' => 'display_type', 'name' => __('Display item types', 'archires'), 'datatype' => 'bool']; $tab[] = ['id' => '10', 'table' => $this->getTable(), 'field' => 'display_state', 'name' => __('Display item statuses', 'archires'), 'datatype' => 'bool']; $tab[] = ['id' => '11', 'table' => $this->getTable(), 'field' => 'display_location', 'name' => __('Display item locations', 'archires'), 'datatype' => 'bool']; $tab[] = ['id' => '12', 'table' => $this->getTable(), 'field' => 'display_entity', 'name' => __('Display item entities', 'archires'), 'datatype' => 'bool']; $tab[] = ['id' => '13', 'table' => $this->getTable(), 'field' => 'engine', 'name' => __('Rendering engine', 'archires')]; $tab[] = ['id' => '14', 'table' => $this->getTable(), 'field' => 'format', 'name' => __('Image format', 'archires')]; $tab[] = ['id' => '15', 'table' => $this->getTable(), 'field' => 'color', 'name' => __('Color', 'archires')]; return $tab; } function dropdownObject($obj) { global $DB; $dbu = new DbUtils(); $ID = $obj->fields["id"]; $query = ['SELECT' => ['id', 'name'], 'FROM' => $obj->getTable(), 'WHERE' => ['is_deleted' => 0]]; // Add Restrict to current entities if ($obj->isEntityAssign()) { $query['WHERE'] += $dbu->getEntitiesRestrictCriteria($obj->getTable()); } $query['ORDER'] = 'name ASC'; if ($result = $DB->request($query)) { if (count($result)) { echo ""; } } } function dropdownView($obj,$default) { global $DB; if (isset($obj->fields["id"])) { $default = $obj->fields["plugin_archires_views_id"]; } $query = ['SELECT' => ['id', 'name'], 'FROM' => $this->getTable(), 'WHERE' => ['is_deleted' => 0, 'entities_id' => $_SESSION["glpiactive_entity"]], 'ORDER' => 'name ASC']; echo ""; } static function linkToAllViews($item) { echo "
"; } function viewSelect($obj,$plugin_archires_views_id,$select=0) { global $CFG_GLPI,$DB; $querytype = get_class($obj); $ID = $obj->fields["id"]; $object_view = $obj->fields["plugin_archires_views_id"]; if (!isset($plugin_archires_views_id)) { $plugin_archires_views_id = $object_view; } if ($select) { // display only echo "