Skip to content

Commit 6e9cd23

Browse files
RomainLvrRom1-Bstonebuzz
authored
GLPI 11 compatibility (#457)
* GLPI 11 compatibility * Fix phpstan * fix review * phpcbf * deleteByCriteria * less doQuery * beta1 * fix path * psalm rector * fix CS * fix CS * fix CS * fix CS * fix CS * fix * fix * fix * release GLPI 11.0 --------- Co-authored-by: Rom1-B <[email protected]> Co-authored-by: Stanislas Kita <[email protected]>
1 parent 8ca1b71 commit 6e9cd23

File tree

94 files changed

+3817
-4378
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+3817
-4378
lines changed

.github/workflows/continuous-integration.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
name: "Generate CI matrix"
2121
uses: "glpi-project/plugin-ci-workflows/.github/workflows/generate-ci-matrix.yml@v1"
2222
with:
23-
glpi-version: "10.0.x"
23+
glpi-version: "11.0.x"
2424
ci:
2525
name: "GLPI ${{ matrix.glpi-version }} - php:${{ matrix.php-version }} - ${{ matrix.db-image }}"
2626
needs: "generate-ci-matrix"

.phpcs.xml

Lines changed: 0 additions & 19 deletions
This file was deleted.

.twig_cs.dist.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@
22

33
declare(strict_types=1);
44

5-
use FriendsOfTwig\Twigcs;
5+
use FriendsOfTwig\Twigcs\Finder\TemplateFinder;
6+
use FriendsOfTwig\Twigcs\Config\Config;
7+
use Glpi\Tools\GlpiTwigRuleset;
68

7-
$finder = Twigcs\Finder\TemplateFinder::create()
9+
$finder = TemplateFinder::create()
810
->in(__DIR__ . '/templates')
911
->name('*.html.twig')
1012
->ignoreVCSIgnored(true);
1113

12-
return Twigcs\Config\Config::create()
14+
return Config::create()
1315
->setFinder($finder)
14-
->setRuleSet(\Glpi\Tools\GlpiTwigRuleset::class)
16+
->setRuleSet(GlpiTwigRuleset::class)
1517
;

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/)
66
and this project adheres to [Semantic Versioning](http://semver.org/).
77

8+
## [2.12.0] - 2025-10-01
9+
10+
### Added
11+
12+
- GLPI 11 compatibility
13+
814
## [2.11.2] - 2025-08-07
915

1016
- Update exemple.odt file to include ecotax tags

ajax/billactions.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,12 @@
2828
* -------------------------------------------------------------------------
2929
*/
3030

31-
include("../../../inc/includes.php");
32-
3331
Session::checkRight("plugin_order_bill", READ);
3432

3533
header("Content-Type: text/html; charset=UTF-8");
3634

3735
Html::header_nocache();
3836

39-
if (!defined('GLPI_ROOT')) {
40-
die("Can not acces directly to this file");
41-
}
42-
4337
if (isset($_POST["action"])) {
4438
switch ($_POST["action"]) {
4539
case "bill":

ajax/dropdownReference.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
/** @var DBmysql $DB */
3232
global $DB;
3333

34-
include_once("../../../inc/includes.php");
34+
include_once(__DIR__ . "/../../../inc/includes.php");
3535

3636
Session::checkRight("plugin_order_reference", READ);
3737

@@ -42,37 +42,37 @@
4242
's.plugin_order_references_id AS id',
4343
's.price_taxfree',
4444
's.reference_code',
45-
'r.name'
45+
'r.name',
4646
],
4747
'FROM' => 'glpi_plugin_order_references_suppliers AS s',
4848
'LEFT JOIN' => [
4949
'glpi_plugin_order_references AS r' => [
5050
'ON' => [
5151
's' => 'plugin_order_references_id',
52-
'r' => 'id'
53-
]
54-
]
52+
'r' => 'id',
53+
],
54+
],
5555
],
5656
'WHERE' => [
5757
's.suppliers_id' => $_POST['suppliers_id'],
5858
'r.itemtype' => $_POST['itemtype'],
5959
'r.is_active' => 1,
60-
'r.is_deleted' => 0
60+
'r.is_deleted' => 0,
6161
] + getEntitiesRestrictCriteria('r', '', $_POST['entities_id'], true),
62-
'ORDER' => ['s.reference_code']
62+
'ORDER' => ['s.reference_code'],
6363
];
6464
$result = $DB->request($criteria);
6565
$number = count($result);
6666
$values = [0 => Dropdown::EMPTY_VALUE];
67-
if ($number) {
67+
if ($number !== 0) {
6868
foreach ($result as $data) {
6969
$values[$data['id']] = $data['name'] . " - " . $data['reference_code'];
7070
}
7171
}
7272
Dropdown::showFromArray(
7373
$_POST['fieldname'],
7474
$values,
75-
['rand' => $_POST['rand'], 'width' => '100%']
75+
['rand' => $_POST['rand'], 'width' => '100%'],
7676
);
7777
Ajax::updateItemOnSelectEvent(
7878
'dropdown_plugin_order_references_id' . $_POST['rand'],
@@ -81,17 +81,17 @@
8181
[
8282
'reference_id' => '__VALUE__',
8383
'suppliers_id' => $_POST['suppliers_id'],
84-
]
84+
],
8585
);
86-
} else if (isset($_POST['reference_id'])) {
87-
// Get price
86+
} elseif (isset($_POST['reference_id'])) {
87+
// Get price
8888
$criteria = [
8989
'SELECT' => ['price_taxfree'],
9090
'FROM' => 'glpi_plugin_order_references_suppliers',
9191
'WHERE' => [
9292
'plugin_order_references_id' => $_POST['reference_id'],
93-
'suppliers_id' => $_POST['suppliers_id']
94-
]
93+
'suppliers_id' => $_POST['suppliers_id'],
94+
],
9595
];
9696
$result = $DB->request($criteria);
9797
$row = $result->current();

