Can get the number of pending calls for a user

This commit is contained in:
Pierre HUBERT 2019-01-24 17:40:26 +01:00
parent e41cf0161e
commit 9d1371fd81
2 changed files with 22 additions and 0 deletions

View File

@ -50,6 +50,12 @@ class notificationsController {
if(postBool("friends_request"))
$data["friends_request"] = components()->friends->count_requests(userID);
//Include pending calls if required
if(isset($_POST["include_calls"]))
if(postBool("include_calls"))
$data["calls"] = components()->calls->countPendingResponsesForUser(userID);
return $data;
}

View File

@ -147,6 +147,22 @@ class CallsComponents {
return count($entries) > 0;
}
/**
* Count and return the number of pending calls for a user
*
* @param $userID The ID of the target user
* @return int The number of pending calls for the user
*/
public function countPendingResponsesForUser(int $userID) : int {
return db()->count(
self::CALLS_MEMBERS_TABLE,
"WHERE user_id = ? AND user_accepted = ?",
array($userID, CallMemberInformation::USER_UNKNOWN)
);
}
/**
* Set the response of a member to a call
*