mirror of
https://github.com/pierre42100/ComunicAPI
synced 2025-06-19 08:35:18 +00:00
Can find user ID with its folder name
This commit is contained in:
@ -297,6 +297,36 @@ class User{
|
||||
return count($result) !== 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the user specified by a folder name
|
||||
*
|
||||
* @param string $folder The folder of the research
|
||||
* @return int 0 if no user was found or the ID of the user in case of success
|
||||
*/
|
||||
public function findByFolder(string $folder) : int {
|
||||
|
||||
//Perform a request on the database
|
||||
$tableName = $this->userTable;
|
||||
$condition = "WHERE sous_repertoire = ?";
|
||||
$condValues = array($folder);
|
||||
$requiredFields = array("ID");
|
||||
|
||||
//Try to perform the request
|
||||
$result = CS::get()->db->select($tableName, $condition, $condValues, $requiredFields);
|
||||
|
||||
//Check for errors
|
||||
if($result === false){
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(count($result) == 0)
|
||||
return 0; //There is no result
|
||||
|
||||
//Return result
|
||||
return $result[0]["ID"];
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Crypt user password
|
||||
*
|
||||
|
Reference in New Issue
Block a user