Merge pull request #14347 from annando/contact-redirect

Improved redirect for contact actions
This commit is contained in:
Tobias Diekershoff 2024-08-09 12:56:52 +02:00 committed by GitHub
commit 5ea3f9e6b7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 12 additions and 3 deletions

View file

@ -58,7 +58,13 @@ class Contact extends BaseModule
return; 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'); self::checkFormSecurityTokenRedirectOnError($redirectUrl, 'contact_batch_actions');
@ -459,6 +465,7 @@ class Contact extends BaseModule
'$finding' => $searching ? DI::l10n()->t('Results for: %s', $search) : '', '$finding' => $searching ? DI::l10n()->t('Results for: %s', $search) : '',
'$submit' => DI::l10n()->t('Find'), '$submit' => DI::l10n()->t('Find'),
'$cmd' => DI::args()->getCommand(), '$cmd' => DI::args()->getCommand(),
'$parameter' => http_build_query($request),
'$contacts' => $contacts, '$contacts' => $contacts,
'$form_security_token' => BaseModule::getFormSecurityToken('contact_batch_actions'), '$form_security_token' => BaseModule::getFormSecurityToken('contact_batch_actions'),
'multiselect' => 1, 'multiselect' => 1,

View file

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

View file

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