From a578dca41fd97d53aad23192cced108098b68595 Mon Sep 17 00:00:00 2001 From: Maxim Leshchenko Date: Thu, 21 Jul 2022 17:59:18 +0100 Subject: [PATCH] VKAPI: Add ovk.aboutInstance --- VKAPI/Handlers/Ovk.php | 52 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/VKAPI/Handlers/Ovk.php b/VKAPI/Handlers/Ovk.php index 42243cf1..c02827be 100644 --- a/VKAPI/Handlers/Ovk.php +++ b/VKAPI/Handlers/Ovk.php @@ -1,5 +1,7 @@ getStatistics(); + $clubsCount = (new ClubsRepo)->getCount(); + $postsCount = (new PostsRepo)->getCount(); + $response->statistics = (object) [ + "users_count" => $usersStats->all, + "online_users_count" => $usersStats->online, + "active_users_count" => $usersStats->active, + "groups_count" => $clubsCount, + "wall_posts_count" => $postsCount + ]; + } + + if(in_array("administrators", $fields)) { + $admins = iterator_to_array((new UsersRepo)->getInstanceAdmins()); + $adminsResponse = (new Users($this->getUser()))->get(implode(',', array_map(function($admin) { + return $admin->getId(); + }, $admins)), $admin_fields, 0, sizeof($admins)); + $response->administrators = (object) [ + "count" => sizeof($admins), + "items" => $adminsResponse + ]; + } + + if(in_array("popular_groups", $fields)) { + $popularClubs = iterator_to_array((new ClubsRepo)->getPopularClubs()); + $clubsResponse = (new Groups($this->getUser()))->getById(implode(',', array_map(function($entry) { + return $entry->club->getId(); + }, $popularClubs)), "", "members_count, " . $group_fields); + + $response->popular_groups = (object) [ + "count" => sizeof($popularClubs), + "items" => $clubsResponse + ]; + } + + if(in_array("links", $fields)) + $response->links = (object) [ + "count" => sizeof(OPENVK_ROOT_CONF['openvk']['preferences']['about']['links']), + "items" => is_null(OPENVK_ROOT_CONF['openvk']['preferences']['about']['links']) ? [] : OPENVK_ROOT_CONF['openvk']['preferences']['about']['links'] + ]; + + return $response; + } }