mirror of
https://github.com/pierre42100/ComunicAPI
synced 2024-12-25 13:08:58 +00:00
Can get the number of friendship request with the notifications.
This commit is contained in:
parent
85582a44cc
commit
e1760dd772
@ -40,11 +40,17 @@ class notificationsController {
|
||||
user_login_required();
|
||||
|
||||
//Get and return the data
|
||||
return array(
|
||||
$data = array(
|
||||
"notifications" => components()->notifications->count_unread(userID),
|
||||
"conversations" => components()->conversations->number_user_unread(userID)
|
||||
);
|
||||
|
||||
//Include friendship requests if required
|
||||
if(isset($_POST["friends_request"]))
|
||||
if(postBool("friends_request"))
|
||||
$data["friends_request"] = components()->friends->count_requests(userID);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
|
@ -409,6 +409,19 @@ class friends {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Count the number of friendship requests a user has received
|
||||
*
|
||||
* @param int $userID Target user ID
|
||||
* @return int The number of friendship request the user received
|
||||
*/
|
||||
public function count_requests(int $userID) : int {
|
||||
return db()->count(
|
||||
$this->friendsTable,
|
||||
"WHERE ID_personne = ? AND actif = 0",
|
||||
array($userID));
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse friend informations from the database
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user