]> git.mxchange.org Git - friendica.git/blobdiff - mod/search.php
Issue 7285: Perform duplicate check for item URI also with AP
[friendica.git] / mod / search.php
index 1416f1d89f52d34edb82e9a94da5af8e91353779..4a911b4fd9828a51aaf05459bdad0dfc67174c15 100644 (file)
@@ -12,15 +12,12 @@ use Friendica\Core\Config;
 use Friendica\Core\L10n;
 use Friendica\Core\Logger;
 use Friendica\Core\Renderer;
-use Friendica\Core\System;
 use Friendica\Database\DBA;
 use Friendica\Model\Item;
+use Friendica\Module\BaseSearchModule;
 use Friendica\Util\Strings;
 
-require_once 'mod/dirfind.php';
-
 function search_saved_searches() {
-
        $o = '';
        $search = (!empty($_GET['search']) ? Strings::escapeTags(trim(rawurldecode($_GET['search']))) : '');
 
@@ -52,12 +49,10 @@ function search_saved_searches() {
        }
 
        return $o;
-
 }
 
 
 function search_init(App $a) {
-
        $search = (!empty($_GET['search']) ? Strings::escapeTags(trim(rawurldecode($_GET['search']))) : '');
 
        if (local_user()) {
@@ -85,13 +80,9 @@ function search_init(App $a) {
                unset($_SESSION['theme']);
                unset($_SESSION['mobile-theme']);
        }
-
-
-
 }
 
 function search_content(App $a) {
-
        if (Config::get('system','block_public') && !local_user() && !remote_user()) {
                notice(L10n::t('Public access denied.') . EOL);
                return;
@@ -150,10 +141,20 @@ function search_content(App $a) {
                $search = substr($search,1);
        }
        if (strpos($search,'@') === 0) {
-               return dirfind_content($a);
+               return BaseSearchModule::performSearch();
        }
        if (strpos($search,'!') === 0) {
-               return dirfind_content($a);
+               return BaseSearchModule::performSearch();
+       }
+
+       if (parse_url($search, PHP_URL_SCHEME) != '') {
+               $id = Item::fetchByLink($search);
+               if (!empty($id)) {
+                       $item = Item::selectFirst(['guid'], ['id' => $id]);
+                       if (DBA::isResult($item)) {
+                               $a->internalRedirect('display/' . $item['guid']);
+                       }
+               }
        }
 
        if (!empty($_GET['search-option']))
@@ -164,11 +165,9 @@ function search_content(App $a) {
                                $tag = true;
                                break;
                        case 'contacts':
-                               return dirfind_content($a, "@");
-                               break;
+                               return BaseSearchModule::performSearch('@');
                        case 'forums':
-                               return dirfind_content($a, "!");
-                               break;
+                               return BaseSearchModule::performSearch('!');
                }
 
        if (!$search)
@@ -190,7 +189,7 @@ function search_content(App $a) {
                $condition = ["(`uid` = 0 OR (`uid` = ? AND NOT `global`))
                        AND `otype` = ? AND `type` = ? AND `term` = ?",
                        local_user(), TERM_OBJ_POST, TERM_HASHTAG, $search];
-               $params = ['order' => ['created' => true],
+               $params = ['order' => ['received' => true],
                        'limit' => [$pager->getStart(), $pager->getItemsPerPage()]];
                $terms = DBA::select('term', ['oid'], $condition, $params);