diff --git a/composer.json b/composer.json
index beecd60..305c824 100644
--- a/composer.json
+++ b/composer.json
@@ -5,16 +5,21 @@
"tecnickcom/tcpdf": "^6.4"
},
"require-dev": {
- "friendsofphp/php-cs-fixer": "^3.66",
+ "friendsofphp/php-cs-fixer": "^3.73",
"glpi-project/tools": "^0.7.4",
"php-parallel-lint/php-parallel-lint": "^1.4",
- "phpstan/phpstan": "^1.12"
+ "phpstan/extension-installer": "^1.4",
+ "phpstan/phpstan": "^2.1",
+ "phpstan/phpstan-deprecation-rules": "^2.0"
},
"config": {
"optimize-autoloader": true,
"platform": {
"php": "7.4.0"
},
- "sort-packages": true
+ "sort-packages": true,
+ "allow-plugins": {
+ "phpstan/extension-installer": true
+ }
}
}
diff --git a/composer.lock b/composer.lock
index 15e82ee..de54be1 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "723b8525e0df12af3810e751ef7c6db6",
+ "content-hash": "99a69b03ea27d0c309ebe6770cd4c902",
"packages": [
{
"name": "symfony/deprecation-contracts",
@@ -25,12 +25,12 @@
},
"type": "library",
"extra": {
+ "thanks": {
+ "url": "https://github.com/symfony/contracts",
+ "name": "symfony/contracts"
+ },
"branch-alias": {
"dev-main": "2.5-dev"
- },
- "thanks": {
- "name": "symfony/contracts",
- "url": "https://github.com/symfony/contracts"
}
},
"autoload": {
@@ -229,20 +229,21 @@
},
{
"name": "tecnickcom/tcpdf",
- "version": "6.7.8",
+ "version": "6.8.2",
"source": {
"type": "git",
"url": "https://github.com/tecnickcom/TCPDF.git",
- "reference": "7956f5e37863c6a569d5ccfae826f353a12a2493"
+ "reference": "f7a781073e1645062f163e058139e2f89355d420"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/tecnickcom/TCPDF/zipball/7956f5e37863c6a569d5ccfae826f353a12a2493",
- "reference": "7956f5e37863c6a569d5ccfae826f353a12a2493",
+ "url": "https://api.github.com/repos/tecnickcom/TCPDF/zipball/f7a781073e1645062f163e058139e2f89355d420",
+ "reference": "f7a781073e1645062f163e058139e2f89355d420",
"shasum": ""
},
"require": {
- "php": ">=5.5.0"
+ "ext-curl": "*",
+ "php": ">=7.1.0"
},
"type": "library",
"autoload": {
@@ -289,7 +290,7 @@
],
"support": {
"issues": "https://github.com/tecnickcom/TCPDF/issues",
- "source": "https://github.com/tecnickcom/TCPDF/tree/6.7.8"
+ "source": "https://github.com/tecnickcom/TCPDF/tree/6.8.2"
},
"funding": [
{
@@ -297,7 +298,7 @@
"type": "custom"
}
],
- "time": "2024-12-13T19:31:40+00:00"
+ "time": "2025-01-26T14:03:12+00:00"
}
],
"packages-dev": [
@@ -392,13 +393,13 @@
},
"type": "library",
"extra": {
- "branch-alias": {
- "dev-main": "3.x-dev"
- },
"phpstan": {
"includes": [
"extension.neon"
]
+ },
+ "branch-alias": {
+ "dev-main": "3.x-dev"
}
},
"autoload": {
@@ -701,16 +702,16 @@
},
{
"name": "friendsofphp/php-cs-fixer",
- "version": "v3.66.1",
+ "version": "v3.73.1",
"source": {
"type": "git",
"url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git",
- "reference": "cde186799d8e92960c5a00c96e6214bf7f5547a9"
+ "reference": "ffcb8200a42045e65049af7910cfd022f631b064"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/cde186799d8e92960c5a00c96e6214bf7f5547a9",
- "reference": "cde186799d8e92960c5a00c96e6214bf7f5547a9",
+ "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/ffcb8200a42045e65049af7910cfd022f631b064",
+ "reference": "ffcb8200a42045e65049af7910cfd022f631b064",
"shasum": ""
},
"require": {
@@ -718,6 +719,7 @@
"composer/semver": "^3.4",
"composer/xdebug-handler": "^3.0.3",
"ext-filter": "*",
+ "ext-hash": "*",
"ext-json": "*",
"ext-tokenizer": "*",
"fidry/cpu-core-counter": "^1.2",
@@ -727,7 +729,7 @@
"react/promise": "^2.0 || ^3.0",
"react/socket": "^1.0",
"react/stream": "^1.0",
- "sebastian/diff": "^4.0 || ^5.1 || ^6.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",
@@ -740,18 +742,18 @@
"symfony/stopwatch": "^5.4 || ^6.4 || ^7.0"
},
"require-dev": {
- "facile-it/paraunit": "^1.3.1 || ^2.4",
- "infection/infection": "^0.29.8",
- "justinrainbow/json-schema": "^5.3 || ^6.0",
+ "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",
"mikey179/vfsstream": "^1.6.12",
"php-coveralls/php-coveralls": "^2.7",
"php-cs-fixer/accessible-object": "^1.1",
- "php-cs-fixer/phpunit-constraint-isidenticalstring": "^1.5",
- "php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "^1.5",
- "phpunit/phpunit": "^9.6.22 || ^10.5.40 || ^11.5.2",
- "symfony/var-dumper": "^5.4.48 || ^6.4.15 || ^7.2.0",
- "symfony/yaml": "^5.4.45 || ^6.4.13 || ^7.2.0"
+ "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"
},
"suggest": {
"ext-dom": "For handling output formats in XML",
@@ -792,7 +794,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.66.1"
+ "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.73.1"
},
"funding": [
{
@@ -800,7 +802,7 @@
"type": "github"
}
],
- "time": "2025-01-05T14:43:25+00:00"
+ "time": "2025-03-19T23:42:16+00:00"
},
{
"name": "glpi-project/tools",
@@ -919,22 +921,70 @@
},
"time": "2024-03-27T12:14:49+00:00"
},
+ {
+ "name": "phpstan/extension-installer",
+ "version": "1.4.3",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/phpstan/extension-installer.git",
+ "reference": "85e90b3942d06b2326fba0403ec24fe912372936"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/phpstan/extension-installer/zipball/85e90b3942d06b2326fba0403ec24fe912372936",
+ "reference": "85e90b3942d06b2326fba0403ec24fe912372936",
+ "shasum": ""
+ },
+ "require": {
+ "composer-plugin-api": "^2.0",
+ "php": "^7.2 || ^8.0",
+ "phpstan/phpstan": "^1.9.0 || ^2.0"
+ },
+ "require-dev": {
+ "composer/composer": "^2.0",
+ "php-parallel-lint/php-parallel-lint": "^1.2.0",
+ "phpstan/phpstan-strict-rules": "^0.11 || ^0.12 || ^1.0"
+ },
+ "type": "composer-plugin",
+ "extra": {
+ "class": "PHPStan\\ExtensionInstaller\\Plugin"
+ },
+ "autoload": {
+ "psr-4": {
+ "PHPStan\\ExtensionInstaller\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "description": "Composer plugin for automatic installation of PHPStan extensions",
+ "keywords": [
+ "dev",
+ "static analysis"
+ ],
+ "support": {
+ "issues": "https://github.com/phpstan/extension-installer/issues",
+ "source": "https://github.com/phpstan/extension-installer/tree/1.4.3"
+ },
+ "time": "2024-09-04T20:21:43+00:00"
+ },
{
"name": "phpstan/phpstan",
- "version": "1.12.13",
+ "version": "2.1.8",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpstan.git",
- "reference": "9b469068840cfa031e1deaf2fa1886d00e20680f"
+ "reference": "f9adff3b87c03b12cc7e46a30a524648e497758f"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/phpstan/phpstan/zipball/9b469068840cfa031e1deaf2fa1886d00e20680f",
- "reference": "9b469068840cfa031e1deaf2fa1886d00e20680f",
+ "url": "https://api.github.com/repos/phpstan/phpstan/zipball/f9adff3b87c03b12cc7e46a30a524648e497758f",
+ "reference": "f9adff3b87c03b12cc7e46a30a524648e497758f",
"shasum": ""
},
"require": {
- "php": "^7.2|^8.0"
+ "php": "^7.4|^8.0"
},
"conflict": {
"phpstan/phpstan-shim": "*"
@@ -975,7 +1025,54 @@
"type": "github"
}
],
- "time": "2024-12-17T17:00:20+00:00"
+ "time": "2025-03-09T09:30:48+00:00"
+ },
+ {
+ "name": "phpstan/phpstan-deprecation-rules",
+ "version": "2.0.1",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/phpstan/phpstan-deprecation-rules.git",
+ "reference": "1cc1259cb91ee4cfbb5c39bca9f635f067c910b4"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/phpstan/phpstan-deprecation-rules/zipball/1cc1259cb91ee4cfbb5c39bca9f635f067c910b4",
+ "reference": "1cc1259cb91ee4cfbb5c39bca9f635f067c910b4",
+ "shasum": ""
+ },
+ "require": {
+ "php": "^7.4 || ^8.0",
+ "phpstan/phpstan": "^2.0"
+ },
+ "require-dev": {
+ "php-parallel-lint/php-parallel-lint": "^1.2",
+ "phpstan/phpstan-phpunit": "^2.0",
+ "phpunit/phpunit": "^9.6"
+ },
+ "type": "phpstan-extension",
+ "extra": {
+ "phpstan": {
+ "includes": [
+ "rules.neon"
+ ]
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "PHPStan\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "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"
+ },
+ "time": "2024-11-28T21:56:36+00:00"
},
{
"name": "psr/container",
@@ -1199,33 +1296,33 @@
},
{
"name": "react/child-process",
- "version": "v0.6.5",
+ "version": "v0.6.6",
"source": {
"type": "git",
"url": "https://github.com/reactphp/child-process.git",
- "reference": "e71eb1aa55f057c7a4a0d08d06b0b0a484bead43"
+ "reference": "1721e2b93d89b745664353b9cfc8f155ba8a6159"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/reactphp/child-process/zipball/e71eb1aa55f057c7a4a0d08d06b0b0a484bead43",
- "reference": "e71eb1aa55f057c7a4a0d08d06b0b0a484bead43",
+ "url": "https://api.github.com/repos/reactphp/child-process/zipball/1721e2b93d89b745664353b9cfc8f155ba8a6159",
+ "reference": "1721e2b93d89b745664353b9cfc8f155ba8a6159",
"shasum": ""
},
"require": {
"evenement/evenement": "^3.0 || ^2.0 || ^1.0",
"php": ">=5.3.0",
"react/event-loop": "^1.2",
- "react/stream": "^1.2"
+ "react/stream": "^1.4"
},
"require-dev": {
- "phpunit/phpunit": "^9.3 || ^5.7 || ^4.8.35",
- "react/socket": "^1.8",
+ "phpunit/phpunit": "^9.6 || ^5.7 || ^4.8.36",
+ "react/socket": "^1.16",
"sebastian/environment": "^5.0 || ^3.0 || ^2.0 || ^1.0"
},
"type": "library",
"autoload": {
"psr-4": {
- "React\\ChildProcess\\": "src"
+ "React\\ChildProcess\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
@@ -1262,19 +1359,15 @@
],
"support": {
"issues": "https://github.com/reactphp/child-process/issues",
- "source": "https://github.com/reactphp/child-process/tree/v0.6.5"
+ "source": "https://github.com/reactphp/child-process/tree/v0.6.6"
},
"funding": [
{
- "url": "https://github.com/WyriHaximus",
- "type": "github"
- },
- {
- "url": "https://github.com/clue",
- "type": "github"
+ "url": "https://opencollective.com/reactphp",
+ "type": "open_collective"
}
],
- "time": "2022-09-16T13:41:56+00:00"
+ "time": "2025-01-01T16:37:48+00:00"
},
{
"name": "react/dns",
@@ -1928,12 +2021,12 @@
},
"type": "library",
"extra": {
+ "thanks": {
+ "url": "https://github.com/symfony/contracts",
+ "name": "symfony/contracts"
+ },
"branch-alias": {
"dev-main": "2.5-dev"
- },
- "thanks": {
- "name": "symfony/contracts",
- "url": "https://github.com/symfony/contracts"
}
},
"autoload": {
@@ -2743,12 +2836,12 @@
},
"type": "library",
"extra": {
+ "thanks": {
+ "url": "https://github.com/symfony/contracts",
+ "name": "symfony/contracts"
+ },
"branch-alias": {
"dev-main": "2.5-dev"
- },
- "thanks": {
- "name": "symfony/contracts",
- "url": "https://github.com/symfony/contracts"
}
},
"autoload": {
diff --git a/hook.php b/hook.php
index 1843cc8..d6150bf 100644
--- a/hook.php
+++ b/hook.php
@@ -32,6 +32,8 @@
function plugin_pdf_postinit()
{
+ /** @var array $CFG_GLPI */
+ /** @var array $PLUGIN_HOOKS */
global $CFG_GLPI, $PLUGIN_HOOKS;
foreach ($PLUGIN_HOOKS['plugin_pdf'] as $type => $typepdf) {
@@ -42,6 +44,7 @@ function plugin_pdf_postinit()
function plugin_pdf_MassiveActions($type)
{
+ /** @var array $PLUGIN_HOOKS */
global $PLUGIN_HOOKS;
switch ($type) {
@@ -58,6 +61,7 @@ function plugin_pdf_MassiveActions($type)
function plugin_pdf_install()
{
+ /** @var DBmysql $DB */
global $DB;
$migration = new Migration('3.0.0');
@@ -79,6 +83,7 @@ function plugin_pdf_install()
function plugin_pdf_uninstall()
{
+ /** @var DBmysql $DB */
global $DB;
$migration = new Migration('3.0.0');
@@ -94,7 +99,7 @@ function plugin_pdf_uninstall()
$query = "DELETE
FROM `glpi_profilerights`
WHERE `name` = 'plugin_pdf'";
- $DB->queryOrDie($query, $DB->error());
+ $DB->doQueryOrDie($query, $DB->error());
$migration->executeMigration();
@@ -107,6 +112,7 @@ function plugin_pdf_uninstall()
**/
function plugin_pdf_registerMethods()
{
+ /** @var array $WEBSERVICES_METHOD */
global $WEBSERVICES_METHOD;
$WEBSERVICES_METHOD['pdf.getTabs'] = ['PluginPdfRemote', 'methodGetTabs'];
diff --git a/inc/appliance.class.php b/inc/appliance.class.php
index 03219e2..0e99812 100644
--- a/inc/appliance.class.php
+++ b/inc/appliance.class.php
@@ -69,7 +69,10 @@ public static function displayTabContentForPDF(PluginPdfSimplePDF $pdf, CommonGL
switch ($tab) {
case 'Appliance_Item$1':
$plugin = new Plugin();
- if ($plugin->isActivated('appliances')) {
+ if (
+ $plugin->isActivated('appliances')
+ && class_exists('PluginAppliancesAppliance_Item')
+ ) {
PluginAppliancesAppliance_Item::pdfForAppliance($pdf, $item);
} else {
self::pdfForAppliance($pdf, $item);
@@ -77,7 +80,9 @@ public static function displayTabContentForPDF(PluginPdfSimplePDF $pdf, CommonGL
break;
case 'PluginAppliancesOptvalue$1':
- PluginAppliancesOptvalue::pdfForAppliance($pdf, $item);
+ if (class_exists('PluginAppliancesOptvalue')) {
+ PluginAppliancesOptvalue::pdfForAppliance($pdf, $item);
+ }
break;
default:
@@ -205,6 +210,7 @@ public static function pdfMain(PluginPdfSimplePDF $pdf, Appliance $item)
public static function pdfForAppliance(PluginPdfSimplePDF $pdf, Appliance $appli)
{
+ /** @var DBmysql $DB */
global $DB;
$instID = $appli->fields['id'];
@@ -331,6 +337,7 @@ public static function pdfForAppliance(PluginPdfSimplePDF $pdf, Appliance $appli
public static function showList_relation($pdf, $relID)
{
+ /** @var DBmysql $DB */
global $DB;
$dbu = new DbUtils();
@@ -381,6 +388,7 @@ public static function showList_relation($pdf, $relID)
**/
public static function showList_PDF($pdf, $ID, $appliancesID)
{
+ /** @var DBmysql $DB */
global $DB;
$result_app_opt = $DB->request(['FIELDS' => ['id', 'champ', 'ddefault', 'vvalues'],
@@ -419,6 +427,7 @@ public static function showList_PDF($pdf, $ID, $appliancesID)
public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonGLPI $item)
{
+ /** @var DBmysql $DB */
global $DB;
$dbu = new DbUtils();
@@ -469,15 +478,15 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonGLPI $item)
$pdf->setColumnsSize(30, 30, 20, 20);
$pdf->displayLine(
$data['name'],
- Html::clean(Dropdown::getDropdownName(
+ Toolbox::stripTags(Dropdown::getDropdownName(
'glpi_entities',
$data['entities_id'],
)),
- Html::clean(Dropdown::getDropdownName(
+ Toolbox::stripTags(Dropdown::getDropdownName(
'glpi_groups',
$data['groups_id'],
)),
- Html::clean(Dropdown::getDropdownName(
+ Toolbox::stripTags(Dropdown::getDropdownName(
'glpi_plugin_appliances_appliancetypes',
$data['plugin_appliances_appliancetypes_id'],
)),
@@ -486,18 +495,22 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonGLPI $item)
$pdf->setColumnsSize(50, 25, 25);
$pdf->displayLine(
$data['name'],
- Html::clean(Dropdown::getDropdownName(
+ Toolbox::stripTags(Dropdown::getDropdownName(
'glpi_groups',
$data['groups_id'],
)),
- Html::clean(Dropdown::getDropdownName(
+ Toolbox::stripTags(Dropdown::getDropdownName(
'glpi_plugin_appliances_appliancetypes',
$data['plugin_appliances_appliancetypes_id'],
)),
);
}
- PluginAppliancesRelation::showList_PDF($pdf, $data['relationtype'], $data['entID']);
- PluginAppliancesOptvalue_Item::showList_PDF($pdf, $ID, $appliancesID);
+ if (class_exists('PluginAppliancesRelation')) {
+ PluginAppliancesRelation::showList_PDF($pdf, $data['relationtype'], $data['entID']);
+ }
+ if (class_exists('PluginAppliancesOptvalue_Item')) {
+ PluginAppliancesOptvalue_Item::showList_PDF($pdf, $ID, $appliancesID);
+ }
$result->next();
}
}
diff --git a/inc/cartridge.class.php b/inc/cartridge.class.php
index da75e2a..7927319 100644
--- a/inc/cartridge.class.php
+++ b/inc/cartridge.class.php
@@ -49,6 +49,7 @@ public function __construct(CommonGLPI $obj = null)
**/
public static function pdfForPrinter(PluginPdfSimplePDF $pdf, Printer $p, $old = false)
{
+ /** @var DBmysql $DB */
global $DB;
$instID = $p->getField('id');
@@ -214,6 +215,7 @@ public static function pdfForPrinter(PluginPdfSimplePDF $pdf, Printer $p, $old =
public static function pdfForCartridgeItem(PluginPdfSimplePDF $pdf, CartridgeItem $cartitem, $state)
{
+ /** @var DBmysql $DB */
global $DB;
$tID = $cartitem->getField('id');
diff --git a/inc/change_item.class.php b/inc/change_item.class.php
index 9475d09..dc79da5 100644
--- a/inc/change_item.class.php
+++ b/inc/change_item.class.php
@@ -41,6 +41,7 @@ public function __construct(CommonGLPI $obj = null)
public static function pdfForChange(PluginPdfSimplePDF $pdf, Change $change)
{
+ /** @var DBmysql $DB */
global $DB;
$dbu = new DbUtils();
@@ -155,6 +156,7 @@ public static function pdfForChange(PluginPdfSimplePDF $pdf, Change $change)
public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item, $tree = false)
{
+ /** @var DBmysql $DB */
global $DB;
$dbu = new DbUtils();
diff --git a/inc/change_problem.class.php b/inc/change_problem.class.php
index 9a7ff6c..cb7c03f 100644
--- a/inc/change_problem.class.php
+++ b/inc/change_problem.class.php
@@ -41,6 +41,7 @@ public function __construct(CommonGLPI $obj = null)
public static function pdfForChange(PluginPdfSimplePDF $pdf, Change $change)
{
+ /** @var DBmysql $DB */
global $DB;
$dbu = new DbUtils();
@@ -282,6 +283,7 @@ public static function pdfForChange(PluginPdfSimplePDF $pdf, Change $change)
public static function pdfForProblem(PluginPdfSimplePDF $pdf, Problem $problem)
{
+ /** @var DBmysql $DB */
global $DB;
$dbu = new DbUtils();
diff --git a/inc/change_ticket.class.php b/inc/change_ticket.class.php
index 93c97c0..2a1ba78 100644
--- a/inc/change_ticket.class.php
+++ b/inc/change_ticket.class.php
@@ -41,6 +41,7 @@ public function __construct(CommonGLPI $obj = null)
public static function pdfForChange(PluginPdfSimplePDF $pdf, Change $change)
{
+ /** @var DBmysql $DB */
global $DB;
$dbu = new DbUtils();
@@ -310,6 +311,7 @@ public static function pdfForChange(PluginPdfSimplePDF $pdf, Change $change)
public static function pdfForTicket(PluginPdfSimplePDF $pdf, Ticket $ticket)
{
+ /** @var DBmysql $DB */
global $DB;
$dbu = new DbUtils();
diff --git a/inc/changetask.class.php b/inc/changetask.class.php
index 1e4f20f..46707d0 100644
--- a/inc/changetask.class.php
+++ b/inc/changetask.class.php
@@ -41,6 +41,7 @@ public function __construct(CommonGLPI $obj = null)
public static function pdfForChange(PluginPdfSimplePDF $pdf, Change $job)
{
+ /** @var DBmysql $DB */
global $DB;
$dbu = new DbUtils();
diff --git a/inc/changevalidation.class.php b/inc/changevalidation.class.php
index 07348b2..4fa840e 100644
--- a/inc/changevalidation.class.php
+++ b/inc/changevalidation.class.php
@@ -41,6 +41,7 @@ public function __construct(CommonGLPI $obj = null)
public static function pdfForChange(PluginPdfSimplePDF $pdf, Change $change)
{
+ /** @var DBmysql $DB */
global $DB;
$dbu = new DbUtils();
diff --git a/inc/common.class.php b/inc/common.class.php
index bede253..a24cce2 100644
--- a/inc/common.class.php
+++ b/inc/common.class.php
@@ -49,7 +49,7 @@ public function __construct(CommonGLPI $obj = null) {}
* @param $ong array defined tab array
* @param $options array of options (for withtemplate)
*
- * @return nothing (set the tab array)
+ * @return void (set the tab array)
**/
final public function addStandardTab($itemtype, &$ong, $options)
{
@@ -120,6 +120,7 @@ public function getTabNameForItem(CommonGLPI $item, $withtemplate = 0)
return __('Print to pdf', 'pdf');
}
}
+ return '';
}
/**
@@ -154,7 +155,7 @@ final public static function displayCommonTabForPDF(PluginPdfSimplePDF $pdf, Com
{
switch ($tab) {
case $item->getType() . '$main':
- static::pdfMain($pdf, $item);
+ $item::pdfMain($pdf, $item);
break;
case 'Notepad$1':
@@ -361,7 +362,7 @@ public static function pdfNote(PluginPdfSimplePDF $pdf, CommonDBTM $item)
* @param $page Integer 1 for landscape, 0 for portrait
* @param $render Boolean send result if true, return result if false
*
- * @return pdf output if $render is false
+ * @return string pdf output if $render is false
**/
final public function generatePDF($tab_id, $tabs, $page = 0, $render = true)
{
@@ -417,6 +418,7 @@ final public function generatePDF($tab_id, $tabs, $page = 0, $render = true)
if ($render) {
$this->pdf->render();
+ return '';
} else {
return $this->pdf->output();
}
diff --git a/inc/commonitilcost.class.php b/inc/commonitilcost.class.php
index a759dde..e59eb40 100644
--- a/inc/commonitilcost.class.php
+++ b/inc/commonitilcost.class.php
@@ -41,6 +41,7 @@ public function __construct(CommonGLPI $obj = null)
public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $job)
{
+ /** @var DBmysql $DB */
global $DB;
$ID = $job->getField('id');
diff --git a/inc/computer.class.php b/inc/computer.class.php
index 05320cf..19b5a54 100644
--- a/inc/computer.class.php
+++ b/inc/computer.class.php
@@ -195,10 +195,6 @@ public static function displayTabContentForPDF(PluginPdfSimplePDF $pdf, CommonGL
PluginPdfComputerAntivirus::pdfForComputer($pdf, $item);
break;
- case 'RegistryKey$1':
- PluginPdfRegistryKey::pdfForComputer($pdf, $item);
- break;
-
case 'Computer_Item$1':
PluginPdfComputer_Item::pdfForComputer($pdf, $item);
break;
diff --git a/inc/computer_item.class.php b/inc/computer_item.class.php
index 6dd169d..4bdb318 100644
--- a/inc/computer_item.class.php
+++ b/inc/computer_item.class.php
@@ -41,6 +41,7 @@ public function __construct(CommonGLPI $obj = null)
public static function pdfForComputer(PluginPdfSimplePDF $pdf, Computer $comp)
{
+ /** @var DBmysql $DB */
global $DB;
$dbu = new DbUtils();
@@ -170,6 +171,7 @@ public static function pdfForComputer(PluginPdfSimplePDF $pdf, Computer $comp)
public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
{
+ /** @var DBmysql $DB */
global $DB;
$ID = $item->getField('id');
diff --git a/inc/computer_softwarelicense.class.php b/inc/computer_softwarelicense.class.php
index 14ff457..638fce8 100644
--- a/inc/computer_softwarelicense.class.php
+++ b/inc/computer_softwarelicense.class.php
@@ -36,11 +36,12 @@ class PluginPdfComputer_SoftwareLicense extends PluginPdfCommon
public function __construct(CommonGLPI $obj = null)
{
- $this->obj = ($obj ? $obj : new Iem_SoftwareLicense());
+ $this->obj = ($obj ? $obj : new Item_SoftwareLicense());
}
public static function pdfForLicenseByEntity(PluginPdfSimplePDF $pdf, SoftwareLicense $license)
{
+ /** @var DBmysql $DB */
global $DB;
$dbu = new DbUtils();
@@ -87,6 +88,7 @@ public static function pdfForLicenseByEntity(PluginPdfSimplePDF $pdf, SoftwareLi
public static function pdfForLicenseByComputer(PluginPdfSimplePDF $pdf, SoftwareLicense $license)
{
+ /** @var DBmysql $DB */
global $DB;
$dbu = new DbUtils();
diff --git a/inc/computer_softwareversion.class.php b/inc/computer_softwareversion.class.php
index 8d2d05c..2844bb8 100644
--- a/inc/computer_softwareversion.class.php
+++ b/inc/computer_softwareversion.class.php
@@ -41,6 +41,7 @@ public function __construct(CommonGLPI $obj = null)
public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
{
+ /** @var DBmysql $DB */
global $DB;
$dbu = new DbUtils();
@@ -196,6 +197,7 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
public static function pdfForVersionByEntity(PluginPdfSimplePDF $pdf, SoftwareVersion $version)
{
+ /** @var DBmysql $DB */
global $DB;
$dbu = new DbUtils();
@@ -253,6 +255,7 @@ public static function pdfForVersionByEntity(PluginPdfSimplePDF $pdf, SoftwareVe
public static function pdfForComputer(PluginPdfSimplePDF $pdf, Computer $comp)
{
+ /** @var DBmysql $DB */
global $DB;
$ID = $comp->getField('id');
diff --git a/inc/computerantivirus.class.php b/inc/computerantivirus.class.php
index 5331aac..bcda467 100644
--- a/inc/computerantivirus.class.php
+++ b/inc/computerantivirus.class.php
@@ -41,6 +41,7 @@ public function __construct(CommonGLPI $obj = null)
public static function pdfForComputer(PluginPdfSimplePDF $pdf, Computer $item)
{
+ /** @var DBmysql $DB */
global $DB;
$ID = $item->getField('id');
diff --git a/inc/config.class.php b/inc/config.class.php
index c533e08..c523802 100644
--- a/inc/config.class.php
+++ b/inc/config.class.php
@@ -104,6 +104,7 @@ public static function getInstance()
public static function install(Migration $mig)
{
+ /** @var DBmysql $DB */
global $DB;
$table = 'glpi_plugin_pdf_configs';
@@ -120,13 +121,13 @@ public static function install(Migration $mig)
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET= {$default_charset}
COLLATE = {$default_collation} ROW_FORMAT=DYNAMIC";
- $DB->queryOrDie($query, 'Error in creating glpi_plugin_pdf_configs' .
+ $DB->doQueryOrDie($query, 'Error in creating glpi_plugin_pdf_configs' .
'
' . $DB->error());
$query = "INSERT INTO `$table`
(id, currency)
VALUES (1, 'EUR')";
- $DB->queryOrDie($query, 'Error during update glpi_plugin_pdf_configs' .
+ $DB->doQueryOrDie($query, 'Error during update glpi_plugin_pdf_configs' .
'
' . $DB->error());
} else {
// 2.1.0
@@ -146,6 +147,7 @@ public static function install(Migration $mig)
public static function showConfigForm($item)
{
+ /** @var array $PDF_DEVICES */
global $PDF_DEVICES;
$config = self::getInstance();
@@ -357,6 +359,7 @@ public static function currency()
public static function formatNumber($value)
{
+ /** @var array $PDF_DEVICES */
global $PDF_DEVICES;
@@ -385,6 +388,7 @@ public static function formatNumber($value)
public static function currencyName()
{
+ /** @var array $PDF_DEVICES */
global $PDF_DEVICES;
$config = self::getInstance();
diff --git a/inc/consumableitem.class.php b/inc/consumableitem.class.php
index e6185ca..c0928f1 100644
--- a/inc/consumableitem.class.php
+++ b/inc/consumableitem.class.php
@@ -137,6 +137,7 @@ public static function displayTabContentForPDF(PluginPdfSimplePDF $pdf, CommonGL
public static function pdfForConsumableItem(PluginPdfSimplePDF $pdf, ConsumableItem $item, $show_old = false)
{
+ /** @var DBmysql $DB */
global $DB;
$dbu = new DbUtils();
diff --git a/inc/contract.class.php b/inc/contract.class.php
index e254693..783a73d 100644
--- a/inc/contract.class.php
+++ b/inc/contract.class.php
@@ -202,6 +202,7 @@ public static function displayTabContentForPDF(PluginPdfSimplePDF $pdf, CommonGL
public static function pdfCost(PluginPdfSimplePDF $pdf, Contract $contract)
{
+ /** @var DBmysql $DB */
global $DB;
$ID = $contract->getField('id');
diff --git a/inc/contract_item.class.php b/inc/contract_item.class.php
index 26abfd3..41f6251 100644
--- a/inc/contract_item.class.php
+++ b/inc/contract_item.class.php
@@ -41,6 +41,7 @@ public function __construct(CommonGLPI $obj = null)
public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
{
+ /** @var DBmysql $DB */
global $DB;
$type = $item->getType();
@@ -122,6 +123,7 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
public static function pdfForContract(PluginPdfSimplePDF $pdf, Contract $contract)
{
+ /** @var DBmysql $DB */
global $DB;
$instID = $contract->fields['id'];
diff --git a/inc/document.class.php b/inc/document.class.php
index 8656f84..d736544 100644
--- a/inc/document.class.php
+++ b/inc/document.class.php
@@ -41,6 +41,7 @@ public function __construct(CommonGLPI $obj = null)
public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
{
+ /** @var DBmysql $DB */
global $DB;
$ID = $item->getField('id');
diff --git a/inc/domain_item.class.php b/inc/domain_item.class.php
index bcec0a9..95f899f 100644
--- a/inc/domain_item.class.php
+++ b/inc/domain_item.class.php
@@ -41,6 +41,7 @@ public function __construct(CommonGLPI $obj = null)
public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
{
+ /** @var DBmysql $DB */
global $DB;
$ID = $item->getField('id');
diff --git a/inc/group.class.php b/inc/group.class.php
index 032e2d0..f03b235 100644
--- a/inc/group.class.php
+++ b/inc/group.class.php
@@ -154,6 +154,7 @@ public static function pdfLdapForm(PluginPdfSimplePDF $pdf, Group $item)
// From Group::showItems()
public static function pdfItems(PluginPdfSimplePDF $pdf, Group $group, $tech, $tree, $user)
{
+ /** @var array $CFG_GLPI */
global $CFG_GLPI;
$dbu = new DbUtils();
@@ -237,6 +238,7 @@ public function defineAllTabsPDF($options = [])
public static function pdfChildren(PluginPdfSimplePDF $pdf, CommonTreeDropdown $item)
{
+ /** @var DBmysql $DB */
global $DB;
$ID = $item->getID();
diff --git a/inc/infocom.class.php b/inc/infocom.class.php
index 1c815a4..b5c2337 100644
--- a/inc/infocom.class.php
+++ b/inc/infocom.class.php
@@ -41,6 +41,8 @@ public function __construct(CommonGLPI $obj = null)
public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
{
+ /** @var array $CFG_GLPI */
+ /** @var array $PDF_DEVICES */
global $CFG_GLPI, $PDF_DEVICES;
$ID = $item->getField('id');
diff --git a/inc/item_device.class.php b/inc/item_device.class.php
index fdd7a83..2751651 100644
--- a/inc/item_device.class.php
+++ b/inc/item_device.class.php
@@ -41,6 +41,7 @@ public function __construct(CommonGLPI $obj = null)
public static function pdfForItem(PluginPdfSimplePDF $pdf, $item)
{
+ /** @var DBmysql $DB */
global $DB;
$dbu = new DbUtils();
diff --git a/inc/item_disk.class.php b/inc/item_disk.class.php
index 7396579..2f34df7 100644
--- a/inc/item_disk.class.php
+++ b/inc/item_disk.class.php
@@ -41,6 +41,7 @@ public function __construct(CommonGLPI $obj = null)
public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
{
+ /** @var DBmysql $DB */
global $DB;
$ID = $item->getField('id');
diff --git a/inc/item_knowbaseitem.class.php b/inc/item_knowbaseitem.class.php
index 792eca8..ea94432 100644
--- a/inc/item_knowbaseitem.class.php
+++ b/inc/item_knowbaseitem.class.php
@@ -41,6 +41,7 @@ public function __construct(CommonGLPI $obj = null)
public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
{
+ /** @var DBmysql $DB */
global $DB;
$ID = $item->getField('id');
diff --git a/inc/item_operatingsystem.class.php b/inc/item_operatingsystem.class.php
index 4a9eb44..6d94a51 100644
--- a/inc/item_operatingsystem.class.php
+++ b/inc/item_operatingsystem.class.php
@@ -41,6 +41,7 @@ public function __construct(CommonGLPI $obj = null)
public static function pdfForItem(PluginPdfSimplePDF $pdf, $item)
{
+ /** @var DBmysql $DB */
global $DB;
diff --git a/inc/item_problem.class.php b/inc/item_problem.class.php
index 44dcca4..dc97b9a 100644
--- a/inc/item_problem.class.php
+++ b/inc/item_problem.class.php
@@ -41,6 +41,7 @@ public function __construct(CommonGLPI $obj = null)
public static function pdfForProblem(PluginPdfSimplePDF $pdf, Problem $problem)
{
+ /** @var DBmysql $DB */
global $DB;
$dbu = new DbUtils();
@@ -156,6 +157,7 @@ public static function pdfForProblem(PluginPdfSimplePDF $pdf, Problem $problem)
public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item, $tree = false)
{
+ /** @var DBmysql $DB */
global $DB;
$dbu = new DbUtils();
diff --git a/inc/item_softwarelicense.class.php b/inc/item_softwarelicense.class.php
index 9e3c91e..14cd3e0 100644
--- a/inc/item_softwarelicense.class.php
+++ b/inc/item_softwarelicense.class.php
@@ -41,6 +41,7 @@ public function __construct(CommonGLPI $obj = null)
public static function pdfForLicenseByEntity(PluginPdfSimplePDF $pdf, SoftwareLicense $license)
{
+ /** @var DBmysql $DB */
global $DB;
$dbu = new DbUtils();
@@ -87,6 +88,7 @@ public static function pdfForLicenseByEntity(PluginPdfSimplePDF $pdf, SoftwareLi
public static function pdfForLicenseByComputer(PluginPdfSimplePDF $pdf, SoftwareLicense $license)
{
+ /** @var DBmysql $DB */
global $DB;
$dbu = new DbUtils();
diff --git a/inc/item_softwareversion.class.php b/inc/item_softwareversion.class.php
index 3389683..3145e27 100644
--- a/inc/item_softwareversion.class.php
+++ b/inc/item_softwareversion.class.php
@@ -41,6 +41,8 @@ public function __construct(CommonGLPI $obj = null)
public static function pdfForSoftware(PluginPdfSimplePDF $pdf, CommonDBTM $item)
{
+ /** @var array $CFG_GLPI */
+ /** @var DBmysql $DB */
global $DB, $CFG_GLPI;
$dbu = new DbUtils();
@@ -260,6 +262,7 @@ public static function pdfForSoftware(PluginPdfSimplePDF $pdf, CommonDBTM $item)
public static function pdfForVersionByEntity(PluginPdfSimplePDF $pdf, SoftwareVersion $version)
{
+ /** @var DBmysql $DB */
global $DB;
$dbu = new DbUtils();
@@ -317,6 +320,7 @@ public static function pdfForVersionByEntity(PluginPdfSimplePDF $pdf, SoftwareVe
public static function pdfForItem(PluginPdfSimplePDF $pdf, $item)
{
+ /** @var DBmysql $DB */
global $DB;
$ID = $item->getField('id');
diff --git a/inc/item_ticket.class.php b/inc/item_ticket.class.php
index 0e51783..7d62437 100644
--- a/inc/item_ticket.class.php
+++ b/inc/item_ticket.class.php
@@ -41,6 +41,7 @@ public function __construct(CommonGLPI $obj = null)
public static function pdfForTicket(PluginPdfSimplePDF $pdf, Ticket $ticket, $sub = false)
{
+ /** @var DBmysql $DB */
global $DB;
$dbu = new DbUtils();
@@ -156,6 +157,7 @@ public static function pdfForTicket(PluginPdfSimplePDF $pdf, Ticket $ticket, $su
public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item, $tree = false)
{
+ /** @var DBmysql $DB */
global $DB;
$dbu = new DbUtils();
diff --git a/inc/itilfollowup.class.php b/inc/itilfollowup.class.php
index d0ffbfe..e018bb6 100644
--- a/inc/itilfollowup.class.php
+++ b/inc/itilfollowup.class.php
@@ -41,6 +41,7 @@ public function __construct(CommonGLPI $obj = null)
public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item, $private)
{
+ /** @var DBmysql $DB */
global $DB;
$dbu = new DbUtils();
diff --git a/inc/itilsolution.class.php b/inc/itilsolution.class.php
index fb92909..ec0f6ff 100644
--- a/inc/itilsolution.class.php
+++ b/inc/itilsolution.class.php
@@ -41,6 +41,7 @@ public function __construct(CommonGLPI $obj = null)
public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
{
+ /** @var DBmysql $DB */
global $DB;
$dbu = new DbUtils();
diff --git a/inc/link.class.php b/inc/link.class.php
index 2cf61fd..1956c35 100644
--- a/inc/link.class.php
+++ b/inc/link.class.php
@@ -41,6 +41,7 @@ public function __construct(CommonGLPI $obj = null)
public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
{
+ /** @var DBmysql $DB */
global $DB;
$ID = $item->getField('id');
diff --git a/inc/networkport.class.php b/inc/networkport.class.php
index 74b5105..fb80fbd 100644
--- a/inc/networkport.class.php
+++ b/inc/networkport.class.php
@@ -43,6 +43,7 @@ public function __construct(CommonGLPI $obj = null)
public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
{
+ /** @var DBmysql $DB */
global $DB;
$dbu = new DbUtils();
diff --git a/inc/preference.class.php b/inc/preference.class.php
index 0a69545..a024925 100644
--- a/inc/preference.class.php
+++ b/inc/preference.class.php
@@ -36,6 +36,7 @@ class PluginPdfPreference extends CommonDBTM
public static function showPreferences()
{
+ /** @var array $PLUGIN_HOOKS */
global $PLUGIN_HOOKS;
$target = Toolbox::getItemTypeFormURL(__CLASS__);
@@ -71,6 +72,8 @@ public function checkbox($num, $label, $checked = false)
**/
public function menu($item, $action)
{
+ /** @var DBmysql $DB */
+ /** @var array $PLUGIN_HOOKS */
global $DB, $PLUGIN_HOOKS;
$type = $item->getType();
@@ -198,14 +201,15 @@ public static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $
public static function install(Migration $mig)
{
+ /** @var DBmysql $DB */
global $DB;
$table = 'glpi_plugin_pdf_preferences';
+ $default_key_sign = DBConnection::getDefaultPrimaryKeySignOption();
if (!$DB->tableExists('glpi_plugin_pdf_preference')
&& !$DB->tableExists($table)) {
$default_charset = DBConnection::getDefaultCharset();
$default_collation = DBConnection::getDefaultCollation();
- $default_key_sign = DBConnection::getDefaultPrimaryKeySignOption();
$query = 'CREATE TABLE `' . $table . "`(
`id` int $default_key_sign NOT NULL AUTO_INCREMENT,
@@ -215,7 +219,7 @@ public static function install(Migration $mig)
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET= {$default_charset}
COLLATE = {$default_collation} ROW_FORMAT=DYNAMIC";
- $DB->queryOrDie($query, $DB->error());
+ $DB->doQueryOrDie($query, $DB->error());
} else {
if ($DB->tableExists('glpi_plugin_pdf_preference')) {
$mig->renameTable('glpi_plugin_pdf_preference', 'glpi_plugin_pdf_preferences');
@@ -232,7 +236,7 @@ public static function install(Migration $mig)
}
// 0.6.1
if ($DB->fieldExists($table, 'FK_users')) {
- $mig > changeField(
+ $mig->changeField(
$table,
'FK_users',
'users_id',
@@ -270,13 +274,6 @@ public static function install(Migration $mig)
['comment' => 'ref of tab to display, or plugname_#, or option name'],
);
}
- //0.85
- if (isset($main)) {
- $query = "UPDATE `glpi_plugin_pdf_preferences`
- SET `tabref`= CONCAT(`itemtype`,'$main')
- WHERE `tabref`='_main_'";
- $DB->queryOrDie($query, 'update tabref for main');
- }
}
}
}
diff --git a/inc/problem.class.php b/inc/problem.class.php
index c027014..331dba8 100644
--- a/inc/problem.class.php
+++ b/inc/problem.class.php
@@ -304,257 +304,6 @@ public static function pdfMain(PluginPdfSimplePDF $pdf, Problem $job)
$pdf->displaySpace();
}
- public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item, $tree = false)
- {
- global $DB;
-
- $dbu = new DbUtils();
- $ID = $item->getField('id');
- $type = $item->getType();
-
- if (!Session::haveRight('problem', Problem::READALL)) {
- return;
- }
-
- switch ($item->getType()) {
- case 'User':
- $restrict = "(`glpi_problems_users`.`users_id` = '" . $item->getID() . "'
- AND `glpi_problems_users`.`type` = " . CommonITILActor::REQUESTER . ')';
- $order = '`glpi_problems`.`date_mod` DESC';
-
- // no break
- case 'Supplier':
- $restrict = "(`glpi_problems_suppliers`.`suppliers_id` = '" . $item->getID() . "'
- AND `glpi_problems_suppliers`.`type` = " . CommonITILActor::REQUESTER . ')';
- $order = '`glpi_problems`.`date_mod` DESC';
-
- // no break
- case 'Group':
- if ($tree) {
- $restrict = 'IN (' . implode(',', $dbu->getSonsOf('glpi_groups', $item->getID())) . ')';
- } else {
- $restrict = "='" . $item->getID() . "'";
- }
- $restrict = "(`glpi_groups_problems`.`groups_id` $restrict
- AND `glpi_groups_problems`.`type` = " . CommonITILActor::REQUESTER . ')';
- $order = '`glpi_problems`.`date_mod` DESC';
-
- // no break
- default:
- $restrict = "(`items_id` = '" . $item->getID() . "' AND `itemtype` = '$type')";
- $order = '`glpi_problems`.`date_mod` DESC';
- }
-
- $query = 'SELECT ' . Problem::getCommonSelect() . '
- FROM `glpi_problems`
- LEFT JOIN `glpi_items_problems`
- ON (`glpi_problems`.`id` = `glpi_items_problems`.`problems_id`) ' .
- Problem::getCommonLeftJoin() . "
- WHERE $restrict " .
- $dbu->getEntitiesRestrictRequest('AND', 'glpi_problems') . "
- ORDER BY $order
- LIMIT " . intval($_SESSION['glpilist_limit']);
-
- $result = $DB->query($query);
- $number = $DB->numrows($result);
-
- $pdf->setColumnsSize(100);
- if (!$number) {
- $pdf->displayTitle('' . __('No problem found.') . '');
- } else {
- $pdf->displayTitle('' . sprintf(
- _n('Last %d problem', 'Last %d problems', $number),
- $number . '',
- ));
-
- $job = new Problem();
- while ($data = $DB->fetchAssoc($result)) {
- if (!$job->getFromDB($data['id'])) {
- continue;
- }
- $pdf->setColumnsAlign('center');
- $col = 'ID ' . $job->fields['id'] . ', ' .
- sprintf(
- __('%1$s: %2$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'));
- } else {
- $col = sprintf(
- __('%1$s (%2$s)'),
- $col,
- Dropdown::getDropdownName(
- 'glpi_entities',
- -$job->fields['entities_id'],
- ),
- );
- }
- }
- $pdf->displayLine($col);
-
- $pdf->setColumnsAlign('left');
- $col = '' . sprintf(
- __('Opened on %s') . '',
- Html::convDateTime($job->fields['date']),
- );
- if ($job->fields['begin_waiting_date']) {
- $col = sprintf(
- __('%1$s, %2$s'),
- $col,
- '' . sprintf(
- __('Put on hold on %s') . '',
- Html::convDateTime($job->fields['begin_waiting_date']),
- ),
- );
- }
- if (in_array($job->fields['status'], $job->getSolvedStatusArray())
- || in_array($job->fields['status'], $job->getClosedStatusArray())) {
- $col = sprintf(
- __('%1$s, %2$s'),
- $col,
- '' . sprintf(
- __('Solved on %s') . '',
- Html::convDateTime($job->fields['solvedate']),
- ),
- );
- }
- if (in_array($job->fields['status'], $job->getClosedStatusArray())) {
- $col = sprintf(
- __('%1$s, %2$s'),
- $col,
- '' . sprintf(
- __('Closed on %s') . '',
- Html::convDateTime($job->fields['closedate']),
- ),
- );
- }
- if ($job->fields['time_to_resolve']) {
- $col = sprintf(
- __('%1$s, %2$s'),
- $col,
- '' . sprintf(
- __('%1$s: %2$s') . '',
- __('Time to resolve'),
- Html::convDateTime($job->fields['time_to_resolve']),
- ),
- );
- }
- $pdf->displayLine($col);
-
- $col = '' . sprintf(
- __('%1$s: %2$s'),
- __('Priority') . '',
- Ticket::getPriorityName($job->fields['priority']),
- );
- if ($job->fields['itilcategories_id']) {
- $col = sprintf(
- __('%1$s - %2$s'),
- $col,
- '' . sprintf(
- __('%1$s: %2$s') . '',
- __('Category'),
- Dropdown::getDropdownName(
- 'glpi_itilcategories',
- $job->fields['itilcategories_id'],
- ),
- ),
- );
- }
- $pdf->displayLine($col);
-
- $col = '';
- $users = $job->getUsers(CommonITILActor::REQUESTER);
- if (count($users)) {
- foreach ($users as $d) {
- if (empty($col)) {
- $col = getUserName($d['users_id']);
- } else {
- $col = sprintf(__('%1$s, %2$s'), $col, 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) . ' ');
- } else {
- $col = sprintf(__('%1$s - %2$s'), $col, _n('Group', 'Groups', 2) . ' ');
- }
- $first = true;
- foreach ($grps as $d) {
- if ($first) {
- $col = sprintf(
- __('%1$s %2$s'),
- $col,
- Dropdown::getDropdownName('glpi_groups', $d['groups_id']),
- );
- } else {
- $col = sprintf(
- __('%1$s, %2$s'),
- $col,
- Dropdown::getDropdownName('glpi_groups', $d['groups_id']),
- );
- }
- $first = false;
- }
- }
- if ($col) {
- $texte = '' . sprintf(__('%1$s: %2$s'), __('Requester') . '', '');
- $pdf->displayText($texte, $col, 1);
- }
-
- $col = '';
- $users = $job->getUsers(CommonITILActor::ASSIGN);
- if (count($users)) {
- foreach ($users as $d) {
- if (empty($col)) {
- $col = getUserName($d['users_id']);
- } else {
- $col = sprintf(__('%1$s, %2$s'), $col, 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) . ' ');
- } else {
- $col = sprintf(__('%1$s - %2$s'), $col, _n('Group', 'Groups', 2) . ' ');
- }
- $first = true;
- foreach ($grps as $d) {
- if ($first) {
- $col = sprintf(
- __('%1$s %2$s'),
- $col,
- Dropdown::getDropdownName('glpi_groups', $d['groups_id']),
- );
- } else {
- $col = sprintf(
- __('%1$s, %2$s'),
- $col,
- Dropdown::getDropdownName('glpi_groups', $d['groups_id']),
- );
- }
- $first = false;
- }
- }
- if ($col) {
- $texte = '' . sprintf(__('%1$s: %2$s') . '', ('Assigned to'), '');
- $pdf->displayText($texte, $col, 1);
- }
-
- $texte = '' . sprintf(__('%1$s: %2$s') . '', ('Title'), '');
- $pdf->displayText($texte, $job->fields['name'], 1);
- }
- }
- $pdf->displaySpace();
- }
-
public static function pdfAnalysis(PluginPdfSimplePDF $pdf, Problem $job)
{
$pdf->setColumnsSize(100);
diff --git a/inc/problem_ticket.class.php b/inc/problem_ticket.class.php
index 727c95b..93faf1f 100644
--- a/inc/problem_ticket.class.php
+++ b/inc/problem_ticket.class.php
@@ -41,6 +41,7 @@ public function __construct(CommonGLPI $obj = null)
public static function pdfForTicket(PluginPdfSimplePDF $pdf, Ticket $ticket)
{
+ /** @var DBmysql $DB */
global $DB;
$dbu = new DbUtils();
@@ -280,6 +281,7 @@ public static function pdfForTicket(PluginPdfSimplePDF $pdf, Ticket $ticket)
public static function pdfForProblem(PluginPdfSimplePDF $pdf, Problem $problem)
{
+ /** @var DBmysql $DB */
global $DB;
$dbu = new DbUtils();
diff --git a/inc/problemtask.class.php b/inc/problemtask.class.php
index 363bd44..1c3cae5 100755
--- a/inc/problemtask.class.php
+++ b/inc/problemtask.class.php
@@ -41,6 +41,7 @@ public function __construct(CommonGLPI $obj = null)
public static function pdfForProblem(PluginPdfSimplePDF $pdf, Problem $job)
{
+ /** @var DBmysql $DB */
global $DB;
$dbu = new DbUtils();
diff --git a/inc/profile.class.php b/inc/profile.class.php
index 6bf41c4..e5c6124 100644
--- a/inc/profile.class.php
+++ b/inc/profile.class.php
@@ -85,6 +85,7 @@ public function showForm($ID, $options = [])
echo "\n";
Html::closeForm();
}
+ return true;
}
public function getTabNameForItem(CommonGLPI $item, $withtemplate = 0)
@@ -154,6 +155,7 @@ public static function getAllRights($all = false)
public static function initProfile()
{
+ /** @var DBmysql $DB */
global $DB;
$profile = new self();
@@ -189,6 +191,7 @@ public static function removeRightsFromSession()
public static function install(Migration $mig)
{
+ /** @var DBmysql $DB */
global $DB;
$table = 'glpi_plugin_pdf_profiles';
diff --git a/inc/remote.class.php b/inc/remote.class.php
index b78e405..fe18e67 100644
--- a/inc/remote.class.php
+++ b/inc/remote.class.php
@@ -36,6 +36,7 @@ class PluginPdfRemote
public static function methodGetTabs($params, $protocol)
{
+ /** @var array $PLUGIN_HOOKS */
global $PLUGIN_HOOKS;
if (isset($params['help'])) {
@@ -59,6 +60,7 @@ public static function methodGetTabs($params, $protocol)
if (isset($PLUGIN_HOOKS['plugin_pdf'][$type])
&& class_exists($PLUGIN_HOOKS['plugin_pdf'][$type])) {
+ $item = new $type();
$itempdf = new $PLUGIN_HOOKS['plugin_pdf'][$type]($item);
return $itempdf->defineAllTabs();
@@ -69,6 +71,7 @@ public static function methodGetTabs($params, $protocol)
public static function methodGetPdf($params, $protocol)
{
+ /** @var array $PLUGIN_HOOKS */
global $PLUGIN_HOOKS;
if (isset($params['help'])) {
diff --git a/inc/reservation.class.php b/inc/reservation.class.php
index 4eb3de0..b601a3f 100644
--- a/inc/reservation.class.php
+++ b/inc/reservation.class.php
@@ -41,6 +41,7 @@ public function __construct(CommonGLPI $obj = null)
public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
{
+ /** @var DBmysql $DB */
global $DB;
$ID = $item->getField('id');
@@ -145,6 +146,7 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
public static function pdfForUser(PluginPdfSimplePDF $pdf, User $user)
{
+ /** @var DBmysql $DB */
global $DB;
$ID = $user->getField('id');
diff --git a/inc/simplepdf.class.php b/inc/simplepdf.class.php
index d57956c..f3387bf 100644
--- a/inc/simplepdf.class.php
+++ b/inc/simplepdf.class.php
@@ -148,7 +148,7 @@ public function render()
*
* @param $name String optional filename
*
- * @return String with PDF content if filename not provided
+ * @return string|void with PDF content if filename not provided
**/
public function output($name = false)
{
@@ -219,7 +219,7 @@ public function setColumnsAlign()
**/
public function displayBox($gray)
{
- Toolbox::displayBox('PluginPdfSimplePDF::displayBox() is deprecated');
+ Toolbox::deprecated('Calling this function is deprecated');
}
/**
diff --git a/inc/softwarelicense.class.php b/inc/softwarelicense.class.php
index 4ccf975..1855f60 100644
--- a/inc/softwarelicense.class.php
+++ b/inc/softwarelicense.class.php
@@ -144,6 +144,7 @@ public static function pdfMain(PluginPdfSimplePDF $pdf, SoftwareLicense $license
public static function pdfForSoftware(PluginPdfSimplePDF $pdf, Software $software, $infocom = false)
{
+ /** @var DBmysql $DB */
global $DB;
$sID = $software->getField('id');
diff --git a/inc/softwareversion.class.php b/inc/softwareversion.class.php
index 1e722a3..ffdf290 100644
--- a/inc/softwareversion.class.php
+++ b/inc/softwareversion.class.php
@@ -86,6 +86,7 @@ public static function pdfMain(PluginPdfSimplePDF $pdf, SoftwareVersion $version
public static function pdfForSoftware(PluginPdfSimplePDF $pdf, Software $item)
{
+ /** @var DBmysql $DB */
global $DB;
$sID = $item->getField('id');
diff --git a/inc/ticket_contract.class.php b/inc/ticket_contract.class.php
index 37a0c2f..a3f21e2 100644
--- a/inc/ticket_contract.class.php
+++ b/inc/ticket_contract.class.php
@@ -41,6 +41,7 @@ public function __construct(CommonGLPI $obj = null)
public static function pdfForTicket(PluginPdfSimplePDF $pdf, CommonDBTM $item)
{
+ /** @var DBmysql $DB */
global $DB;
$type = $item->getType();
diff --git a/inc/tickettask.class.php b/inc/tickettask.class.php
index 82b4693..8b4b8d5 100644
--- a/inc/tickettask.class.php
+++ b/inc/tickettask.class.php
@@ -41,6 +41,7 @@ public function __construct(CommonGLPI $obj = null)
public static function pdfForTicket(PluginPdfSimplePDF $pdf, Ticket $job, $private)
{
+ /** @var DBmysql $DB */
global $DB;
$dbu = new DbUtils();
diff --git a/inc/ticketvalidation.class.php b/inc/ticketvalidation.class.php
index f0f0050..97e2159 100644
--- a/inc/ticketvalidation.class.php
+++ b/inc/ticketvalidation.class.php
@@ -41,6 +41,7 @@ public function __construct(CommonGLPI $obj = null)
public static function pdfForTicket(PluginPdfSimplePDF $pdf, Ticket $ticket)
{
+ /** @var DBmysql $DB */
global $DB;
$dbu = new DbUtils();
diff --git a/inc/user.class.php b/inc/user.class.php
index f3da21c..fde5235 100644
--- a/inc/user.class.php
+++ b/inc/user.class.php
@@ -41,6 +41,7 @@ public function __construct(CommonGLPI $obj = null)
public static function pdfMain(PluginPdfSimplePDF $pdf, User $item)
{
+ /** @var DBmysql $DB */
global $DB;
$ID = $item->getField('id');
@@ -186,6 +187,8 @@ public static function pdfMain(PluginPdfSimplePDF $pdf, User $item)
public static function pdfItems(PluginPdfSimplePDF $pdf, User $user, $tech)
{
+ /** @var array $CFG_GLPI */
+ /** @var DBmysql $DB */
global $CFG_GLPI, $DB;
$dbu = new DbUtils();
diff --git a/phpstan.neon b/phpstan.neon
new file mode 100644
index 0000000..de8ee41
--- /dev/null
+++ b/phpstan.neon
@@ -0,0 +1,22 @@
+parameters:
+ parallel:
+ maximumNumberOfProcesses: 2
+ level: 0
+ bootstrapFiles:
+ - ../../inc/based_config.php
+ paths:
+ - front
+ - inc
+ - tools
+ - .php-cs-fixer.php
+ - hook.php
+ - setup.php
+ scanDirectories:
+ - ../../inc
+ - ../../src
+ stubFiles:
+ - ../../stubs/glpi_constants.php
+ ignoreErrors:
+ - '#Call to static method Error\(\) on an unknown class PluginWebservicesMethodCommon#'
+rules:
+ - GlpiProject\Tools\PHPStan\Rules\GlobalVarTypeRule
diff --git a/setup.php b/setup.php
index 91895d0..63a6e38 100644
--- a/setup.php
+++ b/setup.php
@@ -34,11 +34,13 @@
*/
define('PLUGIN_PDF_VERSION', '4.0.1');
-define('PLUGIN_PDF_MIN_GLPI', '10.0.0');
+define('PLUGIN_PDF_MIN_GLPI', '10.0.11');
define('PLUGIN_PDF_MAX_GLPI', '10.0.99');
function plugin_init_pdf()
{
+ /** @var array $PDF_DEVICES */
+ /** @var array $PLUGIN_HOOKS */
global $PLUGIN_HOOKS, $PDF_DEVICES;
$PLUGIN_HOOKS['csrf_compliant']['pdf'] = true;
diff --git a/tools/move_to_po.php b/tools/move_to_po.php
index 6b7af7b..2d6e983 100755
--- a/tools/move_to_po.php
+++ b/tools/move_to_po.php
@@ -190,6 +190,8 @@
function search_in_dict($string, $context)
{
+ /** @var array $LANG */
+ /** @var array $REFLANG */
global $REFLANG, $LANG;
if ($context) {