diff --git a/app/Models/Pages/Admin/Update.php b/app/Models/Pages/Admin/Update.php index e8c5acee..d9445a10 100644 --- a/app/Models/Pages/Admin/Update.php +++ b/app/Models/Pages/Admin/Update.php @@ -617,4 +617,21 @@ class Update extends Admin return null; } + + /** + * rev.11 to rev.12 + */ + protected function stageNumber11(array $args): ?int + { + $coreConfig = new CoreConfig($this->c->DIR_CONFIG . '/' . self::CONFIG_FILE); + + $coreConfig->add( + 'multiple=>SearchModelActionF', + '\\ForkBB\\Models\\Search\\ActionF::class', + 'SearchModelActionT' + ); + $coreConfig->save(); + + return null; + } } diff --git a/app/Models/Pages/Search.php b/app/Models/Pages/Search.php index b99b9acd..71883e27 100644 --- a/app/Models/Pages/Search.php +++ b/app/Models/Pages/Search.php @@ -502,20 +502,24 @@ class Search extends Page case 'posts': $asTopicsList = false; case 'topics': + case 'topics_subscriptions': + case 'forums_subscriptions': if (! isset($uid)) { break; } - $user = $this->c->users->load($uid); + $user = $this->c->users->load($uid); if ( ! $user instanceof User || $user->isGuest ) { break; } - if ($asTopicsList) { - $list = $model->actionT($action, $forum, $user->id); + if ('forums_subscriptions' == $action) { + $list = $model->actionF($action, $forum, $user->id); + } elseif ($asTopicsList) { + $list = $model->actionT($action, $forum, $user->id); } else { - $list = $model->actionP($action, $forum, $user->id); + $list = $model->actionP($action, $forum, $user->id); } $model->name = __('Quick search user ' . $action, $user->username); $model->linkMarker = 'SearchAction'; @@ -541,13 +545,20 @@ class Search extends Page if ($asTopicsList) { $this->c->Lang->load('forum'); - $this->nameTpl = 'forum'; - $this->topics = $list; + $this->nameTpl = 'forum'; + + if ('forums_subscriptions' == $action) { + $this->c->Lang->load('subforums'); + + $model->subforums = $list; + } else { + $this->topics = $list; + } } else { $this->c->Lang->load('topic'); - $this->nameTpl = 'topic_in_search'; - $this->posts = $list; + $this->nameTpl = 'topic_in_search'; + $this->posts = $list; } $this->fIndex = 'search'; diff --git a/app/Models/Search/ActionF.php b/app/Models/Search/ActionF.php new file mode 100644 index 00000000..dd22a9bf --- /dev/null +++ b/app/Models/Search/ActionF.php @@ -0,0 +1,84 @@ +descendants); + if ($root->id) { + $forums[] = $root->id; + } + if (empty($forums)) { + return []; + } + + $list = []; + switch ($action) { + case 'forums_subscriptions': + if (0 !== $root->id) { + return false; + } + + $user = $this->c->users->load($uid); + + if (! $this->c->ProfileRules->setUser($user)->viewSubscription) { + return false; + } + + $subscr = $this->c->subscriptions; + $subscrInfo = $subscr->info($user, $subscr::FORUMS_DATA); + $ids = $subscrInfo[$subscr::FORUMS_DATA] ?? []; + + if (empty($ids)) { + break; + } + + $all = $this->c->forums->loadTree(0)->descendants; + + foreach ($ids as $id) { + if ( + isset($all[$id]) + && $all[$id] instanceof Forum + ) { + $forum = clone $all[$id]; + $forum->parent_forum_id = 0; + + unset($forum->subforums, $forum->descendants); + + $list[$id] = $forum; + } + } + + break; + default: + throw new InvalidArgumentException('Unknown action: ' . $action); + } + + $this->model->numPages = 1; + + // нет такой страницы в результате поиска + if (! $this->model->hasPage()) { + return false; + } + + return $list; + } +} diff --git a/app/Models/Search/ActionT.php b/app/Models/Search/ActionT.php index 6e8ed598..2668da3e 100644 --- a/app/Models/Search/ActionT.php +++ b/app/Models/Search/ActionT.php @@ -74,6 +74,23 @@ class ActionT extends Method AND (mof.mf_mark_all_read IS NULL OR t.last_post>mof.mf_mark_all_read) ORDER BY t.last_post DESC'; break; + case 'topics_subscriptions': + if (0 !== $root->id) { + return false; + } + + $user = $this->c->users->load($uid); + + if (! $this->c->ProfileRules->setUser($user)->viewSubscription) { + return false; + } + + $subscr = $this->c->subscriptions; + $subscrInfo = $subscr->info($user, $subscr::TOPICS_DATA); + $list = $subscrInfo[$subscr::TOPICS_DATA] ?? []; + + \arsort($list, \SORT_NUMERIC); // ???? или по последнему сообщению делать? + break; default: throw new InvalidArgumentException('Unknown action: ' . $action); } diff --git a/app/bootstrap.php b/app/bootstrap.php index aca95b22..9c5ebaf4 100644 --- a/app/bootstrap.php +++ b/app/bootstrap.php @@ -42,7 +42,7 @@ if ( } $c->PUBLIC_URL = $c->BASE_URL . $forkPublicPrefix; -$c->FORK_REVISION = 11; +$c->FORK_REVISION = 12; $c->START = $forkStart; $c->DIR_APP = __DIR__; $c->DIR_PUBLIC = $forkPublic; diff --git a/app/config/main.dist.php b/app/config/main.dist.php index f1310a3d..ac5f9261 100644 --- a/app/config/main.dist.php +++ b/app/config/main.dist.php @@ -284,6 +284,7 @@ return [ 'SearchModelActionP' => \ForkBB\Models\Search\ActionP::class, 'SearchModelActionT' => \ForkBB\Models\Search\ActionT::class, + 'SearchModelActionF' => \ForkBB\Models\Search\ActionF::class, 'SearchModelDelete' => \ForkBB\Models\Search\Delete::class, 'SearchModelIndex' => \ForkBB\Models\Search\Index::class, 'SearchModelTruncateIndex' => \ForkBB\Models\Search\TruncateIndex::class, diff --git a/app/lang/en/search.po b/app/lang/en/search.po index 31976f2a..86333d92 100644 --- a/app/lang/en/search.po +++ b/app/lang/en/search.po @@ -117,8 +117,11 @@ msgstr "Topics by %s" msgid "Quick search user posts" msgstr "Posts by %s" -msgid "Quick search show_subscriptions" -msgstr "Subscribed by %s" +msgid "Quick search user topics_subscriptions" +msgstr "Topics subscribed by %s" + +msgid "Quick search user forums_subscriptions" +msgstr "Forums subscribed by %s" msgid "Quick search show_user_warn" msgstr "Warnings for %s" diff --git a/app/lang/ru/search.po b/app/lang/ru/search.po index d786ac4c..dd4dd419 100644 --- a/app/lang/ru/search.po +++ b/app/lang/ru/search.po @@ -117,8 +117,11 @@ msgstr "Темы от %s" msgid "Quick search user posts" msgstr "Сообщения от %s" -msgid "Quick search show_subscriptions" -msgstr "Подписки пользователя %s" +msgid "Quick search user topics_subscriptions" +msgstr "Темы с подпиской от %s" + +msgid "Quick search user forums_subscriptions" +msgstr "Разделы с подпиской от %s" msgid "Quick search show_user_warn" msgstr "Предупреждения для %s" diff --git a/readme.md b/readme.md index 045369df..32df200c 100644 --- a/readme.md +++ b/readme.md @@ -1,4 +1,4 @@ -# ForkBB rev 11 Pre-Alpha Readme +# ForkBB rev 12 Pre-Alpha Readme ## About