Change the logic for topic-links
This commit is contained in:
parent
00208dc197
commit
9e4d9078e4
3 changed files with 14 additions and 9 deletions
|
@ -103,8 +103,7 @@ class Post extends Page
|
|||
$topic = $this->c->topics->load((int) $args['id']);
|
||||
|
||||
if (
|
||||
empty($topic)
|
||||
|| $topic->moved_to
|
||||
! $topic instanceof Topic
|
||||
|| ! $topic->canReply
|
||||
) {
|
||||
return $this->c->Message->message('Bad request');
|
||||
|
|
|
@ -93,15 +93,16 @@ class Topic extends Page
|
|||
$topic = $this->c->topics->load((int) $args['id']);
|
||||
}
|
||||
|
||||
if (
|
||||
! $topic instanceof TopicModel
|
||||
|| ! $topic->last_post_id
|
||||
) {
|
||||
if (! $topic instanceof TopicModel) {
|
||||
return $this->c->Message->message('Bad request');
|
||||
}
|
||||
|
||||
if ($topic->moved_to) {
|
||||
return $this->c->Redirect->page('Topic', ['id' => $topic->moved_to]);
|
||||
return $this->c->Redirect->url($topic->link);
|
||||
}
|
||||
|
||||
if (! $topic->last_post_id) {
|
||||
return $this->c->Message->message('Bad request');
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
|
|
|
@ -53,7 +53,9 @@ class Model extends DataModel
|
|||
*/
|
||||
protected function getcanReply(): bool
|
||||
{
|
||||
if ($this->c->user->isAdmin) {
|
||||
if ($this->moved_to) {
|
||||
return false;
|
||||
} elseif ($this->c->user->isAdmin) {
|
||||
return true;
|
||||
} elseif (
|
||||
$this->closed
|
||||
|
@ -117,7 +119,10 @@ class Model extends DataModel
|
|||
*/
|
||||
protected function getlinkLast(): ?string
|
||||
{
|
||||
if ($this->moved_to) {
|
||||
if (
|
||||
$this->moved_to
|
||||
|| $this->last_post_id < 1
|
||||
) {
|
||||
return null;
|
||||
} else {
|
||||
return $this->c->Router->link(
|
||||
|
|
Loading…
Add table
Reference in a new issue