diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml
index 2d1180d..62d4e17 100644
--- a/.github/workflows/continuous-integration.yml
+++ b/.github/workflows/continuous-integration.yml
@@ -53,7 +53,7 @@ jobs:
name: "Generate CI matrix"
uses: "glpi-project/plugin-ci-workflows/.github/workflows/generate-ci-matrix.yml@v1"
with:
- glpi-version: "10.0.x"
+ glpi-version: "11.0.x"
ci:
name: "GLPI ${{ matrix.glpi-version }} - php:${{ matrix.php-version }} - ${{ matrix.db-image }}"
needs: "generate-ci-matrix"
diff --git a/.twig_cs.dist.php b/.twig_cs.dist.php
index 352fe0a..6041bcf 100644
--- a/.twig_cs.dist.php
+++ b/.twig_cs.dist.php
@@ -2,14 +2,16 @@
declare(strict_types=1);
-use FriendsOfTwig\Twigcs;
+use FriendsOfTwig\Twigcs\Finder\TemplateFinder;
+use FriendsOfTwig\Twigcs\Config\Config;
+use Glpi\Tools\GlpiTwigRuleset;
-$finder = Twigcs\Finder\TemplateFinder::create()
+$finder = TemplateFinder::create()
->in(__DIR__ . '/templates')
->name('*.html.twig')
->ignoreVCSIgnored(true);
-return Twigcs\Config\Config::create()
+return Config::create()
->setFinder($finder)
- ->setRuleSet(\Glpi\Tools\GlpiTwigRuleset::class)
+ ->setRuleSet(GlpiTwigRuleset::class)
;
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9004616..166286d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,7 +5,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).
-## [UNRELEASE]
+## [4.1.0] - 2025-10-01
+
+### Added
+
+- GLPI 11 compatibility
## [4.0.2] - 2025-09-30
diff --git a/composer.json b/composer.json
index abb3b8e..b4bc5cf 100644
--- a/composer.json
+++ b/composer.json
@@ -1,12 +1,13 @@
{
"require": {
- "php": ">=7.4",
- "symfony/yaml": "^5.4",
+ "php": ">=8.2",
+ "symfony/yaml": "^7.3",
"tecnickcom/tcpdf": "^6.4"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.73",
"friendsoftwig/twigcs": "^6.1",
+ "glpi-project/phpstan-glpi": "^1.0",
"glpi-project/tools": "^0.7.4",
"php-parallel-lint/php-parallel-lint": "^1.4",
"phpstan/extension-installer": "^1.4",
@@ -16,7 +17,7 @@
"config": {
"optimize-autoloader": true,
"platform": {
- "php": "7.4.0"
+ "php": "8.2.99"
},
"sort-packages": true,
"allow-plugins": {
diff --git a/composer.lock b/composer.lock
index 2df0c14..2d1df72 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,24 +4,24 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "8fd215cf6d5e2da742e395d9b0ebd8be",
+ "content-hash": "322ca0605fe8ff3d0a33158bbbdf409f",
"packages": [
{
"name": "symfony/deprecation-contracts",
- "version": "v2.5.4",
+ "version": "v3.6.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/deprecation-contracts.git",
- "reference": "605389f2a7e5625f273b53960dc46aeaf9c62918"
+ "reference": "63afe740e99a13ba87ec199bb07bbdee937a5b62"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/605389f2a7e5625f273b53960dc46aeaf9c62918",
- "reference": "605389f2a7e5625f273b53960dc46aeaf9c62918",
+ "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/63afe740e99a13ba87ec199bb07bbdee937a5b62",
+ "reference": "63afe740e99a13ba87ec199bb07bbdee937a5b62",
"shasum": ""
},
"require": {
- "php": ">=7.1"
+ "php": ">=8.1"
},
"type": "library",
"extra": {
@@ -30,7 +30,7 @@
"name": "symfony/contracts"
},
"branch-alias": {
- "dev-main": "2.5-dev"
+ "dev-main": "3.6-dev"
}
},
"autoload": {
@@ -55,7 +55,7 @@
"description": "A generic function and convention to trigger deprecation notices",
"homepage": "https://symfony.com",
"support": {
- "source": "https://github.com/symfony/deprecation-contracts/tree/v2.5.4"
+ "source": "https://github.com/symfony/deprecation-contracts/tree/v3.6.0"
},
"funding": [
{
@@ -71,11 +71,11 @@
"type": "tidelift"
}
],
- "time": "2024-09-25T14:11:13+00:00"
+ "time": "2024-09-25T14:21:43+00:00"
},
{
"name": "symfony/polyfill-ctype",
- "version": "v1.31.0",
+ "version": "v1.33.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-ctype.git",
@@ -134,7 +134,7 @@
"portable"
],
"support": {
- "source": "https://github.com/symfony/polyfill-ctype/tree/v1.31.0"
+ "source": "https://github.com/symfony/polyfill-ctype/tree/v1.33.0"
},
"funding": [
{
@@ -145,6 +145,10 @@
"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"
@@ -154,31 +158,28 @@
},
{
"name": "symfony/yaml",
- "version": "v5.4.45",
+ "version": "v7.3.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/yaml.git",
- "reference": "a454d47278cc16a5db371fe73ae66a78a633371e"
+ "reference": "d4f4a66866fe2451f61296924767280ab5732d9d"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/yaml/zipball/a454d47278cc16a5db371fe73ae66a78a633371e",
- "reference": "a454d47278cc16a5db371fe73ae66a78a633371e",
+ "url": "https://api.github.com/repos/symfony/yaml/zipball/d4f4a66866fe2451f61296924767280ab5732d9d",
+ "reference": "d4f4a66866fe2451f61296924767280ab5732d9d",
"shasum": ""
},
"require": {
- "php": ">=7.2.5",
- "symfony/deprecation-contracts": "^2.1|^3",
+ "php": ">=8.2",
+ "symfony/deprecation-contracts": "^2.5|^3.0",
"symfony/polyfill-ctype": "^1.8"
},
"conflict": {
- "symfony/console": "<5.3"
+ "symfony/console": "<6.4"
},
"require-dev": {
- "symfony/console": "^5.3|^6.0"
- },
- "suggest": {
- "symfony/console": "For validating YAML files using the lint command"
+ "symfony/console": "^6.4|^7.0"
},
"bin": [
"Resources/bin/yaml-lint"
@@ -209,7 +210,7 @@
"description": "Loads and dumps YAML files",
"homepage": "https://symfony.com",
"support": {
- "source": "https://github.com/symfony/yaml/tree/v5.4.45"
+ "source": "https://github.com/symfony/yaml/tree/v7.3.3"
},
"funding": [
{
@@ -220,25 +221,29 @@
"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": "2024-09-25T14:11:13+00:00"
+ "time": "2025-08-27T11:34:33+00:00"
},
{
"name": "tecnickcom/tcpdf",
- "version": "6.9.1",
+ "version": "6.10.0",
"source": {
"type": "git",
"url": "https://github.com/tecnickcom/TCPDF.git",
- "reference": "ed27e28a4c478f7f4015b5e7e7b1912af9e85f2b"
+ "reference": "ca5b6de294512145db96bcbc94e61696599c391d"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/tecnickcom/TCPDF/zipball/ed27e28a4c478f7f4015b5e7e7b1912af9e85f2b",
- "reference": "ed27e28a4c478f7f4015b5e7e7b1912af9e85f2b",
+ "url": "https://api.github.com/repos/tecnickcom/TCPDF/zipball/ca5b6de294512145db96bcbc94e61696599c391d",
+ "reference": "ca5b6de294512145db96bcbc94e61696599c391d",
"shasum": ""
},
"require": {
@@ -288,15 +293,15 @@
],
"support": {
"issues": "https://github.com/tecnickcom/TCPDF/issues",
- "source": "https://github.com/tecnickcom/TCPDF/tree/6.9.1"
+ "source": "https://github.com/tecnickcom/TCPDF/tree/6.10.0"
},
"funding": [
{
- "url": "https://www.paypal.com/cgi-bin/webscr?cmd=_donations¤cy_code=GBP&business=paypal@tecnick.com&item_name=donation%20for%20tcpdf%20project",
+ "url": "https://www.paypal.com/donate/?hosted_button_id=NZUEC5XS8MFBJ",
"type": "custom"
}
],
- "time": "2025-04-03T06:38:07+00:00"
+ "time": "2025-05-27T18:02:28+00:00"
}
],
"packages-dev": [
@@ -445,16 +450,16 @@
},
{
"name": "composer/semver",
- "version": "3.4.3",
+ "version": "3.4.4",
"source": {
"type": "git",
"url": "https://github.com/composer/semver.git",
- "reference": "4313d26ada5e0c4edfbd1dc481a92ff7bff91f12"
+ "reference": "198166618906cb2de69b95d7d47e5fa8aa1b2b95"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/composer/semver/zipball/4313d26ada5e0c4edfbd1dc481a92ff7bff91f12",
- "reference": "4313d26ada5e0c4edfbd1dc481a92ff7bff91f12",
+ "url": "https://api.github.com/repos/composer/semver/zipball/198166618906cb2de69b95d7d47e5fa8aa1b2b95",
+ "reference": "198166618906cb2de69b95d7d47e5fa8aa1b2b95",
"shasum": ""
},
"require": {
@@ -506,7 +511,7 @@
"support": {
"irc": "ircs://irc.libera.chat:6697/composer",
"issues": "https://github.com/composer/semver/issues",
- "source": "https://github.com/composer/semver/tree/3.4.3"
+ "source": "https://github.com/composer/semver/tree/3.4.4"
},
"funding": [
{
@@ -516,13 +521,9 @@
{
"url": "https://github.com/composer",
"type": "github"
- },
- {
- "url": "https://tidelift.com/funding/github/packagist/composer/composer",
- "type": "tidelift"
}
],
- "time": "2024-09-19T14:15:21+00:00"
+ "time": "2025-08-20T19:15:30+00:00"
},
{
"name": "composer/xdebug-handler",
@@ -639,16 +640,16 @@
},
{
"name": "fidry/cpu-core-counter",
- "version": "1.2.0",
+ "version": "1.3.0",
"source": {
"type": "git",
"url": "https://github.com/theofidry/cpu-core-counter.git",
- "reference": "8520451a140d3f46ac33042715115e290cf5785f"
+ "reference": "db9508f7b1474469d9d3c53b86f817e344732678"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/theofidry/cpu-core-counter/zipball/8520451a140d3f46ac33042715115e290cf5785f",
- "reference": "8520451a140d3f46ac33042715115e290cf5785f",
+ "url": "https://api.github.com/repos/theofidry/cpu-core-counter/zipball/db9508f7b1474469d9d3c53b86f817e344732678",
+ "reference": "db9508f7b1474469d9d3c53b86f817e344732678",
"shasum": ""
},
"require": {
@@ -658,10 +659,10 @@
"fidry/makefile": "^0.2.0",
"fidry/php-cs-fixer-config": "^1.1.2",
"phpstan/extension-installer": "^1.2.0",
- "phpstan/phpstan": "^1.9.2",
- "phpstan/phpstan-deprecation-rules": "^1.0.0",
- "phpstan/phpstan-phpunit": "^1.2.2",
- "phpstan/phpstan-strict-rules": "^1.4.4",
+ "phpstan/phpstan": "^2.0",
+ "phpstan/phpstan-deprecation-rules": "^2.0.0",
+ "phpstan/phpstan-phpunit": "^2.0",
+ "phpstan/phpstan-strict-rules": "^2.0",
"phpunit/phpunit": "^8.5.31 || ^9.5.26",
"webmozarts/strict-phpunit": "^7.5"
},
@@ -688,7 +689,7 @@
],
"support": {
"issues": "https://github.com/theofidry/cpu-core-counter/issues",
- "source": "https://github.com/theofidry/cpu-core-counter/tree/1.2.0"
+ "source": "https://github.com/theofidry/cpu-core-counter/tree/1.3.0"
},
"funding": [
{
@@ -696,62 +697,62 @@
"type": "github"
}
],
- "time": "2024-08-06T10:04:20+00:00"
+ "time": "2025-08-14T07:29:31+00:00"
},
{
"name": "friendsofphp/php-cs-fixer",
- "version": "v3.75.0",
+ "version": "v3.88.2",
"source": {
"type": "git",
"url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git",
- "reference": "399a128ff2fdaf4281e4e79b755693286cdf325c"
+ "reference": "a8d15584bafb0f0d9d938827840060fd4a3ebc99"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/399a128ff2fdaf4281e4e79b755693286cdf325c",
- "reference": "399a128ff2fdaf4281e4e79b755693286cdf325c",
+ "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/a8d15584bafb0f0d9d938827840060fd4a3ebc99",
+ "reference": "a8d15584bafb0f0d9d938827840060fd4a3ebc99",
"shasum": ""
},
"require": {
- "clue/ndjson-react": "^1.0",
+ "clue/ndjson-react": "^1.3",
"composer/semver": "^3.4",
- "composer/xdebug-handler": "^3.0.3",
+ "composer/xdebug-handler": "^3.0.5",
"ext-filter": "*",
"ext-hash": "*",
"ext-json": "*",
"ext-tokenizer": "*",
- "fidry/cpu-core-counter": "^1.2",
+ "fidry/cpu-core-counter": "^1.3",
"php": "^7.4 || ^8.0",
- "react/child-process": "^0.6.5",
- "react/event-loop": "^1.0",
- "react/promise": "^2.0 || ^3.0",
- "react/socket": "^1.0",
- "react/stream": "^1.0",
- "sebastian/diff": "^4.0 || ^5.1 || ^6.0 || ^7.0",
- "symfony/console": "^5.4 || ^6.4 || ^7.0",
- "symfony/event-dispatcher": "^5.4 || ^6.4 || ^7.0",
- "symfony/filesystem": "^5.4 || ^6.4 || ^7.0",
- "symfony/finder": "^5.4 || ^6.4 || ^7.0",
- "symfony/options-resolver": "^5.4 || ^6.4 || ^7.0",
- "symfony/polyfill-mbstring": "^1.31",
- "symfony/polyfill-php80": "^1.31",
- "symfony/polyfill-php81": "^1.31",
- "symfony/process": "^5.4 || ^6.4 || ^7.2",
- "symfony/stopwatch": "^5.4 || ^6.4 || ^7.0"
+ "react/child-process": "^0.6.6",
+ "react/event-loop": "^1.5",
+ "react/promise": "^3.3",
+ "react/socket": "^1.16",
+ "react/stream": "^1.4",
+ "sebastian/diff": "^4.0.6 || ^5.1.1 || ^6.0.2 || ^7.0",
+ "symfony/console": "^5.4.47 || ^6.4.24 || ^7.0",
+ "symfony/event-dispatcher": "^5.4.45 || ^6.4.24 || ^7.0",
+ "symfony/filesystem": "^5.4.45 || ^6.4.24 || ^7.0",
+ "symfony/finder": "^5.4.45 || ^6.4.24 || ^7.0",
+ "symfony/options-resolver": "^5.4.45 || ^6.4.24 || ^7.0",
+ "symfony/polyfill-mbstring": "^1.33",
+ "symfony/polyfill-php80": "^1.33",
+ "symfony/polyfill-php81": "^1.33",
+ "symfony/polyfill-php84": "^1.33",
+ "symfony/process": "^5.4.47 || ^6.4.24 || ^7.2",
+ "symfony/stopwatch": "^5.4.45 || ^6.4.24 || ^7.0"
},
"require-dev": {
- "facile-it/paraunit": "^1.3.1 || ^2.6",
- "infection/infection": "^0.29.14",
- "justinrainbow/json-schema": "^5.3 || ^6.2",
- "keradus/cli-executor": "^2.1",
+ "facile-it/paraunit": "^1.3.1 || ^2.7",
+ "infection/infection": "^0.31.0",
+ "justinrainbow/json-schema": "^6.5",
+ "keradus/cli-executor": "^2.2",
"mikey179/vfsstream": "^1.6.12",
- "php-coveralls/php-coveralls": "^2.7",
- "php-cs-fixer/accessible-object": "^1.1",
+ "php-coveralls/php-coveralls": "^2.8",
"php-cs-fixer/phpunit-constraint-isidenticalstring": "^1.6",
"php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "^1.6",
- "phpunit/phpunit": "^9.6.22 || ^10.5.45 || ^11.5.12",
- "symfony/var-dumper": "^5.4.48 || ^6.4.18 || ^7.2.3",
- "symfony/yaml": "^5.4.45 || ^6.4.18 || ^7.2.3"
+ "phpunit/phpunit": "^9.6.25 || ^10.5.53 || ^11.5.34",
+ "symfony/var-dumper": "^5.4.48 || ^6.4.24 || ^7.3.2",
+ "symfony/yaml": "^5.4.45 || ^6.4.24 || ^7.3.2"
},
"suggest": {
"ext-dom": "For handling output formats in XML",
@@ -792,7 +793,7 @@
],
"support": {
"issues": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues",
- "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.75.0"
+ "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.88.2"
},
"funding": [
{
@@ -800,20 +801,20 @@
"type": "github"
}
],
- "time": "2025-03-31T18:40:42+00:00"
+ "time": "2025-09-27T00:24:15+00:00"
},
{
"name": "friendsoftwig/twigcs",
- "version": "v6.1.0",
+ "version": "6.5.0",
"source": {
"type": "git",
"url": "https://github.com/friendsoftwig/twigcs.git",
- "reference": "3c36d606c4f19db0dd2a01b735ec7a8151b7f182"
+ "reference": "aaa3ba112bf4fcee7b51a00d9b45b13bc2cc23bc"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/friendsoftwig/twigcs/zipball/3c36d606c4f19db0dd2a01b735ec7a8151b7f182",
- "reference": "3c36d606c4f19db0dd2a01b735ec7a8151b7f182",
+ "url": "https://api.github.com/repos/friendsoftwig/twigcs/zipball/aaa3ba112bf4fcee7b51a00d9b45b13bc2cc23bc",
+ "reference": "aaa3ba112bf4fcee7b51a00d9b45b13bc2cc23bc",
"shasum": ""
},
"require": {
@@ -822,14 +823,14 @@
"ext-json": "*",
"ext-mbstring": "*",
"ext-simplexml": "*",
- "php": "~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0",
- "symfony/console": "^4.4 || ^5.3 || ^6.0",
- "symfony/filesystem": "^4.4 || ^5.3 || ^6.0",
- "symfony/finder": "^4.4 || ^5.3 || ^6.0"
+ "php": "~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0",
+ "symfony/console": "^4.4 || ^5.3 || ^6.0 || ^7.0",
+ "symfony/filesystem": "^4.4 || ^5.3 || ^6.0 || ^7.0",
+ "symfony/finder": "^4.4 || ^5.3 || ^6.0 || ^7.0"
},
"require-dev": {
- "phpunit/phpunit": "^9.5.20",
- "symfony/phpunit-bridge": "^6.2.3"
+ "phpunit/phpunit": "^9.6.19",
+ "symfony/phpunit-bridge": "^7.1.4"
},
"bin": [
"bin/twigcs"
@@ -853,22 +854,71 @@
"description": "Checkstyle automation for Twig",
"support": {
"issues": "https://github.com/friendsoftwig/twigcs/issues",
- "source": "https://github.com/friendsoftwig/twigcs/tree/v6.1.0"
+ "source": "https://github.com/friendsoftwig/twigcs/tree/6.5.0"
},
- "time": "2023-01-04T16:01:24+00:00"
+ "time": "2024-11-27T21:59:24+00:00"
+ },
+ {
+ "name": "glpi-project/phpstan-glpi",
+ "version": "1.1.1",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/glpi-project/phpstan-glpi.git",
+ "reference": "e98ef833abc1389a0cc69743db5b1f3a7dc8ccfe"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/glpi-project/phpstan-glpi/zipball/e98ef833abc1389a0cc69743db5b1f3a7dc8ccfe",
+ "reference": "e98ef833abc1389a0cc69743db5b1f3a7dc8ccfe",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=7.4",
+ "phpstan/phpstan": "^2.1",
+ "symfony/polyfill-php80": "^1.32"
+ },
+ "require-dev": {
+ "friendsofphp/php-cs-fixer": "^3.85",
+ "php-parallel-lint/php-parallel-lint": "^1.4",
+ "phpstan/phpstan-phpunit": "^2.0",
+ "phpunit/phpunit": "^9.6"
+ },
+ "type": "phpstan-extension",
+ "extra": {
+ "phpstan": {
+ "includes": [
+ "extension.neon"
+ ]
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "PHPStanGlpi\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "description": "PHPStan rules for GLPI.",
+ "support": {
+ "issues": "https://github.com/glpi-project/phpstan-glpi/issues",
+ "source": "https://github.com/glpi-project/phpstan-glpi/tree/1.1.1"
+ },
+ "time": "2025-08-11T13:48:13+00:00"
},
{
"name": "glpi-project/tools",
- "version": "0.7.4",
+ "version": "0.7.8",
"source": {
"type": "git",
"url": "https://github.com/glpi-project/tools.git",
- "reference": "65a09a93350da6fa67d423dd94e4cb4023a17e20"
+ "reference": "bd78ad2ab0d30510729530c077f84d52b8f02866"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/glpi-project/tools/zipball/65a09a93350da6fa67d423dd94e4cb4023a17e20",
- "reference": "65a09a93350da6fa67d423dd94e4cb4023a17e20",
+ "url": "https://api.github.com/repos/glpi-project/tools/zipball/bd78ad2ab0d30510729530c077f84d52b8f02866",
+ "reference": "bd78ad2ab0d30510729530c077f84d52b8f02866",
"shasum": ""
},
"require": {
@@ -911,7 +961,7 @@
"issues": "https://github.com/glpi-project/tools/issues",
"source": "https://github.com/glpi-project/tools"
},
- "time": "2024-09-18T06:58:02+00:00"
+ "time": "2025-08-20T09:58:56+00:00"
},
{
"name": "php-parallel-lint/php-parallel-lint",
@@ -1024,16 +1074,16 @@
},
{
"name": "phpstan/phpstan",
- "version": "2.1.11",
+ "version": "2.1.29",
"source": {
"type": "git",
- "url": "https://github.com/phpstan/phpstan.git",
- "reference": "8ca5f79a8f63c49b2359065832a654e1ec70ac30"
+ "url": "https://github.com/phpstan/phpstan-phar-composer-source.git",
+ "reference": "git"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/phpstan/phpstan/zipball/8ca5f79a8f63c49b2359065832a654e1ec70ac30",
- "reference": "8ca5f79a8f63c49b2359065832a654e1ec70ac30",
+ "url": "https://api.github.com/repos/phpstan/phpstan/zipball/d618573eed4a1b6b75e37b2e0b65ac65c885d88e",
+ "reference": "d618573eed4a1b6b75e37b2e0b65ac65c885d88e",
"shasum": ""
},
"require": {
@@ -1078,25 +1128,25 @@
"type": "github"
}
],
- "time": "2025-03-24T13:45:00+00:00"
+ "time": "2025-09-25T06:58:18+00:00"
},
{
"name": "phpstan/phpstan-deprecation-rules",
- "version": "2.0.1",
+ "version": "2.0.3",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpstan-deprecation-rules.git",
- "reference": "1cc1259cb91ee4cfbb5c39bca9f635f067c910b4"
+ "reference": "468e02c9176891cc901143da118f09dc9505fc2f"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/phpstan/phpstan-deprecation-rules/zipball/1cc1259cb91ee4cfbb5c39bca9f635f067c910b4",
- "reference": "1cc1259cb91ee4cfbb5c39bca9f635f067c910b4",
+ "url": "https://api.github.com/repos/phpstan/phpstan-deprecation-rules/zipball/468e02c9176891cc901143da118f09dc9505fc2f",
+ "reference": "468e02c9176891cc901143da118f09dc9505fc2f",
"shasum": ""
},
"require": {
"php": "^7.4 || ^8.0",
- "phpstan/phpstan": "^2.0"
+ "phpstan/phpstan": "^2.1.15"
},
"require-dev": {
"php-parallel-lint/php-parallel-lint": "^1.2",
@@ -1123,28 +1173,33 @@
"description": "PHPStan rules for detecting usage of deprecated classes, methods, properties, constants and traits.",
"support": {
"issues": "https://github.com/phpstan/phpstan-deprecation-rules/issues",
- "source": "https://github.com/phpstan/phpstan-deprecation-rules/tree/2.0.1"
+ "source": "https://github.com/phpstan/phpstan-deprecation-rules/tree/2.0.3"
},
- "time": "2024-11-28T21:56:36+00:00"
+ "time": "2025-05-14T10:56:57+00:00"
},
{
"name": "psr/container",
- "version": "1.1.2",
+ "version": "2.0.2",
"source": {
"type": "git",
"url": "https://github.com/php-fig/container.git",
- "reference": "513e0666f7216c7459170d56df27dfcefe1689ea"
+ "reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/php-fig/container/zipball/513e0666f7216c7459170d56df27dfcefe1689ea",
- "reference": "513e0666f7216c7459170d56df27dfcefe1689ea",
+ "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/"
@@ -1171,9 +1226,9 @@
],
"support": {
"issues": "https://github.com/php-fig/container/issues",
- "source": "https://github.com/php-fig/container/tree/1.1.2"
+ "source": "https://github.com/php-fig/container/tree/2.0.2"
},
- "time": "2021-11-05T16:50:12+00:00"
+ "time": "2021-11-05T16:47:00+00:00"
},
{
"name": "psr/event-dispatcher",
@@ -1227,30 +1282,30 @@
},
{
"name": "psr/log",
- "version": "1.1.4",
+ "version": "3.0.2",
"source": {
"type": "git",
"url": "https://github.com/php-fig/log.git",
- "reference": "d49695b909c3b7628b6289db5479a1c204601f11"
+ "reference": "f16e1d5863e37f8d8c2a01719f5b34baa2b714d3"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/php-fig/log/zipball/d49695b909c3b7628b6289db5479a1c204601f11",
- "reference": "d49695b909c3b7628b6289db5479a1c204601f11",
+ "url": "https://api.github.com/repos/php-fig/log/zipball/f16e1d5863e37f8d8c2a01719f5b34baa2b714d3",
+ "reference": "f16e1d5863e37f8d8c2a01719f5b34baa2b714d3",
"shasum": ""
},
"require": {
- "php": ">=5.3.0"
+ "php": ">=8.0.0"
},
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "1.1.x-dev"
+ "dev-master": "3.x-dev"
}
},
"autoload": {
"psr-4": {
- "Psr\\Log\\": "Psr/Log/"
+ "Psr\\Log\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
@@ -1271,9 +1326,9 @@
"psr-3"
],
"support": {
- "source": "https://github.com/php-fig/log/tree/1.1.4"
+ "source": "https://github.com/php-fig/log/tree/3.0.2"
},
- "time": "2021-05-03T11:20:27+00:00"
+ "time": "2024-09-11T13:17:53+00:00"
},
{
"name": "react/cache",
@@ -1572,23 +1627,23 @@
},
{
"name": "react/promise",
- "version": "v3.2.0",
+ "version": "v3.3.0",
"source": {
"type": "git",
"url": "https://github.com/reactphp/promise.git",
- "reference": "8a164643313c71354582dc850b42b33fa12a4b63"
+ "reference": "23444f53a813a3296c1368bb104793ce8d88f04a"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/reactphp/promise/zipball/8a164643313c71354582dc850b42b33fa12a4b63",
- "reference": "8a164643313c71354582dc850b42b33fa12a4b63",
+ "url": "https://api.github.com/repos/reactphp/promise/zipball/23444f53a813a3296c1368bb104793ce8d88f04a",
+ "reference": "23444f53a813a3296c1368bb104793ce8d88f04a",
"shasum": ""
},
"require": {
"php": ">=7.1.0"
},
"require-dev": {
- "phpstan/phpstan": "1.10.39 || 1.4.10",
+ "phpstan/phpstan": "1.12.28 || 1.4.10",
"phpunit/phpunit": "^9.6 || ^7.5"
},
"type": "library",
@@ -1633,7 +1688,7 @@
],
"support": {
"issues": "https://github.com/reactphp/promise/issues",
- "source": "https://github.com/reactphp/promise/tree/v3.2.0"
+ "source": "https://github.com/reactphp/promise/tree/v3.3.0"
},
"funding": [
{
@@ -1641,7 +1696,7 @@
"type": "open_collective"
}
],
- "time": "2024-05-24T10:39:05+00:00"
+ "time": "2025-08-19T18:57:03+00:00"
},
{
"name": "react/socket",
@@ -1803,29 +1858,29 @@
},
{
"name": "sebastian/diff",
- "version": "4.0.6",
+ "version": "6.0.2",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/diff.git",
- "reference": "ba01945089c3a293b01ba9badc29ad55b106b0bc"
+ "reference": "b4ccd857127db5d41a5b676f24b51371d76d8544"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/ba01945089c3a293b01ba9badc29ad55b106b0bc",
- "reference": "ba01945089c3a293b01ba9badc29ad55b106b0bc",
+ "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/b4ccd857127db5d41a5b676f24b51371d76d8544",
+ "reference": "b4ccd857127db5d41a5b676f24b51371d76d8544",
"shasum": ""
},
"require": {
- "php": ">=7.3"
+ "php": ">=8.2"
},
"require-dev": {
- "phpunit/phpunit": "^9.3",
+ "phpunit/phpunit": "^11.0",
"symfony/process": "^4.2 || ^5"
},
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "4.0-dev"
+ "dev-main": "6.0-dev"
}
},
"autoload": {
@@ -1857,7 +1912,8 @@
],
"support": {
"issues": "https://github.com/sebastianbergmann/diff/issues",
- "source": "https://github.com/sebastianbergmann/diff/tree/4.0.6"
+ "security": "https://github.com/sebastianbergmann/diff/security/policy",
+ "source": "https://github.com/sebastianbergmann/diff/tree/6.0.2"
},
"funding": [
{
@@ -1865,56 +1921,51 @@
"type": "github"
}
],
- "time": "2024-03-02T06:30:58+00:00"
+ "time": "2024-07-03T04:53:05+00:00"
},
{
"name": "symfony/console",
- "version": "v5.4.47",
+ "version": "v6.4.26",
"source": {
"type": "git",
"url": "https://github.com/symfony/console.git",
- "reference": "c4ba980ca61a9eb18ee6bcc73f28e475852bb1ed"
+ "reference": "492de6dfd93910d7d7a729c5a04ddcd2b9e99c4f"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/console/zipball/c4ba980ca61a9eb18ee6bcc73f28e475852bb1ed",
- "reference": "c4ba980ca61a9eb18ee6bcc73f28e475852bb1ed",
+ "url": "https://api.github.com/repos/symfony/console/zipball/492de6dfd93910d7d7a729c5a04ddcd2b9e99c4f",
+ "reference": "492de6dfd93910d7d7a729c5a04ddcd2b9e99c4f",
"shasum": ""
},
"require": {
- "php": ">=7.2.5",
- "symfony/deprecation-contracts": "^2.1|^3",
+ "php": ">=8.1",
+ "symfony/deprecation-contracts": "^2.5|^3",
"symfony/polyfill-mbstring": "~1.0",
- "symfony/polyfill-php73": "^1.9",
- "symfony/polyfill-php80": "^1.16",
- "symfony/service-contracts": "^1.1|^2|^3",
- "symfony/string": "^5.1|^6.0"
+ "symfony/service-contracts": "^2.5|^3",
+ "symfony/string": "^5.4|^6.0|^7.0"
},
"conflict": {
- "psr/log": ">=3",
- "symfony/dependency-injection": "<4.4",
- "symfony/dotenv": "<5.1",
- "symfony/event-dispatcher": "<4.4",
- "symfony/lock": "<4.4",
- "symfony/process": "<4.4"
+ "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"
+ "psr/log-implementation": "1.0|2.0|3.0"
},
"require-dev": {
- "psr/log": "^1|^2",
- "symfony/config": "^4.4|^5.0|^6.0",
- "symfony/dependency-injection": "^4.4|^5.0|^6.0",
- "symfony/event-dispatcher": "^4.4|^5.0|^6.0",
- "symfony/lock": "^4.4|^5.0|^6.0",
- "symfony/process": "^4.4|^5.0|^6.0",
- "symfony/var-dumper": "^4.4|^5.0|^6.0"
- },
- "suggest": {
- "psr/log": "For using the console logger",
- "symfony/event-dispatcher": "",
- "symfony/lock": "",
- "symfony/process": ""
+ "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": {
@@ -1948,7 +1999,7 @@
"terminal"
],
"support": {
- "source": "https://github.com/symfony/console/tree/v5.4.47"
+ "source": "https://github.com/symfony/console/tree/v6.4.26"
},
"funding": [
{
@@ -1959,53 +2010,52 @@
"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": "2024-11-06T11:30:55+00:00"
+ "time": "2025-09-26T12:13:46+00:00"
},
{
"name": "symfony/event-dispatcher",
- "version": "v5.4.45",
+ "version": "v7.3.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/event-dispatcher.git",
- "reference": "72982eb416f61003e9bb6e91f8b3213600dcf9e9"
+ "reference": "b7dc69e71de420ac04bc9ab830cf3ffebba48191"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/72982eb416f61003e9bb6e91f8b3213600dcf9e9",
- "reference": "72982eb416f61003e9bb6e91f8b3213600dcf9e9",
+ "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/b7dc69e71de420ac04bc9ab830cf3ffebba48191",
+ "reference": "b7dc69e71de420ac04bc9ab830cf3ffebba48191",
"shasum": ""
},
"require": {
- "php": ">=7.2.5",
- "symfony/deprecation-contracts": "^2.1|^3",
- "symfony/event-dispatcher-contracts": "^2|^3",
- "symfony/polyfill-php80": "^1.16"
+ "php": ">=8.2",
+ "symfony/event-dispatcher-contracts": "^2.5|^3"
},
"conflict": {
- "symfony/dependency-injection": "<4.4"
+ "symfony/dependency-injection": "<6.4",
+ "symfony/service-contracts": "<2.5"
},
"provide": {
"psr/event-dispatcher-implementation": "1.0",
- "symfony/event-dispatcher-implementation": "2.0"
+ "symfony/event-dispatcher-implementation": "2.0|3.0"
},
"require-dev": {
"psr/log": "^1|^2|^3",
- "symfony/config": "^4.4|^5.0|^6.0",
- "symfony/dependency-injection": "^4.4|^5.0|^6.0",
- "symfony/error-handler": "^4.4|^5.0|^6.0",
- "symfony/expression-language": "^4.4|^5.0|^6.0",
- "symfony/http-foundation": "^4.4|^5.0|^6.0",
- "symfony/service-contracts": "^1.1|^2|^3",
- "symfony/stopwatch": "^4.4|^5.0|^6.0"
- },
- "suggest": {
- "symfony/dependency-injection": "",
- "symfony/http-kernel": ""
+ "symfony/config": "^6.4|^7.0",
+ "symfony/dependency-injection": "^6.4|^7.0",
+ "symfony/error-handler": "^6.4|^7.0",
+ "symfony/expression-language": "^6.4|^7.0",
+ "symfony/http-foundation": "^6.4|^7.0",
+ "symfony/service-contracts": "^2.5|^3",
+ "symfony/stopwatch": "^6.4|^7.0"
},
"type": "library",
"autoload": {
@@ -2033,7 +2083,7 @@
"description": "Provides tools that allow your application components to communicate with each other by dispatching events and listening to them",
"homepage": "https://symfony.com",
"support": {
- "source": "https://github.com/symfony/event-dispatcher/tree/v5.4.45"
+ "source": "https://github.com/symfony/event-dispatcher/tree/v7.3.3"
},
"funding": [
{
@@ -2044,34 +2094,35 @@
"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": "2024-09-25T14:11:13+00:00"
+ "time": "2025-08-13T11:49:31+00:00"
},
{
"name": "symfony/event-dispatcher-contracts",
- "version": "v2.5.4",
+ "version": "v3.6.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/event-dispatcher-contracts.git",
- "reference": "e0fe3d79b516eb75126ac6fa4cbf19b79b08c99f"
+ "reference": "59eb412e93815df44f05f342958efa9f46b1e586"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/e0fe3d79b516eb75126ac6fa4cbf19b79b08c99f",
- "reference": "e0fe3d79b516eb75126ac6fa4cbf19b79b08c99f",
+ "url": "https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/59eb412e93815df44f05f342958efa9f46b1e586",
+ "reference": "59eb412e93815df44f05f342958efa9f46b1e586",
"shasum": ""
},
"require": {
- "php": ">=7.2.5",
+ "php": ">=8.1",
"psr/event-dispatcher": "^1"
},
- "suggest": {
- "symfony/event-dispatcher-implementation": ""
- },
"type": "library",
"extra": {
"thanks": {
@@ -2079,7 +2130,7 @@
"name": "symfony/contracts"
},
"branch-alias": {
- "dev-main": "2.5-dev"
+ "dev-main": "3.6-dev"
}
},
"autoload": {
@@ -2112,7 +2163,7 @@
"standards"
],
"support": {
- "source": "https://github.com/symfony/event-dispatcher-contracts/tree/v2.5.4"
+ "source": "https://github.com/symfony/event-dispatcher-contracts/tree/v3.6.0"
},
"funding": [
{
@@ -2128,30 +2179,29 @@
"type": "tidelift"
}
],
- "time": "2024-09-25T14:11:13+00:00"
+ "time": "2024-09-25T14:21:43+00:00"
},
{
"name": "symfony/filesystem",
- "version": "v5.4.45",
+ "version": "v7.3.2",
"source": {
"type": "git",
"url": "https://github.com/symfony/filesystem.git",
- "reference": "57c8294ed37d4a055b77057827c67f9558c95c54"
+ "reference": "edcbb768a186b5c3f25d0643159a787d3e63b7fd"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/filesystem/zipball/57c8294ed37d4a055b77057827c67f9558c95c54",
- "reference": "57c8294ed37d4a055b77057827c67f9558c95c54",
+ "url": "https://api.github.com/repos/symfony/filesystem/zipball/edcbb768a186b5c3f25d0643159a787d3e63b7fd",
+ "reference": "edcbb768a186b5c3f25d0643159a787d3e63b7fd",
"shasum": ""
},
"require": {
- "php": ">=7.2.5",
+ "php": ">=8.2",
"symfony/polyfill-ctype": "~1.8",
- "symfony/polyfill-mbstring": "~1.8",
- "symfony/polyfill-php80": "^1.16"
+ "symfony/polyfill-mbstring": "~1.8"
},
"require-dev": {
- "symfony/process": "^5.4|^6.4"
+ "symfony/process": "^6.4|^7.0"
},
"type": "library",
"autoload": {
@@ -2179,7 +2229,7 @@
"description": "Provides basic utilities for the filesystem",
"homepage": "https://symfony.com",
"support": {
- "source": "https://github.com/symfony/filesystem/tree/v5.4.45"
+ "source": "https://github.com/symfony/filesystem/tree/v7.3.2"
},
"funding": [
{
@@ -2190,31 +2240,36 @@
"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": "2024-10-22T13:05:35+00:00"
+ "time": "2025-07-07T08:17:47+00:00"
},
{
"name": "symfony/finder",
- "version": "v5.4.45",
+ "version": "v7.3.2",
"source": {
"type": "git",
"url": "https://github.com/symfony/finder.git",
- "reference": "63741784cd7b9967975eec610b256eed3ede022b"
+ "reference": "2a6614966ba1074fa93dae0bc804227422df4dfe"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/finder/zipball/63741784cd7b9967975eec610b256eed3ede022b",
- "reference": "63741784cd7b9967975eec610b256eed3ede022b",
+ "url": "https://api.github.com/repos/symfony/finder/zipball/2a6614966ba1074fa93dae0bc804227422df4dfe",
+ "reference": "2a6614966ba1074fa93dae0bc804227422df4dfe",
"shasum": ""
},
"require": {
- "php": ">=7.2.5",
- "symfony/deprecation-contracts": "^2.1|^3",
- "symfony/polyfill-php80": "^1.16"
+ "php": ">=8.2"
+ },
+ "require-dev": {
+ "symfony/filesystem": "^6.4|^7.0"
},
"type": "library",
"autoload": {
@@ -2242,7 +2297,7 @@
"description": "Finds files and directories via an intuitive fluent interface",
"homepage": "https://symfony.com",
"support": {
- "source": "https://github.com/symfony/finder/tree/v5.4.45"
+ "source": "https://github.com/symfony/finder/tree/v7.3.2"
},
"funding": [
{
@@ -2253,32 +2308,34 @@
"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": "2024-09-28T13:32:08+00:00"
+ "time": "2025-07-15T13:41:35+00:00"
},
{
"name": "symfony/options-resolver",
- "version": "v5.4.45",
+ "version": "v7.3.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/options-resolver.git",
- "reference": "74e5b6f0db3e8589e6cfd5efb317a1fc2bb52fb6"
+ "reference": "0ff2f5c3df08a395232bbc3c2eb7e84912df911d"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/options-resolver/zipball/74e5b6f0db3e8589e6cfd5efb317a1fc2bb52fb6",
- "reference": "74e5b6f0db3e8589e6cfd5efb317a1fc2bb52fb6",
+ "url": "https://api.github.com/repos/symfony/options-resolver/zipball/0ff2f5c3df08a395232bbc3c2eb7e84912df911d",
+ "reference": "0ff2f5c3df08a395232bbc3c2eb7e84912df911d",
"shasum": ""
},
"require": {
- "php": ">=7.2.5",
- "symfony/deprecation-contracts": "^2.1|^3",
- "symfony/polyfill-php73": "~1.0",
- "symfony/polyfill-php80": "^1.16"
+ "php": ">=8.2",
+ "symfony/deprecation-contracts": "^2.5|^3"
},
"type": "library",
"autoload": {
@@ -2311,7 +2368,7 @@
"options"
],
"support": {
- "source": "https://github.com/symfony/options-resolver/tree/v5.4.45"
+ "source": "https://github.com/symfony/options-resolver/tree/v7.3.3"
},
"funding": [
{
@@ -2322,25 +2379,29 @@
"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": "2024-09-25T14:11:13+00:00"
+ "time": "2025-08-05T10:16:07+00:00"
},
{
"name": "symfony/polyfill-intl-grapheme",
- "version": "v1.31.0",
+ "version": "v1.33.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-intl-grapheme.git",
- "reference": "b9123926e3b7bc2f98c02ad54f6a4b02b91a8abe"
+ "reference": "380872130d3a5dd3ace2f4010d95125fde5d5c70"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/b9123926e3b7bc2f98c02ad54f6a4b02b91a8abe",
- "reference": "b9123926e3b7bc2f98c02ad54f6a4b02b91a8abe",
+ "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/380872130d3a5dd3ace2f4010d95125fde5d5c70",
+ "reference": "380872130d3a5dd3ace2f4010d95125fde5d5c70",
"shasum": ""
},
"require": {
@@ -2389,7 +2450,7 @@
"shim"
],
"support": {
- "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.31.0"
+ "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.33.0"
},
"funding": [
{
@@ -2400,16 +2461,20 @@
"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": "2024-09-09T11:45:10+00:00"
+ "time": "2025-06-27T09:58:17+00:00"
},
{
"name": "symfony/polyfill-intl-normalizer",
- "version": "v1.31.0",
+ "version": "v1.33.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-intl-normalizer.git",
@@ -2470,7 +2535,7 @@
"shim"
],
"support": {
- "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.31.0"
+ "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.33.0"
},
"funding": [
{
@@ -2481,6 +2546,10 @@
"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"
@@ -2490,19 +2559,20 @@
},
{
"name": "symfony/polyfill-mbstring",
- "version": "v1.31.0",
+ "version": "v1.33.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-mbstring.git",
- "reference": "85181ba99b2345b0ef10ce42ecac37612d9fd341"
+ "reference": "6d857f4d76bd4b343eac26d6b539585d2bc56493"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/85181ba99b2345b0ef10ce42ecac37612d9fd341",
- "reference": "85181ba99b2345b0ef10ce42ecac37612d9fd341",
+ "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/6d857f4d76bd4b343eac26d6b539585d2bc56493",
+ "reference": "6d857f4d76bd4b343eac26d6b539585d2bc56493",
"shasum": ""
},
"require": {
+ "ext-iconv": "*",
"php": ">=7.2"
},
"provide": {
@@ -2550,7 +2620,7 @@
"shim"
],
"support": {
- "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.31.0"
+ "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.33.0"
},
"funding": [
{
@@ -2561,25 +2631,29 @@
"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": "2024-09-09T11:45:10+00:00"
+ "time": "2024-12-23T08:48:59+00:00"
},
{
- "name": "symfony/polyfill-php73",
- "version": "v1.31.0",
+ "name": "symfony/polyfill-php80",
+ "version": "v1.33.0",
"source": {
"type": "git",
- "url": "https://github.com/symfony/polyfill-php73.git",
- "reference": "0f68c03565dcaaf25a890667542e8bd75fe7e5bb"
+ "url": "https://github.com/symfony/polyfill-php80.git",
+ "reference": "0cc9dd0f17f61d8131e7df6b84bd344899fe2608"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/0f68c03565dcaaf25a890667542e8bd75fe7e5bb",
- "reference": "0f68c03565dcaaf25a890667542e8bd75fe7e5bb",
+ "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/0cc9dd0f17f61d8131e7df6b84bd344899fe2608",
+ "reference": "0cc9dd0f17f61d8131e7df6b84bd344899fe2608",
"shasum": ""
},
"require": {
@@ -2597,7 +2671,7 @@
"bootstrap.php"
],
"psr-4": {
- "Symfony\\Polyfill\\Php73\\": ""
+ "Symfony\\Polyfill\\Php80\\": ""
},
"classmap": [
"Resources/stubs"
@@ -2608,6 +2682,10 @@
"MIT"
],
"authors": [
+ {
+ "name": "Ion Bazan",
+ "email": "ion.bazan@gmail.com"
+ },
{
"name": "Nicolas Grekas",
"email": "p@tchwork.com"
@@ -2617,7 +2695,7 @@
"homepage": "https://symfony.com/contributors"
}
],
- "description": "Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions",
+ "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions",
"homepage": "https://symfony.com",
"keywords": [
"compatibility",
@@ -2626,7 +2704,7 @@
"shim"
],
"support": {
- "source": "https://github.com/symfony/polyfill-php73/tree/v1.31.0"
+ "source": "https://github.com/symfony/polyfill-php80/tree/v1.33.0"
},
"funding": [
{
@@ -2637,25 +2715,29 @@
"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": "2024-09-09T11:45:10+00:00"
+ "time": "2025-01-02T08:10:11+00:00"
},
{
- "name": "symfony/polyfill-php80",
- "version": "v1.31.0",
+ "name": "symfony/polyfill-php81",
+ "version": "v1.33.0",
"source": {
"type": "git",
- "url": "https://github.com/symfony/polyfill-php80.git",
- "reference": "60328e362d4c2c802a54fcbf04f9d3fb892b4cf8"
+ "url": "https://github.com/symfony/polyfill-php81.git",
+ "reference": "4a4cfc2d253c21a5ad0e53071df248ed48c6ce5c"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/60328e362d4c2c802a54fcbf04f9d3fb892b4cf8",
- "reference": "60328e362d4c2c802a54fcbf04f9d3fb892b4cf8",
+ "url": "https://api.github.com/repos/symfony/polyfill-php81/zipball/4a4cfc2d253c21a5ad0e53071df248ed48c6ce5c",
+ "reference": "4a4cfc2d253c21a5ad0e53071df248ed48c6ce5c",
"shasum": ""
},
"require": {
@@ -2673,7 +2755,7 @@
"bootstrap.php"
],
"psr-4": {
- "Symfony\\Polyfill\\Php80\\": ""
+ "Symfony\\Polyfill\\Php81\\": ""
},
"classmap": [
"Resources/stubs"
@@ -2684,10 +2766,6 @@
"MIT"
],
"authors": [
- {
- "name": "Ion Bazan",
- "email": "ion.bazan@gmail.com"
- },
{
"name": "Nicolas Grekas",
"email": "p@tchwork.com"
@@ -2697,7 +2775,7 @@
"homepage": "https://symfony.com/contributors"
}
],
- "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions",
+ "description": "Symfony polyfill backporting some PHP 8.1+ features to lower PHP versions",
"homepage": "https://symfony.com",
"keywords": [
"compatibility",
@@ -2706,7 +2784,7 @@
"shim"
],
"support": {
- "source": "https://github.com/symfony/polyfill-php80/tree/v1.31.0"
+ "source": "https://github.com/symfony/polyfill-php81/tree/v1.33.0"
},
"funding": [
{
@@ -2717,6 +2795,10 @@
"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"
@@ -2725,17 +2807,17 @@
"time": "2024-09-09T11:45:10+00:00"
},
{
- "name": "symfony/polyfill-php81",
- "version": "v1.31.0",
+ "name": "symfony/polyfill-php84",
+ "version": "v1.33.0",
"source": {
"type": "git",
- "url": "https://github.com/symfony/polyfill-php81.git",
- "reference": "4a4cfc2d253c21a5ad0e53071df248ed48c6ce5c"
+ "url": "https://github.com/symfony/polyfill-php84.git",
+ "reference": "d8ced4d875142b6a7426000426b8abc631d6b191"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/polyfill-php81/zipball/4a4cfc2d253c21a5ad0e53071df248ed48c6ce5c",
- "reference": "4a4cfc2d253c21a5ad0e53071df248ed48c6ce5c",
+ "url": "https://api.github.com/repos/symfony/polyfill-php84/zipball/d8ced4d875142b6a7426000426b8abc631d6b191",
+ "reference": "d8ced4d875142b6a7426000426b8abc631d6b191",
"shasum": ""
},
"require": {
@@ -2753,7 +2835,7 @@
"bootstrap.php"
],
"psr-4": {
- "Symfony\\Polyfill\\Php81\\": ""
+ "Symfony\\Polyfill\\Php84\\": ""
},
"classmap": [
"Resources/stubs"
@@ -2773,7 +2855,7 @@
"homepage": "https://symfony.com/contributors"
}
],
- "description": "Symfony polyfill backporting some PHP 8.1+ features to lower PHP versions",
+ "description": "Symfony polyfill backporting some PHP 8.4+ features to lower PHP versions",
"homepage": "https://symfony.com",
"keywords": [
"compatibility",
@@ -2782,7 +2864,7 @@
"shim"
],
"support": {
- "source": "https://github.com/symfony/polyfill-php81/tree/v1.31.0"
+ "source": "https://github.com/symfony/polyfill-php84/tree/v1.33.0"
},
"funding": [
{
@@ -2793,30 +2875,33 @@
"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": "2024-09-09T11:45:10+00:00"
+ "time": "2025-06-24T13:30:11+00:00"
},
{
"name": "symfony/process",
- "version": "v5.4.47",
+ "version": "v7.3.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/process.git",
- "reference": "5d1662fb32ebc94f17ddb8d635454a776066733d"
+ "reference": "f24f8f316367b30810810d4eb30c543d7003ff3b"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/process/zipball/5d1662fb32ebc94f17ddb8d635454a776066733d",
- "reference": "5d1662fb32ebc94f17ddb8d635454a776066733d",
+ "url": "https://api.github.com/repos/symfony/process/zipball/f24f8f316367b30810810d4eb30c543d7003ff3b",
+ "reference": "f24f8f316367b30810810d4eb30c543d7003ff3b",
"shasum": ""
},
"require": {
- "php": ">=7.2.5",
- "symfony/polyfill-php80": "^1.16"
+ "php": ">=8.2"
},
"type": "library",
"autoload": {
@@ -2844,7 +2929,7 @@
"description": "Executes commands in sub-processes",
"homepage": "https://symfony.com",
"support": {
- "source": "https://github.com/symfony/process/tree/v5.4.47"
+ "source": "https://github.com/symfony/process/tree/v7.3.4"
},
"funding": [
{
@@ -2855,38 +2940,39 @@
"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": "2024-11-06T11:36:42+00:00"
+ "time": "2025-09-11T10:12:26+00:00"
},
{
"name": "symfony/service-contracts",
- "version": "v2.5.4",
+ "version": "v3.6.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/service-contracts.git",
- "reference": "f37b419f7aea2e9abf10abd261832cace12e3300"
+ "reference": "f021b05a130d35510bd6b25fe9053c2a8a15d5d4"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/service-contracts/zipball/f37b419f7aea2e9abf10abd261832cace12e3300",
- "reference": "f37b419f7aea2e9abf10abd261832cace12e3300",
+ "url": "https://api.github.com/repos/symfony/service-contracts/zipball/f021b05a130d35510bd6b25fe9053c2a8a15d5d4",
+ "reference": "f021b05a130d35510bd6b25fe9053c2a8a15d5d4",
"shasum": ""
},
"require": {
- "php": ">=7.2.5",
- "psr/container": "^1.1",
- "symfony/deprecation-contracts": "^2.1|^3"
+ "php": ">=8.1",
+ "psr/container": "^1.1|^2.0",
+ "symfony/deprecation-contracts": "^2.5|^3"
},
"conflict": {
"ext-psr": "<1.1|>=2"
},
- "suggest": {
- "symfony/service-implementation": ""
- },
"type": "library",
"extra": {
"thanks": {
@@ -2894,13 +2980,16 @@
"name": "symfony/contracts"
},
"branch-alias": {
- "dev-main": "2.5-dev"
+ "dev-main": "3.6-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Contracts\\Service\\": ""
- }
+ },
+ "exclude-from-classmap": [
+ "/Test/"
+ ]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
@@ -2927,7 +3016,7 @@
"standards"
],
"support": {
- "source": "https://github.com/symfony/service-contracts/tree/v2.5.4"
+ "source": "https://github.com/symfony/service-contracts/tree/v3.6.0"
},
"funding": [
{
@@ -2943,25 +3032,25 @@
"type": "tidelift"
}
],
- "time": "2024-09-25T14:11:13+00:00"
+ "time": "2025-04-25T09:37:31+00:00"
},
{
"name": "symfony/stopwatch",
- "version": "v5.4.45",
+ "version": "v7.3.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/stopwatch.git",
- "reference": "fb2c199cf302eb207f8c23e7ee174c1c31a5c004"
+ "reference": "5a49289e2b308214c8b9c2fda4ea454d8b8ad7cd"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/stopwatch/zipball/fb2c199cf302eb207f8c23e7ee174c1c31a5c004",
- "reference": "fb2c199cf302eb207f8c23e7ee174c1c31a5c004",
+ "url": "https://api.github.com/repos/symfony/stopwatch/zipball/5a49289e2b308214c8b9c2fda4ea454d8b8ad7cd",
+ "reference": "5a49289e2b308214c8b9c2fda4ea454d8b8ad7cd",
"shasum": ""
},
"require": {
- "php": ">=7.2.5",
- "symfony/service-contracts": "^1|^2|^3"
+ "php": ">=8.2",
+ "symfony/service-contracts": "^2.5|^3"
},
"type": "library",
"autoload": {
@@ -2989,7 +3078,7 @@
"description": "Provides a way to profile code",
"homepage": "https://symfony.com",
"support": {
- "source": "https://github.com/symfony/stopwatch/tree/v5.4.45"
+ "source": "https://github.com/symfony/stopwatch/tree/v7.3.0"
},
"funding": [
{
@@ -3005,38 +3094,38 @@
"type": "tidelift"
}
],
- "time": "2024-09-25T14:11:13+00:00"
+ "time": "2025-02-24T10:49:57+00:00"
},
{
"name": "symfony/string",
- "version": "v5.4.47",
+ "version": "v7.3.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/string.git",
- "reference": "136ca7d72f72b599f2631aca474a4f8e26719799"
+ "reference": "f96476035142921000338bad71e5247fbc138872"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/string/zipball/136ca7d72f72b599f2631aca474a4f8e26719799",
- "reference": "136ca7d72f72b599f2631aca474a4f8e26719799",
+ "url": "https://api.github.com/repos/symfony/string/zipball/f96476035142921000338bad71e5247fbc138872",
+ "reference": "f96476035142921000338bad71e5247fbc138872",
"shasum": ""
},
"require": {
- "php": ">=7.2.5",
+ "php": ">=8.2",
"symfony/polyfill-ctype": "~1.8",
"symfony/polyfill-intl-grapheme": "~1.0",
"symfony/polyfill-intl-normalizer": "~1.0",
- "symfony/polyfill-mbstring": "~1.0",
- "symfony/polyfill-php80": "~1.15"
+ "symfony/polyfill-mbstring": "~1.0"
},
"conflict": {
- "symfony/translation-contracts": ">=3.0"
+ "symfony/translation-contracts": "<2.5"
},
"require-dev": {
- "symfony/error-handler": "^4.4|^5.0|^6.0",
- "symfony/http-client": "^4.4|^5.0|^6.0",
- "symfony/translation-contracts": "^1.1|^2",
- "symfony/var-exporter": "^4.4|^5.0|^6.0"
+ "symfony/emoji": "^7.1",
+ "symfony/http-client": "^6.4|^7.0",
+ "symfony/intl": "^6.4|^7.0",
+ "symfony/translation-contracts": "^2.5|^3.0",
+ "symfony/var-exporter": "^6.4|^7.0"
},
"type": "library",
"autoload": {
@@ -3075,7 +3164,7 @@
"utf8"
],
"support": {
- "source": "https://github.com/symfony/string/tree/v5.4.47"
+ "source": "https://github.com/symfony/string/tree/v7.3.4"
},
"funding": [
{
@@ -3086,36 +3175,39 @@
"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": "2024-11-10T20:33:58+00:00"
+ "time": "2025-09-11T14:36:48+00:00"
},
{
"name": "twig/twig",
- "version": "v3.11.3",
+ "version": "v3.21.1",
"source": {
"type": "git",
"url": "https://github.com/twigphp/Twig.git",
- "reference": "3b06600ff3abefaf8ff55d5c336cd1c4253f8c7e"
+ "reference": "285123877d4dd97dd7c11842ac5fb7e86e60d81d"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/twigphp/Twig/zipball/3b06600ff3abefaf8ff55d5c336cd1c4253f8c7e",
- "reference": "3b06600ff3abefaf8ff55d5c336cd1c4253f8c7e",
+ "url": "https://api.github.com/repos/twigphp/Twig/zipball/285123877d4dd97dd7c11842ac5fb7e86e60d81d",
+ "reference": "285123877d4dd97dd7c11842ac5fb7e86e60d81d",
"shasum": ""
},
"require": {
- "php": ">=7.2.5",
+ "php": ">=8.1.0",
"symfony/deprecation-contracts": "^2.5|^3",
"symfony/polyfill-ctype": "^1.8",
- "symfony/polyfill-mbstring": "^1.3",
- "symfony/polyfill-php80": "^1.22",
- "symfony/polyfill-php81": "^1.29"
+ "symfony/polyfill-mbstring": "^1.3"
},
"require-dev": {
+ "phpstan/phpstan": "^2.0",
"psr/container": "^1.0|^2.0",
"symfony/phpunit-bridge": "^5.4.9|^6.4|^7.0"
},
@@ -3159,7 +3251,7 @@
],
"support": {
"issues": "https://github.com/twigphp/Twig/issues",
- "source": "https://github.com/twigphp/Twig/tree/v3.11.3"
+ "source": "https://github.com/twigphp/Twig/tree/v3.21.1"
},
"funding": [
{
@@ -3171,20 +3263,20 @@
"type": "tidelift"
}
],
- "time": "2024-11-07T12:34:41+00:00"
+ "time": "2025-05-03T07:21:55+00:00"
}
],
"aliases": [],
"minimum-stability": "stable",
- "stability-flags": [],
+ "stability-flags": {},
"prefer-stable": false,
"prefer-lowest": false,
"platform": {
- "php": ">=7.4"
+ "php": ">=8.2"
},
- "platform-dev": [],
+ "platform-dev": {},
"platform-overrides": {
- "php": "7.4.0"
+ "php": "8.2.99"
},
"plugin-api-version": "2.6.0"
}
diff --git a/front/config.form.php b/front/config.form.php
index 3ea7941..ed9a7bf 100644
--- a/front/config.form.php
+++ b/front/config.form.php
@@ -30,12 +30,10 @@
* --------------------------------------------------------------------------
*/
-include('../../../inc/includes.php');
-
Session::checkLoginUser();
// No autoload when plugin is not activated
-require_once('../inc/config.class.php');
+require_once(__DIR__ . '/../inc/config.class.php');
$config = new PluginPdfConfig();
if (isset($_POST['update'])) {
diff --git a/front/export.massive.php b/front/export.massive.php
index 0fab385..2302400 100644
--- a/front/export.massive.php
+++ b/front/export.massive.php
@@ -30,27 +30,34 @@
* --------------------------------------------------------------------------
*/
-include('../../../inc/includes.php');
+/** @var array $PLUGIN_HOOKS */
+global $PLUGIN_HOOKS;
Session::checkRight('plugin_pdf', READ);
Plugin::load('pdf', true);
$type = $_SESSION['plugin_pdf']['type'];
-$item = new $type();
+$dbu = new DbUtils();
+$item = $dbu->getItemForItemtype($type);
+if (!$item) {
+ throw new InvalidArgumentException('Invalid item type: ' . $type);
+}
$tab_id = unserialize($_SESSION['plugin_pdf']['tab_id']);
unset($_SESSION['plugin_pdf']['tab_id']);
-/** @var \DBmysql $DB */
+/** @var DBmysql $DB */
global $DB;
-$result = $DB->request(
- 'glpi_plugin_pdf_preferences',
- ['SELECT' => 'tabref',
- 'WHERE' => ['users_ID' => $_SESSION['glpiID'],
- 'itemtype' => $type]],
-);
+$result = $DB->request([
+ 'FROM' => 'glpi_plugin_pdf_preferences',
+ 'SELECT' => 'tabref',
+ 'WHERE' => [
+ 'users_ID' => $_SESSION['glpiID'],
+ 'itemtype' => $type,
+ ],
+]);
$tab = [];
@@ -61,13 +68,18 @@
$tab[] = $data['tabref'];
}
}
-if (empty($tab)) {
+if ($tab === []) {
$tab[] = $type . '$main';
}
-if (isset($PLUGIN_HOOKS['plugin_pdf'][$type])) {
- $itempdf = new $PLUGIN_HOOKS['plugin_pdf'][$type]($item);
- $itempdf->generatePDF($tab_id, $tab, (isset($pag) ? $pag : 0));
+if (isset($PLUGIN_HOOKS['plugin_pdf'][$type]) && class_exists($PLUGIN_HOOKS['plugin_pdf'][$type])) {
+ $pdf_class = $PLUGIN_HOOKS['plugin_pdf'][$type];
+ if (!is_a($pdf_class, PluginPdfCommon::class, true)) {
+ throw new RuntimeException('Invalid PDF plugin class for type: ' . $type);
+ }
+
+ $itempdf = new $pdf_class($item);
+ $itempdf->generatePDF($tab_id, $tab, ($pag ?? 0));
} else {
- die('Missing hook');
+ throw new RuntimeException('Missing PDF plugin hook for type: ' . $type);
}
diff --git a/front/export.php b/front/export.php
index d3df80e..dea3448 100644
--- a/front/export.php
+++ b/front/export.php
@@ -30,18 +30,14 @@
* --------------------------------------------------------------------------
*/
-define('GLPI_KEEP_CSRF_TOKEN', true); // 0.90
-$token = (isset($_POST['_glpi_csrf_token']) ? $_POST['_glpi_csrf_token'] : false);
+/** @var array $PLUGIN_HOOKS */
+global $PLUGIN_HOOKS;
-include('../../../inc/includes.php');
+define('GLPI_KEEP_CSRF_TOKEN', true); // 0.90
+$token = ($_POST['_glpi_csrf_token'] ?? false);
Session::checkRight('plugin_pdf', READ);
-/* 0.85 Hack to allow multiple exports, yes this is an hack, yes an awful one */
-if (!isset($_SESSION['glpicsrftokens'][$token])) {
- $_SESSION['glpicsrftokens'][$token] = time() + GLPI_CSRF_EXPIRES;
-}
-
Plugin::load('pdf', true);
$dbu = new DbUtils();
@@ -65,17 +61,24 @@
}
}
}
- if (empty($tab)) {
+ if ($tab === []) {
$tab[] = $type . '$main';
}
- if (isset($PLUGIN_HOOKS['plugin_pdf'][$type])
- && class_exists($PLUGIN_HOOKS['plugin_pdf'][$type])) {
- $itempdf = new $PLUGIN_HOOKS['plugin_pdf'][$type]($item);
- $itempdf->generatePDF([$_POST['itemID']], $tab, (isset($_POST['page']) ? $_POST['page'] : 0));
+ if (
+ isset($PLUGIN_HOOKS['plugin_pdf'][$type])
+ && class_exists($PLUGIN_HOOKS['plugin_pdf'][$type])
+ ) {
+ $pdf_class = $PLUGIN_HOOKS['plugin_pdf'][$type];
+ if (!is_a($pdf_class, PluginPdfCommon::class, true)) {
+ throw new RuntimeException('Invalid PDF plugin class for type: ' . $type);
+ }
+
+ $itempdf = new $pdf_class($item);
+ $itempdf->generatePDF([$_POST['itemID']], $tab, ($_POST['page'] ?? 0));
} else {
- die('Missing hook');
+ throw new RuntimeException('Missing PDF plugin hook for type: ' . $type);
}
} else {
- die('Missing context');
+ throw new InvalidArgumentException('Missing required context or parameters for PDF generation');
}
diff --git a/front/preference.form.php b/front/preference.form.php
index 657af87..c84ae48 100644
--- a/front/preference.form.php
+++ b/front/preference.form.php
@@ -30,11 +30,11 @@
* --------------------------------------------------------------------------
*/
-include_once('../../../inc/includes.php');
+include_once(__DIR__ . '/../../../inc/includes.php');
Session::checkLoginUser();
-/** @var \DBmysql $DB */
+/** @var DBmysql $DB */
global $DB;
//Save user preferences
diff --git a/hook.php b/hook.php
index d6150bf..c6d1a75 100644
--- a/hook.php
+++ b/hook.php
@@ -51,7 +51,7 @@ function plugin_pdf_MassiveActions($type)
default:
if (isset($PLUGIN_HOOKS['plugin_pdf'][$type])) {
return ['PluginPdfCommon' . MassiveAction::CLASS_ACTION_SEPARATOR . 'DoIt'
- => __('Print to pdf', 'pdf')];
+ => '' . __s('PDF export', 'pdf')];
}
}
@@ -99,22 +99,9 @@ function plugin_pdf_uninstall()
$query = "DELETE
FROM `glpi_profilerights`
WHERE `name` = 'plugin_pdf'";
- $DB->doQueryOrDie($query, $DB->error());
+ $DB->doQuery($query);
$migration->executeMigration();
return true;
}
-
-
-/**
- * @since version 1.0.2
-**/
-function plugin_pdf_registerMethods()
-{
- /** @var array $WEBSERVICES_METHOD */
- global $WEBSERVICES_METHOD;
-
- $WEBSERVICES_METHOD['pdf.getTabs'] = ['PluginPdfRemote', 'methodGetTabs'];
- $WEBSERVICES_METHOD['pdf.getPdf'] = ['PluginPdfRemote', 'methodGetPdf'];
-}
diff --git a/inc/appliance.class.php b/inc/appliance.class.php
index cf23ca8..bbee4b1 100644
--- a/inc/appliance.class.php
+++ b/inc/appliance.class.php
@@ -39,7 +39,7 @@ class PluginPdfAppliance extends PluginPdfCommon
**/
public function __construct(?CommonGLPI $obj = null)
{
- $this->obj = ($obj ? $obj : new Appliance());
+ $this->obj = ($obj ?: new Appliance());
}
/**
@@ -96,15 +96,13 @@ public static function displayTabContentForPDF(PluginPdfSimplePDF $pdf, CommonGL
public static function pdfMain(PluginPdfSimplePDF $pdf, Appliance $item)
{
- $dbu = new DbUtils();
-
PluginPdfCommon::mainTitle($pdf, $item);
$pdf->displayLine(
- sprintf(__('%1$s: %2$s'), '' . __('Name') . '', $item->fields['name']),
+ sprintf(__s('%1$s: %2$s'), '' . __s('Name') . '', $item->fields['name']),
sprintf(
- __('%1$s: %2$s'),
- '' . _n('Status', 'Statuses', 1) . '',
+ __s('%1$s: %2$s'),
+ '' . _sn('Status', 'Statuses', 1) . '',
Toolbox::stripTags(Dropdown::getDropdownName(
'glpi_states',
$item->fields['states_id'],
@@ -114,13 +112,13 @@ public static function pdfMain(PluginPdfSimplePDF $pdf, Appliance $item)
$pdf->displayLine(
sprintf(
- __('%1$s: %2$s'),
- '' . __('Associable to a ticket') . '',
+ __s('%1$s: %2$s'),
+ '' . __s('Associable to a ticket') . '',
Dropdown::getYesNo($item->fields['is_helpdesk_visible']),
),
sprintf(
- __('%1$s: %2$s'),
- '' . __('Location') . '',
+ __s('%1$s: %2$s'),
+ '' . __s('Location') . '',
Toolbox::stripTags(Dropdown::getDropdownName(
'glpi_locations',
$item->fields['locations_id'],
@@ -130,32 +128,32 @@ public static function pdfMain(PluginPdfSimplePDF $pdf, Appliance $item)
$pdf->displayLine(
sprintf(
- __('%1$s: %2$s'),
- '' . __('Type') . '',
+ __s('%1$s: %2$s'),
+ '' . __s('Type') . '',
Toolbox::stripTags(Dropdown::getDropdownName(
'glpi_appliancetypes',
$item->fields['appliancetypes_id'],
)),
),
sprintf(
- __('%1$s: %2$s'),
- '' . __('Technician in charge of the hardware') . '',
+ __s('%1$s: %2$s'),
+ '' . __s('Technician in charge of the hardware') . '',
getUserName($item->fields['users_id_tech']),
),
);
$pdf->displayLine(
sprintf(
- __('%1$s: %2$s'),
- '' . __('Manufacturer') . '',
+ __s('%1$s: %2$s'),
+ '' . __s('Manufacturer') . '',
Toolbox::stripTags(Dropdown::getDropdownName(
'glpi_suppliers',
$item->fields['manufacturers_id'],
)),
),
sprintf(
- __('%1$s: %2$s'),
- '' . __('Group in charge of the hardware') . '',
+ __s('%1$s: %2$s'),
+ '' . __s('Group in charge of the hardware') . '',
Toolbox::stripTags(Dropdown::getDropdownName(
'glpi_groups',
$item->fields['groups_id_tech'],
@@ -165,26 +163,26 @@ public static function pdfMain(PluginPdfSimplePDF $pdf, Appliance $item)
$pdf->displayLine(
sprintf(
- __('%1$s: %2$s'),
- '' . __('Serial number') . '',
+ __s('%1$s: %2$s'),
+ '' . __s('Serial number') . '',
$item->fields['serial'],
),
sprintf(
- __('%1$s: %2$s'),
- '' . __('Inventory number') . '',
+ __s('%1$s: %2$s'),
+ '' . __s('Inventory number') . '',
$item->fields['otherserial'],
),
);
$pdf->displayLine(
sprintf(
- __('%1$s: %2$s'),
- '' . __('User') . '',
+ __s('%1$s: %2$s'),
+ '' . __s('User') . '',
getUserName($item->fields['users_id']),
),
sprintf(
- __('%1$s: %2$s'),
- '' . __('Group') . '',
+ __s('%1$s: %2$s'),
+ '' . __s('Group') . '',
Toolbox::stripTags(Dropdown::getDropdownName(
'glpi_groups',
$item->fields['groups_id'],
@@ -194,8 +192,8 @@ public static function pdfMain(PluginPdfSimplePDF $pdf, Appliance $item)
$pdf->displayLine(
sprintf(
- __('%1$s: %2$s'),
- '' . __('Environment', 'appliances') . '',
+ __s('%1$s: %2$s'),
+ '' . __s('Environment', 'appliances') . '',
Toolbox::stripTags(Dropdown::getDropdownName(
'glpi_applianceenvironments',
$item->fields['applianceenvironments_id'],
@@ -204,7 +202,7 @@ public static function pdfMain(PluginPdfSimplePDF $pdf, Appliance $item)
);
$pdf->displayText(
- sprintf(__('%1$s: %2$s'), '' . __('Comments') . '', $item->fields['comment']),
+ sprintf(__s('%1$s: %2$s'), '' . __s('Comments') . '', $item->fields['comment']),
);
$pdf->displaySpace();
@@ -218,34 +216,36 @@ public static function pdfForAppliance(PluginPdfSimplePDF $pdf, Appliance $appli
$instID = $appli->fields['id'];
$pdf->setColumnsSize(100);
- $pdf->displayTitle('' . _n('Associated item', 'Associated items', 2) . '');
+ $pdf->displayTitle('' . _sn('Associated item', 'Associated items', 2) . '');
- $result = $DB->request('SELECT DISTINCT `itemtype`
- FROM `glpi_appliances_items`
- WHERE `appliances_id` = ' . $instID);
+ $result = $DB->request([
+ 'SELECT' => 'DISTINCT itemtype',
+ 'FROM' => 'glpi_appliances_items',
+ 'WHERE' => ['appliances_id' => $instID],
+ ]);
$number = count($result);
if (Session::isMultiEntitiesMode()) {
$pdf->setColumnsSize(12, 27, 25, 18, 18);
$pdf->displayTitle(
- '' . __('Type'),
- __('Name'),
- __('Entity'),
- __('Serial number'),
- __('Inventory number') . '',
+ '' . __s('Type'),
+ __s('Name'),
+ __s('Entity'),
+ __s('Serial number'),
+ __s('Inventory number') . '',
);
} else {
$pdf->setColumnsSize(25, 31, 22, 22);
$pdf->displayTitle(
- '' . __('Type'),
- __('Name'),
- __('Serial number'),
- __('Inventory number') . '',
+ '' . __s('Type'),
+ __s('Name'),
+ __s('Serial number'),
+ __s('Inventory number') . '',
);
}
- if (!$number) {
- $pdf->displayLine(__('No item found'));
+ if ($number === 0) {
+ $pdf->displayLine(__s('No item found'));
} else {
$dbu = new DbUtils();
foreach ($result as $id => $row) {
@@ -286,21 +286,21 @@ public static function pdfForAppliance(PluginPdfSimplePDF $pdf, Appliance $appli
$query['ORDER'] = ['glpi_entities.completename', $item->getTable() . '.' . $column];
$result_linked = $DB->request($query);
- if (count($result_linked)) {
+ if (count($result_linked) > 0) {
foreach ($result_linked as $id => $data) {
if (!$item->getFromDB($data['id'])) {
continue;
}
if ($type == 'Ticket') {
- $data['name'] = sprintf(__('%1$s %2$s'), __('Ticket'), $data['id']);
+ $data['name'] = sprintf(__s('%1$s %2$s'), __s('Ticket'), $data['id']);
}
if ($type == 'KnowbaseItem') {
$data['name'] = $data['question'];
}
$name = $data['name'];
if (empty($data['name'])) {
- $name = sprintf(__('%1$s (%2$s)'), $name, $data['id']);
+ $name = sprintf(__s('%1$s (%2$s)'), $name, $data['id']);
}
if (Session::isMultiEntitiesMode()) {
@@ -312,16 +312,16 @@ public static function pdfForAppliance(PluginPdfSimplePDF $pdf, Appliance $appli
'glpi_entities',
$data['entities_id'],
),
- (isset($data['serial']) ? $data['serial'] : '-'),
- (isset($data['otherserial']) ? $data['otherserial'] : '-'),
+ ($data['serial'] ?? '-'),
+ ($data['otherserial'] ?? '-'),
);
} else {
$pdf->setColumnsSize(25, 31, 22, 22);
$pdf->displayTitle(
$item->getTypeName(1),
$name,
- (isset($data['serial']) ? $data['serial'] : '-'),
- (isset($data['otherserial']) ? $data['otherserial'] : '-'),
+ ($data['serial'] ?? '-'),
+ ($data['otherserial'] ?? '-'),
);
}
@@ -348,7 +348,10 @@ public static function showList_relation($pdf, $relID)
$item = $relation->fields['itemtype'];
- $objtype = new $item();
+ $objtype = $dbu->getItemForItemtype($item);
+ if (!$objtype) {
+ return;
+ }
// selects all the attached relations
$tablename = $dbu->getTableForItemType($item);
@@ -374,8 +377,8 @@ public static function showList_relation($pdf, $relID)
}
$pdf->setColumnsSize(100);
$pdf->displayLine(sprintf(
- __('%1$s: %2$s'),
- '' . __('Relations') . " $title ",
+ __s('%1$s: %2$s'),
+ '' . __s('Relations') . " $title ",
implode(', ', $opts),
));
}
@@ -398,7 +401,7 @@ public static function showList_PDF($pdf, $ID, $appliancesID)
'ORDER' => 'vvalues']);
$number_champs = count($result_app_opt);
- if (!$number_champs) {
+ if ($number_champs === 0) {
return;
}
@@ -420,8 +423,8 @@ public static function showList_PDF($pdf, $ID, $appliancesID)
$pdf->setColumnsSize(100);
$pdf->displayLine(sprintf(
- __('%1$s: %2$s'),
- '' . __('User fields', 'appliances') . '',
+ __s('%1$s: %2$s'),
+ '' . __s('User fields', 'appliances') . '',
implode(', ', $opts),
));
}
@@ -431,13 +434,11 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
/** @var DBmysql $DB */
global $DB;
- $dbu = new DbUtils();
-
$ID = $item->getField('id');
$itemtype = get_class($item);
$pdf->setColumnsSize(100);
- $pdf->displayTitle('' . __('Associated appliances', 'appliances') . '');
+ $pdf->displayTitle('' . __s('Associated appliances', 'appliances') . '');
$query = ['FIELDS' => ['glpi_plugin_appliances_appliances_items.id AS entID',
'glpi_plugin_appliances_appliances.*'],
@@ -462,15 +463,15 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
$result = $DB->request($query);
$number = count($result);
- if (!$number) {
- $pdf->displayLine(__('No item found'));
+ if ($number === 0) {
+ $pdf->displayLine(__s('No item found'));
} else {
if (Session::isMultiEntitiesMode()) {
$pdf->setColumnsSize(30, 30, 20, 20);
- $pdf->displayTitle('' . __('Name'), __('Entity'), __('Group'), __('Type') . '');
+ $pdf->displayTitle('' . __s('Name'), __s('Entity'), __s('Group'), __s('Type') . '');
} else {
$pdf->setColumnsSize(50, 25, 25);
- $pdf->displayTitle('' . __('Name'), __('Group'), __('Type') . '');
+ $pdf->displayTitle('' . __s('Name'), __s('Group'), __s('Type') . '');
}
while ($data = $result->current()) {
diff --git a/inc/cartridge.class.php b/inc/cartridge.class.php
index 266368d..efda6d0 100644
--- a/inc/cartridge.class.php
+++ b/inc/cartridge.class.php
@@ -39,7 +39,7 @@ class PluginPdfCartridge extends PluginPdfCommon
**/
public function __construct(?CommonGLPI $obj = null)
{
- $this->obj = ($obj ? $obj : new Cartridge());
+ $this->obj = ($obj ?: new Cartridge());
}
/**
@@ -62,78 +62,98 @@ public static function pdfForPrinter(PluginPdfSimplePDF $pdf, Printer $p, $old =
if ($old) {
$dateout = ' IS NOT NULL ';
}
- $query = 'SELECT `glpi_cartridgeitems`.`id` AS tID,
- `glpi_cartridgeitems`.`is_deleted`,
- `glpi_cartridgeitems`.`ref`,
- `glpi_cartridgeitems`.`name` AS type,
- `glpi_cartridges`.`id`,
- `glpi_cartridges`.`pages`,
- `glpi_cartridges`.`date_use`,
- `glpi_cartridges`.`date_out`,
- `glpi_cartridges`.`date_in`,
- `glpi_cartridgeitemtypes`.`name` AS typename
- FROM `glpi_cartridges`,
- `glpi_cartridgeitems`
- LEFT JOIN `glpi_cartridgeitemtypes`
- ON (`glpi_cartridgeitems`.`cartridgeitemtypes_id` = `glpi_cartridgeitemtypes`.`id`)
- WHERE `glpi_cartridges`.`date_out` ' . $dateout . "
- AND `glpi_cartridges`.`printers_id` = '" . $instID . "'
- AND `glpi_cartridges`.`cartridgeitems_id` = `glpi_cartridgeitems`.`id`
- ORDER BY `glpi_cartridges`.`date_out` ASC,
- `glpi_cartridges`.`date_use` DESC,
- `glpi_cartridges`.`date_in`";
+ $query = [
+ 'SELECT' => [
+ 'glpi_cartridgeitems.id AS tID',
+ 'glpi_cartridgeitems.is_deleted',
+ 'glpi_cartridgeitems.ref',
+ 'glpi_cartridgeitems.name AS type',
+ 'glpi_cartridges.id',
+ 'glpi_cartridges.pages',
+ 'glpi_cartridges.date_use',
+ 'glpi_cartridges.date_out',
+ 'glpi_cartridges.date_in',
+ 'glpi_cartridgeitemtypes.name AS typename',
+ ],
+ 'FROM' => 'glpi_cartridges',
+ 'INNER JOIN' => [
+ 'glpi_cartridgeitems' => [
+ 'FKEY' => [
+ 'glpi_cartridges' => 'cartridgeitems_id',
+ 'glpi_cartridgeitems' => 'id',
+ ],
+ ],
+ ],
+ 'LEFT JOIN' => [
+ 'glpi_cartridgeitemtypes' => [
+ 'FKEY' => [
+ 'glpi_cartridgeitems' => 'cartridgeitemtypes_id',
+ 'glpi_cartridgeitemtypes' => 'id',
+ ],
+ ],
+ ],
+ 'WHERE' => [
+ 'glpi_cartridges.printers_id' => $instID,
+ 'glpi_cartridges.date_out' => ($old ? ['NOT' => null] : null),
+ ],
+ 'ORDER' => [
+ 'glpi_cartridges.date_out ASC',
+ 'glpi_cartridges.date_use DESC',
+ 'glpi_cartridges.date_in',
+ ],
+ ];
$result = $DB->request($query);
$number = count($result);
- $i = 0;
$pages = $p->fields['init_pages_counter'];
$pdf->setColumnsSize(100);
- $title = '' . ($old ? __('Worn cartridges') : __('Used cartridges')) . '';
+ $title = '' . ($old ? __s('Worn cartridges') : __s('Used cartridges')) . '';
- if (!$number) {
- $pdf->displayTitle(sprintf(__('%1$s: %2$s'), $title, __('No item to display')));
+ $stock_time = 0;
+ $use_time = 0;
+ $pages_printed = 0;
+ $nb_pages_printed = 0;
+
+ if ($number === 0) {
+ $pdf->displayTitle(sprintf(__s('%1$s: %2$s'), $title, __s('No item to display')));
} else {
- $title = sprintf(__('%1$s: %2$s'), $title, $number);
+ $title = sprintf(__s('%1$s: %2$s'), $title, $number);
$pdf->displayTitle($title);
if (!$old) {
$pdf->setColumnsSize(5, 35, 30, 15, 15);
$pdf->displayTitle(
- '' . __('ID'),
- __('Cartridge model'),
- __('Cartridge type'),
- __('Add date'),
- __('Use date') .
+ '' . __s('ID'),
+ __s('Cartridge model'),
+ __s('Cartridge type'),
+ __s('Add date'),
+ __s('Use date') .
'',
);
} else {
$pdf->setColumnsSize(4, 20, 20, 10, 10, 10, 13, 13);
$pdf->displayTitle(
- '' . __('ID'),
- __('Cartridge model'),
- __('Cartridge type'),
- __('Add date'),
- __('Use date'),
- __('End date'),
- __('Printer counter'),
- __('Printed pages') .
+ '' . __s('ID'),
+ __s('Cartridge model'),
+ __s('Cartridge type'),
+ __s('Add date'),
+ __s('Use date'),
+ __s('End date'),
+ __s('Printer counter'),
+ __s('Printed pages') .
'',
);
}
- $stock_time = 0;
- $use_time = 0;
- $pages_printed = 0;
- $nb_pages_printed = 0;
foreach ($result as $data) {
$date_in = Html::convDate($data['date_in']);
$date_use = Html::convDate($data['date_use']);
$date_out = Html::convDate($data['date_out']);
$col1 = $data['id'];
- $col2 = sprintf(__('%1$s - %2$s'), $data['type'], $data['ref']);
+ $col2 = sprintf(__s('%1$s - %2$s'), $data['type'], $data['ref']);
$col6 = $data['pages'];
$col7 = '';
@@ -156,9 +176,9 @@ public static function pdfForPrinter(PluginPdfSimplePDF $pdf, Printer $p, $old =
$pages_printed += $data['pages'] - $pages;
$nb_pages_printed++;
$col7 = sprintf(
- __('%1$s (%2$s)'),
+ __s('%1$s (%2$s)'),
$col6,
- __('%d printed pages'),
+ __s('%d printed pages'),
($data['pages'] - $pages),
);
$pages = $data['pages'];
@@ -192,18 +212,18 @@ public static function pdfForPrinter(PluginPdfSimplePDF $pdf, Printer $p, $old =
$pdf->setColumnsSize(33, 33, 34);
$pdf->displayTitle(
'' . sprintf(
- __('%1$s: %2$s'),
- __('Average time in stock') . '',
- sprintf(_n('%d month', '%d months', (int) $time_stock), $time_stock),
+ __s('%1$s: %2$s'),
+ __s('Average time in stock') . '',
+ sprintf(_sn('%d month', '%d months', (int) $time_stock), $time_stock),
),
'' . sprintf(
- __('%1$s: %2$s'),
- __('Average time in use') . '',
- sprintf(_n('%d month', '%d months', (int) $time_use), $time_use),
+ __s('%1$s: %2$s'),
+ __s('Average time in use') . '',
+ sprintf(_sn('%d month', '%d months', (int) $time_use), $time_use),
),
'' . sprintf(
- __('%1$s: %2$s'),
- __('Average number of printed pages') . '',
+ __s('%1$s: %2$s'),
+ __s('Average number of printed pages') . '',
round($pages_printed / $nb_pages_printed),
),
);
@@ -245,76 +265,83 @@ public static function pdfForCartridgeItem(PluginPdfSimplePDF $pdf, CartridgeIte
$pages_printed = 0;
$nb_pages_printed = 0;
- $iterator = $DB->request(
- Cartridge::gettable(),
- ['SELECT' => ['glpi_cartridges.*',
+ $iterator = $DB->request([
+ 'FROM' => Cartridge::getTable(),
+ 'SELECT' => [
+ 'glpi_cartridges.*',
'glpi_printers.id AS printID',
'glpi_printers.name AS printname',
- 'glpi_printers.init_pages_counter'],
- 'LEFT JOIN' => ['glpi_printers'
- => ['FKEY' => [Cartridge::getTable() => 'printers_id',
- 'glpi_printers' => 'id']]],
- 'WHERE' => $where,
- 'ORDER' => $order],
- );
+ 'glpi_printers.init_pages_counter',
+ ],
+ 'LEFT JOIN' => [
+ 'glpi_printers' => [
+ 'FKEY' => [
+ Cartridge::getTable() => 'printers_id',
+ 'glpi_printers' => 'id',
+ ],
+ ],
+ ],
+ 'WHERE' => $where,
+ 'ORDER' => $order,
+ ]);
$number = count($iterator);
$pages = [];
- if ($number) {
+ if ($number !== 0) {
if ($state == 'new') {
$pdf->setColumnsSize(25, 25, 25, 25);
$pdf->displayTitle(
- '' . __('Total') . '',
+ '' . __s('Total') . '',
'' . Cartridge::getTotalNumber($tID) . '',
'' . sprintf(
- __('%1$s %2$s'),
- _n('Cartridge', 'Cartridges', $number),
+ __s('%1$s %2$s'),
+ _sn('Cartridge', 'Cartridges', $number),
_nx('cartridge', 'New', 'New', $number),
) . '',
'' . Cartridge::getUnusedNumber($tID) . '',
);
$pdf->displayTitle(
- '' . __('Used cartridges') . '',
+ '' . __s('Used cartridges') . '',
'' . Cartridge::getUsedNumber($tID),
- '' . __('Worn cartridges') . '',
+ '' . __s('Worn cartridges') . '',
'' . Cartridge::getOldNumber($tID),
);
$pdf->setColumnsSize(100);
$pdf->displayTitle('' . sprintf(
- __('%1$s %2$s'),
- _n('Cartridge', 'Cartridges', $number),
+ __s('%1$s %2$s'),
+ _sn('Cartridge', 'Cartridges', $number),
_nx('cartridge', 'New', 'New', $number),
) . '');
} elseif ($state == 'used') {
$pdf->setColumnsSize(100);
- $pdf->displayTitle('' . __('Used cartridges') . '');
+ $pdf->displayTitle('' . __s('Used cartridges') . '');
} else { // Old
$pdf->setColumnsSize(100);
- $pdf->displayTitle('' . __('Worn cartridges') . '');
+ $pdf->displayTitle('' . __s('Worn cartridges') . '');
}
if ($state != 'old') {
$pdf->setColumnsSize(5, 20, 20, 20, 35);
$pdf->displayLine(
- '' . __('ID') . '',
+ '' . __s('ID') . '',
'' . _x('item', 'State') . '',
- '' . __('Add date') . '',
- '' . __('Use date') . '',
- '' . __('Used on') . '',
+ '' . __s('Add date') . '',
+ '' . __s('Use date') . '',
+ '' . __s('Used on') . '',
);
} else {
$pdf->setColumnsSize(5, 20, 15, 15, 15, 15, 15);
$pdf->displayLine(
- '' . __('ID') . '',
+ '' . __s('ID') . '',
'' . _x('item', 'State') . '',
- '' . __('Add date') . '',
- '' . __('Use date') . '',
- '' . __('Used on') . '',
- '' . __('End date') . '',
- '' . __('Printer counter') . '',
+ '' . __s('Add date') . '',
+ '' . __s('Use date') . '',
+ '' . __s('Used on') . '',
+ '' . __s('End date') . '',
+ '' . __s('Printer counter') . '',
);
}
@@ -347,10 +374,10 @@ public static function pdfForCartridgeItem(PluginPdfSimplePDF $pdf, CartridgeIte
$pages_printed += $data['pages'] - $pages[$printer];
$nb_pages_printed++;
$pp = $data['pages'] - $pages[$printer];
- $pdfpages = sprintf(_n('%d printed page', '%d printed pages', $pp), $pp);
+ $pdfpages = sprintf(_sn('%d printed page', '%d printed pages', $pp), $pp);
$pages[$printer] = $data['pages'];
} elseif ($data['pages'] != 0) {
- $pdfpages = __('Counter error');
+ $pdfpages = __s('Counter error');
}
}
$pdf->displayLine(
@@ -370,14 +397,14 @@ public static function pdfForCartridgeItem(PluginPdfSimplePDF $pdf, CartridgeIte
}
$pdf->setColumnsSize(33, 33, 34);
$pdf->displayLine(
- '' . __('Average time in stock') . '',
- '' . __('Average time in use') . '',
- '' . __('Average number of printed pages') . '',
+ '' . __s('Average time in stock') . '',
+ '' . __s('Average time in use') . '',
+ '' . __s('Average number of printed pages') . '',
);
$pdf->displayLine(
- round($stock_time / $number / 60 / 60 / 24 / 30.5, 1) . ' ' . __('month'),
- round($use_time / $number / 60 / 60 / 24 / 30.5, 1) . ' ' . __('month'),
+ round($stock_time / $number / 60 / 60 / 24 / 30.5, 1) . ' ' . __s('month'),
+ round($use_time / $number / 60 / 60 / 24 / 30.5, 1) . ' ' . __s('month'),
round($pages_printed / $nb_pages_printed),
);
}
diff --git a/inc/cartridgeitem.class.php b/inc/cartridgeitem.class.php
index 17a9644..63a09db 100644
--- a/inc/cartridgeitem.class.php
+++ b/inc/cartridgeitem.class.php
@@ -36,7 +36,7 @@ class PluginPdfCartridgeItem extends PluginPdfCommon
public function __construct(?CommonGLPI $obj = null)
{
- $this->obj = ($obj ? $obj : new CartridgeItem());
+ $this->obj = ($obj ?: new CartridgeItem());
}
public function defineAllTabsPDF($options = [])
@@ -53,10 +53,10 @@ public static function pdfMain(PluginPdfSimplePDF $pdf, CartridgeItem $cartitem)
PluginPdfCommon::mainTitle($pdf, $cartitem);
$pdf->displayLine(
- '' . sprintf(__('%1$s: %2$s'), __('Name') . '', $cartitem->fields['name']),
+ '' . sprintf(__s('%1$s: %2$s'), __s('Name') . '', $cartitem->fields['name']),
'' . sprintf(
- __('%1$s: %2$s'),
- __('Location') . '',
+ __s('%1$s: %2$s'),
+ __s('Location') . '',
Toolbox::stripTags(Dropdown::getDropdownName(
'glpi_locations',
$cartitem->fields['locations_id'],
@@ -65,26 +65,26 @@ public static function pdfMain(PluginPdfSimplePDF $pdf, CartridgeItem $cartitem)
);
$pdf->displayLine(
'' . sprintf(
- __('%1$s: %2$s'),
- __('Type') . '',
+ __s('%1$s: %2$s'),
+ __s('Type') . '',
Toolbox::stripTags(Dropdown::getDropdownName(
'glpi_cartridgeitemtypes',
$cartitem->fields['cartridgeitemtypes_id'],
)),
),
- '' . sprintf(__('%1$s: %2$s'), __('Reference') . '', $cartitem->fields['ref']),
+ '' . sprintf(__s('%1$s: %2$s'), __s('Reference') . '', $cartitem->fields['ref']),
);
$pdf->displayLine(
'' . sprintf(
- __('%1$s: %2$s'),
- __('Technician in charge of the hardware') . '',
+ __s('%1$s: %2$s'),
+ __s('Technician in charge of the hardware') . '',
$dbu->getUserName($cartitem->fields['users_id_tech']),
),
'' . sprintf(
- __('%1$s: %2$s'),
- __('Manufacturer') . '',
+ __s('%1$s: %2$s'),
+ __s('Manufacturer') . '',
Toolbox::stripTags(Dropdown::getDropdownName(
'glpi_manufacturers',
$cartitem->fields['manufacturers_id'],
@@ -93,8 +93,8 @@ public static function pdfMain(PluginPdfSimplePDF $pdf, CartridgeItem $cartitem)
);
$pdf->displayLine(
'' . sprintf(
- __('%1$s: %2$s'),
- __('Group in charge of the hardware') . '',
+ __s('%1$s: %2$s'),
+ __s('Group in charge of the hardware') . '',
Dropdown::getDropdownName(
'glpi_groups',
$cartitem->fields['groups_id_tech'],
@@ -104,16 +104,16 @@ public static function pdfMain(PluginPdfSimplePDF $pdf, CartridgeItem $cartitem)
$pdf->displayLine(
'' . sprintf(
- __('%1$s: %2$s'),
- __('Stock location') . '',
+ __s('%1$s: %2$s'),
+ __s('Stock location') . '',
Dropdown::getDropdownName(
'glpi_locations',
$cartitem->fields['locations_id'],
),
),
'' . sprintf(
- __('%1$s: %2$s'),
- __('Alert threshold') . '',
+ __s('%1$s: %2$s'),
+ __s('Alert threshold') . '',
$cartitem->getField('alarm_threshold'),
),
);
@@ -161,14 +161,14 @@ public static function pdfForPrinterModel(PluginPdfSimplePDF $pdf, CartridgeItem
}
$pdf->setColumnsSize(100);
- $title = '' . _n('Printer model', 'Printer models', $number) . '';
- if (!$number) {
- $pdf->displayTitle(__('No printel model associated', 'pdf'));
+ $title = '' . _sn('Printer model', 'Printer models', $number) . '';
+ if ($number === 0) {
+ $pdf->displayTitle(__s('No printel model associated', 'pdf'));
} else {
if ($number > $_SESSION['glpilist_limit']) {
- $title = sprintf(__('%1$s: %2$s'), $title, $_SESSION['glpilist_limit'] . ' / ' . $number);
+ $title = sprintf(__s('%1$s: %2$s'), $title, $_SESSION['glpilist_limit'] . ' / ' . $number);
} else {
- $title = sprintf(__('%1$s: %2$s'), $title, $number);
+ $title = sprintf(__s('%1$s: %2$s'), $title, $number);
}
$pdf->displayTitle($title);
diff --git a/inc/change.class.php b/inc/change.class.php
index 2d6a8a3..0aa10a6 100644
--- a/inc/change.class.php
+++ b/inc/change.class.php
@@ -36,7 +36,7 @@ class PluginPdfChange extends PluginPdfCommon
public function __construct(?CommonGLPI $obj = null)
{
- $this->obj = ($obj ? $obj : new Change());
+ $this->obj = ($obj ?: new Change());
}
public static function pdfMain(PluginPdfSimplePDF $pdf, Change $job)
@@ -51,7 +51,7 @@ public static function pdfMain(PluginPdfSimplePDF $pdf, Change $job)
$pdf->setColumnsSize(100);
$pdf->displayTitle('' .
- (empty($job->fields['name']) ? __('Without title') : $name = $job->fields['name']) . '');
+ (empty($job->fields['name']) ? __s('Without title') : $name = $job->fields['name']) . '');
if (count($_SESSION['glpiactiveentities']) > 1) {
$entity = ' (' . Dropdown::getDropdownName('glpi_entities', $job->fields['entities_id']) . ')';
@@ -61,24 +61,23 @@ public static function pdfMain(PluginPdfSimplePDF $pdf, Change $job)
$pdf->setColumnsSize(50, 50);
$recipient_name = '';
+ $due = "";
if ($job->fields['users_id_recipient']) {
$recipient = new User();
$recipient->getFromDB($job->fields['users_id_recipient']);
$recipient_name = $recipient->getName();
}
-
- $sla = $due = $commentsla = '';
if ($job->fields['time_to_resolve']) {
$due = '' . sprintf(
- __('%1$s: %2$s'),
- __('Time to resolve') . '',
+ __s('%1$s: %2$s'),
+ __s('Time to resolve') . '',
Html::convDateTime($job->fields['time_to_resolve']),
);
}
$pdf->displayLine(
'' . sprintf(
- __('%1$s: %2$s'),
- __('Opening date') . '',
+ __s('%1$s: %2$s'),
+ __s('Opening date') . '',
Html::convDateTime($job->fields['date']),
),
$due,
@@ -88,29 +87,29 @@ public static function pdfMain(PluginPdfSimplePDF $pdf, Change $job)
$lastupdate = Html::convDateTime($job->fields['date_mod']);
if ($job->fields['users_id_lastupdater'] > 0) {
$lastupdate = sprintf(
- __('%1$s by %2$s'),
+ __s('%1$s by %2$s'),
$lastupdate,
$dbu->getUserName($job->fields['users_id_lastupdater']),
);
}
$pdf->displayLine(
- '' . sprintf(__('%1$s: %2$s'), __('By') . '', $recipient_name),
- '' . sprintf(__('%1$s: %2$s'), __('Last update') . '', $lastupdate),
+ '' . sprintf(__s('%1$s: %2$s'), __s('By') . '', $recipient_name),
+ '' . sprintf(__s('%1$s: %2$s'), __s('Last update') . '', $lastupdate),
);
$status = '';
if (in_array($job->fields['status'], $job->getSolvedStatusArray())
|| in_array($job->fields['status'], $job->getClosedStatusArray())) {
- $status = sprintf(__('%1$s %2$s'), '-', Html::convDateTime($job->fields['solvedate']));
+ $status = sprintf(__s('%1$s %2$s'), '-', Html::convDateTime($job->fields['solvedate']));
}
if (in_array($job->fields['status'], $job->getClosedStatusArray())) {
- $status = sprintf(__('%1$s %2$s'), '-', Html::convDateTime($job->fields['closedate']));
+ $status = sprintf(__s('%1$s %2$s'), '-', Html::convDateTime($job->fields['closedate']));
}
if ($job->fields['status'] == Change::WAITING) {
$status = sprintf(
- __('%1$s %2$s'),
+ __s('%1$s %2$s'),
'-',
Html::convDateTime($job->fields['begin_waiting_date']),
);
@@ -118,13 +117,13 @@ public static function pdfMain(PluginPdfSimplePDF $pdf, Change $job)
$pdf->displayLine(
'' . sprintf(
- __('%1$s: %2$s'),
- __('Status') . '',
+ __s('%1$s: %2$s'),
+ __s('Status') . '',
Toolbox::stripTags($job->getStatus($job->fields['status'])) . $status,
),
'' . sprintf(
- __('%1$s: %2$s'),
- __('Urgency') . '',
+ __s('%1$s: %2$s'),
+ __s('Urgency') . '',
Toolbox::stripTags($job->getUrgencyName($job->fields['urgency'])),
),
);
@@ -132,29 +131,29 @@ public static function pdfMain(PluginPdfSimplePDF $pdf, Change $job)
$pdf->displayLine(
'' . sprintf(
- __('%1$s: %2$s'),
- __('Category') . '',
+ __s('%1$s: %2$s'),
+ __s('Category') . '',
Dropdown::getDropdownName(
'glpi_itilcategories',
$job->fields['itilcategories_id'],
),
),
'' . sprintf(
- __('%1$s: %2$s'),
- __('Impact') . '',
+ __s('%1$s: %2$s'),
+ __s('Impact') . '',
Toolbox::stripTags($job->getImpactName($job->fields['impact'])),
),
);
$pdf->displayLine(
'' . sprintf(
- __('%1$s: %2$s'),
- __('Total duration') . '',
+ __s('%1$s: %2$s'),
+ __s('Total duration') . '',
Toolbox::stripTags(CommonITILObject::getActionTime($job->fields['actiontime'])),
),
'' . sprintf(
- __('%1$s: %2$s'),
- __('Priority') . '',
+ __s('%1$s: %2$s'),
+ __s('Priority') . '',
Toolbox::stripTags($job->getPriorityName($job->fields['priority'])),
),
);
@@ -164,7 +163,7 @@ public static function pdfMain(PluginPdfSimplePDF $pdf, Change $job)
// Requester
$users = [];
$listusers = '';
- $requester = '' . sprintf(__('%1$s: %2$s') . '', __('Requester'), $listusers);
+ $requester = '' . sprintf(__s('%1$s: %2$s') . '', __s('Requester'), $listusers);
foreach ($job->getUsers(CommonITILActor::REQUESTER) as $d) {
if ($d['users_id']) {
$tmp = Toolbox::stripTags($dbu->getUserName($d['users_id']));
@@ -184,8 +183,8 @@ public static function pdfMain(PluginPdfSimplePDF $pdf, Change $job)
$groups = [];
$listgroups = '';
$requestergroup = '' . sprintf(
- __('%1$s: %2$s') . '',
- __('Requester group'),
+ __s('%1$s: %2$s') . '',
+ __s('Requester group'),
$listgroups,
);
foreach ($job->getGroups(CommonITILActor::REQUESTER) as $d) {
@@ -200,7 +199,7 @@ public static function pdfMain(PluginPdfSimplePDF $pdf, Change $job)
// Observer
$users = [];
$listusers = '';
- $watcher = '' . sprintf(__('%1$s: %2$s') . '', __('Watcher'), $listusers);
+ $watcher = '' . sprintf(__s('%1$s: %2$s') . '', __s('Watcher'), $listusers);
foreach ($job->getUsers(CommonITILActor::OBSERVER) as $d) {
if ($d['users_id']) {
$tmp = Toolbox::stripTags($dbu->getUserName($d['users_id']));
@@ -220,8 +219,8 @@ public static function pdfMain(PluginPdfSimplePDF $pdf, Change $job)
$groups = [];
$listgroups = '';
$watchergroup = '' . sprintf(
- __('%1$s: %2$s') . '',
- __('Watcher group'),
+ __s('%1$s: %2$s') . '',
+ __s('Watcher group'),
$listgroups,
);
foreach ($job->getGroups(CommonITILActor::OBSERVER) as $d) {
@@ -237,8 +236,8 @@ public static function pdfMain(PluginPdfSimplePDF $pdf, Change $job)
$users = [];
$listusers = '';
$assign = '' . sprintf(
- __('%1$s: %2$s') . '',
- __('Assigned to technicians'),
+ __s('%1$s: %2$s') . '',
+ __s('Assigned to technicians'),
$listusers,
);
foreach ($job->getUsers(CommonITILActor::ASSIGN) as $d) {
@@ -260,8 +259,8 @@ public static function pdfMain(PluginPdfSimplePDF $pdf, Change $job)
$groups = [];
$listgroups = '';
$assigngroup = '' . sprintf(
- __('%1$s: %2$s') . '',
- __('Assigned to groups'),
+ __s('%1$s: %2$s') . '',
+ __s('Assigned to groups'),
$listgroups,
);
foreach ($job->getGroups(CommonITILActor::ASSIGN) as $d) {
@@ -277,8 +276,8 @@ public static function pdfMain(PluginPdfSimplePDF $pdf, Change $job)
$suppliers = [];
$listsuppliers = '';
$assignsupplier = '' . sprintf(
- __('%1$s: %2$s') . '',
- __('Assigned to a supplier'),
+ __s('%1$s: %2$s') . '',
+ __s('Assigned to a supplier'),
$listsuppliers,
);
foreach ($job->getSuppliers(CommonITILActor::ASSIGN) as $d) {
@@ -294,11 +293,11 @@ public static function pdfMain(PluginPdfSimplePDF $pdf, Change $job)
$pdf->setColumnsSize(100);
$pdf->displayLine(
- '' . sprintf(__('%1$s: %2$s'), __('Title') . '', $job->fields['name']),
+ '' . sprintf(__s('%1$s: %2$s'), __s('Title') . '', $job->fields['name']),
);
$pdf->displayText(
- '' . sprintf(__('%1$s: %2$s') . '', __('Description'), ''),
+ '' . sprintf(__s('%1$s: %2$s') . '', __s('Description'), ''),
Toolbox::stripTags($job->fields['content']),
1,
);
@@ -309,19 +308,19 @@ public static function pdfMain(PluginPdfSimplePDF $pdf, Change $job)
public static function pdfAnalysis(PluginPdfSimplePDF $pdf, Change $job)
{
$pdf->setColumnsSize(100);
- $pdf->displayTitle('' . __('Analysis') . '');
+ $pdf->displayTitle('' . __s('Analysis') . '');
$pdf->setColumnsSize(10, 90);
$pdf->displayText(sprintf(
- __('%1$s: %2$s'),
- '' . __('Impacts') . '',
+ __s('%1$s: %2$s'),
+ '' . __s('Impacts') . '',
$job->fields['impactcontent'],
));
$pdf->displayText(sprintf(
- __('%1$s: %2$s'),
- '' . __('Control list') . '',
+ __s('%1$s: %2$s'),
+ '' . __s('Control list') . '',
$job->fields['controlistcontent'],
));
}
@@ -329,25 +328,25 @@ public static function pdfAnalysis(PluginPdfSimplePDF $pdf, Change $job)
public static function pdfPlan(PluginPdfSimplePDF $pdf, Change $job)
{
$pdf->setColumnsSize(100);
- $pdf->displayTitle('' . __('Plans') . '');
+ $pdf->displayTitle('' . __s('Plans') . '');
$pdf->setColumnsSize(10, 90);
$pdf->displayText(sprintf(
- __('%1$s: %2$s'),
- '' . __('Deployment plan') . '',
+ __s('%1$s: %2$s'),
+ '' . __s('Deployment plan') . '',
$job->fields['rolloutplancontent'],
));
$pdf->displayText(sprintf(
- __('%1$s: %2$s'),
- '' . __('Backup plan') . '',
+ __s('%1$s: %2$s'),
+ '' . __s('Backup plan') . '',
$job->fields['backoutplancontent'],
));
$pdf->displayText(sprintf(
- __('%1$s: %2$s'),
- '' . __('Checklist') . '',
+ __s('%1$s: %2$s'),
+ '' . __s('Checklist') . '',
$job->fields['checklistcontent'],
));
}
@@ -355,24 +354,24 @@ public static function pdfPlan(PluginPdfSimplePDF $pdf, Change $job)
public static function pdfStat(PluginPdfSimplePDF $pdf, Change $job)
{
$pdf->setColumnsSize(100);
- $pdf->displayTitle('' . __('Statistics') . '');
+ $pdf->displayTitle('' . __s('Statistics') . '');
- $pdf->displayTitle('' . _n('Date', 'Dates', 2) . '');
+ $pdf->displayTitle('' . _sn('Date', 'Dates', 2) . '');
$pdf->setColumnsSize(50, 50);
- $pdf->displayLine(__('Opening date'), Html::convDateTime($job->fields['date']));
- $pdf->displayLine(__('Time to resolve'), Html::convDateTime($job->fields['time_to_resolve']));
+ $pdf->displayLine(__s('Opening date'), Html::convDateTime($job->fields['date']));
+ $pdf->displayLine(__s('Time to resolve'), Html::convDateTime($job->fields['time_to_resolve']));
if (in_array($job->fields['status'], $job->getSolvedStatusArray())
|| in_array($job->fields['status'], $job->getClosedStatusArray())) {
- $pdf->displayLine(__('Resolution date'), Html::convDateTime($job->fields['solvedate']));
+ $pdf->displayLine(__s('Resolution date'), Html::convDateTime($job->fields['solvedate']));
}
if (in_array($job->fields['status'], $job->getClosedStatusArray())) {
- $pdf->displayLine(__('Closing date'), Html::convDateTime($job->fields['closedate']));
+ $pdf->displayLine(__s('Closing date'), Html::convDateTime($job->fields['closedate']));
}
$pdf->setColumnsSize(100);
- $pdf->displayTitle('' . _n('Time', 'Times', 2) . '');
+ $pdf->displayTitle('' . _sn('Time', 'Times', 2) . '');
$pdf->setColumnsSize(50, 50);
if (isset($job->fields['takeintoaccount_delay_stat']) > 0) {
@@ -380,31 +379,26 @@ public static function pdfStat(PluginPdfSimplePDF $pdf, Change $job)
$accountdelay = Toolbox::stripTags(Html::timestampToString($job->fields['takeintoaccount_delay_stat'], false));
}
$pdf->displayLine(
- __('Take into account'),
- isset($accountdelay) ? $accountdelay : '',
+ __s('Take into account'),
+ $accountdelay ?? '',
);
}
- if (in_array($job->fields['status'], $job->getSolvedStatusArray())
- || in_array($job->fields['status'], $job->getClosedStatusArray())) {
- if ($job->fields['solve_delay_stat'] > 0) {
- $pdf->displayLine(
- __('Resolution'),
- Toolbox::stripTags(Html::timestampToString($job->fields['solve_delay_stat'], false)),
- );
- }
+ if ((in_array($job->fields['status'], $job->getSolvedStatusArray()) || in_array($job->fields['status'], $job->getClosedStatusArray())) && $job->fields['solve_delay_stat'] > 0) {
+ $pdf->displayLine(
+ __s('Resolution'),
+ Toolbox::stripTags(Html::timestampToString($job->fields['solve_delay_stat'], false)),
+ );
}
- if (in_array($job->fields['status'], $job->getClosedStatusArray())) {
- if ($job->fields['close_delay_stat'] > 0) {
- $pdf->displayLine(
- __('Closing'),
- Toolbox::stripTags(Html::timestampToString($job->fields['close_delay_stat'], false)),
- );
- }
+ if (in_array($job->fields['status'], $job->getClosedStatusArray()) && $job->fields['close_delay_stat'] > 0) {
+ $pdf->displayLine(
+ __s('Closing'),
+ Toolbox::stripTags(Html::timestampToString($job->fields['close_delay_stat'], false)),
+ );
}
if ($job->fields['waiting_duration'] > 0) {
$pdf->displayLine(
- __('Pending'),
+ __s('Pending'),
Toolbox::stripTags(Html::timestampToString($job->fields['waiting_duration'], false)),
);
}
@@ -421,7 +415,7 @@ public function defineAllTabsPDF($options = [])
if (Session::haveRight('change', Change::READALL) // for technician
|| Session::haveRight('followup', ITILFollowup::SEEPRIVATE)
|| Session::haveRight('task', TicketTask::SEEPRIVATE)) {
- $onglets['_private_'] = __('Private');
+ $onglets['_private_'] = __s('Private');
}
return $onglets;
diff --git a/inc/change_item.class.php b/inc/change_item.class.php
index daebdde..e6790b7 100644
--- a/inc/change_item.class.php
+++ b/inc/change_item.class.php
@@ -36,7 +36,7 @@ class PluginPdfChange_Item extends PluginPdfCommon
public function __construct(?CommonGLPI $obj = null)
{
- $this->obj = ($obj ? $obj : new Change_Item());
+ $this->obj = ($obj ?: new Change_Item());
}
public static function pdfForChange(PluginPdfSimplePDF $pdf, Change $change)
@@ -52,31 +52,31 @@ public static function pdfForChange(PluginPdfSimplePDF $pdf, Change $change)
return false;
}
- $result = $DB->request(
- 'glpi_changes_items',
- ['SELECT' => 'itemtype',
- 'DISTINCT' => true,
- 'WHERE' => ['changes_id' => $instID],
- 'ORDER' => 'itemtype'],
- );
+ $result = $DB->request([
+ 'FROM' => 'glpi_changes_items',
+ 'SELECT' => 'itemtype',
+ 'DISTINCT' => true,
+ 'WHERE' => ['changes_id' => $instID],
+ 'ORDER' => 'itemtype',
+ ]);
$number = count($result);
$pdf->setColumnsSize(100);
- $title = '' . _n('Item', 'Items', $number) . '';
+ $title = '' . _sn('Item', 'Items', $number) . '';
- if (!$number) {
- $pdf->displayTitle(sprintf(__('%1$s: %2$s'), $title, __('No item to display')));
+ if ($number === 0) {
+ $pdf->displayTitle(sprintf(__s('%1$s: %2$s'), $title, __s('No item to display')));
} else {
- $title = sprintf(__('%1$s: %2$s'), $title, $number);
+ $title = sprintf(__s('%1$s: %2$s'), $title, $number);
$pdf->displayTitle($title);
$pdf->setColumnsSize(20, 20, 26, 17, 17);
$pdf->displayTitle(
- '' . __('Type'),
- __('Name'),
- __('Entity'),
- __('Serial number'),
- __('Inventory number') . '',
+ '' . __s('Type'),
+ __s('Name'),
+ __s('Entity'),
+ __s('Serial number'),
+ __s('Inventory number') . '',
);
$totalnb = 0;
@@ -115,7 +115,7 @@ public static function pdfForChange(PluginPdfSimplePDF $pdf, Change $change)
$query['ORDER'] = ['glpi_entities.completename', $itemtable . '.name'];
- $result_linked = $DB->request($query, '', true);
+ $result_linked = $DB->request($query);
$nb = count($result_linked);
$prem = true;
@@ -127,7 +127,7 @@ public static function pdfForChange(PluginPdfSimplePDF $pdf, Change $change)
if ($prem) {
$typename = $item->getTypeName($nb);
$pdf->displayLine(
- Toolbox::stripTags(sprintf(__('%1$s: %2$s'), $typename, $nb)),
+ Toolbox::stripTags(sprintf(__s('%1$s: %2$s'), $typename, $nb)),
Toolbox::stripTags($name),
Dropdown::getDropdownName('glpi_entities', $data['entity']),
Toolbox::stripTags((string) $data["serial"]),
@@ -150,7 +150,7 @@ public static function pdfForChange(PluginPdfSimplePDF $pdf, Change $change)
}
}
// }
- $pdf->displayLine('' . sprintf(__('%1$s = %2$s') . '', __('Total'), $totalnb));
+ $pdf->displayLine('' . sprintf(__s('%1$s = %2$s') . '', __s('Total'), $totalnb));
}
}
@@ -193,44 +193,53 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item, $tr
break;
}
- $SELECT = '';
- $FROM = '';
+ $SELECT = ['glpi_changes.*', 'glpi_itilcategories.completename AS catname'];
+ $LEFT_JOIN = [
+ 'glpi_changes_items' => [
+ 'FKEY' => ['glpi_changes' => 'id', 'glpi_changes_items' => 'changes_id'],
+ ],
+ 'glpi_changes_groups' => [
+ 'FKEY' => ['glpi_changes' => 'id', 'glpi_changes_groups' => 'changes_id'],
+ ],
+ 'glpi_changes_users' => [
+ 'FKEY' => ['glpi_changes' => 'id', 'glpi_changes_users' => 'changes_id'],
+ ],
+ 'glpi_changes_suppliers' => [
+ 'FKEY' => ['glpi_changes' => 'id', 'glpi_changes_suppliers' => 'changes_id'],
+ ],
+ 'glpi_itilcategories' => [
+ 'FKEY' => ['glpi_changes' => 'itilcategories_id', 'glpi_itilcategories' => 'id'],
+ ],
+ ];
+
if (count($_SESSION['glpiactiveentities']) > 1) {
- $SELECT = ', `glpi_entities`.`completename` AS entityname,
- `glpi_changes`.`entities_id` AS entityID ';
- $FROM = ' LEFT JOIN `glpi_entities`
- ON (`glpi_entities`.`id` = `glpi_changes`.`entities_id`) ';
+ $SELECT[] = 'glpi_entities.completename AS entityname';
+ $SELECT[] = 'glpi_changes.entities_id AS entityID';
+ $LEFT_JOIN['glpi_entities'] = [
+ 'FKEY' => ['glpi_entities' => 'id', 'glpi_changes' => 'entities_id'],
+ ];
}
- $query = "SELECT DISTINCT `glpi_changes`.*,
- `glpi_itilcategories`.`completename` AS catname
- $SELECT
- FROM `glpi_changes`
- LEFT JOIN `glpi_changes_items`
- ON (`glpi_changes`.`id` = `glpi_changes_items`.`changes_id`)
- LEFT JOIN `glpi_changes_groups`
- ON (`glpi_changes`.`id` = `glpi_changes_groups`.`changes_id`)
- LEFT JOIN `glpi_changes_users`
- ON (`glpi_changes`.`id` = `glpi_changes_users`.`changes_id`)
- LEFT JOIN `glpi_changes_suppliers`
- ON (`glpi_changes`.`id` = `glpi_changes_suppliers`.`changes_id`)
- LEFT JOIN `glpi_itilcategories`
- ON (`glpi_changes`.`itilcategories_id` = `glpi_itilcategories`.`id`)
- $FROM
- WHERE $restrict " .
- $dbu->getEntitiesRestrictRequest('AND', 'glpi_changes') . "
- ORDER BY $order
- LIMIT " . intval($_SESSION['glpilist_limit']);
+
+ $query = [
+ 'SELECT' => $SELECT,
+ 'DISTINCT' => true,
+ 'FROM' => 'glpi_changes',
+ 'LEFT JOIN' => $LEFT_JOIN,
+ 'WHERE' => [$restrict] + $dbu->getEntitiesRestrictCriteria('glpi_changes'),
+ 'ORDER' => $order,
+ 'LIMIT' => (int) $_SESSION['glpilist_limit'],
+ ];
$result = $DB->request($query);
$number = count($result);
$pdf->setColumnsSize(100);
$title = '' . Change::getTypeName($number) . '';
- if (!$number) {
- $pdf->displayTitle(sprintf(__('%1$s: %2$s'), $title, __('No item to display')));
+ if ($number === 0) {
+ $pdf->displayTitle(sprintf(__s('%1$s: %2$s'), $title, __s('No item to display')));
} else {
$pdf->displayTitle('' . sprintf(
- _n('Last %d change', 'Last %d changes', $number) . '',
+ _sn('Last %d change', 'Last %d changes', $number) . '',
$number,
));
@@ -241,14 +250,14 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item, $tr
}
$pdf->setColumnsAlign('center');
$col = 'ID ' . $job->fields['id'] . ', ' .
- sprintf(__('%1$s: %2$s'), __('Status'), Change::getStatus($job->fields['status']));
+ sprintf(__s('%1$s: %2$s'), __s('Status'), Change::getStatus($job->fields['status']));
if (count($_SESSION['glpiactiveentities']) > 1) {
if ($job->fields['entities_id'] == 0) {
- $col = sprintf(__('%1$s (%2$s)'), $col, __('Root entity'));
+ $col = sprintf(__s('%1$s (%2$s)'), $col, __s('Root entity'));
} else {
$col = sprintf(
- __('%1$s (%2$s)'),
+ __s('%1$s (%2$s)'),
$col,
Dropdown::getDropdownName('glpi_entities', $job->fields['entities_id']),
);
@@ -259,15 +268,15 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item, $tr
$pdf->setColumnsAlign('left');
$col = '' . sprintf(
- __('Opened on %s') . '',
+ __s('Opened on %s') . '',
Html::convDateTime($job->fields['date']),
);
if ($job->fields['begin_waiting_date']) {
$col = sprintf(
- __('%1$s, %2$s'),
+ __s('%1$s, %2$s'),
$col,
'' . sprintf(
- __('Put on hold on %s') . '',
+ __s('Put on hold on %s') . '',
Html::convDateTime($job->fields['begin_waiting_date']),
),
);
@@ -275,31 +284,31 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item, $tr
if (in_array($job->fields['status'], $job->getSolvedStatusArray())
|| in_array($job->fields['status'], $job->getClosedStatusArray())) {
$col = sprintf(
- __('%1$s, %2$s'),
+ __s('%1$s, %2$s'),
$col,
'' . sprintf(
- __('Solved on %s') . '',
+ __s('Solved on %s') . '',
Html::convDateTime($job->fields['solvedate']),
),
);
}
if (in_array($job->fields['status'], $job->getClosedStatusArray())) {
$col = sprintf(
- __('%1$s, %2$s'),
+ __s('%1$s, %2$s'),
$col,
'' . sprintf(
- __('Closed on %s') . '',
+ __s('Closed on %s') . '',
Html::convDateTime($job->fields['closedate']),
),
);
}
if ($job->fields['time_to_resolve']) {
$col = sprintf(
- __('%1$s, %2$s'),
+ __s('%1$s, %2$s'),
$col,
'' . sprintf(
- __('%1$s: %2$s') . '',
- __('Time to resolve'),
+ __s('%1$s: %2$s') . '',
+ __s('Time to resolve'),
Html::convDateTime($job->fields['time_to_resolve']),
),
);
@@ -307,35 +316,35 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item, $tr
$pdf->displayLine($col);
$col = '' . sprintf(
- __('%1$s: %2$s'),
- __('Priority') . '',
+ __s('%1$s: %2$s'),
+ __s('Priority') . '',
Change::getPriorityName($job->fields['priority']),
);
if ($job->fields['itilcategories_id']) {
$cat = '' . sprintf(
- __('%1$s: %2$s'),
- __('Category') . '',
+ __s('%1$s: %2$s'),
+ __s('Category') . '',
Dropdown::getDropdownName(
'glpi_itilcategories',
$job->fields['itilcategories_id'],
),
);
- $col = sprintf(__('%1$s - %2$s'), $col, $cat);
+ $col = sprintf(__s('%1$s - %2$s'), $col, $cat);
}
$pdf->displayLine($col);
$lastupdate = Html::convDateTime($job->fields['date_mod']);
if ($job->fields['users_id_lastupdater'] > 0) {
$lastupdate = sprintf(
- __('%1$s by %2$s'),
+ __s('%1$s by %2$s'),
$lastupdate,
$dbu->getUserName($job->fields['users_id_lastupdater']),
);
}
$pdf->displayLine('' . sprintf(
- __('%1$s: %2$s'),
- __('Last update') . '',
+ __s('%1$s: %2$s'),
+ __s('Last update') . '',
$lastupdate,
));
@@ -346,28 +355,28 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item, $tr
if (empty($col)) {
$col = $dbu->getUserName($d['users_id']);
} else {
- $col = sprintf(__('%1$s, %2$s'), $col, $dbu->getUserName($d['users_id']));
+ $col = sprintf(__s('%1$s, %2$s'), $col, $dbu->getUserName($d['users_id']));
}
}
}
$grps = $job->getGroups(CommonITILActor::REQUESTER);
if (count($grps)) {
if (empty($col)) {
- $col = sprintf(__('%1$s %2$s'), $col, _n('Group', 'Groups', 2) . ' ');
+ $col = sprintf(__s('%1$s %2$s'), $col, _sn('Group', 'Groups', 2) . ' ');
} else {
- $col = sprintf(__('%1$s - %2$s'), $col, _n('Group', 'Groups', 2) . ' ');
+ $col = sprintf(__s('%1$s - %2$s'), $col, _sn('Group', 'Groups', 2) . ' ');
}
$first = true;
foreach ($grps as $d) {
if ($first) {
$col = sprintf(
- __('%1$s %2$s'),
+ __s('%1$s %2$s'),
$col,
Dropdown::getDropdownName('glpi_groups', $d['groups_id']),
);
} else {
$col = sprintf(
- __('%1$s, %2$s'),
+ __s('%1$s, %2$s'),
$col,
Dropdown::getDropdownName('glpi_groups', $d['groups_id']),
);
@@ -376,7 +385,7 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item, $tr
}
}
if ($col) {
- $texte = '' . sprintf(__('%1$s: %2$s'), __('Requester') . '', '');
+ $texte = '' . sprintf(__s('%1$s: %2$s'), __s('Requester') . '', '');
$pdf->displayText($texte, $col, 1);
}
@@ -387,28 +396,28 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item, $tr
if (empty($col)) {
$col = $dbu->getUserName($d['users_id']);
} else {
- $col = sprintf(__('%1$s, %2$s'), $col, $dbu->getUserName($d['users_id']));
+ $col = sprintf(__s('%1$s, %2$s'), $col, $dbu->getUserName($d['users_id']));
}
}
}
$grps = $job->getGroups(CommonITILActor::ASSIGN);
if (count($grps)) {
if (empty($col)) {
- $col = sprintf(__('%1$s %2$s'), $col, _n('Group', 'Groups', 2) . ' ');
+ $col = sprintf(__s('%1$s %2$s'), $col, _sn('Group', 'Groups', 2) . ' ');
} else {
- $col = sprintf(__('%1$s - %2$s'), $col, _n('Group', 'Groups', 2) . ' ');
+ $col = sprintf(__s('%1$s - %2$s'), $col, _sn('Group', 'Groups', 2) . ' ');
}
$first = true;
foreach ($grps as $d) {
if ($first) {
$col = sprintf(
- __('%1$s %2$s'),
+ __s('%1$s %2$s'),
$col,
Dropdown::getDropdownName('glpi_groups', $d['groups_id']),
);
} else {
$col = sprintf(
- __('%1$s, %2$s'),
+ __s('%1$s, %2$s'),
$col,
Dropdown::getDropdownName('glpi_groups', $d['groups_id']),
);
@@ -417,13 +426,13 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item, $tr
}
}
if ($col) {
- $texte = '' . sprintf(__('%1$s: %2$s') . '', __('Assigned to'), '');
+ $texte = '' . sprintf(__s('%1$s: %2$s') . '', __s('Assigned to'), '');
$pdf->displayText($texte, $col, 1);
}
- $texte = '' . sprintf(__('%1$s: %2$s') . '', __('Associated items'), '');
+ $texte = '' . sprintf(__s('%1$s: %2$s') . '', __s('Associated items'), '');
- $texte = '' . sprintf(__('%1$s: %2$s') . '', __('Title'), '');
+ $texte = '' . sprintf(__s('%1$s: %2$s') . '', __s('Title'), '');
$pdf->displayText($texte, $job->fields['name'], 1);
}
}
diff --git a/inc/change_problem.class.php b/inc/change_problem.class.php
index 5bb0d1a..16eca1b 100644
--- a/inc/change_problem.class.php
+++ b/inc/change_problem.class.php
@@ -36,7 +36,7 @@ class PluginPdfChange_Problem extends PluginPdfCommon
public function __construct(?CommonGLPI $obj = null)
{
- $this->obj = ($obj ? $obj : new Change_Problem());
+ $this->obj = ($obj ?: new Change_Problem());
}
public static function pdfForChange(PluginPdfSimplePDF $pdf, Change $change)
@@ -52,30 +52,27 @@ public static function pdfForChange(PluginPdfSimplePDF $pdf, Change $change)
return false;
}
- $result = $DB->request(
- 'glpi_changes_problems',
- ['SELECT' => 'glpi_changes_problems.id',
- 'DISTINCT' => true,
- 'FIELDS' => ['glpi_problems.*', 'name'],
- 'LEFT JOIN' => ['glpi_problems'
- => ['FKEY' => ['glpi_changes_problems' => 'problems_id',
- 'glpi_problems' => 'id']]],
- 'WHERE' => ['changes_id' => $ID],
- 'ORDER' => 'name'],
- );
+ $result = $DB->request([
+ 'SELECT' => ['glpi_changes_problems.id'],
+ 'DISTINCT' => true,
+ 'FROM' => 'glpi_changes_problems',
+ 'FIELDS' => ['glpi_problems.*', 'name'],
+ 'LEFT JOIN' => ['glpi_problems'
+ => ['FKEY' => ['glpi_changes_problems' => 'problems_id',
+ 'glpi_problems' => 'id']]],
+ 'WHERE' => ['changes_id' => $ID],
+ 'ORDER' => 'name',
+ ]);
$number = count($result);
- $problems = [];
- $used = [];
-
$pdf->setColumnsSize(100);
$title = '' . Problem::getTypeName($number) . '';
- if (!$number) {
- $pdf->displayTitle(sprintf(__('%1$s: %2$s'), $title, __('No item to display')));
+ if ($number === 0) {
+ $pdf->displayTitle(sprintf(__s('%1$s: %2$s'), $title, __s('No item to display')));
} else {
$pdf->displayTitle('' . sprintf(
- _n('Last %d problem', 'Last %d problems', $number) . '',
+ _sn('Last %d problem', 'Last %d problems', $number) . '',
$number,
));
@@ -87,17 +84,17 @@ public static function pdfForChange(PluginPdfSimplePDF $pdf, Change $change)
$pdf->setColumnsAlign('center');
$col = 'ID ' . $job->fields['id'] . ', ' .
sprintf(
- __('%1$s: %2$s'),
- __('Status'),
+ __s('%1$s: %2$s'),
+ __s('Status'),
Problem::getStatus($job->fields['status']),
);
if (count($_SESSION['glpiactiveentities']) > 1) {
if ($job->fields['entities_id'] == 0) {
- $col = sprintf(__('%1$s (%2$s)'), $col, __('Root entity'));
+ $col = sprintf(__s('%1$s (%2$s)'), $col, __s('Root entity'));
} else {
$col = sprintf(
- __('%1$s (%2$s)'),
+ __s('%1$s (%2$s)'),
$col,
Dropdown::getDropdownName(
'glpi_entities',
@@ -111,15 +108,15 @@ public static function pdfForChange(PluginPdfSimplePDF $pdf, Change $change)
$pdf->setColumnsAlign('left');
$col = '' . sprintf(
- __('Opened on %s') . '',
+ __s('Opened on %s') . '',
Html::convDateTime($job->fields['date']),
);
if ($job->fields['begin_waiting_date']) {
$col = sprintf(
- __('%1$s, %2$s'),
+ __s('%1$s, %2$s'),
$col,
'' . sprintf(
- __('Put on hold on %s') . '',
+ __s('Put on hold on %s') . '',
Html::convDateTime($job->fields['begin_waiting_date']),
),
);
@@ -127,31 +124,31 @@ public static function pdfForChange(PluginPdfSimplePDF $pdf, Change $change)
if (in_array($job->fields['status'], $job->getSolvedStatusArray())
|| in_array($job->fields['status'], $job->getClosedStatusArray())) {
$col = sprintf(
- __('%1$s, %2$s'),
+ __s('%1$s, %2$s'),
$col,
'' . sprintf(
- __('Solved on %s') . '',
+ __s('Solved on %s') . '',
Html::convDateTime($job->fields['solvedate']),
),
);
}
if (in_array($job->fields['status'], $job->getClosedStatusArray())) {
$col = sprintf(
- __('%1$s, %2$s'),
+ __s('%1$s, %2$s'),
$col,
'' . sprintf(
- __('Closed on %s') . '',
+ __s('Closed on %s') . '',
Html::convDateTime($job->fields['closedate']),
),
);
}
if ($job->fields['time_to_resolve']) {
$col = sprintf(
- __('%1$s, %2$s'),
+ __s('%1$s, %2$s'),
$col,
'' . sprintf(
- __('%1$s: %2$s') . '',
- __('Time to resolve'),
+ __s('%1$s: %2$s') . '',
+ __s('Time to resolve'),
Html::convDateTime($job->fields['time_to_resolve']),
),
);
@@ -161,29 +158,29 @@ public static function pdfForChange(PluginPdfSimplePDF $pdf, Change $change)
$lastupdate = Html::convDateTime($job->fields['date_mod']);
if ($job->fields['users_id_lastupdater'] > 0) {
$lastupdate = sprintf(
- __('%1$s by %2$s'),
+ __s('%1$s by %2$s'),
$lastupdate,
$dbu->getUserName($job->fields['users_id_lastupdater']),
);
}
$pdf->displayLine('' . sprintf(
- __('%1$s: %2$s'),
- __('Last update') . '',
+ __s('%1$s: %2$s'),
+ __s('Last update') . '',
$lastupdate,
));
$pdf->displayLine('' . sprintf(
- __('%1$s: %2$s'),
- __('Priority') . '',
+ __s('%1$s: %2$s'),
+ __s('Priority') . '',
Ticket::getPriorityName($job->fields['priority']),
));
if ($job->fields['itilcategories_id']) {
$pdf->displayLine(
'' . sprintf(
- __('%1$s: %2$s'),
- __('Category') . '',
+ __s('%1$s: %2$s'),
+ __s('Category') . '',
Dropdown::getDropdownName(
'glpi_itilcategories',
$job->fields['itilcategories_id'],
@@ -199,28 +196,28 @@ public static function pdfForChange(PluginPdfSimplePDF $pdf, Change $change)
if (empty($col)) {
$col = $dbu->getUserName($d['users_id']);
} else {
- $col = sprintf(__('%1$s, %2$s'), $col, $dbu->getUserName($d['users_id']));
+ $col = sprintf(__s('%1$s, %2$s'), $col, $dbu->getUserName($d['users_id']));
}
}
}
$grps = $job->getGroups(CommonITILActor::REQUESTER);
if (count($grps)) {
if (empty($col)) {
- $col = sprintf(__('%1$s %2$s'), $col, _n('Group', 'Groups', 2) . ' ');
+ $col = sprintf(__s('%1$s %2$s'), $col, _sn('Group', 'Groups', 2) . ' ');
} else {
- $col = sprintf(__('%1$s - %2$s'), $col, _n('Group', 'Groups', 2) . ' ');
+ $col = sprintf(__s('%1$s - %2$s'), $col, _sn('Group', 'Groups', 2) . ' ');
}
$first = true;
foreach ($grps as $d) {
if ($first) {
$col = sprintf(
- __('%1$s %2$s'),
+ __s('%1$s %2$s'),
$col,
Dropdown::getDropdownName('glpi_groups', $d['groups_id']),
);
} else {
$col = sprintf(
- __('%1$s, %2$s'),
+ __s('%1$s, %2$s'),
$col,
Dropdown::getDropdownName('glpi_groups', $d['groups_id']),
);
@@ -229,7 +226,7 @@ public static function pdfForChange(PluginPdfSimplePDF $pdf, Change $change)
}
}
if ($col) {
- $texte = '' . sprintf(__('%1$s: %2$s'), __('Requester') . '', '');
+ $texte = '' . sprintf(__s('%1$s: %2$s'), __s('Requester') . '', '');
$pdf->displayText($texte, $col, 1);
}
@@ -240,28 +237,28 @@ public static function pdfForChange(PluginPdfSimplePDF $pdf, Change $change)
if (empty($col)) {
$col = $dbu->getUserName($d['users_id']);
} else {
- $col = sprintf(__('%1$s, %2$s'), $col, $dbu->getUserName($d['users_id']));
+ $col = sprintf(__s('%1$s, %2$s'), $col, $dbu->getUserName($d['users_id']));
}
}
}
$grps = $job->getGroups(CommonITILActor::ASSIGN);
if (count($grps)) {
if (empty($col)) {
- $col = sprintf(__('%1$s %2$s'), $col, _n('Group', 'Groups', 2) . ' ');
+ $col = sprintf(__s('%1$s %2$s'), $col, _sn('Group', 'Groups', 2) . ' ');
} else {
- $col = sprintf(__('%1$s - %2$s'), $col, _n('Group', 'Groups', 2) . ' ');
+ $col = sprintf(__s('%1$s - %2$s'), $col, _sn('Group', 'Groups', 2) . ' ');
}
$first = true;
foreach ($grps as $d) {
if ($first) {
$col = sprintf(
- __('%1$s %2$s'),
+ __s('%1$s %2$s'),
$col,
Dropdown::getDropdownName('glpi_groups', $d['groups_id']),
);
} else {
$col = sprintf(
- __('%1$s, %2$s'),
+ __s('%1$s, %2$s'),
$col,
Dropdown::getDropdownName('glpi_groups', $d['groups_id']),
);
@@ -270,11 +267,11 @@ public static function pdfForChange(PluginPdfSimplePDF $pdf, Change $change)
}
}
if ($col) {
- $texte = '' . sprintf(__('%1$s: %2$s') . '', ('Assigned to'), '');
+ $texte = '' . sprintf(__s('%1$s: %2$s') . '', ('Assigned to'), '');
$pdf->displayText($texte, $col, 1);
}
- $texte = '' . sprintf(__('%1$s: %2$s') . '', ('Title'), '');
+ $texte = '' . sprintf(__s('%1$s: %2$s') . '', ('Title'), '');
$pdf->displayText($texte, $job->fields['name'], 1);
}
}
@@ -294,29 +291,26 @@ public static function pdfForProblem(PluginPdfSimplePDF $pdf, Problem $problem)
return false;
}
- $result = $DB->request(
- 'glpi_changes_problems',
- ['SELECT' => 'glpi_changes_problems.id',
- 'DISTINCT' => true,
- 'FIELDS' => ['glpi_changes.*', 'name'],
- 'LEFT JOIN' => ['glpi_changes'
- => ['FKEY' => ['glpi_changes_problems' => 'changes_id',
- 'glpi_changes' => 'id']]],
- 'WHERE' => ['problems_id' => $ID],
- 'ORDER' => 'name'],
- );
+ $result = $DB->request([
+ 'SELECT' => ['glpi_changes_problems.id'],
+ 'DISTINCT' => true,
+ 'FROM' => 'glpi_changes_problems',
+ 'FIELDS' => ['glpi_changes.*', 'name'],
+ 'LEFT JOIN' => ['glpi_changes'
+ => ['FKEY' => ['glpi_changes_problems' => 'changes_id',
+ 'glpi_changes' => 'id']]],
+ 'WHERE' => ['problems_id' => $ID],
+ 'ORDER' => 'name',
+ ]);
$number = count($result);
- $problems = [];
- $used = [];
-
$pdf->setColumnsSize(100);
$title = '' . Change::getTypeName($number) . '';
- if (!$number) {
- $pdf->displayTitle(sprintf(__('%1$s: %2$s'), $title, __('No item to display')));
+ if ($number === 0) {
+ $pdf->displayTitle(sprintf(__s('%1$s: %2$s'), $title, __s('No item to display')));
} else {
$pdf->displayTitle('' . sprintf(
- _n('Last %d change', 'Last %d changes', $number) . '',
+ _sn('Last %d change', 'Last %d changes', $number) . '',
$number,
));
@@ -328,17 +322,17 @@ public static function pdfForProblem(PluginPdfSimplePDF $pdf, Problem $problem)
$pdf->setColumnsAlign('center');
$col = 'ID ' . $job->fields['id'] . ', ' .
sprintf(
- __('%1$s: %2$s'),
- __('Status'),
+ __s('%1$s: %2$s'),
+ __s('Status'),
Problem::getStatus($job->fields['status']),
);
if (count($_SESSION['glpiactiveentities']) > 1) {
if ($job->fields['entities_id'] == 0) {
- $col = sprintf(__('%1$s (%2$s)'), $col, __('Root entity'));
+ $col = sprintf(__s('%1$s (%2$s)'), $col, __s('Root entity'));
} else {
$col = sprintf(
- __('%1$s (%2$s)'),
+ __s('%1$s (%2$s)'),
$col,
Dropdown::getDropdownName(
'glpi_entities',
@@ -352,37 +346,37 @@ public static function pdfForProblem(PluginPdfSimplePDF $pdf, Problem $problem)
$pdf->setColumnsAlign('left');
$col = '' . sprintf(
- __('Opened on %s') . '',
+ __s('Opened on %s') . '',
Html::convDateTime($job->fields['date']),
);
if (in_array($job->fields['status'], $job->getSolvedStatusArray())
|| in_array($job->fields['status'], $job->getClosedStatusArray())) {
$col = sprintf(
- __('%1$s, %2$s'),
+ __s('%1$s, %2$s'),
$col,
'' . sprintf(
- __('Solved on %s') . '',
+ __s('Solved on %s') . '',
Html::convDateTime($job->fields['solvedate']),
),
);
}
if (in_array($job->fields['status'], $job->getClosedStatusArray())) {
$col = sprintf(
- __('%1$s, %2$s'),
+ __s('%1$s, %2$s'),
$col,
'' . sprintf(
- __('Closed on %s') . '',
+ __s('Closed on %s') . '',
Html::convDateTime($job->fields['closedate']),
),
);
}
if ($job->fields['time_to_resolve']) {
$col = sprintf(
- __('%1$s, %2$s'),
+ __s('%1$s, %2$s'),
$col,
'' . sprintf(
- __('%1$s: %2$s') . '',
- __('Time to resolve'),
+ __s('%1$s: %2$s') . '',
+ __s('Time to resolve'),
Html::convDateTime($job->fields['time_to_resolve']),
),
);
@@ -392,28 +386,28 @@ public static function pdfForProblem(PluginPdfSimplePDF $pdf, Problem $problem)
$lastupdate = Html::convDateTime($job->fields['date_mod']);
if ($job->fields['users_id_lastupdater'] > 0) {
$lastupdate = sprintf(
- __('%1$s by %2$s'),
+ __s('%1$s by %2$s'),
$lastupdate,
$dbu->getUserName($job->fields['users_id_lastupdater']),
);
}
$pdf->displayLine('' . sprintf(
- __('%1$s: %2$s'),
- __('Last update') . '',
+ __s('%1$s: %2$s'),
+ __s('Last update') . '',
$lastupdate,
));
$pdf->displayLine('' . sprintf(
- __('%1$s: %2$s'),
- __('Priority') . '',
+ __s('%1$s: %2$s'),
+ __s('Priority') . '',
Ticket::getPriorityName($job->fields['priority']),
));
if ($job->fields['itilcategories_id']) {
$pdf->displayLine(
'' . sprintf(
- __('%1$s: %2$s'),
- __('Category') . '',
+ __s('%1$s: %2$s'),
+ __s('Category') . '',
Dropdown::getDropdownName(
'glpi_itilcategories',
$job->fields['itilcategories_id'],
@@ -429,28 +423,28 @@ public static function pdfForProblem(PluginPdfSimplePDF $pdf, Problem $problem)
if (empty($col)) {
$col = $dbu->getUserName($d['users_id']);
} else {
- $col = sprintf(__('%1$s, %2$s'), $col, $dbu->getUserName($d['users_id']));
+ $col = sprintf(__s('%1$s, %2$s'), $col, $dbu->getUserName($d['users_id']));
}
}
}
$grps = $job->getGroups(CommonITILActor::REQUESTER);
if (count($grps)) {
if (empty($col)) {
- $col = sprintf(__('%1$s %2$s'), $col, _n('Group', 'Groups', 2) . ' ');
+ $col = sprintf(__s('%1$s %2$s'), $col, _sn('Group', 'Groups', 2) . ' ');
} else {
- $col = sprintf(__('%1$s - %2$s'), $col, _n('Group', 'Groups', 2) . ' ');
+ $col = sprintf(__s('%1$s - %2$s'), $col, _sn('Group', 'Groups', 2) . ' ');
}
$first = true;
foreach ($grps as $d) {
if ($first) {
$col = sprintf(
- __('%1$s %2$s'),
+ __s('%1$s %2$s'),
$col,
Dropdown::getDropdownName('glpi_groups', $d['groups_id']),
);
} else {
$col = sprintf(
- __('%1$s, %2$s'),
+ __s('%1$s, %2$s'),
$col,
Dropdown::getDropdownName('glpi_groups', $d['groups_id']),
);
@@ -459,7 +453,7 @@ public static function pdfForProblem(PluginPdfSimplePDF $pdf, Problem $problem)
}
}
if ($col) {
- $texte = '' . sprintf(__('%1$s: %2$s'), __('Requester') . '', '');
+ $texte = '' . sprintf(__s('%1$s: %2$s'), __s('Requester') . '', '');
$pdf->displayText($texte, $col, 1);
}
@@ -470,28 +464,28 @@ public static function pdfForProblem(PluginPdfSimplePDF $pdf, Problem $problem)
if (empty($col)) {
$col = $dbu->getUserName($d['users_id']);
} else {
- $col = sprintf(__('%1$s, %2$s'), $col, $dbu->getUserName($d['users_id']));
+ $col = sprintf(__s('%1$s, %2$s'), $col, $dbu->getUserName($d['users_id']));
}
}
}
$grps = $job->getGroups(CommonITILActor::ASSIGN);
if (count($grps)) {
if (empty($col)) {
- $col = sprintf(__('%1$s %2$s'), $col, _n('Group', 'Groups', 2) . ' ');
+ $col = sprintf(__s('%1$s %2$s'), $col, _sn('Group', 'Groups', 2) . ' ');
} else {
- $col = sprintf(__('%1$s - %2$s'), $col, _n('Group', 'Groups', 2) . ' ');
+ $col = sprintf(__s('%1$s - %2$s'), $col, _sn('Group', 'Groups', 2) . ' ');
}
$first = true;
foreach ($grps as $d) {
if ($first) {
$col = sprintf(
- __('%1$s %2$s'),
+ __s('%1$s %2$s'),
$col,
Dropdown::getDropdownName('glpi_groups', $d['groups_id']),
);
} else {
$col = sprintf(
- __('%1$s, %2$s'),
+ __s('%1$s, %2$s'),
$col,
Dropdown::getDropdownName('glpi_groups', $d['groups_id']),
);
@@ -500,11 +494,11 @@ public static function pdfForProblem(PluginPdfSimplePDF $pdf, Problem $problem)
}
}
if ($col) {
- $texte = '' . sprintf(__('%1$s: %2$s') . '', __('Assigned to'), '');
+ $texte = '' . sprintf(__s('%1$s: %2$s') . '', __s('Assigned to'), '');
$pdf->displayText($texte, $col, 1);
}
- $texte = '' . sprintf(__('%1$s: %2$s') . '', ('Title'), '');
+ $texte = '' . sprintf(__s('%1$s: %2$s') . '', ('Title'), '');
$pdf->displayText($texte, $job->fields['name'], 1);
}
}
diff --git a/inc/change_ticket.class.php b/inc/change_ticket.class.php
index bdf9537..9712793 100644
--- a/inc/change_ticket.class.php
+++ b/inc/change_ticket.class.php
@@ -36,7 +36,7 @@ class PluginPdfChange_Ticket extends PluginPdfCommon
public function __construct(?CommonGLPI $obj = null)
{
- $this->obj = ($obj ? $obj : new Change_Ticket());
+ $this->obj = ($obj ?: new Change_Ticket());
}
public static function pdfForChange(PluginPdfSimplePDF $pdf, Change $change)
@@ -52,27 +52,27 @@ public static function pdfForChange(PluginPdfSimplePDF $pdf, Change $change)
return false;
}
- $result = $DB->request(
- 'glpi_changes_tickets',
- ['SELECT' => 'glpi_changes_tickets.id',
- 'DISTINCT' => true,
- 'FIELDS' => ['glpi_tickets.*', 'name'],
- 'LEFT JOIN' => ['glpi_tickets'
- => ['FKEY' => ['glpi_changes_tickets' => 'tickets_id',
- 'glpi_tickets' => 'id']]],
- 'WHERE' => ['changes_id' => $ID],
- 'ORDER' => 'name'],
- );
+ $result = $DB->request([
+ 'SELECT' => ['glpi_changes_tickets.id'],
+ 'DISTINCT' => true,
+ 'FROM' => 'glpi_changes_tickets',
+ 'FIELDS' => ['glpi_tickets.*', 'name'],
+ 'LEFT JOIN' => ['glpi_tickets'
+ => ['FKEY' => ['glpi_changes_tickets' => 'tickets_id',
+ 'glpi_tickets' => 'id']]],
+ 'WHERE' => ['changes_id' => $ID],
+ 'ORDER' => 'name',
+ ]);
$number = count($result);
$pdf->setColumnsSize(100);
$title = '' . Ticket::getTypeName($number) . '';
- if (!$number) {
- $pdf->displayTitle(sprintf(__('%1$s: %2$s'), $title, __('No item to display')));
+ if ($number === 0) {
+ $pdf->displayTitle(sprintf(__s('%1$s: %2$s'), $title, __s('No item to display')));
} else {
$pdf->displayTitle('' . sprintf(
- _n('Last %d ticket', 'Last %d tickets', $number) . '',
+ _sn('Last %d ticket', 'Last %d tickets', $number) . '',
$number,
));
$pdf->displayTitle($title);
@@ -85,17 +85,17 @@ public static function pdfForChange(PluginPdfSimplePDF $pdf, Change $change)
$pdf->setColumnsAlign('center');
$col = 'ID ' . $job->fields['id'] . ', ' .
sprintf(
- __('%1$s: %2$s'),
- __('Status'),
+ __s('%1$s: %2$s'),
+ __s('Status'),
Ticket::getStatus($job->fields['status']),
);
if (count($_SESSION['glpiactiveentities']) > 1) {
if ($job->fields['entities_id'] == 0) {
- $col = sprintf(__('%1$s (%2$s)'), $col, __('Root entity'));
+ $col = sprintf(__s('%1$s (%2$s)'), $col, __s('Root entity'));
} else {
$col = sprintf(
- __('%1$s (%2$s)'),
+ __s('%1$s (%2$s)'),
$col,
Dropdown::getDropdownName(
'glpi_entities',
@@ -109,15 +109,15 @@ public static function pdfForChange(PluginPdfSimplePDF $pdf, Change $change)
$pdf->setColumnsAlign('left');
$col = '' . sprintf(
- __('Opened on %s') . '',
+ __s('Opened on %s') . '',
Html::convDateTime($job->fields['date']),
);
if ($job->fields['begin_waiting_date']) {
$col = sprintf(
- __('%1$s, %2$s'),
+ __s('%1$s, %2$s'),
$col,
'' . sprintf(
- __('Put on hold on %s') . '',
+ __s('Put on hold on %s') . '',
Html::convDateTime($job->fields['begin_waiting_date']),
),
);
@@ -125,31 +125,31 @@ public static function pdfForChange(PluginPdfSimplePDF $pdf, Change $change)
if (in_array($job->fields['status'], $job->getSolvedStatusArray())
|| in_array($job->fields['status'], $job->getClosedStatusArray())) {
$col = sprintf(
- __('%1$s, %2$s'),
+ __s('%1$s, %2$s'),
$col,
'' . sprintf(
- __('Solved on %s') . '',
+ __s('Solved on %s') . '',
Html::convDateTime($job->fields['solvedate']),
),
);
}
if (in_array($job->fields['status'], $job->getClosedStatusArray())) {
$col = sprintf(
- __('%1$s, %2$s'),
+ __s('%1$s, %2$s'),
$col,
'' . sprintf(
- __('Closed on %s') . '',
+ __s('Closed on %s') . '',
Html::convDateTime($job->fields['closedate']),
),
);
}
if ($job->fields['time_to_resolve']) {
$col = sprintf(
- __('%1$s, %2$s'),
+ __s('%1$s, %2$s'),
$col,
'' . sprintf(
- __('%1$s: %2$s') . '',
- __('Time to resolve'),
+ __s('%1$s: %2$s') . '',
+ __s('Time to resolve'),
Html::convDateTime($job->fields['time_to_resolve']),
),
);
@@ -159,29 +159,29 @@ public static function pdfForChange(PluginPdfSimplePDF $pdf, Change $change)
$lastupdate = Html::convDateTime($job->fields['date_mod']);
if ($job->fields['users_id_lastupdater'] > 0) {
$lastupdate = sprintf(
- __('%1$s by %2$s'),
+ __s('%1$s by %2$s'),
$lastupdate,
$dbu->getUserName($job->fields['users_id_lastupdater']),
);
}
$pdf->displayLine('' . sprintf(
- __('%1$s: %2$s'),
- __('Last update') . '',
+ __s('%1$s: %2$s'),
+ __s('Last update') . '',
$lastupdate,
));
$pdf->displayLine('' . sprintf(
- __('%1$s: %2$s'),
- __('Priority') . '',
+ __s('%1$s: %2$s'),
+ __s('Priority') . '',
Ticket::getPriorityName($job->fields['priority']),
));
if ($job->fields['itilcategories_id']) {
$pdf->displayLine(
'' . sprintf(
- __('%1$s: %2$s'),
- __('Category') . '',
+ __s('%1$s: %2$s'),
+ __s('Category') . '',
Dropdown::getDropdownName(
'glpi_itilcategories',
$job->fields['itilcategories_id'],
@@ -197,28 +197,28 @@ public static function pdfForChange(PluginPdfSimplePDF $pdf, Change $change)
if (empty($col)) {
$col = $dbu->getUserName($d['users_id']);
} else {
- $col = sprintf(__('%1$s, %2$s'), $col, $dbu->getUserName($d['users_id']));
+ $col = sprintf(__s('%1$s, %2$s'), $col, $dbu->getUserName($d['users_id']));
}
}
}
$grps = $job->getGroups(CommonITILActor::REQUESTER);
if (count($grps)) {
if (empty($col)) {
- $col = sprintf(__('%1$s %2$s'), $col, _n('Group', 'Groups', 2) . ' ');
+ $col = sprintf(__s('%1$s %2$s'), $col, _sn('Group', 'Groups', 2) . ' ');
} else {
- $col = sprintf(__('%1$s - %2$s'), $col, _n('Group', 'Groups', 2) . ' ');
+ $col = sprintf(__s('%1$s - %2$s'), $col, _sn('Group', 'Groups', 2) . ' ');
}
$first = true;
foreach ($grps as $d) {
if ($first) {
$col = sprintf(
- __('%1$s %2$s'),
+ __s('%1$s %2$s'),
$col,
Dropdown::getDropdownName('glpi_groups', $d['groups_id']),
);
} else {
$col = sprintf(
- __('%1$s, %2$s'),
+ __s('%1$s, %2$s'),
$col,
Dropdown::getDropdownName('glpi_groups', $d['groups_id']),
);
@@ -227,7 +227,7 @@ public static function pdfForChange(PluginPdfSimplePDF $pdf, Change $change)
}
}
if ($col) {
- $texte = '' . sprintf(__('%1$s: %2$s'), __('Requester') . '', '');
+ $texte = '' . sprintf(__s('%1$s: %2$s'), __s('Requester') . '', '');
$pdf->displayText($texte, $col, 1);
}
@@ -238,28 +238,28 @@ public static function pdfForChange(PluginPdfSimplePDF $pdf, Change $change)
if (empty($col)) {
$col = $dbu->getUserName($d['users_id']);
} else {
- $col = sprintf(__('%1$s, %2$s'), $col, $dbu->getUserName($d['users_id']));
+ $col = sprintf(__s('%1$s, %2$s'), $col, $dbu->getUserName($d['users_id']));
}
}
}
$grps = $job->getGroups(CommonITILActor::ASSIGN);
if (count($grps)) {
if (empty($col)) {
- $col = sprintf(__('%1$s %2$s'), $col, _n('Group', 'Groups', 2) . ' ');
+ $col = sprintf(__s('%1$s %2$s'), $col, _sn('Group', 'Groups', 2) . ' ');
} else {
- $col = sprintf(__('%1$s - %2$s'), $col, _n('Group', 'Groups', 2) . ' ');
+ $col = sprintf(__s('%1$s - %2$s'), $col, _sn('Group', 'Groups', 2) . ' ');
}
$first = true;
foreach ($grps as $d) {
if ($first) {
$col = sprintf(
- __('%1$s %2$s'),
+ __s('%1$s %2$s'),
$col,
Dropdown::getDropdownName('glpi_groups', $d['groups_id']),
);
} else {
$col = sprintf(
- __('%1$s, %2$s'),
+ __s('%1$s, %2$s'),
$col,
Dropdown::getDropdownName('glpi_groups', $d['groups_id']),
);
@@ -268,28 +268,28 @@ public static function pdfForChange(PluginPdfSimplePDF $pdf, Change $change)
}
}
if ($col) {
- $texte = '' . sprintf(__('%1$s: %2$s') . '', __('Assigned to'), '');
+ $texte = '' . sprintf(__s('%1$s: %2$s') . '', __s('Assigned to'), '');
$pdf->displayText($texte, $col, 1);
}
$first = true;
$listitems = $texteitem = '';
- foreach ($DB->request(
- 'glpi_items_tickets',
- ['WHERE' => ['tickets_id' => $job->fields['id']]],
- ) as $data) {
+ foreach ($DB->request([
+ 'FROM' => 'glpi_items_tickets',
+ 'WHERE' => ['tickets_id' => $job->fields['id']],
+ ]) as $data) {
if (!($item = $dbu->getItemForItemtype($data['itemtype']))) {
continue;
}
if ($first) {
$texteitem = '' . sprintf(
- __('%1$s: %2$s') . '',
- _n('Associated items', 'Associated items', 2),
+ __s('%1$s: %2$s') . '',
+ _sn('Associated items', 'Associated items', 2),
'' . '
',
);
}
$listitems .= sprintf(
- __('%1$s - %2$s'),
+ __s('%1$s - %2$s'),
$item->getTypeName(1),
Dropdown::getDropdownName(
getTableForItemType($data['itemtype']),
@@ -302,7 +302,7 @@ public static function pdfForChange(PluginPdfSimplePDF $pdf, Change $change)
$pdf->displayText($texteitem, $listitems);
}
- $texte = '' . sprintf(__('%1$s: %2$s') . '', ('Title'), '');
+ $texte = '' . sprintf(__s('%1$s: %2$s') . '', ('Title'), '');
$pdf->displayText($texte, $job->fields['name'], 1);
}
}
@@ -322,26 +322,26 @@ public static function pdfForTicket(PluginPdfSimplePDF $pdf, Ticket $ticket)
return false;
}
- $result = $DB->request(
- 'glpi_changes_tickets',
- ['SELECT' => 'glpi_changes_tickets.id',
- 'DISTINCT' => true,
- 'FIELDS' => ['glpi_changes.*', 'name'],
- 'LEFT JOIN' => ['glpi_changes'
- => ['FKEY' => ['glpi_changes_tickets' => 'changes_id',
- 'glpi_changes' => 'id']]],
- 'WHERE' => ['tickets_id' => $ID],
- 'ORDER' => 'name'],
- );
+ $result = $DB->request([
+ 'SELECT' => ['glpi_changes_tickets.id'],
+ 'DISTINCT' => true,
+ 'FROM' => 'glpi_changes_tickets',
+ 'FIELDS' => ['glpi_changes.*', 'name'],
+ 'LEFT JOIN' => ['glpi_changes'
+ => ['FKEY' => ['glpi_changes_tickets' => 'changes_id',
+ 'glpi_changes' => 'id']]],
+ 'WHERE' => ['tickets_id' => $ID],
+ 'ORDER' => 'name',
+ ]);
$number = count($result);
$pdf->setColumnsSize(100);
$title = '' . Change::getTypeName($number) . '';
- if (!$number) {
- $pdf->displayTitle(sprintf(__('%1$s: %2$s'), $title, __('No item to display')));
+ if ($number === 0) {
+ $pdf->displayTitle(sprintf(__s('%1$s: %2$s'), $title, __s('No item to display')));
} else {
$pdf->displayTitle('' . sprintf(
- _n('Last %d change', 'Last %d changes', $number) . '',
+ _sn('Last %d change', 'Last %d changes', $number) . '',
$number,
));
@@ -353,17 +353,17 @@ public static function pdfForTicket(PluginPdfSimplePDF $pdf, Ticket $ticket)
$pdf->setColumnsAlign('center');
$col = 'ID ' . $job->fields['id'] . ', ' .
sprintf(
- __('%1$s: %2$s'),
- __('Status'),
+ __s('%1$s: %2$s'),
+ __s('Status'),
Problem::getStatus($job->fields['status']),
);
if (count($_SESSION['glpiactiveentities']) > 1) {
if ($job->fields['entities_id'] == 0) {
- $col = sprintf(__('%1$s (%2$s)'), $col, __('Root entity'));
+ $col = sprintf(__s('%1$s (%2$s)'), $col, __s('Root entity'));
} else {
$col = sprintf(
- __('%1$s (%2$s)'),
+ __s('%1$s (%2$s)'),
$col,
Dropdown::getDropdownName(
'glpi_entities',
@@ -377,37 +377,37 @@ public static function pdfForTicket(PluginPdfSimplePDF $pdf, Ticket $ticket)
$pdf->setColumnsAlign('left');
$col = '' . sprintf(
- __('Opened on %s') . '',
+ __s('Opened on %s') . '',
Html::convDateTime($job->fields['date']),
);
if (in_array($job->fields['status'], $job->getSolvedStatusArray())
|| in_array($job->fields['status'], $job->getClosedStatusArray())) {
$col = sprintf(
- __('%1$s, %2$s'),
+ __s('%1$s, %2$s'),
$col,
'' . sprintf(
- __('Solved on %s') . '',
+ __s('Solved on %s') . '',
Html::convDateTime($job->fields['solvedate']),
),
);
}
if (in_array($job->fields['status'], $job->getClosedStatusArray())) {
$col = sprintf(
- __('%1$s, %2$s'),
+ __s('%1$s, %2$s'),
$col,
'' . sprintf(
- __('Closed on %s') . '',
+ __s('Closed on %s') . '',
Html::convDateTime($job->fields['closedate']),
),
);
}
if ($job->fields['time_to_resolve']) {
$col = sprintf(
- __('%1$s, %2$s'),
+ __s('%1$s, %2$s'),
$col,
'' . sprintf(
- __('%1$s: %2$s') . '',
- __('Time to resolve'),
+ __s('%1$s: %2$s') . '',
+ __s('Time to resolve'),
Html::convDateTime($job->fields['time_to_resolve']),
),
);
@@ -417,28 +417,28 @@ public static function pdfForTicket(PluginPdfSimplePDF $pdf, Ticket $ticket)
$lastupdate = Html::convDateTime($job->fields['date_mod']);
if ($job->fields['users_id_lastupdater'] > 0) {
$lastupdate = sprintf(
- __('%1$s by %2$s'),
+ __s('%1$s by %2$s'),
$lastupdate,
$dbu->getUserName($job->fields['users_id_lastupdater']),
);
}
$pdf->displayLine('' . sprintf(
- __('%1$s: %2$s'),
- __('Last update') . '',
+ __s('%1$s: %2$s'),
+ __s('Last update') . '',
$lastupdate,
));
$pdf->displayLine('' . sprintf(
- __('%1$s: %2$s'),
- __('Priority') . '',
+ __s('%1$s: %2$s'),
+ __s('Priority') . '',
Ticket::getPriorityName($job->fields['priority']),
));
if ($job->fields['itilcategories_id']) {
$pdf->displayLine(
'' . sprintf(
- __('%1$s: %2$s'),
- __('Category') . '',
+ __s('%1$s: %2$s'),
+ __s('Category') . '',
Dropdown::getDropdownName(
'glpi_itilcategories',
$job->fields['itilcategories_id'],
@@ -454,28 +454,28 @@ public static function pdfForTicket(PluginPdfSimplePDF $pdf, Ticket $ticket)
if (empty($col)) {
$col = $dbu->getUserName($d['users_id']);
} else {
- $col = sprintf(__('%1$s, %2$s'), $col, $dbu->getUserName($d['users_id']));
+ $col = sprintf(__s('%1$s, %2$s'), $col, $dbu->getUserName($d['users_id']));
}
}
}
$grps = $job->getGroups(CommonITILActor::REQUESTER);
if (count($grps)) {
if (empty($col)) {
- $col = sprintf(__('%1$s %2$s'), $col, _n('Group', 'Groups', 2) . ' ');
+ $col = sprintf(__s('%1$s %2$s'), $col, _sn('Group', 'Groups', 2) . ' ');
} else {
- $col = sprintf(__('%1$s - %2$s'), $col, _n('Group', 'Groups', 2) . ' ');
+ $col = sprintf(__s('%1$s - %2$s'), $col, _sn('Group', 'Groups', 2) . ' ');
}
$first = true;
foreach ($grps as $d) {
if ($first) {
$col = sprintf(
- __('%1$s %2$s'),
+ __s('%1$s %2$s'),
$col,
Dropdown::getDropdownName('glpi_groups', $d['groups_id']),
);
} else {
$col = sprintf(
- __('%1$s, %2$s'),
+ __s('%1$s, %2$s'),
$col,
Dropdown::getDropdownName('glpi_groups', $d['groups_id']),
);
@@ -484,7 +484,7 @@ public static function pdfForTicket(PluginPdfSimplePDF $pdf, Ticket $ticket)
}
}
if ($col) {
- $texte = '' . sprintf(__('%1$s: %2$s'), __('Requester') . '', '');
+ $texte = '' . sprintf(__s('%1$s: %2$s'), __s('Requester') . '', '');
$pdf->displayText($texte, $col, 1);
}
@@ -495,28 +495,28 @@ public static function pdfForTicket(PluginPdfSimplePDF $pdf, Ticket $ticket)
if (empty($col)) {
$col = $dbu->getUserName($d['users_id']);
} else {
- $col = sprintf(__('%1$s, %2$s'), $col, $dbu->getUserName($d['users_id']));
+ $col = sprintf(__s('%1$s, %2$s'), $col, $dbu->getUserName($d['users_id']));
}
}
}
$grps = $job->getGroups(CommonITILActor::ASSIGN);
if (count($grps)) {
if (empty($col)) {
- $col = sprintf(__('%1$s %2$s'), $col, _n('Group', 'Groups', 2) . ' ');
+ $col = sprintf(__s('%1$s %2$s'), $col, _sn('Group', 'Groups', 2) . ' ');
} else {
- $col = sprintf(__('%1$s - %2$s'), $col, _n('Group', 'Groups', 2) . ' ');
+ $col = sprintf(__s('%1$s - %2$s'), $col, _sn('Group', 'Groups', 2) . ' ');
}
$first = true;
foreach ($grps as $d) {
if ($first) {
$col = sprintf(
- __('%1$s %2$s'),
+ __s('%1$s %2$s'),
$col,
Dropdown::getDropdownName('glpi_groups', $d['groups_id']),
);
} else {
$col = sprintf(
- __('%1$s, %2$s'),
+ __s('%1$s, %2$s'),
$col,
Dropdown::getDropdownName('glpi_groups', $d['groups_id']),
);
@@ -525,11 +525,11 @@ public static function pdfForTicket(PluginPdfSimplePDF $pdf, Ticket $ticket)
}
}
if ($col) {
- $texte = '' . sprintf(__('%1$s: %2$s') . '', __('Assigned to'), '');
+ $texte = '' . sprintf(__s('%1$s: %2$s') . '', __s('Assigned to'), '');
$pdf->displayText($texte, $col, 1);
}
- $texte = '' . sprintf(__('%1$s: %2$s') . '', ('Title'), '');
+ $texte = '' . sprintf(__s('%1$s: %2$s') . '', ('Title'), '');
$pdf->displayText($texte, $job->fields['name'], 1);
}
}
diff --git a/inc/changetask.class.php b/inc/changetask.class.php
index a54058c..c438de7 100644
--- a/inc/changetask.class.php
+++ b/inc/changetask.class.php
@@ -36,7 +36,7 @@ class PluginPdfChangeTask extends PluginPdfCommon
public function __construct(?CommonGLPI $obj = null)
{
- $this->obj = ($obj ? $obj : new ChangeTask());
+ $this->obj = ($obj ?: new ChangeTask());
}
public static function pdfForChange(PluginPdfSimplePDF $pdf, Change $job)
@@ -48,30 +48,30 @@ public static function pdfForChange(PluginPdfSimplePDF $pdf, Change $job)
$ID = $job->getField('id');
- $result = $DB->request(
- 'glpi_changetasks',
- ['WHERE' => ['changes_id' => $ID],
- 'ORDER' => 'date DESC'],
- );
+ $result = $DB->request([
+ 'FROM' => 'glpi_changetasks',
+ 'WHERE' => ['changes_id' => $ID],
+ 'ORDER' => 'date DESC',
+ ]);
$number = count($result);
$pdf->setColumnsSize(100);
$title = '' . ChangeTask::getTypeName(2) . '';
- if (!$number) {
- $pdf->displayTitle(sprintf(__('%1$s: %2$s'), $title, __('No item to display')));
+ if ($number === 0) {
+ $pdf->displayTitle(sprintf(__s('%1$s: %2$s'), $title, __s('No item to display')));
} else {
- $title = sprintf(__('%1$s: %2$s'), $title, $number);
+ $title = sprintf(__s('%1$s: %2$s'), $title, $number);
$pdf->displayTitle($title);
foreach ($result as $data) {
$pdf->setColumnsSize(20, 20, 20, 20, 20);
$pdf->displayTitle(
- '' . __('Type'),
- __('Date'),
- __('Duration'),
- __('Writer'),
- __('Planning') . '',
+ '' . __s('Type'),
+ __s('Date'),
+ __s('Duration'),
+ __s('Writer'),
+ __s('Planning') . '',
);
$actiontime = Html::timestampToString($data['actiontime'], false);
@@ -83,33 +83,29 @@ public static function pdfForChange(PluginPdfSimplePDF $pdf, Change $job)
} else {
if (isset($data['state']) && $data['state']) {
$planification = sprintf(
- __('%1$s: %2$s'),
+ __s('%1$s: %2$s'),
_x('item', 'State'),
Planning::getState($data['state']),
);
}
$planification .= '
' . sprintf(
- __('%1$s: %2$s'),
- __('Begin'),
+ __s('%1$s: %2$s'),
+ __s('Begin'),
Html::convDateTime($data['begin']),
);
$planification .= '
' . sprintf(
- __('%1$s: %2$s'),
- __('End'),
+ __s('%1$s: %2$s'),
+ __s('End'),
Html::convDateTime($data['end']),
);
$planification .= '
' . sprintf(
- __('%1$s: %2$s'),
- __('By'),
+ __s('%1$s: %2$s'),
+ __s('By'),
$dbu->getUserName($data['users_id_tech']),
);
}
- if ($data['taskcategories_id']) {
- $lib = Dropdown::getDropdownName('glpi_taskcategories', $data['taskcategories_id']);
- } else {
- $lib = '';
- }
+ $lib = $data['taskcategories_id'] ? Dropdown::getDropdownName('glpi_taskcategories', $data['taskcategories_id']) : '';
$pdf->displayLine(
'' . Toolbox::stripTags($lib),
@@ -120,7 +116,7 @@ public static function pdfForChange(PluginPdfSimplePDF $pdf, Change $job)
1,
);
$pdf->displayText(
- '' . sprintf(__('%1$s: %2$s') . '', __('Description'), ''),
+ '' . sprintf(__s('%1$s: %2$s') . '', __s('Description'), ''),
$data['content'],
1,
);
diff --git a/inc/changevalidation.class.php b/inc/changevalidation.class.php
index bc8d797..6b20670 100644
--- a/inc/changevalidation.class.php
+++ b/inc/changevalidation.class.php
@@ -36,7 +36,7 @@ class PluginPdfChangeValidation extends PluginPdfCommon
public function __construct(?CommonGLPI $obj = null)
{
- $this->obj = ($obj ? $obj : new ChangeValidation());
+ $this->obj = ($obj ?: new ChangeValidation());
}
public static function pdfForChange(PluginPdfSimplePDF $pdf, Change $change)
@@ -47,7 +47,7 @@ public static function pdfForChange(PluginPdfSimplePDF $pdf, Change $change)
$dbu = new DbUtils();
$pdf->setColumnsSize(100);
- $pdf->displayTitle('' . __('Approvals for the change', 'pdf') . '');
+ $pdf->displayTitle('' . __s('Approvals for the change', 'pdf') . '');
if (!Session::haveRightsOr(
'changevalidation',
@@ -59,32 +59,32 @@ public static function pdfForChange(PluginPdfSimplePDF $pdf, Change $change)
)) {
return false;
}
- $ID = $change->getField('id');
+ $change->getField('id');
- $result = $DB->request(
- 'glpi_changevalidations',
- ['WHERE' => ['changes_id' => $change->getField('id')],
- 'ORDER' => 'submission_date DESC'],
- );
+ $result = $DB->request([
+ 'FROM' => 'glpi_changevalidations',
+ 'WHERE' => ['changes_id' => $change->getField('id')],
+ 'ORDER' => 'submission_date DESC',
+ ]);
$number = count($result);
$pdf->setColumnsSize(100);
$title = '' . ChangeValidation::getTypeName(2) . '';
- if (!$number) {
- $pdf->displayTitle(sprintf(__('%1$s: %2$s'), $title, __('No item to display')));
+ if ($number === 0) {
+ $pdf->displayTitle(sprintf(__s('%1$s: %2$s'), $title, __s('No item to display')));
} else {
- $title = sprintf(__('%1$s: %2$s'), $title, $number);
+ $title = sprintf(__s('%1$s: %2$s'), $title, $number);
$pdf->displayTitle($title);
$pdf->setColumnsSize(10, 10, 15, 20, 10, 15, 20);
$pdf->displayTitle(
_x('item', 'State'),
- __('Request date'),
- __('Approval requester'),
- __('Request comments'),
- __('Approval status'),
- __('Approver'),
- __('Approval comments'),
+ __s('Request date'),
+ __s('Approval requester'),
+ __s('Request comments'),
+ __s('Approval status'),
+ __s('Approver'),
+ __s('Approval comments'),
);
foreach ($result as $row) {
diff --git a/inc/common.class.php b/inc/common.class.php
index 7d6a289..04fad82 100644
--- a/inc/common.class.php
+++ b/inc/common.class.php
@@ -42,22 +42,16 @@ abstract class PluginPdfCommon extends CommonGLPI
**/
public function __construct(?CommonGLPI $obj = null)
{
- if ($obj) {
+ if ($obj instanceof CommonGLPI) {
$this->obj = $obj;
}
}
- /**
- * Add standard define tab
- *
- * @param $itemtype itemtype link to the tab
- * @param $ong array defined tab array
- * @param $options array of options (for withtemplate)
- *
- * @return CommonGLPI (set the tab array)
- **/
- final public function addStandardTab($itemtype, &$ong, $options)
+ // cannot override because created in CommonGLPI as final
+ /** @phpstan-ignore-next-line */
+ public function addStandardTab($itemtype, array &$ong, array $options)
{
+ parent::addStandardTab($itemtype, $ong, $options);
$dbu = new DbUtils();
$withtemplate = 0;
@@ -65,19 +59,14 @@ final public function addStandardTab($itemtype, &$ong, $options)
$withtemplate = $options['withtemplate'];
}
- if (!is_numeric($itemtype)
- && ($obj = $dbu->getItemForItemtype($itemtype))) {
- if (method_exists($itemtype, 'displayTabContentForPDF')
- && !($obj instanceof PluginPdfCommon)) {
- $titles = $obj->getTabNameForItem($this->obj, $withtemplate);
- if (!is_array($titles)) {
- $titles = [1 => $titles];
- }
-
- foreach ($titles as $key => $val) {
- if (!empty($val)) {
- $ong[$itemtype . '$' . $key] = $val;
- }
+ if (!is_numeric($itemtype) && ($obj = $dbu->getItemForItemtype($itemtype)) && (method_exists($itemtype, 'displayTabContentForPDF'))) {
+ $titles = $obj->getTabNameForItem($this->obj, $withtemplate);
+ if (!is_array($titles)) {
+ $titles = [1 => $titles];
+ }
+ foreach ($titles as $key => $val) {
+ if (!empty($val)) {
+ $ong[$itemtype . '$' . $key] = $val;
}
}
}
@@ -121,10 +110,8 @@ public function defineAllTabsPDF($options = [])
**/
public function getTabNameForItem(CommonGLPI $item, $withtemplate = 0)
{
- if (Session::haveRight('plugin_pdf', READ)) {
- if (empty($withtemplate)) {
- return __('Print to pdf', 'pdf');
- }
+ if (Session::haveRight('plugin_pdf', READ) && empty($withtemplate)) {
+ return self::createTabEntry(__s('PDF export', 'pdf'), 0, $item::getType(), PluginPdfConfig::getIcon());
}
return '';
}
@@ -280,8 +267,11 @@ final public static function displayCommonTabForPDF(PluginPdfSimplePDF $pdf, Com
**/
public static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtemplate = 0)
{
+ /** @var array $CFG_GLPI */
+ global $CFG_GLPI;
+
$pref = new PluginPdfPreference();
- $pref->menu($item, Plugin::getWebDir('pdf') . '/front/export.php');
+ $pref->menu($item, $CFG_GLPI['root_doc'] . '/plugins/pdf/front/export.php');
return true;
}
@@ -302,21 +292,21 @@ private function addHeader($ID)
&& $this->obj->getField('name')) {
$name = $this->obj->getField('name');
} else {
- $name = sprintf(__('%1$s %2$s'), __('ID'), $ID);
+ $name = sprintf(__s('%1$s %2$s'), __s('ID'), $ID);
}
if (Session::isMultiEntitiesMode() && $this->obj->isEntityAssign()) {
$entity = ' (' . Dropdown::getDropdownName('glpi_entities', $this->obj->getEntityID()) . ')';
}
- $header = Glpi\Toolbox\Sanitizer::unsanitize(sprintf(
- __('%1$s - %2$s'),
+ $header = sprintf(
+ __s('%1$s - %2$s'),
$this->obj->getTypeName(),
sprintf(
- __('%1$s %2$s'),
+ __s('%1$s %2$s'),
$name,
$entity,
),
- ));
+ );
$this->pdf->setHeader($header);
return true;
@@ -334,15 +324,15 @@ public static function pdfNote(PluginPdfSimplePDF $pdf, CommonDBTM $item)
$number = count($notes);
$pdf->setColumnsSize(100);
- $title = '' . _n('Note', 'Notes', $number) . '';
+ $title = '' . _sn('Note', 'Notes', $number) . '';
- if (!$number) {
- $pdf->displayTitle(sprintf(__('%1$s: %2$s'), $title, __('No item to display')));
+ if ($number === 0) {
+ $pdf->displayTitle(sprintf(__s('%1$s: %2$s'), $title, __s('No item to display')));
} else {
if ($number > $_SESSION['glpilist_limit']) {
- $title = sprintf(__('%1$s: %2$s'), $title, $_SESSION['glpilist_limit'] . ' / ' . $number);
+ $title = sprintf(__s('%1$s: %2$s'), $title, $_SESSION['glpilist_limit'] . ' / ' . $number);
} else {
- $title = sprintf(__('%1$s: %2$s'), $title, $number);
+ $title = sprintf(__s('%1$s: %2$s'), $title, $number);
}
$pdf->displayTitle($title);
@@ -384,12 +374,12 @@ final public function generatePDF($tab_id, $tabs, $page = 0, $render = true)
}
foreach ($tabs as $tab) {
- if (!$this->displayTabContentForPDF($this->pdf, $this->obj, $tab)
- && !$this->displayCommonTabForPDF($this->pdf, $this->obj, $tab)) {
+ if (!static::displayTabContentForPDF($this->pdf, $this->obj, $tab)
+ && !static::displayCommonTabForPDF($this->pdf, $this->obj, $tab)) {
$data = explode('$', $tab);
$itemtype = $data[0];
// Default set
- $tabnum = (isset($data[1]) ? $data[1] : 1);
+ $tabnum = ($data[1] ?? 1);
if (!is_numeric($itemtype)
&& ($itemtype != 'empty')) {
@@ -404,6 +394,7 @@ final public function generatePDF($tab_id, $tabs, $page = 0, $render = true)
}
} elseif (method_exists($itemtype, 'displayTabContentForPdf')
&& ($obj = $dbu->getItemForItemtype($itemtype))) {
+ /** @phpstan-ignore-next-line */
if ($obj->displayTabContentForPdf($this->pdf, $this->obj, $tabnum)) {
continue;
}
@@ -411,7 +402,7 @@ final public function generatePDF($tab_id, $tabs, $page = 0, $render = true)
}
Toolbox::logInFile(
'php-errors',
- sprintf(__("PDF: don't know how to display %s tab") . '\n', $tab),
+ sprintf(__s("PDF: don't know how to display %s tab") . '\n', $tab),
);
}
}
@@ -433,19 +424,19 @@ public static function mainTitle(PluginPdfSimplePDF $pdf, $item)
{
$pdf->setColumnsSize(50, 50);
- $col1 = '' . sprintf(__('%1$s %2$s'), __('ID'), $item->fields['id']) . '';
+ $col1 = '' . sprintf(__s('%1$s %2$s'), __s('ID'), $item->fields['id']) . '';
$col2 = sprintf(
- __('%1$s: %2$s'),
- __('Last update'),
+ __s('%1$s: %2$s'),
+ __s('Last update'),
Html::convDateTime($item->fields['date_mod']),
);
if (!empty($item->fields['template_name'])) {
$col2 = sprintf(
- __('%1$s (%2$s)'),
+ __s('%1$s (%2$s)'),
$col2,
sprintf(
- __('%1$s: %2$s'),
- __('Template name'),
+ __s('%1$s: %2$s'),
+ __s('Template name'),
$item->fields['template_name'],
),
);
@@ -463,13 +454,13 @@ public static function mainLine(PluginPdfSimplePDF $pdf, $item, $field)
case 'name-status':
return $pdf->displayLine(
'' . sprintf(
- __('%1$s: %2$s'),
- __('Name') . '',
+ __s('%1$s: %2$s'),
+ __s('Name') . '',
$item->fields['name'],
),
'' . sprintf(
- __('%1$s: %2$s'),
- __('Status') . '',
+ __s('%1$s: %2$s'),
+ __s('Status') . '',
Toolbox::stripTags(Dropdown::getDropdownName(
'glpi_states',
$item->fields['states_id'],
@@ -480,16 +471,16 @@ public static function mainLine(PluginPdfSimplePDF $pdf, $item, $field)
case 'location-type':
return $pdf->displayLine(
'' . sprintf(
- __('%1$s: %2$s'),
- __('Location') . '',
+ __s('%1$s: %2$s'),
+ __s('Location') . '',
Dropdown::getDropdownName(
'glpi_locations',
$item->fields['locations_id'],
),
),
'' . sprintf(
- __('%1$s: %2$s'),
- __('Type') . '',
+ __s('%1$s: %2$s'),
+ __s('Type') . '',
Toolbox::stripTags(Dropdown::getDropdownName(
'glpi_' . $type . 'types',
$item->fields[$type . 'types_id'],
@@ -500,13 +491,13 @@ public static function mainLine(PluginPdfSimplePDF $pdf, $item, $field)
case 'tech-manufacturer':
return $pdf->displayLine(
'' . sprintf(
- __('%1$s: %2$s'),
- __('Technician in charge of the hardware') . '',
+ __s('%1$s: %2$s'),
+ __s('Technician in charge of the hardware') . '',
$dbu->getUserName($item->fields['users_id_tech']),
),
'' . sprintf(
- __('%1$s: %2$s'),
- __('Manufacturer') . '',
+ __s('%1$s: %2$s'),
+ __s('Manufacturer') . '',
Toolbox::stripTags(Dropdown::getDropdownName(
'glpi_manufacturers',
$item->fields['manufacturers_id'],
@@ -516,16 +507,16 @@ public static function mainLine(PluginPdfSimplePDF $pdf, $item, $field)
case 'group-model':
return $pdf->displayLine(
'' . sprintf(
- __('%1$s: %2$s'),
- __('Group in charge of the hardware') . '',
+ __s('%1$s: %2$s'),
+ __s('Group in charge of the hardware') . '',
Dropdown::getDropdownName(
'glpi_groups',
$item->fields['groups_id_tech'],
),
),
'' . sprintf(
- __('%1$s: %2$s'),
- __('Model') . '',
+ __s('%1$s: %2$s'),
+ __s('Model') . '',
Toolbox::stripTags(Dropdown::getDropdownName(
'glpi_' . $type . 'models',
$item->fields[$type . 'models_id'],
@@ -536,13 +527,13 @@ public static function mainLine(PluginPdfSimplePDF $pdf, $item, $field)
case 'contactnum-serial':
return $pdf->displayLine(
'' . sprintf(
- __('%1$s: %2$s'),
- __('Alternate username number') . '',
+ __s('%1$s: %2$s'),
+ __s('Alternate username number') . '',
$item->fields['contact_num'],
),
'' . sprintf(
- __('%1$s: %2$s'),
- __('Serial number') . '',
+ __s('%1$s: %2$s'),
+ __s('Serial number') . '',
$item->fields['serial'],
),
);
@@ -550,13 +541,13 @@ public static function mainLine(PluginPdfSimplePDF $pdf, $item, $field)
case 'contact-otherserial':
return $pdf->displayLine(
'' . sprintf(
- __('%1$s: %2$s'),
- __('Alternate username') . '',
+ __s('%1$s: %2$s'),
+ __s('Alternate username') . '',
$item->fields['contact'],
),
'' . sprintf(
- __('%1$s: %2$s'),
- __('Inventory number') . '',
+ __s('%1$s: %2$s'),
+ __s('Inventory number') . '',
$item->fields['otherserial'],
),
);
@@ -564,22 +555,22 @@ public static function mainLine(PluginPdfSimplePDF $pdf, $item, $field)
case 'user-management':
return $pdf->displayLine(
'' . sprintf(
- __('%1$s: %2$s'),
- __('User') . '',
+ __s('%1$s: %2$s'),
+ __s('User') . '',
$dbu->getUserName($item->fields['users_id']),
),
'' . sprintf(
- __('%1$s: %2$s'),
- __('Management type') . '',
- ($item->fields['is_global'] ? __('Global management')
- : __('Unit management')),
+ __s('%1$s: %2$s'),
+ __s('Management type') . '',
+ ($item->fields['is_global'] ? __s('Global management')
+ : __s('Unit management')),
),
);
case 'comment':
return $pdf->displayText('' . sprintf(
- __('%1$s: %2$s'),
- __('Comments') . '',
+ __s('%1$s: %2$s'),
+ __s('Comments') . '',
'',
), $item->fields['comment']);
@@ -611,6 +602,9 @@ public static function processMassiveActionsForOneItemtype(
CommonDBTM $item,
array $ids
) {
+ /** @var array $CFG_GLPI */
+ global $CFG_GLPI;
+
switch ($ma->getAction()) {
case 'DoIt':
$tab_id = [];
@@ -621,9 +615,8 @@ public static function processMassiveActionsForOneItemtype(
}
$_SESSION['plugin_pdf']['type'] = $item->getType();
$_SESSION['plugin_pdf']['tab_id'] = serialize($tab_id);
- $webDir = Plugin::getWebDir('pdf');
echo "";
+ location.href='" . $CFG_GLPI['root_doc'] . "/plugins/pdf/front/export.massive.php'";
break;
}
}
diff --git a/inc/commonitilcost.class.php b/inc/commonitilcost.class.php
index 2d01a00..8532c2b 100644
--- a/inc/commonitilcost.class.php
+++ b/inc/commonitilcost.class.php
@@ -36,7 +36,7 @@ class PluginPdfCommonItilCost extends PluginPdfCommon
public function __construct(?CommonGLPI $obj = null)
{
- $this->obj = ($obj ? $obj : new TicketCost());
+ $this->obj = ($obj ?: new TicketCost());
}
public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $job)
@@ -49,31 +49,34 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $job)
$table = 'glpi_' . (strtolower($type)) . 'costs';
$classname = $type . 'Cost';
- $result = $DB->request($table, ['WHERE' => [$job->getForeignKeyField() => $ID],
- 'ORDER' => 'begin_date']);
+ $result = $DB->request([
+ 'FROM' => $table,
+ 'WHERE' => [$job->getForeignKeyField() => $ID],
+ 'ORDER' => 'begin_date',
+ ]);
$number = count($result);
- if (!$number) {
+ if ($number === 0) {
$pdf->setColumnsSize(100);
$pdf->displayTitle(sprintf(
- __('%1$s: %2$s'),
+ __s('%1$s: %2$s'),
'' . $classname::getTypeName(2) . '',
- __('No item to display'),
+ __s('No item to display'),
));
} else {
$pdf->setColumnsSize(60, 20, 20);
$title = $classname::getTypeName($number);
if (!empty(PluginPdfConfig::currencyName())) {
$title = sprintf(
- __('%1$s (%2$s)'),
+ __s('%1$s (%2$s)'),
$classname::getTypeName($number),
PluginPdfConfig::currencyName(),
);
}
$pdf->displayTitle(
'' . $title . '',
- '' . __('Duration') . '',
+ '' . __s('Duration') . '',
'' . CommonITILObject::getActionTime($job->fields['actiontime']) . '',
);
@@ -90,15 +93,15 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $job)
'right',
);
$pdf->displayTitle(
- '' . __('Name') . '',
- '' . __('Begin date') . '',
- '' . __('End date') . '',
- '' . __('Budget') . '',
- '' . __('Duration') . '',
- '' . __('Time cost') . '',
- '' . __('Fixed cost') . '',
- '' . __('Material cost') . '',
- '' . __('Total cost') . '',
+ '' . __s('Name') . '',
+ '' . __s('Begin date') . '',
+ '' . __s('End date') . '',
+ '' . __s('Budget') . '',
+ '' . __s('Duration') . '',
+ '' . __s('Time cost') . '',
+ '' . __s('Fixed cost') . '',
+ '' . __s('Material cost') . '',
+ '' . __s('Total cost') . '',
);
$total = 0;
@@ -138,7 +141,7 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $job)
$pdf->setColumnsSize(52, 8, 10, 10, 10, 10);
$pdf->setColumnsAlign('right', 'right', 'right', 'right', 'right', 'right');
$pdf->displayLine(
- '' . __('Total') . '',
+ '' . __s('Total') . '',
'' . CommonITILObject::getActionTime($total_time) . '',
'' . PluginPdfConfig::formatNumber($total_costtime) . '',
'' . PluginPdfConfig::formatNumber($total_fixed) . '',
diff --git a/inc/computer.class.php b/inc/computer.class.php
index b88b448..c8851cf 100644
--- a/inc/computer.class.php
+++ b/inc/computer.class.php
@@ -36,7 +36,7 @@ class PluginPdfComputer extends PluginPdfCommon
public function __construct(?CommonGLPI $obj = null)
{
- $this->obj = ($obj ? $obj : new Computer());
+ $this->obj = ($obj ?: new Computer());
}
public function defineAllTabsPDF($options = [])
diff --git a/inc/computer_item.class.php b/inc/computer_item.class.php
index d1b4d14..7b1f443 100644
--- a/inc/computer_item.class.php
+++ b/inc/computer_item.class.php
@@ -30,13 +30,15 @@
* --------------------------------------------------------------------------
*/
+use Glpi\Asset\Asset_PeripheralAsset;
+
class PluginPdfComputer_Item extends PluginPdfCommon
{
public static $rightname = 'plugin_pdf';
public function __construct(?CommonGLPI $obj = null)
{
- $this->obj = ($obj ? $obj : new Computer_Item());
+ $this->obj = ($obj ?: new Asset_PeripheralAsset());
}
public static function pdfForComputer(PluginPdfSimplePDF $pdf, Computer $comp)
@@ -48,38 +50,48 @@ public static function pdfForComputer(PluginPdfSimplePDF $pdf, Computer $comp)
$ID = $comp->getField('id');
- $items = ['Printer' => _n('Printer', 'Printers', 2),
- 'Monitor' => _n('Monitor', 'Monitors', 2),
- 'Peripheral' => _n('Device', 'Devices', 2),
- 'Phone' => _n('Phone', 'Phones', 2)];
+ $items = ['Printer' => _sn('Printer', 'Printers', 2),
+ 'Monitor' => _sn('Monitor', 'Monitors', 2),
+ 'Peripheral' => _sn('Device', 'Devices', 2),
+ 'Phone' => _sn('Phone', 'Phones', 2)];
$info = new Infocom();
$pdf->setColumnsSize(100);
- $pdf->displayTitle('' . __('Direct connections') . '');
+ $pdf->displayTitle('' . __s('Direct connections') . '');
- foreach ($items as $type => $title) {
- if (!($item = $dbu->getItemForItemtype($type))) {
- continue;
- }
+ foreach (array_keys($items) as $type) {
+ $item = $dbu->getItemForItemtype($type);
if (!$item->canView()) {
continue;
}
- $query = 'SELECT `glpi_computers_items`.`id` AS assoc_id,
- `glpi_computers_items`.`computers_id` AS assoc_computers_id,
- `glpi_computers_items`.`itemtype`,
- `glpi_computers_items`.`items_id`,
- `glpi_computers_items`.`is_dynamic` AS assoc_is_dynamic,
- ' . $dbu->getTableForItemType($type) . '.*
- FROM `glpi_computers_items`
- LEFT JOIN `' . $dbu->getTableForItemType($type) . '`
- ON (`' . $dbu->getTableForItemType($type) . "`.`id`
- = `glpi_computers_items`.`items_id`)
- WHERE `computers_id` = '$ID'
- AND `itemtype` = '" . $type . "'
- AND `glpi_computers_items`.`is_deleted` = '0'";
+ $itemTable = $dbu->getTableForItemType($type);
+ $query = [
+ 'SELECT' => [
+ 'glpi_assets_assets_peripheralassets.id AS assoc_id',
+ 'glpi_assets_assets_peripheralassets.computers_id AS assoc_computers_id',
+ 'glpi_assets_assets_peripheralassets.itemtype',
+ 'glpi_assets_assets_peripheralassets.items_id',
+ 'glpi_assets_assets_peripheralassets.is_dynamic AS assoc_is_dynamic',
+ ],
+ 'FROM' => 'glpi_assets_assets_peripheralassets',
+ 'LEFT JOIN' => [
+ $itemTable => [
+ 'FKEY' => [
+ $itemTable => 'id',
+ 'glpi_assets_assets_peripheralassets' => 'items_id',
+ ],
+ ],
+ ],
+ 'WHERE' => [
+ 'computers_id' => $ID,
+ 'itemtype' => $type,
+ 'glpi_assets_assets_peripheralassets.is_deleted' => 0,
+ ],
+ ];
+
if ($item->maybetemplate()) {
- $query .= ' AND NOT `' . $dbu->getTableForItemType($type) . '`.`is_template` ';
+ $query['WHERE'][$itemTable . '.is_template'] = 0;
}
$result = $DB->request($query);
@@ -89,23 +101,25 @@ public static function pdfForComputer(PluginPdfSimplePDF $pdf, Computer $comp)
$tID = $row['items_id'];
$connID = $row['id'];
$item->getFromDB($tID);
- $info->getFromDBforDevice($type, $tID) || $info->getEmpty();
+ if (!$info->getFromDBforDevice($type, $tID)) {
+ $info->getEmpty();
+ }
$line1 = $item->getName();
if ($item->getField('serial') != null) {
$line1 = sprintf(
- __('%1$s - %2$s'),
+ __s('%1$s - %2$s'),
$line1,
sprintf(
- __('%1$s: %2$s'),
- __('Serial number'),
+ __s('%1$s: %2$s'),
+ __s('Serial number'),
$item->getField('serial'),
),
);
}
$line1 = sprintf(
- __('%1$s - %2$s'),
+ __s('%1$s - %2$s'),
$line1,
Toolbox::stripTags(Dropdown::getDropdownName(
'glpi_states',
@@ -116,31 +130,31 @@ public static function pdfForComputer(PluginPdfSimplePDF $pdf, Computer $comp)
$line2 = '';
if ($item->getField('otherserial') != null) {
$line2 = sprintf(
- __('%1$s: %2$s'),
- __('Inventory number'),
+ __s('%1$s: %2$s'),
+ __s('Inventory number'),
$item->getField('otherserial'),
);
}
if ($info->fields['immo_number']) {
$line2 = sprintf(
- __('%1$s - %2$s'),
+ __s('%1$s - %2$s'),
$line2,
sprintf(
- __('%1$s: %2$s'),
- __('Immobilization number'),
+ __s('%1$s: %2$s'),
+ __s('Immobilization number'),
$info->fields['immo_number'],
),
);
}
- if ($line2) {
+ if ($line2 !== '' && $line2 !== '0') {
$pdf->displayText(
- '' . sprintf(__('%1$s: %2$s'), $item->getTypeName() . '', ''),
+ '' . sprintf(__s('%1$s: %2$s'), $item->getTypeName() . '', ''),
$line1 . "\n" . $line2,
2,
);
} else {
$pdf->displayText(
- '' . sprintf(__('%1$s: %2$s'), $item->getTypeName() . '', ''),
+ '' . sprintf(__s('%1$s: %2$s'), $item->getTypeName() . '', ''),
$line1,
1,
);
@@ -149,19 +163,19 @@ public static function pdfForComputer(PluginPdfSimplePDF $pdf, Computer $comp)
} else { // No row
switch ($type) {
case 'Printer':
- $pdf->displayLine(sprintf(__('No printer', 'pdf')));
+ $pdf->displayLine(__s('No printer', 'pdf'));
break;
case 'Monitor':
- $pdf->displayLine(sprintf(__('No monitor', 'pdf')));
+ $pdf->displayLine(__s('No monitor', 'pdf'));
break;
case 'Peripheral':
- $pdf->displayLine(sprintf(__('No peripheral', 'pdf')));
+ $pdf->displayLine(__s('No peripheral', 'pdf'));
break;
case 'Phone':
- $pdf->displayLine(sprintf(__('No phone', 'pdf')));
+ $pdf->displayLine(__s('No phone', 'pdf'));
break;
}
} // No row
@@ -181,17 +195,16 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
$comp = new Computer();
$pdf->setColumnsSize(100);
- $title = '' . __('Direct connections') . '';
+ $title = '' . __s('Direct connections') . '';
$result = $DB->request(
- 'glpi_computers_items',
- ['items_id' => $ID,
+ ['FROM' => 'glpi_assets_assets_peripheralassets'] + ['items_id' => $ID,
'itemtype' => $type],
);
$resultnum = count($result);
- if (!$resultnum) {
- $pdf->displayTitle(sprintf(__('%1$s: %2$s'), $title, __('No item to display')));
+ if ($resultnum === 0) {
+ $pdf->displayTitle(sprintf(__s('%1$s: %2$s'), $title, __s('No item to display')));
} else {
$pdf->displayTitle($title);
@@ -199,16 +212,18 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
$tID = $row['computers_id'];
$connID = $row['id'];
$comp->getFromDB($tID);
- $info->getFromDBforDevice('Computer', $tID) || $info->getEmpty();
+ if (!$info->getFromDBforDevice('Computer', $tID)) {
+ $info->getEmpty();
+ }
- $line1 = (isset($comp->fields['name']) ? $comp->fields['name'] : '(' . $comp->fields['id'] . ')');
+ $line1 = ($comp->fields['name'] ?? '(' . $comp->fields['id'] . ')');
if (isset($comp->fields['states_id'])) {
$line1 = sprintf(
- __('%1$s - %2$s'),
+ __s('%1$s - %2$s'),
$line1,
sprintf(
- __('%1$s: %2$s'),
- '' . __('Status') . '',
+ __s('%1$s: %2$s'),
+ '' . __s('Status') . '',
Toolbox::stripTags(Dropdown::getDropdownName(
'glpi_states',
$comp->fields['states_id'],
@@ -218,11 +233,11 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
}
if (isset($comp->fields['serial'])) {
$line1 = sprintf(
- __('%1$s - %2$s'),
+ __s('%1$s - %2$s'),
$line1,
sprintf(
- __('%1$s: %2$s'),
- '' . __('Serial number') . '',
+ __s('%1$s: %2$s'),
+ '' . __s('Serial number') . '',
$comp->fields['serial'],
),
);
@@ -231,11 +246,11 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
if (isset($comp->fields['otherserial'])) {
$line1 = sprintf(
- __('%1$s - %2$s'),
+ __s('%1$s - %2$s'),
$line1,
sprintf(
- __('%1$s: %2$s'),
- '' . __('Inventory number') . '',
+ __s('%1$s: %2$s'),
+ '' . __s('Inventory number') . '',
$item->getField('otherserial'),
),
);
@@ -243,24 +258,24 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
$line2 = '';
if ($info->fields['immo_number']) {
$line2 = sprintf(
- __('%1$s - %2$s'),
+ __s('%1$s - %2$s'),
$line2,
sprintf(
- __('%1$s: %2$s'),
- '' . __('Immobilization number') . '',
+ __s('%1$s: %2$s'),
+ '' . __s('Immobilization number') . '',
$info->fields['immo_number'],
),
);
}
- if ($line2) {
+ if ($line2 !== '' && $line2 !== '0') {
$pdf->displayText(
- '' . sprintf(__('%1$s: %2$s'), __('Computer') . '', ''),
+ '' . sprintf(__s('%1$s: %2$s'), __s('Computer') . '', ''),
$line1 . "\n" . $line2,
2,
);
} else {
$pdf->displayText(
- '' . sprintf(__('%1$s: %2$s'), __('Computer') . '', ''),
+ '' . sprintf(__s('%1$s: %2$s'), __s('Computer') . '', ''),
$line1,
1,
);
diff --git a/inc/computer_softwarelicense.class.php b/inc/computer_softwarelicense.class.php
index b401c57..67ac3f2 100644
--- a/inc/computer_softwarelicense.class.php
+++ b/inc/computer_softwarelicense.class.php
@@ -30,13 +30,44 @@
* --------------------------------------------------------------------------
*/
+use Glpi\DBAL\QueryExpression;
+
+/**
+ * -------------------------------------------------------------------------
+ * LICENSE
+ *
+ * This file is part of PDF plugin for GLPI.
+ *
+ * PDF is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * PDF 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with Reports. If not, see
' . $DB->error());
+ $DB->doQuery($query);
$query = "INSERT INTO `$table`
(id, currency)
VALUES (1, 'EUR')";
- $DB->doQueryOrDie($query, 'Error during update glpi_plugin_pdf_configs' .
- '
' . $DB->error());
+ $DB->doQuery($query);
} else {
// 2.1.0
if ($DB->fieldExists($table, 'date_mod')) {
@@ -187,7 +190,7 @@ public static function showConfigForm($item)
public function getTabNameForItem(CommonGLPI $item, $withtemplate = 0)
{
if ($item->getType() == 'Config') {
- return $this->getName();
+ return self::createTabEntry(self::getTypeName(), 0, $item::getType(), self::getIcon());
}
return '';
@@ -205,156 +208,156 @@ public static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $
public static function currency()
{
// name, symbole, currency, uniqUE
- return ['AED' => [__('UAE Dirham', 'pdf'), 'د.إ', false],
- 'AFN' => [__('Afghani', 'pdf'), 'Af'],
- 'ALL' => [__('Lek', 'pdf'), 'L', false],
- 'AMD' => [__('Armenian Dram', 'pdf'), 'Դ'],
- 'AOA' => [__('Kwanza', 'pdf'), 'Kz'],
- 'ARS' => [__('Argentine Peso', 'pdf'), '$', false],
- 'AUD' => [__('Australian Dollar', 'pdf'), '$', false],
- 'AWG' => [__('Aruban Guilder/Florin', 'pdf'), 'ƒ'],
- 'AZN' => [__('Azerbaijanian Manat', 'pdf'), 'ман'],
- 'BAM' => [__('Konvertibilna Marka', 'pdf'), 'КМ'],
- 'BBD' => [__('Barbados Dollar', 'pdf'), '$', false],
- 'BDT' => [__('Taka', 'pdf'), '৳'],
- 'BGN' => [__('Bulgarian Lev', 'pdf'), 'лв'],
- 'BHD' => [__('Bahraini Dinar', 'pdf'), 'ب.د'],
- 'BIF' => [__('Burundi Franc', 'pdf'), '₣', false],
- 'BMD' => [__('Bermudian Dollar', 'pdf'), '$', false],
- 'BND' => [__('Brunei Dollar', 'pdf'), '$', false],
- 'BOB' => [__('Boliviano', 'pdf'), 'Bs.'],
- 'BRL' => [__('Brazilian Real', 'pdf'), 'R$'],
- 'BSD' => [__('Bahamian Dollar', 'pdf'), '$', false],
- 'BTN' => [__('Ngultrum', 'pdf'), ''],
- 'BWP' => [__('Pula', 'pdf'), 'P', false],
- 'BYR' => [__('Belarussian Ruble', 'pdf'), 'Br.'],
- 'BZD' => [__('Belize Dollar', 'pdf'), '$', false],
- 'CAD' => [__('Canadian Dollar', 'pdf'), '$', false],
- 'CDF' => [__('Congolese Franc', 'pdf'), 'F', false],
- 'CHF' => [__('Swiss Franc', 'pdf'), 'F', false],
- 'CLP' => [__('Chilean Peso', 'pdf'), '$', false],
- 'CNY' => [__('Yuan', 'pdf'), '¥'],
- 'COP' => [__('Colombian Peso', 'pdf'), '$', false],
- 'CRC' => [__('Costa Rican Colon', 'pdf'), '₡'],
- 'CUP' => [__('Cuban Peso', 'pdf'), '$', false],
- 'CVE' => [__('Cape Verde Escudo', 'pdf'), '$', false],
- 'CZK' => [__('Czech Koruna', 'pdf'), 'Kč'],
- 'DJF' => [__('Djibouti Franc', 'pdf'), '₣', false],
- 'DKK' => [__('Danish Krone', 'pdf'), 'kr', false],
- 'DOP' => [__('Dominican Peso', 'pdf'), '$', false],
- 'DZD' => [__('Algerian Dinar', 'pdf'), 'د.ج'],
- 'EGP' => [__('Egyptian Pound', 'pdf'), '£', false],
- 'ERN' => [__('Nakfa', 'pdf'), 'Nfk'],
- 'ETB' => [__('Ethiopian Birr', 'pdf'), ''],
- 'EUR' => [__('Euro', 'pdf'), '€'],
- 'FJD' => [__('Fiji Dollar', 'pdf'), '$', false],
- 'FKP' => [__('Falkland Islands Pound', 'pdf'), '£', false],
- 'GBP' => [__('Pound Sterling', 'pdf'), '£', false],
- 'GEL' => [__('Lari', 'pdf'), 'ლ'],
- 'GHS' => [__('Cedi', 'pdf'), '₵'],
- 'GIP' => [__('Gibraltar Pound', 'pdf'), '£', false],
- 'GMD' => [__('Dalasi', 'pdf'), 'D'],
- 'GNF' => [__('Guinea Franc', 'pdf'), '₣', false],
- 'GTQ' => [__('Quetzal', 'pdf'), 'Q'],
- 'HKD' => [__('Hong Kong Dollar', 'pdf'), '$', false],
- 'HNL' => [__('Lempira', 'pdf'), 'L', false],
- 'HRK' => [__('Croatian Kuna', 'pdf'), 'Kn'],
- 'HTG' => [__('Gourde', 'pdf'), 'G'],
- 'HUF' => [__('Forint', 'pdf'), 'Ft'],
- 'IDR' => [__('Rupiah', 'pdf'), 'Rp'],
- 'ILS' => [__('New Israeli Shekel', 'pdf'), '₪'],
- 'INR' => [__('Indian Rupee', 'pdf'), '₨', false],
- 'IQD' => [__('Iraqi Dinar', 'pdf'), 'ع.د'],
- 'IRR' => [__('Iranian Rial', 'pdf'), '﷼'],
- 'ISK' => [__('Iceland Krona', 'pdf'), 'Kr', false],
- 'JMD' => [__('Jamaican Dollar', 'pdf'), '$', false],
- 'JOD' => [__('Jordanian Dinar', 'pdf'), 'د.ا', false],
- 'JPY' => [__('Yen', 'pdf'), '¥'],
- 'KES' => [__('Kenyan Shilling', 'pdf'), 'Sh', false],
- 'KGS' => [__('Som', 'pdf'), ''],
- 'KHR' => [__('Riel', 'pdf'), '៛'],
- 'KPW' => [__('North Korean Won', 'pdf'), '₩', false],
- 'KRW' => [__('South Korean Won', 'pdf'), '₩', false],
- 'KWD' => [__('Kuwaiti Dinar', 'pdf'), 'د.ك'],
- 'KYD' => [__('Cayman Islands Dollar', 'pdf'), '$', false],
- 'KZT' => [__('Tenge', 'pdf'), '〒'],
- 'LAK' => [__('Kip', 'pdf'), '₭'],
- 'LBP' => [__('Lebanese Pound', 'pdf'), '£L'],
- 'LKR' => [__('Sri Lanka Rupee', 'pdf'), 'Rs'],
- 'LRD' => [__('Liberian Dollar', 'pdf'), '$', false],
- 'LSL' => [__('Loti', 'pdf'), 'L', false],
- 'LYD' => [__('Libyan Dinar', 'pdf'), 'ل.د'],
- 'MAD' => [__('Moroccan Dirham', 'pdf'), 'د.م.'],
- 'MDL' => [__('Moldavian Leu', 'pdf'), 'L', false],
- 'MGA' => [__('Malagasy Ariary', 'pdf'), ''],
- 'MKD' => [__('Denar', 'pdf'), 'ден'],
- 'MMK' => [__('Kyat', 'pdf'), 'K', false],
- 'MNT' => [__('Tugrik', 'pdf'), '₮'],
- 'MOP' => [__('Pataca', 'pdf'), 'P', false],
- 'MRO' => [__('Ouguiya', 'pdf'), 'UM'],
- 'MUR' => [__('Mauritius Rupee', 'pdf'), '₨', false],
- 'MVR' => [__('Rufiyaa', 'pdf'), 'ރ.'],
- 'MWK' => [__('Kwacha', 'pdf'), 'MK'],
- 'MXN' => [__('Mexican Peso', 'pdf'), '$', false],
- 'MYR' => [__('Malaysian Ringgit', 'pdf'), 'RM'],
- 'MZN' => [__('Metical', 'pdf'), 'MTn'],
- 'NAD' => [__('Namibia Dollar', 'pdf'), '$', false],
- 'NGN' => [__('Naira', 'pdf'), '₦'],
- 'NIO' => [__('Cordoba Oro', 'pdf'), 'C$'],
- 'NOK' => [__('Norwegian Krone', 'pdf'), 'kr', false],
- 'NPR' => [__('Nepalese Rupee', 'pdf'), '₨', false],
- 'NZD' => [__('New Zealand Dollar', 'pdf'), '$', false],
- 'OMR' => [__('Rial Omani', 'pdf'), 'ر.ع.'],
- 'PAB' => [__('Balboa', 'pdf'), 'B/.'],
- 'PEN' => [__('Nuevo Sol', 'pdf'), 'S/.'],
- 'PGK' => [__('Kina', 'pdf'), 'K', false],
- 'PHP' => [__('Philippine Peso', 'pdf'), '₱'],
- 'PKR' => [__('Pakistan Rupee', 'pdf'), '₨', false],
- 'PLN' => [__('PZloty', 'pdf'), 'zł'],
- 'PYG' => [__('Guarani', 'pdf'), '₲'],
- 'QAR' => [__('Qatari Rial', 'pdf'), 'ر.ق'],
- 'RON' => [__('Leu', 'pdf'), 'L', false],
- 'RSD' => [__('Serbian Dinar', 'pdf'), 'din'],
- 'RUB' => [__('Russian Ruble', 'pdf'), 'р.'],
- 'RWF' => [__('Rwanda Franc', 'pdf'), 'F', false],
- 'SAR' => [__('Saudi Riyal', 'pdf'), 'ر.س '],
- 'SBD' => [__('Solomon Islands Dollar', 'pdf'), '$', false],
- 'SCR' => [__('Seychelles Rupee', 'pdf'), '₨', false],
- 'SDG' => [__('Sudanese', 'pdf'), '£', false],
- 'SEK' => [__('Swedish Krona', 'pdf'), 'kr', false],
- 'SGD' => [__('Singapore Dollar', 'pdf'), '$', false],
- 'SHP' => [__('Saint Helena Pound', 'pdf'), '£', false],
- 'SLL' => [__('leone', 'pdf'), 'Le'],
- 'SOS' => [__('Somali Shilling', 'pdf'), 'Sh', false],
- 'SRD' => [__('Suriname Dollar', 'pdf'), '$', false],
- 'STD' => [__('Dobra', 'pdf'), 'Db'],
- 'SYP' => [__('Syrian Pound', 'pdf'), 'ل.س'],
- 'SZL' => [__('Lilangeni', 'pdf'), 'L', false],
- 'THB' => [__('Baht', 'pdf'), '฿'],
- 'TJS' => [__('Somoni', 'pdf'), 'ЅМ'],
- 'TMT' => [__('Manat', 'pdf'), 'm'],
- 'TND' => [__('Tunisian Dinar', 'pdf'), 'د.ت'],
- 'TOP' => [__('Pa’anga', 'pdf'), 'T$'],
- 'TRY' => [__('Turkish Lira', 'pdf'), '₤', false],
- 'TTD' => [__('Trinidad and Tobago Dollar', 'pdf'), '$', false],
- 'TWD' => [__('Taiwan Dollar', 'pdf'), '$', false],
- 'TZS' => [__('Tanzanian Shilling', 'pdf'), 'Sh', false],
- 'UAH' => [__('Hryvnia', 'pdf'), '₴'],
- 'UGX' => [__('Uganda Shilling', 'pdf'), 'Sh', false],
- 'USD' => [__('US Dollar', 'pdf'), '$', false],
- 'UYU' => [__('Peso Uruguayo', 'pdf'), '$', false],
- 'UZS' => [__('Uzbekistan Sum', 'pdf'), ''],
- 'VEF' => [__('Bolivar Fuerte', 'pdf'), 'Bs F'],
- 'VND' => [__('Dong', 'pdf'), '₫'],
- 'VUV' => [__('Vatu', 'pdf'), 'Vt'],
- 'WST' => [__('Tala', 'pdf'), 'T'],
- 'XAF' => [__('CFA Franc BCEAO', 'pdf'), '₣', false],
- 'XCD' => [__('East Caribbean Dollar', 'pdf'), '$', false],
- 'XPF' => [__('CFP Franc', 'pdf'), '₣', false],
- 'YER' => [__('Yemeni Rial', 'pdf'), '﷼'],
- 'ZAR' => [__('Rand', 'pdf'), 'R'],
- 'ZMW' => [__('Zambian Kwacha', 'pdf'), 'ZK'],
- 'ZWL' => [__('Zimbabwe Dollar', 'pdf'), '$', false]];
+ return ['AED' => [__s('UAE Dirham', 'pdf'), 'د.إ', false],
+ 'AFN' => [__s('Afghani', 'pdf'), 'Af'],
+ 'ALL' => [__s('Lek', 'pdf'), 'L', false],
+ 'AMD' => [__s('Armenian Dram', 'pdf'), 'Դ'],
+ 'AOA' => [__s('Kwanza', 'pdf'), 'Kz'],
+ 'ARS' => [__s('Argentine Peso', 'pdf'), '$', false],
+ 'AUD' => [__s('Australian Dollar', 'pdf'), '$', false],
+ 'AWG' => [__s('Aruban Guilder/Florin', 'pdf'), 'ƒ'],
+ 'AZN' => [__s('Azerbaijanian Manat', 'pdf'), 'ман'],
+ 'BAM' => [__s('Konvertibilna Marka', 'pdf'), 'КМ'],
+ 'BBD' => [__s('Barbados Dollar', 'pdf'), '$', false],
+ 'BDT' => [__s('Taka', 'pdf'), '৳'],
+ 'BGN' => [__s('Bulgarian Lev', 'pdf'), 'лв'],
+ 'BHD' => [__s('Bahraini Dinar', 'pdf'), 'ب.د'],
+ 'BIF' => [__s('Burundi Franc', 'pdf'), '₣', false],
+ 'BMD' => [__s('Bermudian Dollar', 'pdf'), '$', false],
+ 'BND' => [__s('Brunei Dollar', 'pdf'), '$', false],
+ 'BOB' => [__s('Boliviano', 'pdf'), 'Bs.'],
+ 'BRL' => [__s('Brazilian Real', 'pdf'), 'R$'],
+ 'BSD' => [__s('Bahamian Dollar', 'pdf'), '$', false],
+ 'BTN' => [__s('Ngultrum', 'pdf'), ''],
+ 'BWP' => [__s('Pula', 'pdf'), 'P', false],
+ 'BYR' => [__s('Belarussian Ruble', 'pdf'), 'Br.'],
+ 'BZD' => [__s('Belize Dollar', 'pdf'), '$', false],
+ 'CAD' => [__s('Canadian Dollar', 'pdf'), '$', false],
+ 'CDF' => [__s('Congolese Franc', 'pdf'), 'F', false],
+ 'CHF' => [__s('Swiss Franc', 'pdf'), 'F', false],
+ 'CLP' => [__s('Chilean Peso', 'pdf'), '$', false],
+ 'CNY' => [__s('Yuan', 'pdf'), '¥'],
+ 'COP' => [__s('Colombian Peso', 'pdf'), '$', false],
+ 'CRC' => [__s('Costa Rican Colon', 'pdf'), '₡'],
+ 'CUP' => [__s('Cuban Peso', 'pdf'), '$', false],
+ 'CVE' => [__s('Cape Verde Escudo', 'pdf'), '$', false],
+ 'CZK' => [__s('Czech Koruna', 'pdf'), 'Kč'],
+ 'DJF' => [__s('Djibouti Franc', 'pdf'), '₣', false],
+ 'DKK' => [__s('Danish Krone', 'pdf'), 'kr', false],
+ 'DOP' => [__s('Dominican Peso', 'pdf'), '$', false],
+ 'DZD' => [__s('Algerian Dinar', 'pdf'), 'د.ج'],
+ 'EGP' => [__s('Egyptian Pound', 'pdf'), '£', false],
+ 'ERN' => [__s('Nakfa', 'pdf'), 'Nfk'],
+ 'ETB' => [__s('Ethiopian Birr', 'pdf'), ''],
+ 'EUR' => [__s('Euro', 'pdf'), '€'],
+ 'FJD' => [__s('Fiji Dollar', 'pdf'), '$', false],
+ 'FKP' => [__s('Falkland Islands Pound', 'pdf'), '£', false],
+ 'GBP' => [__s('Pound Sterling', 'pdf'), '£', false],
+ 'GEL' => [__s('Lari', 'pdf'), 'ლ'],
+ 'GHS' => [__s('Cedi', 'pdf'), '₵'],
+ 'GIP' => [__s('Gibraltar Pound', 'pdf'), '£', false],
+ 'GMD' => [__s('Dalasi', 'pdf'), 'D'],
+ 'GNF' => [__s('Guinea Franc', 'pdf'), '₣', false],
+ 'GTQ' => [__s('Quetzal', 'pdf'), 'Q'],
+ 'HKD' => [__s('Hong Kong Dollar', 'pdf'), '$', false],
+ 'HNL' => [__s('Lempira', 'pdf'), 'L', false],
+ 'HRK' => [__s('Croatian Kuna', 'pdf'), 'Kn'],
+ 'HTG' => [__s('Gourde', 'pdf'), 'G'],
+ 'HUF' => [__s('Forint', 'pdf'), 'Ft'],
+ 'IDR' => [__s('Rupiah', 'pdf'), 'Rp'],
+ 'ILS' => [__s('New Israeli Shekel', 'pdf'), '₪'],
+ 'INR' => [__s('Indian Rupee', 'pdf'), '₨', false],
+ 'IQD' => [__s('Iraqi Dinar', 'pdf'), 'ع.د'],
+ 'IRR' => [__s('Iranian Rial', 'pdf'), '﷼'],
+ 'ISK' => [__s('Iceland Krona', 'pdf'), 'Kr', false],
+ 'JMD' => [__s('Jamaican Dollar', 'pdf'), '$', false],
+ 'JOD' => [__s('Jordanian Dinar', 'pdf'), 'د.ا', false],
+ 'JPY' => [__s('Yen', 'pdf'), '¥'],
+ 'KES' => [__s('Kenyan Shilling', 'pdf'), 'Sh', false],
+ 'KGS' => [__s('Som', 'pdf'), ''],
+ 'KHR' => [__s('Riel', 'pdf'), '៛'],
+ 'KPW' => [__s('North Korean Won', 'pdf'), '₩', false],
+ 'KRW' => [__s('South Korean Won', 'pdf'), '₩', false],
+ 'KWD' => [__s('Kuwaiti Dinar', 'pdf'), 'د.ك'],
+ 'KYD' => [__s('Cayman Islands Dollar', 'pdf'), '$', false],
+ 'KZT' => [__s('Tenge', 'pdf'), '〒'],
+ 'LAK' => [__s('Kip', 'pdf'), '₭'],
+ 'LBP' => [__s('Lebanese Pound', 'pdf'), '£L'],
+ 'LKR' => [__s('Sri Lanka Rupee', 'pdf'), 'Rs'],
+ 'LRD' => [__s('Liberian Dollar', 'pdf'), '$', false],
+ 'LSL' => [__s('Loti', 'pdf'), 'L', false],
+ 'LYD' => [__s('Libyan Dinar', 'pdf'), 'ل.د'],
+ 'MAD' => [__s('Moroccan Dirham', 'pdf'), 'د.م.'],
+ 'MDL' => [__s('Moldavian Leu', 'pdf'), 'L', false],
+ 'MGA' => [__s('Malagasy Ariary', 'pdf'), ''],
+ 'MKD' => [__s('Denar', 'pdf'), 'ден'],
+ 'MMK' => [__s('Kyat', 'pdf'), 'K', false],
+ 'MNT' => [__s('Tugrik', 'pdf'), '₮'],
+ 'MOP' => [__s('Pataca', 'pdf'), 'P', false],
+ 'MRO' => [__s('Ouguiya', 'pdf'), 'UM'],
+ 'MUR' => [__s('Mauritius Rupee', 'pdf'), '₨', false],
+ 'MVR' => [__s('Rufiyaa', 'pdf'), 'ރ.'],
+ 'MWK' => [__s('Kwacha', 'pdf'), 'MK'],
+ 'MXN' => [__s('Mexican Peso', 'pdf'), '$', false],
+ 'MYR' => [__s('Malaysian Ringgit', 'pdf'), 'RM'],
+ 'MZN' => [__s('Metical', 'pdf'), 'MTn'],
+ 'NAD' => [__s('Namibia Dollar', 'pdf'), '$', false],
+ 'NGN' => [__s('Naira', 'pdf'), '₦'],
+ 'NIO' => [__s('Cordoba Oro', 'pdf'), 'C$'],
+ 'NOK' => [__s('Norwegian Krone', 'pdf'), 'kr', false],
+ 'NPR' => [__s('Nepalese Rupee', 'pdf'), '₨', false],
+ 'NZD' => [__s('New Zealand Dollar', 'pdf'), '$', false],
+ 'OMR' => [__s('Rial Omani', 'pdf'), 'ر.ع.'],
+ 'PAB' => [__s('Balboa', 'pdf'), 'B/.'],
+ 'PEN' => [__s('Nuevo Sol', 'pdf'), 'S/.'],
+ 'PGK' => [__s('Kina', 'pdf'), 'K', false],
+ 'PHP' => [__s('Philippine Peso', 'pdf'), '₱'],
+ 'PKR' => [__s('Pakistan Rupee', 'pdf'), '₨', false],
+ 'PLN' => [__s('PZloty', 'pdf'), 'zł'],
+ 'PYG' => [__s('Guarani', 'pdf'), '₲'],
+ 'QAR' => [__s('Qatari Rial', 'pdf'), 'ر.ق'],
+ 'RON' => [__s('Leu', 'pdf'), 'L', false],
+ 'RSD' => [__s('Serbian Dinar', 'pdf'), 'din'],
+ 'RUB' => [__s('Russian Ruble', 'pdf'), 'р.'],
+ 'RWF' => [__s('Rwanda Franc', 'pdf'), 'F', false],
+ 'SAR' => [__s('Saudi Riyal', 'pdf'), 'ر.س '],
+ 'SBD' => [__s('Solomon Islands Dollar', 'pdf'), '$', false],
+ 'SCR' => [__s('Seychelles Rupee', 'pdf'), '₨', false],
+ 'SDG' => [__s('Sudanese', 'pdf'), '£', false],
+ 'SEK' => [__s('Swedish Krona', 'pdf'), 'kr', false],
+ 'SGD' => [__s('Singapore Dollar', 'pdf'), '$', false],
+ 'SHP' => [__s('Saint Helena Pound', 'pdf'), '£', false],
+ 'SLL' => [__s('leone', 'pdf'), 'Le'],
+ 'SOS' => [__s('Somali Shilling', 'pdf'), 'Sh', false],
+ 'SRD' => [__s('Suriname Dollar', 'pdf'), '$', false],
+ 'STD' => [__s('Dobra', 'pdf'), 'Db'],
+ 'SYP' => [__s('Syrian Pound', 'pdf'), 'ل.س'],
+ 'SZL' => [__s('Lilangeni', 'pdf'), 'L', false],
+ 'THB' => [__s('Baht', 'pdf'), '฿'],
+ 'TJS' => [__s('Somoni', 'pdf'), 'ЅМ'],
+ 'TMT' => [__s('Manat', 'pdf'), 'm'],
+ 'TND' => [__s('Tunisian Dinar', 'pdf'), 'د.ت'],
+ 'TOP' => [__s('Pa’anga', 'pdf'), 'T$'],
+ 'TRY' => [__s('Turkish Lira', 'pdf'), '₤', false],
+ 'TTD' => [__s('Trinidad and Tobago Dollar', 'pdf'), '$', false],
+ 'TWD' => [__s('Taiwan Dollar', 'pdf'), '$', false],
+ 'TZS' => [__s('Tanzanian Shilling', 'pdf'), 'Sh', false],
+ 'UAH' => [__s('Hryvnia', 'pdf'), '₴'],
+ 'UGX' => [__s('Uganda Shilling', 'pdf'), 'Sh', false],
+ 'USD' => [__s('US Dollar', 'pdf'), '$', false],
+ 'UYU' => [__s('Peso Uruguayo', 'pdf'), '$', false],
+ 'UZS' => [__s('Uzbekistan Sum', 'pdf'), ''],
+ 'VEF' => [__s('Bolivar Fuerte', 'pdf'), 'Bs F'],
+ 'VND' => [__s('Dong', 'pdf'), '₫'],
+ 'VUV' => [__s('Vatu', 'pdf'), 'Vt'],
+ 'WST' => [__s('Tala', 'pdf'), 'T'],
+ 'XAF' => [__s('CFA Franc BCEAO', 'pdf'), '₣', false],
+ 'XCD' => [__s('East Caribbean Dollar', 'pdf'), '$', false],
+ 'XPF' => [__s('CFP Franc', 'pdf'), '₣', false],
+ 'YER' => [__s('Yemeni Rial', 'pdf'), '﷼'],
+ 'ZAR' => [__s('Rand', 'pdf'), 'R'],
+ 'ZMW' => [__s('Zambian Kwacha', 'pdf'), 'ZK'],
+ 'ZWL' => [__s('Zimbabwe Dollar', 'pdf'), '$', false]];
}
public static function formatNumber($value)
@@ -393,12 +396,9 @@ public static function currencyName()
global $PDF_DEVICES;
$config = self::getInstance();
- $name = '';
foreach ($PDF_DEVICES as $option => $value) {
- if ($config->getField('currency') == $option) {
- if (isset($value[2])) {
- return $value[0];
- }
+ if ($config->getField('currency') == $option && isset($value[2])) {
+ return $value[0];
}
}
}
diff --git a/inc/consumableitem.class.php b/inc/consumableitem.class.php
index 74df805..991a641 100644
--- a/inc/consumableitem.class.php
+++ b/inc/consumableitem.class.php
@@ -36,7 +36,7 @@ class PluginPdfConsumableItem extends PluginPdfCommon
public function __construct(?CommonGLPI $obj = null)
{
- $this->obj = ($obj ? $obj : new CartridgeItem());
+ $this->obj = ($obj ?: new CartridgeItem());
}
public function defineAllTabsPDF($options = [])
@@ -53,10 +53,10 @@ public static function pdfMain(PluginPdfSimplePDF $pdf, ConsumableItem $consitem
PluginPdfCommon::mainTitle($pdf, $consitem);
$pdf->displayLine(
- '' . sprintf(__('%1$s: %2$s'), __('Name') . '', $consitem->fields['name']),
+ '' . sprintf(__s('%1$s: %2$s'), __s('Name') . '', $consitem->fields['name']),
'' . sprintf(
- __('%1$s: %2$s'),
- __('Type') . '',
+ __s('%1$s: %2$s'),
+ __s('Type') . '',
Toolbox::stripTags(Dropdown::getDropdownName(
'glpi_consumableitemtypes',
$consitem->fields['consumableitemtypes_id'],
@@ -64,10 +64,10 @@ public static function pdfMain(PluginPdfSimplePDF $pdf, ConsumableItem $consitem
),
);
$pdf->displayLine(
- '' . sprintf(__('%1$s: %2$s'), __('Reference') . '', $consitem->fields['ref']),
+ '' . sprintf(__s('%1$s: %2$s'), __s('Reference') . '', $consitem->fields['ref']),
'' . sprintf(
- __('%1$s: %2$s'),
- __('Manufacturer') . '',
+ __s('%1$s: %2$s'),
+ __s('Manufacturer') . '',
Toolbox::stripTags(Dropdown::getDropdownName(
'glpi_manufacturers',
$consitem->fields['manufacturers_id'],
@@ -77,13 +77,13 @@ public static function pdfMain(PluginPdfSimplePDF $pdf, ConsumableItem $consitem
$pdf->displayLine(
'' . sprintf(
- __('%1$s: %2$s'),
- __('Technician in charge of the hardware') . '',
+ __s('%1$s: %2$s'),
+ __s('Technician in charge of the hardware') . '',
$dbu->getUserName($consitem->fields['users_id_tech']),
),
'' . sprintf(
- __('%1$s: %2$s'),
- __('Group in charge of the hardware') . '',
+ __s('%1$s: %2$s'),
+ __s('Group in charge of the hardware') . '',
Dropdown::getDropdownName(
'glpi_groups',
$consitem->fields['groups_id_tech'],
@@ -93,24 +93,24 @@ public static function pdfMain(PluginPdfSimplePDF $pdf, ConsumableItem $consitem
$pdf->displayLine(
'' . sprintf(
- __('%1$s: %2$s'),
- __('Stock location') . '',
+ __s('%1$s: %2$s'),
+ __s('Stock location') . '',
Dropdown::getDropdownName(
'glpi_locations',
$consitem->fields['locations_id'],
),
),
'' . sprintf(
- __('%1$s: %2$s'),
- __('Alert threshold') . '',
+ __s('%1$s: %2$s'),
+ __s('Alert threshold') . '',
$consitem->getField('alarm_threshold'),
),
);
$pdf->displayLine(
'' . sprintf(
- __('%1$s: %2$s'),
- __('Inventory number') . '',
+ __s('%1$s: %2$s'),
+ __s('Inventory number') . '',
$consitem->fields['otherserial'],
),
);
@@ -161,54 +161,53 @@ public static function pdfForConsumableItem(PluginPdfSimplePDF $pdf, ConsumableI
$number = $dbu->countElementsInTable('glpi_consumables', $where);
$iterator = $DB->request(
- 'glpi_consumables',
- ['WHERE' => $where,
+ ['FROM' => 'glpi_consumables'] + ['WHERE' => $where,
'ORDER' => $order],
);
if (!$number) {
$pdf->setColumnsSize(100);
- $pdf->displayTitle(__('No consumable'));
+ $pdf->displayTitle(__s('No consumable'));
} else {
if (!$show_old) {
$pdf->setColumnsSize(50, 50);
$pdf->displayTitle(
'' . sprintf(
- __('%1$s: %2$s'),
- __('Total'),
+ __s('%1$s: %2$s'),
+ __s('Total'),
Consumable::getTotalNumber($instID),
) . '',
'' . sprintf(
- __('%1$s: %2$s'),
+ __s('%1$s: %2$s'),
_nx('consumable', 'New', 'New', $instID),
Consumable::getUnusedNumber($instID),
) . '',
);
$pdf->displayTitle('', '' . sprintf(
- __('%1$s: %2$s'),
+ __s('%1$s: %2$s'),
_nx('consumable', 'Used', 'Used', $instID),
Consumable::getOldNumber($instID),
));
} else { // Old
$pdf->setColumnsSize(100);
- $pdf->displayTitle('' . __('Used consumables') . '');
+ $pdf->displayTitle('' . __s('Used consumables') . '');
}
if (!$show_old) {
$pdf->setColumnsSize(10, 45, 45);
$pdf->displayLine(
- '' . __('ID') . '',
+ '' . __s('ID') . '',
'' . _x('item', 'State') . '',
- '' . __('Add date') . '',
+ '' . __s('Add date') . '',
);
} else {
$pdf->setColumnsSize(8, 23, 23, 23, 23);
$pdf->displayLine(
- '' . __('ID') . '',
+ '' . __s('ID') . '',
'' . _x('item', 'State') . '',
- '' . __('Add date') . '',
- '' . __('Use date') . '',
- '' . __('Given to') . '',
+ '' . __s('Add date') . '',
+ '' . __s('Use date') . '',
+ '' . __s('Given to') . '',
);
}
@@ -221,10 +220,8 @@ public static function pdfForConsumableItem(PluginPdfSimplePDF $pdf, ConsumableI
$pdf->displayLine($data['id'], Consumable::getStatus($data['id']), $date_in);
} else {
$name = '';
- if ($item = getItemForItemtype($data['itemtype'])) {
- if ($item->getFromDB($data['items_id'])) {
- $name = $item->getNameID();
- }
+ if (($item = getItemForItemtype($data['itemtype'])) && $item->getFromDB($data['items_id'])) {
+ $name = $item->getNameID();
}
$pdf->setColumnsSize(8, 23, 23, 23, 23);
$pdf->displayLine(
diff --git a/inc/contract.class.php b/inc/contract.class.php
index 3461060..c44664a 100644
--- a/inc/contract.class.php
+++ b/inc/contract.class.php
@@ -36,7 +36,7 @@ class PluginPdfContract extends PluginPdfCommon
public function __construct(?CommonGLPI $obj = null)
{
- $this->obj = ($obj ? $obj : new Contract());
+ $this->obj = ($obj ?: new Contract());
}
public function defineAllTabsPDF($options = [])
@@ -49,15 +49,13 @@ public function defineAllTabsPDF($options = [])
public static function pdfMain(PluginPdfSimplePDF $pdf, Contract $contract)
{
- $dbu = new DbUtils();
-
PluginPdfCommon::mainTitle($pdf, $contract);
$pdf->displayLine(
- '' . sprintf(__('%1$s: %2$s'), __('Name') . '', $contract->fields['name']),
+ '' . sprintf(__s('%1$s: %2$s'), __s('Name') . '', $contract->fields['name']),
'' . sprintf(
- __('%1$s: %2$s'),
- __('Status') . '',
+ __s('%1$s: %2$s'),
+ __s('Status') . '',
Toolbox::stripTags(Dropdown::getDropdownName(
'glpi_states',
$contract->fields['states_id'],
@@ -67,15 +65,15 @@ public static function pdfMain(PluginPdfSimplePDF $pdf, Contract $contract)
$pdf->displayLine(
'' . sprintf(
- __('%1$s: %2$s'),
- __('Contract type') . '',
+ __s('%1$s: %2$s'),
+ __s('Contract type') . '',
Toolbox::stripTags(Dropdown::getDropdownName(
'glpi_contracttypes',
$contract->fields['contracttypes_id'],
)),
),
'' . sprintf(
- __('%1$s: %2$s'),
+ __s('%1$s: %2$s'),
_x('phone', 'Number') . '',
$contract->fields['num'],
),
@@ -84,7 +82,7 @@ public static function pdfMain(PluginPdfSimplePDF $pdf, Contract $contract)
$textduration = '';
if (!empty($contract->fields['begin_date'])) {
$textduration = sprintf(
- __('%1$s %2$s'),
+ __s('%1$s %2$s'),
' -> ',
Infocom::getWarrantyExpir(
$contract->fields['begin_date'],
@@ -94,15 +92,15 @@ public static function pdfMain(PluginPdfSimplePDF $pdf, Contract $contract)
}
$pdf->displayLine(
'' . sprintf(
- __('%1$s: %2$s'),
- __('Start date') . '',
+ __s('%1$s: %2$s'),
+ __s('Start date') . '',
Html::convDate($contract->fields['begin_date']),
),
'' . sprintf(
- __('%1$s: %2$s'),
- __('Initial contract period') . '',
+ __s('%1$s: %2$s'),
+ __s('Initial contract period') . '',
sprintf(
- _n('%d month', '%d months', $contract->fields['duration']),
+ _sn('%d month', '%d months', $contract->fields['duration']),
$contract->fields['duration'],
) . $textduration,
),
@@ -110,7 +108,7 @@ public static function pdfMain(PluginPdfSimplePDF $pdf, Contract $contract)
if (!empty($contract->fields['begin_date']) && ($contract->fields['notice'] > 0)) {
$textduration = sprintf(
- __('%1$s %2$s'),
+ __s('%1$s %2$s'),
' -> ',
Infocom::getWarrantyExpir(
$contract->fields['begin_date'],
@@ -121,34 +119,34 @@ public static function pdfMain(PluginPdfSimplePDF $pdf, Contract $contract)
}
$pdf->displayLine(
'' . sprintf(
- __('%1$s: %2$s'),
- __('Notice') . '',
+ __s('%1$s: %2$s'),
+ __s('Notice') . '',
sprintf(
- _n('%d month', '%d months', $contract->fields['notice']),
+ _sn('%d month', '%d months', $contract->fields['notice']),
$contract->fields['notice'],
) . $textduration,
),
'' . sprintf(
- __('%1$s: %2$s'),
- __('Account number') . '',
+ __s('%1$s: %2$s'),
+ __s('Account number') . '',
$contract->fields['accounting_number'],
),
);
$pdf->displayLine(
'' . sprintf(
- __('%1$s: %2$s'),
- __('Contract renewal period') . '',
+ __s('%1$s: %2$s'),
+ __s('Contract renewal period') . '',
sprintf(
- _n('%d month', '%d months', $contract->fields['periodicity']),
+ _sn('%d month', '%d months', $contract->fields['periodicity']),
$contract->fields['periodicity'],
),
),
'' . sprintf(
- __('%1$s: %2$s'),
- __('Invoice period') . '',
+ __s('%1$s: %2$s'),
+ __s('Invoice period') . '',
sprintf(
- _n('%d month', '%d months', $contract->fields['billing']),
+ _sn('%d month', '%d months', $contract->fields['billing']),
$contract->fields['billing'],
),
),
@@ -156,13 +154,13 @@ public static function pdfMain(PluginPdfSimplePDF $pdf, Contract $contract)
$pdf->displayLine(
'' . sprintf(
- __('%1$s: %2$s'),
- __('Renewal') . '',
+ __s('%1$s: %2$s'),
+ __s('Renewal') . '',
Contract::getContractRenewalName($contract->fields['renewal']),
),
'' . sprintf(
- __('%1$s: %2$s'),
- __('Max number of items') . '',
+ __s('%1$s: %2$s'),
+ __s('Max number of items') . '',
$contract->fields['max_links_allowed'],
),
);
@@ -170,8 +168,8 @@ public static function pdfMain(PluginPdfSimplePDF $pdf, Contract $contract)
if (Entity::getUsedConfig('use_contracts_alert', $contract->fields['entities_id'])) {
$pdf->displayLine(
'' . sprintf(
- __('%1$s: %2$s'),
- __('Email alarms') . '',
+ __s('%1$s: %2$s'),
+ __s('Email alarms') . '',
($contract->fields['alert'] > 0) ? $contract->fields['alert'] : '',
),
);
@@ -215,12 +213,12 @@ public static function pdfCost(PluginPdfSimplePDF $pdf, Contract $contract)
$number = count($result);
- if (!$number) {
+ if ($number === 0) {
$pdf->setColumnsSize(100);
$pdf->displayTitle(sprintf(
- __('%1$s: %2$s'),
+ __s('%1$s: %2$s'),
'' . ContractCost::getTypeName(2) . '',
- __('No item to display'),
+ __s('No item to display'),
));
} else {
$pdf->setColumnsSize(100);
@@ -230,11 +228,11 @@ public static function pdfCost(PluginPdfSimplePDF $pdf, Contract $contract)
$pdf->setColumnsAlign('left', 'center', 'center', 'left', 'right');
$pdf->displayTitle(
- '' . __('Name') . '',
- '' . __('Begin date') . '',
- '' . __('End date') . '',
+ '' . __s('Name') . '',
+ '' . __s('Begin date') . '',
+ '' . __s('End date') . '',
'' . Budget::getTypeName(1) . '',
- '' . _n('Cost', 'Costs', 1) . '',
+ '' . _sn('Cost', 'Costs', 1) . '',
);
$total = 0;
@@ -255,7 +253,7 @@ public static function pdfCost(PluginPdfSimplePDF $pdf, Contract $contract)
$pdf->setColumnsSize(81, 19);
$pdf->setColumnsAlign('right', 'right');
$pdf->displayLine(
- '' . __('Total cost') . '',
+ '' . __s('Total cost') . '',
'' . PluginPdfConfig::formatNumber($total) . '',
);
}
diff --git a/inc/contract_item.class.php b/inc/contract_item.class.php
index daa8366..ed33e58 100644
--- a/inc/contract_item.class.php
+++ b/inc/contract_item.class.php
@@ -36,7 +36,7 @@ class PluginPdfContract_Item extends PluginPdfCommon
public function __construct(?CommonGLPI $obj = null)
{
- $this->obj = ($obj ? $obj : new Contract_Item());
+ $this->obj = ($obj ?: new Contract_Item());
}
public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
@@ -46,7 +46,7 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
$type = $item->getType();
$ID = $item->getField('id');
- $itemtable = getTableForItemType($type);
+ getTableForItemType($type);
$con = new Contract();
$dbu = new DbUtils();
@@ -64,21 +64,21 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
$number = count($result);
$pdf->setColumnsSize(100);
- $title = '' . _n('Associated contract', 'Associated contracts', $number) . '';
- if (!$number) {
- $pdf->displayTitle(sprintf(__('%1$s: %2$s'), $title, __('No item to display')));
+ $title = '' . _sn('Associated contract', 'Associated contracts', $number) . '';
+ if ($number === 0) {
+ $pdf->displayTitle(sprintf(__s('%1$s: %2$s'), $title, __s('No item to display')));
} else {
- $pdf->displayTitle(sprintf(__('%1$s: %2$s'), $title, $number));
+ $pdf->displayTitle(sprintf(__s('%1$s: %2$s'), $title, $number));
$pdf->setColumnsSize(19, 19, 15, 10, 16, 11, 10);
$pdf->displayTitle(
- __('Name'),
- __('Entity'),
+ __s('Name'),
+ __s('Entity'),
_x('phone', 'Number'),
- __('Contract type'),
- __('Supplier'),
- __('Start date'),
- __('Initial contract period'),
+ __s('Contract type'),
+ __s('Supplier'),
+ __s('Start date'),
+ __s('Initial contract period'),
);
foreach ($result as $row) {
@@ -89,7 +89,7 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
$textduration = '';
if ($con->fields['duration'] > 0) {
$textduration = sprintf(
- __('Valid to %s'),
+ __s('Valid to %s'),
Infocom::getWarrantyExpir(
$con->fields['begin_date'],
$con->fields['duration'],
@@ -107,9 +107,9 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
str_replace('
', ' ', $con->getSuppliersNames()),
Html::convDate($con->fields['begin_date']),
sprintf(
- __('%1$s - %2$s'),
+ __s('%1$s - %2$s'),
sprintf(
- _n('%d month', '%d months', $con->fields['duration']),
+ _sn('%d month', '%d months', $con->fields['duration']),
$con->fields['duration'],
),
$textduration,
@@ -202,22 +202,22 @@ public static function pdfForContract(PluginPdfSimplePDF $pdf, Contract $contrac
}
$pdf->setColumnsSize(100);
- $title = '' . _n('Item', 'Items', $number) . '';
+ $title = '' . _sn('Item', 'Items', $number) . '';
- if (!$number) {
- $pdf->displayTitle(sprintf(__('%1$s: %2$s'), $title, __('No item to display')));
+ if ($number === 0) {
+ $pdf->displayTitle(sprintf(__s('%1$s: %2$s'), $title, __s('No item to display')));
} else {
- $title = sprintf(__('%1$s: %2$s'), $title, $number);
+ $title = sprintf(__s('%1$s: %2$s'), $title, $number);
$pdf->displayTitle($title);
$pdf->setColumnsSize(15, 18, 29, 15, 15, 8);
$pdf->displayTitle(
- '' . __('Type') . '',
- '' . __('Name') . '',
- '' . __('Entity') . '',
- '' . __('Serial number') . '',
- '' . __('Inventory number') . '',
- '' . __('Status') . '',
+ '' . __s('Type') . '',
+ '' . __s('Name') . '',
+ '' . __s('Entity') . '',
+ '' . __s('Serial number') . '',
+ '' . __s('Inventory number') . '',
+ '' . __s('Status') . '',
);
$totalnb = 0;
@@ -228,20 +228,20 @@ public static function pdfForContract(PluginPdfSimplePDF $pdf, Contract $contrac
$prem = true;
$nb = count($datas);
foreach ($datas as $objdata) {
- $item = new $itemtype();
- if ($item instanceof Item_Devices) {
- $name = $objdata['name_device'];
- } else {
- $name = $objdata['name'];
+ $dbu = new DbUtils();
+ $item = $dbu->getItemForItemtype($itemtype);
+ if (!$item) {
+ continue;
}
+ $name = $item instanceof Item_Devices ? $objdata['name_device'] : $objdata['name'];
if (empty($data['name'])) {
- $name = sprintf(__('%1$s (%2$s)'), $name, $objdata['id']);
+ $name = sprintf(__s('%1$s (%2$s)'), $name, $objdata['id']);
}
if ($prem) {
$typename = $item->getTypeName($nb);
$pdf->displayLine(
- Toolbox::stripTags(sprintf(__('%1$s: %2$s'), $typename, $nb)),
+ Toolbox::stripTags(sprintf(__s('%1$s: %2$s'), $typename, $nb)),
Toolbox::stripTags($name),
Dropdown::getDropdownName('glpi_entities', $objdata['entity']),
Toolbox::stripTags((isset($objdata['serial'])
diff --git a/inc/document.class.php b/inc/document.class.php
index 1b45280..418cd12 100644
--- a/inc/document.class.php
+++ b/inc/document.class.php
@@ -36,7 +36,7 @@ class PluginPdfDocument extends PluginPdfCommon
public function __construct(?CommonGLPI $obj = null)
{
- $this->obj = ($obj ? $obj : new Document());
+ $this->obj = ($obj ?: new Document());
}
public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
@@ -48,8 +48,7 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
$type = get_class($item);
$result = $DB->request(
- 'glpi_documents_items',
- ['SELECT' => ['glpi_documents_items.id',
+ ['FROM' => 'glpi_documents_items'] + ['SELECT' => ['glpi_documents_items.id',
'glpi_documents_items.date_mod',
'glpi_documents.*', 'glpi_entities.id',
'completename'],
@@ -67,27 +66,27 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
$number = count($result);
$pdf->setColumnsSize(100);
- $title = '' . _n('Document', 'Documents', $number) . '';
- if (!$number) {
- $pdf->displayTitle(sprintf(__('%1$s: %2$s'), $title, __('No item to display')));
+ $title = '' . _sn('Document', 'Documents', $number) . '';
+ if ($number === 0) {
+ $pdf->displayTitle(sprintf(__s('%1$s: %2$s'), $title, __s('No item to display')));
} else {
if ($number > $_SESSION['glpilist_limit']) {
- $title = sprintf(__('%1$s: %2$s'), $title, $_SESSION['glpilist_limit'] . ' / ' . $number);
+ $title = sprintf(__s('%1$s: %2$s'), $title, $_SESSION['glpilist_limit'] . ' / ' . $number);
} else {
- $title = sprintf(__('%1$s: %2$s'), $title, $number);
+ $title = sprintf(__s('%1$s: %2$s'), $title, $number);
}
$pdf->displayTitle($title);
$pdf->setColumnsSize(20, 15, 10, 10, 10, 8, 20, 7);
$pdf->displayTitle(
- __('Name'),
- __('Entity'),
- __('File'),
- __('Web link'),
- __('Heading'),
- __('MIME type'),
- __('Tag'),
- __('Date'),
+ __s('Name'),
+ __s('Entity'),
+ __s('File'),
+ __s('Web link'),
+ __s('Heading'),
+ __s('MIME type'),
+ __s('Tag'),
+ __s('Date'),
);
foreach ($result as $data) {
if (empty($data['link'])) {
diff --git a/inc/domain_item.class.php b/inc/domain_item.class.php
index 4cfd664..22e5456 100644
--- a/inc/domain_item.class.php
+++ b/inc/domain_item.class.php
@@ -36,7 +36,7 @@ class PluginPdfDomain_Item extends PluginPdfCommon
public function __construct(?CommonGLPI $obj = null)
{
- $this->obj = ($obj ? $obj : new Domain_Item());
+ $this->obj = ($obj ?: new Domain_Item());
}
public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
@@ -62,26 +62,26 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
$pdf->setColumnsSize(100);
$title = '' . Domain::getTypeName($number) . '';
- if (!$number) {
- $pdf->displayTitle(sprintf(__('%1$s: %2$s'), $title, __('No item to display')));
+ if ($number === 0) {
+ $pdf->displayTitle(sprintf(__s('%1$s: %2$s'), $title, __s('No item to display')));
} else {
if ($number > $_SESSION['glpilist_limit']) {
- $title = sprintf(__('%1$s: %2$s'), $title, $_SESSION['glpilist_limit'] . ' / ' . $number);
+ $title = sprintf(__s('%1$s: %2$s'), $title, $_SESSION['glpilist_limit'] . ' / ' . $number);
} else {
- $title = sprintf(__('%1$s: %2$s'), $title, $number);
+ $title = sprintf(__s('%1$s: %2$s'), $title, $number);
}
$pdf->displayTitle($title);
$pdf->setColumnsSize(17, 15, 10, 10, 8, 8, 16, 16);
$pdf->displayTitle(
- __('Name'),
- __('Entity'),
- __('Group in charge'),
- __('Technician in charge'),
- __('Type'),
- __('Domain relation'),
- __('Creation date'),
- __('Expiration date'),
+ __s('Name'),
+ __s('Entity'),
+ __s('Group in charge'),
+ __s('Technician in charge'),
+ __s('Type'),
+ __s('Domain relation'),
+ __s('Creation date'),
+ __s('Expiration date'),
);
foreach ($result as $data) {
diff --git a/inc/group.class.php b/inc/group.class.php
index cd824bc..5b7e82c 100644
--- a/inc/group.class.php
+++ b/inc/group.class.php
@@ -36,84 +36,84 @@ class PluginPdfGroup extends PluginPdfCommon
public function __construct(?CommonGLPI $obj = null)
{
- $this->obj = ($obj ? $obj : new Group());
+ $this->obj = ($obj ?: new Group());
}
public static function pdfMain(PluginPdfSimplePDF $pdf, Group $item)
{
- $ID = $item->getField('id');
+ $item->getField('id');
$pdf->setColumnsSize(50, 50);
$pdf->displayTitle(
- '' . sprintf(__('%1$s %2$s'), __('ID'), $item->fields['id']) . '',
+ '' . sprintf(__s('%1$s %2$s'), __s('ID'), $item->fields['id']) . '',
sprintf(
- __('%1$s: %2$s'),
- __('Last update'),
+ __s('%1$s: %2$s'),
+ __s('Last update'),
Html::convDateTime($item->fields['date_mod']),
),
);
$pdf->setColumnsSize(100);
$pdf->displayLine('' . sprintf(
- __('%1$s: %2$s'),
- __('Complete name') . '',
+ __s('%1$s: %2$s'),
+ __s('Complete name') . '',
$item->fields['completename'],
));
$pdf->setColumnsAlign('center');
- $pdf->displayLine('' . sprintf(__('%1$s: %2$s'), __('Visible in a ticket'), '' . ''));
+ $pdf->displayLine('' . sprintf(__s('%1$s: %2$s'), __s('Visible in a ticket'), '' . ''));
$pdf->setColumnsSize(20, 20, 20, 20, 20);
$pdf->displayLine(
'' . sprintf(
- __('%1$s - %2$s'),
- __('Requester') . '',
+ __s('%1$s - %2$s'),
+ __s('Requester') . '',
Dropdown::getYesNo($item->fields['is_requester']),
),
'' . sprintf(
- __('%1$s - %2$s'),
- __('Watcher') . '',
+ __s('%1$s - %2$s'),
+ __s('Watcher') . '',
Dropdown::getYesNo($item->fields['is_watcher']),
),
'' . sprintf(
- __('%1$s - %2$s'),
- __('Assigned to') . '',
+ __s('%1$s - %2$s'),
+ __s('Assigned to') . '',
Dropdown::getYesNo($item->fields['is_assign']),
),
'' . sprintf(
- __('%1$s - %2$s'),
- __('Task') . '',
+ __s('%1$s - %2$s'),
+ __s('Task') . '',
Dropdown::getYesNo($item->fields['is_task']),
),
'' . sprintf(
- __('%1$s - %2$s'),
- __('Can be notified') . '',
+ __s('%1$s - %2$s'),
+ __s('Can be notified') . '',
Dropdown::getYesNo($item->fields['is_notify']),
),
);
$pdf->setColumnsSize(100);
$pdf->setColumnsAlign('center');
- $pdf->displayLine('' . sprintf(__('%1$s: %2$s'), __('Visible in a project'), ''));
+ $pdf->displayLine('' . sprintf(__s('%1$s: %2$s'), __s('Visible in a project'), ''));
$pdf->setColumnsAlign('left');
$pdf->displayLine('' . sprintf(
- __('%1$s - %2$s'),
- __('Can be manager') . '',
+ __s('%1$s - %2$s'),
+ __s('Can be manager') . '',
Dropdown::getYesNo($item->fields['is_manager']),
));
$pdf->setColumnsSize(100);
$pdf->setColumnsAlign('center');
- $pdf->displayLine('' . sprintf(__('%1$s: %2$s'), __('Can contain'), ''));
+ $pdf->displayLine('' . sprintf(__s('%1$s: %2$s'), __s('Can contain'), ''));
$pdf->setColumnsSize(50, 50);
$pdf->displayLine(
'' . sprintf(
- __('%1$s - %2$s'),
- _n('Item', 'Items', 2) . '',
+ __s('%1$s - %2$s'),
+ _sn('Item', 'Items', 2) . '',
Dropdown::getYesNo($item->fields['is_itemgroup']),
),
'' . sprintf(
- __('%1$s - %2$s'),
- _n('User', 'Users', 2) . '',
+ __s('%1$s - %2$s'),
+ _sn('User', 'Users', 2) . '',
Dropdown::getYesNo($item->fields['is_usergroup']),
),
);
@@ -128,22 +128,22 @@ public static function pdfLdapForm(PluginPdfSimplePDF $pdf, Group $item)
{
if (Session::haveRight('config', READ) && AuthLDAP::useAuthLdap()) {
$pdf->setColumnsSize(100);
- $pdf->displayTitle('' . __('LDAP directory link') . '');
+ $pdf->displayTitle('' . __s('LDAP directory link') . '');
$pdf->displayText(
'' . sprintf(
- __('%1$s: %2$s'),
- __('User attribute containing its groups') . '',
+ __s('%1$s: %2$s'),
+ __s('User attribute containing its groups') . '',
'',
),
$item->getField('ldap_field'),
);
$pdf->displayText(
- '' . sprintf(__('%1$s: %2$s'), __('Attribute value') . '', ''),
+ '' . sprintf(__s('%1$s: %2$s'), __s('Attribute value') . '', ''),
$item->getField('ldap_value'),
);
$pdf->displayText(
- '' . sprintf(__('%1$s: %2$s'), __('Group DN') . '', ''),
+ '' . sprintf(__s('%1$s: %2$s'), __s('Group DN') . '', ''),
$item->getField('ldap_group_dn'),
);
@@ -160,46 +160,40 @@ public static function pdfItems(PluginPdfSimplePDF $pdf, Group $group, $tech, $t
$dbu = new DbUtils();
if ($tech) {
- $types = $CFG_GLPI['linkgroup_tech_types'];
$field = 'groups_id_tech';
- $title = __('Managed items');
+ $title = __s('Managed items');
} else {
- $types = $CFG_GLPI['linkgroup_types'];
$field = 'groups_id';
- $title = __('Used items');
+ $title = __s('Used items');
}
$datas = [];
- $max = $group->getDataItems($types, $field, $tree, $user, 0, $datas);
+ $max = $group->getDataItems($tech, $tree, $user, 0, $datas);
$nb = count($datas);
- if ($nb < $max) {
- $title = sprintf(__('%1$s (%2$s)'), $title, $nb . '/' . $max);
- } else {
- $title = sprintf(__('%1$s (%2$s)'), $title, $nb);
- }
+ $title = $nb < $max ? sprintf(__s('%1$s (%2$s)'), $title, $nb . '/' . $max) : sprintf(__s('%1$s (%2$s)'), $title, $nb);
$pdf->setColumnsSize(100);
$pdf->displayTitle('' . $title . '');
- if ($nb) {
+ if ($nb !== 0) {
if ($tree || $user) {
$pdf->setColumnsSize(16, 20, 34, 30);
$pdf->displayTitle(
- __('Type'),
- __('Name'),
- __('Entity'),
+ __s('Type'),
+ __s('Name'),
+ __s('Entity'),
Group::getTypeName(1) . ' / ' . User::getTypeName(1),
);
} else {
$pdf->setColumnsSize(20, 25, 55);
- $pdf->displayTitle(__('Type'), __('Name'), __('Entity'));
+ $pdf->displayTitle(__s('Type'), __s('Name'), __s('Entity'));
}
} else {
- $pdf->displayLine(__('No item found'));
+ $pdf->displayLine(__s('No item found'));
}
$tmpgrp = new Group();
- $tmpusr = new User();
+ new User();
foreach ($datas as $data) {
if (!($item = $dbu->getItemForItemtype($data['itemtype']))) {
@@ -241,35 +235,38 @@ public static function pdfChildren(PluginPdfSimplePDF $pdf, CommonTreeDropdown $
/** @var DBmysql $DB */
global $DB;
- $ID = $item->getID();
- $fields = $item->getAdditionalFields();
- $nb = count($fields);
+ $item->getID();
+ $item->getAdditionalFields();
$entity_assign = $item->isEntityAssign();
$fk = $item->getForeignKeyField();
- $crit = [$fk => $item->getID(),
- 'ORDER' => 'name'];
+ $crit = [
+ 'FROM' => $item->getTable(),
+ 'WHERE' => [
+ $fk => $item->getID(),
+ ],
+ 'ORDER' => 'name',
+ ];
if ($item->haveChildren()) {
$pdf->setColumnsSize(100);
- $pdf->displayTitle(sprintf(__('Sons of %s'), '' . $item->getNameID() . ''));
+ $pdf->displayTitle(sprintf(__s('Sons of %s'), '' . $item->getNameID() . ''));
if ($entity_assign) {
if ($fk == 'entities_id') {
- $crit['id'] = $_SESSION['glpiactiveentities'];
- $crit['id'] += $_SESSION['glpiparententities'];
+ $crit['WHERE']['id'] = $_SESSION['glpiactiveentities'] + $_SESSION['glpiparententities'];
} else {
- $crit['entities_id'] = $_SESSION['glpiactiveentities'];
+ $crit['WHERE']['entities_id'] = $_SESSION['glpiactiveentities'];
}
$pdf->setColumnsSize(30, 30, 40);
- $pdf->displayTitle(__('Name'), __('Entity'), __('Comments'));
+ $pdf->displayTitle(__s('Name'), __s('Entity'), __s('Comments'));
} else {
$pdf->setColumnsSize(45, 55);
- $pdf->displayTitle(__('Name'), __('Comments'));
+ $pdf->displayTitle(__s('Name'), __s('Comments'));
}
- foreach ($DB->request($item->getTable(), $crit) as $data) {
+ foreach ($DB->request($crit) as $data) {
if ($entity_assign) {
$pdf->displayLine(
$data['name'],
@@ -282,7 +279,7 @@ public static function pdfChildren(PluginPdfSimplePDF $pdf, CommonTreeDropdown $
}
} else {
$pdf->setColumnsSize(100);
- $pdf->displayTitle('' . sprintf(__('No sons of %s', 'behaviors'), $item->getNameID() . ''));
+ $pdf->displayTitle('' . sprintf(__s('No sons of %s', 'behaviors'), $item->getNameID() . ''));
}
$pdf->displaySpace();
diff --git a/inc/group_user.class.php b/inc/group_user.class.php
index 730e0a8..a1d02b1 100644
--- a/inc/group_user.class.php
+++ b/inc/group_user.class.php
@@ -36,7 +36,7 @@ class PluginPdfGroup_User extends PluginPdfCommon
public function __construct(?CommonGLPI $obj = null)
{
- $this->obj = ($obj ? $obj : new Group_User());
+ $this->obj = ($obj ?: new Group_User());
}
public static function pdfForGroup(PluginPdfSimplePDF $pdf, Group $group, $tree)
@@ -46,20 +46,20 @@ public static function pdfForGroup(PluginPdfSimplePDF $pdf, Group $group, $tree)
$ids = [];
// Retrieve member list
- $entityrestrict = Group_User::getDataForGroup($group, $used, $ids, '', $tree);
+ Group_User::getDataForGroup($group, $used, $ids, '', $tree);
$number = count($used);
$pdf->setColumnsSize(100);
- $title = '' . _n('User', 'Users', 2) . '';
+ $title = '' . _sn('User', 'Users', 2) . '';
- if (!$number) {
- $pdf->displayTitle(sprintf(__('%1$s: %2$s'), $title, __('No item to display')));
+ if ($number === 0) {
+ $pdf->displayTitle(sprintf(__s('%1$s: %2$s'), $title, __s('No item to display')));
} else {
if ($number > $_SESSION['glpilist_limit']) {
- $title = sprintf(__('%1$s (%2$s)'), $title, $_SESSION['glpilist_limit'] . '/' . $number);
+ $title = sprintf(__s('%1$s (%2$s)'), $title, $_SESSION['glpilist_limit'] . '/' . $number);
} else {
- $title = sprintf(__('%1$s: %2$s'), $title, $number);
+ $title = sprintf(__s('%1$s: %2$s'), $title, $number);
}
$pdf->displayTitle($title);
@@ -71,19 +71,19 @@ public static function pdfForGroup(PluginPdfSimplePDF $pdf, Group $group, $tree)
$pdf->displayTitle(
User::getTypeName(1),
Group::getTypeName(1),
- __('Dynamic'),
- __('Manager'),
- __('Delegatee'),
- __('Active'),
+ __s('Dynamic'),
+ __s('Manager'),
+ __s('Delegatee'),
+ __s('Active'),
);
} else {
$pdf->setColumnsSize(40, 15, 15, 15, 15);
$pdf->displayTitle(
User::getTypeName(1),
- __('Dynamic'),
- __('Manager'),
- __('Delegatee'),
- __('Active'),
+ __s('Dynamic'),
+ __s('Manager'),
+ __s('Delegatee'),
+ __s('Active'),
);
}
diff --git a/inc/infocom.class.php b/inc/infocom.class.php
index c618694..37b45a4 100644
--- a/inc/infocom.class.php
+++ b/inc/infocom.class.php
@@ -36,7 +36,7 @@ class PluginPdfInfocom extends PluginPdfCommon
public function __construct(?CommonGLPI $obj = null)
{
- $this->obj = ($obj ? $obj : new Infocom());
+ $this->obj = ($obj ?: new Infocom());
}
public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
@@ -54,71 +54,71 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
$ic = new Infocom();
$pdf->setColumnsSize(100);
- $title = '' . __('Financial and administratives information') . '';
+ $title = '' . __s('Financial and administratives information') . '';
if (!$ic->getFromDBforDevice(get_class($item), $ID)) {
- $pdf->displayTitle(sprintf(__('%1$s: %2$s'), $title, __('No item to display')));
+ $pdf->displayTitle(sprintf(__s('%1$s: %2$s'), $title, __s('No item to display')));
} else {
- $pdf->displayTitle('' . __('Asset lifecycle') . '');
+ $pdf->displayTitle('' . __s('Asset lifecycle') . '');
$pdf->setColumnsSize(50, 50);
$pdf->displayLine(
'' . sprintf(
- __('%1$s: %2$s'),
- __('Order date') . '',
+ __s('%1$s: %2$s'),
+ __s('Order date') . '',
Html::convDate($ic->fields['order_date']),
),
'' . sprintf(
- __('%1$s: %2$s'),
- __('Date of purchase') . '',
+ __s('%1$s: %2$s'),
+ __s('Date of purchase') . '',
Html::convDate($ic->fields['buy_date']),
),
);
$pdf->displayLine(
'' . sprintf(
- __('%1$s: %2$s'),
- __('Delivery date') . '',
+ __s('%1$s: %2$s'),
+ __s('Delivery date') . '',
Html::convDate($ic->fields['delivery_date']),
),
'' . sprintf(
- __('%1$s: %2$s'),
- __('Startup date') . '',
+ __s('%1$s: %2$s'),
+ __s('Startup date') . '',
Html::convDate($ic->fields['use_date']),
),
);
$pdf->displayLine(
'' . sprintf(
- __('%1$s: %2$s'),
- __('Date of last physical inventory') . '',
+ __s('%1$s: %2$s'),
+ __s('Date of last physical inventory') . '',
Html::convDate($ic->fields['inventory_date']),
),
'' . sprintf(
- __('%1$s: %2$s'),
- __('Decommission date') . '',
+ __s('%1$s: %2$s'),
+ __s('Decommission date') . '',
Html::convDate($ic->fields['decommission_date']),
),
);
$pdf->setColumnsSize(100);
- $pdf->displayTitle('' . __('Financial and administrative information') . '');
+ $pdf->displayTitle('' . __s('Financial and administrative information') . '');
$pdf->setColumnsSize(50, 50);
$pdf->displayLine(
'' . sprintf(
- __('%1$s: %2$s'),
- __('Supplier') . '',
+ __s('%1$s: %2$s'),
+ __s('Supplier') . '',
Toolbox::stripTags(Dropdown::getDropdownName(
'glpi_suppliers',
$ic->fields['suppliers_id'],
)),
),
'' . sprintf(
- __('%1$s: %2$s'),
- __('Budget') . '',
+ __s('%1$s: %2$s'),
+ __s('Budget') . '',
Toolbox::stripTags(Dropdown::getDropdownName(
'glpi_budgets',
$ic->fields['budgets_id'],
@@ -128,47 +128,47 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
$pdf->displayLine(
'' . sprintf(
- __('%1$s: %2$s'),
- __('Order number') . '',
+ __s('%1$s: %2$s'),
+ __s('Order number') . '',
$ic->fields['order_number'],
),
'' . sprintf(
- __('%1$s: %2$s'),
- __('Immobilization number') . '',
+ __s('%1$s: %2$s'),
+ __s('Immobilization number') . '',
$ic->fields['immo_number'],
),
);
$pdf->displayLine(
'' . sprintf(
- __('%1$s: %2$s'),
- __('Invoice number') . '',
+ __s('%1$s: %2$s'),
+ __s('Invoice number') . '',
$ic->fields['bill'],
),
'' . sprintf(
- __('%1$s: %2$s'),
- __('Delivery form') . '',
+ __s('%1$s: %2$s'),
+ __s('Delivery form') . '',
$ic->fields['delivery_number'],
),
);
$pdf->displayLine(
'' . sprintf(
- __('%1$s: %2$s'),
+ __s('%1$s: %2$s'),
_x('price', 'Value') . '',
PluginPdfConfig::formatNumber($ic->fields['value']),
),
'' . sprintf(
- __('%1$s: %2$s'),
- __('Warranty extension value') . '',
+ __s('%1$s: %2$s'),
+ __s('Warranty extension value') . '',
PluginPdfConfig::formatNumber($ic->fields['warranty_value']),
),
);
$pdf->displayLine(
'' . sprintf(
- __('%1$s: %2$s'),
- __('Account net value') . '',
+ __s('%1$s: %2$s'),
+ __s('Account net value') . '',
PluginPdfConfig::formatNumber(Infocom::Amort(
$ic->fields['sink_type'],
$ic->fields['value'],
@@ -181,12 +181,12 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
)),
),
'' . sprintf(
- __('%1$s: %2$s'),
- __('Amortization duration') . '',
+ __s('%1$s: %2$s'),
+ __s('Amortization duration') . '',
sprintf(
- __('%1$s (%2$s)'),
+ __s('%1$s (%2$s)'),
sprintf(
- _n('%d year', '%d years', $ic->fields['sink_time']),
+ _sn('%d year', '%d years', $ic->fields['sink_time']),
$ic->fields['sink_time'],
),
Infocom::getAmortTypeName($ic->fields['sink_type']),
@@ -196,13 +196,13 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
$pdf->displayLine(
'' . sprintf(
- __('%1$s: %2$s'),
- __('Amortization type') . '',
+ __s('%1$s: %2$s'),
+ __s('Amortization type') . '',
Infocom::getAmortTypeName($ic->fields['sink_type']),
),
'' . sprintf(
- __('%1$s: %2$s'),
- __('Amortization coefficient') . '',
+ __s('%1$s: %2$s'),
+ __s('Amortization coefficient') . '',
$ic->fields['sink_coeff'],
),
);
@@ -217,10 +217,10 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
}
$pdf->displayLine(
'' . sprintf(
- __('%1$s: %2$s'),
- __('TCO (value + tracking cost)') . '',
+ __s('%1$s: %2$s'),
+ __s('TCO (value + tracking cost)') . '',
sprintf(
- __('%1$s %2$s'),
+ __s('%1$s %2$s'),
Toolbox::stripTags((string) Infocom::showTco(
$item->getField('ticket_tco'),
$ic->fields['value'],
@@ -229,10 +229,10 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
),
),
'' . sprintf(
- __('%1$s: %2$s'),
- __('Monthly TCO') . '',
+ __s('%1$s: %2$s'),
+ __s('Monthly TCO') . '',
sprintf(
- __('%1$s %2$s'),
+ __s('%1$s %2$s'),
Toolbox::stripTags((string) Infocom::showTco(
$item->getField('ticket_tco'),
$ic->fields['value'],
@@ -245,8 +245,8 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
$pdf->displayLine(
'' . sprintf(
- __('%1$s: %2$s'),
- __('Business criticity') . '',
+ __s('%1$s: %2$s'),
+ __s('Business criticity') . '',
Dropdown::getDropdownName(
'glpi_businesscriticities',
$ic->fields['businesscriticities_id'],
@@ -257,23 +257,23 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
PluginPdfCommon::mainLine($pdf, $ic, 'comment');
$pdf->setColumnsSize(100);
- $pdf->displayTitle('' . __('Warranty information') . '');
+ $pdf->displayTitle('' . __s('Warranty information') . '');
$pdf->setColumnsSize(50, 50);
$pdf->displayLine(
'' . sprintf(
- __('%1$s: %2$s'),
- __('Start date of warranty') . '',
+ __s('%1$s: %2$s'),
+ __s('Start date of warranty') . '',
Html::convDate($ic->fields['warranty_date']),
),
'' . sprintf(
- __('%1$s: %2$s'),
- __('Warranty duration') . '',
+ __s('%1$s: %2$s'),
+ __s('Warranty duration') . '',
sprintf(
- __('%1$s - %2$s'),
+ __s('%1$s - %2$s'),
sprintf(
- _n(
+ _sn(
'%d month',
'%d months',
$ic->fields['warranty_duration'],
@@ -281,7 +281,7 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
$ic->fields['warranty_duration'],
),
sprintf(
- __('Valid to %s'),
+ __s('Valid to %s'),
Infocom::getWarrantyExpir(
$ic->fields['buy_date'],
$ic->fields['warranty_duration'],
@@ -291,16 +291,16 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
),
);
- $col1 = '' . __('Alarms on financial and administrative information') . '';
+ $col1 = '' . __s('Alarms on financial and administrative information') . '';
if ($ic->fields['alert'] == 0) {
- $col1 = sprintf(__('%1$s: %2$s'), $col1, __('No'));
+ $col1 = sprintf(__s('%1$s: %2$s'), $col1, __s('No'));
} elseif ($ic->fields['alert'] == 4) {
- $col1 = sprintf(__('%1$s: %2$s'), $col1, __('Warranty expiration date'));
+ $col1 = sprintf(__s('%1$s: %2$s'), $col1, __s('Warranty expiration date'));
}
$pdf->displayLine(
'' . sprintf(
- __('%1$s: %2$s'),
- __('Warranty information') . '',
+ __s('%1$s: %2$s'),
+ __s('Warranty information') . '',
$ic->fields['warranty_info'],
),
$col1,
diff --git a/inc/item_device.class.php b/inc/item_device.class.php
index 64d7af8..bceeb3d 100644
--- a/inc/item_device.class.php
+++ b/inc/item_device.class.php
@@ -36,7 +36,7 @@ class PluginPdfItem_Device extends PluginPdfCommon
public function __construct(?CommonGLPI $obj = null)
{
- $this->obj = ($obj ? $obj : new Item_Devices());
+ $this->obj = ($obj ?: new Item_Devices());
}
public static function pdfForItem(PluginPdfSimplePDF $pdf, $item)
@@ -54,40 +54,55 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, $item)
}
$pdf->setColumnsSize(100);
- $pdf->displayTitle('' . Toolbox::ucfirst(_n('Component', 'Components', 2)) . '');
+ $pdf->displayTitle('' . Toolbox::ucfirst(_sn('Component', 'Components', 2)) . '');
$pdf->setColumnsSize(3, 14, 42, 41);
$vide = true;
foreach ($devtypes as $itemtype) {
- $devicetypes = new $itemtype();
+ $dbu_local = new DbUtils();
+ $devicetypes = $dbu_local->getItemForItemtype($itemtype);
$specificities = $devicetypes->getSpecificities();
$specif_fields = array_keys($specificities);
- $specif_text = implode(',', $specif_fields);
- if (!empty($specif_text)) {
- $specif_text = ' ,' . $specif_text . ' ';
- }
$associated_type = str_replace('Item_', '', $itemtype);
$linktable = $dbu->getTableForItemType($itemtype);
$fk = $dbu->getForeignKeyFieldForTable($dbu->getTableForItemType($associated_type));
- $query = 'SELECT count(*) AS NB, `id`, `' . $fk . '`' . $specif_text . '
- FROM `' . $linktable . "`
- WHERE `items_id` = '" . $ID . "'
- AND `itemtype` = '" . $item->getType() . "'
- GROUP BY `" . $fk . '`' . $specif_text;
-
+ $select_fields = ['COUNT(*) AS NB', 'id', $fk];
+ if ($specif_fields !== []) {
+ $select_fields = array_merge($select_fields, $specif_fields);
+ }
+ // Construction of the GROUP BY clause
+ $group_by = [$fk];
+ if ($specif_fields !== []) {
+ $group_by = array_merge($group_by, $specif_fields);
+ }
- $device = new $associated_type();
- $itemdevice = new $itemtype();
- foreach ($DB->request($query) as $data) {
+ $query_params = [
+ 'SELECT' => $select_fields,
+ 'FROM' => $linktable,
+ 'WHERE' => [
+ 'items_id' => $ID,
+ 'itemtype' => $item->getType(),
+ ],
+ 'GROUPBY' => $group_by,
+ ];
+
+ $dbu = new DbUtils();
+ foreach ($DB->request($query_params) as $data) {
+ $device = $dbu->getItemForItemtype($associated_type);
+ $itemdevice = $dbu->getItemForItemtype($itemtype);
$itemdevice->getFromDB($data['id']);
if ($device->getFromDB($data[$fk])) {
- $spec = $device->getAdditionalFields();
+ $spec = [];
+ if (method_exists($device, 'getAdditionalFields')) {
+ $spec = $device->getAdditionalFields();
+ }
+
$col4 = '';
- if (count($spec)) {
+ if (count($spec) > 0) {
$colspan = (60 / count($spec));
foreach ($spec as $i => $label) {
$toto = substr($label['name'], 0, strpos($label['name'], '_'));
@@ -107,7 +122,7 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, $item)
);
}
$col4 .= '' . sprintf(
- __('%1$s: %2$s'),
+ __s('%1$s: %2$s'),
$label['label'] . '',
Toolbox::stripTags($value) . ' ',
);
@@ -116,27 +131,23 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, $item)
$value = $device->fields[$label['name']];
}
if ($label['type'] == 'bool') {
- if ($value == 1) {
- $value = __('Yes');
- } else {
- $value = __('No');
- }
+ $value = $value == 1 ? __s('Yes') : __s('No');
}
if (isset($label['unit'])) {
$labelname = '' . sprintf(
- __('%1$s (%2$s)'),
+ __s('%1$s (%2$s)'),
$label['label'],
$label['unit'],
) . '';
} else {
$labelname = $label['label'];
}
- $col4 .= '' . sprintf(__('%1$s: %2$s'), $labelname . '', $value . ' ');
+ $col4 .= '' . sprintf(__s('%1$s: %2$s'), $labelname . '', $value . ' ');
}
} elseif (isset($device->fields[$label['name'] . '_default'])
&& !empty($device->fields[$label['name'] . '_default'])) {
$col4 .= '' . sprintf(
- __('%1$s: %2$s'),
+ __s('%1$s: %2$s'),
$label['label'] . '',
$device->fields[$label['name'] . '_default'] . ' ',
);
@@ -151,7 +162,7 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, $item)
if ($vide) {
$pdf->setColumnsSize(100);
$pdf->setColumnsAlign('center');
- $pdf->displayLine(__('No item to display'));
+ $pdf->displayLine(__s('No item to display'));
}
$pdf->displaySpace();
diff --git a/inc/item_disk.class.php b/inc/item_disk.class.php
index f4befda..7c0f165 100644
--- a/inc/item_disk.class.php
+++ b/inc/item_disk.class.php
@@ -36,7 +36,7 @@ class PluginPdfItem_Disk extends PluginPdfCommon
public function __construct(?CommonGLPI $obj = null)
{
- $this->obj = ($obj ? $obj : new Item_Disk());
+ $this->obj = ($obj ?: new Item_Disk());
}
public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
@@ -47,8 +47,7 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
$ID = $item->getField('id');
$result = $DB->request(
- 'glpi_items_disks',
- ['SELECT' => ['glpi_filesystems.name', 'glpi_items_disks.*'],
+ ['FROM' => 'glpi_items_disks'] + ['SELECT' => ['glpi_filesystems.name', 'glpi_items_disks.*'],
'LEFT JOIN' => ['glpi_filesystems'
=> ['FKEY' => ['glpi_items_disks' => 'filesystems_id',
'glpi_filesystems' => 'id']]],
@@ -60,27 +59,27 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
$number = count($result);
$pdf->setColumnsSize(100);
- $title = '' . _n('Volume', 'Volumes', $number) . '';
+ $title = '' . _sn('Volume', 'Volumes', $number) . '';
- if (!$number) {
- $pdf->displayTitle(sprintf(__('%1$s: %2$s'), $title, __('No item to display')));
+ if ($number === 0) {
+ $pdf->displayTitle(sprintf(__s('%1$s: %2$s'), $title, __s('No item to display')));
} else {
if ($number > $_SESSION['glpilist_limit']) {
- $title = sprintf(__('%1$s: %2$s'), $title, $_SESSION['glpilist_limit'] . ' / ' . $number);
+ $title = sprintf(__s('%1$s: %2$s'), $title, $_SESSION['glpilist_limit'] . ' / ' . $number);
} else {
- $title = sprintf(__('%1$s: %2$s'), $title, $number);
+ $title = sprintf(__s('%1$s: %2$s'), $title, $number);
}
$pdf->displayTitle($title);
$pdf->setColumnsSize(21, 21, 20, 9, 9, 9, 11);
$pdf->displayTitle(
- '' . __('Name'),
- __('Partition'),
- __('Mount point'),
- __('File system'),
- __('Global size'),
- __('Free size'),
- __('Free percentage') . '',
+ '' . __s('Name'),
+ __s('Partition'),
+ __s('Mount point'),
+ __s('File system'),
+ __s('Global size'),
+ __s('Free size'),
+ __s('Free percentage') . '',
);
$pdf->setColumnsAlign('left', 'left', 'left', 'left', 'center', 'right', 'right');
@@ -96,7 +95,7 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
$data['mountpoint'],
$data['name'],
sprintf(
- __('%s Mio'),
+ __s('%s Mio'),
Toolbox::stripTags(Html::formatNumber(
$data['totalsize'],
false,
@@ -104,7 +103,7 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
)),
),
sprintf(
- __('%s Mio'),
+ __s('%s Mio'),
Toolbox::stripTags(Html::formatNumber(
$data['freesize'],
false,
@@ -112,7 +111,7 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
)),
),
sprintf(
- __('%s %s'),
+ __s('%s %s'),
Toolbox::stripTags(Html::formatNumber($percent, false, 0)),
'%',
),
diff --git a/inc/item_knowbaseitem.class.php b/inc/item_knowbaseitem.class.php
index 6bb6768..2096bc9 100644
--- a/inc/item_knowbaseitem.class.php
+++ b/inc/item_knowbaseitem.class.php
@@ -36,7 +36,7 @@ class PluginPdfItem_Knowbaseitem extends PluginPdfCommon
public function __construct(?CommonGLPI $obj = null)
{
- $this->obj = ($obj ? $obj : new Item_Disk());
+ $this->obj = ($obj ?: new Item_Disk());
}
public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
@@ -47,8 +47,7 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
$ID = $item->getField('id');
$result = $DB->request(
- 'glpi_knowbaseitems',
- ['SELECT' => ['glpi_knowbaseitems.*',
+ ['FROM' => 'glpi_knowbaseitems'] + ['SELECT' => ['glpi_knowbaseitems.*',
'glpi_knowbaseitems_items.itemtype',
'glpi_knowbaseitems_items.items_id'],
'LEFT JOIN' => ['glpi_knowbaseitems_items'
@@ -61,23 +60,23 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
$pdf->setColumnsSize(100);
- if (!$number) {
- $pdf->displayTitle('' . __('No knowledge base entries linked') . '');
+ if ($number === 0) {
+ $pdf->displayTitle('' . __s('No knowledge base entries linked') . '');
} else {
- $title = '' . __('Link a knowledge base entry') . '';
+ $title = '' . __s('Link a knowledge base entry') . '';
if ($number > $_SESSION['glpilist_limit']) {
- $title = sprintf(__('%1$s: %2$s'), $title, $_SESSION['glpilist_limit'] . ' / ' . $number);
+ $title = sprintf(__s('%1$s: %2$s'), $title, $_SESSION['glpilist_limit'] . ' / ' . $number);
} else {
- $title = sprintf(__('%1$s: %2$s'), $title, $number);
+ $title = sprintf(__s('%1$s: %2$s'), $title, $number);
}
$pdf->displayTitle($title);
$pdf->setColumnsSize(40, 40, 10, 10);
- $pdf->displayTitle(__('Type'), __('Item'), __('Creation date'), __('Update date'));
+ $pdf->displayTitle(__s('Type'), __s('Item'), __s('Creation date'), __s('Update date'));
foreach ($result as $data) {
$pdf->displayLine(
- __('Knowledge base'),
+ __s('Knowledge base'),
$data['name'],
Html::convDateTime($data['date_creation']),
Html::convDateTime($data['date_mod']),
diff --git a/inc/item_operatingsystem.class.php b/inc/item_operatingsystem.class.php
index f1c055f..50686fe 100644
--- a/inc/item_operatingsystem.class.php
+++ b/inc/item_operatingsystem.class.php
@@ -36,7 +36,7 @@ class PluginPdfItem_OperatingSystem extends PluginPdfCommon
public function __construct(?CommonGLPI $obj = null)
{
- $this->obj = ($obj ? $obj : new Item_OperatingSystem());
+ $this->obj = ($obj ?: new Item_OperatingSystem());
}
public static function pdfForItem(PluginPdfSimplePDF $pdf, $item)
@@ -85,27 +85,27 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, $item)
$number = count($result);
$pdf->setColumnsSize(100);
- $title = '' . __('Operating system') . '';
- if (!$number) {
- $pdf->displayTitle(sprintf(__('%1$s: %2$s'), $title, __('No item to display')));
+ $title = '' . __s('Operating system') . '';
+ if ($number === 0) {
+ $pdf->displayTitle(sprintf(__s('%1$s: %2$s'), $title, __s('No item to display')));
} else {
if ($number > $_SESSION['glpilist_limit']) {
- $title = sprintf(__('%1$s: %2$s'), $title, $_SESSION['glpilist_limit'] . ' / ' . $number);
+ $title = sprintf(__s('%1$s: %2$s'), $title, $_SESSION['glpilist_limit'] . ' / ' . $number);
} else {
- $title = sprintf(__('%1$s: %2$s'), $title, $number);
+ $title = sprintf(__s('%1$s: %2$s'), $title, $number);
}
$pdf->displayTitle($title);
$pdf->setColumnsSize(17, 10, 14, 15, 10, 10, 12, 12);
$pdf->displayTitle(
- __('Name'),
- __('Version'),
- __('Architecture'),
- __('Service pack'),
- __('Kernel'),
- __('Edition'),
- __('Product ID'),
- __('Serial number'),
+ __s('Name'),
+ __s('Version'),
+ __s('Architecture'),
+ __s('Service pack'),
+ __s('Kernel'),
+ __s('Edition'),
+ __s('Product ID'),
+ __s('Serial number'),
);
}
diff --git a/inc/item_problem.class.php b/inc/item_problem.class.php
index 9cae4e1..0a1bdc8 100644
--- a/inc/item_problem.class.php
+++ b/inc/item_problem.class.php
@@ -30,13 +30,44 @@
* --------------------------------------------------------------------------
*/
+use Glpi\DBAL\QueryExpression;
+
+/**
+ * -------------------------------------------------------------------------
+ * LICENSE
+ *
+ * This file is part of PDF plugin for GLPI.
+ *
+ * PDF is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * PDF 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with Reports. If not, see
',
);
}
$listitems .= sprintf(
- __('%1$s - %2$s'),
+ __s('%1$s - %2$s'),
$item->getTypeName(1),
Dropdown::getDropdownName(
getTableForItemType($data['itemtype']),
@@ -484,7 +594,7 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item, $tr
$pdf->displayText($texteitem, $listitems);
}
- $texte = '' . sprintf(__('%1$s: %2$s') . '', __('Title'), '');
+ $texte = '' . sprintf(__s('%1$s: %2$s') . '', __s('Title'), '');
$pdf->displayText($texte, $job->fields['name'], 1);
}
}
diff --git a/inc/itilfollowup.class.php b/inc/itilfollowup.class.php
index 8f5b08d..46c8c7a 100644
--- a/inc/itilfollowup.class.php
+++ b/inc/itilfollowup.class.php
@@ -36,7 +36,7 @@ class PluginPdfItilFollowup extends PluginPdfCommon
public function __construct(?CommonGLPI $obj = null)
{
- $this->obj = ($obj ? $obj : new ITILFollowup());
+ $this->obj = ($obj ?: new ITILFollowup());
}
public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item, $private)
@@ -72,29 +72,25 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item, $pr
$pdf->setColumnsSize(100);
$title = '' . ITILFollowup::getTypeName(2) . '';
- if (!$number) {
- $pdf->displayTitle(sprintf(__('%1$s: %2$s'), $title, __('No item to display')));
+ if ($number === 0) {
+ $pdf->displayTitle(sprintf(__s('%1$s: %2$s'), $title, __s('No item to display')));
} else {
if ($number > $_SESSION['glpilist_limit']) {
- $title = sprintf(__('%1$s (%2$s)'), $title, $_SESSION['glpilist_limit'] . '/' . $number);
+ $title = sprintf(__s('%1$s (%2$s)'), $title, $_SESSION['glpilist_limit'] . '/' . $number);
} else {
- $title = sprintf(__('%1$s: %2$s'), $title, $number);
+ $title = sprintf(__s('%1$s: %2$s'), $title, $number);
}
$pdf->displayTitle($title);
$pdf->setColumnsSize(44, 14, 42);
- $pdf->displayTitle('' . __('Source of followup', 'pdf') . '', // Source
- '' . __('Date') . '', // Date
- '' . __('Requester') . ''); // Author
+ $pdf->displayTitle('' . __s('Source of followup', 'pdf') . '', // Source
+ '' . __s('Date') . '', // Date
+ '' . __s('Requester') . ''); // Author
foreach ($result as $data) {
- if ($data['requesttypes_id']) {
- $lib = Dropdown::getDropdownName('glpi_requesttypes', $data['requesttypes_id']);
- } else {
- $lib = '';
- }
+ $lib = $data['requesttypes_id'] ? Dropdown::getDropdownName('glpi_requesttypes', $data['requesttypes_id']) : '';
if ($data['is_private']) {
- $lib = sprintf(__('%1$s (%2$s)'), $lib, __('Private'));
+ $lib = sprintf(__s('%1$s (%2$s)'), $lib, __s('Private'));
}
$pdf->displayLine(
Toolbox::stripTags($lib),
@@ -103,7 +99,7 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item, $pr
);
- $content = Glpi\Toolbox\Sanitizer::unsanitize(Html::entity_decode_deep($data['content']));
+ $content = $data['content'];
$content = preg_replace('#data:image/[^;]+;base64,#', '@', $content);
preg_match_all('/]*src=[\'"]([^\'"]*docid=([0-9]*))[^>]*>/', $content, $res, PREG_SET_ORDER);
@@ -117,7 +113,7 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item, $pr
}
$pdf->displayText(
- '' . sprintf(__('%1$s: %2$s') . '', __('Description'), ''),
+ '' . sprintf(__s('%1$s: %2$s') . '', __s('Description'), ''),
$content,
1,
);
diff --git a/inc/itilsolution.class.php b/inc/itilsolution.class.php
index 6a59bf7..f612963 100644
--- a/inc/itilsolution.class.php
+++ b/inc/itilsolution.class.php
@@ -36,7 +36,7 @@ class PluginPdfITILSolution extends PluginPdfCommon
public function __construct(?CommonGLPI $obj = null)
{
- $this->obj = ($obj ? $obj : new ITILSolution());
+ $this->obj = ($obj ?: new ITILSolution());
}
public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
@@ -49,18 +49,17 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
$pdf->setColumnsSize(100);
$soluce = $DB->request(
- 'glpi_itilsolutions',
- ['itemtype' => $item->getType(),
+ ['FROM' => 'glpi_itilsolutions'] + ['itemtype' => $item->getType(),
'items_id' => $item->fields['id']],
);
$number = count($soluce);
- $title = '' . __('Solution') . '';
- if (!$number) {
- $pdf->displayTitle(sprintf(__('%1$s: %2$s'), $title, __('No item to display')));
+ $title = '' . __s('Solution') . '';
+ if ($number === 0) {
+ $pdf->displayTitle(sprintf(__s('%1$s: %2$s'), $title, __s('No item to display')));
} else {
- $title = sprintf(__('%1$s: %2$s'), $title, $number);
+ $title = sprintf(__s('%1$s: %2$s'), $title, $number);
$pdf->displayTitle($title);
foreach ($soluce as $row) {
if ($row['solutiontypes_id']) {
@@ -69,9 +68,9 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
$row['solutiontypes_id'],
));
} else {
- $title = __('Solution');
+ $title = __s('Solution');
}
- $sol = Glpi\Toolbox\Sanitizer::unsanitize(Html::entity_decode_deep($row['content']));
+ $sol = $row['content'];
$sol = preg_replace('#data:image/[^;]+;base64,#', '@', $sol);
preg_match_all('/
]*src=[\'"]([^\'"]*docid=([0-9]*))[^>]*>/', $sol, $res, PREG_SET_ORDER);
@@ -86,25 +85,25 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
$text = $textapprove = '';
if ($row['status'] == 3) {
- $text = __('Soluce approved on ', 'pdf');
+ $text = __s('Soluce approved on ', 'pdf');
} elseif ($row['status'] == 4) {
- $text = __('Soluce refused on ', 'pdf');
+ $text = __s('Soluce refused on ', 'pdf');
}
if (isset($row['date_approval']) || !empty($row['users_id_approval'])) {
$textapprove = '
' .
sprintf(
- __('%1$s %2$s'),
+ __s('%1$s %2$s'),
$text,
Html::convDateTime($row['date_approval']),
) . ' ' .
sprintf(
- __('%1$s %2$s'),
- __('By'),
+ __s('%1$s %2$s'),
+ __s('By'),
Toolbox::stripTags($dbu->getUserName($row['users_id_approval'])),
)
. '';
}
- $pdf->displayText('' . sprintf(__('%1$s: %2$s'), $title . '', ''), $sol . $textapprove);
+ $pdf->displayText('' . sprintf(__s('%1$s: %2$s'), $title . '', ''), $sol . $textapprove);
}
}
diff --git a/inc/knowbaseitem.class.php b/inc/knowbaseitem.class.php
index b8b5787..74c95aa 100644
--- a/inc/knowbaseitem.class.php
+++ b/inc/knowbaseitem.class.php
@@ -36,7 +36,7 @@ class PluginPdfKnowbaseItem extends PluginPdfCommon
public function __construct(?CommonGLPI $obj = null)
{
- $this->obj = ($obj ? $obj : new KnowbaseItem());
+ $this->obj = ($obj ?: new KnowbaseItem());
}
public function defineAllTabsPDF($options = [])
@@ -54,7 +54,7 @@ public static function pdfMain(PluginPdfSimplePDF $pdf, KnowbaseItem $item)
{
$dbu = new DbUtils();
- $ID = $item->getField('id');
+ $item->getField('id');
if (!Session::haveRightsOr(
'knowbase',
@@ -71,13 +71,9 @@ public static function pdfMain(PluginPdfSimplePDF $pdf, KnowbaseItem $item)
));
$question
- = Toolbox::stripTags(Glpi\Toolbox\Sanitizer::unsanitize(html_entity_decode(
- $item->getField('name'),
- ENT_QUOTES,
- 'UTF-8',
- )));
+ = Toolbox::stripTags(html_entity_decode($item->getField('name')));
- $answer = Glpi\Toolbox\Sanitizer::unsanitize(Html::entity_decode_deep($item->getField('answer')));
+ $answer = $item->getField('answer');
$answer = preg_replace('#data:image/[^;]+;base64,#', '@', $answer);
preg_match_all('/]*src=[\'"]([^\'"]*docid=([0-9]*))[^>]*>/', $answer, $res, PREG_SET_ORDER);
@@ -98,31 +94,31 @@ public static function pdfMain(PluginPdfSimplePDF $pdf, KnowbaseItem $item)
$pdf->setColumnsSize(100);
if (Toolbox::strlen($fullcategoryname) > 0) {
- $pdf->displayTitle('' . __('Category name') . '');
+ $pdf->displayTitle('' . __s('Category name') . '');
$pdf->displayLine($fullcategoryname);
}
if (Toolbox::strlen($question) > 0) {
- $pdf->displayTitle('' . __('Subject') . '');
+ $pdf->displayTitle('' . __s('Subject') . '');
$pdf->displayText('', $question, 5);
} else {
- $pdf->displayTitle('' . __('No question found', 'pdf') . '');
+ $pdf->displayTitle('' . __s('No question found', 'pdf') . '');
}
if (Toolbox::strlen($answer) > 0) {
- $pdf->displayTitle('' . __('Content') . '');
+ $pdf->displayTitle('' . __s('Content') . '');
$pdf->displayText('', $answer, 5);
} else {
- $pdf->displayTitle('' . __('No answer found', 'pdf') . '');
+ $pdf->displayTitle('' . __s('No answer found', 'pdf') . '');
}
$pdf->setColumnsSize(50, 15, 15, 10, 10);
$pdf->displayTitle(
- __('Writer'),
- __('Creation date'),
- __('Last update'),
- __('FAQ'),
- _n('View', 'Views', 2),
+ __s('Writer'),
+ __s('Creation date'),
+ __s('Last update'),
+ __s('FAQ'),
+ _sn('View', 'Views', 2),
);
$pdf->displayLine(
$dbu->getUserName($item->fields['users_id']),
@@ -179,22 +175,22 @@ public static function pdfCible(PluginPdfSimplePDF $pdf, KnowbaseItem $item)
$nb = $item->countVisibilities();
if ($nb) {
$pdf->setColumnsSize(100);
- $pdf->displayTitle(_n('Target', 'Targets', $nb));
+ $pdf->displayTitle(_sn('Target', 'Targets', $nb));
$pdf->setColumnsSize(30, 70);
- $pdf->displayTitle(__('Type'), _n('Recipient', 'Recipients', 2));
+ $pdf->displayTitle(__s('Type'), _sn('Recipient', 'Recipients', 2));
$recursive = '';
if (count($entities)) {
foreach ($entities as $key => $val) {
foreach ($val as $data) {
if ($data['is_recursive']) {
- $recursive = '(' . __('R') . ')';
+ $recursive = '(' . __s('R') . ')';
}
$pdf->displayLine(
- __('Entity'),
+ __s('Entity'),
sprintf(
- __('%1s %2s'),
+ __s('%1s %2s'),
Dropdown::getDropdownName(
'glpi_entities',
$data['entities_id'],
@@ -210,13 +206,13 @@ public static function pdfCible(PluginPdfSimplePDF $pdf, KnowbaseItem $item)
foreach ($profiles as $key => $val) {
foreach ($val as $data) {
if ($data['is_recursive']) {
- $recursive = '(' . __('R') . ')';
+ $recursive = '(' . __s('R') . ')';
}
$names = Dropdown::getDropdownName('glpi_profiles', $data['profiles_id']);
$profilename = '';
if ($data['entities_id'] >= 0) {
$profilename = sprintf(
- __('%1$s / %2$s'),
+ __s('%1$s / %2$s'),
$names,
Dropdown::getDropdownName(
'glpi_entities',
@@ -224,10 +220,10 @@ public static function pdfCible(PluginPdfSimplePDF $pdf, KnowbaseItem $item)
),
);
if ($data['is_recursive']) {
- $profilename = sprintf(__('%1$s %2$s'), $profilename, $recursive);
+ $profilename = sprintf(__s('%1$s %2$s'), $profilename, $recursive);
}
}
- $pdf->displayLine(__('Profile'), $profilename);
+ $pdf->displayLine(__s('Profile'), $profilename);
}
}
}
@@ -236,13 +232,13 @@ public static function pdfCible(PluginPdfSimplePDF $pdf, KnowbaseItem $item)
foreach ($groups as $key => $val) {
foreach ($val as $data) {
if ($data['is_recursive']) {
- $recursive = '(' . __('R') . ')';
+ $recursive = '(' . __s('R') . ')';
}
$names = Dropdown::getDropdownName('glpi_groups', $data['groups_id']);
$groupname = '';
if ($data['entities_id'] >= 0) {
$groupname = sprintf(
- __('%1$s / %2$s'),
+ __s('%1$s / %2$s'),
$names,
Dropdown::getDropdownName(
'glpi_entities',
@@ -250,10 +246,10 @@ public static function pdfCible(PluginPdfSimplePDF $pdf, KnowbaseItem $item)
),
);
if ($data['is_recursive']) {
- $groupname = sprintf(__('%1$s %2$s'), $groupname, $recursive);
+ $groupname = sprintf(__s('%1$s %2$s'), $groupname, $recursive);
}
}
- $pdf->displayLine(__('Group'), $groupname);
+ $pdf->displayLine(__s('Group'), $groupname);
}
}
}
@@ -261,7 +257,7 @@ public static function pdfCible(PluginPdfSimplePDF $pdf, KnowbaseItem $item)
if (count($users)) {
foreach ($users as $key => $val) {
foreach ($val as $data) {
- $pdf->displayLine(__('User'), $dbu->getUserName($data['users_id']));
+ $pdf->displayLine(__s('User'), $dbu->getUserName($data['users_id']));
}
}
}
diff --git a/inc/link.class.php b/inc/link.class.php
index e8794ef..b4e040d 100644
--- a/inc/link.class.php
+++ b/inc/link.class.php
@@ -36,7 +36,7 @@ class PluginPdfLink extends PluginPdfCommon
public function __construct(?CommonGLPI $obj = null)
{
- $this->obj = ($obj ? $obj : new Link());
+ $this->obj = ($obj ?: new Link());
}
public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
@@ -44,7 +44,7 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
/** @var DBmysql $DB */
global $DB;
- $ID = $item->getField('id');
+ $item->getField('id');
$type = get_class($item);
$query = ['SELECT' => ['glpi_links.id', 'link', 'name', 'data'],
@@ -59,14 +59,14 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
$number = count($result);
$pdf->setColumnsSize(100);
- $title = '' . _n('External link', 'External links', $number) . '';
- if (!$number) {
- $pdf->displayTitle(sprintf(__('%1$s: %2$s'), $title, __('No item to display')));
+ $title = '' . _sn('External link', 'External links', $number) . '';
+ if ($number === 0) {
+ $pdf->displayTitle(sprintf(__s('%1$s: %2$s'), $title, __s('No item to display')));
} else {
if ($number > $_SESSION['glpilist_limit']) {
- $title = sprintf(__('%1$s: %2$s'), $title, $_SESSION['glpilist_limit'] . ' / ' . $number);
+ $title = sprintf(__s('%1$s: %2$s'), $title, $_SESSION['glpilist_limit'] . ' / ' . $number);
} else {
- $title = sprintf(__('%1$s: %2$s'), $title, $number);
+ $title = sprintf(__s('%1$s: %2$s'), $title, $number);
}
$pdf->displayTitle($title);
@@ -83,7 +83,7 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
$i = 1;
foreach ($links as $key => $link) {
$url = $link;
- $pdf->displayLine(sprintf(__('%1$s: %2$s'), "$name #$i", $link));
+ $pdf->displayLine(sprintf(__s('%1$s: %2$s'), "$name #$i", $link));
$i++;
$i++;
}
@@ -100,7 +100,7 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
$file = reset($files);
}
$pdf->displayText(
- sprintf(__('%1$s: %2$s'), "$name #$i - $file", ''),
+ sprintf(__s('%1$s: %2$s'), "$name #$i - $file", ''),
trim($data),
1,
10,
diff --git a/inc/log.class.php b/inc/log.class.php
index 58f6924..feb190c 100644
--- a/inc/log.class.php
+++ b/inc/log.class.php
@@ -36,7 +36,7 @@ class PluginPdfLog extends PluginPdfCommon
public function __construct(?CommonGLPI $obj = null)
{
- $this->obj = ($obj ? $obj : new Log());
+ $this->obj = ($obj ?: new Log());
}
public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
@@ -46,24 +46,24 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
$number = count($changes);
$pdf->setColumnsSize(100);
- $title = '' . __('Historical') . '';
+ $title = '' . __s('Historical') . '';
- if (!$number) {
- $pdf->displayTitle(sprintf(__('%1$s: %2$s'), $title, __('No item to display')));
+ if ($number === 0) {
+ $pdf->displayTitle(sprintf(__s('%1$s: %2$s'), $title, __s('No item to display')));
} else {
if ($number > $_SESSION['glpilist_limit']) {
- $title = sprintf(__('%1$s: %2$s'), $title, $_SESSION['glpilist_limit'] . ' / ' . $number);
+ $title = sprintf(__s('%1$s: %2$s'), $title, $_SESSION['glpilist_limit'] . ' / ' . $number);
} else {
- $title = sprintf(__('%1$s: %2$s'), $title, $number);
+ $title = sprintf(__s('%1$s: %2$s'), $title, $number);
}
$pdf->displayTitle($title);
$pdf->setColumnsSize(10, 15, 24, 11, 40);
$pdf->displayTitle(
- '' . __('ID'),
- __('Date'),
- __('User'),
- __('Field'),
+ '' . __s('ID'),
+ __s('Date'),
+ __s('User'),
+ __s('Field'),
_x('name', 'Update') . '',
);
diff --git a/inc/monitor.class.php b/inc/monitor.class.php
index bfff18e..5d7ccc7 100644
--- a/inc/monitor.class.php
+++ b/inc/monitor.class.php
@@ -36,7 +36,7 @@ class PluginPdfMonitor extends PluginPdfCommon
public function __construct(?CommonGLPI $obj = null)
{
- $this->obj = ($obj ? $obj : new Monitor());
+ $this->obj = ($obj ?: new Monitor());
}
public function defineAllTabsPDF($options = [])
@@ -62,26 +62,26 @@ public static function pdfMain(PluginPdfSimplePDF $pdf, Monitor $item)
$pdf->displayLine(
'' . sprintf(
- __('%1$s: %2$s'),
- __('Group') . '',
+ __s('%1$s: %2$s'),
+ __s('Group') . '',
Dropdown::getDropdownName('glpi_groups', $item->fields['groups_id']),
),
'' . sprintf(
- __('%1$s: %2$s'),
- __('Size') . '',
- sprintf(__('%1$s %2$s'), $item->fields['size'], '"'),
+ __s('%1$s: %2$s'),
+ __s('Size') . '',
+ sprintf(__s('%1$s %2$s'), $item->fields['size'], '"'),
),
);
- $opts = ['have_micro' => __('Microphone'),
- 'have_speaker' => __('Speakers'),
- 'have_subd' => __('Sub-D'),
- 'have_bnc' => __('BNC'),
- 'have_dvi' => __('DVI'),
- 'have_pivot' => __('Pivot'),
- 'have_hdmi' => __('HDMI'),
- 'have_displayport' => __('DisplayPort')];
- foreach ($opts as $key => $val) {
+ $opts = ['have_micro' => __s('Microphone'),
+ 'have_speaker' => __s('Speakers'),
+ 'have_subd' => __s('Sub-D'),
+ 'have_bnc' => __s('BNC'),
+ 'have_dvi' => __s('DVI'),
+ 'have_pivot' => __s('Pivot'),
+ 'have_hdmi' => __s('HDMI'),
+ 'have_displayport' => __s('DisplayPort')];
+ foreach (array_keys($opts) as $key) {
if (!$item->fields[$key]) {
unset($opts[$key]);
}
@@ -89,9 +89,9 @@ public static function pdfMain(PluginPdfSimplePDF $pdf, Monitor $item)
$pdf->setColumnsSize(100);
$pdf->displayLine(
'' . sprintf(
- __('%1$s: %2$s'),
- __('Flags') . '',
- (count($opts) ? implode(', ', $opts) : __('None')),
+ __s('%1$s: %2$s'),
+ __s('Flags') . '',
+ (count($opts) ? implode(', ', $opts) : __s('None')),
),
);
diff --git a/inc/networkequipment.class.php b/inc/networkequipment.class.php
index 161622c..cbd1155 100644
--- a/inc/networkequipment.class.php
+++ b/inc/networkequipment.class.php
@@ -36,7 +36,7 @@ class PluginPdfNetworkEquipment extends PluginPdfCommon
public function __construct(?CommonGLPI $obj = null)
{
- $this->obj = ($obj ? $obj : new NetworkEquipment());
+ $this->obj = ($obj ?: new NetworkEquipment());
}
public function defineAllTabsPDF($options = [])
@@ -68,13 +68,13 @@ public static function pdfMain(PluginPdfSimplePDF $pdf, NetworkEquipment $item)
$pdf->displayLine(
'' . sprintf(
- __('%1$s: %2$s'),
- __('User') . '',
+ __s('%1$s: %2$s'),
+ __s('User') . '',
$dbu->getUserName($item->fields['users_id']),
),
'' . sprintf(
- __('%1$s: %2$s'),
- __('Network') . '',
+ __s('%1$s: %2$s'),
+ __s('Network') . '',
Toolbox::stripTags(Dropdown::getDropdownName(
'glpi_networks',
$item->fields['networks_id'],
@@ -84,14 +84,14 @@ public static function pdfMain(PluginPdfSimplePDF $pdf, NetworkEquipment $item)
$pdf->displayLine(
'' . sprintf(
- __('%1$s: %2$s'),
- __('Group') . '',
+ __s('%1$s: %2$s'),
+ __s('Group') . '',
Dropdown::getDropdownName('glpi_groups', $item->fields['groups_id']),
),
- '' . __('The MAC address and the IP of the equipment are included in an aggregated network port'),
+ '' . __s('The MAC address and the IP of the equipment are included in an aggregated network port'),
'' . sprintf(
- __('%1$s: %2$s'),
- sprintf(__('%1$s (%2$s)'), __('Memory'), __('Mio')) . '',
+ __s('%1$s: %2$s'),
+ sprintf(__s('%1$s (%2$s)'), __s('Memory'), __s('Mio')) . '',
$item->fields['ram'],
),
);
diff --git a/inc/networkport.class.php b/inc/networkport.class.php
index a5005ec..1d5a0ee 100644
--- a/inc/networkport.class.php
+++ b/inc/networkport.class.php
@@ -38,7 +38,7 @@ class PluginPdfNetworkPort extends PluginPdfCommon
public function __construct(?CommonGLPI $obj = null)
{
- $this->obj = ($obj ? $obj : new NetworkPort());
+ $this->obj = ($obj ?: new NetworkPort());
}
public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
@@ -52,22 +52,21 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
$pdf->setColumnsSize(100);
$result = $DB->request(
- 'glpi_networkports',
- ['SELECT' => ['id', 'name', 'logical_number'],
+ ['FROM' => 'glpi_networkports'] + ['SELECT' => ['id', 'name', 'logical_number'],
'WHERE' => ['items_id' => $ID,
'itemtype' => $type],
'ORDER' => ['name', 'logical_number']],
);
$nb_connect = count($result);
- $title = '' . _n('Network port', 'Network ports', $nb_connect) . '';
- if (!$nb_connect) {
- $pdf->displayTitle('' . __('No network port found') . '');
+ $title = '' . _sn('Network port', 'Network ports', $nb_connect) . '';
+ if ($nb_connect === 0) {
+ $pdf->displayTitle('' . __s('No network port found') . '');
} else {
if ($nb_connect > $_SESSION['glpilist_limit']) {
- $title = sprintf(__('%1$s: %2$s'), $title, $_SESSION['glpilist_limit'] . ' / ' . $nb_connect);
+ $title = sprintf(__s('%1$s: %2$s'), $title, $_SESSION['glpilist_limit'] . ' / ' . $nb_connect);
} else {
- $title = sprintf(__('%1$s: %2$d'), $title, $nb_connect);
+ $title = sprintf(__s('%1$s: %2$d'), $title, $nb_connect);
}
$pdf->displayTitle($title);
@@ -79,35 +78,30 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
$pdf->displayTitle('' . $instname . '');
$pdf->displayLine('' . sprintf(
- __('%1$s: %2$s'),
+ __s('%1$s: %2$s'),
'#',
$netport->fields['logical_number'],
));
$pdf->displayLine('' . sprintf(
- __('%1$s: %2$s'),
- __('Name') . '',
+ __s('%1$s: %2$s'),
+ __s('Name') . '',
$netport->fields['name'],
));
$contact = new NetworkPort();
$netport2 = new NetworkPort();
- $add = __('Not connected.');
- if ($cid = $contact->getContact($netport->fields['id'])) {
- if ($netport2->getFromDB($cid)
- && ($device2 = $dbu->getItemForItemtype($netport2->fields['itemtype']))) {
- if ($device2->getFromDB($netport2->fields['items_id'])) {
- $add = $netport2->getName() . ' ' . __('on') . ' ' .
- $device2->getName() . ' (' . $device2->getTypeName() . ')';
- }
- }
+ $add = __s('Not connected.');
+ $cid = $contact->getContact($netport->fields['id']);
+ if ($cid && $netport2->getFromDB($cid) && ($device2 = $dbu->getItemForItemtype($netport2->fields['itemtype'])) && $device2->getFromDB($netport2->fields['items_id'])) {
+ $add = $netport2->getName() . ' ' . __s('on') . ' ' . $device2->getName() . ' (' . $device2->getTypeName() . ')';
}
if ($instantiation_type == 'NetworkPortEthernet') {
$pdf->displayLine('' . sprintf(
- __('%1$s: %2$s'),
- __('Connected to') . '',
+ __s('%1$s: %2$s'),
+ __s('Connected to') . '',
$add,
));
$netportethernet = new NetworkPortEthernet();
@@ -118,10 +112,10 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
$type = NetworkPortEthernet::getPortTypeName($netportethernet->fields['type']);
}
$pdf->displayLine(
- '' . sprintf(__('%1$s: %2$s'), __('Ethernet port speed') . '', $speed),
+ '' . sprintf(__s('%1$s: %2$s'), __s('Ethernet port speed') . '', $speed),
);
$pdf->displayLine(
- '' . sprintf(__('%1$s: %2$s'), __('Ethernet port type') . '', $type),
+ '' . sprintf(__s('%1$s: %2$s'), __s('Ethernet port type') . '', $type),
);
$netpoint = new Socket();
@@ -132,15 +126,15 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
}
$pdf->displayLine(
'' . sprintf(
- __('%1$s: %2$s'),
- __('Network outlet') . '',
+ __s('%1$s: %2$s'),
+ __s('Network outlet') . '',
$outlet,
),
);
}
$pdf->displayLine('' . sprintf(
- __('%1$s: %2$s'),
- __('MAC') . '',
+ __s('%1$s: %2$s'),
+ __s('MAC') . '',
$netport->fields['mac'],
));
@@ -156,7 +150,7 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
if ($ip->getFromDBByRequest($sqlip)) {
$ipname = $ip->fields['name'];
- $pdf->displayLine('' . sprintf(__('%1$s: %2$s'), __('ip') . '', $ipname));
+ $pdf->displayLine('' . sprintf(__s('%1$s: %2$s'), __s('ip') . '', $ipname));
$sql = ['SELECT' => 'glpi_ipaddresses_ipnetworks.ipnetworks_id',
'FROM' => 'glpi_ipaddresses_ipnetworks',
@@ -171,8 +165,8 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
$ipnetwork = new IPNetwork();
if ($ipnetwork->getFromDB($row['ipnetworks_id'])) {
$pdf->displayLine('' . sprintf(
- __('%1$s: %2$s'),
- __('IP network') . '',
+ __s('%1$s: %2$s'),
+ __s('IP network') . '',
$ipnetwork->fields['completename'],
));
}
diff --git a/inc/peripheral.class.php b/inc/peripheral.class.php
index ed868cf..9f38312 100644
--- a/inc/peripheral.class.php
+++ b/inc/peripheral.class.php
@@ -36,7 +36,7 @@ class PluginPdfPeripheral extends PluginPdfCommon
public function __construct(?CommonGLPI $obj = null)
{
- $this->obj = ($obj ? $obj : new Peripheral());
+ $this->obj = ($obj ?: new Peripheral());
}
public function defineAllTabsPDF($options = [])
@@ -64,11 +64,11 @@ public static function pdfMain(PluginPdfSimplePDF $pdf, Peripheral $item)
$pdf->displayLine(
'' . sprintf(
- __('%1$s: %2$s'),
- __('Group') . '',
+ __s('%1$s: %2$s'),
+ __s('Group') . '',
Dropdown::getDropdownName('glpi_groups', $item->fields['groups_id']),
),
- '' . sprintf(__('%1$s: %2$s'), __('Brand') . '', $item->fields['brand']),
+ '' . sprintf(__s('%1$s: %2$s'), __s('Brand') . '', $item->fields['brand']),
);
$pdf->setColumnsSize(100);
diff --git a/inc/phone.class.php b/inc/phone.class.php
index b3a8840..e35cf92 100644
--- a/inc/phone.class.php
+++ b/inc/phone.class.php
@@ -36,7 +36,7 @@ class PluginPdfPhone extends PluginPdfCommon
public function __construct(?CommonGLPI $obj = null)
{
- $this->obj = ($obj ? $obj : new Phone());
+ $this->obj = ($obj ?: new Phone());
}
public function defineAllTabsPDF($options = [])
@@ -65,29 +65,29 @@ public static function pdfMain(PluginPdfSimplePDF $pdf, Phone $item)
$pdf->displayLine(
'' . sprintf(
- __('%1$s: %2$s'),
- __('Group') . '',
+ __s('%1$s: %2$s'),
+ __s('Group') . '',
Dropdown::getDropdownName('glpi_groups', $item->fields['groups_id']),
),
'' . sprintf(
- __('%1$s: %2$s'),
- __('UUID') . '',
+ __s('%1$s: %2$s'),
+ __s('UUID') . '',
$item->fields['uuid'],
),
);
$pdf->displayLine(
- '' . sprintf(__('%1$s: %2$s'), __('Brand') . '', $item->fields['brand']),
+ '' . sprintf(__s('%1$s: %2$s'), __s('Brand') . '', $item->fields['brand']),
'' . sprintf(
- __('%1$s: %2$s'),
+ __s('%1$s: %2$s'),
_x('quantity', 'Number of lines') . '',
$item->fields['number_line'],
),
);
- $opts = ['have_headset' => __('Headset'),
- 'have_hp' => __('Speaker')];
- foreach ($opts as $key => $val) {
+ $opts = ['have_headset' => __s('Headset'),
+ 'have_hp' => __s('Speaker')];
+ foreach (array_keys($opts) as $key) {
if (!$item->fields[$key]) {
unset($opts[$key]);
}
@@ -95,14 +95,14 @@ public static function pdfMain(PluginPdfSimplePDF $pdf, Phone $item)
$pdf->displayLine(
'' . sprintf(
- __('%1$s: %2$s'),
- __('Power supply') . '',
+ __s('%1$s: %2$s'),
+ __s('Power supply') . '',
Dropdown::getYesNo($item->fields['phonepowersupplies_id']),
),
'' . sprintf(
- __('%1$s: %2$s'),
- __('Flags') . '',
- (count($opts) ? implode(', ', $opts) : __('None')),
+ __s('%1$s: %2$s'),
+ __s('Flags') . '',
+ (count($opts) ? implode(', ', $opts) : __s('None')),
),
);
diff --git a/inc/preference.class.php b/inc/preference.class.php
index a024925..15a8dc7 100644
--- a/inc/preference.class.php
+++ b/inc/preference.class.php
@@ -30,16 +30,23 @@
* --------------------------------------------------------------------------
*/
+use Glpi\Application\View\TemplateRenderer;
+
class PluginPdfPreference extends CommonDBTM
{
public static $rightname = 'plugin_pdf';
+ public static function getTypeName($nb = 0)
+ {
+ return __s('PDF export', 'pdf');
+ }
+
public static function showPreferences()
{
/** @var array $PLUGIN_HOOKS */
global $PLUGIN_HOOKS;
- $target = Toolbox::getItemTypeFormURL(__CLASS__);
+ $target = Toolbox::getItemTypeFormURL(self::class);
$pref = new self();
$dbu = new DbUtils();
@@ -55,17 +62,6 @@ public static function showPreferences()
echo '';
}
- /**
- * @param $num
- * @param $label
- * @param $checked (false by default)
- **/
- public function checkbox($num, $label, $checked = false)
- {
- echo "