+ Added search for topics with new posts
This commit is contained in:
parent
2345182df6
commit
3c79787879
6 changed files with 32 additions and 3 deletions
|
@ -96,6 +96,20 @@ class Model extends DataModel
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ссылка на поиск новых сообщений
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getlinkNew()
|
||||
{
|
||||
if (0 === $this->id) {
|
||||
return $this->c->Router->link('SearchAction', ['action' => 'new']);
|
||||
} else {
|
||||
return $this->c->Router->link('SearchAction', ['action' => 'new', 'forum' => $this->id]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ссылка на последнее сообщение в разделе
|
||||
*
|
||||
|
|
|
@ -437,6 +437,7 @@ class Search extends Page
|
|||
'topics_with_your_posts' => 'with-your-posts',
|
||||
'latest_active_topics' => 'latest',
|
||||
'unanswered_topics' => 'unanswered',
|
||||
'new' => 'new',
|
||||
];
|
||||
switch ($action) {
|
||||
case 'search':
|
||||
|
@ -454,6 +455,7 @@ class Search extends Page
|
|||
$model->linkMarker = $advanced ? 'SearchAdvanced' : 'Search';
|
||||
$model->linkArgs = $args;
|
||||
break;
|
||||
case 'new':
|
||||
case 'topics_with_your_posts':
|
||||
if ($this->user->isGuest) {
|
||||
break;
|
||||
|
|
|
@ -63,6 +63,18 @@ class ActionT extends Method
|
|||
WHERE t.forum_id IN (?ai:forums) AND t.moved_to IS NULL AND p.poster_id=?i:uid
|
||||
ORDER BY t.last_post DESC';
|
||||
break;
|
||||
case 'new':
|
||||
$sql = 'SELECT t.id
|
||||
FROM ::topics AS t
|
||||
LEFT JOIN ::mark_of_topic AS mot ON (mot.uid=?i:uid AND mot.tid=t.id)
|
||||
LEFT JOIN ::mark_of_forum AS mof ON (mof.uid=?i:uid AND mof.fid=t.forum_id)
|
||||
WHERE t.forum_id IN (?ai:forums)
|
||||
AND t.last_post>?i:max
|
||||
AND t.moved_to IS NULL
|
||||
AND (mot.mt_last_visit IS NULL OR t.last_post>mot.mt_last_visit)
|
||||
AND (mof.mf_mark_all_read IS NULL OR t.last_post>mof.mf_mark_all_read)
|
||||
ORDER BY t.last_post DESC';
|
||||
break;
|
||||
default:
|
||||
throw new InvalidArgumentException('Unknown action: ' . $action);
|
||||
}
|
||||
|
@ -71,6 +83,7 @@ class ActionT extends Method
|
|||
$vars = [
|
||||
':forums' => $forums,
|
||||
':uid' => $uid,
|
||||
':max' => \max((int) $this->c->user->last_visit, (int) $this->c->user->u_mark_all_read),
|
||||
];
|
||||
$list = $this->c->DB->query($sql, $vars)->fetchAll(PDO::FETCH_COLUMN);
|
||||
}
|
||||
|
|
|
@ -99,7 +99,7 @@ msgstr "Posts"
|
|||
msgid "Search results"
|
||||
msgstr "Search results"
|
||||
|
||||
msgid "Quick search show_new"
|
||||
msgid "Quick search new"
|
||||
msgstr "New"
|
||||
|
||||
msgid "Quick search latest_active_topics"
|
||||
|
|
|
@ -99,7 +99,7 @@ msgstr "сообщения"
|
|||
msgid "Search results"
|
||||
msgstr "Результаты поиска"
|
||||
|
||||
msgid "Quick search show_new"
|
||||
msgid "Quick search new"
|
||||
msgstr "Темы с новыми сообщениями"
|
||||
|
||||
msgid "Quick search latest_active_topics"
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
<h3>
|
||||
<a class="f-ftname" href="{!! $cur->link !!}">{{ $cur->forum_name }}</a>
|
||||
@if ($cur->tree->newMessages)
|
||||
<span class="f-newtxt"><a href="">{!! __('New posts') !!}</a></span>
|
||||
<span class="f-newtxt"><a href="{!! $cur->linkNew !!}">{!! __('New posts') !!}</a></span>
|
||||
@endif
|
||||
</h3>
|
||||
@if ($cur->subforums)
|
||||
|
|
Loading…
Add table
Reference in a new issue