grthtrhthjhtyjytjytkergtrhtrjytjerhrfh4:24 29/09/2026. -------------------------------------------------------------------------- */ /** @file * @since version 9.1 */ class APIClient extends CommonDBTM { const DOLOG_DISABLED = 0; const DOLOG_LOGS = 1; const DOLOG_HISTORICAL = 2; static $rightname = 'config'; // From CommonDBTM public $dohistory = true; static function canCreate() { return Session::haveRight(static::$rightname, UPDATE); } static function canPurge() { return Session::haveRight(static::$rightname, UPDATE); } static function getTypeName($nb = 0) { return _n("API client", "API clients", $nb); } /** * @see CommonGLPI::defineTabs() **/ function defineTabs($options=array()) { $ong = array(); $this->addDefaultFormTab($ong) ->addStandardTab('Log', $ong, $options); return $ong; } function getSearchOptions() { $tab = array(); $tab['common'] = self::GetTypeName(); $tab[1]['table'] = $this->getTable(); $tab[1]['field'] = 'name'; $tab[1]['name'] = __('Name'); $tab[1]['datatype'] = 'itemlink'; $tab[2]['table'] = $this->getTable(); $tab[2]['field'] = 'id'; $tab[2]['name'] = __('ID'); $tab[2]['massiveaction'] = false; $tab[2]['datatype'] = 'number'; $tab[3]['table'] = $this->getTable(); $tab[3]['field'] = 'is_active'; $tab[3]['name'] = __('Active'); $tab[3]['datatype'] = 'bool'; $tab[4]['table'] = $this->getTable(); $tab[4]['field'] = 'dolog_method'; $tab[4]['name'] = __('Log connections'); $tab[4]['datatype'] = 'specific'; $tab['filter'] = __("Filter access"); $tab[5]['table'] = $this->getTable(); $tab[5]['field'] = 'ipv4_range_start'; $tab[5]['name'] = __('IPv4 address range')." - ".__("Start"); $tab[5]['datatype'] = 'specific'; $tab[6]['table'] = $this->getTable(); $tab[6]['field'] = 'ipv4_range_end'; $tab[6]['name'] = __('IPv4 address range')." - ".__("End"); $tab[6]['datatype'] = 'specific'; $tab[7]['table'] = $this->getTable(); $tab[7]['field'] = 'ipv6'; $tab[7]['name'] = __('IPv6 address'); $tab[7]['datatype'] = 'text'; $tab[8]['table'] = $this->getTable(); $tab[8]['field'] = 'app_token'; $tab[8]['name'] = __('Application token'); $tab[8]['massiveaction'] = false; $tab[8]['datatype'] = 'text'; return $tab; } static function getSpecificValueToDisplay($field, $values, array $options=array()) { switch ($field) { case 'dolog_method' : $methods = self::getLogMethod(); return $methods[$values[$field]]; case 'ipv4_range_start': case 'ipv4_range_end': return long2ip($values[$field]); } return parent::getSpecificValueToDisplay($field, $values, $options); } function showForm ($ID, $options=array()) { $this->initForm($ID, $options); $this->showFormHeader($options); echo "