diff --git a/js/modules/Forms/RendererController.js b/js/modules/Forms/RendererController.js index 91791f43703..f9242d1b5e2 100644 --- a/js/modules/Forms/RendererController.js +++ b/js/modules/Forms/RendererController.js @@ -31,7 +31,7 @@ * --------------------------------------------------------------------- */ -/* global glpi_toast_info, tinymce */ +/* global glpi_toast_info, tinymce, glpi_toast_error */ /** * Client code to handle users actions on the form_renderer template @@ -148,7 +148,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 f5036d161f2..a070f74d490 100644 --- a/src/Glpi/Controller/Form/RendererController.php +++ b/src/Glpi/Controller/Form/RendererController.php @@ -51,6 +51,13 @@ 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 +70,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 cbb5c4771d8..fba075ae6c2 100644 --- a/templates/pages/form_renderer.html.twig +++ b/templates/pages/form_renderer.html.twig @@ -196,6 +196,16 @@

{{ __("Your form has been submitted successfully.") }}

+
+ + + {{ __("Go home") }} + + + + {{ __("See my tickets") }} + +