Can respond to a membership invitation.

This commit is contained in:
Pierre HUBERT
2018-07-06 06:53:59 +02:00
parent d55cca75b2
commit c3bdbedb30
2 changed files with 458 additions and 358 deletions

View File

@ -119,6 +119,8 @@ class GroupsController {
*/
public function getSettings(){
user_login_required();
//Get the ID of the group (with admin access)
$groupID = getPostGroupIdWithAccess("id", GroupInfo::ADMIN_ACCESS);
@ -140,6 +142,8 @@ class GroupsController {
*/
public function setSettings(){
user_login_required();
//Get the ID of the group (with admin access)
$groupID = getPostGroupIdWithAccess("id", GroupInfo::ADMIN_ACCESS);
@ -176,6 +180,8 @@ class GroupsController {
*/
public function uploadLogo(){
user_login_required();
//Get the ID of the group (with admin access)
$groupID = getPostGroupIdWithAccess("id", GroupInfo::ADMIN_ACCESS);
@ -211,6 +217,8 @@ class GroupsController {
*/
public function deleteLogo(){
user_login_required();
//Get the ID of the group (with admin access)
$groupID = getPostGroupIdWithAccess("id", GroupInfo::ADMIN_ACCESS);
@ -225,6 +233,33 @@ class GroupsController {
);
}
/**
* Respond to a membership invitation
*
* @url POST /groups/respond_invitation
*/
public function respondInvitation(){
user_login_required();
//Get the ID of the group (with basic access)
$groupID = getPostGroupIdWithAccess("id", GroupInfo::LIMITED_ACCESS);
//Get the response to the invitation
$accept = postBool("accept");
//Check if the user received an invitation or not
if(!components()->groups->receivedInvitation(userID, $groupID))
Rest_fatal_error(404, "Invitation not found!");
//Try to respond to the invitation
if(!components()->groups->respondInvitation(userID, $groupID, $accept))
Rest_fatal_error(500, "An error occurred while trying to respond to membership invitation!");
//Success
return array("success" => "The response to the invitation was saved!");
}
/**
* Parse a GroupInfo object into an array for the API
*