ajax/dropdownSupplier.php

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,10 @@
2727
* @link https://github.com/pluginsGLPI/order
2828
* -------------------------------------------------------------------------
2929
*/
30-
31-
/** @var \DBmysql $DB */
30+
/** @var DBmysql $DB */
3231
global $DB;
3332

3433
if (strpos($_SERVER['PHP_SELF'], "dropdownSupplier.php")) {
35-
include("../../../inc/includes.php");
3634
header("Content-Type: text/html; charset=UTF-8");
3735
Html::header_nocache();
3836
}
@@ -41,28 +39,28 @@
4139

4240
// Make a select box
4341
if (isset($_POST["suppliers_id"])) {
44-
// Make a select box
42+
// Make a select box
4543
$criteria = [
4644
'SELECT' => ['c.id', 'c.name', 'c.firstname'],
4745
'FROM' => 'glpi_contacts AS c',
4846
'LEFT JOIN' => [
4947
'glpi_contacts_suppliers AS s' => [
5048
'ON' => [
5149
's' => 'contacts_id',
52-
'c' => 'id'
53-
]
54-
]
50+
'c' => 'id',
51+
],
52+
],
5553
],
5654
'WHERE' => ['s.suppliers_id' => $_POST['suppliers_id']],
57-
'ORDER' => ['c.name']
55+
'ORDER' => ['c.name'],
5856
];
5957
$result = $DB->request($criteria);
6058
$number = count($result);
6159

6260
$values = [0 => Dropdown::EMPTY_VALUE];
63-
if ($number) {
61+
if ($number !== 0) {
6462
foreach ($result as $data) {
65-
$values[$data['id']] = formatUserName('', '', $data['name'], $data['firstname']);
63+
$values[$data['id']] = formatUserName(0, '', $data['name'], $data['firstname']);
6664
}
6765
}
6866
Dropdown::showFromArray($_POST['fieldname'], $values);

ajax/inputnumber.php

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,7 @@
3232
* @brief
3333
*/
3434

35-
use Glpi\Toolbox\Sanitizer;
3635

37-
include('../../../inc/includes.php');
3836

3937
header("Content-Type: text/html; charset=UTF-8");
4038
Html::header_nocache();
@@ -53,14 +51,28 @@
5351

5452
$min = 0;
5553
if (isset($_REQUEST['min'])) {
56-
if (isset($_REQUEST['force_integer']) && $_REQUEST['force_integer']) {
57-
$min = (int)$_REQUEST['min'];
58-
} else {
59-
$min = (float)$_REQUEST['min'];
60-
}
54+
$min = !empty($_REQUEST['force_integer']) ? (int) $_REQUEST['min'] : (float) $_REQUEST['min'];
6155
}
6256

63-
$data = Html::cleanInputText(Sanitizer::sanitize(rawurldecode(stripslashes($_POST["data"]))));
57+
$data = htmlescape(rawurldecode(stripslashes($_POST["data"])));
58+
59+
// Validation et fallback
60+
$name = preg_match('/^[a-zA-Z0-9_\-]+$/', $_POST['name']) ? $_POST['name'] : 'default_name';
61+
62+
// Ces variables existent déjà et ne sont pas null, donc pas besoin de ??=
63+
$value = $data;
64+
$step = $step;
65+
$min = $min;
66+
$class = $class;
67+
68+
// Échappement pour HTML (caster les nombres en string)
69+
$name = htmlspecialchars($name, ENT_QUOTES, 'UTF-8');
70+
$value = htmlspecialchars((string) $value, ENT_QUOTES, 'UTF-8');
71+
$step = htmlspecialchars((string) $step, ENT_QUOTES, 'UTF-8');
72+
$min = htmlspecialchars((string) $min, ENT_QUOTES, 'UTF-8');
73+
$class = htmlspecialchars($class, ENT_QUOTES, 'UTF-8');
74+
75+
// Affichage
76+
echo "<input type='number' class='form-control' step='{$step}' min='{$min}' name='{$name}' value='{$value}' {$class}>";
6477

65-
echo "<input type='number' class='form-control' step='$step' min='$min' name='" . $_POST['name'] . "' value='$data' $class>";
6678
}

0 commit comments

Comments
 (0)