mirror of
				https://github.com/pierre42100/ComunicAPI
				synced 2025-11-04 04:04:20 +00:00 
			
		
		
		
	Get safely the ID of a group in a POST request.
This commit is contained in:
		@@ -563,4 +563,24 @@ function getPostUserDirectory(string $name) : string {
 | 
			
		||||
	//Return the directory
 | 
			
		||||
	return $directory;
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Get a POST group ID
 | 
			
		||||
 * 
 | 
			
		||||
 * @param string $name The name of variable in the $_POST request
 | 
			
		||||
 * @return int The ID of the group
 | 
			
		||||
 * @throws RESTException If the directory is missing
 | 
			
		||||
 */
 | 
			
		||||
function getPostGroupId(string $name) : int {
 | 
			
		||||
 | 
			
		||||
	//Get the ID of the group
 | 
			
		||||
	$id = postInt($name);
 | 
			
		||||
 | 
			
		||||
	//Check if the group exists or not
 | 
			
		||||
	if(!components()->groups->exists($id))
 | 
			
		||||
		Rest_fatal_error(404, "Specified group does not exists !");
 | 
			
		||||
	
 | 
			
		||||
	//Return the ID of the group
 | 
			
		||||
	return $id;
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user