From c552cbc9d24bda860bb8a9909bb410b869ed520f Mon Sep 17 00:00:00 2001 From: Rom1-B <8530352+Rom1-B@users.noreply.github.com> Date: Tue, 10 Nov 2026 15:55:32 +0100 Subject: [PATCH 1/3] feat: make plugin CSP compliant --- CHANGELOG.md | 4 ++ inc/bill.class.php | 11 +++-- inc/order.class.php | 12 +++--- inc/order_item.class.php | 14 +++--- inc/order_supplier.class.php | 4 +- inc/reception.class.php | 11 ++--- inc/reference_supplier.class.php | 8 ++-- inc/surveysupplier.class.php | 10 ++--- public/js/order.js | 36 ++++++++++++++++ setup.php | 2 + templates/order_getitems.html.twig | 67 ++++++++++++++++------------- templates/order_link_item.html.twig | 42 +++++++++--------- 12 files changed, 134 insertions(+), 87 deletions(-) create mode 100644 public/js/order.js diff --git a/CHANGELOG.md b/CHANGELOG.md index 738978cb0d..ee4dc0cdbd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] +### Changed + +- Make the plugin compatible with the Content Security Policy (requires the GLPI release with CSP support) + ### Fixed - Faster order form, reception, bills and budget tabs on large volumes (missing indexes, budget check and prices read in one query) diff --git a/inc/bill.class.php b/inc/bill.class.php index 773f982e62..3f5ac4aa3c 100644 --- a/inc/bill.class.php +++ b/inc/bill.class.php @@ -360,8 +360,7 @@ public static function showOrder($data_ref, $result_ref, $canedit, $order, $refe $itemtype = $data_ref["itemtype"]; $item = getItemForItemtype($itemtype); echo "
| "; - echo sprintf("" . __s("Check all") . " | "; + echo sprintf("", $rand) + . __s("Check all") . ""; echo "/ | "; - echo sprintf("" . __s("Uncheck all") . ""; + echo sprintf("", $rand) + . __s("Uncheck all") . ""; echo " | ";
echo Html::hidden('plugin_order_orders_id', ['value' => $order->getID()]);
$order_item->dropdownBillItemsActions($order->getID());
diff --git a/inc/order.class.php b/inc/order.class.php
index 56a30ff073..3f7ab39af8 100644
--- a/inc/order.class.php
+++ b/inc/order.class.php
@@ -1696,9 +1696,9 @@ public function showValidationForm($orders_id)
$link = "";
if ($this->canCancelOrder()) {
- echo "";
+ . "\" name='cancel_order' value=\"" . __s("Cancel order", "order") . "\" class='submit'>";
$link = " "; } @@ -1709,9 +1709,9 @@ public function showValidationForm($orders_id) } if ($this->canCancelValidationRequest()) { - echo $link . ""; $link = " "; } @@ -1723,9 +1723,9 @@ public function showValidationForm($orders_id) } if ($this->canUndoValidation()) { - echo $link . ""; $link = " "; } diff --git a/inc/order_item.class.php b/inc/order_item.class.php index b92d826404..fdba7323bb 100644 --- a/inc/order_item.class.php +++ b/inc/order_item.class.php @@ -657,7 +657,8 @@ public function showAddForm($plugin_order_orders_id) } };"); - echo ""; + echo ""; + echo Html::scriptBlock('$("#addreference").on("click", function () { plugin_order_checkboxAction(); });'); echo " | ";
echo "