. * ------------------------------------------------------------------------- * @copyright Copyright (C) 2006-2022 by Example plugin team. * @license GPLv2 https://www.gnu.org/licenses/gpl-2.0.html * @link https://github.com/pluginsGLPI/example * ------------------------------------------------------------------------- */ namespace GlpiPlugin\Example; use CommonGLPI; use Html; use Session; class Profile extends \Profile { public function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) { if ( $item instanceof \Profile && $item->getField('id') ) { return self::createTabEntry(__s('Example plugin')); } return ''; } public static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtemplate = 0) { if ($item instanceof self) { $profile = new self(); $profile->showFormExample($item->getID()); } return true; } public function showFormExample(int $profiles_id): void { if (!$this->can($profiles_id, READ)) { return; } echo "
"; $can_edit = Session::haveRight(self::$rightname, UPDATE); if ($can_edit) { echo "
"; } $matrix_options = [ 'canedit' => $can_edit, ]; $rights = [ [ 'itemtype' => Example::class, 'label' => Example::getTypeName(Session::getPluralNumber()), 'field' => Example::$rightname, ], ]; $matrix_options['title'] = self::getTypeName(1); $this->displayRightsChoiceMatrix($rights, $matrix_options); if ($can_edit) { echo "
"; echo Html::hidden('id', ['value' => $profiles_id]); echo Html::submit(_sx('button', 'Save'), ['name' => 'update']); echo "
\n"; Html::closeForm(); } echo '
'; } }