Commit b1028901 authored by Tino Goratsch's avatar Tino Goratsch

improved the fix for the correct redirect url when posting a comment

parent 55dd075a
......@@ -56,7 +56,16 @@ class LoadModule extends AbstractFunction
{
$pathArray = $this->convertPathToArray($params['module']);
$path = $pathArray[0] . '/' . $pathArray[1] . '/' . $pathArray[2] . '/' . $pathArray[3];
$arguments = isset($params['args']) ? $params['args'] : [];
$arguments = [];
if (isset($params['args']) && is_array($params['args'])) {
$arguments = array_map(
function($item) {
return urlencode($item);
},
$params['args']
);
}
$response = '';
if ($this->acl->hasPermission($path) === true) {
......
......@@ -48,34 +48,34 @@ class Create extends AbstractFrontendAction
/**
* @param string $module
* @param int $entryId
*
* @param int $entryId
* @param string $redirectUrl
* @return array|\Symfony\Component\HttpFoundation\RedirectResponse
*/
public function execute($module, $entryId)
public function execute($module, $entryId, $redirectUrl)
{
if ($this->request->getPost()->count() !== 0) {
return $this->executePost($this->request->getPost()->all(), $module, $entryId);
return $this->executePost($this->request->getPost()->all(), $module, $entryId, $redirectUrl);
}
return [
'form' => array_merge($this->fetchFormDefaults(), $this->request->getPost()->all()),
'form' => array_merge($this->fetchFormDefaults($redirectUrl), $this->request->getPost()->all()),
'form_token' => $this->formTokenHelper->renderFormToken(),
'can_use_emoticons' => $this->emoticonsActive === true
];
}
/**
* @param array $formData
* @param array $formData
* @param string $module
* @param int $entryId
*
* @param int $entryId
* @param string $redirectUrl
* @return \Symfony\Component\HttpFoundation\RedirectResponse
*/
protected function executePost(array $formData, $module, $entryId)
protected function executePost(array $formData, $module, $entryId, $redirectUrl)
{
return $this->actionHelper->handlePostAction(
function () use ($formData, $module, $entryId) {
function () use ($formData, $module, $entryId, $redirectUrl) {
$ipAddress = $this->request->getSymfonyRequest()->getClientIp();
$this->formValidation
......@@ -93,7 +93,7 @@ class Create extends AbstractFrontendAction
return $this->redirectMessages()->setMessage(
$bool,
$this->translator->t('system', $bool !== false ? 'create_success' : 'create_error'),
$module . '/index/details/id_' . $entryId
base64_decode(urldecode($redirectUrl))
);
}
);
......
......@@ -29,7 +29,7 @@
{if $comments_allowed === true}
<section id="comments">
{load_module module="frontend/comments" args=['module' => 'files', 'entryId' => $file.id]}
{load_module module="frontend/comments/index/create" args=['module' => 'files', 'entryId' => $file.id]}
{load_module module="frontend/comments/index/create" args=['module' => 'files', 'entryId' => $file.id, 'redirectUrl' => base64_encode("files/index/details/id_`$file.id`")]}
</section>
{/if}
</article>
......
......@@ -42,7 +42,7 @@
{if $comments_allowed === true}
<section id="comments">
{load_module module="frontend/comments" args=['module' => 'gallery', 'entryId' => $picture.id]}
{load_module module="frontend/comments/index/create" args=['module' => 'gallery', 'entryId' => $picture.id]}
{load_module module="frontend/comments/index/create" args=['module' => 'gallery', 'entryId' => $picture.id, 'redirectUrl' => base64_encode("gallery/index/details/id_`$picture.id`")]}
</section>
{/if}
</article>
......
......@@ -25,7 +25,7 @@
{if $comments_allowed === true}
<section id="comments">
{load_module module="frontend/comments" args=['module' => 'news', 'entryId' => $news.id]}
{load_module module="frontend/comments/index/create" args=['module' => 'news', 'entryId' => $news.id]}
{load_module module="frontend/comments/index/create" args=['module' => 'news', 'entryId' => $news.id, 'redirectUrl' => base64_encode("news/index/details/id_`$news.id`")]}
</section>
{/if}
</article>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment