]> git.mxchange.org Git - friendica.git/blobdiff - mod/msearch.php
"escapeTags" is finally removed
[friendica.git] / mod / msearch.php
index b280db4f1879045d0c21641902426979d37258a9..969446ffb524968f77f0acf1afd2528832abf23a 100644 (file)
@@ -22,6 +22,8 @@
 use Friendica\App;
 use Friendica\Database\DBA;
 use Friendica\DI;
+use Friendica\Model\User;
+use Friendica\Util\Proxy;
 
 function msearch_post(App $a)
 {
@@ -41,38 +43,15 @@ function msearch_post(App $a)
 
        $total = 0;
 
-       $count_stmt = DBA::p(
-               "SELECT COUNT(*) AS `total`
-                       FROM `profile`
-                       JOIN `user` ON `user`.`uid` = `profile`.`uid`
-                       WHERE `profile`.`net-publish`
-                       AND MATCH(`pub_keywords`) AGAINST (?)",
-               $search
-       );
-       if (DBA::isResult($count_stmt)) {
-               $row = DBA::fetch($count_stmt);
-               $total = $row['total'];
-       }
-
-       DBA::close($count_stmt);
-
-       $search_stmt = DBA::p(
-               "SELECT `pub_keywords`, `username`, `nickname`, `user`.`uid`
-                       FROM `user`
-                       JOIN `profile` ON `user`.`uid` = `profile`.`uid`
-                       WHERE `profile`.`net-publish`
-                       AND MATCH(`pub_keywords`) AGAINST (?)
-                       LIMIT ?, ?",
-               $search,
-               $startrec,
-               $perpage
-       );
+       $condition = ["`net-publish` AND MATCH(`pub_keywords`) AGAINST (?)", $search];
+       $total = DBA::count('owner-view', $condition);
 
+       $search_stmt = DBA::select('owner-view', ['pub_keywords', 'name', 'nickname', 'uid'], $condition, ['limit' => [$startrec, $perpage]]);
        while ($search_result = DBA::fetch($search_stmt)) {
                $results[] = [
                        'name'  => $search_result['name'],
                        'url'   => DI::baseUrl() . '/profile/' . $search_result['nickname'],
-                       'photo' => DI::baseUrl() . '/photo/avatar/' . $search_result['uid'] . '.jpg',
+                       'photo' => User::getAvatarUrl($search_result, Proxy::SIZE_THUMB),
                        'tags'  => str_replace([',', '  '], [' ', ' '], $search_result['pub_keywords'])
                ];
        }