X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModule%2FSearch%2FIndex.php;h=93c1af7aa6d5874afb82f08d744ae4392969c893;hb=69b7923df2beed71419bc38e61ca9755fad24b12;hp=5f776577e0825380a00e46fc7d8b6c3dbfbd7fcd;hpb=2bfd9851d30b56821e042c6882db84ec62fd8a2a;p=friendica.git diff --git a/src/Module/Search/Index.php b/src/Module/Search/Index.php index 5f776577e0..93c1af7aa6 100644 --- a/src/Module/Search/Index.php +++ b/src/Module/Search/Index.php @@ -1,6 +1,6 @@ get('system', 'block_public') && !Session::isAuthenticated()) { throw new HTTPException\ForbiddenException(DI::l10n()->t('Public access denied.')); } if (DI::config()->get('system', 'local_search') && !Session::isAuthenticated()) { - $e = new HTTPException\ForbiddenException(DI::l10n()->t('Only logged in users are permitted to perform a search.')); - $e->httpdesc = DI::l10n()->t('Public access denied.'); - throw $e; + throw new HTTPException\ForbiddenException(DI::l10n()->t('Only logged in users are permitted to perform a search.')); } if (DI::config()->get('system', 'permit_crawling') && !Session::isAuthenticated()) { @@ -90,7 +87,7 @@ class Index extends BaseSearch $tag = false; if (!empty($_GET['tag'])) { $tag = true; - $search = '#' . Strings::escapeTags(trim(rawurldecode($_GET['tag']))); + $search = '#' . trim(rawurldecode($_GET['tag'])); } // contruct a wrapper for the search header @@ -165,17 +162,21 @@ class Index extends BaseSearch $count = Tag::countByTag($search, local_user()); } else { Logger::info('Start fulltext search.', ['q' => $search]); - $uriids = ItemContent::getURIIdListBySearch($search, local_user(), $pager->getStart(), $pager->getItemsPerPage(), $last_uriid); - $count = ItemContent::countBySearch($search, local_user()); + $uriids = Post\Content::getURIIdListBySearch($search, local_user(), $pager->getStart(), $pager->getItemsPerPage(), $last_uriid); + $count = Post\Content::countBySearch($search, local_user()); } if (!empty($uriids)) { - $params = ['order' => ['id' => true], 'group_by' => ['uri-id']]; - $items = Item::inArray(Item::selectForUser(local_user(), [], ['uri-id' => $uriids], $params)); + $condition = ["(`uid` = ? OR (`uid` = ? AND NOT `global`))", 0, local_user()]; + $condition = DBA::mergeConditions($condition, ['uri-id' => $uriids]); + $params = ['order' => ['id' => true]]; + $items = Post::toArray(Post::selectForUser(local_user(), Item::DISPLAY_FIELDLIST, $condition, $params)); } if (empty($items)) { - notice(DI::l10n()->t('No results.')); + if (empty($last_uriid)) { + notice(DI::l10n()->t('No results.')); + } return $o; } @@ -196,7 +197,7 @@ class Index extends BaseSearch Logger::info('Start Conversation.', ['q' => $search]); - $o .= conversation(DI::app(), $items, 'search', false, false, 'commented', local_user()); + $o .= DI::conversation()->create($items, 'search', false, false, 'commented', local_user()); if (DI::pConfig()->get(local_user(), 'system', 'infinite_scroll')) { $o .= HTML::scrollLoader(); @@ -286,7 +287,7 @@ class Index extends BaseSearch } if (!empty($item_id)) { - $item = Item::selectFirst(['guid'], ['id' => $item_id]); + $item = Post::selectFirst(['guid'], ['id' => $item_id]); if (DBA::isResult($item)) { DI::baseUrl()->redirect('display/' . $item['guid']); }