Added hang up status

This commit is contained in:
Pierre HUBERT 2019-01-25 19:12:06 +01:00
parent b94c859a16
commit 4d6ada1523
3 changed files with 28 additions and 3 deletions

View File

@ -14,7 +14,8 @@ class CallsController {
const USER_RESPONSE_TO_CALL = array(
CallMemberInformation::USER_ACCEPTED => "accepted",
CallMemberInformation::USER_REJECTED => "rejected",
CallMemberInformation::USER_UNKNOWN => "unknown"
CallMemberInformation::USER_UNKNOWN => "unknown",
CallMemberInformation::USER_HANG_UP => "hang_up"
);
/**

View File

@ -265,12 +265,35 @@ class CallsComponents {
* @return bool TRUE for a success / FALSE else
*/
public function setMemberResponse(int $callID, int $userID, bool $accept) : bool {
return $this->setMemberStatus(
$accept ? CallMemberInformation::USER_ACCEPTED : CallMemberInformation::USER_REJECTED, $callID, $userID);
}
/**
* Make user hang up the call
*
* @param int $callID Target call ID
* @param int $userID Target user ID
* @return bool TRUE for a success / FALSE else
*/
public function setMemberHangUp(int $callID, int $userID) : bool {
return $this->setMemberStatus(CallMemberInformation::USER_HANG_UP, $callID, $userID);
}
/**
* Update member status
*
* @param $status New status for the user
* @param $callID Target call ID
* @param $userID Target user ID
* @return bool TRUE for a success / FALSE else
*/
private function setMemberStatus(int $status, int $callID, int $userID){
db()->updateDB(
self::CALLS_MEMBERS_TABLE,
"call_id = ? AND user_id = ?",
array(
"user_accepted" =>
$accept ? CallMemberInformation::USER_ACCEPTED : CallMemberInformation::USER_REJECTED
"user_accepted" => $status
),
array(
$callID,

View File

@ -13,6 +13,7 @@ class CallMemberInformation extends BaseUniqueObjectFromUser {
public const USER_ACCEPTED = 1;
public const USER_REJECTED = 0;
public const USER_UNKNOWN = -1;
public const USER_HANG_UP = 2;