From ffcef67b70a921703bd5838ce8b63302db15a1bf Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Fri, 20 Jul 2018 08:53:33 +0200 Subject: [PATCH] Can get information about multiple groups. --- RestControllers/GroupsController.php | 33 ++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/RestControllers/GroupsController.php b/RestControllers/GroupsController.php index dfb6a62..be837a6 100644 --- a/RestControllers/GroupsController.php +++ b/RestControllers/GroupsController.php @@ -99,6 +99,39 @@ class GroupsController { return self::GroupInfoToAPI($group); } + /** + * Get information about multiple groups + * + * @url POST /groups/get_multiple_info + */ + public function getMultipleInfo(){ + + //Get the IDs of requested groups + $IDs = numbers_list_to_array(postString("list", 1)); + + //Process the list of groups + foreach($IDs as $groupID){ + + //Check if the group exists or not + if(!components()->groups->exists($groupID)) + Rest_fatal_error(404, "Group ".$groupID." not found!"); + + //Check the user is allowed to access this group information + if(components()->groups->getAccessLevel($groupID, userID) < GroupInfo::LIMITED_ACCESS) + Rest_fatal_error(404, "Group ".$groupID." not found!"); + + //Get the group information + $group = components()->groups->get_info($groupID); + + if(!$group->isValid()) + Rest_fatal_error(500, "Could not get a group information!"); + + $IDs[$groupID] = self::GroupInfoToAPI($group); + } + + return $IDs; + } + /** * Get advanced information about a group *