return to corresponding forum page after editing a reply (#19)

This commit is contained in:
Parziphal 2013-11-17 01:44:01 -05:00
parent 69b6c0cbcd
commit 3fd8924f0e
3 changed files with 8 additions and 3 deletions

View File

@ -123,7 +123,9 @@ class ForumController extends ApplicationController
$this->forum_post->assignAttributes($this->params()->forum_post);
if ($this->forum_post->save()) {
$this->notice("Post updated");
$this->redirectTo(["#show", 'id' => $this->forum_post->root_id(), 'page' => ceil($this->forum_post->root()->response_count / 30.0)]);
$page = $this->params()->page ? $this->page_number() : ceil($this->forum_post->root()->response_count / 30.0);
$this->redirectTo(["#show", 'id' => $this->forum_post->root_id(), 'page' => $page]);
} else {
$this->_render_error($this->forum_post);
}

View File

@ -19,7 +19,7 @@
<div class="post-footer" style="clear: left;">
<ul class="flat-list pipe-list">
<?php if (current_user()->has_permission($this->post, 'creator_id')) : ?>
<li> <?= $this->linkTo($this->t('.edit'), ['action' => "edit", 'id' => $this->post->id]) ?>
<li> <?= $this->linkTo($this->t('.edit'), ['action' => "edit", 'id' => $this->post->id, 'page' => (int)$this->params()->page]) ?>
<li> <?= $this->linkTo($this->t('.delete'), ["#destroy", 'id' => $this->post->id], ['confirm' => $this->t('.delete_confirm'), 'method' => 'post']) ?>
<?php endif ?>
<?php if ($this->post->is_parent() && current_user()->is_mod_or_higher()) : ?>

View File

@ -3,6 +3,9 @@
<?= $this->formTag("#update", function(){ ?>
<?= $this->hiddenFieldTag("id", $this->params()->id) ?>
<?php if ($this->params()->page) : ?>
<?= $this->hiddenFieldTag("page", (int)$this->params()->page, ['id' => '']) ?>
<?php endif ?>
<table>
<tr><td><label for="forum_post_title"><?= $this->t('.post_title') ?></label></td><td><?= $this->textField('forum_post', 'title', ['size' => 60]) ?></td></tr>
<tr><td colspan="2"><?= $this->textArea('forum_post', 'body', ['rows' => 20, 'cols' => 80]) ?></td></tr>