2018-04-12
This commit is contained in:
parent
51a7a1724b
commit
1d9ca9814d
7 changed files with 53 additions and 12 deletions
|
@ -72,7 +72,7 @@ class Routing
|
|||
$r->add('GET', '/search/advanced[/{keywords}/{author}/{forums}/{serch_in:\d}/{sort_by:\d}/{sort_dir:\d}/{show_as:\d}[/{page:[1-9]\d*}]]', 'Search:viewAdvanced', 'SearchAdvanced');
|
||||
$r->add('POST', '/search/advanced', 'Search:viewAdvanced');
|
||||
|
||||
$r->add('GET', '/search/{action:(?!search)\w+}[/{page:[1-9]\d*}]', 'Search:action', 'SearchAction');
|
||||
$r->add('GET', '/search[/user/{uid:[2-9]|[1-9]\d+}]/{action:(?!search)\w+}[/{page:[1-9]\d*}]', 'Search:action', 'SearchAction');
|
||||
}
|
||||
// юзеры
|
||||
if ($user->viewUsers) {
|
||||
|
|
|
@ -406,7 +406,7 @@ class Profile extends Page
|
|||
# $auth = $this->c->Auth;
|
||||
# $auth->fIswev = ['s' => [\ForkBB\__('Pass updated')]];
|
||||
# return $auth->login(['_username' => $this->curUser->username], 'GET');
|
||||
return $this->c->Redirect->page('Login')->message('Pass updated'); // ????
|
||||
return $this->c->Redirect->page('Login')->message('Pass updated'); // ???? нужна передача данных между скриптами не привязанная к пользователю
|
||||
} else {
|
||||
return $this->c->Redirect->page('EditUserProfile', ['id' => $this->curUser->id])->message('Pass updated redirect');
|
||||
}
|
||||
|
@ -955,7 +955,7 @@ class Profile extends Page
|
|||
'type' => 'link',
|
||||
'caption' => \ForkBB\__('Posts info'),
|
||||
'value' => $this->user->showPostCount ? \ForkBB\num($this->curUser->num_posts) : \ForkBB\__('Show posts'),
|
||||
'href' => '',
|
||||
'href' => $this->c->Router->link('SearchAction', ['action' => 'posts', 'uid' => $this->curUser->id]),
|
||||
'title' => \ForkBB\__('Show posts'),
|
||||
];
|
||||
$fields['topics'] = [
|
||||
|
@ -964,7 +964,7 @@ class Profile extends Page
|
|||
'type' => 'link',
|
||||
'caption' => \ForkBB\__('Topics info'),
|
||||
'value' => $this->user->showPostCount ? \ForkBB\num($this->curUser->num_topics) : \ForkBB\__('Show topics'),
|
||||
'href' => '',
|
||||
'href' => $this->c->Router->link('SearchAction', ['action' => 'topics', 'uid' => $this->curUser->id]),
|
||||
'title' => \ForkBB\__('Show topics'),
|
||||
];
|
||||
} elseif ($this->user->showPostCount) {
|
||||
|
|
|
@ -5,6 +5,7 @@ namespace ForkBB\Models\Pages;
|
|||
use ForkBB\Models\Page;
|
||||
use ForkBB\Core\Validator;
|
||||
use ForkBB\Models\Forum\Model as Forum;
|
||||
use ForkBB\Models\User\Model as User;
|
||||
use InvalidArgumentException;
|
||||
|
||||
class Search extends Page
|
||||
|
@ -402,9 +403,9 @@ class Search extends Page
|
|||
switch ($action) {
|
||||
case 'search':
|
||||
if (1 === $model->showAs) {
|
||||
$list = $model->actionT($action);
|
||||
$list = $model->actionT($action);
|
||||
} else {
|
||||
$list = $model->actionP($action);
|
||||
$list = $model->actionP($action);
|
||||
$asTopicsList = false;
|
||||
}
|
||||
if ('*' === $args['author']) {
|
||||
|
@ -419,14 +420,37 @@ class Search extends Page
|
|||
if ($this->user->isGuest) {
|
||||
break;
|
||||
}
|
||||
$uid = $this->user->id;
|
||||
case 'latest_active_topics':
|
||||
case 'unanswered_topics':
|
||||
if (isset($uid)) {
|
||||
break;
|
||||
}
|
||||
$uid = $this->user->id;
|
||||
$list = $model->actionT($action, $uid);
|
||||
$model->name = \ForkBB\__('Quick search ' . $action);
|
||||
$model->linkMarker = 'SearchAction';
|
||||
$model->linkArgs = ['action' => $action];
|
||||
$this->fSubIndex = $subIndex[$action];
|
||||
break;
|
||||
case 'posts':
|
||||
$asTopicsList = false;
|
||||
case 'topics':
|
||||
if (! isset($uid)) {
|
||||
break;
|
||||
}
|
||||
$user = $this->c->users->load($uid);
|
||||
if (! $user instanceof User) {
|
||||
break;
|
||||
}
|
||||
if ($asTopicsList) {
|
||||
$list = $model->actionT($action, $user->id);
|
||||
} else {
|
||||
$list = $model->actionP($action, $user->id);
|
||||
}
|
||||
$model->name = \ForkBB\__('Quick search user ' . $action, $user->username);
|
||||
$model->linkMarker = 'SearchAction';
|
||||
$model->linkArgs = ['action' => $action, 'uid' => $user->id];
|
||||
|
||||
break;
|
||||
# default:
|
||||
# throw new InvalidArgumentException('Unknown action: ' . $action);
|
||||
|
|
|
@ -14,12 +14,13 @@ class ActionP extends Method
|
|||
* Поисковые действия по сообщениям
|
||||
*
|
||||
* @param string $action
|
||||
* @param int $uid
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*
|
||||
* @return false|array
|
||||
*/
|
||||
public function actionP($action)
|
||||
public function actionP($action, $uid = null)
|
||||
{
|
||||
$root = $this->c->forums->get(0);
|
||||
if (! $root instanceof Forum || empty($root->descendants)) {
|
||||
|
@ -31,6 +32,14 @@ class ActionP extends Method
|
|||
case 'search':
|
||||
$list = $this->model->queryIds;
|
||||
break;
|
||||
case 'posts':
|
||||
$sql = 'SELECT p.id
|
||||
FROM ::posts AS p
|
||||
INNER JOIN ::topics AS t ON t.id=p.topic_id
|
||||
WHERE t.forum_id IN (?ai:forums) AND t.moved_to IS NULL AND p.poster_id=?i:uid
|
||||
ORDER BY p.posted DESC';
|
||||
break;
|
||||
|
||||
# case 'last':
|
||||
# $sql = 'SELECT t.id
|
||||
# FROM ::topics AS t
|
||||
|
@ -50,6 +59,7 @@ class ActionP extends Method
|
|||
if (null !== $sql) {
|
||||
$vars = [
|
||||
':forums' => array_keys($root->descendants),
|
||||
':uid' => $uid,
|
||||
];
|
||||
$list = $this->c->DB->query($sql, $vars)->fetchAll(PDO::FETCH_COLUMN);
|
||||
}
|
||||
|
|
|
@ -52,6 +52,13 @@ class ActionT extends Method
|
|||
GROUP BY t.id
|
||||
ORDER BY t.last_post DESC';
|
||||
break;
|
||||
case 'topics':
|
||||
$sql = 'SELECT t.id
|
||||
FROM ::topics AS t
|
||||
INNER JOIN ::posts AS p ON t.first_post_id=p.id
|
||||
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;
|
||||
default:
|
||||
throw new InvalidArgumentException('Unknown action: ' . $action);
|
||||
}
|
||||
|
|
|
@ -111,10 +111,10 @@ msgstr "Unanswered"
|
|||
msgid "Quick search topics_with_your_posts"
|
||||
msgstr "Posted"
|
||||
|
||||
msgid "Quick search show_user_topics"
|
||||
msgid "Quick search user topics"
|
||||
msgstr "Topics by %s"
|
||||
|
||||
msgid "Quick search show_user_posts"
|
||||
msgid "Quick search user posts"
|
||||
msgstr "Posts by %s"
|
||||
|
||||
msgid "Quick search show_subscriptions"
|
||||
|
|
|
@ -111,10 +111,10 @@ msgstr "Темы без ответа"
|
|||
msgid "Quick search topics_with_your_posts"
|
||||
msgstr "Темы с вашим участием"
|
||||
|
||||
msgid "Quick search show_user_topics"
|
||||
msgid "Quick search user topics"
|
||||
msgstr "Темы от %s"
|
||||
|
||||
msgid "Quick search show_user_posts"
|
||||
msgid "Quick search user posts"
|
||||
msgstr "Сообщения от %s"
|
||||
|
||||
msgid "Quick search show_subscriptions"
|
||||
|
|
Loading…
Reference in a new issue