From 7a2a735101906494888bb3c845d32828fbf86d76 Mon Sep 17 00:00:00 2001 From: Rom1-B <8530352+Rom1-B@users.noreply.github.com> Date: Tue, 18 Aug 2026 08:25:41 +0200 Subject: [PATCH 1/7] feature/glpi-12.0 --- .github/workflows/continuous-integration.yml | 2 +- CHANGELOG.md | 6 +++++- setup.php | 4 ++-- .../AbstractReservationWidgetController.php | 3 ++- src/Controller/LdapDropdownController.php | 2 +- .../TreeDropdownChildrenController.php | 2 +- .../Condition/TableRowCountConditionHandler.php | 2 ++ .../TreeCascadeItemAsTextConditionHandler.php | 2 ++ src/Model/QuestionType/TableColumnRule.php | 1 + .../TreeCascadeDropdownQuestion.php | 6 +++--- src/Model/TicketReservationRequest.php | 6 +++--- templates/config_form.html.twig | 1 - tests/Front/ConfigFormTest.php | 3 ++- .../Model/QuestionType/QuestionTypeTestCase.php | 17 ++++++++--------- .../TreeCascadeDropdownQuestionTest.php | 17 ++++++----------- 15 files changed, 39 insertions(+), 35 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index c822c8e..a28d1a1 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -20,7 +20,7 @@ jobs: name: "Generate CI matrix" uses: "glpi-project/plugin-ci-workflows/.github/workflows/generate-ci-matrix.yml@v1" with: - glpi-version: "11.0.x" + glpi-version: "12.0.x" ci: name: "GLPI ${{ matrix.glpi-version }} - php:${{ matrix.php-version }} - ${{ matrix.db-image }}" needs: "generate-ci-matrix" diff --git a/CHANGELOG.md b/CHANGELOG.md index a39684d..86a455f 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/). -## [Unreleased] +## [UNRELEASED] + +### Added + +- GLPI 12 compatibility ### Added diff --git a/setup.php b/setup.php index 8e4bb84..9df614c 100644 --- a/setup.php +++ b/setup.php @@ -40,11 +40,11 @@ // Minimal GLPI version, inclusive /** @phpstan-ignore theCodingMachineSafe.function (safe to assume this isn't already defined) */ -define("PLUGIN_ADVANCEDFORMS_MIN_GLPI_VERSION", "11.0.7"); +define("PLUGIN_ADVANCEDFORMS_MIN_GLPI_VERSION", "12.0.0"); // Maximum GLPI version, exclusive /** @phpstan-ignore theCodingMachineSafe.function (safe to assume this isn't already defined) */ -define("PLUGIN_ADVANCEDFORMS_MAX_GLPI_VERSION", "11.0.99"); +define("PLUGIN_ADVANCEDFORMS_MAX_GLPI_VERSION", "12.0.99"); /** * Init hooks of the plugin. diff --git a/src/Controller/AbstractReservationWidgetController.php b/src/Controller/AbstractReservationWidgetController.php index f3add04..09b43e0 100644 --- a/src/Controller/AbstractReservationWidgetController.php +++ b/src/Controller/AbstractReservationWidgetController.php @@ -36,6 +36,7 @@ use Glpi\Controller\AbstractController; use Glpi\Exception\Http\AccessDeniedHttpException; use Glpi\Exception\Http\BadRequestHttpException; +use Reservation; use ReservationItem; use Session; @@ -45,7 +46,7 @@ abstract class AbstractReservationWidgetController extends AbstractController /** @throws AccessDeniedHttpException when the current user cannot read reservations. */ protected function checkReservationAccess(): void { - if (!Session::haveRightsOr('reservation', [READ, ReservationItem::RESERVEANITEM])) { + if (!Session::haveRightsOr(Reservation::$rightname, [READ, ReservationItem::RESERVEANITEM])) { throw new AccessDeniedHttpException(); } } diff --git a/src/Controller/LdapDropdownController.php b/src/Controller/LdapDropdownController.php index 2ae6ef5..24240e4 100644 --- a/src/Controller/LdapDropdownController.php +++ b/src/Controller/LdapDropdownController.php @@ -98,7 +98,7 @@ public function __invoke(Request $request): Response $page_limit = $request->request->getInt('page_limit', 0); // Make sure mandatory parameters are set - if ($page == 0 || $page_limit == 0) { + if ($page === 0 || $page_limit === 0) { throw new BadRequestHttpException(); } diff --git a/src/Controller/TreeDropdownChildrenController.php b/src/Controller/TreeDropdownChildrenController.php index 037d25f..264832b 100644 --- a/src/Controller/TreeDropdownChildrenController.php +++ b/src/Controller/TreeDropdownChildrenController.php @@ -99,7 +99,7 @@ public function __invoke(Request $request): Response $is_recursive = $item_check->maybeRecursive(); $entity_restrict = getEntitiesRestrictCriteria($table, '', '', $is_recursive); - if (!empty($entity_restrict)) { + if ($entity_restrict !== []) { $where = array_merge($where, $entity_restrict); } diff --git a/src/Model/Condition/TableRowCountConditionHandler.php b/src/Model/Condition/TableRowCountConditionHandler.php index 1a1dbba..6d0f02f 100644 --- a/src/Model/Condition/TableRowCountConditionHandler.php +++ b/src/Model/Condition/TableRowCountConditionHandler.php @@ -33,6 +33,7 @@ namespace GlpiPlugin\Advancedforms\Model\Condition; +use Glpi\DBAL\JsonFieldInterface; use Glpi\Form\Condition\ConditionData; use Glpi\Form\Condition\ConditionHandler\ConditionHandlerInterface; use Glpi\Form\Condition\ValueOperator; @@ -86,6 +87,7 @@ public function applyValueOperator( mixed $a, ValueOperator $operator, mixed $b, + ?JsonFieldInterface $config = null, ): bool { $rows = $this->countFilledRows($a); $threshold = (int) (is_scalar($b) ? $b : 0); diff --git a/src/Model/ConditionHandler/TreeCascadeItemAsTextConditionHandler.php b/src/Model/ConditionHandler/TreeCascadeItemAsTextConditionHandler.php index 30519b1..2341044 100644 --- a/src/Model/ConditionHandler/TreeCascadeItemAsTextConditionHandler.php +++ b/src/Model/ConditionHandler/TreeCascadeItemAsTextConditionHandler.php @@ -34,6 +34,7 @@ namespace GlpiPlugin\Advancedforms\Model\ConditionHandler; use CommonDBTM; +use Glpi\DBAL\JsonFieldInterface; use Glpi\Form\Condition\ConditionData; use Glpi\Form\Condition\ConditionHandler\ConditionHandlerInterface; use Glpi\Form\Condition\ValueOperator; @@ -83,6 +84,7 @@ public function applyValueOperator( mixed $a, ValueOperator $operator, mixed $b, + ?JsonFieldInterface $config, ): bool { if (!is_array($a) || !isset($a['items_id'])) { return false; diff --git a/src/Model/QuestionType/TableColumnRule.php b/src/Model/QuestionType/TableColumnRule.php index 7bf5ece..7a3ba15 100644 --- a/src/Model/QuestionType/TableColumnRule.php +++ b/src/Model/QuestionType/TableColumnRule.php @@ -177,6 +177,7 @@ public function matchesPattern(string $value): bool $value, ValueOperator::MATCH_REGEX, $this->pattern, + null, ); } } diff --git a/src/Model/QuestionType/TreeCascadeDropdownQuestion.php b/src/Model/QuestionType/TreeCascadeDropdownQuestion.php index 7406210..95f78a7 100644 --- a/src/Model/QuestionType/TreeCascadeDropdownQuestion.php +++ b/src/Model/QuestionType/TreeCascadeDropdownQuestion.php @@ -117,7 +117,7 @@ public function renderEndUserTemplate(Question $question): string return parent::renderEndUserTemplate($question); } - $default_items_id = $this->getDefaultValueItemId($question); + $default_items_id = $this->getDefaultValuesItemIds($question)[0] ?? 0; $aria_label = $this->items_id_aria_label; $tree_table = $itemtype::getTable(); @@ -262,7 +262,7 @@ private function buildAncestorChain( /** @var array $base_where */ $base_where = []; $entity_restrict = getEntitiesRestrictCriteria($table, '', '', $is_recursive); - if (!empty($entity_restrict)) { + if ($entity_restrict !== []) { $base_where = array_merge($base_where, $entity_restrict); } @@ -331,7 +331,7 @@ private function getFirstLevelItems( $is_recursive = $item_check->maybeRecursive(); $entity_restrict = getEntitiesRestrictCriteria($table, '', '', $is_recursive); - if (!empty($entity_restrict)) { + if ($entity_restrict !== []) { $base_where = array_merge($base_where, $entity_restrict); } diff --git a/src/Model/TicketReservationRequest.php b/src/Model/TicketReservationRequest.php index 462f600..7de4c9a 100644 --- a/src/Model/TicketReservationRequest.php +++ b/src/Model/TicketReservationRequest.php @@ -47,11 +47,11 @@ /** A ticket-driven request to reserve an equipment item for a timeframe. */ final class TicketReservationRequest extends CommonDBChild { - public static $itemtype = 'Ticket'; + public static string $itemtype = 'Ticket'; - public static $items_id = 'tickets_id'; + public static string $items_id = 'tickets_id'; - public static $rightname = 'ticket'; + public static string $rightname = 'ticket'; public const STATUS_WAITING = 1; diff --git a/templates/config_form.html.twig b/templates/config_form.html.twig index a6ce18d..4c4c265 100644 --- a/templates/config_form.html.twig +++ b/templates/config_form.html.twig @@ -53,7 +53,6 @@ -
-{% if show_calendar %} - {# Session-deduped, also loads the FullCalendar locale matching the user language #} - {% do call(['Html', 'requireJs'], ['fullcalendar']) %} -{% endif %}