mirror of
https://github.com/pierre42100/ComunicAPI
synced 2024-11-27 15:59:29 +00:00
Can get the number of friends of a user
This commit is contained in:
parent
ffff5e6c85
commit
a2b92b4e6c
@ -138,6 +138,17 @@ class userController
|
|||||||
if(count($userInfos) == 0)
|
if(count($userInfos) == 0)
|
||||||
Rest_fatal_error(500, "Couldn't get informations about the user !");
|
Rest_fatal_error(500, "Couldn't get informations about the user !");
|
||||||
|
|
||||||
|
//Add account image url
|
||||||
|
$userInfos['accountImage'] = CS::get()->components->accountImage->getPath($userID);
|
||||||
|
|
||||||
|
//Get the number of friends (if allowed)
|
||||||
|
if($userInfos['friend_list_public'] === true){
|
||||||
|
$userInfos['number_friends'] = CS::get()->components->friends->count_all($userID);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
//User friends won't be displayed
|
||||||
|
$userInfos["number_friends"] = 0;
|
||||||
|
|
||||||
//Return user informations
|
//Return user informations
|
||||||
return $userInfos;
|
return $userInfos;
|
||||||
|
|
||||||
|
@ -322,6 +322,23 @@ class friends {
|
|||||||
//Perform the request
|
//Perform the request
|
||||||
return CS::get()->db->updateDB($tableName, $conditions, $newValues, $conditionsValues);
|
return CS::get()->db->updateDB($tableName, $conditions, $newValues, $conditionsValues);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Count the number of friends of a user
|
||||||
|
*
|
||||||
|
* @param int $userID The target user ID
|
||||||
|
* @return int The number of friends of the user
|
||||||
|
*/
|
||||||
|
public function count_all(int $userID) : int {
|
||||||
|
|
||||||
|
//Perform a request on the datbase
|
||||||
|
$tableName = $this->friendsTable;
|
||||||
|
$conditions = "WHERE ID_amis = ? AND actif = 1";
|
||||||
|
$condValues = array($userID);
|
||||||
|
|
||||||
|
return CS::get()->db->count($tableName, $conditions, $condValues);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Register component
|
//Register component
|
||||||
|
@ -236,9 +236,6 @@ class User{
|
|||||||
$return['openPage'] = $userInfos['pageouverte'] == 1;
|
$return['openPage'] = $userInfos['pageouverte'] == 1;
|
||||||
$return['virtualDirectory'] = $userInfos['sous_repertoire'];
|
$return['virtualDirectory'] = $userInfos['sous_repertoire'];
|
||||||
|
|
||||||
//Add account image url
|
|
||||||
$return['accountImage'] = CS::get()->components->accountImage->getPath($return['userID']);
|
|
||||||
|
|
||||||
//Check if we have to fetch advanced informations
|
//Check if we have to fetch advanced informations
|
||||||
if($advanced){
|
if($advanced){
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user