Can get information about multiple groups.

This commit is contained in:
Pierre HUBERT 2018-07-20 08:53:33 +02:00
parent e1c8399a74
commit ffcef67b70

View File

@ -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
*