Improved redirect for contact actions

This commit is contained in:
Michael 2024-08-06 21:35:59 +00:00
parent 3776cf8919
commit 342c9088d3
3 changed files with 12 additions and 3 deletions

View file

@ -58,7 +58,13 @@ class Contact extends BaseModule
return;
}
$redirectUrl = $_POST['redirect_url'] ?? 'contact';
$redirectUrl = $_POST['command'] ?? '';
if (substr($redirectUrl, 0, 7) != 'contact') {
$redirectUrl = 'contact';
}
if (!empty($_POST['parameter'])) {
$redirectUrl .= '?' . $_POST['parameter'];
}
self::checkFormSecurityTokenRedirectOnError($redirectUrl, 'contact_batch_actions');
@ -459,6 +465,7 @@ class Contact extends BaseModule
'$finding' => $searching ? DI::l10n()->t('Results for: %s', $search) : '',
'$submit' => DI::l10n()->t('Find'),
'$cmd' => DI::args()->getCommand(),
'$parameter' => http_build_query($request),
'$contacts' => $contacts,
'$form_security_token' => BaseModule::getFormSecurityToken('contact_batch_actions'),
'multiselect' => 1,

View file

@ -15,7 +15,8 @@
{{$tabs nofilter}}
<form action="{{$baseurl}}/contact/batch/" method="POST">
<input type="hidden" name="redirect_url" value="{{$cmd}}" />
<input type="hidden" name="command" value="{{$cmd}}" />
<input type="hidden" name="parameter" value="{{$parameter}}" />
<input type="hidden" name="form_security_token" value="{{$form_security_token}}" />
{{foreach $contacts as $contact}}
{{include file="contact/entry.tpl"}}

View file

@ -25,7 +25,8 @@
{{* we need the form container to make batch actions work *}}
<form name="batch_actions_submit" action="{{$baseurl}}/contact/batch/" method="POST">
<input type="hidden" name="redirect_url" value="{{$cmd}}" />
<input type="hidden" name="command" value="{{$cmd}}" />
<input type="hidden" name="parameter" value="{{$parameter}}" />
<input type="hidden" name="form_security_token" value="{{$form_security_token}}" />
{{* we put here a hidden input element. This is needed to transmit the batch actions with javascript*}}