]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/Circle.php
Drop using the proxy large size for image preview
[friendica.git] / src / Model / Circle.php
index c0b3cf6b4b37cc9365e35735de5407414ee1a956..92e3ea656010a6fed2c439a1e87c1929a467864f 100644 (file)
@@ -22,6 +22,7 @@
 namespace Friendica\Model;
 
 use Friendica\BaseModule;
+use Friendica\Content\Widget;
 use Friendica\Core\Logger;
 use Friendica\Core\Protocol;
 use Friendica\Core\Renderer;
@@ -168,16 +169,17 @@ class Circle
         *
         * Count unread items of each circle of the local user
         *
+        * @param int $uid
         * @return array
         *    'id' => circle id
         *    'name' => circle name
         *    'count' => counted unseen circle items
         * @throws \Exception
         */
-       public static function countUnseen()
+       public static function countUnseen(int $uid)
        {
                $stmt = DBA::p("SELECT `circle`.`id`, `circle`.`name`,
-                               (SELECT COUNT(*) FROM `post-user-view`
+                               (SELECT COUNT(*) FROM `post-user`
                                        WHERE `uid` = ?
                                        AND `unseen`
                                        AND `contact-id` IN
@@ -187,8 +189,8 @@ class Circle
                                        ) AS `count`
                                FROM `group` AS `circle`
                                WHERE `circle`.`uid` = ?;",
-                       DI::userSession()->getLocalUserId(),
-                       DI::userSession()->getLocalUserId()
+                       $uid,
+                       $uid
                );
 
                return DBA::toArray($stmt);
@@ -565,7 +567,12 @@ class Circle
                        }
 
                        if ($each == 'circle') {
-                               $count = DBA::count('group_member', ['gid' => $circle['id']]);
+                               $networks = Widget::unavailableNetworks();
+                               $sql_values = array_merge([$circle['id']], $networks);
+                               $condition = ["`circle-id` = ? AND NOT `contact-network` IN (" . substr(str_repeat("?, ", count($networks)), 0, -2) . ")"];
+                               $condition = array_merge($condition, $sql_values);
+
+                               $count = DBA::count('circle-member-view', $condition);
                                $circle_name = sprintf('%s (%d)', $circle['name'], $count);
                        } else {
                                $circle_name = $circle['name'];