From d99b4c7f1814d420d55f42e69dc6b5bd3a6bbf7c Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Fri, 20 Jul 2018 13:37:32 +0200 Subject: [PATCH] Get the list of followers of a group --- classes/components/GroupsComponent.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/classes/components/GroupsComponent.php b/classes/components/GroupsComponent.php index e7e36d1..d2ee32e 100644 --- a/classes/components/GroupsComponent.php +++ b/classes/components/GroupsComponent.php @@ -231,6 +231,29 @@ class GroupsComponent { return $this->multipleDBToGroupMember($members); } + /** + * Get the list of members of the group that follows it + * + * @param int $groupID The ID of the target group + * @return array The list of members + */ + public function getListFollowers(int $groupID) : array { + + $result = db()->select( + self::GROUPS_MEMBERS_TABLE, + "WHERE groups_id = ? AND following = 1", + array($groupID), + array("user_id") + ); + + //Parse the list of IDs + $list = array(); + foreach($result as $el) + $list[] = $el["user_id"]; + return $list; + + } + /** * Count the number of a kind of membership in a group *