]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/Tag.php
Merge pull request #10116 from mexon/mat/addon-console-command
[friendica.git] / src / Model / Tag.php
index c63ba0a83940e281b20066424f2082858972474a..8f132e82f3614168b91812480bc21c16f6a17173 100644 (file)
@@ -455,12 +455,11 @@ class Tag
         */
        public static function countByTag(string $search, int $uid = 0)
        {
-               $condition = ["`name` = ? AND (NOT `private` OR (`private` AND `uid` = ?))
-                       AND `uri-id` IN (SELECT `uri-id` FROM `post-view` WHERE `network` IN (?, ?, ?, ?))",
-                       $search, $uid, Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS];
-               $params = ['group_by' => ['uri-id']];
+               $condition = ["`name` = ? AND (`uid` = ? OR (`uid` = ? AND NOT `global`))
+                       AND (`network` IN (?, ?, ?, ?) OR (`uid` = ? AND `uid` != ?))",
+                       $search, 0, $uid, Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS, $uid, 0];
 
-               return DBA::count('tag-search-view', $condition, $params);
+               return DBA::count('tag-search-view', $condition);
        }
 
        /**
@@ -475,9 +474,9 @@ class Tag
         */
        public static function getURIIdListByTag(string $search, int $uid = 0, int $start = 0, int $limit = 100, int $last_uriid = 0)
        {
-               $condition = ["`name` = ? AND (NOT `private` OR (`private` AND `uid` = ?))
-                       AND `uri-id` IN (SELECT `uri-id` FROM `post-view` WHERE `network` IN (?, ?, ?, ?))",
-                       $search, $uid, Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS];
+               $condition = ["`name` = ? AND (`uid` = ? OR (`uid` = ? AND NOT `global`))
+                       AND (`network` IN (?, ?, ?, ?) OR (`uid` = ? AND `uid` != ?))",
+                       $search, 0, $uid, Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS, $uid, 0];
 
                if (!empty($last_uriid)) {
                        $condition = DBA::mergeConditions($condition, ["`uri-id` < ?", $last_uriid]);
@@ -485,7 +484,6 @@ class Tag
 
                $params = [
                        'order' => ['uri-id' => true],
-                       'group_by' => ['uri-id'],
                        'limit' => [$start, $limit]
                ];