Can respond to a membership request

This commit is contained in:
Pierre HUBERT
2018-07-09 15:24:56 +02:00
parent 4fd5cfde37
commit aee09dee43
2 changed files with 59 additions and 0 deletions

View File

@ -296,6 +296,24 @@ class GroupsComponent {
return $this->updateMembershipLevel($userID, $groupID, GroupMember::MEMBER);
}
/**
* Respond to a membership request
*
* @param int $userID The ID of the target user
* @param int $groupID The ID of the related group
* @param bool $accept Set whether the request was accepted or not
* @return bool TRUE for a success / FALSE else
*/
public function respondRequest(int $userID, int $groupID, bool $accept) : bool {
//If the user reject the invitation, delete it
if(!$accept)
return $this->deleteRequest($userID, $groupID);
//Upgrade the user as member
return $this->updateMembershipLevel($userID, $groupID, GroupMember::MEMBER);
}
/**
* Delete a membership invitation
*
@ -307,6 +325,17 @@ class GroupsComponent {
return $this->deleteMembershipWithStatus($userID, $groupID, GroupMember::INVITED);
}
/**
* Delete a membership request
*
* @param int $userID The ID of the target user
* @param int $groupID The ID of the related group
* @return bool TRUE for a success / FALSE else
*/
public function deleteRequest(int $userID, int $groupID) : bool {
return $this->deleteMembershipWithStatus($userID, $groupID, GroupMember::PENDING);
}
/**
* Cancel a membership request
*