X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fgroup.php;h=fd1c97dfde47d1af8c665b03eac51370428a7940;hb=9d4d29ad9eb6302fb02eda0ba5f6bcd128a86f49;hp=862d06818dd0957bb8a7428f3a7c7b996b953e89;hpb=d3d0647ff8e354e1a1b6ba12e0e2454d58901f6a;p=friendica.git diff --git a/include/group.php b/include/group.php index 862d06818d..fd1c97dfde 100644 --- a/include/group.php +++ b/include/group.php @@ -340,3 +340,30 @@ function groups_containing($uid,$c) { return $ret; } +/** + * @brief count unread group items + * + * Count unread items of each groups + * + * @return array + * 'id' => group id + * 'name' => group name + * 'count' => counted unseen group items + * + */ +function groups_count_unseen() { + + $r = q("SELECT `group`.`id`, `group`.`name`, COUNT(`item`.`id`) AS `count` FROM `group`, `group_member`, `item` + WHERE `group`.`uid` = %d + AND `item`.`uid` = %d + AND `item`.`unseen` AND `item`.`visible` + AND NOT `item`.`deleted` + AND `item`.`contact-id` = `group_member`.`contact-id` + AND `group_member`.`gid` = `group`.`id` + GROUP BY `group`.`id` ", + intval(local_user()), + intval(local_user()) + ); + + return $r; +} \ No newline at end of file