feature/glpi-12.0 (#129)

* feature/glpi-12.0

* fix CI

---------

Co-authored-by: Stanislas Kita <[email protected]>
This commit is contained in:
Romain B.andStanislas Kita authored and GitHub committed 2026-10-05 15:12:25 +02:00
1 parent 3596fd5659
commit 8632a60ba2
15 files changed
+41 -905

No files matched your search

+1 -1
View File
@@ -20,7 +20,7 @@ jobs:
name: "Generate CI matrix"
uses: "glpi-project/plugin-ci-workflows/.github/workflows/generate-ci-matrix.yml@v1"
with:
glpi-version: "11.0.x"
glpi-version: "12.0.x"
ci:
name: "GLPI ${{ matrix.glpi-version }} - php:${{ matrix.php-version }} - ${{ matrix.db-image }}"
needs: "generate-ci-matrix"
+7
View File
@@ -0,0 +1,7 @@
# Changelog
## [UNRELEASED]
### Added
- GLPI 12 compatibility
+1
View File
@@ -0,0 +1 @@
include ../../PluginsMakefile.mk
+1 -3
View File
@@ -2,10 +2,8 @@
"require": {
"php": ">=8.2"
},
"require-dev": {
"glpi-project/tools": "^0.8"
},
"config": {
"autoloader-suffix": "PluginExample",
"optimize-autoloader": true,
"platform": {
"php": "8.2.99"
Generated
+3 -875
View File
@@ -4,881 +4,9 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "0bb7734a8837cdd118f20d259d3613e7",
"content-hash": "4cacb822b12bf0d2a0dbcf952b20ef7b",
"packages": [],
"packages-dev": [
{
"name": "glpi-project/tools",
"version": "0.8.4",
"source": {
"type": "git",
"url": "https://github.com/glpi-project/tools.git",
"reference": "2791387652f570c0f676a372ad74c4dade65c937"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/glpi-project/tools/zipball/2791387652f570c0f676a372ad74c4dade65c937",
"reference": "2791387652f570c0f676a372ad74c4dade65c937",
"shasum": ""
},
"require": {
"symfony/console": "^5.4 || ^6.0",
"twig/twig": "^3.3"
},
"require-dev": {
"nikic/php-parser": "^4.13",
"phpstan/phpstan-src": "^1.10"
},
"bin": [
"bin/extract-locales",
"bin/licence-headers-check",
"tools/plugin-release"
],
"type": "library",
"autoload": {
"psr-4": {
"GlpiProject\\Tools\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"GPL-3.0-or-later"
],
"authors": [
{
"name": "Teclib'",
"email": "[email protected]",
"homepage": "http://teclib-group.com"
}
],
"description": "Various tools for GLPI and its plugins",
"keywords": [
"glpi",
"plugins",
"tools"
],
"support": {
"issues": "https://github.com/glpi-project/tools/issues",
"source": "https://github.com/glpi-project/tools"
},
"time": "2026-09-09T13:56:33+00:00"
},
{
"name": "psr/container",
"version": "2.0.2",
"source": {
"type": "git",
"url": "https://github.com/php-fig/container.git",
"reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/container/zipball/c71ecc56dfe541dbd90c5360474fbc405f8d5963",
"reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963",
"shasum": ""
},
"require": {
"php": ">=7.4.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Psr\\Container\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "https://www.php-fig.org/"
}
],
"description": "Common Container Interface (PHP FIG PSR-11)",
"homepage": "https://github.com/php-fig/container",
"keywords": [
"PSR-11",
"container",
"container-interface",
"container-interop",
"psr"
],
"support": {
"issues": "https://github.com/php-fig/container/issues",
"source": "https://github.com/php-fig/container/tree/2.0.2"
},
"time": "2021-11-05T16:47:00+00:00"
},
{
"name": "symfony/console",
"version": "v6.4.47",
"source": {
"type": "git",
"url": "https://github.com/symfony/console.git",
"reference": "0f758dfab4608cac6a342b7e7f80cb84c9cc98ca"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/console/zipball/0f758dfab4608cac6a342b7e7f80cb84c9cc98ca",
"reference": "0f758dfab4608cac6a342b7e7f80cb84c9cc98ca",
"shasum": ""
},
"require": {
"php": ">=8.1",
"symfony/deprecation-contracts": "^2.5|^3",
"symfony/polyfill-mbstring": "~1.0",
"symfony/service-contracts": "^2.5|^3",
"symfony/string": "^5.4|^6.0|^7.0"
},
"conflict": {
"symfony/dependency-injection": "<5.4",
"symfony/dotenv": "<5.4",
"symfony/event-dispatcher": "<5.4",
"symfony/lock": "<5.4",
"symfony/process": "<5.4"
},
"provide": {
"psr/log-implementation": "1.0|2.0|3.0"
},
"require-dev": {
"psr/log": "^1|^2|^3",
"symfony/config": "^5.4|^6.0|^7.0",
"symfony/dependency-injection": "^5.4|^6.0|^7.0",
"symfony/event-dispatcher": "^5.4|^6.0|^7.0",
"symfony/http-foundation": "^6.4|^7.0",
"symfony/http-kernel": "^6.4|^7.0",
"symfony/lock": "^5.4|^6.0|^7.0",
"symfony/messenger": "^5.4|^6.0|^7.0",
"symfony/process": "^5.4|^6.0|^7.0",
"symfony/stopwatch": "^5.4|^6.0|^7.0",
"symfony/var-dumper": "^5.4|^6.0|^7.0"
},
"type": "library",
"autoload": {
"psr-4": {
"Symfony\\Component\\Console\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "[email protected]"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Eases the creation of beautiful and testable command line interfaces",
"homepage": "https://symfony.com",
"keywords": [
"cli",
"command-line",
"console",
"terminal"
],
"support": {
"source": "https://github.com/symfony/console/tree/v6.4.47"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://github.com/nicolas-grekas",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2026-09-18T10:23:48+00:00"
},
{
"name": "symfony/deprecation-contracts",
"version": "v3.7.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/deprecation-contracts.git",
"reference": "f3202fa1b5097b0af062dc978b32ecf63404e31d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/f3202fa1b5097b0af062dc978b32ecf63404e31d",
"reference": "f3202fa1b5097b0af062dc978b32ecf63404e31d",
"shasum": ""
},
"require": {
"php": ">=8.1"
},
"type": "library",
"extra": {
"thanks": {
"url": "https://github.com/symfony/contracts",
"name": "symfony/contracts"
},
"branch-alias": {
"dev-main": "3.7-dev"
}
},
"autoload": {
"files": [
"function.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Nicolas Grekas",
"email": "[email protected]"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "A generic function and convention to trigger deprecation notices",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/deprecation-contracts/tree/v3.7.1"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://github.com/nicolas-grekas",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2026-06-05T06:23:12+00:00"
},
{
"name": "symfony/polyfill-ctype",
"version": "v1.37.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-ctype.git",
"reference": "141046a8f9477948ff284fa65be2095baafb94f2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/141046a8f9477948ff284fa65be2095baafb94f2",
"reference": "141046a8f9477948ff284fa65be2095baafb94f2",
"shasum": ""
},
"require": {
"php": ">=7.2"
},
"provide": {
"ext-ctype": "*"
},
"suggest": {
"ext-ctype": "For best performance"
},
"type": "library",
"extra": {
"thanks": {
"url": "https://github.com/symfony/polyfill",
"name": "symfony/polyfill"
}
},
"autoload": {
"files": [
"bootstrap.php"
],
"psr-4": {
"Symfony\\Polyfill\\Ctype\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Gert de Pagter",
"email": "[email protected]"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony polyfill for ctype functions",
"homepage": "https://symfony.com",
"keywords": [
"compatibility",
"ctype",
"polyfill",
"portable"
],
"support": {
"source": "https://github.com/symfony/polyfill-ctype/tree/v1.37.0"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://github.com/nicolas-grekas",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2026-04-10T16:19:22+00:00"
},
{
"name": "symfony/polyfill-intl-grapheme",
"version": "v1.43.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-intl-grapheme.git",
"reference": "5cac8f4db97208823aa353f59a01faad2da52c75"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/5cac8f4db97208823aa353f59a01faad2da52c75",
"reference": "5cac8f4db97208823aa353f59a01faad2da52c75",
"shasum": ""
},
"require": {
"php": ">=7.2"
},
"suggest": {
"ext-intl": "For best performance"
},
"type": "library",
"extra": {
"thanks": {
"url": "https://github.com/symfony/polyfill",
"name": "symfony/polyfill"
}
},
"autoload": {
"files": [
"bootstrap.php"
],
"psr-4": {
"Symfony\\Polyfill\\Intl\\Grapheme\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Nicolas Grekas",
"email": "[email protected]"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony polyfill for intl's grapheme_* functions",
"homepage": "https://symfony.com",
"keywords": [
"compatibility",
"grapheme",
"intl",
"polyfill",
"portable",
"shim"
],
"support": {
"source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.43.0"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://github.com/nicolas-grekas",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2026-09-25T15:46:47+00:00"
},
{
"name": "symfony/polyfill-intl-normalizer",
"version": "v1.43.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-intl-normalizer.git",
"reference": "ebd57ccc7edb93d632e184efbe7693d2517bab3b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/ebd57ccc7edb93d632e184efbe7693d2517bab3b",
"reference": "ebd57ccc7edb93d632e184efbe7693d2517bab3b",
"shasum": ""
},
"require": {
"php": ">=7.2"
},
"suggest": {
"ext-intl": "For best performance"
},
"type": "library",
"extra": {
"thanks": {
"url": "https://github.com/symfony/polyfill",
"name": "symfony/polyfill"
}
},
"autoload": {
"files": [
"bootstrap.php"
],
"psr-4": {
"Symfony\\Polyfill\\Intl\\Normalizer\\": ""
},
"classmap": [
"Resources/stubs"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Nicolas Grekas",
"email": "[email protected]"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony polyfill for intl's Normalizer class and related functions",
"homepage": "https://symfony.com",
"keywords": [
"compatibility",
"intl",
"normalizer",
"polyfill",
"portable",
"shim"
],
"support": {
"source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.43.0"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://github.com/nicolas-grekas",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2026-09-23T22:02:09+00:00"
},
{
"name": "symfony/polyfill-mbstring",
"version": "v1.43.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-mbstring.git",
"reference": "4d5d331bf731e0aedbc6b2f5e61135b7b7996a72"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/4d5d331bf731e0aedbc6b2f5e61135b7b7996a72",
"reference": "4d5d331bf731e0aedbc6b2f5e61135b7b7996a72",
"shasum": ""
},
"require": {
"ext-iconv": "*",
"php": ">=7.2"
},
"provide": {
"ext-mbstring": "*"
},
"suggest": {
"ext-mbstring": "For best performance"
},
"type": "library",
"extra": {
"thanks": {
"url": "https://github.com/symfony/polyfill",
"name": "symfony/polyfill"
}
},
"autoload": {
"files": [
"bootstrap.php"
],
"psr-4": {
"Symfony\\Polyfill\\Mbstring\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Nicolas Grekas",
"email": "[email protected]"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony polyfill for the Mbstring extension",
"homepage": "https://symfony.com",
"keywords": [
"compatibility",
"mbstring",
"polyfill",
"portable",
"shim"
],
"support": {
"source": "https://github.com/symfony/polyfill-mbstring/tree/v1.43.0"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://github.com/nicolas-grekas",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2026-09-24T15:19:04+00:00"
},
{
"name": "symfony/service-contracts",
"version": "v3.7.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/service-contracts.git",
"reference": "15e6a07ec2a2c75ceb1b21dd98105ee8456d2257"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/service-contracts/zipball/15e6a07ec2a2c75ceb1b21dd98105ee8456d2257",
"reference": "15e6a07ec2a2c75ceb1b21dd98105ee8456d2257",
"shasum": ""
},
"require": {
"php": ">=8.1",
"psr/container": "^1.1|^2.0",
"symfony/deprecation-contracts": "^2.5|^3"
},
"conflict": {
"ext-psr": "<1.1|>=2"
},
"type": "library",
"extra": {
"thanks": {
"url": "https://github.com/symfony/contracts",
"name": "symfony/contracts"
},
"branch-alias": {
"dev-main": "3.7-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Contracts\\Service\\": ""
},
"exclude-from-classmap": [
"/Test/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Nicolas Grekas",
"email": "[email protected]"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Generic abstractions related to writing services",
"homepage": "https://symfony.com",
"keywords": [
"abstractions",
"contracts",
"decoupling",
"interfaces",
"interoperability",
"standards"
],
"support": {
"source": "https://github.com/symfony/service-contracts/tree/v3.7.3"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://github.com/nicolas-grekas",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2026-07-27T15:39:01+00:00"
},
{
"name": "symfony/string",
"version": "v7.4.19",
"source": {
"type": "git",
"url": "https://github.com/symfony/string.git",
"reference": "02731ce2bd26514bec9efc0baef2cd0b0cf67f46"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/string/zipball/02731ce2bd26514bec9efc0baef2cd0b0cf67f46",
"reference": "02731ce2bd26514bec9efc0baef2cd0b0cf67f46",
"shasum": ""
},
"require": {
"php": ">=8.2",
"symfony/deprecation-contracts": "^2.5|^3.0",
"symfony/polyfill-ctype": "~1.8",
"symfony/polyfill-intl-grapheme": "~1.33",
"symfony/polyfill-intl-normalizer": "~1.0",
"symfony/polyfill-mbstring": "~1.0"
},
"conflict": {
"symfony/translation-contracts": "<2.5"
},
"require-dev": {
"symfony/emoji": "^7.1|^8.0",
"symfony/http-client": "^6.4|^7.0|^8.0",
"symfony/intl": "^6.4|^7.0|^8.0",
"symfony/translation-contracts": "^2.5|^3.0",
"symfony/var-exporter": "^6.4|^7.0|^8.0"
},
"type": "library",
"autoload": {
"files": [
"Resources/functions.php"
],
"psr-4": {
"Symfony\\Component\\String\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Nicolas Grekas",
"email": "[email protected]"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Provides an object-oriented API to strings and deals with bytes, UTF-8 code points and grapheme clusters in a unified way",
"homepage": "https://symfony.com",
"keywords": [
"grapheme",
"i18n",
"string",
"unicode",
"utf-8",
"utf8"
],
"support": {
"source": "https://github.com/symfony/string/tree/v7.4.19"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://github.com/nicolas-grekas",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2026-09-11T14:46:58+00:00"
},
{
"name": "twig/twig",
"version": "v3.30.0",
"source": {
"type": "git",
"url": "https://github.com/twigphp/Twig.git",
"reference": "8c737079b726af72ff8ef3c595be9f6a810ea1ef"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/twigphp/Twig/zipball/8c737079b726af72ff8ef3c595be9f6a810ea1ef",
"reference": "8c737079b726af72ff8ef3c595be9f6a810ea1ef",
"shasum": ""
},
"require": {
"php": ">=8.1.0",
"symfony/deprecation-contracts": "^2.5|^3",
"symfony/polyfill-ctype": "^1.8",
"symfony/polyfill-mbstring": "^1.3"
},
"require-dev": {
"php-cs-fixer/shim": "^3.0@stable",
"phpstan/phpstan": "^2.0@stable",
"psr/container": "^1.0|^2.0",
"symfony/phpunit-bridge": "^5.4.9|^6.4|^7.0"
},
"type": "library",
"autoload": {
"files": [
"src/Resources/core.php",
"src/Resources/debug.php",
"src/Resources/escaper.php",
"src/Resources/string_loader.php"
],
"psr-4": {
"Twig\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "[email protected]",
"homepage": "http://fabien.potencier.org",
"role": "Lead Developer"
},
{
"name": "Twig Team",
"role": "Contributors"
},
{
"name": "Armin Ronacher",
"email": "[email protected]",
"role": "Project Founder"
}
],
"description": "Twig, the flexible, fast, and secure template language for PHP",
"homepage": "https://twig.symfony.com",
"keywords": [
"templating"
],
"support": {
"issues": "https://github.com/twigphp/Twig/issues",
"source": "https://github.com/twigphp/Twig/tree/v3.30.0"
},
"funding": [
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/twig/twig",
"type": "tidelift"
}
],
"time": "2026-09-25T13:20:01+00:00"
}
],
"packages-dev": [],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": {},
@@ -891,5 +19,5 @@
"platform-overrides": {
"php": "8.2.99"
},
"plugin-api-version": "2.9.0"
"plugin-api-version": "2.6.0"
}
+3 -1
View File
@@ -33,13 +33,15 @@
// Purpose of file:
// ----------------------------------------------------------------------
use GlpiPlugin\Example\Config;
// Non menu entry case
//header("Location:../../central.php");
// Entry menu case
include(__DIR__ . '/../../../inc/includes.php');
Session::checkRight('config', UPDATE);
Session::checkRight(Config::$rightname, UPDATE);
// To be available when plugin in not activated
Plugin::load('example');
+1
View File
@@ -1,6 +1,7 @@
<?xml version="1.0"?>
<psalm
runTaintAnalysis="true"
cacheDirectory="var/psalm"
>
<projectFiles>
<directory name="front" />
+3 -3
View File
@@ -44,9 +44,9 @@ use function Safe\define;
define('PLUGIN_EXAMPLE_VERSION', '0.1.0');
// Minimal GLPI version, inclusive
define('PLUGIN_EXAMPLE_MIN_GLPI', '11.0.0');
define('PLUGIN_EXAMPLE_MIN_GLPI', '12.0.0');
// Maximum GLPI version, exclusive
define('PLUGIN_EXAMPLE_MAX_GLPI', '11.0.99');
define('PLUGIN_EXAMPLE_MAX_GLPI', '12.0.99');
/**
* Init hooks of the plugin.
@@ -113,7 +113,7 @@ function plugin_init_example()
}
// Config page
if (Session::haveRight('config', UPDATE)) {
if (Session::haveRight(Config::$rightname, UPDATE)) {
$PLUGIN_HOOKS['config_page']['example'] = 'front/config.php';
}
+7 -6
View File
@@ -36,6 +36,7 @@
namespace GlpiPlugin\Example;
use CommonDBChild;
use FQDN;
use Session;
// Sample of class that inherit from CommonDBChild. The behaviour of CommonRelation is similar.
@@ -47,8 +48,8 @@ use Session;
class Child extends CommonDBChild
{
// A child rely on an item. If $itemtype=='itemtype', then that is a variable item.
public static $itemtype = 'itemtype';
public static $items_id = 'items_id';
public static string $itemtype = 'itemtype';
public static string $items_id = 'items_id';
// With 0.84, you have to specify each right (create, view, update and delete), because
// CommonDBChild(s) and CommonDBRelation(s) mainly depend on the rights on the parent item
@@ -61,25 +62,25 @@ class Child extends CommonDBChild
// * $mustBeAttached: some CommonDBChild can be free, without any parent.
public static function canCreate(): bool
{
return (Session::haveRight('internet', UPDATE)
return (Session::haveRight(FQDN::$rightname, UPDATE)
&& parent::canCreate());
}
public static function canView(): bool
{
return (Session::haveRight('internet', READ)
return (Session::haveRight(FQDN::$rightname, READ)
&& parent::canView());
}
public static function canUpdate(): bool
{
return (Session::haveRight('internet', UPDATE)
return (Session::haveRight(FQDN::$rightname, UPDATE)
&& parent::canUpdate());
}
public static function canDelete(): bool
{
return (Session::haveRight('internet', DELETE)
return (Session::haveRight(FQDN::$rightname, DELETE)
&& parent::canDelete());
}
+4 -2
View File
@@ -40,7 +40,9 @@ use Toolbox;
class Config extends CommonDBTM
{
protected static $notable = true;
public static string $rightname = 'config';
protected static bool $notable = true;
public function getTabNameForItem(CommonGLPI $item, $withtemplate = 0)
{
@@ -62,7 +64,7 @@ class Config extends CommonDBTM
{
global $CFG_GLPI;
if (!Session::haveRight('config', UPDATE)) {
if (!Session::haveRight(self::$rightname, UPDATE)) {
return false;
}
+1 -3
View File
@@ -79,9 +79,7 @@ class Document extends GlpiDocument
**/
public static function getTable($classname = null)
{
if ($classname === null) {
$classname = static::class;
}
$classname ??= static::class;
if ($classname == static::class) {
return parent::getTable(Document::class);
}
+2 -4
View File
@@ -55,7 +55,7 @@ use function Safe\strtotime;
class Example extends CommonDBTM
{
public static $tags = '[EXAMPLE_ID]';
public static $rightname = 'plugin_example';
public static string $rightname = 'plugin_example';
// Should return the localized name of the type
public static function getTypeName($nb = 0)
@@ -518,9 +518,7 @@ class Example extends CommonDBTM
public static function dashboardCards($cards = [])
{
if (is_null($cards)) {
$cards = [];
}
$cards ??= [];
$new_cards = [
'plugin_example_card' => [
'widgettype' => ['example'],
+3 -3
View File
@@ -45,8 +45,8 @@ use Item_Devices;
**/
class Item_DeviceCamera extends Item_Devices
{
public static $itemtype_2 = DeviceCamera::class;
public static $items_id_2 = 'plugin_example_devicecameras_id';
public static ?string $itemtype_2 = DeviceCamera::class;
public static ?string $items_id_2 = 'plugin_example_devicecameras_id';
protected static $notable = false;
protected static bool $notable = false;
}
+1 -1
View File
@@ -47,7 +47,7 @@ use Rule;
class RuleTest extends Rule
{
// From Rule
public static $rightname = 'rule_import';
public static string $rightname = 'rule_import';
public $can_sort = true;
public function getTitle()
+3 -3
View File
@@ -40,9 +40,9 @@ use RuleCollection;
class RuleTestCollection extends RuleCollection
{
// From RuleCollection
public $stop_on_first_match = true;
public static $rightname = 'rule_import';
public $menu_option = 'test';
public bool $stop_on_first_match = true;
public static string $rightname = 'rule_import';
public string $menu_option = 'test';
public function getTitle()
{