mirror of
https://github.com/pierre42100/ComunicAPI
synced 2024-11-23 22:09:29 +00:00
Can get informations about a specific user
This commit is contained in:
parent
cd81cfd8ba
commit
6cc90d281f
@ -79,6 +79,29 @@ class friendsController{
|
|||||||
return $IDs;
|
return $IDs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get friendship informations about a specific friend
|
||||||
|
*
|
||||||
|
* @url POST /friends/get_single_infos
|
||||||
|
*/
|
||||||
|
public function get_single_infos(){
|
||||||
|
|
||||||
|
user_login_required();
|
||||||
|
|
||||||
|
//Get friendID
|
||||||
|
$friendID = getPostUserID('friendID');
|
||||||
|
|
||||||
|
//Get informations about the friendship
|
||||||
|
$list = components()->friends->getList(userID, $friendID);
|
||||||
|
|
||||||
|
//Check if the friend was found or not
|
||||||
|
if(count($list) == 0)
|
||||||
|
Rest_fatal_error(404, "Specified friend not found !");
|
||||||
|
|
||||||
|
//Return informations about the friend
|
||||||
|
return $this->parseFriendAPI($list[0], true);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send a friendship request
|
* Send a friendship request
|
||||||
*
|
*
|
||||||
|
@ -28,15 +28,25 @@ class friends {
|
|||||||
* Get and returns the list of the friends of a user
|
* Get and returns the list of the friends of a user
|
||||||
*
|
*
|
||||||
* @param int $userID The ID of the user
|
* @param int $userID The ID of the user
|
||||||
|
* @param int $friendID The ID of a specific friend (default -1)
|
||||||
* @return array The list of the friends of the user (Friend objects)
|
* @return array The list of the friends of the user (Friend objects)
|
||||||
*/
|
*/
|
||||||
public function getList(int $userID) : array {
|
public function getList(int $userID, int $friendID = -1) : array {
|
||||||
|
|
||||||
//Prepare the request on the database
|
//Prepare the request on the database
|
||||||
$tableName = $this->friendsTable.", utilisateurs";
|
$tableName = $this->friendsTable.", utilisateurs";
|
||||||
$condition = "WHERE ID_personne = ? AND amis.ID_amis = utilisateurs.ID ORDER BY utilisateurs.last_activity DESC";
|
$condition = "WHERE ID_personne = ? AND amis.ID_amis = utilisateurs.ID ";
|
||||||
$condValues = array($userID);
|
$condValues = array($userID);
|
||||||
|
|
||||||
|
//Check if the request is targeting a specific friend
|
||||||
|
if($friendID != -1){
|
||||||
|
$condition .= " AND ID_amis = ?";
|
||||||
|
$condValues[] = $friendID;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Complete conditions
|
||||||
|
$condition .= "ORDER BY utilisateurs.last_activity DESC";
|
||||||
|
|
||||||
//Specify which fields to get
|
//Specify which fields to get
|
||||||
$fieldsList = array(
|
$fieldsList = array(
|
||||||
"utilisateurs.last_activity",
|
"utilisateurs.last_activity",
|
||||||
|
Loading…
Reference in New Issue
Block a user