mirror of
https://github.com/pierre42100/ComunicAPI
synced 2024-11-27 07:49:27 +00:00
Get safely the ID of a group in a POST request.
This commit is contained in:
parent
0a3ae02bce
commit
291558578b
@ -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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user