* * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ /** * \file htdocs/custom/netdiag/class/netdiagdevice.class.php * \ingroup netdiag * \brief Klasse für ein im Diagnose-Protokoll gefundenes Gerät */ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; /** * Klasse NetDiagDevice — ein im Netzwerk gefundenes Gerät. */ class NetDiagDevice extends CommonObject { /** @var string Modul-Name */ public $module = 'netdiag'; /** @var string Element-Typ */ public $element = 'netdiagdevice'; /** @var string Datenbanktabelle (ohne Präfix) */ public $table_element = 'netdiag_device'; /** @var string Icon */ public $picto = 'fa-desktop'; /** @var int 1 = Tabelle hat ein 'entity'-Feld */ public $ismultientitymanaged = 1; /** * @var array> Felddefinitionen */ public $fields = array( 'rowid' => array('type' => 'integer', 'label' => 'TechnicalID', 'enabled' => 1, 'visible' => 0, 'notnull' => 1, 'index' => 1, 'position' => 1), 'entity' => array('type' => 'integer', 'label' => 'Entity', 'enabled' => 1, 'visible' => 0, 'notnull' => 1, 'default' => 1, 'index' => 1, 'position' => 5), 'fk_protocol' => array('type' => 'integer', 'label' => 'Protocol', 'enabled' => 1, 'visible' => 0, 'notnull' => 1, 'index' => 1, 'position' => 10), 'ip' => array('type' => 'varchar(45)', 'label' => 'IpAddress', 'enabled' => 1, 'visible' => 1, 'position' => 20), 'mac' => array('type' => 'varchar(17)', 'label' => 'MacAddress', 'enabled' => 1, 'visible' => 1, 'position' => 25), 'hostname' => array('type' => 'varchar(255)', 'label' => 'Hostname', 'enabled' => 1, 'visible' => 1, 'position' => 30), 'vendor' => array('type' => 'varchar(128)', 'label' => 'Vendor', 'enabled' => 1, 'visible' => 1, 'position' => 35), 'devicetype' => array('type' => 'varchar(64)', 'label' => 'DeviceType', 'enabled' => 1, 'visible' => 1, 'position' => 40), 'note' => array('type' => 'text', 'label' => 'Note', 'enabled' => 1, 'visible' => 3, 'position' => 50), 'date_creation' => array('type' => 'datetime', 'label' => 'DateCreation', 'enabled' => 1, 'visible' => 0, 'notnull' => 1, 'position' => 500), 'tms' => array('type' => 'timestamp', 'label' => 'DateModification', 'enabled' => 1, 'visible' => 0, 'notnull' => 1, 'position' => 501), ); public $rowid; public $entity; public $fk_protocol; public $ip; public $mac; public $hostname; public $vendor; public $devicetype; public $note; public $date_creation; public $tms; /** * Konstruktor * * @param DoliDB $db Datenbank-Handler */ public function __construct(DoliDB $db) { $this->db = $db; } /** * Datensatz anlegen * * @param User $user Benutzer * @param int $notrigger 1 = Trigger unterdrücken * @return int >0 wenn OK, <=0 bei Fehler */ public function create(User $user, $notrigger = 0) { return $this->createCommon($user, $notrigger); } /** * Datensatz laden * * @param int $id Rowid * @param string $ref Referenz * @return int >0 wenn OK, 0 wenn nicht gefunden, <0 bei Fehler */ public function fetch($id, $ref = null) { return $this->fetchCommon($id, $ref); } /** * Alle Geräte eines Protokolls laden * * @param int $fk_protocol Protokoll-Rowid * @return NetDiagDevice[] Liste der Geräte */ public function fetchAllByProtocol($fk_protocol) { $result = array(); $sql = "SELECT rowid FROM ".$this->db->prefix().$this->table_element; $sql .= " WHERE fk_protocol = ".((int) $fk_protocol); $sql .= " ORDER BY INET_ATON(ip), rowid"; $resql = $this->db->query($sql); if ($resql) { while ($obj = $this->db->fetch_object($resql)) { $dev = new self($this->db); if ($dev->fetch((int) $obj->rowid) > 0) { $result[] = $dev; } } } return $result; } /** * Datensatz aktualisieren * * @param User $user Benutzer * @param int $notrigger 1 = Trigger unterdrücken * @return int >0 wenn OK, <=0 bei Fehler */ public function update(User $user, $notrigger = 0) { return $this->updateCommon($user, $notrigger); } /** * Datensatz löschen * * @param User $user Benutzer * @param int $notrigger 1 = Trigger unterdrücken * @return int >0 wenn OK, <=0 bei Fehler */ public function delete(User $user, $notrigger = 0) { return $this->deleteCommon($user, $notrigger); } }