diff --git a/.phpstan-baseline.php b/.phpstan-baseline.php index 57045dfdad4..f9973d74fab 100644 --- a/.phpstan-baseline.php +++ b/.phpstan-baseline.php @@ -2287,18 +2287,6 @@ 'count' => 1, 'path' => __DIR__ . '/src/Glpi/Form/Section.php', ]; -$ignoreErrors[] = [ - // identifier: classConstant.nonObject - 'message' => '#^Cannot access constant class on Glpi\\\\Asset\\\\AssetModel\\|false\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/src/Glpi/Http/LegacyDropdownRouteListener.php', -]; -$ignoreErrors[] = [ - // identifier: classConstant.nonObject - 'message' => '#^Cannot access constant class on Glpi\\\\Asset\\\\AssetType\\|false\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/src/Glpi/Http/LegacyDropdownRouteListener.php', -]; $ignoreErrors[] = [ // identifier: booleanNot.alwaysFalse 'message' => '#^Negated boolean expression is always false\\.$#', diff --git a/CHANGELOG.md b/CHANGELOG.md index b4ee4d9b477..738c175eb7c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -322,6 +322,7 @@ The present file will list all changes made to the project; according to the - `CommonDBTM::getSNMPCredential()` - `CommonDBTM::showDebugInfo()` - `CommonDevice::title()` +- `CommonDropdown::$first_level_menu`, `CommonDropdown::$second_level_menu` and `CommonDropdown::$third_level_menu` properties. - `CommonDropdown::displayHeader()` - `CommonGLPI::$type` property. - `CommonGLPI::getAvailableDisplayOptions()` diff --git a/front/agent.form.php b/front/agent.form.php index eab74a3a281..4b806cb3063 100644 --- a/front/agent.form.php +++ b/front/agent.form.php @@ -102,7 +102,7 @@ ); Html::back(); } else {//print agent information - $menus = ["admin", "glpi\inventory\inventory", "agent"]; + $menus = ["admin", "glpi\inventory\inventory", "Agent"]; Agent::displayFullPageForItem((int) $_GET['id'], $menus, [ 'withtemplate' => $_GET["withtemplate"], 'formoptions' => "data-track-changes=true", diff --git a/front/agent.php b/front/agent.php deleted file mode 100644 index 229df7dc38e..00000000000 --- a/front/agent.php +++ /dev/null @@ -1,42 +0,0 @@ -. - * - * --------------------------------------------------------------------- - */ - -Session::checkRight("agent", READ); - -Html::header(Agent::getTypeName(Session::getPluralNumber()), $_SERVER['PHP_SELF'], "admin", "glpi\inventory\inventory", "agent"); - -Search::show('Agent'); - -Html::footer(); diff --git a/front/allassets.php b/front/allassets.php deleted file mode 100644 index 941b84a6234..00000000000 --- a/front/allassets.php +++ /dev/null @@ -1,48 +0,0 @@ -. - * - * --------------------------------------------------------------------- - */ - -/** - * Filename was previously states.php - * @since 0.84 - */ - -Session::checkCentralAccess(); - -Html::header(__('Global'), $_SERVER['PHP_SELF'], "assets", "allassets"); - -Search::show(AllAssets::getType()); - - -Html::footer(); diff --git a/front/apiclient.form.php b/front/apiclient.form.php index 9d301cb9a42..29259934120 100644 --- a/front/apiclient.form.php +++ b/front/apiclient.form.php @@ -82,6 +82,6 @@ ); Html::redirect($CFG_GLPI["root_doc"] . "/front/config.form.php"); } else { - $menus = ["config", "config", "apiclient"]; + $menus = ["config", "config", "APIClient"]; APIClient::displayFullPageForItem($_GET["id"], $menus); } diff --git a/front/appliance.php b/front/appliance.php deleted file mode 100644 index 279b4f6f3fe..00000000000 --- a/front/appliance.php +++ /dev/null @@ -1,42 +0,0 @@ -. - * - * --------------------------------------------------------------------- - */ - -Session::checkRight('appliance', READ); - -Html::header(Appliance::getTypeName(Session::getPluralNumber()), $_SERVER['PHP_SELF'], "management", "appliance"); - -Search::show('Appliance'); - -Html::footer(); diff --git a/front/asset/asset.php b/front/asset/asset.php deleted file mode 100644 index 45a7f6cc2af..00000000000 --- a/front/asset/asset.php +++ /dev/null @@ -1,55 +0,0 @@ -. - * - * --------------------------------------------------------------------- - */ - -use Glpi\Asset\AssetDefinition; -use Glpi\Exception\Http\BadRequestHttpException; -use Glpi\Search\SearchEngine; - -$definition = new AssetDefinition(); -$classname = array_key_exists('class', $_GET) && $definition->getFromDBBySystemName((string)$_GET['class']) - ? $definition->getAssetClassName() - : null; - -if ($classname === null || !class_exists($classname)) { - throw new BadRequestHttpException('Bad request'); -} - -Session::checkRightsOr($classname::$rightname, [READ, READ_ASSIGNED, READ_OWNED]); - -Html::header($classname::getTypeName(Session::getPluralNumber()), $_SERVER['PHP_SELF'], 'assets', $classname); - -SearchEngine::show($classname); - -Html::footer(); diff --git a/front/asset/assetdefinition.php b/front/asset/assetdefinition.php deleted file mode 100644 index 45b516e4b36..00000000000 --- a/front/asset/assetdefinition.php +++ /dev/null @@ -1,49 +0,0 @@ -. - * - * --------------------------------------------------------------------- - */ - -use Glpi\Asset\AssetDefinition; - -Session::checkRight(AssetDefinition::$rightname, READ); - -Html::header( - AssetDefinition::getTypeName(Session::getPluralNumber()), - $_SERVER['PHP_SELF'], - 'config', - AssetDefinition::class -); - -Search::show(AssetDefinition::class); - -Html::footer(); diff --git a/front/authldap.form.php b/front/authldap.form.php index c730f98faa6..df968919911 100644 --- a/front/authldap.form.php +++ b/front/authldap.form.php @@ -81,5 +81,5 @@ Html::back(); } -$menus = ['config', 'auth', 'ldap']; +$menus = ['config', 'auth', 'AuthLDAP']; AuthLDAP::displayFullPageForItem($_GET['id'], $menus, $_GET); diff --git a/front/authldap.php b/front/authldap.php deleted file mode 100644 index 12d56b3a2b8..00000000000 --- a/front/authldap.php +++ /dev/null @@ -1,42 +0,0 @@ -. - * - * --------------------------------------------------------------------- - */ - -Session::checkRight("config", READ); - -Html::header(AuthLDAP::getTypeName(Session::getPluralNumber()), $_SERVER['PHP_SELF'], 'config', 'auth', 'ldap'); - -Search::show('AuthLDAP'); - -Html::footer(); diff --git a/front/authmail.form.php b/front/authmail.form.php index d55a05a7b7a..04da1a64a4f 100644 --- a/front/authmail.form.php +++ b/front/authmail.form.php @@ -69,5 +69,5 @@ Html::back(); } -$menus = ["config", "auth", "imap"]; +$menus = ["config", "auth", "AuthMail"]; AuthMail::displayFullPageForItem($_GET['id'], $menus); diff --git a/front/authmail.php b/front/authmail.php deleted file mode 100644 index ff2b3c65fbd..00000000000 --- a/front/authmail.php +++ /dev/null @@ -1,42 +0,0 @@ -. - * - * --------------------------------------------------------------------- - */ - -Session::checkRight("config", UPDATE); - -Html::header(AuthMail::getTypeName(Session::getPluralNumber()), $_SERVER['PHP_SELF'], "config", "auth", "imap"); - -Search::show('AuthMail'); - -Html::footer(); diff --git a/front/cable.php b/front/cable.php deleted file mode 100644 index 8eb43bb4cef..00000000000 --- a/front/cable.php +++ /dev/null @@ -1,42 +0,0 @@ -. - * - * --------------------------------------------------------------------- - */ - -Session::checkRight("cable_management", READ); - -Html::header(Cable::getTypeName(1), $_SERVER['PHP_SELF'], "assets", "cable"); - -Search::show('Cable'); - -Html::footer(); diff --git a/front/cartridgeitem.php b/front/cartridgeitem.php deleted file mode 100644 index 48a85c54086..00000000000 --- a/front/cartridgeitem.php +++ /dev/null @@ -1,42 +0,0 @@ -. - * - * --------------------------------------------------------------------- - */ - -Session::checkRightsOr(Cartridge::$rightname, [READ, READ_ASSIGNED, READ_OWNED]); - -Html::header(Cartridge::getTypeName(Session::getPluralNumber()), $_SERVER['PHP_SELF'], "assets", "cartridgeitem"); - -Search::show('CartridgeItem'); - -Html::footer(); diff --git a/front/certificate.php b/front/certificate.php deleted file mode 100644 index 0a3ad5b6d05..00000000000 --- a/front/certificate.php +++ /dev/null @@ -1,47 +0,0 @@ -. - * - * --------------------------------------------------------------------- - */ - -Session::checkRight("certificate", READ); - -Html::header( - Certificate::getTypeName(Session::getPluralNumber()), - $_SERVER['PHP_SELF'], - 'management', - 'certificate' -); - -Search::show('Certificate'); - -Html::footer(); diff --git a/front/change.php b/front/change.php deleted file mode 100644 index 9795c42b593..00000000000 --- a/front/change.php +++ /dev/null @@ -1,42 +0,0 @@ -. - * - * --------------------------------------------------------------------- - */ - -Session::checkRightsOr('change', [Change::READALL, Change::READMY]); - -Html::header(Change::getTypeName(Session::getPluralNumber()), '', "helpdesk", "change"); - -Search::show('Change'); - -Html::footer(); diff --git a/front/cluster.php b/front/cluster.php deleted file mode 100644 index edc19830b4d..00000000000 --- a/front/cluster.php +++ /dev/null @@ -1,42 +0,0 @@ -. - * - * --------------------------------------------------------------------- - */ - -Session::checkRight("cluster", READ); - -Html::header(Cluster::getTypeName(Session::getPluralNumber()), $_SERVER['PHP_SELF'], "management", "cluster"); - -Search::show('Cluster'); - -Html::footer(); diff --git a/front/computer.php b/front/computer.php deleted file mode 100644 index 5951c8b6783..00000000000 --- a/front/computer.php +++ /dev/null @@ -1,42 +0,0 @@ -. - * - * --------------------------------------------------------------------- - */ - -Session::checkRightsOr(Computer::$rightname, [READ, READ_ASSIGNED, READ_OWNED]); - -Html::header(Computer::getTypeName(Session::getPluralNumber()), $_SERVER['PHP_SELF'], "assets", "computer"); - -Search::show('Computer'); - -Html::footer(); diff --git a/front/contact.php b/front/contact.php deleted file mode 100644 index 5592f757010..00000000000 --- a/front/contact.php +++ /dev/null @@ -1,42 +0,0 @@ -. - * - * --------------------------------------------------------------------- - */ - -Session::checkRight("contact_enterprise", READ); - -Html::header(Contact::getTypeName(Session::getPluralNumber()), $_SERVER['PHP_SELF'], "management", "contact"); - -Search::show('Contact'); - -Html::footer(); diff --git a/front/contract.php b/front/contract.php deleted file mode 100644 index 51220b90713..00000000000 --- a/front/contract.php +++ /dev/null @@ -1,42 +0,0 @@ -. - * - * --------------------------------------------------------------------- - */ - -Session::checkRight("contract", READ); - -Html::header(Contract::getTypeName(Session::getPluralNumber()), $_SERVER['PHP_SELF'], "management", "contract"); - -Search::show('Contract'); - -Html::footer(); diff --git a/front/crontask.php b/front/crontask.php deleted file mode 100644 index 1671b5dcf97..00000000000 --- a/front/crontask.php +++ /dev/null @@ -1,49 +0,0 @@ -. - * - * --------------------------------------------------------------------- - */ - -/** - * Search engine from cron tasks - */ - -/** @var array $CFG_GLPI */ -global $CFG_GLPI; - -Session::checkRight("config", UPDATE); - -Html::header(CronTask::getTypeName(Session::getPluralNumber()), $_SERVER['PHP_SELF'], 'config', 'crontask'); - -Search::show('CronTask'); - -Html::footer(); diff --git a/front/database.php b/front/database.php deleted file mode 100644 index dc9654161a9..00000000000 --- a/front/database.php +++ /dev/null @@ -1,42 +0,0 @@ -. - * - * --------------------------------------------------------------------- - */ - -Session::checkRight('database', READ); - -Html::header(Database::getTypeName(Session::getPluralNumber()), $_SERVER['PHP_SELF'], "management", "database"); - -Search::show('Database'); - -Html::footer(); diff --git a/front/databaseinstance.form.php b/front/databaseinstance.form.php index 85aee6df0d4..f3e4253d91b 100644 --- a/front/databaseinstance.form.php +++ b/front/databaseinstance.form.php @@ -118,15 +118,7 @@ } Html::back(); } else { - Html::header( - DatabaseInstance::getTypeName(Session::getPluralNumber()), - $_SERVER['PHP_SELF'], - "management", - "database", - "databaseinstance" - ); - - $menus = ["database", "databaseinstance"]; + $menus = ["management", "database", "DatabaseInstance"]; DatabaseInstance::displayFullPageForItem($_GET['id'], $menus, [ 'withtemplate' => $_GET['withtemplate'] ]); diff --git a/front/databaseinstance.php b/front/databaseinstance.php deleted file mode 100644 index a7a0f7378c9..00000000000 --- a/front/databaseinstance.php +++ /dev/null @@ -1,42 +0,0 @@ -. - * - * --------------------------------------------------------------------- - */ - -Session::checkRight('database', READ); - -Html::header(DatabaseInstance::getTypeName(Session::getPluralNumber()), $_SERVER['PHP_SELF'], "management", "database", "databaseinstance"); - -Search::show('DatabaseInstance'); - -Html::footer(); diff --git a/front/datacenter.php b/front/datacenter.php deleted file mode 100644 index 83474e11746..00000000000 --- a/front/datacenter.php +++ /dev/null @@ -1,42 +0,0 @@ -. - * - * --------------------------------------------------------------------- - */ - -Session::checkRight("datacenter", READ); - -Html::header(Datacenter::getTypeName(Session::getPluralNumber()), $_SERVER['PHP_SELF'], "management", "datacenter"); - -Search::show('Datacenter'); - -Html::footer(); diff --git a/front/dcroom.form.php b/front/dcroom.form.php index 3cf7dad2fd9..b785f2633bb 100644 --- a/front/dcroom.form.php +++ b/front/dcroom.form.php @@ -127,6 +127,6 @@ $datacenter->getFromDB($options['datacenters_id']); $options['locations_id'] = $datacenter->fields['locations_id']; } - $menus = ["management", "datacenter", "dcroom"]; + $menus = ["management", "datacenter", "DCRoom"]; DCRoom::displayFullPageForItem($_GET["id"], $menus, $options); } diff --git a/front/dcroom.php b/front/dcroom.php deleted file mode 100644 index 5e8b477afda..00000000000 --- a/front/dcroom.php +++ /dev/null @@ -1,42 +0,0 @@ -. - * - * --------------------------------------------------------------------- - */ - -Session::checkRight("datacenter", READ); - -Html::header(DCRoom::getTypeName(Session::getPluralNumber()), $_SERVER['PHP_SELF'], "management", "datacenter", "dcroom"); - -Search::show('DCRoom'); - -Html::footer(); diff --git a/front/defaultfilter.php b/front/defaultfilter.php deleted file mode 100644 index 87020df4b15..00000000000 --- a/front/defaultfilter.php +++ /dev/null @@ -1,48 +0,0 @@ -. - * - * --------------------------------------------------------------------- - */ - -Session::checkRight(DefaultFilter::$rightname, READ); - -Html::header( - DefaultFilter::getTypeName(Session::getPluralNumber()), - $_SERVER['PHP_SELF'], - "config", - "commondropdown", - "DefaultFilter" -); - -Search::show('DefaultFilter'); - -Html::footer(); diff --git a/front/document.php b/front/document.php deleted file mode 100644 index 9654af8b1f1..00000000000 --- a/front/document.php +++ /dev/null @@ -1,42 +0,0 @@ -. - * - * --------------------------------------------------------------------- - */ - -Session::checkRight("document", READ); - -Html::header(Document::getTypeName(Session::getPluralNumber()), $_SERVER['PHP_SELF'], "management", "document"); - -Search::show('Document'); - -Html::footer(); diff --git a/front/domain.php b/front/domain.php deleted file mode 100644 index fedb0d19fcc..00000000000 --- a/front/domain.php +++ /dev/null @@ -1,42 +0,0 @@ -. - * - * --------------------------------------------------------------------- - */ - -Session::checkRight("domain", READ); - -Html::header(Domain::getTypeName(1), $_SERVER['PHP_SELF'], "management", "domain"); - -Search::show('Domain'); - -Html::footer(); diff --git a/front/domainrecord.form.php b/front/domainrecord.form.php index 259c6d0f34d..ef39bfd791b 100644 --- a/front/domainrecord.form.php +++ b/front/domainrecord.form.php @@ -72,7 +72,7 @@ $record->showForm($_GET["id"], ['domains_id' => $_GET['domains_id'] ?? null]); Html::popFooter(); } else { - $menus = ["management", "domain", "domainrecord"]; + $menus = ["management", "domain", "DomainRecord"]; $options = [ 'withtemplate' => $_GET["withtemplate"] ]; diff --git a/front/domainrecord.php b/front/domainrecord.php deleted file mode 100644 index 20a317cd098..00000000000 --- a/front/domainrecord.php +++ /dev/null @@ -1,42 +0,0 @@ -. - * - * --------------------------------------------------------------------- - */ - -Session::checkCentralAccess(); - -Html::header(Domain::getTypeName(Session::getPluralNumber()), $_SERVER['PHP_SELF'], "management", "domain", "domainrecord"); - -Search::show('DomainRecord'); - -Html::footer(); diff --git a/front/dropdown.common.php b/front/dropdown.common.php index 2ed9e03ee99..fe0450854cd 100644 --- a/front/dropdown.common.php +++ b/front/dropdown.common.php @@ -39,8 +39,9 @@ * @var LegacyFileLoadController $this */ -use Glpi\Controller\DropdownController; +use Glpi\Application\View\TemplateRenderer; use Glpi\Controller\LegacyFileLoadController; +use Glpi\Exception\Http\AccessDeniedHttpException; if (!($this instanceof LegacyFileLoadController) || !($dropdown instanceof CommonDropdown)) { throw new LogicException(); @@ -52,4 +53,10 @@ 'glpi_dropdown', )); -DropdownController::loadDropdown($this->request, $dropdown); +if (!$dropdown::canView()) { + throw new AccessDeniedHttpException(); +} + +TemplateRenderer::getInstance()->display('pages/generic_list.html.twig', [ + 'object_class' => $dropdown::class, +]); diff --git a/front/dropdown/dropdowndefinition.php b/front/dropdown/dropdowndefinition.php deleted file mode 100644 index 52ec9e762c2..00000000000 --- a/front/dropdown/dropdowndefinition.php +++ /dev/null @@ -1,50 +0,0 @@ -. - * - * --------------------------------------------------------------------- - */ - -use Glpi\Dropdown\DropdownDefinition; - -Session::checkRight(DropdownDefinition::$rightname, READ); - -Html::header( - DropdownDefinition::getTypeName(Session::getPluralNumber()), - $_SERVER['PHP_SELF'], - 'config', - CommonDropdown::class, - DropdownDefinition::class -); - -Search::show(DropdownDefinition::class); - -Html::footer(); diff --git a/front/enclosure.php b/front/enclosure.php deleted file mode 100644 index 582dc06c6cd..00000000000 --- a/front/enclosure.php +++ /dev/null @@ -1,42 +0,0 @@ -. - * - * --------------------------------------------------------------------- - */ - -Session::checkRight("datacenter", READ); - -Html::header(Enclosure::getTypeName(Session::getPluralNumber()), $_SERVER['PHP_SELF'], "assets", "enclosure"); - -Search::show('Enclosure'); - -Html::footer(); diff --git a/front/event.php b/front/event.php deleted file mode 100644 index ebd7ad37222..00000000000 --- a/front/event.php +++ /dev/null @@ -1,50 +0,0 @@ -. - * - * --------------------------------------------------------------------- - */ - -use Glpi\Event; - -Session::checkRight(Event::$rightname, READ); - -Html::header( - Event::getTypeName(Session::getPluralNumber()), - $_SERVER['PHP_SELF'], - "admin", - "glpi\system\log\logviewer", - "Glpi\\Event" -); - -Search::show(Event::class); - -Html::footer(); diff --git a/front/fieldunicity.php b/front/fieldunicity.php deleted file mode 100644 index a5c8f3fca84..00000000000 --- a/front/fieldunicity.php +++ /dev/null @@ -1,42 +0,0 @@ -. - * - * --------------------------------------------------------------------- - */ - -Session::checkRight('config', READ); - -Html::header(FieldUnicity::getTypeName(Session::getPluralNumber()), $_SERVER['PHP_SELF'], "config", "fieldunicity"); - -Search::show('FieldUnicity'); - -Html::footer(); diff --git a/front/form/form.php b/front/form/form.php deleted file mode 100644 index 084f5201bf6..00000000000 --- a/front/form/form.php +++ /dev/null @@ -1,42 +0,0 @@ -. - * - * --------------------------------------------------------------------- - */ - -use Glpi\Form\Form; - -Session::checkRight(Form::$rightname, READ); - -Html::header(Form::getTypeName(1), $_SERVER['PHP_SELF'], "admin", Form::getType()); -Search::show(Form::getType()); -Html::footer(); diff --git a/front/group.form.php b/front/group.form.php index f1b69d420da..e8902726015 100644 --- a/front/group.form.php +++ b/front/group.form.php @@ -68,8 +68,7 @@ $group->getTypeName(1), $_SERVER['PHP_SELF'], "admin", - "group", - str_replace('glpi_', '', $group->getTable()) + "group" ); $group->showDeleteConfirmForm($_SERVER['PHP_SELF']); diff --git a/front/group.php b/front/group.php deleted file mode 100644 index 817798002ec..00000000000 --- a/front/group.php +++ /dev/null @@ -1,42 +0,0 @@ -. - * - * --------------------------------------------------------------------- - */ - -Session::checkRight("group", READ); - -Html::header(Group::getTypeName(Session::getPluralNumber()), $_SERVER['PHP_SELF'], "admin", "group"); - -Search::show('Group'); - -Html::footer(); diff --git a/front/line.php b/front/line.php deleted file mode 100644 index 407479e0954..00000000000 --- a/front/line.php +++ /dev/null @@ -1,42 +0,0 @@ -. - * - * --------------------------------------------------------------------- - */ - -Session::checkRight("line", READ); - -Html::header(Line::getTypeName(Session::getPluralNumber()), $_SERVER['PHP_SELF'], "management", "line"); - -Search::show('Line'); - -Html::footer(); diff --git a/front/link.php b/front/link.php deleted file mode 100644 index 03c65a7acb7..00000000000 --- a/front/link.php +++ /dev/null @@ -1,42 +0,0 @@ -. - * - * --------------------------------------------------------------------- - */ - -Session::checkRight("link", READ); - -Html::header(Link::getTypeName(Session::getPluralNumber()), $_SERVER['PHP_SELF'], "config", "link"); - -Search::show('Link'); - -Html::footer(); diff --git a/front/lockedfield.form.php b/front/lockedfield.form.php index 372bd330106..19dc6d65ed2 100644 --- a/front/lockedfield.form.php +++ b/front/lockedfield.form.php @@ -88,7 +88,7 @@ ); Html::back(); } else {//print locked field information - $menus = ["admin", "glpi\inventory\inventory", "lockedfield"]; + $menus = ["admin", "glpi\inventory\inventory", "Lockedfield"]; $lockedfield->displayFullPageForItem($_GET['id'], $menus, [ 'formoptions' => "data-track-changes=true" ]); diff --git a/front/lockedfield.php b/front/lockedfield.php deleted file mode 100644 index e239c115818..00000000000 --- a/front/lockedfield.php +++ /dev/null @@ -1,42 +0,0 @@ -. - * - * --------------------------------------------------------------------- - */ - -Session::checkRight("locked_field", CREATE); - -Html::header(Lockedfield::getTypeName(Session::getPluralNumber()), $_SERVER['PHP_SELF'], "admin", "glpi\inventory\inventory", "lockedfield"); - -Search::show('Lockedfield'); - -Html::footer(); diff --git a/front/mailcollector.php b/front/mailcollector.php deleted file mode 100644 index d4daa677c61..00000000000 --- a/front/mailcollector.php +++ /dev/null @@ -1,42 +0,0 @@ -. - * - * --------------------------------------------------------------------- - */ - -Session::checkRight("config", UPDATE); - -Html::header(MailCollector::getTypeName(Session::getPluralNumber()), $_SERVER['PHP_SELF'], "config", "mailcollector"); - -$mailcollector = new MailCollector(); -Search::show('MailCollector'); -Html::footer(); diff --git a/front/monitor.php b/front/monitor.php deleted file mode 100644 index 479af247c38..00000000000 --- a/front/monitor.php +++ /dev/null @@ -1,42 +0,0 @@ -. - * - * --------------------------------------------------------------------- - */ - -Session::checkRightsOr(Monitor::$rightname, [READ, READ_ASSIGNED, READ_OWNED]); - -Html::header(Monitor::getTypeName(Session::getPluralNumber()), $_SERVER['PHP_SELF'], "assets", "monitor"); - -Search::show('Monitor'); - -Html::footer(); diff --git a/front/networkequipment.php b/front/networkequipment.php deleted file mode 100644 index e7c1b2a8904..00000000000 --- a/front/networkequipment.php +++ /dev/null @@ -1,42 +0,0 @@ -. - * - * --------------------------------------------------------------------- - */ - -Session::checkRightsOr(NetworkEquipment::$rightname, [READ, READ_ASSIGNED, READ_OWNED]); - -Html::header(NetworkEquipment::getTypeName(Session::getPluralNumber()), $_SERVER['PHP_SELF'], "assets", "networkequipment"); - -Search::show('NetworkEquipment'); - -Html::footer(); diff --git a/front/networkname.php b/front/networkname.php deleted file mode 100644 index 5c7d6da627d..00000000000 --- a/front/networkname.php +++ /dev/null @@ -1,48 +0,0 @@ -. - * - * --------------------------------------------------------------------- - */ - -Session::checkRight(NetworkName::$rightname, READ); - -Html::header( - NetworkName::getTypeName(Session::getPluralNumber()), - $_SERVER['PHP_SELF'], - 'config', - 'commondropdown', - 'NetworkName' -); - -Search::show('NetworkName'); - -Html::footer(); diff --git a/front/notification.form.php b/front/notification.form.php index 10a691ce1c5..62e688bac5c 100644 --- a/front/notification.form.php +++ b/front/notification.form.php @@ -81,6 +81,6 @@ ); Html::back(); } else { - $menus = ["config", "notification", "notification"]; + $menus = ["config", "notification", "Notification"]; Notification::displayFullPageForItem($_GET["id"], $menus); } diff --git a/front/notification.php b/front/notification.php deleted file mode 100644 index a05629c0484..00000000000 --- a/front/notification.php +++ /dev/null @@ -1,48 +0,0 @@ -. - * - * --------------------------------------------------------------------- - */ - -Session::checkRight("notification", READ); - -Html::header( - Notification::getTypeName(Session::getPluralNumber()), - $_SERVER['PHP_SELF'], - "config", - "notification", - "notification" -); - -Search::show('Notification'); - -Html::footer(); diff --git a/front/notification_notificationtemplate.form.php b/front/notification_notificationtemplate.form.php index 7aed6aec298..a824b009b29 100644 --- a/front/notification_notificationtemplate.form.php +++ b/front/notification_notificationtemplate.form.php @@ -66,7 +66,7 @@ $params['notifications_id'] = $_GET['notifications_id']; } - $menus = ["config", "notification", "notifications_notificationtemplates"]; + $menus = ["config", "notification", "Notification_NotificationTemplate"]; Notification_NotificationTemplate::displayFullPageForItem( $_GET['id'], $menus, diff --git a/front/notificationtemplate.form.php b/front/notificationtemplate.form.php index bc303adc309..ea6dd2a7282 100644 --- a/front/notificationtemplate.form.php +++ b/front/notificationtemplate.form.php @@ -84,6 +84,6 @@ ); Html::back(); } else { - $menus = ["config", "notification", "notificationtemplate"]; + $menus = ["config", "notification", "NotificationTemplate"]; NotificationTemplate::displayFullPageForItem($_GET["id"], $menus); } diff --git a/front/notificationtemplate.php b/front/notificationtemplate.php deleted file mode 100644 index 6caa68a38e3..00000000000 --- a/front/notificationtemplate.php +++ /dev/null @@ -1,48 +0,0 @@ -. - * - * --------------------------------------------------------------------- - */ - -Session::checkRight("config", READ); - -Html::header( - NotificationTemplate::getTypeName(Session::getPluralNumber()), - $_SERVER['PHP_SELF'], - "config", - "notification", - "notificationtemplate" -); - -Search::show('NotificationTemplate'); - -Html::footer(); diff --git a/front/notificationtemplatetranslation.form.php b/front/notificationtemplatetranslation.form.php index 1eb15fac57f..f607891b497 100644 --- a/front/notificationtemplatetranslation.form.php +++ b/front/notificationtemplatetranslation.form.php @@ -97,7 +97,7 @@ $options = []; } - $menus = ["config", "notification", "notificationtemplate"]; + $menus = ["config", "notification", "NotificationTemplate"]; NotificationTemplateTranslation::displayFullPageForItem( $_GET["id"], $menus, diff --git a/front/notimportedemail.php b/front/notimportedemail.php deleted file mode 100644 index da1f0f5387b..00000000000 --- a/front/notimportedemail.php +++ /dev/null @@ -1,48 +0,0 @@ -. - * - * --------------------------------------------------------------------- - */ - -Session::checkRight("config", READ); - -Html::header( - NotImportedEmail::getTypeName(Session::getPluralNumber()), - $_SERVER['PHP_SELF'], - "config", - "mailcollector", - "notimportedemails" -); - -Search::show('NotImportedEmail'); - -Html::footer(); diff --git a/front/oauthclient.php b/front/oauthclient.php deleted file mode 100644 index 2bd76ac7e43..00000000000 --- a/front/oauthclient.php +++ /dev/null @@ -1,42 +0,0 @@ -. - * - * --------------------------------------------------------------------- - */ - -Session::checkRight(OAuthClient::$rightname, READ); - -Html::header(OAuthClient::getTypeName(Session::getPluralNumber()), $_SERVER['PHP_SELF'], "config", "oauthclient"); - -Search::show(OAuthClient::getType()); - -Html::footer(); diff --git a/front/ola.form.php b/front/ola.form.php index 37450f54daa..49788b0b2b3 100644 --- a/front/ola.form.php +++ b/front/ola.form.php @@ -90,6 +90,6 @@ ); Html::back(); } else { - $menus = ["config", "slm", "ola"]; + $menus = ["config", "slm", "OLA"]; OLA::displayFullPageForItem($_GET["id"], $menus); } diff --git a/front/ola.php b/front/ola.php deleted file mode 100644 index c98480a5df0..00000000000 --- a/front/ola.php +++ /dev/null @@ -1,46 +0,0 @@ -. - * - * --------------------------------------------------------------------- - */ - -/** - * @since 9.1 - */ - -Session::checkRight("slm", READ); - -Html::header(OLA::getTypeName(1), $_SERVER['PHP_SELF'], "config", "slm", "ola"); - -Search::show('OLA'); - -Html::footer(); diff --git a/front/olalevel.form.php b/front/olalevel.form.php index 224e9895e38..48503c44e01 100644 --- a/front/olalevel.form.php +++ b/front/olalevel.form.php @@ -104,6 +104,6 @@ Html::back(); } else if (isset($_GET["id"]) && ($_GET["id"] > 0)) { - $menus = ["config", "slm", "olalevel"]; + $menus = ["config", "slm", "OlaLevel"]; OlaLevel::displayFullPageForItem($_GET["id"], $menus); } diff --git a/front/olalevel.php b/front/olalevel.php deleted file mode 100644 index 5502d23234b..00000000000 --- a/front/olalevel.php +++ /dev/null @@ -1,52 +0,0 @@ -. - * - * --------------------------------------------------------------------- - */ - -/** - * @since 9.2 - */ - -Session::checkRight("slm", READ); - -Html::header( - OlaLevel::getTypeName(Session::getPluralNumber()), - $_SERVER['PHP_SELF'], - "config", - "ola", - "olalevel" -); - -Search::show('OlaLevel'); - -Html::footer(); diff --git a/front/passivedcequipment.php b/front/passivedcequipment.php deleted file mode 100644 index 3947b2b8a4f..00000000000 --- a/front/passivedcequipment.php +++ /dev/null @@ -1,47 +0,0 @@ -. - * - * --------------------------------------------------------------------- - */ - -Session::checkRight("datacenter", READ); - -Html::header( - PassiveDCEquipment::getTypeName(Session::getPluralNumber()), - $_SERVER['PHP_SELF'], - "assets", - "passivedcequipment" -); - -Search::show('PassiveDCEquipment'); - -Html::footer(); diff --git a/front/pdu.php b/front/pdu.php deleted file mode 100644 index 8cbcb0412fd..00000000000 --- a/front/pdu.php +++ /dev/null @@ -1,42 +0,0 @@ -. - * - * --------------------------------------------------------------------- - */ - -Session::checkRight("datacenter", READ); - -Html::header(PDU::getTypeName(Session::getPluralNumber()), $_SERVER['PHP_SELF'], "assets", "pdu"); - -Search::show('PDU'); - -Html::footer(); diff --git a/front/peripheral.php b/front/peripheral.php deleted file mode 100644 index 8e50e5487b6..00000000000 --- a/front/peripheral.php +++ /dev/null @@ -1,42 +0,0 @@ -. - * - * --------------------------------------------------------------------- - */ - -Session::checkRightsOr(Peripheral::$rightname, [READ, READ_ASSIGNED, READ_OWNED]); - -Html::header(Peripheral::getTypeName(Session::getPluralNumber()), $_SERVER['PHP_SELF'], "assets", "peripheral"); - -Search::show('Peripheral'); - -Html::footer(); diff --git a/front/phone.php b/front/phone.php deleted file mode 100644 index 9ebae864406..00000000000 --- a/front/phone.php +++ /dev/null @@ -1,42 +0,0 @@ -. - * - * --------------------------------------------------------------------- - */ - -Session::checkRightsOr(Phone::$rightname, [READ, READ_ASSIGNED, READ_OWNED]); - -Html::header(Phone::getTypeName(Session::getPluralNumber()), $_SERVER['PHP_SELF'], 'assets', 'phone'); - -Search::show('Phone'); - -Html::footer(); diff --git a/front/planningexternalevent.form.php b/front/planningexternalevent.form.php index 24bece86a1c..51a284097e1 100644 --- a/front/planningexternalevent.form.php +++ b/front/planningexternalevent.form.php @@ -80,6 +80,6 @@ $extevent->update($_POST); Html::back(); } else { - $menus = ["helpdesk", "planning", "external"]; + $menus = ["helpdesk", "planning", "PlanningExternalEvent"]; PlanningExternalEvent::displayFullPageForItem($_GET["id"], $menus); } diff --git a/front/planningexternalevent.php b/front/planningexternalevent.php deleted file mode 100644 index 2520f2785d9..00000000000 --- a/front/planningexternalevent.php +++ /dev/null @@ -1,48 +0,0 @@ -. - * - * --------------------------------------------------------------------- - */ - -Session::checkRight("planning", READ); - -Html::header( - PlanningExternalEvent::getTypeName(Session::getPluralNumber()), - $_SERVER['PHP_SELF'], - "helpdesk", - "planning", - "external" -); - -Search::show('PlanningExternalEvent'); - -Html::footer(); diff --git a/front/printer.php b/front/printer.php deleted file mode 100644 index 2cad3c83be9..00000000000 --- a/front/printer.php +++ /dev/null @@ -1,42 +0,0 @@ -. - * - * --------------------------------------------------------------------- - */ - -Session::checkRightsOr(Printer::$rightname, [READ, READ_ASSIGNED, READ_OWNED]); - -Html::header(Printer::getTypeName(Session::getPluralNumber()), $_SERVER['PHP_SELF'], "assets", "printer"); - -Search::show('Printer'); - -Html::footer(); diff --git a/front/problem.php b/front/problem.php deleted file mode 100644 index d24c3c4c6df..00000000000 --- a/front/problem.php +++ /dev/null @@ -1,42 +0,0 @@ -. - * - * --------------------------------------------------------------------- - */ - -Session::checkRightsOr('problem', [Problem::READALL, Problem::READMY]); - -Html::header(Problem::getTypeName(Session::getPluralNumber()), '', "helpdesk", "problem"); - -Search::show('Problem'); - -Html::footer(); diff --git a/front/profile.php b/front/profile.php deleted file mode 100644 index ef914da6628..00000000000 --- a/front/profile.php +++ /dev/null @@ -1,42 +0,0 @@ -. - * - * --------------------------------------------------------------------- - */ - -Session::checkRight("profile", READ); - -Html::header(Profile::getTypeName(Session::getPluralNumber()), $_SERVER['PHP_SELF'], "admin", "profile"); - -Search::show('Profile'); - -Html::footer(); diff --git a/front/project.php b/front/project.php deleted file mode 100644 index ab01cfd8d94..00000000000 --- a/front/project.php +++ /dev/null @@ -1,46 +0,0 @@ -. - * - * --------------------------------------------------------------------- - */ - -/** - * @since 0.85 - */ - -Session::checkRightsOr('project', [Project::READALL, Project::READMY]); - -Html::header(Project::getTypeName(Session::getPluralNumber()), $_SERVER['PHP_SELF'], "tools", "project"); - -Search::show('Project'); - -Html::footer(); diff --git a/front/projecttask.php b/front/projecttask.php deleted file mode 100644 index 931bb4956b2..00000000000 --- a/front/projecttask.php +++ /dev/null @@ -1,46 +0,0 @@ -. - * - * --------------------------------------------------------------------- - */ - -/** - * @since 0.85 - */ - -Session::checkRightsOr('project', [Project::READALL, Project::READMY, ProjectTask::READMY]); - -Html::header(ProjectTask::getTypeName(Session::getPluralNumber()), $_SERVER['PHP_SELF'], "tools", "project", 'task'); - -Search::show('ProjectTask'); - -Html::footer(); diff --git a/front/queuednotification.php b/front/queuednotification.php deleted file mode 100644 index fe119d02d14..00000000000 --- a/front/queuednotification.php +++ /dev/null @@ -1,46 +0,0 @@ -. - * - * --------------------------------------------------------------------- - */ - -/** - * @since 0.85 - */ - -Session::checkRight("queuednotification", READ); - -Html::header(QueuedNotification::getTypeName(), $_SERVER['PHP_SELF'], "admin", "queuednotification"); - -Search::show('QueuedNotification'); - -Html::footer(); diff --git a/front/queuedwebhook.php b/front/queuedwebhook.php deleted file mode 100644 index f1e725abdbf..00000000000 --- a/front/queuedwebhook.php +++ /dev/null @@ -1,42 +0,0 @@ -. - * - * --------------------------------------------------------------------- - */ - -Session::checkRight("config", READ); - -Html::header(QueuedWebhook::getTypeName(Session::getPluralNumber()), $_SERVER['PHP_SELF'], "config", Webhook::class); - -Search::show(QueuedWebhook::class); - -Html::footer(); diff --git a/front/rack.php b/front/rack.php deleted file mode 100644 index d408f0494c0..00000000000 --- a/front/rack.php +++ /dev/null @@ -1,42 +0,0 @@ -. - * - * --------------------------------------------------------------------- - */ - -Session::checkRight("datacenter", READ); - -Html::header(Rack::getTypeName(Session::getPluralNumber()), $_SERVER['PHP_SELF'], "assets", "rack"); - -Search::show('Rack'); - -Html::footer(); diff --git a/front/refusedequipment.form.php b/front/refusedequipment.form.php index 2bd061d1802..367f6d37a2e 100644 --- a/front/refusedequipment.form.php +++ b/front/refusedequipment.form.php @@ -71,7 +71,7 @@ ); Html::back(); } else { - $menus = ["admin", "glpi\inventory\inventory", "refusedequipment"]; + $menus = ["admin", "glpi\inventory\inventory", "RefusedEquipment"]; RefusedEquipment::displayFullPageForItem($_GET["id"], $menus, [ 'withtemplate' => $_GET["withtemplate"], 'formoptions' => "data-track-changes=true" diff --git a/front/refusedequipment.php b/front/refusedequipment.php deleted file mode 100644 index d9ba64c3e72..00000000000 --- a/front/refusedequipment.php +++ /dev/null @@ -1,42 +0,0 @@ -. - * - * --------------------------------------------------------------------- - */ - -Session::checkRight("refusedequipment", READ); - -Html::header(RefusedEquipment::getTypeName(Session::getPluralNumber()), $_SERVER['PHP_SELF'], "admin", "glpi\inventory\inventory", "refusedequipment"); - -Search::show('RefusedEquipment'); - -Html::footer(); diff --git a/front/reminder.php b/front/reminder.php deleted file mode 100644 index e9113e748fe..00000000000 --- a/front/reminder.php +++ /dev/null @@ -1,42 +0,0 @@ -. - * - * --------------------------------------------------------------------- - */ - -Session::checkCentralAccess(); - -Html::header(Reminder::getTypeName(Session::getPluralNumber()), $_SERVER['PHP_SELF'], "tools", "reminder"); - -Search::show('Reminder'); - -Html::footer(); diff --git a/front/rssfeed.php b/front/rssfeed.php deleted file mode 100644 index 8ea16066469..00000000000 --- a/front/rssfeed.php +++ /dev/null @@ -1,46 +0,0 @@ -. - * - * --------------------------------------------------------------------- - */ - -/** - * @since 0.84 - */ - -Session::checkCentralAccess(); - -Html::header(RSSFeed::getTypeName(Session::getPluralNumber()), $_SERVER['PHP_SELF'], "tools", "rssfeed"); - -Search::show('RSSFeed'); - -Html::footer(); diff --git a/front/sla.form.php b/front/sla.form.php index 57dac6d40ba..633c26eec11 100644 --- a/front/sla.form.php +++ b/front/sla.form.php @@ -86,6 +86,6 @@ ); Html::back(); } else { - $menus = ["config", "slm", "sla"]; + $menus = ["config", "slm", "SLA"]; SLA::displayFullPageForItem($_GET["id"], $menus); } diff --git a/front/sla.php b/front/sla.php deleted file mode 100644 index 423dbf09aa2..00000000000 --- a/front/sla.php +++ /dev/null @@ -1,42 +0,0 @@ -. - * - * --------------------------------------------------------------------- - */ - -Session::checkRight("slm", READ); - -Html::header(SLA::getTypeName(Session::getPluralNumber()), $_SERVER['PHP_SELF'], "config", "slm", "sla"); - -Search::show('SLA'); - -Html::footer(); diff --git a/front/slalevel.form.php b/front/slalevel.form.php index fc6a3a3fea4..d27a741fa98 100644 --- a/front/slalevel.form.php +++ b/front/slalevel.form.php @@ -100,6 +100,6 @@ Html::back(); } else if (isset($_GET["id"]) && ($_GET["id"] > 0)) { - $menus = ["config", "slm", "slalevel"]; + $menus = ["config", "slm", "SlaLevel"]; SlaLevel::displayFullPageForItem($_GET["id"], $menus); } diff --git a/front/slalevel.php b/front/slalevel.php deleted file mode 100644 index 0f900fdc5a2..00000000000 --- a/front/slalevel.php +++ /dev/null @@ -1,52 +0,0 @@ -. - * - * --------------------------------------------------------------------- - */ - -/** - * @since 9.1 - */ - -Session::checkRight("slm", READ); - -Html::header( - SlaLevel::getTypeName(Session::getPluralNumber()), - $_SERVER['PHP_SELF'], - "config", - "sla", - "slalevel" -); - -Search::show('SlaLevel'); - -Html::footer(); diff --git a/front/slm.php b/front/slm.php deleted file mode 100644 index 110c3cff0a3..00000000000 --- a/front/slm.php +++ /dev/null @@ -1,46 +0,0 @@ -. - * - * --------------------------------------------------------------------- - */ - -/** - * @since 9.2 - */ - -Session::checkRight("slm", READ); - -Html::header(SLM::getTypeName(Session::getPluralNumber()), $_SERVER['PHP_SELF'], "config", "slm"); - -Search::show('SLM'); - -Html::footer(); diff --git a/front/snmpcredential.form.php b/front/snmpcredential.form.php index 39075d6b80c..6e6897197c3 100644 --- a/front/snmpcredential.form.php +++ b/front/snmpcredential.form.php @@ -114,7 +114,7 @@ ); Html::back(); } else { - $menus = ["admin", "glpi\inventory\inventory", "snmpcredential"]; + $menus = ["admin", "glpi\inventory\inventory", "SNMPCredential"]; SNMPCredential::displayFullPageForItem($_GET["id"], $menus, [ 'withtemplate' => $_GET["withtemplate"], 'formoptions' => "data-track-changes=true" diff --git a/front/snmpcredential.php b/front/snmpcredential.php deleted file mode 100644 index 4b6376450fa..00000000000 --- a/front/snmpcredential.php +++ /dev/null @@ -1,42 +0,0 @@ -. - * - * --------------------------------------------------------------------- - */ - -Session::checkRight("snmpcredential", READ); - -Html::header(SNMPCredential::getTypeName(Session::getPluralNumber()), $_SERVER['PHP_SELF'], "admin", "glpi\inventory\inventory", "snmpcredential"); - -Search::show('SNMPCredential'); - -Html::footer(); diff --git a/front/socket.form.php b/front/socket.form.php index 9ea3ecf3ffd..5eaeba07720 100644 --- a/front/socket.form.php +++ b/front/socket.form.php @@ -170,6 +170,6 @@ ]; } - $menus = ["assets", "cable", "socket"]; + $menus = ["assets", "cable", "Glpi\\Socket"]; Socket::displayFullPageForItem($_GET["id"], $menus, $options); } diff --git a/front/socket.php b/front/socket.php deleted file mode 100644 index 4031b0bdfe4..00000000000 --- a/front/socket.php +++ /dev/null @@ -1,43 +0,0 @@ -. - * - * --------------------------------------------------------------------- - */ - -use Glpi\Socket; - -Session::checkRight("cable_management", READ); - -Html::header(Socket::getTypeName(Session::getPluralNumber()), $_SERVER['PHP_SELF'], "assets", "cable", "socket"); -Search::show(Socket::class); - -Html::footer(); diff --git a/front/software.php b/front/software.php deleted file mode 100644 index 055da01d043..00000000000 --- a/front/software.php +++ /dev/null @@ -1,42 +0,0 @@ -. - * - * --------------------------------------------------------------------- - */ - -Session::checkRightsOr(Software::$rightname, [READ, READ_ASSIGNED, READ_OWNED]); - -Html::header(Software::getTypeName(Session::getPluralNumber()), $_SERVER['PHP_SELF'], "assets", "software"); - -Search::show('Software'); - -Html::footer(); diff --git a/front/softwarelicense.php b/front/softwarelicense.php deleted file mode 100644 index dc72faedb9b..00000000000 --- a/front/softwarelicense.php +++ /dev/null @@ -1,47 +0,0 @@ -. - * - * --------------------------------------------------------------------- - */ - -Session::checkRight("license", READ); - -Html::header( - SoftwareLicense::getTypeName(Session::getPluralNumber()), - $_SERVER['PHP_SELF'], - "management", - "softwarelicense" -); - -Search::show('SoftwareLicense'); - -Html::footer(); diff --git a/front/supplier.php b/front/supplier.php deleted file mode 100644 index fbada509068..00000000000 --- a/front/supplier.php +++ /dev/null @@ -1,42 +0,0 @@ -. - * - * --------------------------------------------------------------------- - */ - -Session::checkRight("contact_enterprise", READ); - -Html::header(Supplier::getTypeName(Session::getPluralNumber()), '', "management", "supplier"); - -Search::show('Supplier'); - -Html::footer(); diff --git a/front/transfer.action.php b/front/transfer.action.php index 8daa4f25217..c32f0c280df 100644 --- a/front/transfer.action.php +++ b/front/transfer.action.php @@ -35,7 +35,7 @@ use Glpi\Exception\Http\AccessDeniedHttpException; -Html::header(__('Transfer'), '', 'admin', 'rule', 'transfer'); +Html::header(__('Transfer'), '', 'admin', 'rule', 'Transfer'); $transfer = new Transfer(); diff --git a/front/transfer.form.php b/front/transfer.form.php index 63be7183971..797956ce41b 100644 --- a/front/transfer.form.php +++ b/front/transfer.form.php @@ -86,7 +86,7 @@ Html::back(); } -$menus = ['admin', 'rule', 'transfer']; +$menus = ['admin', 'rule', 'Transfer']; Transfer::displayFullPageForItem($_GET["id"], $menus, [ 'target' => $transfer->getFormURL() ]); diff --git a/front/unmanaged.php b/front/unmanaged.php deleted file mode 100644 index 0ca4ddc0d93..00000000000 --- a/front/unmanaged.php +++ /dev/null @@ -1,42 +0,0 @@ -. - * - * --------------------------------------------------------------------- - */ - -Session::checkRight("unmanaged", READ); - -Html::header(Unmanaged::getTypeName(Session::getPluralNumber()), $_SERVER['PHP_SELF'], "assets", "unmanaged"); - -Search::show('Unmanaged'); - -Html::footer(); diff --git a/front/webhook.php b/front/webhook.php deleted file mode 100644 index c374a570609..00000000000 --- a/front/webhook.php +++ /dev/null @@ -1,42 +0,0 @@ -. - * - * --------------------------------------------------------------------- - */ - -Session::checkRight("config", READ); - -Html::header(Webhook::getTypeName(Session::getPluralNumber()), $_SERVER['PHP_SELF'], "config", Webhook::class); - -Search::show(Webhook::class); - -Html::footer(); diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 0fdece1aec8..300d493a422 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -21,7 +21,7 @@ parameters: - '/Instantiation of deprecated class Glpi\\Http\\HeaderlessStreamedResponse/' - { message: '/Variable \$this might not be defined/', paths: [ 'inc/includes.php' ] } - { message: '/Call to protected method setAjax\(\) of class Glpi\\Controller\\LegacyFileLoadController./', paths: [ 'ajax/*', 'front/*', 'inc/includes.php' ] } - - { message: '/Access to protected property/', paths: [ 'front/dropdown.common.php', 'front/dropdown.common.form.php' ] } + - { message: '/Access to protected property/', paths: [ 'front/dropdown.common.form.php' ] } - { message: '/LDAP\\Connection/', reportUnmatched: false } rules: diff --git a/phpunit/functional/Glpi/Http/LegacyDropdownRouteListenerTest.php b/phpunit/functional/Glpi/Http/LegacyItemtypeRouteListenerTest.php similarity index 76% rename from phpunit/functional/Glpi/Http/LegacyDropdownRouteListenerTest.php rename to phpunit/functional/Glpi/Http/LegacyItemtypeRouteListenerTest.php index 1b36935a8cb..24493d9aadb 100644 --- a/phpunit/functional/Glpi/Http/LegacyDropdownRouteListenerTest.php +++ b/phpunit/functional/Glpi/Http/LegacyItemtypeRouteListenerTest.php @@ -34,9 +34,9 @@ namespace tests\units\Glpi\Http; -use Glpi\Controller\DropdownController; +use Glpi\Controller\GenericListController; use Glpi\Controller\DropdownFormController; -use Glpi\Http\LegacyDropdownRouteListener; +use Glpi\Http\LegacyItemtypeRouteListener; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\RunInSeparateProcess; use PHPUnit\Framework\TestCase; @@ -45,18 +45,12 @@ use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\HttpKernel\KernelInterface; -final class LegacyDropdownRouteListenerTest extends TestCase +final class LegacyItemtypeRouteListenerTest extends TestCase { - public function setUp(): void + #[DataProvider('provideItemtypes')] + public function testFindDbClass(string $path_info, string $expected_class_name): void { - $_SESSION['glpi_use_mode'] = \Session::DEBUG_MODE; - parent::setUp(); - } - - #[DataProvider('provideDropdownClasses')] - public function testFindDropdownClass(string $path_info, string $expected_class_name): void - { - $listener = new LegacyDropdownRouteListener(); + $listener = new LegacyItemtypeRouteListener(); $request = $this->createRequest($path_info); $event = new RequestEvent($this->createMock(KernelInterface::class), $request, HttpKernelInterface::MAIN_REQUEST); @@ -65,77 +59,107 @@ public function testFindDropdownClass(string $path_info, string $expected_class_ if (\str_contains($path_info, '.form.php')) { self::assertSame(DropdownFormController::class, $request->attributes->get('_controller')); } else { - self::assertSame(DropdownController::class, $request->attributes->get('_controller')); + self::assertSame(GenericListController::class, $request->attributes->get('_controller')); } self::assertSame($expected_class_name, $request->attributes->get('class')); } - public static function provideDropdownClasses(): \Generator + public static function provideItemtypes(): iterable { $list = [ + '/front/agent.php' => \Agent::class, + '/front/allassets.php' => \AllAssets::class, + '/front/appliance.php' => \Appliance::class, '/front/applianceenvironment.form.php' => \ApplianceEnvironment::class, '/front/applianceenvironment.php' => \ApplianceEnvironment::class, '/front/appliancetype.form.php' => \ApplianceType::class, '/front/appliancetype.php' => \ApplianceType::class, + '/front/asset/assetdefinition.php' => \Glpi\Asset\AssetDefinition::class, + '/front/authldap.php' => \AuthLDAP::class, + '/front/authmail.php' => \AuthMail::class, '/front/autoupdatesystem.form.php' => \AutoUpdateSystem::class, '/front/autoupdatesystem.php' => \AutoUpdateSystem::class, '/front/blacklist.form.php' => \Blacklist::class, '/front/blacklist.php' => \Blacklist::class, '/front/blacklistedmailcontent.form.php' => \BlacklistedMailContent::class, '/front/blacklistedmailcontent.php' => \BlacklistedMailContent::class, + '/front/budget.php' => \Budget::class, '/front/budgettype.form.php' => \BudgetType::class, '/front/budgettype.php' => \BudgetType::class, '/front/businesscriticity.form.php' => \BusinessCriticity::class, '/front/businesscriticity.php' => \BusinessCriticity::class, + '/front/cable.php' => \Cable::class, '/front/cablestrand.form.php' => \CableStrand::class, '/front/cablestrand.php' => \CableStrand::class, '/front/cabletype.form.php' => \CableType::class, '/front/cabletype.php' => \CableType::class, '/front/calendar.form.php' => \Calendar::class, '/front/calendar.php' => \Calendar::class, + '/front/cartridgeitem.php' => \CartridgeItem::class, '/front/cartridgeitemtype.form.php' => \CartridgeItemType::class, '/front/cartridgeitemtype.php' => \CartridgeItemType::class, + '/front/certificate.php' => \Certificate::class, '/front/certificatetype.form.php' => \CertificateType::class, '/front/certificatetype.php' => \CertificateType::class, + '/front/change.php' => \Change::class, '/front/changetemplate.form.php' => \ChangeTemplate::class, '/front/changetemplate.php' => \ChangeTemplate::class, + '/front/cluster.php' => \Cluster::class, '/front/clustertype.form.php' => \ClusterType::class, '/front/clustertype.php' => \ClusterType::class, + '/front/computer.php' => \Computer::class, '/front/computermodel.form.php' => \ComputerModel::class, '/front/computermodel.php' => \ComputerModel::class, '/front/computertype.form.php' => \ComputerType::class, '/front/computertype.php' => \ComputerType::class, '/front/consumableitemtype.form.php' => \ConsumableItemType::class, '/front/consumableitemtype.php' => \ConsumableItemType::class, + '/front/contact.php' => \Contact::class, '/front/contacttype.form.php' => \ContactType::class, '/front/contacttype.php' => \ContactType::class, + '/front/contract.php' => \Contract::class, '/front/contracttype.form.php' => \ContractType::class, '/front/contracttype.php' => \ContractType::class, + '/front/crontask.php' => \CronTask::class, + '/front/database.php' => \Database::class, + '/front/databaseinstance.php' => \DatabaseInstance::class, '/front/databaseinstancecategory.form.php' => \DatabaseInstanceCategory::class, '/front/databaseinstancecategory.php' => \DatabaseInstanceCategory::class, '/front/databaseinstancetype.form.php' => \DatabaseInstanceType::class, '/front/databaseinstancetype.php' => \DatabaseInstanceType::class, + '/front/datacenter.php' => \Datacenter::class, + '/front/dcroom.php' => \DCRoom::class, + '/front/defaultfilter.php' => \DefaultFilter::class, + '/front/document.php' => \Document::class, '/front/documentcategory.form.php' => \DocumentCategory::class, '/front/documentcategory.php' => \DocumentCategory::class, '/front/documenttype.form.php' => \DocumentType::class, '/front/documenttype.php' => \DocumentType::class, + '/front/domain.php' => \Domain::class, + '/front/domainrecord.php' => \DomainRecord::class, '/front/domainrecordtype.form.php' => \DomainRecordType::class, '/front/domainrecordtype.php' => \DomainRecordType::class, '/front/domainrelation.form.php' => \DomainRelation::class, '/front/domainrelation.php' => \DomainRelation::class, '/front/domaintype.form.php' => \DomainType::class, '/front/domaintype.php' => \DomainType::class, + '/front/dropdown/dropdowndefinition.php' => \Glpi\Dropdown\DropdownDefinition::class, + '/front/enclosure.php' => \Enclosure::class, '/front/enclosuremodel.form.php' => \EnclosureModel::class, '/front/enclosuremodel.php' => \EnclosureModel::class, '/front/entity.form.php' => \Entity::class, '/front/entity.php' => \Entity::class, + '/front/event.php' => \Glpi\Event::class, '/front/fieldblacklist.form.php' => \Fieldblacklist::class, '/front/fieldblacklist.php' => \Fieldblacklist::class, '/front/fieldunicity.form.php' => \FieldUnicity::class, + '/front/fieldunicity.php' => \FieldUnicity::class, '/front/filesystem.form.php' => \Filesystem::class, '/front/filesystem.php' => \Filesystem::class, + '/front/form/form.php' => \Glpi\Form\Form::class, '/front/fqdn.form.php' => \FQDN::class, '/front/fqdn.php' => \FQDN::class, + '/front/group.php' => \Group::class, '/front/holiday.form.php' => \Holiday::class, '/front/holiday.php' => \Holiday::class, '/front/imageformat.form.php' => \ImageFormat::class, @@ -154,30 +178,43 @@ public static function provideDropdownClasses(): \Generator '/front/itilvalidationtemplate.php' => \ITILValidationTemplate::class, '/front/knowbaseitemcategory.form.php' => \KnowbaseItemCategory::class, '/front/knowbaseitemcategory.php' => \KnowbaseItemCategory::class, + '/front/line.php' => \Line::class, '/front/lineoperator.form.php' => \LineOperator::class, '/front/lineoperator.php' => \LineOperator::class, '/front/linetype.form.php' => \LineType::class, '/front/linetype.php' => \LineType::class, + '/front/link.php' => \Link::class, '/front/location.form.php' => \Location::class, '/front/location.php' => \Location::class, + '/front/lockedfield.php' => \Lockedfield::class, + '/front/mailcollector.php' => \MailCollector::class, '/front/manufacturer.form.php' => \Manufacturer::class, '/front/manufacturer.php' => \Manufacturer::class, + '/front/monitor.php' => \Monitor::class, '/front/monitormodel.form.php' => \MonitorModel::class, '/front/monitormodel.php' => \MonitorModel::class, '/front/monitortype.form.php' => \MonitorType::class, '/front/monitortype.php' => \MonitorType::class, '/front/network.form.php' => \Network::class, '/front/network.php' => \Network::class, + '/front/networkequipment.php' => \NetworkEquipment::class, '/front/networkequipmentmodel.form.php' => \NetworkEquipmentModel::class, '/front/networkequipmentmodel.php' => \NetworkEquipmentModel::class, '/front/networkequipmenttype.form.php' => \NetworkEquipmentType::class, '/front/networkequipmenttype.php' => \NetworkEquipmentType::class, '/front/networkinterface.form.php' => \NetworkInterface::class, '/front/networkinterface.php' => \NetworkInterface::class, + '/front/networkname.php' => \NetworkName::class, '/front/networkportfiberchanneltype.form.php' => \NetworkPortFiberchannelType::class, '/front/networkportfiberchanneltype.php' => \NetworkPortFiberchannelType::class, '/front/networkporttype.form.php' => \NetworkPortType::class, '/front/networkporttype.php' => \NetworkPortType::class, + '/front/notification.php' => \Notification::class, + '/front/notificationtemplate.php' => \NotificationTemplate::class, + '/front/notimportedemail.php' => \NotImportedEmail::class, + '/front/oauthclient.php' => \OAuthClient::class, + '/front/ola.php' => \OLA::class, + '/front/olalevel.php' => \OlaLevel::class, '/front/operatingsystem.form.php' => \OperatingSystem::class, '/front/operatingsystem.php' => \OperatingSystem::class, '/front/operatingsystemarchitecture.form.php' => \OperatingSystemArchitecture::class, @@ -192,22 +229,26 @@ public static function provideDropdownClasses(): \Generator '/front/operatingsystemservicepack.php' => \OperatingSystemServicePack::class, '/front/operatingsystemversion.form.php' => \OperatingSystemVersion::class, '/front/operatingsystemversion.php' => \OperatingSystemVersion::class, + '/front/passivedcequipment.php' => \PassiveDCEquipment::class, '/front/passivedcequipmentmodel.form.php' => \PassiveDCEquipmentModel::class, '/front/passivedcequipmentmodel.php' => \PassiveDCEquipmentModel::class, '/front/passivedcequipmenttype.form.php' => \PassiveDCEquipmentType::class, '/front/passivedcequipmenttype.php' => \PassiveDCEquipmentType::class, '/front/pcivendor.form.php' => \PCIVendor::class, '/front/pcivendor.php' => \PCIVendor::class, + '/front/pdu.php' => \PDU::class, '/front/pdumodel.form.php' => \PDUModel::class, '/front/pdumodel.php' => \PDUModel::class, '/front/pdutype.form.php' => \PDUType::class, '/front/pdutype.php' => \PDUType::class, '/front/pendingreason.form.php' => \PendingReason::class, '/front/pendingreason.php' => \PendingReason::class, + '/front/peripheral.php' => \Peripheral::class, '/front/peripheralmodel.form.php' => \PeripheralModel::class, '/front/peripheralmodel.php' => \PeripheralModel::class, '/front/peripheraltype.form.php' => \PeripheralType::class, '/front/peripheraltype.php' => \PeripheralType::class, + '/front/phone.php' => \Phone::class, '/front/phonemodel.form.php' => \PhoneModel::class, '/front/phonemodel.php' => \PhoneModel::class, '/front/phonepowersupply.form.php' => \PhonePowerSupply::class, @@ -216,38 +257,57 @@ public static function provideDropdownClasses(): \Generator '/front/phonetype.php' => \PhoneType::class, '/front/planningeventcategory.form.php' => \PlanningEventCategory::class, '/front/planningeventcategory.php' => \PlanningEventCategory::class, + '/front/planningexternalevent.php' => \PlanningExternalEvent::class, '/front/planningexternaleventtemplate.form.php' => \PlanningExternalEventTemplate::class, '/front/planningexternaleventtemplate.php' => \PlanningExternalEventTemplate::class, '/front/plug.form.php' => \Plug::class, '/front/plug.php' => \Plug::class, + '/front/printer.php' => \Printer::class, '/front/printermodel.form.php' => \PrinterModel::class, '/front/printermodel.php' => \PrinterModel::class, '/front/printertype.form.php' => \PrinterType::class, '/front/printertype.php' => \PrinterType::class, + '/front/problem.php' => \Problem::class, '/front/problemtemplate.form.php' => \ProblemTemplate::class, '/front/problemtemplate.php' => \ProblemTemplate::class, + '/front/profile.php' => \Profile::class, + '/front/project.php' => \Project::class, '/front/projectstate.form.php' => \ProjectState::class, '/front/projectstate.php' => \ProjectState::class, + '/front/projecttask.php' => \ProjectTask::class, '/front/projecttasktemplate.form.php' => \ProjectTaskTemplate::class, '/front/projecttasktemplate.php' => \ProjectTaskTemplate::class, '/front/projecttasktype.form.php' => \ProjectTaskType::class, '/front/projecttasktype.php' => \ProjectTaskType::class, '/front/projecttype.form.php' => \ProjectType::class, '/front/projecttype.php' => \ProjectType::class, + '/front/queuednotification.php' => \QueuedNotification::class, + '/front/queuedwebhook.php' => \QueuedWebhook::class, + '/front/rack.php' => \Rack::class, '/front/rackmodel.form.php' => \RackModel::class, '/front/rackmodel.php' => \RackModel::class, '/front/racktype.form.php' => \RackType::class, '/front/racktype.php' => \RackType::class, '/front/recurrentchange.form.php' => \RecurrentChange::class, '/front/recurrentchange.php' => \RecurrentChange::class, + '/front/refusedequipment.php' => \RefusedEquipment::class, + '/front/reminder.php' => \Reminder::class, '/front/requesttype.form.php' => \RequestType::class, '/front/requesttype.php' => \RequestType::class, + '/front/rssfeed.php' => \RSSFeed::class, '/front/rulerightparameter.form.php' => \RuleRightParameter::class, '/front/rulerightparameter.php' => \RuleRightParameter::class, + '/front/sla.php' => \SLA::class, + '/front/slalevel.php' => \SlaLevel::class, + '/front/slm.php' => \SLM::class, + '/front/snmpcredential.php' => \SNMPCredential::class, + '/front/socket.php' => \Glpi\Socket::class, '/front/socketmodel.form.php' => \Glpi\SocketModel::class, '/front/socketmodel.php' => \Glpi\SocketModel::class, + '/front/software.php' => \Software::class, '/front/softwarecategory.form.php' => \SoftwareCategory::class, '/front/softwarecategory.php' => \SoftwareCategory::class, + '/front/softwarelicense.php' => \SoftwareLicense::class, '/front/softwarelicensetype.form.php' => \SoftwareLicenseType::class, '/front/softwarelicensetype.php' => \SoftwareLicenseType::class, '/front/solutiontemplate.form.php' => \SolutionTemplate::class, @@ -258,6 +318,7 @@ public static function provideDropdownClasses(): \Generator '/front/ssovariable.php' => \SsoVariable::class, '/front/state.form.php' => \State::class, '/front/state.php' => \State::class, + '/front/supplier.php' => \Supplier::class, '/front/suppliertype.form.php' => \SupplierType::class, '/front/suppliertype.php' => \SupplierType::class, '/front/taskcategory.form.php' => \TaskCategory::class, @@ -268,8 +329,11 @@ public static function provideDropdownClasses(): \Generator '/front/ticketrecurrent.php' => \TicketRecurrent::class, '/front/tickettemplate.form.php' => \TicketTemplate::class, '/front/tickettemplate.php' => \TicketTemplate::class, + '/front/transfer.php' => \Transfer::class, + '/front/unmanaged.php' => \Unmanaged::class, '/front/usbvendor.form.php' => \USBVendor::class, '/front/usbvendor.php' => \USBVendor::class, + '/front/user.php' => \User::class, '/front/usercategory.form.php' => \UserCategory::class, '/front/usercategory.php' => \UserCategory::class, '/front/usertitle.form.php' => \UserTitle::class, @@ -282,10 +346,11 @@ public static function provideDropdownClasses(): \Generator '/front/virtualmachinetype.php' => \VirtualMachineType::class, '/front/vlan.form.php' => \Vlan::class, '/front/vlan.php' => \Vlan::class, - '/front/wifinetwork.form.php' => \WifiNetwork::class, - '/front/wifinetwork.php' => \WifiNetwork::class, + '/front/webhook.php' => \Webhook::class, '/front/webhookcategory.form.php' => \WebhookCategory::class, '/front/webhookcategory.php' => \WebhookCategory::class, + '/front/wifinetwork.form.php' => \WifiNetwork::class, + '/front/wifinetwork.php' => \WifiNetwork::class, ]; foreach ($list as $path => $class) { @@ -331,34 +396,44 @@ public static function provideDropdownClasses(): \Generator } #[RunInSeparateProcess] - #[DataProvider('provideDropdownClassesForPlugin')] - public function testFindDropdownClassForPlugin(string $path_info, string $class): void + #[DataProvider('provideClassesForPlugin')] + public function testFindClassForPlugin(string $path_info, string $class): void { - $listener = new LegacyDropdownRouteListener(); + $listener = new LegacyItemtypeRouteListener(); $request = $this->createRequest($path_info); $event = new RequestEvent($this->createMock(KernelInterface::class), $request, HttpKernelInterface::MAIN_REQUEST); $listener->onKernelRequest($event); - self::assertSame(DropdownController::class, $request->attributes->get('_controller')); + self::assertSame(GenericListController::class, $request->attributes->get('_controller')); self::assertSame($class, $request->attributes->get('class')); } - public static function provideDropdownClassesForPlugin(): array + public static function provideClassesForPlugin(): iterable { - return [ - '/plugins/tester/front/mylegacyclass.php' => [ - '/plugins/tester/front/mylegacyclass.php', - \PluginTesterMyLegacyClass::class, - ], - '/plugins/tester/front/mypseudopsr4class.php' => [ - '/plugins/tester/front/mypseudopsr4class.php', - \PluginTesterMyPseudoPsr4Class::class, - ], - '/plugins/tester/front/mypsr4class.php' => [ - '/plugins/tester/front/mypsr4class.php', - \GlpiPlugin\Tester\MyPsr4Class::class, - ], + yield [ + 'path_info' => '/plugins/tester/front/mylegacyclass.php', + 'class' => \PluginTesterMyLegacyClass::class, + ]; + yield [ + 'path_info' => '/plugins/tester/front/mylegacydropdown.php', + 'class' => \PluginTesterMyLegacyDropdown::class, + ]; + yield [ + 'path_info' => '/plugins/tester/front/mypseudopsr4class.php', + 'class' => \PluginTesterMyPseudoPsr4Class::class, + ]; + yield [ + 'path_info' => '/plugins/tester/front/mypseudopsr4dropdown.php', + 'class' => \PluginTesterMyPseudoPsr4Dropdown::class, + ]; + yield [ + 'path_info' => '/plugins/tester/front/mypsr4class.php', + 'class' => \GlpiPlugin\Tester\MyPsr4Class::class, + ]; + yield [ + 'path_info' => '/plugins/tester/front/mypsr4dropdown.php', + 'class' => \GlpiPlugin\Tester\MyPsr4Dropdown::class, ]; } diff --git a/src/Agent.php b/src/Agent.php index 07d70f583de..80f425d4765 100644 --- a/src/Agent.php +++ b/src/Agent.php @@ -39,6 +39,7 @@ use Glpi\Application\View\TemplateRenderer; use Glpi\DBAL\QueryFunction; use Glpi\Inventory\Conf; +use Glpi\Inventory\Inventory; use Glpi\Plugin\Hooks; use GuzzleHttp\Client as Guzzle_Client; use GuzzleHttp\Psr7\Response; @@ -77,6 +78,11 @@ public static function getTypeName($nb = 0) return _n('Agent', 'Agents', $nb); } + public static function getSectorizedDetails(): array + { + return ['admin', Inventory::class, self::class]; + } + public function rawSearchOptions() { diff --git a/src/AllAssets.php b/src/AllAssets.php index b80db9df9d3..d975925f25b 100644 --- a/src/AllAssets.php +++ b/src/AllAssets.php @@ -40,6 +40,20 @@ public static function canView(): bool return Session::getCurrentInterface() == "central"; } + public static function getHeaderParameters(): array + { + return [ + __('Global'), + '', + ...static::getSectorizedDetails(), + ]; + } + + public static function getSectorizedDetails(): array + { + return ['assets', self::class]; + } + public static function getTypeName($nb = 0) { return _n('Asset', 'Assets', $nb); diff --git a/src/Appliance.php b/src/Appliance.php index 2e3db8a959f..78258f7f328 100644 --- a/src/Appliance.php +++ b/src/Appliance.php @@ -67,6 +67,11 @@ public function getCloneRelations(): array ]; } + public static function getSectorizedDetails(): array + { + return ['management', self::class]; + } + public static function getTypeName($nb = 0) { return _n('Appliance', 'Appliances', $nb); diff --git a/src/Auth.php b/src/Auth.php index 9722ac7a573..03d1626f664 100644 --- a/src/Auth.php +++ b/src/Auth.php @@ -132,7 +132,7 @@ public static function getMenuContent() 'links' => [], ]; - $menu['options']['ldap'] = [ + $menu['options'][AuthLDAP::class] = [ 'icon' => AuthLDAP::getIcon(), 'title' => AuthLDAP::getTypeName(Session::getPluralNumber()), 'page' => AuthLDAP::getSearchURL(false), @@ -142,7 +142,7 @@ public static function getMenuContent() ], ]; - $menu['options']['imap'] = [ + $menu['options'][AuthMail::class] = [ 'icon' => AuthMail::getIcon(), 'title' => AuthMail::getTypeName(Session::getPluralNumber()), 'page' => AuthMail::getSearchURL(false), diff --git a/src/AuthLDAP.php b/src/AuthLDAP.php index 4894a77f82a..c040c6f9ff9 100644 --- a/src/AuthLDAP.php +++ b/src/AuthLDAP.php @@ -183,6 +183,11 @@ public static function getTypeName($nb = 0) return _n('LDAP directory', 'LDAP directories', $nb); } + public static function getSectorizedDetails(): array + { + return ['config', Auth::class, self::class]; + } + public static function canCreate(): bool { return static::canUpdate(); diff --git a/src/AuthMail.php b/src/AuthMail.php index bb869dc0d05..b3bc8f83c51 100644 --- a/src/AuthMail.php +++ b/src/AuthMail.php @@ -48,6 +48,11 @@ public static function getTypeName($nb = 0) return _n('Mail server', 'Mail servers', $nb); } + public static function getSectorizedDetails(): array + { + return ['config', Auth::class, self::class]; + } + public function prepareInputForUpdate($input) { if (!empty($input['mail_server'])) { diff --git a/src/Budget.php b/src/Budget.php index d1e8c23558a..ef0870a869b 100644 --- a/src/Budget.php +++ b/src/Budget.php @@ -65,6 +65,11 @@ public static function getTypeName($nb = 0) return _n('Budget', 'Budgets', $nb); } + public static function getSectorizedDetails(): array + { + return ['management', self::class]; + } + public function defineTabs($options = []) { diff --git a/src/Cable.php b/src/Cable.php index 30ca6e576e3..3468e2fd702 100644 --- a/src/Cable.php +++ b/src/Cable.php @@ -53,6 +53,11 @@ public static function getTypeName($nb = 0) return _n('Cable', 'Cables', $nb); } + public static function getSectorizedDetails(): array + { + return ['assets', self::class]; + } + public static function getFieldLabel() { return self::getTypeName(1); @@ -106,7 +111,7 @@ public static function getAdditionalMenuOptions() { if (static::canView()) { return [ - 'socket' => [ + Socket::class => [ 'title' => Socket::getTypeName(Session::getPluralNumber()), 'page' => Socket::getSearchURL(false), 'links' => [ diff --git a/src/Cartridge.php b/src/Cartridge.php index 8556f24c556..e9ad8bdb40e 100644 --- a/src/Cartridge.php +++ b/src/Cartridge.php @@ -97,6 +97,11 @@ public static function getTypeName($nb = 0) return _n('Cartridge', 'Cartridges', $nb); } + public static function getSectorizedDetails(): array + { + return ['assets', self::class]; + } + public function prepareInputForAdd($input) { $item = static::getItemFromArray(CartridgeItem::class, CartridgeItem::getForeignKeyField(), $input); diff --git a/src/Certificate.php b/src/Certificate.php index 29e05b313f6..efc816497d4 100644 --- a/src/Certificate.php +++ b/src/Certificate.php @@ -69,6 +69,11 @@ public static function getTypeName($nb = 0) return _n('Certificate', 'Certificates', $nb); } + public static function getSectorizedDetails(): array + { + return ['management', self::class]; + } + /** * Clean certificate items */ diff --git a/src/Change.php b/src/Change.php index b630d1d4ddd..3e7c87078ae 100644 --- a/src/Change.php +++ b/src/Change.php @@ -72,6 +72,10 @@ public static function getTypeName($nb = 0) return _n('Change', 'Changes', $nb); } + public static function getSectorizedDetails(): array + { + return ['helpdesk', self::class]; + } public function canSolve() { diff --git a/src/ChangeTemplate.php b/src/ChangeTemplate.php index cea1b63f005..435dde9dd62 100644 --- a/src/ChangeTemplate.php +++ b/src/ChangeTemplate.php @@ -42,14 +42,16 @@ class ChangeTemplate extends ITILTemplate { use Glpi\Features\Clonable; - public $second_level_menu = "change"; - public $third_level_menu = "ChangeTemplate"; - public static function getTypeName($nb = 0) { return _n('Change template', 'Change templates', $nb); } + public static function getSectorizedDetails(): array + { + return ['helpdesk', Change::class, self::class]; + } + public function getCloneRelations(): array { return [ diff --git a/src/Cluster.php b/src/Cluster.php index 0a7d0095c3b..6317b1703d9 100644 --- a/src/Cluster.php +++ b/src/Cluster.php @@ -60,6 +60,11 @@ public static function getTypeName($nb = 0) return _n('Cluster', 'Clusters', $nb); } + public static function getSectorizedDetails(): array + { + return ['management', self::class]; + } + public function defineTabs($options = []) { $ong = []; diff --git a/src/CommonDevice.php b/src/CommonDevice.php index e8608022169..9333def48bd 100644 --- a/src/CommonDevice.php +++ b/src/CommonDevice.php @@ -48,15 +48,16 @@ abstract class CommonDevice extends CommonDropdown // From CommonDBTM public $dohistory = true; - public $first_level_menu = "config"; - public $second_level_menu = "commondevice"; - public $third_level_menu = ""; - public static function getTypeName($nb = 0) { return _n('Component', 'Components', $nb); } + public static function getSectorizedDetails(): array + { + return ['config', self::class, static::class]; + } + /** * Get all the kind of devices available inside the system. * diff --git a/src/CommonDropdown.php b/src/CommonDropdown.php index 1e213515cda..006a4b5e3aa 100644 --- a/src/CommonDropdown.php +++ b/src/CommonDropdown.php @@ -49,10 +49,6 @@ abstract class CommonDropdown extends CommonDBTM public $must_be_replace = false; //Menu & navigation - public $first_level_menu = "config"; - public $second_level_menu = "commondropdown"; - public $third_level_menu = ""; - public $display_dropdowntitle = true; //This dropdown can be translated @@ -71,6 +67,11 @@ public static function getTypeName($nb = 0) return _n('Dropdown', 'Dropdowns', $nb); } + public static function getSectorizedDetails(): array + { + return ['config', self::class, static::class]; + } + /** * Is translation enabled for this itemtype @@ -235,23 +236,6 @@ public function defineTabs($options = []) return $ong; } - public static function displayCentralHeader( - ?string $title = null, - ?array $menus = null - ): void { - if (empty($menus)) { - $dropdown = new static(); - - $menus = [ - $dropdown->first_level_menu, - $dropdown->second_level_menu, - $dropdown->third_level_menu ?: $dropdown->getType() - ]; - } - - parent::displayCentralHeader($title, $menus); - } - /** * @since 0.83.3 * diff --git a/src/CommonGLPI.php b/src/CommonGLPI.php index 02aba76db48..5ccf4249b44 100644 --- a/src/CommonGLPI.php +++ b/src/CommonGLPI.php @@ -482,7 +482,7 @@ public static function getMenuContent() } if ($data = $item->getAdditionalMenuContent()) { $newmenu = [ - strtolower($type) => $menu, + $type => $menu, ]; // Force overwrite existing menu foreach ($data as $key => $val) { @@ -592,6 +592,20 @@ public function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) return ''; } + public static function getSectorizedDetails(): array + { + return []; + } + + public static function getHeaderParameters(): array + { + return [ + static::getTypeName(\Session::getPluralNumber()), + '', + ...static::getSectorizedDetails(), + ]; + } + /** * show Tab content * diff --git a/src/CommonITILRecurrent.php b/src/CommonITILRecurrent.php index 343eb76c2c8..3dd92ac068c 100644 --- a/src/CommonITILRecurrent.php +++ b/src/CommonITILRecurrent.php @@ -47,11 +47,6 @@ abstract class CommonITILRecurrent extends CommonDropdown */ public $dohistory = true; - /** - * @var string From CommonDropdown - */ - public $first_level_menu = "helpdesk"; - /** * @var bool From CommonDropdown */ diff --git a/src/Computer.php b/src/Computer.php index cbf88b86ef2..4ca2a5e9f09 100644 --- a/src/Computer.php +++ b/src/Computer.php @@ -92,6 +92,10 @@ public static function getTypeName($nb = 0) return _n('Computer', 'Computers', $nb); } + public static function getSectorizedDetails(): array + { + return ['assets', self::class]; + } public function useDeletedToLockIfDynamic() { diff --git a/src/Config.php b/src/Config.php index 14b5d553a96..3845401d00e 100644 --- a/src/Config.php +++ b/src/Config.php @@ -96,11 +96,11 @@ public static function getMenuContent() $menu['page'] = Config::getFormURL(false); $menu['icon'] = Config::getIcon(); - $menu['options']['apiclient']['icon'] = APIClient::getIcon(); - $menu['options']['apiclient']['title'] = APIClient::getTypeName(Session::getPluralNumber()); - $menu['options']['apiclient']['page'] = Config::getFormURL(false) . '?forcetab=Config$8'; - $menu['options']['apiclient']['links']['search'] = Config::getFormURL(false) . '?forcetab=Config$8'; - $menu['options']['apiclient']['links']['add'] = '/front/apiclient.form.php'; + $menu['options'][APIClient::class]['icon'] = APIClient::getIcon(); + $menu['options'][APIClient::class]['title'] = APIClient::getTypeName(Session::getPluralNumber()); + $menu['options'][APIClient::class]['page'] = Config::getFormURL(false) . '?forcetab=Config$8'; + $menu['options'][APIClient::class]['links']['search'] = Config::getFormURL(false) . '?forcetab=Config$8'; + $menu['options'][APIClient::class]['links']['add'] = '/front/apiclient.form.php'; } if (count($menu)) { return $menu; diff --git a/src/Contact.php b/src/Contact.php index e313b062ba4..594c62a5f9c 100644 --- a/src/Contact.php +++ b/src/Contact.php @@ -58,6 +58,11 @@ public static function getTypeName($nb = 0) return _n('Contact', 'Contacts', $nb); } + public static function getSectorizedDetails(): array + { + return ['management', self::class]; + } + public function prepareInputForAdd($input) { $input = parent::prepareInputForAdd($input); diff --git a/src/Contract.php b/src/Contract.php index b545bcf52d2..042938524d6 100644 --- a/src/Contract.php +++ b/src/Contract.php @@ -71,6 +71,11 @@ public static function getTypeName($nb = 0) return _n('Contract', 'Contracts', $nb); } + public static function getSectorizedDetails(): array + { + return ['management', self::class]; + } + public function post_getEmpty() { if (isset($_SESSION['glpiactive_entity'])) { diff --git a/src/CronTask.php b/src/CronTask.php index e31f28dd4fe..d38bde269ec 100644 --- a/src/CronTask.php +++ b/src/CronTask.php @@ -88,6 +88,11 @@ public static function getTypeName($nb = 0) return _n('Automatic action', 'Automatic actions', $nb); } + public static function getSectorizedDetails(): array + { + return ['config', self::class]; + } + public function defineTabs($options = []) { $ong = []; diff --git a/src/DCRoom.php b/src/DCRoom.php index 791a9a7e6d4..51ae7d4f7fb 100644 --- a/src/DCRoom.php +++ b/src/DCRoom.php @@ -52,6 +52,11 @@ public static function getTypeName($nb = 0) return _n('Server room', 'Server rooms', $nb); } + public static function getSectorizedDetails(): array + { + return ['management', Datacenter::class, self::class]; + } + public function defineTabs($options = []) { $ong = []; diff --git a/src/Database.php b/src/Database.php index ac1b728579b..37630301c2a 100644 --- a/src/Database.php +++ b/src/Database.php @@ -54,6 +54,11 @@ public static function getTypeName($nb = 0) return _n('Database', 'Databases', $nb); } + public static function getSectorizedDetails(): array + { + return ['management', self::class]; + } + public function defineTabs($options = []) { $ong = []; @@ -468,7 +473,7 @@ public static function getAdditionalMenuOptions() { if (static::canView()) { return [ - 'databaseinstance' => [ + DatabaseInstance::class => [ 'title' => DatabaseInstance::getTypeName(Session::getPluralNumber()), 'page' => DatabaseInstance::getSearchURL(false), 'icon' => DatabaseInstance::getIcon(), diff --git a/src/DatabaseInstance.php b/src/DatabaseInstance.php index bbdad7cc6e9..883ed267a45 100644 --- a/src/DatabaseInstance.php +++ b/src/DatabaseInstance.php @@ -76,6 +76,11 @@ public static function getTypeName($nb = 0) return _n('Database instance', 'Database instances', $nb); } + public static function getSectorizedDetails(): array + { + return ['management', Database::class, self::class]; + } + public function defineTabs($options = []) { $ong = []; diff --git a/src/Datacenter.php b/src/Datacenter.php index 93eeec3b384..265a6a0b7d9 100644 --- a/src/Datacenter.php +++ b/src/Datacenter.php @@ -52,6 +52,11 @@ public static function getTypeName($nb = 0) return _n('Data center', 'Data centers', $nb); } + public static function getSectorizedDetails(): array + { + return ['management', self::class]; + } + public function prepareInputForAdd($input) { $input = parent::prepareInputForAdd($input); @@ -212,7 +217,7 @@ public static function getAdditionalMenuOptions() { if (static::canView()) { return [ - 'dcroom' => [ + DCRoom::class => [ 'title' => DCRoom::getTypeName(Session::getPluralNumber()), 'page' => DCRoom::getSearchURL(false), 'icon' => DCRoom::getIcon(), diff --git a/src/DefaultFilter.php b/src/DefaultFilter.php index 882269115fc..3468e2b242e 100644 --- a/src/DefaultFilter.php +++ b/src/DefaultFilter.php @@ -67,6 +67,11 @@ public static function getTypeName($nb = 0) return _n('Default filter', 'Default filters', $nb); } + public static function getSectorizedDetails(): array + { + return ['config', CommonDropdown::class, self::class]; + } + public static function getIcon() { return "ti ti-filter"; diff --git a/src/Document.php b/src/Document.php index 3d499b3d943..d78e152226b 100644 --- a/src/Document.php +++ b/src/Document.php @@ -61,6 +61,11 @@ public static function getTypeName($nb = 0) return _n('Document', 'Documents', $nb); } + public static function getSectorizedDetails(): array + { + return ['management', self::class]; + } + /** * Check if given object can have Document * diff --git a/src/Domain.php b/src/Domain.php index 0c61be90584..513844bd57d 100644 --- a/src/Domain.php +++ b/src/Domain.php @@ -77,6 +77,11 @@ public static function getTypeName($nb = 0) return _n('Domain', 'Domains', $nb); } + public static function getSectorizedDetails(): array + { + return ['management', self::class]; + } + public function cleanDBonPurge() { /** @var \DBmysql $DB */ @@ -860,7 +865,7 @@ public static function getAdditionalMenuOptions() { if (static::canManageRecords()) { return [ - 'domainrecord' => [ + DomainRecord::class => [ 'icon' => DomainRecord::getIcon(), 'title' => DomainRecord::getTypeName(Session::getPluralNumber()), 'page' => DomainRecord::getSearchURL(false), diff --git a/src/DomainRecord.php b/src/DomainRecord.php index c5f17cd46a5..73d71ce02a5 100644 --- a/src/DomainRecord.php +++ b/src/DomainRecord.php @@ -56,6 +56,11 @@ public static function getTypeName($nb = 0) return _n('Domain record', 'Domains records', $nb); } + public static function getSectorizedDetails(): array + { + return ['management', Domain::class, self::class]; + } + public function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) { if ($item::class === Domain::class) { diff --git a/src/Enclosure.php b/src/Enclosure.php index c10f28047f1..a452c215b6a 100644 --- a/src/Enclosure.php +++ b/src/Enclosure.php @@ -66,6 +66,11 @@ public static function getTypeName($nb = 0) return _n('Enclosure', 'Enclosures', $nb); } + public static function getSectorizedDetails(): array + { + return ['assets', self::class]; + } + public function defineTabs($options = []) { $ong = []; diff --git a/src/Entity.php b/src/Entity.php index 3d814b4f582..2775a4eac89 100644 --- a/src/Entity.php +++ b/src/Entity.php @@ -50,9 +50,6 @@ class Entity extends CommonTreeDropdown public $must_be_replace = true; public $dohistory = true; - public $first_level_menu = "admin"; - public $second_level_menu = "entity"; - public static $rightname = 'entity'; protected $usenotepad = true; @@ -234,6 +231,11 @@ public static function getTypeName($nb = 0) return _n('Entity', 'Entities', $nb); } + public static function getSectorizedDetails(): array + { + return ['admin', self::class]; + } + public static function canCreate(): bool { // Do not show the create button if no recusive access on current entity diff --git a/src/FieldUnicity.php b/src/FieldUnicity.php index 81deb5dfbd4..0b028344cf8 100644 --- a/src/FieldUnicity.php +++ b/src/FieldUnicity.php @@ -43,8 +43,6 @@ class FieldUnicity extends CommonDropdown // From CommonDBTM public $dohistory = true; - public $first_level_menu = "config"; - public $second_level_menu = "fieldunicity"; public $can_be_translated = false; public static $rightname = 'config'; @@ -55,6 +53,11 @@ public static function getTypeName($nb = 0) return __('Fields unicity'); } + public static function getSectorizedDetails(): array + { + return ['config', self::class]; + } + public static function canCreate(): bool { return static::canUpdate(); diff --git a/src/Glpi/Asset/Asset.php b/src/Glpi/Asset/Asset.php index 4c1e0c86de4..cc44de0f4e3 100644 --- a/src/Glpi/Asset/Asset.php +++ b/src/Glpi/Asset/Asset.php @@ -96,6 +96,11 @@ public static function getDefinitionClass(): string return AssetDefinition::class; } + public static function getSectorizedDetails(): array + { + return ['assets', static::getDefinition()->getAssetClassName()]; + } + public function rawSearchOptions() { $search_options = parent::rawSearchOptions(); diff --git a/src/Glpi/Asset/AssetDefinition.php b/src/Glpi/Asset/AssetDefinition.php index 19d8c0854d0..c87ecd08e33 100644 --- a/src/Glpi/Asset/AssetDefinition.php +++ b/src/Glpi/Asset/AssetDefinition.php @@ -54,6 +54,11 @@ */ final class AssetDefinition extends AbstractDefinition { + public static function getSectorizedDetails(): array + { + return ['config', self::class]; + } + public static function getCustomObjectBaseClass(): string { return Asset::class; diff --git a/src/Glpi/Controller/DropdownFormController.php b/src/Glpi/Controller/DropdownFormController.php index 41a63dc6379..3015fbb7b83 100644 --- a/src/Glpi/Controller/DropdownFormController.php +++ b/src/Glpi/Controller/DropdownFormController.php @@ -41,6 +41,7 @@ use Glpi\Exception\Http\AccessDeniedHttpException; use Glpi\Exception\Http\BadRequestHttpException; use Glpi\Http\HeaderlessStreamedResponse; +use Session; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Attribute\Route; @@ -122,11 +123,7 @@ public static function loadDropdownForm(Request $request, CommonDropdown $dropdo && empty($input["forcepurge"]) ) { Html::header( - $dropdown->getTypeName(1), - '', - "config", - $dropdown->second_level_menu, - \str_replace('glpi_', '', $dropdown->getTable()) + ...$dropdown->getHeaderParameters() ); $dropdown->showDeleteConfirmForm($request->getPathInfo()); Html::footer(); @@ -182,12 +179,10 @@ public static function loadDropdownForm(Request $request, CommonDropdown $dropdo } } else if ($in_modal) { Html::popHeader( - $dropdown->getTypeName(1), + $dropdown->getTypeName(Session::getPluralNumber()), '', true, - $dropdown->first_level_menu, - $dropdown->second_level_menu, - $dropdown->getType() + ...$dropdown->getSectorizedDetails() ); $dropdown->showForm($id); Html::popFooter(); @@ -198,7 +193,7 @@ public static function loadDropdownForm(Request $request, CommonDropdown $dropdo $options['formoptions'] = ($options['formoptions'] ?? '') . ' data-track-changes=true'; $options['id'] = $id; - $dropdown::displayFullPageForItem($id, null, $options); + $dropdown::displayFullPageForItem($id, $dropdown->getSectorizedDetails(), $options); } } } diff --git a/src/Glpi/Controller/DropdownController.php b/src/Glpi/Controller/GenericListController.php similarity index 66% rename from src/Glpi/Controller/DropdownController.php rename to src/Glpi/Controller/GenericListController.php index 1f661bbf821..cc1716fb6ba 100644 --- a/src/Glpi/Controller/DropdownController.php +++ b/src/Glpi/Controller/GenericListController.php @@ -34,47 +34,43 @@ namespace Glpi\Controller; -use CommonDropdown; +use CommonGLPI; use Glpi\Exception\Http\AccessDeniedHttpException; use Glpi\Exception\Http\BadRequestHttpException; -use Glpi\Http\HeaderlessStreamedResponse; -use Html; -use Search; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Attribute\Route; -final class DropdownController extends AbstractController +final class GenericListController extends AbstractController { - #[Route("/Dropdown/{class}", name: "glpi_dropdown")] + #[Route("/{class}/Search", name: "glpi_generic_list")] public function __invoke(Request $request): Response { $class = $request->attributes->getString('class'); - if (!$class) { - throw new BadRequestHttpException('The "class" attribute is mandatory for dropdown routes.'); - } - - if (!\is_subclass_of($class, CommonDropdown::class)) { - throw new BadRequestHttpException('The "class" attribute is mandatory for dropdown routes.'); - } + $this->checkIsValidClass($class); - return new HeaderlessStreamedResponse(function () use ($class, $request) { - $dropdown = new $class(); - $this->loadDropdown($request, $dropdown); - }); + return $this->render('pages/generic_list.html.twig', [ + 'class' => $class, + ]); } - public static function loadDropdown(Request $request, CommonDropdown $dropdown): void + private function checkIsValidClass(string $class): void { - if (!$dropdown->canView()) { - throw new AccessDeniedHttpException(); + if ($class === '') { + throw new BadRequestHttpException('The "class" attribute is mandatory for itemtype routes.'); } - $dropdown::displayCentralHeader(); + if (!\class_exists($class)) { + throw new BadRequestHttpException(\sprintf("Class \"%s\" does not exist.", $class)); + } - Search::show($dropdown::class); + if (!\is_subclass_of($class, CommonGLPI::class)) { + throw new BadRequestHttpException(\sprintf("Class \"%s\" is not a valid itemtype.", $class)); + } - Html::footer(); + if (!$class::canView()) { + throw new AccessDeniedHttpException(); + } } } diff --git a/src/Glpi/Dropdown/DropdownDefinition.php b/src/Glpi/Dropdown/DropdownDefinition.php index 315c505efaf..d8e94c6f9a4 100644 --- a/src/Glpi/Dropdown/DropdownDefinition.php +++ b/src/Glpi/Dropdown/DropdownDefinition.php @@ -34,6 +34,7 @@ namespace Glpi\Dropdown; +use CommonDropdown; use CommonGLPI; use Glpi\CustomObject\AbstractDefinition; use Session; @@ -48,6 +49,11 @@ public static function getTypeName($nb = 0) return _n('Dropdown definition', 'Dropdown definitions', $nb); } + public static function getSectorizedDetails(): array + { + return ['config', CommonDropdown::class, self::class]; + } + public static function getCustomObjectBaseClass(): string { return Dropdown::class; diff --git a/src/Glpi/Event.php b/src/Glpi/Event.php index fbbd9dd5b7c..2f6703bbd8e 100644 --- a/src/Glpi/Event.php +++ b/src/Glpi/Event.php @@ -43,6 +43,7 @@ use Document; use Glpi\Application\View\TemplateRenderer; use Glpi\DBAL\QueryExpression; +use Glpi\System\Log\LogViewer; use Html; use Infocom; use ITILSolution; @@ -61,6 +62,11 @@ public static function getTypeName($nb = 0) return _n('Event log', 'Event logs', $nb); } + public static function getSectorizedDetails(): array + { + return ['admin', LogViewer::class, self::class]; + } + public function prepareInputForAdd($input) { /** @var array $CFG_GLPI */ diff --git a/src/Glpi/Form/Form.php b/src/Glpi/Form/Form.php index 50eec2600a9..d1c72f13e7a 100644 --- a/src/Glpi/Form/Form.php +++ b/src/Glpi/Form/Form.php @@ -86,6 +86,12 @@ public static function getIcon() return "ti ti-forms"; } + #[Override] + public static function getSectorizedDetails(): array + { + return ['admin', self::class]; + } + #[Override] public function defineTabs($options = []) { diff --git a/src/Glpi/Http/LegacyDropdownRouteListener.php b/src/Glpi/Http/LegacyItemtypeRouteListener.php similarity index 59% rename from src/Glpi/Http/LegacyDropdownRouteListener.php rename to src/Glpi/Http/LegacyItemtypeRouteListener.php index 0c8e3ffe8e0..40d97694355 100644 --- a/src/Glpi/Http/LegacyDropdownRouteListener.php +++ b/src/Glpi/Http/LegacyItemtypeRouteListener.php @@ -34,10 +34,14 @@ namespace Glpi\Http; +use CommonDevice; +use CommonDropdown; +use CommonGLPI; +use Glpi\Asset\Asset; use Glpi\Asset\AssetDefinition; use Glpi\Asset\AssetModel; use Glpi\Asset\AssetType; -use Glpi\Controller\DropdownController; +use Glpi\Controller\GenericListController; use Glpi\Controller\DropdownFormController; use Glpi\Dropdown\Dropdown; use Glpi\Dropdown\DropdownDefinition; @@ -46,7 +50,7 @@ use Symfony\Component\HttpKernel\Event\RequestEvent; use Symfony\Component\HttpKernel\KernelEvents; -final readonly class LegacyDropdownRouteListener implements EventSubscriberInterface +final readonly class LegacyItemtypeRouteListener implements EventSubscriberInterface { public static function getSubscribedEvents(): array { @@ -70,45 +74,90 @@ public function onKernelRequest(RequestEvent $event): void return; } - if ($class = $this->findDropdownClass($request)) { + if ($class = $this->findClass($request)) { $is_form = \str_ends_with($request->getPathInfo(), '.form.php'); - $request->attributes->set('_controller', $is_form ? DropdownFormController::class : DropdownController::class); - $request->attributes->set('class', $class); + if (\is_a($class, CommonDropdown::class, true)) { + $request->attributes->set('_controller', $is_form ? DropdownFormController::class : GenericListController::class); + $request->attributes->set('class', $class); + } else { + $request->attributes->set('_controller', $is_form ? null : GenericListController::class); + $request->attributes->set('class', $class); + } } } - public function findDropdownClass(Request $request): ?string + /** + * @phpstan-return class-string|null + */ + private function findClass(Request $request): ?string { $path_info = $request->getPathInfo(); - if ($model_class = $this->findPluginClass($path_info)) { - return $this->normalizeClass($model_class); + if ($plugin_class = $this->findPluginClass($path_info)) { + return $plugin_class; } - if ($model_class = $this->findCustomDropdownClass($request)) { - return $this->normalizeClass($model_class); + if ($asset_class = $this->findCustomAssetClass($request)) { + return $asset_class; } - if ($model_class = $this->findGenericClass($path_info)) { - return $this->normalizeClass($model_class); + if ($asset_model_class = $this->findAssetModelclass($request)) { + return $asset_model_class; } - if ($device_class = $this->findDeviceClass($request)) { - return $this->normalizeClass($device_class); + if ($asset_type_class = $this->findAssetTypeclass($request)) { + return $asset_type_class; } - if ($asset_model_class = $this->findAssetModelclass($request)) { - return $this->normalizeClass($asset_model_class); + if ($dropdown_class = $this->findCustomDropdownClass($request)) { + return $dropdown_class; } - if ($asset_type_class = $this->findAssetTypeclass($request)) { - return $this->normalizeClass($asset_type_class); + if ($device_class = $this->findDeviceClass($request)) { + return $device_class; + } + + if ($model_class = $this->findGenericClass($path_info)) { + return $model_class; } return null; } + /** + * @phpstan-return class-string|null + */ + private function findCustomAssetClass(Request $request): ?string + { + $matches = []; + if (!\preg_match('~^/front/asset/asset(?\.form)?\.php$~i', $request->getPathInfo(), $matches)) { + return null; + } + + $is_form = !empty($matches['is_form']); + $id = $request->query->get('id') ?: $request->request->get('id'); + + $classname = null; + + if ($is_form && $id !== null && !Asset::isNewId($id)) { + $asset = Asset::getById($id); + if ($asset instanceof Asset) { + $classname = $asset::class; + } + } else { + $definition = new AssetDefinition(); + if ($request->query->has('class') && $definition->getFromDBBySystemName((string) $request->query->get('class'))) { + $classname = $definition->getAssetClassName(); + } + } + + return $classname; + } + + /** + * @phpstan-return class-string|null + */ private function findCustomDropdownClass(Request $request): ?string { $matches = []; @@ -121,7 +170,7 @@ private function findCustomDropdownClass(Request $request): ?string $classname = null; - if ($is_form && $id !== null) { + if ($is_form && $id !== null && !Dropdown::isNewId($id)) { $dropdown = Dropdown::getById($id); if ($dropdown instanceof Dropdown) { $classname = $dropdown::class; @@ -136,44 +185,44 @@ private function findCustomDropdownClass(Request $request): ?string return $classname; } + /** + * @phpstan-return class-string|null + */ private function findGenericClass(string $path_info): ?string { - $path_regex = '~^/front/(?.+)(?
\.form)?\.php~isUu'; + $path_regex = '~^/front/(?.+)(?\.form)?\.php~isUu'; $matches = []; if (!\preg_match($path_regex, $path_info, $matches)) { return null; } - if (!$matches['basename']) { - throw new \RuntimeException('Could not extract basename from URL to match legacy dropdowns.'); - } - - $basename = $matches['basename']; + $itemtype = $matches['itemtype']; - $class = (new \DbUtils())->fixItemtypeCase($basename); + $item = \getItemForItemtype($itemtype); - if ( - $class - && \class_exists($class) - && \is_subclass_of($class, \CommonDropdown::class) - ) { - return $class; + if ($item instanceof CommonGLPI) { + return $item::class; } - $namespacedClass = \preg_replace_callback('~\\\([a-z])~Uu', static fn($i) => '\\' . \ucfirst($i[1]), 'Glpi\\' . \str_replace('/', '\\', $class)); + $namespaced_itemtype = \preg_replace_callback( + '~\\\([a-z])~Uu', + static fn($i) => '\\' . \ucfirst($i[1]), + 'Glpi\\' . \str_replace('/', '\\', $itemtype) + ); - if ( - $namespacedClass - && \class_exists($namespacedClass) - && \is_subclass_of($namespacedClass, \CommonDropdown::class) - ) { - return $namespacedClass; + $namespaced_item = \getItemForItemtype($namespaced_itemtype); + + if ($namespaced_item instanceof CommonGLPI) { + return $namespaced_item::class; } return null; } + /** + * @phpstan-return class-string|null + */ private function findDeviceClass(Request $request): ?string { $device_paths = [ @@ -189,22 +238,23 @@ private function findDeviceClass(Request $request): ?string return null; } - $item_type = $request->query->get('itemtype') ?: $request->request->get('itemtype'); + $itemtype = $request->query->get('itemtype') ?: $request->request->get('itemtype'); - if (!$item_type || !\class_exists($item_type)) { - throw new \RuntimeException( - 'Missing or incorrect device type called!' - ); + if ($itemtype === null) { + return null; } - $class = \getItemForItemtype($item_type) ?: null; - if (!$class) { - return null; + $item = \getItemForItemtype($itemtype); + if ($item instanceof CommonDevice) { + return $item::class; } - return \get_class($class); + return null; } + /** + * @return class-string|null + */ private function findAssetModelclass(Request $request): ?string { $matches = []; @@ -217,8 +267,11 @@ private function findAssetModelclass(Request $request): ?string $classname = null; - if ($is_form && $id !== null) { + if ($is_form && $id !== null && !AssetModel::isNewId($id)) { $asset = AssetModel::getById($id); + if (!$asset) { + return null; + } $classname = $asset::class; } else { $definition = new AssetDefinition(); @@ -230,6 +283,9 @@ private function findAssetModelclass(Request $request): ?string return $classname; } + /** + * @return class-string|null + */ private function findAssetTypeclass(Request $request): ?string { $matches = []; @@ -242,8 +298,11 @@ private function findAssetTypeclass(Request $request): ?string $classname = null; - if ($is_form && $id !== null) { + if ($is_form && $id !== null && !AssetType::isNewId($id)) { $asset = AssetType::getById($id); + if (!$asset) { + return null; + } $classname = $asset::class; } else { $definition = new AssetDefinition(); @@ -255,44 +314,40 @@ private function findAssetTypeclass(Request $request): ?string return $classname; } - private function normalizeClass(string $class): string - { - if (!\class_exists($class)) { - throw new \RuntimeException('Class "$class" does not exist.'); - } - - return (new \ReflectionClass($class))->getName(); - } - + /** + * @phpstan-return class-string|null + */ private function findPluginClass(string $path_info): ?string { - $path_regex = '~^/(plugins|marketplace)/(?[^/]+)/front/(?.+)(?\.form)?.php~isUu'; + $path_regex = '~^/(plugins|marketplace)/(?[^/]+)/front/(?.+)(?\.form)?.php~isUu'; $matches = []; if (\preg_match($path_regex, $path_info, $matches) !== 1) { return null; } - if (!$matches['basename']) { - throw new \RuntimeException('Could not extract basename from URL to match legacy dropdowns.'); - } - - $basename = $matches['basename']; + $itemtype = $matches['itemtype']; $plugin = $matches['plugin']; if (!$this->isPluginActive($plugin)) { return null; } - // PluginMyPluginDropdown -> /plugins/myplugin/front/dropdown.php - $legacy_classname = (new \DbUtils())->fixItemtypeCase(\sprintf('Plugin%s%s', ucfirst($plugin), ucfirst($basename))); - if (is_a($legacy_classname, \CommonDropdown::class, true)) { - return $legacy_classname; + $item = \getItemForItemtype($itemtype); + + if ($item instanceof CommonGLPI) { + return $item::class; + } + + // PluginMyPluginItem -> /plugins/myplugin/front/item.php + $legacy_item = \getItemForItemtype(\sprintf('Plugin%s%s', ucfirst($plugin), ucfirst($itemtype))); + if ($legacy_item instanceof CommonGLPI) { + return $legacy_item::class; } - // GlpiPlugin\MyPlugin\Dropdown -> /plugins/myplugin/front/dropdown.php - $namespaced_classname = (new \DbUtils())->fixItemtypeCase(\sprintf('GlpiPlugin\%s\%s', ucfirst($plugin), ucfirst($basename))); - if (is_a($namespaced_classname, \CommonDropdown::class, true)) { - return $namespaced_classname; + // GlpiPlugin\MyPlugin\Item -> /plugins/myplugin/front/item.php + $namespaced_item = \getItemForItemtype(\sprintf('GlpiPlugin\%s\%s', ucfirst($plugin), ucfirst($itemtype))); + if ($namespaced_item instanceof CommonGLPI) { + return $namespaced_item::class; } return null; diff --git a/src/Glpi/Http/ListenersPriority.php b/src/Glpi/Http/ListenersPriority.php index f927d53de59..8c59c0e5157 100644 --- a/src/Glpi/Http/ListenersPriority.php +++ b/src/Glpi/Http/ListenersPriority.php @@ -49,10 +49,10 @@ final class ListenersPriority // They must therefore be executed after the `LegacyRouterListener`. LegacyConfigProviderListener::class => 350, - // Plugins dropdowns requires plugins to be initialized, therefore config must be already set. - // Also, keep it after the `LegacyRouterListener` to not map to the generic dropdown controller if a + // Plugins itemtypes requires plugins to be initialized, therefore config must be already set. + // Also, keep it after the `LegacyRouterListener` to not map to the generic controller if a // legacy script exists for the requested URI. - LegacyDropdownRouteListener::class => 300, + LegacyItemtypeRouteListener::class => 300, // This listener allows matching plugins routes at runtime, // that's why it's executed right after Symfony's Router, diff --git a/src/Glpi/Inventory/Inventory.php b/src/Glpi/Inventory/Inventory.php index 6149fdee4c4..e932cfab61d 100644 --- a/src/Glpi/Inventory/Inventory.php +++ b/src/Glpi/Inventory/Inventory.php @@ -512,7 +512,7 @@ public static function getMenuContent() ]; if (Session::haveRight(Agent::$rightname, READ)) { - $menu['options']['agent'] = [ + $menu['options'][Agent::class] = [ 'icon' => Agent::getIcon(), 'title' => Agent::getTypeName(Session::getPluralNumber()), 'page' => Agent::getSearchURL(false), @@ -523,7 +523,7 @@ public static function getMenuContent() } if (Session::haveRight(Lockedfield::$rightname, UPDATE)) { - $menu['options']['lockedfield'] = [ + $menu['options'][Lockedfield::class] = [ 'icon' => Lockedfield::getIcon(), 'title' => Lockedfield::getTypeName(Session::getPluralNumber()), 'page' => Lockedfield::getSearchURL(false), @@ -534,7 +534,7 @@ public static function getMenuContent() } if (Session::haveRight(RefusedEquipment::$rightname, READ)) { - $menu['options']['refusedequipment'] = [ + $menu['options'][RefusedEquipment::class] = [ 'icon' => RefusedEquipment::getIcon(), 'title' => RefusedEquipment::getTypeName(Session::getPluralNumber()), 'page' => RefusedEquipment::getSearchURL(false), @@ -543,7 +543,7 @@ public static function getMenuContent() } if (Session::haveRight(SNMPCredential::$rightname, READ)) { - $menu['options']['snmpcredential'] = [ + $menu['options'][SNMPCredential::class] = [ 'icon' => SNMPCredential::getIcon(), 'title' => SNMPCredential::getTypeName(Session::getPluralNumber()), 'page' => SNMPCredential::getSearchURL(false), diff --git a/src/Glpi/Socket.php b/src/Glpi/Socket.php index ed7fd6f3295..6096b08724f 100644 --- a/src/Glpi/Socket.php +++ b/src/Glpi/Socket.php @@ -319,6 +319,11 @@ public static function getTypeName($nb = 0) return _n('Socket', 'Sockets', $nb); } + public static function getSectorizedDetails(): array + { + return ['assets', Cable::class, self::class]; + } + public function rawSearchOptions() { $tab = parent::rawSearchOptions(); diff --git a/src/Glpi/System/Log/LogViewer.php b/src/Glpi/System/Log/LogViewer.php index 18b6b1d2dfb..090ee5d5e9b 100644 --- a/src/Glpi/System/Log/LogViewer.php +++ b/src/Glpi/System/Log/LogViewer.php @@ -79,7 +79,7 @@ public static function getMenuContent() ]; if (Event::canView()) { - $menu['options']['Glpi\\Event'] = [ + $menu['options'][Event::class] = [ 'title' => Event::getTypeName(Session::getPluralNumber()), 'page' => Event::getSearchURL(false), 'icon' => Event::getIcon(), diff --git a/src/Group.php b/src/Group.php index 2314d4514fa..dcb11a89a09 100644 --- a/src/Group.php +++ b/src/Group.php @@ -62,6 +62,11 @@ public static function getTypeName($nb = 0) return _n('Group', 'Groups', $nb); } + public static function getSectorizedDetails(): array + { + return ['admin', self::class]; + } + public static function getAdditionalMenuOptions() { if (Session::haveRight('user', User::UPDATEAUTHENT)) { diff --git a/src/ITILTemplate.php b/src/ITILTemplate.php index 4ac7fc9d7ff..2bfad9d85f5 100644 --- a/src/ITILTemplate.php +++ b/src/ITILTemplate.php @@ -46,9 +46,6 @@ abstract class ITILTemplate extends CommonDropdown // From CommonDBTM public $dohistory = true; - // From CommonDropdown - public $first_level_menu = "helpdesk"; - public $display_dropdowntitle = false; public static $rightname = 'itiltemplate'; diff --git a/src/Line.php b/src/Line.php index fcfa057c5de..54ac3e88b0f 100644 --- a/src/Line.php +++ b/src/Line.php @@ -58,6 +58,10 @@ public static function getTypeName($nb = 0) return _n('Line', 'Lines', $nb); } + public static function getSectorizedDetails(): array + { + return ['management', self::class]; + } /** * @see CommonDBTM::useDeletedToLockIfDynamic() diff --git a/src/Link.php b/src/Link.php index a8faca2e9b6..f02b2e46d48 100644 --- a/src/Link.php +++ b/src/Link.php @@ -58,6 +58,11 @@ public static function getTypeName($nb = 0) return _n('External link', 'External links', $nb); } + public static function getSectorizedDetails(): array + { + return ['config', self::class]; + } + /** * For plugins, add a tag to the links tags * diff --git a/src/Lockedfield.php b/src/Lockedfield.php index dcbfde8d534..94fc0ed31f5 100644 --- a/src/Lockedfield.php +++ b/src/Lockedfield.php @@ -34,6 +34,7 @@ */ use Glpi\Application\View\TemplateRenderer; +use Glpi\Inventory\Inventory; use Glpi\Search\SearchOption; /** @@ -54,6 +55,11 @@ public static function getTypeName($nb = 0) return _n('Locked field', 'Locked fields', $nb); } + public static function getSectorizedDetails(): array + { + return ['admin', Inventory::class, self::class]; + } + public static function canView(): bool { return self::canUpdate(); diff --git a/src/MailCollector.php b/src/MailCollector.php index 6aba4968eaa..ae489aa690c 100644 --- a/src/MailCollector.php +++ b/src/MailCollector.php @@ -112,6 +112,10 @@ public static function getTypeName($nb = 0) return _n('Receiver', 'Receivers', $nb); } + public static function getSectorizedDetails(): array + { + return ['config', self::class]; + } public static function canCreate(): bool { @@ -131,7 +135,7 @@ public static function getAdditionalMenuOptions() if (static::canView()) { return [ 'options' => [ - 'notimportedemail' => [ + NotImportedEmail::class => [ 'links' => [ 'search' => '/front/notimportedemail.php', ], diff --git a/src/Monitor.php b/src/Monitor.php index ecaa6720be4..3d17e3da95a 100644 --- a/src/Monitor.php +++ b/src/Monitor.php @@ -81,6 +81,10 @@ public static function getTypeName($nb = 0) return _n('Monitor', 'Monitors', $nb); } + public static function getSectorizedDetails(): array + { + return ['assets', self::class]; + } /** * @see CommonDBTM::useDeletedToLockIfDynamic() diff --git a/src/NetworkEquipment.php b/src/NetworkEquipment.php index 2932a300782..49b6e151a67 100644 --- a/src/NetworkEquipment.php +++ b/src/NetworkEquipment.php @@ -85,13 +85,17 @@ public static function getTypeName($nb = 0) return _n('Network device', 'Network devices', $nb); } + public static function getSectorizedDetails(): array + { + return ['assets', self::class]; + } public static function getAdditionalMenuOptions() { if (static::canView()) { $options = [ - 'networkport' => [ + NetworkPort::class => [ 'title' => NetworkPort::getTypeName(Session::getPluralNumber()), 'page' => NetworkPort::getFormURL(false), ], diff --git a/src/NetworkName.php b/src/NetworkName.php index 67c31c3dcb6..3630e204c96 100644 --- a/src/NetworkName.php +++ b/src/NetworkName.php @@ -70,6 +70,11 @@ public static function getTypeName($nb = 0) return _n('Network name', 'Network names', $nb); } + public static function getSectorizedDetails(): array + { + return ['config', CommonDropdown::class, self::class]; + } + public function useDeletedToLockIfDynamic() { return false; diff --git a/src/NotImportedEmail.php b/src/NotImportedEmail.php index 2496a6dd479..b4e8760fc1d 100644 --- a/src/NotImportedEmail.php +++ b/src/NotImportedEmail.php @@ -63,6 +63,11 @@ public static function getTypeName($nb = 0) return _n('Refused email', 'Refused emails', $nb); } + public static function getSectorizedDetails(): array + { + return ['config', MailCollector::class, self::class]; + } + public function getSpecificMassiveActions($checkitem = null) { diff --git a/src/Notification.php b/src/Notification.php index 6302cbfbab6..d73b56741c4 100644 --- a/src/Notification.php +++ b/src/Notification.php @@ -172,6 +172,11 @@ public static function getTypeName($nb = 0) return _n('Notification', 'Notifications', $nb); } + public static function getSectorizedDetails(): array + { + return ['config', self::class, self::class]; + } + /** * @see CommonGLPI::getMenuContent() * @@ -188,25 +193,25 @@ public static function getMenuContent() $menu['title'] = _n('Notification', 'Notifications', Session::getPluralNumber()); $menu['page'] = '/front/setup.notification.php'; $menu['icon'] = self::getIcon(); - $menu['options']['notification']['title'] = _n('Notification', 'Notifications', Session::getPluralNumber()); - $menu['options']['notification']['page'] = Notification::getSearchURL(false); - $menu['options']['notification']['links']['add'] = Notification::getFormURL(false); - $menu['options']['notification']['links']['search'] = Notification::getSearchURL(false); + $menu['options'][Notification::class]['title'] = _n('Notification', 'Notifications', Session::getPluralNumber()); + $menu['options'][Notification::class]['page'] = Notification::getSearchURL(false); + $menu['options'][Notification::class]['links']['add'] = Notification::getFormURL(false); + $menu['options'][Notification::class]['links']['search'] = Notification::getSearchURL(false); //saved search list - $menu['options']['notification']['links']['lists'] = ""; - $menu['options']['notification']['lists_itemtype'] = Notification::getType(); + $menu['options'][Notification::class]['links']['lists'] = ""; + $menu['options'][Notification::class]['lists_itemtype'] = Notification::getType(); - $menu['options']['notificationtemplate']['title'] + $menu['options'][NotificationTemplate::class]['title'] = _n('Notification template', 'Notification templates', Session::getPluralNumber()); - $menu['options']['notificationtemplate']['page'] + $menu['options'][NotificationTemplate::class]['page'] = NotificationTemplate::getSearchURL(false); - $menu['options']['notificationtemplate']['links']['add'] + $menu['options'][NotificationTemplate::class]['links']['add'] = NotificationTemplate::getFormURL(false); - $menu['options']['notificationtemplate']['links']['search'] + $menu['options'][NotificationTemplate::class]['links']['search'] = NotificationTemplate::getSearchURL(false); //saved search list - $menu['options']['notificationtemplate']['links']['lists'] = ""; - $menu['options']['notificationtemplate']['lists_itemtype'] = NotificationTemplate::getType(); + $menu['options'][NotificationTemplate::class]['links']['lists'] = ""; + $menu['options'][NotificationTemplate::class]['lists_itemtype'] = NotificationTemplate::getType(); } if (count($menu)) { return $menu; diff --git a/src/NotificationTemplate.php b/src/NotificationTemplate.php index f181296ce8b..1475af3d522 100644 --- a/src/NotificationTemplate.php +++ b/src/NotificationTemplate.php @@ -66,6 +66,11 @@ public static function getTypeName($nb = 0) return _n('Notification template', 'Notification templates', $nb); } + public static function getSectorizedDetails(): array + { + return ['config', Notification::class, self::class]; + } + public static function getIcon() { return 'ti ti-template'; diff --git a/src/OAuthClient.php b/src/OAuthClient.php index 478f4289c74..d554142fe8c 100644 --- a/src/OAuthClient.php +++ b/src/OAuthClient.php @@ -49,6 +49,11 @@ public static function getTypeName($nb = 0) return _n('OAuth client', 'OAuth clients', $nb); } + public static function getSectorizedDetails(): array + { + return ['config', self::class]; + } + public static function getIcon() { return 'ti ti-key'; diff --git a/src/OLA.php b/src/OLA.php index 8d7420de900..a0826ee9dea 100644 --- a/src/OLA.php +++ b/src/OLA.php @@ -51,6 +51,11 @@ public static function getTypeName($nb = 0) return __('OLA'); } + public static function getSectorizedDetails(): array + { + return ['config', SLM::class, self::class]; + } + public static function getIcon() { return SLM::getIcon(); diff --git a/src/OlaLevel.php b/src/OlaLevel.php index 05a15e09fc0..6e3dec41001 100644 --- a/src/OlaLevel.php +++ b/src/OlaLevel.php @@ -56,6 +56,11 @@ public static function getTable($classname = null) return CommonDBTM::getTable(__CLASS__); } + public static function getSectorizedDetails(): array + { + return ['config', OLA::class, self::class]; + } + public function cleanDBonPurge() { parent::cleanDBonPurge(); diff --git a/src/PDU.php b/src/PDU.php index c77bee978a3..37abdbb0d70 100644 --- a/src/PDU.php +++ b/src/PDU.php @@ -63,6 +63,11 @@ public static function getTypeName($nb = 0) return _n('PDU', 'PDUs', $nb); } + public static function getSectorizedDetails(): array + { + return ['assets', self::class]; + } + public function defineTabs($options = []) { $ong = []; diff --git a/src/PassiveDCEquipment.php b/src/PassiveDCEquipment.php index 5e7c0df6ad1..ae3540f5c48 100644 --- a/src/PassiveDCEquipment.php +++ b/src/PassiveDCEquipment.php @@ -54,6 +54,11 @@ public static function getTypeName($nb = 0) return _n('Passive device', 'Passive devices', $nb); } + public static function getSectorizedDetails(): array + { + return ['assets', self::class]; + } + public function defineTabs($options = []) { $ong = []; diff --git a/src/Peripheral.php b/src/Peripheral.php index 89695a62c15..b640258a5b7 100644 --- a/src/Peripheral.php +++ b/src/Peripheral.php @@ -83,6 +83,10 @@ public static function getTypeName($nb = 0) return _n('Peripheral', 'Peripherals', $nb); } + public static function getSectorizedDetails(): array + { + return ['assets', self::class]; + } /** * @see CommonDBTM::useDeletedToLockIfDynamic() diff --git a/src/Phone.php b/src/Phone.php index 5195b5a5776..e8976d569ed 100644 --- a/src/Phone.php +++ b/src/Phone.php @@ -86,6 +86,10 @@ public static function getTypeName($nb = 0) return _n('Phone', 'Phones', $nb); } + public static function getSectorizedDetails(): array + { + return ['assets', self::class]; + } /** * @see CommonDBTM::useDeletedToLockIfDynamic() diff --git a/src/Planning.php b/src/Planning.php index 64eb2b6b1fc..75e0137a902 100644 --- a/src/Planning.php +++ b/src/Planning.php @@ -45,6 +45,7 @@ use Sabre\VObject\Property\FlatText; use Sabre\VObject\Property\ICalendar\Recur; use Sabre\VObject\Reader; +use Glpi\Features\PlanningEvent; /** * Planning Class @@ -145,7 +146,7 @@ public static function getAdditionalMenuOptions() { if (PlanningExternalEvent::canView()) { return [ - 'external' => [ + PlanningEvent::class => [ 'title' => PlanningExternalEvent::getTypeName(Session::getPluralNumber()), 'page' => PlanningExternalEvent::getSearchURL(false), 'links' => [ diff --git a/src/PlanningExternalEvent.php b/src/PlanningExternalEvent.php index 6b91b3dd626..bab14659a2f 100644 --- a/src/PlanningExternalEvent.php +++ b/src/PlanningExternalEvent.php @@ -57,6 +57,11 @@ public static function getTypeName($nb = 0) return _n('External event', 'External events', $nb); } + public static function getSectorizedDetails(): array + { + return ['helpdesk', Planning::class, self::class]; + } + public function defineTabs($options = []) { $ong = []; diff --git a/src/Printer.php b/src/Printer.php index 674dbedaf92..a643af9312b 100644 --- a/src/Printer.php +++ b/src/Printer.php @@ -86,6 +86,10 @@ public static function getTypeName($nb = 0) return _n('Printer', 'Printers', $nb); } + public static function getSectorizedDetails(): array + { + return ['assets', self::class]; + } /** * @see CommonDBTM::useDeletedToLockIfDynamic() diff --git a/src/Problem.php b/src/Problem.php index 1f6cbdaa7fa..a33e3c91c8a 100644 --- a/src/Problem.php +++ b/src/Problem.php @@ -74,6 +74,10 @@ public static function getTypeName($nb = 0) return _n('Problem', 'Problems', $nb); } + public static function getSectorizedDetails(): array + { + return ['helpdesk', self::class]; + } public function canSolve() { diff --git a/src/ProblemTemplate.php b/src/ProblemTemplate.php index 090efa60404..0e8de259ee2 100644 --- a/src/ProblemTemplate.php +++ b/src/ProblemTemplate.php @@ -42,14 +42,16 @@ class ProblemTemplate extends ITILTemplate { use Glpi\Features\Clonable; - public $second_level_menu = "problem"; - public $third_level_menu = "ProblemTemplate"; - public static function getTypeName($nb = 0) { return _n('Problem template', 'Problem templates', $nb); } + public static function getSectorizedDetails(): array + { + return ['helpdesk', Problem::class, self::class]; + } + public function getCloneRelations(): array { return [ diff --git a/src/Profile.php b/src/Profile.php index d0d55546c92..98ccfe23539 100644 --- a/src/Profile.php +++ b/src/Profile.php @@ -134,6 +134,11 @@ public static function getTypeName($nb = 0) return _n('Profile', 'Profiles', $nb); } + public static function getSectorizedDetails(): array + { + return ['admin', self::class]; + } + public function defineTabs($options = []) { $ong = []; diff --git a/src/Project.php b/src/Project.php index 3e74b43bb9e..9ec6ad5a55e 100644 --- a/src/Project.php +++ b/src/Project.php @@ -88,6 +88,11 @@ public static function getTypeName($nb = 0) return _n('Project', 'Projects', $nb); } + public static function getSectorizedDetails(): array + { + return ['tools', self::class]; + } + public static function canView(): bool { return Session::haveRightsOr(self::$rightname, [self::READALL, self::READMY]); @@ -217,7 +222,7 @@ public static function getAdditionalMenuContent() public static function getAdditionalMenuOptions() { return [ - 'task' => [ + ProjectTask::class => [ 'title' => __('My tasks'), 'page' => ProjectTask::getSearchURL(false), 'links' => [ diff --git a/src/ProjectTask.php b/src/ProjectTask.php index 14f0d8c4a13..ebdfcd12d99 100644 --- a/src/ProjectTask.php +++ b/src/ProjectTask.php @@ -77,6 +77,11 @@ public static function getTypeName($nb = 0) return _n('Project task', 'Project tasks', $nb); } + public static function getSectorizedDetails(): array + { + return ['tools', Project::class, self::class]; + } + public static function getIcon() { return 'ti ti-list-check'; diff --git a/src/QueuedNotification.php b/src/QueuedNotification.php index 7ded293419f..3ff4fbb8186 100644 --- a/src/QueuedNotification.php +++ b/src/QueuedNotification.php @@ -51,6 +51,11 @@ public static function getTypeName($nb = 0) return __('Notification queue'); } + public static function getSectorizedDetails(): array + { + return ['admin', self::class]; + } + public static function canCreate(): bool { // Everybody can create : human and cron diff --git a/src/QueuedWebhook.php b/src/QueuedWebhook.php index 58842e07c99..7a7704ccbee 100644 --- a/src/QueuedWebhook.php +++ b/src/QueuedWebhook.php @@ -45,7 +45,7 @@ class QueuedWebhook extends CommonDBChild { public static $rightname = 'config'; - public static $itemtype = Webhook::class; + public static $itemtype = \Webhook::class; public static $items_id = 'webhooks_id'; public static function getTypeName($nb = 0) @@ -53,6 +53,11 @@ public static function getTypeName($nb = 0) return __('Webhook queue'); } + public static function getSectorizedDetails(): array + { + return ['config', Webhook::class]; + } + public static function canCreate(): bool { // Everybody can create : human and cron diff --git a/src/RSSFeed.php b/src/RSSFeed.php index 514c2b4906d..766f95cc5fa 100644 --- a/src/RSSFeed.php +++ b/src/RSSFeed.php @@ -60,6 +60,11 @@ public static function getTypeName($nb = 0) return _n('Personal RSS feed', 'Personal RSS feed', $nb); } + public static function getSectorizedDetails(): array + { + return ['tools', self::class]; + } + public static function canCreate(): bool { return (Session::haveRightsOr(self::$rightname, [CREATE, self::PERSONAL])); diff --git a/src/Rack.php b/src/Rack.php index 97008fe7905..44fadaebc43 100644 --- a/src/Rack.php +++ b/src/Rack.php @@ -72,6 +72,11 @@ public static function getTypeName($nb = 0) return _n('Rack', 'Racks', $nb); } + public static function getSectorizedDetails(): array + { + return ['assets', self::class]; + } + public function defineTabs($options = []) { $ong = []; diff --git a/src/RecurrentChange.php b/src/RecurrentChange.php index 43dd9c6dc45..14b8281b3dc 100644 --- a/src/RecurrentChange.php +++ b/src/RecurrentChange.php @@ -35,11 +35,6 @@ class RecurrentChange extends CommonITILRecurrent { - /** - * @var string CommonDropdown - */ - public $second_level_menu = "recurrentchange"; - /** * @var string Right managements */ @@ -50,6 +45,11 @@ public static function getTypeName($nb = 0) return __('Recurrent changes'); } + public static function getSectorizedDetails(): array + { + return ['helpdesk', self::class]; + } + public static function getConcreteClass() { return Change::class; diff --git a/src/RefusedEquipment.php b/src/RefusedEquipment.php index 533d8f12ee3..72089fd599a 100644 --- a/src/RefusedEquipment.php +++ b/src/RefusedEquipment.php @@ -33,6 +33,7 @@ * --------------------------------------------------------------------- */ +use Glpi\Inventory\Inventory; use Glpi\Inventory\Request; /** @@ -51,6 +52,11 @@ public static function getTypeName($nb = 0) return _n('Equipment refused by rules log', 'Equipments refused by rules log', $nb); } + public static function getSectorizedDetails(): array + { + return ['admin', Inventory::class, self::class]; + } + public function rawSearchOptions() { $tab = parent::rawSearchOptions(); diff --git a/src/Reminder.php b/src/Reminder.php index 76ceae36a73..b0a7a97e9cd 100644 --- a/src/Reminder.php +++ b/src/Reminder.php @@ -70,6 +70,10 @@ public static function getTypeName($nb = 0) return _n('Personal reminder', 'Personal reminders', $nb); } + public static function getSectorizedDetails(): array + { + return ['tools', self::class]; + } public static function canCreate(): bool { diff --git a/src/Rule.php b/src/Rule.php index 514002d3f10..9aec1ed0c42 100644 --- a/src/Rule.php +++ b/src/Rule.php @@ -246,14 +246,14 @@ public static function getMenuContent() $menu['rule']['page'] = static::getSearchURL(false); $menu['rule']['icon'] = static::getIcon(); - $menu['rule']['options']['transfer']['title'] = __('Transfer'); - $menu['rule']['options']['transfer']['page'] = "/front/transfer.php"; - $menu['rule']['options']['transfer']['links']['search'] = "/front/transfer.php"; + $menu['rule']['options'][Transfer::class]['title'] = __('Transfer'); + $menu['rule']['options'][Transfer::class]['page'] = "/front/transfer.php"; + $menu['rule']['options'][Transfer::class]['links']['search'] = "/front/transfer.php"; if (Session::haveRightsOr("transfer", [CREATE, UPDATE])) { - $menu['rule']['options']['transfer']['links']['transfer_list'] + $menu['rule']['options'][Transfer::class]['links']['transfer_list'] = "/front/transfer.action.php"; - $menu['rule']['options']['transfer']['links']['add'] = Transfer::getFormURL(false); + $menu['rule']['options'][Transfer::class]['links']['add'] = Transfer::getFormURL(false); } } diff --git a/src/SLA.php b/src/SLA.php index 388c362df45..1e28dc7b4e0 100644 --- a/src/SLA.php +++ b/src/SLA.php @@ -55,6 +55,11 @@ public static function getTypeName($nb = 0) return __('SLA'); } + public static function getSectorizedDetails(): array + { + return ['config', SLM::class, self::class]; + } + public static function getIcon() { return SLM::getIcon(); diff --git a/src/SLM.php b/src/SLM.php index fad0c7e3741..8d06d83c8e0 100644 --- a/src/SLM.php +++ b/src/SLM.php @@ -58,6 +58,11 @@ public static function getTypeName($nb = 0) return _n('Service level', 'Service levels', $nb); } + public static function getSectorizedDetails(): array + { + return ['config', self::class]; + } + public function defineTabs($options = []) { $ong = []; @@ -234,21 +239,21 @@ public static function getMenuContent() $menu['links']['add'] = SLM::getFormURL(false); } - $menu['options']['sla']['title'] = SLA::getTypeName(1); - $menu['options']['sla']['page'] = SLA::getSearchURL(false); - $menu['options']['sla']['links']['search'] = SLA::getSearchURL(false); + $menu['options'][SLA::class]['title'] = SLA::getTypeName(1); + $menu['options'][SLA::class]['page'] = SLA::getSearchURL(false); + $menu['options'][SLA::class]['links']['search'] = SLA::getSearchURL(false); - $menu['options']['ola']['title'] = OLA::getTypeName(1); - $menu['options']['ola']['page'] = OLA::getSearchURL(false); - $menu['options']['ola']['links']['search'] = OLA::getSearchURL(false); + $menu['options'][OLA::class]['title'] = OLA::getTypeName(1); + $menu['options'][OLA::class]['page'] = OLA::getSearchURL(false); + $menu['options'][OLA::class]['links']['search'] = OLA::getSearchURL(false); - $menu['options']['slalevel']['title'] = SlaLevel::getTypeName(Session::getPluralNumber()); - $menu['options']['slalevel']['page'] = SlaLevel::getSearchURL(false); - $menu['options']['slalevel']['links']['search'] = SlaLevel::getSearchURL(false); + $menu['options'][SlaLevel::class]['title'] = SlaLevel::getTypeName(Session::getPluralNumber()); + $menu['options'][SlaLevel::class]['page'] = SlaLevel::getSearchURL(false); + $menu['options'][SlaLevel::class]['links']['search'] = SlaLevel::getSearchURL(false); - $menu['options']['olalevel']['title'] = OlaLevel::getTypeName(Session::getPluralNumber()); - $menu['options']['olalevel']['page'] = OlaLevel::getSearchURL(false); - $menu['options']['olalevel']['links']['search'] = OlaLevel::getSearchURL(false); + $menu['options'][OlaLevel::class]['title'] = OlaLevel::getTypeName(Session::getPluralNumber()); + $menu['options'][OlaLevel::class]['page'] = OlaLevel::getSearchURL(false); + $menu['options'][OlaLevel::class]['links']['search'] = OlaLevel::getSearchURL(false); } if (count($menu)) { return $menu; diff --git a/src/SNMPCredential.php b/src/SNMPCredential.php index 55d425c753a..9fda01f6b2d 100644 --- a/src/SNMPCredential.php +++ b/src/SNMPCredential.php @@ -34,6 +34,7 @@ */ use Glpi\Application\View\TemplateRenderer; +use Glpi\Inventory\Inventory; /** * SNMP credentials @@ -49,6 +50,11 @@ public static function getTypeName($nb = 0) return _n('SNMP credential', 'SNMP credentials', $nb); } + public static function getSectorizedDetails(): array + { + return ['admin', Inventory::class, self::class]; + } + public static function rawSearchOptionsToAdd() { $tab = []; diff --git a/src/SlaLevel.php b/src/SlaLevel.php index 4983d201994..f6983430f45 100644 --- a/src/SlaLevel.php +++ b/src/SlaLevel.php @@ -45,12 +45,16 @@ class SlaLevel extends LevelAgreementLevel // No criteria protected $rulecriteriaclass = 'SlaLevelCriteria'; - public static function getTable($classname = null) { return CommonDBTM::getTable(__CLASS__); } + public static function getSectorizedDetails(): array + { + return ['config', SLA::class, self::class]; + } + public function cleanDBonPurge() { parent::cleanDBonPurge(); diff --git a/src/Software.php b/src/Software.php index 78da974827e..2adbb743ebe 100644 --- a/src/Software.php +++ b/src/Software.php @@ -72,6 +72,11 @@ public static function getTypeName($nb = 0) return _n('Software', 'Software', $nb); } + public static function getSectorizedDetails(): array + { + return ['assets', self::class]; + } + public static function getMenuShorcut() { return 's'; diff --git a/src/SoftwareLicense.php b/src/SoftwareLicense.php index 7cb88910f52..abf92092083 100644 --- a/src/SoftwareLicense.php +++ b/src/SoftwareLicense.php @@ -80,6 +80,11 @@ public static function getTypeName($nb = 0) return _n('License', 'Licenses', $nb); } + public static function getSectorizedDetails(): array + { + return ['management', self::class]; + } + public function pre_updateInDB() { // Clean end alert if expire is after old one diff --git a/src/Supplier.php b/src/Supplier.php index f744e9069e0..5cdd2cce736 100644 --- a/src/Supplier.php +++ b/src/Supplier.php @@ -60,6 +60,11 @@ public static function getTypeName($nb = 0) return _n('Supplier', 'Suppliers', $nb); } + public static function getSectorizedDetails(): array + { + return ['management', self::class]; + } + public function post_getEmpty() { $this->fields['is_active'] = 1; diff --git a/src/TicketRecurrent.php b/src/TicketRecurrent.php index d6d9d3cd462..2da435093b6 100644 --- a/src/TicketRecurrent.php +++ b/src/TicketRecurrent.php @@ -40,11 +40,6 @@ **/ class TicketRecurrent extends CommonITILRecurrent { - /** - * @var string CommonDropdown - */ - public $second_level_menu = "ticketrecurrent"; - /** * @var string Right managements */ @@ -55,6 +50,11 @@ public static function getTypeName($nb = 0) return __('Recurrent tickets'); } + public static function getSectorizedDetails(): array + { + return ['helpdesk', self::class]; + } + public static function getConcreteClass() { return Ticket::class; diff --git a/src/TicketTemplate.php b/src/TicketTemplate.php index e351291ca9a..e6fbf20f681 100644 --- a/src/TicketTemplate.php +++ b/src/TicketTemplate.php @@ -42,14 +42,16 @@ class TicketTemplate extends ITILTemplate { use Glpi\Features\Clonable; - public $second_level_menu = "ticket"; - public $third_level_menu = "TicketTemplate"; - public static function getTypeName($nb = 0) { return _n('Ticket template', 'Ticket templates', $nb); } + public static function getSectorizedDetails(): array + { + return ['helpdesk', Ticket::class, self::class]; + } + public function getCloneRelations(): array { return [ diff --git a/src/Transfer.php b/src/Transfer.php index 5a6f627d568..9eeabe00c99 100644 --- a/src/Transfer.php +++ b/src/Transfer.php @@ -84,6 +84,11 @@ public static function getTypeName($nb = 0) return __('Transfer'); } + public static function getSectorizedDetails(): array + { + return ['admin', Rule::class, self::class]; + } + public function maxActionsCount() { return 0; diff --git a/src/Unmanaged.php b/src/Unmanaged.php index 4eca1ba57ea..23562836dc7 100644 --- a/src/Unmanaged.php +++ b/src/Unmanaged.php @@ -55,6 +55,11 @@ public static function getTypeName($nb = 0) return _n('Unmanaged asset', 'Unmanaged assets', $nb); } + public static function getSectorizedDetails(): array + { + return ['assets', self::class]; + } + public function defineTabs($options = []) { diff --git a/src/User.php b/src/User.php index 56c060e2dfb..f419871791f 100644 --- a/src/User.php +++ b/src/User.php @@ -112,6 +112,11 @@ public static function getTypeName($nb = 0) return _n('User', 'Users', $nb); } + public static function getSectorizedDetails(): array + { + return ['admin', self::class]; + } + public static function getMenuShorcut() { return 'u'; diff --git a/src/Webhook.php b/src/Webhook.php index c4fed45775e..083dec8c03f 100644 --- a/src/Webhook.php +++ b/src/Webhook.php @@ -79,6 +79,11 @@ public static function getTypeName($nb = 0) return _n('Webhook', 'Webhooks', $nb); } + public static function getSectorizedDetails(): array + { + return ['config', self::class]; + } + public static function canCreate(): bool { return static::canUpdate(); diff --git a/src/autoload/CFG_GLPI.php b/src/autoload/CFG_GLPI.php index 5fc0039540d..4280c48766d 100644 --- a/src/autoload/CFG_GLPI.php +++ b/src/autoload/CFG_GLPI.php @@ -529,7 +529,7 @@ ], 'management' => [ 'datacenter' => [ - 'dcroom' => ['gridstack', 'rack'] + 'DCRoom' => ['gridstack', 'rack'] ], ], 'config' => [ @@ -541,7 +541,7 @@ 'ITILValidationTemplate' => ['tinymce'], ], 'notification' => [ - 'notificationtemplate' => ['tinymce'] + 'NotificationTemplate' => ['tinymce'] ], 'plugin' => [ 'marketplace' => ['marketplace'] diff --git a/templates/pages/generic_list.html.twig b/templates/pages/generic_list.html.twig new file mode 100644 index 00000000000..de40a107932 --- /dev/null +++ b/templates/pages/generic_list.html.twig @@ -0,0 +1,39 @@ +{# + # --------------------------------------------------------------------- + # + # GLPI - Gestionnaire Libre de Parc Informatique + # + # http://glpi-project.org + # + # @copyright 2015-2024 Teclib' and contributors. + # @licence https://www.gnu.org/licenses/gpl-3.0.html + # + # --------------------------------------------------------------------- + # + # LICENSE + # + # This file is part of GLPI. + # + # 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 . + # + # --------------------------------------------------------------------- + #} + +{% set header_params = call(class ~ '::getHeaderParameters') %} + +{{ call('Html::header', header_params) }} + +{{ call('Glpi\\Search\\SearchEngine::show', [class]) }} + +{{ call('Html::footer') }} diff --git a/tests/cypress/e2e/error_page.cy.js b/tests/cypress/e2e/error_page.cy.js index f7a6d43c20c..6e3435794d7 100644 --- a/tests/cypress/e2e/error_page.cy.js +++ b/tests/cypress/e2e/error_page.cy.js @@ -41,8 +41,8 @@ describe('Error page', () => { cy.changeProfile('Super-Admin'); const urls = [ - '/front/impactcsv.php', // streamed response - '/Dropdown/InvalidClassname', // modern controller + '/front/impactcsv.php', // streamed response + '/InvalidClassname/Search', // modern controller ]; const expected_code = 400; diff --git a/tests/fixtures/plugins/tester/inc/mylegacyclass.class.php b/tests/fixtures/plugins/tester/inc/mylegacyclass.class.php index f08a25eadf4..6b8cb9ddad8 100644 --- a/tests/fixtures/plugins/tester/inc/mylegacyclass.class.php +++ b/tests/fixtures/plugins/tester/inc/mylegacyclass.class.php @@ -32,10 +32,10 @@ * --------------------------------------------------------------------- */ -final class PluginTesterMyLegacyClass extends CommonDropdown +final class PluginTesterMyLegacyClass extends CommonDBTM { public static function getTypeName($nb = 0): string { - return 'Tester plugin legacy dropdown'; + return 'Tester plugin legacy itemtype'; } } diff --git a/front/transfer.php b/tests/fixtures/plugins/tester/inc/mylegacydropdown.class.php similarity index 84% rename from front/transfer.php rename to tests/fixtures/plugins/tester/inc/mylegacydropdown.class.php index 37820c67d90..978027e0c96 100644 --- a/front/transfer.php +++ b/tests/fixtures/plugins/tester/inc/mylegacydropdown.class.php @@ -8,7 +8,6 @@ * http://glpi-project.org * * @copyright 2015-2024 Teclib' and contributors. - * @copyright 2003-2014 by the INDEPNET Development Team. * @licence https://www.gnu.org/licenses/gpl-3.0.html * * --------------------------------------------------------------------- @@ -33,10 +32,10 @@ * --------------------------------------------------------------------- */ -Session::checkRight("transfer", READ); - -Html::header(__('Transfer'), '', 'admin', 'rule', 'transfer'); - -Search::show('Transfer'); - -Html::footer(); +final class PluginTesterMyLegacyDropdown extends CommonDropdown +{ + public static function getTypeName($nb = 0): string + { + return 'Tester plugin legacy dropdown'; + } +} diff --git a/tests/fixtures/plugins/tester/src/MyPsr4Class.php b/tests/fixtures/plugins/tester/src/MyPsr4Class.php index d69da3125ff..e99578b0e8e 100644 --- a/tests/fixtures/plugins/tester/src/MyPsr4Class.php +++ b/tests/fixtures/plugins/tester/src/MyPsr4Class.php @@ -34,12 +34,12 @@ namespace GlpiPlugin\Tester; -use CommonDropdown; +use CommonDBTM; -final class MyPsr4Class extends CommonDropdown +final class MyPsr4Class extends CommonDBTM { public static function getTypeName($nb = 0): string { - return 'Tester plugin PSR4 dropdown'; + return 'Tester plugin PSR4 itemtype'; } } diff --git a/front/budget.php b/tests/fixtures/plugins/tester/src/MyPsr4Dropdown.php similarity index 83% rename from front/budget.php rename to tests/fixtures/plugins/tester/src/MyPsr4Dropdown.php index 74656c6f594..c10745c909a 100644 --- a/front/budget.php +++ b/tests/fixtures/plugins/tester/src/MyPsr4Dropdown.php @@ -8,7 +8,6 @@ * http://glpi-project.org * * @copyright 2015-2024 Teclib' and contributors. - * @copyright 2003-2014 by the INDEPNET Development Team. * @licence https://www.gnu.org/licenses/gpl-3.0.html * * --------------------------------------------------------------------- @@ -33,10 +32,14 @@ * --------------------------------------------------------------------- */ -Session::checkRight("budget", READ); +namespace GlpiPlugin\Tester; -Html::header(Budget::getTypeName(1), $_SERVER['PHP_SELF'], "management", "budget"); +use CommonDropdown; -Search::show('Budget'); - -Html::footer(); +final class MyPsr4Dropdown extends CommonDropdown +{ + public static function getTypeName($nb = 0): string + { + return 'Tester plugin PSR4 dropdown'; + } +} diff --git a/tests/fixtures/plugins/tester/src/PluginTesterMyPseudoPsr4Class.php b/tests/fixtures/plugins/tester/src/PluginTesterMyPseudoPsr4Class.php index ca7b1b9483b..bc05b6860f0 100644 --- a/tests/fixtures/plugins/tester/src/PluginTesterMyPseudoPsr4Class.php +++ b/tests/fixtures/plugins/tester/src/PluginTesterMyPseudoPsr4Class.php @@ -32,10 +32,10 @@ * --------------------------------------------------------------------- */ -final class PluginTesterMyPseudoPsr4Class extends CommonDropdown +final class PluginTesterMyPseudoPsr4Class extends CommonDBTM { public static function getTypeName($nb = 0): string { - return 'Tester plugin pseudo-PSR4 dropdown'; + return 'Tester plugin pseudo-PSR4 itemtype'; } } diff --git a/front/user.php b/tests/fixtures/plugins/tester/src/PluginTesterMyPseudoPsr4Dropdown.php similarity index 83% rename from front/user.php rename to tests/fixtures/plugins/tester/src/PluginTesterMyPseudoPsr4Dropdown.php index 8c4cb8d0089..f89bfaad36c 100644 --- a/front/user.php +++ b/tests/fixtures/plugins/tester/src/PluginTesterMyPseudoPsr4Dropdown.php @@ -8,7 +8,6 @@ * http://glpi-project.org * * @copyright 2015-2024 Teclib' and contributors. - * @copyright 2003-2014 by the INDEPNET Development Team. * @licence https://www.gnu.org/licenses/gpl-3.0.html * * --------------------------------------------------------------------- @@ -33,10 +32,10 @@ * --------------------------------------------------------------------- */ -Session::checkRight("user", READ); - -Html::header(User::getTypeName(Session::getPluralNumber()), '', "admin", "user"); - -Search::show('User'); - -Html::footer(); +final class PluginTesterMyPseudoPsr4Dropdown extends CommonDropdown +{ + public static function getTypeName($nb = 0): string + { + return 'Tester plugin pseudo-PSR4 dropdown'; + } +}