. * --------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { die("Sorry. You can't access this file directly"); } class DomainRelation extends CommonDropdown { const BELONGS = 1; const MANAGE = 2; // From CommonDBTM public $dohistory = true; static $rightname = 'domain'; static public $knowrelations = [ [ 'id' => self::BELONGS, 'name' => 'Belongs', 'comment' => 'Item belongs to domain' ], [ 'id' => self::MANAGE, 'name' => 'Manage', 'comment' => 'Item manages domain' ] ]; static function getTypeName($nb = 0) { return _n('Domain relation', 'Domains relations', $nb); } function defineTabs($options = []) { $ong = []; $this->addDefaultFormTab($ong); $this->addStandardTab('Domain_Item', $ong, $options); $this->addStandardTab('Log', $ong, $options); return $ong; } /** * Print the form * * @param $ID integer ID of the item * @param $options array of possible options: * - target for the Form * - withtemplate : template or basic item * * @return void **/ function showForm($ID, $options = []) { $rowspan = 3; if ($ID > 0) { $rowspan++; } $this->initForm($ID, $options); $this->showFormHeader($options); echo ""; echo "".__('Name').""; echo ""; Html::autocompletionTextField($this, "name"); echo ""; echo "" . __('Comments').""; echo " "; echo ""; $this->showFormButtons($options); return true; } public static function getDefaults() { return array_map( function($e) { $e['is_recursive'] = 1; return $e; }, self::$knowrelations ); } public function pre_deleteItem() { if (in_array([self::BELONGS, self::MANAGE], $this->fields['id'])) { //keep defaults return false; } return true; } }