return to corresponding forum page after editing a reply (#19)
This commit is contained in:
parent
69b6c0cbcd
commit
3fd8924f0e
@ -123,7 +123,9 @@ class ForumController extends ApplicationController
|
|||||||
$this->forum_post->assignAttributes($this->params()->forum_post);
|
$this->forum_post->assignAttributes($this->params()->forum_post);
|
||||||
if ($this->forum_post->save()) {
|
if ($this->forum_post->save()) {
|
||||||
$this->notice("Post updated");
|
$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 {
|
} else {
|
||||||
$this->_render_error($this->forum_post);
|
$this->_render_error($this->forum_post);
|
||||||
}
|
}
|
||||||
@ -132,7 +134,7 @@ class ForumController extends ApplicationController
|
|||||||
public function show()
|
public function show()
|
||||||
{
|
{
|
||||||
$this->forum_post = ForumPost::find($this->params()->id);
|
$this->forum_post = ForumPost::find($this->params()->id);
|
||||||
$this->children = ForumPost::where("parent_id = ?", $this->params()->id)->order("id")->paginate($this->page_number(), 30);
|
$this->children = ForumPost::where("parent_id = ?", $this->params()->id)->order("id")->paginate($this->page_number(), 30);
|
||||||
|
|
||||||
if (!$this->current_user->is_anonymous() && $this->current_user->last_forum_topic_read_at < $this->forum_post->updated_at && $this->forum_post->updated_at < (time() - 3)) {
|
if (!$this->current_user->is_anonymous() && $this->current_user->last_forum_topic_read_at < $this->forum_post->updated_at && $this->forum_post->updated_at < (time() - 3)) {
|
||||||
$this->current_user->updateAttribute('last_forum_topic_read_at', $this->forum_post->updated_at);
|
$this->current_user->updateAttribute('last_forum_topic_read_at', $this->forum_post->updated_at);
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
<div class="post-footer" style="clear: left;">
|
<div class="post-footer" style="clear: left;">
|
||||||
<ul class="flat-list pipe-list">
|
<ul class="flat-list pipe-list">
|
||||||
<?php if (current_user()->has_permission($this->post, 'creator_id')) : ?>
|
<?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']) ?>
|
<li> <?= $this->linkTo($this->t('.delete'), ["#destroy", 'id' => $this->post->id], ['confirm' => $this->t('.delete_confirm'), 'method' => 'post']) ?>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
<?php if ($this->post->is_parent() && current_user()->is_mod_or_higher()) : ?>
|
<?php if ($this->post->is_parent() && current_user()->is_mod_or_higher()) : ?>
|
||||||
|
@ -3,6 +3,9 @@
|
|||||||
|
|
||||||
<?= $this->formTag("#update", function(){ ?>
|
<?= $this->formTag("#update", function(){ ?>
|
||||||
<?= $this->hiddenFieldTag("id", $this->params()->id) ?>
|
<?= $this->hiddenFieldTag("id", $this->params()->id) ?>
|
||||||
|
<?php if ($this->params()->page) : ?>
|
||||||
|
<?= $this->hiddenFieldTag("page", (int)$this->params()->page, ['id' => '']) ?>
|
||||||
|
<?php endif ?>
|
||||||
<table>
|
<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><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>
|
<tr><td colspan="2"><?= $this->textArea('forum_post', 'body', ['rows' => 20, 'cols' => 80]) ?></td></tr>
|
||||||
|
Reference in New Issue
Block a user