diff --git a/js/modules/Forms/RendererController.js b/js/modules/Forms/RendererController.js index ac7f6552ae6..990c6cb13f5 100644 --- a/js/modules/Forms/RendererController.js +++ b/js/modules/Forms/RendererController.js @@ -31,7 +31,7 @@ * --------------------------------------------------------------------- */ -/* global glpi_toast_info */ +/* global glpi_toast_info, glpi_toast_error */ /** * Client code to handle users actions on the form_renderer template @@ -143,7 +143,9 @@ export class GlpiFormRendererController .addClass("d-none"); } catch { - // Failure (TODO) + glpi_toast_error( + __("Failed to submit form, please contact your administrator.") + ); } } diff --git a/src/Glpi/Controller/Form/RendererController.php b/src/Glpi/Controller/Form/RendererController.php index 67d02d50ad1..7beb64941de 100644 --- a/src/Glpi/Controller/Form/RendererController.php +++ b/src/Glpi/Controller/Form/RendererController.php @@ -51,6 +51,12 @@ final class RendererController extends AbstractController { + private string $interface; + + public function __construct() { + $this->interface = Session::getCurrentInterface(); + } + #[SecurityStrategy(Firewall::STRATEGY_NO_CHECK)] // Some forms can be accessed anonymously #[Route( "/Form/Render/{id}", @@ -63,11 +69,30 @@ public function __invoke(Request $request): Response $form = $this->loadTargetForm($request); $this->checkFormAccessPolicies($form, $request); + $my_tickets_criteria = [ + "criteria" => [ + [ + "field" => 12, // Status + "searchtype" => "equals", + "value" => "notold", // Not solved + ], + ], + ]; + if ($this->interface == 'central') { + $my_tickets_criteria["criteria"][] = [ + "link" => "AND", + "field" => 4, // Requester + "searchtype" => "equals", + "value" => 'myself', + ]; + } + return $this->render('pages/form_renderer.html.twig', [ 'title' => $form->fields['name'], 'menu' => ['admin', Form::getType()], 'form' => $form, 'unauthenticated_user' => !Session::isAuthenticated(), + 'my_tickets_url_param' => http_build_query($my_tickets_criteria), // Direct access token must be included in the form data as it will // be checked in the submit answers controller. diff --git a/templates/pages/form_renderer.html.twig b/templates/pages/form_renderer.html.twig index d1d84e454a6..b99908870a6 100644 --- a/templates/pages/form_renderer.html.twig +++ b/templates/pages/form_renderer.html.twig @@ -197,6 +197,14 @@
{{ __("Your form has been submitted successfully.") }}
+