Update Models\PM\PTopic

Change ->firstNew.
This commit is contained in:
Visman 2021-04-05 16:53:58 +07:00
parent 968b1e0a2e
commit 7400f4abe7

View file

@ -25,8 +25,10 @@ class PTopic extends DataModel
$this->zDepend = [
'id' => ['link', 'hasNew', 'linkNew', 'firstNew', 'pagination', 'dataReply', 'linkReply'],
'first_post_id' => ['firstNew'],
'last_number' => ['last_poster'],
'last_post_id' => ['linkLast'],
'last_post' => ['firstNew'],
'last_post_id' => ['linkLast', 'firstNew'],
'num_replies' => ['numPages', 'pagination'],
'poster' => ['last_poster', 'byOrFor', 'zpUser', 'ztUser'],
'poster_id' => ['closed', 'firstNew', 'zp', 'zt', 'zpUser', 'ztUser', 'actionsAllowed', 'canReply'],
@ -152,9 +154,17 @@ class PTopic extends DataModel
return 0;
}
$visit = $this->{"{$this->zp}_visit"};
if ($visit < 1) {
return $this->first_post_id;
} elseif ($visit >= $this->last_post) {
return $this->last_post_id;
}
$vars = [
':tid' => $this->id,
':visit' => $this->{"{$this->zp}_visit"},
':visit' => $visit,
];
$query = 'SELECT MIN(pp.id)
FROM ::pm_posts AS pp