Add poster_id and last_poster_id for topics
This commit is contained in:
parent
159fc15c7f
commit
9b91b9068a
3 changed files with 37 additions and 32 deletions
|
@ -768,25 +768,27 @@ class Install extends Page
|
|||
// topics
|
||||
$schema = [
|
||||
'FIELDS' => [
|
||||
'id' => ['SERIAL', false],
|
||||
'poster' => ['VARCHAR(190)', false, ''],
|
||||
'subject' => ['VARCHAR(255)', false, ''],
|
||||
'posted' => ['INT(10) UNSIGNED', false, 0],
|
||||
'first_post_id' => ['INT(10) UNSIGNED', false, 0],
|
||||
'last_post' => ['INT(10) UNSIGNED', false, 0],
|
||||
'last_post_id' => ['INT(10) UNSIGNED', false, 0],
|
||||
'last_poster' => ['VARCHAR(190)', false, ''],
|
||||
'num_views' => ['MEDIUMINT(8) UNSIGNED', false, 0],
|
||||
'num_replies' => ['MEDIUMINT(8) UNSIGNED', false, 0],
|
||||
'closed' => ['TINYINT(1)', false, 0],
|
||||
'sticky' => ['TINYINT(1)', false, 0],
|
||||
'stick_fp' => ['TINYINT(1)', false, 0],
|
||||
'moved_to' => ['INT(10) UNSIGNED', false, 0],
|
||||
'forum_id' => ['INT(10) UNSIGNED', false, 0],
|
||||
'poll_type' => ['TINYINT(4)', false, 0],
|
||||
'poll_time' => ['INT(10) UNSIGNED', false, 0],
|
||||
'poll_term' => ['TINYINT(4)', false, 0],
|
||||
'poll_kol' => ['INT(10) UNSIGNED', false, 0],
|
||||
'id' => ['SERIAL', false],
|
||||
'poster' => ['VARCHAR(190)', false, ''],
|
||||
'poster_id' => ['INT(10) UNSIGNED', false, 0],
|
||||
'subject' => ['VARCHAR(255)', false, ''],
|
||||
'posted' => ['INT(10) UNSIGNED', false, 0],
|
||||
'first_post_id' => ['INT(10) UNSIGNED', false, 0],
|
||||
'last_post' => ['INT(10) UNSIGNED', false, 0],
|
||||
'last_post_id' => ['INT(10) UNSIGNED', false, 0],
|
||||
'last_poster' => ['VARCHAR(190)', false, ''],
|
||||
'last_poster_id' => ['INT(10) UNSIGNED', false, 0],
|
||||
'num_views' => ['MEDIUMINT(8) UNSIGNED', false, 0],
|
||||
'num_replies' => ['MEDIUMINT(8) UNSIGNED', false, 0],
|
||||
'closed' => ['TINYINT(1)', false, 0],
|
||||
'sticky' => ['TINYINT(1)', false, 0],
|
||||
'stick_fp' => ['TINYINT(1)', false, 0],
|
||||
'moved_to' => ['INT(10) UNSIGNED', false, 0],
|
||||
'forum_id' => ['INT(10) UNSIGNED', false, 0],
|
||||
'poll_type' => ['TINYINT(4)', false, 0],
|
||||
'poll_time' => ['INT(10) UNSIGNED', false, 0],
|
||||
'poll_term' => ['TINYINT(4)', false, 0],
|
||||
'poll_kol' => ['INT(10) UNSIGNED', false, 0],
|
||||
],
|
||||
'PRIMARY KEY' => ['id'],
|
||||
'INDEXES' => [
|
||||
|
|
|
@ -134,7 +134,7 @@ class Post extends Page
|
|||
$forum = $model->parent;
|
||||
$topic = $model;
|
||||
|
||||
if (! $this->user->isGuest && $topic->last_poster === $username) {
|
||||
if (! $this->user->isGuest && $topic->last_poster_id === $this->user->id) {
|
||||
if ($executive) {
|
||||
if ($v->merge_post) {
|
||||
$merge = true;
|
||||
|
@ -153,13 +153,15 @@ class Post extends Page
|
|||
$forum = $model;
|
||||
$topic = $this->c->topics->create();
|
||||
|
||||
$topic->subject = $v->subject;
|
||||
$topic->poster = $username;
|
||||
$topic->last_poster = $username;
|
||||
$topic->posted = $now;
|
||||
$topic->last_post = $now;
|
||||
$topic->sticky = $v->stick_topic ? 1 : 0;
|
||||
$topic->stick_fp = $v->stick_fp ? 1 : 0;
|
||||
$topic->subject = $v->subject;
|
||||
$topic->poster = $username;
|
||||
$topic->poster_id = $this->user->id;
|
||||
$topic->last_poster = $username;
|
||||
$topic->last_poster_id = $this->user->id;
|
||||
$topic->posted = $now;
|
||||
$topic->last_post = $now;
|
||||
$topic->sticky = $v->stick_topic ? 1 : 0;
|
||||
$topic->stick_fp = $v->stick_fp ? 1 : 0;
|
||||
# $topic->poll_type = ;
|
||||
# $topic->poll_time = ;
|
||||
# $topic->poll_term = ;
|
||||
|
|
|
@ -30,7 +30,7 @@ class CalcStat extends Method
|
|||
|
||||
$num_replies = $this->c->DB->query($sql, $vars)->fetchColumn();
|
||||
|
||||
$sql = 'SELECT p.id AS last_post_id, p.poster AS last_poster, p.posted, p.edited
|
||||
$sql = 'SELECT p.id, p.poster, p.poster_id, p.posted, p.edited
|
||||
FROM ::posts AS p
|
||||
WHERE p.topic_id=?i:tid
|
||||
ORDER BY p.id DESC
|
||||
|
@ -39,10 +39,11 @@ class CalcStat extends Method
|
|||
$result = $this->c->DB->query($sql, $vars)->fetch();
|
||||
|
||||
//????
|
||||
$this->model->num_replies = $num_replies;
|
||||
$this->model->last_post_id = $result['last_post_id'];
|
||||
$this->model->last_poster = $result['last_poster'];
|
||||
$this->model->last_post = $result['edited'] > 0 && $result['edited'] > $result['posted'] ? $result['edited'] : $result['posted'];
|
||||
$this->model->num_replies = $num_replies;
|
||||
$this->model->last_post_id = $result['id'];
|
||||
$this->model->last_poster = $result['poster'];
|
||||
$this->model->last_poster_id = $result['poster_id'];
|
||||
$this->model->last_post = $result['edited'] > 0 && $result['edited'] > $result['posted'] ? $result['edited'] : $result['posted'];
|
||||
|
||||
return $this->model;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue